Hola chicos tengo un problema extraño y no sé dónde estoy haciendo mal ...Problema con "en" operador en Delphi
he el siguiente código busque al final de la misma que es donde que no les comentaba que ...
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;
Por supuesto que puedo reemplazar esa línea con
if (ep>=tmp1) and (ep<=tmp2)
pero yo quiero saber lo que estoy haciendo mal.
¡Lo tengo ahora, muchas gracias! – opc0de
@ opc0de: FWIW, realmente creo que el compilador debería decir algo al respecto. Por lo menos, debería dar una advertencia ... –
Quizás en las versiones futuras :)) – opc0de