当然,所有的.exe都被加载到同一地址的。可以用一般的工具软件查看,这个并不难。 用这段代码可以看看某个进程的信息,那个参数是进程IDfunction TForm1.GetMemoryInfo(ProcessID: Cardinal): boolean; var P : Pointer; MemInfo : MEMORY_BASIC_INFORMATION; MemSize : LongWord; ProHWND : HWND; begin ProHWND := OpenProcess(PROCESS_ALL_ACCESS,false,ProcessID); P := nil; MemSize := SizeOf(MemInfo); while LongWord(p)<$80000000 do begin if MemSize<>VirtualQueryEx(ProHWND,P,MemInfo,MemSize) then break; RichEdit1.Lines.Add(Format('基址: %p %p 大小:%d 属性:%s', [MemInfo.BaseAddress,MemInfo.AllocationBase,MemInfo.RegionSize,GetStat(MemInfo.State)])); Inc(LongWord(P),MemInfo.RegionSize); end; Result := true; end;
这是那个 getstat 函数function TForm1.GetStat(nType: Cardinal): string; begin Result := ''; if nType = 0 then exit; case nType of MEM_COMMIT: Result := 'Commit'; MEM_FREE: Result := 'Free'; MEM_RESERVE: Result := 'Reserve'; end; end;
或者微软不愿意公开?
一般的.exe都是被转载到$00400000处,是通过内存映射实现的。所以文件大小其实和转载速度没什么太大的关系。
"一般的.exe都是被转载到$00400000处"
可以提供一般的手段加以验证吗?
你是说所有一般的exe都加载到同一地址吗?
用这段代码可以看看某个进程的信息,那个参数是进程IDfunction TForm1.GetMemoryInfo(ProcessID: Cardinal): boolean;
var
P : Pointer;
MemInfo : MEMORY_BASIC_INFORMATION;
MemSize : LongWord;
ProHWND : HWND;
begin
ProHWND := OpenProcess(PROCESS_ALL_ACCESS,false,ProcessID);
P := nil;
MemSize := SizeOf(MemInfo);
while LongWord(p)<$80000000 do
begin
if MemSize<>VirtualQueryEx(ProHWND,P,MemInfo,MemSize) then break;
RichEdit1.Lines.Add(Format('基址: %p %p 大小:%d 属性:%s',
[MemInfo.BaseAddress,MemInfo.AllocationBase,MemInfo.RegionSize,GetStat(MemInfo.State)]));
Inc(LongWord(P),MemInfo.RegionSize);
end;
Result := true;
end;
begin
Result := '';
if nType = 0 then exit;
case nType of
MEM_COMMIT: Result := 'Commit';
MEM_FREE: Result := 'Free';
MEM_RESERVE: Result := 'Reserve';
end;
end;