使用此代码,我猜扫描速度更快,但扫描始终返回相同的地址。
例如:
00123456
00124567
00135478
00145893
00123456 //start repeat
00124567
00135478
00145893
00123456 //start repeat
00124567
00135478
00145893
这是我的程序:
procedure SCANBYTE(value: integer);
var
lpflOldProtect: dword;
s: size_t;
mbi: MEMORY_BASIC_INFORMATION;
SI: SYSTEM_INFO;
lpStartAddress, lpStopAddress: dword;
addr: dword;
i: dword;
begin
GetSystemInfo(si);
lpStartAddress := dword(SI.lpMinimumApplicationAddress);
lpStopAddress := dword(SI.lpMaximumApplicationAddress);
for addr := lpStartAddress to lpStopAddress do begin
S:= VirtualQuery(Pointer(addr), MBI, SizeOf(MEMORY_BASIC_INFORMATION));
if (S=SizeOf(MEMORY_BASIC_INFORMATION)) and (MBI.State = MEM_COMMIT) and (MBI.Type_9 = MEM_PRIVATE) and (MBI.RegionSize>0) and (MBI.Protect = PAGE_READWRITE) then begin
for i := dword(MBI.BaseAddress) to (dword(MBI.BaseAddress) + dword(MBI.RegionSize)) - 4096 do begin
if value = PBYTE(i)^ then ListBox1.Items.Add(IntToHex(i,8));
end;
end;
end;
end;
我猜问题出在最后一个 FOR 循环:
(...)
for i := dword(MBI.BaseAddress) to (dword(MBI.BaseAddress) + dword(MBI.RegionSize)) - 4096 do begin
(...)
但我真的不知道..我该如何解决这个问题?