MapAndLoad Function

Debug Help Library

MapAndLoad Function

Maps an image and preloads data from the mapped file.

BOOL MapAndLoad(
  __in          PSTR ImageName,
  __in          PSTR DllPath,
  __out         PLOADED_IMAGE LoadedImage,
  __in          BOOL DotDll,
  __in          BOOL ReadOnly



The file name of the image (executable file or DLL) that is loaded.


The path used to locate the image if the name provided cannot be found. If this parameter is NULL, then the search path rules set using the SearchPath function apply.


A pointer to a LOADED_IMAGE structure that receives information about the image after it is loaded.


The default extension to be used if the image name does not contain a file extension. If the value is TRUE, a .DLL extension is used. If the value is FALSE, then an .EXE extension is used.


The access mode. If this value is TRUE, the file is mapped for read-access only. If the value is FALSE, the file is mapped for read and write access.

Return Value

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.


The MapAndLoad function maps an image and preloads data from the mapped file. The corresponding function, UnMapAndLoad, must be used to deallocate all resources that are allocated by the MapAndLoad function.

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.



Requires Windows Vista, Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95.


Requires Windows Server 2008, Windows Server 2003, Windows 2000 Server, or Windows NT Server.


Declared in Imagehlp.h.


Use Imagehlp.lib.


Requires Imagehlp.dll.

See Also

ImageHlp FunctionsLOADED_IMAGE

Send comments about this topic to Microsoft

Build date: 9/25/2007

© 2007 Microsoft Corporation. All rights reserved.