imagehlp: Check for 64-bit PE files in CheckSumMappedFile.
This commit is contained in:
parent
b277012765
commit
ba5a86e349
|
@ -89,11 +89,14 @@ PIMAGE_NT_HEADERS WINAPI CheckSumMappedFile(
|
|||
LPVOID BaseAddress, DWORD FileLength,
|
||||
LPDWORD HeaderSum, LPDWORD CheckSum)
|
||||
{
|
||||
PIMAGE_NT_HEADERS Header;
|
||||
IMAGE_DOS_HEADER *dos = (IMAGE_DOS_HEADER *) BaseAddress;
|
||||
PIMAGE_NT_HEADERS32 Header32;
|
||||
PIMAGE_NT_HEADERS64 Header64;
|
||||
DWORD *ChecksumFile;
|
||||
DWORD CalcSum;
|
||||
DWORD HdrSum;
|
||||
|
||||
FIXME("(%p, %d, %p, %p): stub\n",
|
||||
TRACE("(%p, %d, %p, %p)\n",
|
||||
BaseAddress, FileLength, HeaderSum, CheckSum
|
||||
);
|
||||
|
||||
|
@ -101,8 +104,25 @@ PIMAGE_NT_HEADERS WINAPI CheckSumMappedFile(
|
|||
BaseAddress,
|
||||
(FileLength + 1) / sizeof(WORD));
|
||||
|
||||
Header = RtlImageNtHeader(BaseAddress);
|
||||
HdrSum = Header->OptionalHeader.CheckSum;
|
||||
if (dos->e_magic != IMAGE_DOS_SIGNATURE)
|
||||
return NULL;
|
||||
|
||||
Header32 = (IMAGE_NT_HEADERS32 *)((char *)dos + dos->e_lfanew);
|
||||
|
||||
if (Header32->Signature != IMAGE_NT_SIGNATURE)
|
||||
return NULL;
|
||||
|
||||
if (Header32->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
|
||||
ChecksumFile = &Header32->OptionalHeader.CheckSum;
|
||||
else if (Header32->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC)
|
||||
{
|
||||
Header64 = (IMAGE_NT_HEADERS64 *)Header32;
|
||||
ChecksumFile = &Header64->OptionalHeader.CheckSum;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
|
||||
HdrSum = *ChecksumFile;
|
||||
|
||||
/* Subtract image checksum from calculated checksum. */
|
||||
/* fix low word of checksum */
|
||||
|
@ -129,9 +149,9 @@ PIMAGE_NT_HEADERS WINAPI CheckSumMappedFile(
|
|||
CalcSum += FileLength;
|
||||
|
||||
*CheckSum = CalcSum;
|
||||
*HeaderSum = Header->OptionalHeader.CheckSum;
|
||||
*HeaderSum = *ChecksumFile;
|
||||
|
||||
return Header;
|
||||
return (PIMAGE_NT_HEADERS) Header32;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
|
Loading…
Reference in New Issue