Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var
- hFile: DWORD;
- hMapping: DWORD;
- dwSize: DWORD;
- pFile: Pointer;
- IDH: TImageDosHeader;
- INH: TImageNtHeaders;
- ISH: TImageSectionHeader;
- bByte: Byte;
- begin
- hFile := CreateFile('PE.exe', GENERIC_READ or GENERIC_WRITE, FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0);
- if hFile <> INVALID_HANDLE_VALUE then
- begin
- dwSize := GetFileSize(hFile, nil);
- if dwSize > 0 then
- begin
- hMapping := CreateFileMapping(hFile, nil, PAGE_READWRITE, 0, dwSize, 0);
- if hMapping <> 0 then
- begin
- pFile := MapViewOfFile(hMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0);
- if pFile <> nil then
- begin
- IDH := TImageDosHeader(pFile^);
- if IDH.e_magic = IMAGE_DOS_SIGNATURE then
- begin
- INH := TImageNtHeaders(Pointer(DWORD(pFile) + IDH._lfanew)^);
- if INH.Signature = IMAGE_NT_SIGNATURE then
- begin
- ISH := TImageSectionHeader(Pointer(DWORD(pFile) + IDH._lfanew + 248)^);
- bByte := PByte(Pointer(DWORD(pFile) + ISH.PointerToRawData))^;
- MessageBox(0, PChar(IntToHex(bByte, 4)), nil, 0);
- //PByte(pFile)^ := 0;
- end;
- UnmapViewOfFile(pFile);
- end;
- end;
- end;
- end
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement