MapFileAndCheckSum Function
Computes the checksum of the specified file.
DWORD MapFileAndCheckSum( __in PTSTR Filename, __out PDWORD HeaderSum, __out PDWORD CheckSum );
Parameters
- Filename
-
The file name 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 a variable that receives the computed checksum.
Return Value
If the function succeeds, the return value is CHECKSUM_SUCCESS (0).
If the function fails, the return value is one of the following.
Return code/value | Description |
---|---|
CHECKSUM_MAP_FAILURE |
Could not map the file. |
CHECKSUM_MAPVIEW_FAILURE |
Could not map a view of the file. |
CHECKSUM_OPEN_FAILURE |
Could not open the file. |
CHECKSUM_UNICODE_FAILURE |
Could not convert the file name to Unicode. |
Remarks
The MapFileAndCheckSum function computes a new checksum for the file and returns it in the CheckSum parameter. This function is used by any application that creates or modifies an executable image. Checksums are required for kernel-mode drivers and some system DLLs. The linker computes the original checksum at link time, if you use the appropriate linker switch. For more details, see your linker documentation.
It is recommended that all images have valid checksums. It is the caller's responsibility to place the newly computed checksum into the mapped image and update the on-disk image of the file.
All ImageHlp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more than one thread to this function.
Requirements
Client |
Requires Windows Vista, Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95. |
---|---|
Server |
Requires Windows Server 2008, Windows Server 2003, Windows 2000 Server, or Windows NT Server. |
Header |
Declared in Imagehlp.h. |
Library |
Use Imagehlp.lib. |
DLL |
Requires Imagehlp.dll. |
Unicode |
Implemented as MapFileAndCheckSumW (Unicode) and MapFileAndCheckSumA (ANSI). |
See Also
ImageHlp Functions
CheckSumMappedFile
Send comments about this topic to Microsoft
Build date: 9/25/2007
© 2007 Microsoft Corporation. All rights reserved.