function rav2offset(nthd:pimagentheaders;rva:cardinal):integer;stdcall;
var
psectionh:pimagesectionheader;
secnum,i:integer;
begin
result:=0;
secnum:=nthd^.FileHeader.NumberOfSections;
psectionh:=pimagesectionheader(dword(nthd)+sizeof(image_section_header));
for i:=0 to secnum-1 do begin
if (psectionh.VirtualAddress<=rva) and (rva<(psectionh.VirtualAddress+psectionh.SizeOfRawData)) then
result:=rva-psectionh.VirtualAddress+psectionh.PointerToRawData;
end;
end;