Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function RAW2VA(pFile: PByte; RAW: DWORD): DWORD;
- var
- i : integer;
- IDH : PImageDosHeader;
- INTH: PImageNtHeaders;
- ISH : PImageSectionHeader;
- begin
- Result := $FFFFFFFF;
- if pFile <> nil then
- try
- IDH := PImageDosHeader(pFile);
- INTH := PImageNtHeaders(DWORD(pFile) + IDH^._lfanew);
- if ((LoWord(IDH^.e_magic) <> $5A4D {MZ})
- or (LoWord(INTH^.Signature) <> $4550 {PE})) then
- Exit;
- ISH := PImageSectionHeader(DWORD(INTH) + SizeOf(TImageNtHeaders));
- for i := 0 to INTH^.FileHeader.NumberOfSections - 1 do
- begin
- if (RAW >= ISH^.PointerToRawData)
- and(RAW <= (ISH^.PointerToRawData+ISH^.SizeOfRawData)) then
- begin
- Result := ISH^.VirtualAddress + RAW - ISH^.PointerToRawData + INTH^.OptionalHeader.ImageBase;
- Break;
- end;
- ISH := PImageSectionHeader(DWORD(ISH) + SizeOf(TImageSectionHeader));
- end;
- except
- Result := $FFFFFFFF;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement