最近研究文件的装载与执行原理, 正好看到这个函数可以加载可执行文件并且使用PLOADED_IMAGE结构来保存内容.\
MapAndLoad
The MapAndLoad function maps an image and preloads data from the mapped file.
BOOL MapAndLoad( PSTR ImageName, PSTR DllPath, PLOADED_IMAGE LoadedImage, BOOL DotDll, BOOL ReadOnly );
Parameters
-
ImageName
- [in] Pointer to a null-terminated string that specifies the name of the image that is loaded. DllPath
- [in] Pointer to a null-terminated string that specifies the path used to locate the image if the name provided cannot be found. If NULL is used, then the search path rules set forth in the SearchPath function apply. LoadedImage
- [out] Pointer to a LOADED_IMAGE structure that receives information about the image after it is loaded. DotDll
- [in] 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. ReadOnly
- [in] 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 Values
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.