MapFileAndCheckSumA

The MapFileAndCheckSumA function computes the checksum of an image file.

ULONG MapFileAndCheckSumA(

IN LPSTR Filename,  
OUT LPDWORD HeaderSum,  
OUT LPDWORD CheckSum  
);  

Parameters

Filename

The filename of the file for which the checksum is to be computed.

HeaderSum

A pointer to a variable that receives the original checksum from the image file, or zero if there is an error.

CheckSum

A pointer to the variable that receives the computed checksum.

Return Values

If the function succeeds, the return value is CHECKSUM_SUCCESS.

If the function fails, then the return value is one of the following:

Value Meaning
CHECKSUM_OPEN_FAILURE Could not open the file.
CHECKSUM_MAP_FAILURE Could not create the file mapping for the file.
CHECKSUM_MAPVIEW_FAILURE Could not map a view of the file.
CHECKSUM_UNICODE_FAILURE Could not convert the filename to UNICODE.

Remarks

A new checksum for the file is computed and returned in the CheckSum parameter. This function is used by any application that creates or modifies an executable image. Checksums are required for Windows NT kernel mode drivers and some system DLLs. The Win32 linker computes the original checksum at link time, if the linker switch for checksumming is turned on. It is recommended that all images have valid checksums.