6
嗨,大家好,我有一個奇怪的問題,我不知道我做錯了......問題的「中」在德爾福運營商
我有下面的代碼,請看看它的結束這就是它失敗我評論它...
var
IDH:PImageDosHeader;
INH:PImageNtHeaders;
ISH:PImageSectionHeader;
buf:Pointer;
FS:TFileStream;
ep,tmp1,tmp2:DWORD;
i:Word;
begin
if OpenDialog1.Execute then
begin
FS:=TFileStream.Create(OpenDialog1.FileName,fmOpenRead or fmShareDenyNone);
GetMem(buf,FS.size);
FS.Read(buf^,FS.Size);
FS.Free;
IDH:=PImageDosHeader(buf);
INH:=PImageNtHeaders(DWORD(buf) + DWORD(IDH^._lfanew));
ep:=INH^.OptionalHeader.AddressOfEntryPoint;
for i:=0 to INH^.FileHeader.NumberOfSections - 1 do
begin
ISH:=PimageSectionHeader(DWORD(INH) + sizeof(TImageNtHeaders) + i * sizeof(TImageSectionHeader));
tmp1:=ISH^.VirtualAddress;
tmp2:=ISH^.VirtualAddress + ISH^.Misc.VirtualSize;
ShowMessageFmt('%d -> %d .. %d',[ep,tmp1,tmp2]);
if ep in [tmp1..tmp2] then ShowMessage('Got it'); //This fails even if ep is in the defined interval. Why?
end;
end;
end;
我當然可以替換符合
if (ep>=tmp1) and (ep<=tmp2)
,但我想知道我做錯了。
現在明白了,非常感謝! – opc0de
@ opc0de:FWIW,我真的認爲編譯器應該說些什麼。至少,它應該給出警告...... –
也許在未來的版本:)) – opc0de