I did this in VS2005 and it worked alright as far as I understand it
Code:
DWORD hdrsum, chksum;
DWORD retval = MapFileAndCheckSum( "../debug/console.exe", &hdrsum, &chksum );
// retval = 0, hdrsum = 0, chksum = 0xdf68
HANDLE hFile = CreateFile( "../debug/console.exe", GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
DWORD size = GetFileSize( hFile, 0 ); // Don't need high-order DWORD
HANDLE hMap  = CreateFileMapping( hFile, 0, PAGE_READONLY, 0, 0, 0 );
LPVOID lpBaseAddr = MapViewOfFile( hMap, FILE_MAP_COPY, 0, 0, 0 );
IMAGE_NT_HEADERS* pHdrs = CheckSumMappedFile( lpBaseAddr, size, &hdrsum, &chksum );
// pHdrs = 0x3c00e8, hdrsum = 0, chksum = 0xdf68
UnmapViewOfFile( lpBaseAddr ); // Unchecked return...
CloseHandle( hMap );
CloseHandle( hFile );
Since all functions return success I can only presume that the original checksum is 0. In http://msdn.microsoft.com/en-us/libr...(v=VS.85).aspx it's stated
The linker computes the original checksum at link time, if you use the appropriate linker switch. For more details, see your linker documentation.
and, yes they were right... in my project the Set Checksum option was No so I changed it to Yes and voila!