读写另一EXE的内存
procedure TfrmMain.tmrChangeServerNameTimer(Sender: TObject);
function GetProcessID(FileName: string = ''): TProcessEntry32;
var
Ret: BOOL;
s: string;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, );
FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
Ret := Process32First(FSnapshotHandle, FProcessEntry32);
while Ret do
begin
s := ExtractFileName(FProcessEntry32.szExeFile);
if (AnsiCompareText(Trim(s),Trim(FileName))=) and (FileName <> '') then begin
result := FProcessEntry32;
break;
end;
Ret := Process32Next(FSnapshotHandle, FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
end;
var
FProcessEntry32: TProcessEntry32;
ProcessID: integer;
ProcessHandle: THandle;
lpBuffer: PChar;
nSize: DWORD;
lpNumberOfBytes: DWORD;
mbi_thunk:TMemoryBasicInformation;
dwOldProtect:dword;
const
LeftAddress = $02370C68;
RightAddress1 = $02370C74;
RightAddress2 = $02370C84;
// ServerName = '京信三国';
begin
FProcessEntry32 := GetProcessID('aLogin.exe');
if FProcessEntry32.th32ProcessID = then exit;
ProcessID := FProcessEntry32.th32ProcessID;
ProcessHandle := OpenProcess(PROCESS_ALL_ACCESS, false, ProcessID);
//---------------写left
lpBuffer := PChar(GB2Big5('01.' + ServerName));
nSize:= ; //N是数据长度
//写LeftAddress数据
VirtualQueryEx(ProcessHandle,Pointer(LeftAddress),mbi_thunk, sizeof(TMemoryBasicInformation));
VirtualProtectEx(ProcessHandle,Pointer(LeftAddress),nSize,PAGE_EXECUTE_READWRITE,mbi_thunk.Protect);
WriteProcessMemory(ProcessHandle, Pointer(LeftAddress), lpBuffer, nSize, lpNumberOfBytes);
VirtualProtectEx(ProcessHandle,Pointer(LeftAddress), nSize, mbi_thunk.Protect,dwOldProtect);
//---------------写right
lpBuffer := PChar(GB2Big5(ServerName)); //要写的内容
nSize:= ; //数据长度
//写RightAddress1数据
VirtualQueryEx(ProcessHandle,Pointer(RightAddress1),mbi_thunk, sizeof(TMemoryBasicInformation));
VirtualProtectEx(ProcessHandle,Pointer(RightAddress1),nSize,PAGE_EXECUTE_READWRITE,mbi_thunk.Protect);
WriteProcessMemory(ProcessHandle, Pointer(RightAddress1), lpBuffer, nSize, lpNumberOfBytes);
VirtualProtectEx(ProcessHandle,Pointer(RightAddress1), nSize, mbi_thunk.Protect,dwOldProtect);
//写RightAddress2数据
VirtualQueryEx(ProcessHandle,Pointer(RightAddress2),mbi_thunk, sizeof(TMemoryBasicInformation));
VirtualProtectEx(ProcessHandle,Pointer(RightAddress2),nSize,PAGE_EXECUTE_READWRITE,mbi_thunk.Protect);
WriteProcessMemory(ProcessHandle, Pointer(RightAddress2), lpBuffer, nSize, lpNumberOfBytes);
VirtualProtectEx(ProcessHandle,Pointer(RightAddress2), nSize, mbi_thunk.Protect,dwOldProtect);
//读内容,确定是否修改成功
lpBuffer := AllocMem(nSize);
ReadProcessMemory(ProcessHandle, Pointer(RightAddress2), lpBuffer, nSize, lpNumberOfBytes);
if ServerName = Big52GB(lpBuffer) then begin
Caption := '内存内容为:' + Big52GB(lpBuffer);
tmrChangeServerName.Enabled := False;
end;
CloseHandle(ProcessHandle);
// Memo1.Lines.Add(Big52GB(lpBuffer));
//MEMO显示信息
// Memo1.Lines.Clear;
// memo1.lines.add('Process ID ' + IntToHex(FProcessEntry32.th32ProcessID, ));
// memo1.lines.Add('File name ' + FProcessEntry32.szExeFile);
// memo1.Lines.Add('Process Handle ' + intTohex(ProcessHandle, ));
// Memo1.Lines.Add('虚拟内存中的数据:');
end;
读写另一EXE的内存的更多相关文章
- 解决服务器上 w3wp.exe 和 sqlservr.exe 的内存占用率居高不下的方案
SQL Server是如何使用内存 最大的开销一般是用于数据缓存,如果内存足够,它会把用过的数据和觉得你会用到的数据统统扔到内存中,直到内存不足的时候,才把命中率低的数据给清掉.所以一般我们在看sta ...
- 使用PageHeap.EXE或GFlags.EXE检查内存越界错误 (转)
2011-05-27 20:19 290人阅读 评论(0) 收藏 举报 microsoftdebuggingstructureoutputimagefile 必先利其器之一:使用PageHeap.EX ...
- 使用PageHeap.EXE或GFlags.EXE检查内存越界错误
必先利其器之一:使用PageHeap.EXE或GFlags.EXE检查内存越界错误 Article last modified on 2002-6-3 ------------------------ ...
- win7 64位的 svchost.exe 占用内存过大的问题
svchost.exe 是用来启动系统服务的,所以某个 svchost.exe 占用内存过大,可能就是它启动的那个服务占用内存过大,所以只要停止并禁用那个服务就行了. 一般来说占用内存最大的服务是 S ...
- win7的svchost.exe占用内存过高如何解决
方法/步骤 1 在我的电脑上点击鼠标右键,选择[管理] 步骤阅读 2 选择右侧[服务和应用程序]下的[服务]选项 步骤阅读 3 找到名称我Superfetch的服务,双击鼠标左键. 步骤阅读 4 选择 ...
- powershell加载EXE进内存运行
当实战中我们想在目标上运行一些相当复杂的功能,这些功能常是 EXE 文件的一部分.我不想直接在目标上放置一个二进制文件,因为这样可能会触发反病毒机制.一个很好的思路就是将二进制文件嵌入到 Powers ...
- delphi 实现两个exe文件共享内存映像的代码
创建内存映像的程序 ------------------------------------------------------------------------------------------ ...
- 两个exe共享内存数据
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...
- svchost.exe 占用内存过多
http://www.tomshardware.com/forum/20583-63-svchost-netsvcs-speed By Lokesh Chandra: Just Go to Contr ...
随机推荐
- HTTP Message Handlers in ASP.NET Web API
https://docs.microsoft.com/en-us/aspnet/web-api/overview/advanced/http-message-handlers A message ha ...
- js 执行跨域刷新页面
主要代码: 注意这段代码 是子页面中添加的也就是弹出的那个页面刷新父页面 <script type="text/javascript"> function shuaxi ...
- eclipse设置控制台字体大小
步骤如下
- SQL编码规范
1 目的 为了保证所每个项目组编写出的程序都符合相同的规范,便于理解和维护,便于检查.减少出错概率,有助于成员间交流,保证一致性.统一性而建立的SQL程序编码规范. 2 范 ...
- 分享:SQL优化器简介
SQL优化是我们经常会遇到的问题,无论你是专职的数据分析人员还是全栈开发大神或者是CURD搬运工. 我们在工作中经常会听到这样的声音:“查询慢?加个索引吧”.虽然加索引并不一定能解决问题,但是这体现了 ...
- BZOJ 1835 [ZJOI2010]base 基站选址:线段树优化dp
传送门 题意 有 $ n $ 个村庄在一排直线上,现在要建造不超过 $ K $ 个通讯基站,基站只能造在村庄处. 第 $ i $ 个村庄距离第 $ 1 $ 个村庄的距离为 $ D_i $ .在此建造基 ...
- 分享知识-快乐自己:Ajax 跨域请求处理
<%-- Created by IntelliJ IDEA. User: asus Date: 2019/1/24 Time: 15:57 To change this template use ...
- 解决:actual_tessdata_num_entries_ <= TESSDATA_NUM_ENTRIES:Error:Assert failed:in file ..\..\ccutil\tessdatamanager.cp p, line 50
在玩tesseract时,发现如下报错: 这个是因为Tesseract-OCR的版本和chi_sim.traindata字库版本不匹配,由于我的Tesseract-OCR是3.02.02,去googl ...
- java String转Long两种方法区别
第一种:包装类型:Byte,Integer,Short,Long,Boolean,Character,Float,Double等8种 Long.valueOf("String")返 ...
- 亚马逊EC2
亚马逊EC2编辑 本词条缺少信息栏,补充相关内容使词条更完整,还能快速升级,赶紧来编辑吧! 亚马逊弹性计算云(EC2,Elastic Compute Cloud)是一个让使用者可以租用云端电脑运行所需 ...