diff options
Diffstat (limited to 'src/pal/src/include')
-rw-r--r-- | src/pal/src/include/pal/dbgmsg.h | 19 | ||||
-rw-r--r-- | src/pal/src/include/pal/map.hpp | 46 | ||||
-rw-r--r-- | src/pal/src/include/pal/module.h | 48 |
3 files changed, 103 insertions, 10 deletions
diff --git a/src/pal/src/include/pal/dbgmsg.h b/src/pal/src/include/pal/dbgmsg.h index d7219b2bd4..58ab25b92d 100644 --- a/src/pal/src/include/pal/dbgmsg.h +++ b/src/pal/src/include/pal/dbgmsg.h @@ -363,14 +363,17 @@ inline void ANALYZER_NORETURN AssertBreak() } } -#define ASSERT(...) \ -{ \ - __ASSERT_ENTER(); \ - if (output_file && dbg_master_switch) \ - { \ - DBG_printf(defdbgchan,DLI_ASSERT,TRUE,__FUNCTION__,__FILE__,__LINE__,__VA_ARGS__); \ - } \ - AssertBreak(); \ +#define ASSERT(...) \ +{ \ + if (PALIsInitialized()) \ + { \ + __ASSERT_ENTER(); \ + if (output_file && dbg_master_switch) \ + { \ + DBG_printf(defdbgchan,DLI_ASSERT,TRUE,__FUNCTION__,__FILE__,__LINE__,__VA_ARGS__); \ + } \ + AssertBreak(); \ + } \ } #define _ASSERT(expr) do { if (!(expr)) { ASSERT(""); } } while(0) diff --git a/src/pal/src/include/pal/map.hpp b/src/pal/src/include/pal/map.hpp index 7bcb20a404..16ee58ec43 100644 --- a/src/pal/src/include/pal/map.hpp +++ b/src/pal/src/include/pal/map.hpp @@ -77,15 +77,59 @@ extern "C" Map a PE format file into memory like Windows LoadLibrary() would do. Doesn't apply base relocations if the function is relocated. + There are two scenarios: + + - image could be preloaded and then MAPMapPEFile is called for it + - image is loaded with MAPMapPEFile + + In the first scenario, hFile and lpPreloadedBase are supposed to be NULL, and szPath and size - non-NULL. + In the second scenario, hFile and lpPreloadedBase are supposed to be non-NULL, and szPath and size - NULL. + + See coreclr_preload_assembly for further details. + Parameters: IN hFile - file to map + IN szPath - path to mapped file + OUT size - mapped virtual size + IN lpPreloadedBase - previously loaded base Return value: non-NULL - the base address of the mapped image NULL - error, with last error set. --*/ - void * MAPMapPEFile(HANDLE hFile); + void * MAPMapPEFile(HANDLE hFile, LPCSTR szPath, SIZE_T *size, LPVOID lpPreloadedBase); + + /*++ + MAPApplyBaseRelocationsPreloadedPEFile - + + Apply base relocations to preloaded image + + Parameters: + IN lpMappedImage - base address of preloaded image + IN virtualSize - virtual size of preloaded image + + Return value: + true - if relocations were applied successfully + false - otherwise + --*/ + + bool MAPApplyBaseRelocationsPreloadedPEFile(LPVOID lpMappedImage, SIZE_T virtualSize); + + /*++ + MAPUnmapPreloadedPEFile - + + Unmap a PE file + + Parameters: + IN lpMappedImage - address of mapped file + IN size - virtual size + + Return value: + returns TRUE if successful, FALSE otherwise + --*/ + + BOOL MAPUnmapPreloadedPEFile(LPVOID lpMappedImage, SIZE_T size); /*++ Function : diff --git a/src/pal/src/include/pal/module.h b/src/pal/src/include/pal/module.h index 66ac23834a..ee5d000d63 100644 --- a/src/pal/src/include/pal/module.h +++ b/src/pal/src/include/pal/module.h @@ -51,6 +51,20 @@ typedef struct _MODSTRUCT struct _MODSTRUCT *prev; } MODSTRUCT; +/*++ + LOADFindPreloadedPEFile - + + Find image in list of preloaded + +Parameters: + IN wszPath - path to mapped file + +Return value: + non-NULL - the base address of the mapped image + NULL - image is not in the list of preloaded. +--*/ + +void * LOADFindPreloadedPEFile(LPCWSTR wszPath); /*++ Function : @@ -145,12 +159,14 @@ Abstract Parameters: IN hFile - The file to load + IN wszPath - File path + OUT isPreloaded - Flag whether pefile was preloaded Return value: A valid base address if successful. 0 if failure --*/ -void * PAL_LOADLoadPEFile(HANDLE hFile); +void * PAL_LOADLoadPEFile(HANDLE hFile, LPCWSTR wszPath, BOOL *isPreloaded); /*++ PAL_LOADUnloadPEFile @@ -167,6 +183,36 @@ Return value: BOOL PAL_LOADUnloadPEFile(void * ptr); /*++ +Function: + PAL_LOADPreloadPEFile + +Abstract + Preloads a PE file into memory. Properly maps all of the sections in the PE file. Returns a pointer to the + loaded base. + +Parameters: + IN szPath - path of file to load + +Return value: + A valid base address if successful. + 0 if failure +--*/ +void * +PAL_LOADPreloadPEFile(LPCSTR szPath); + +/*++ + PAL_LOADUnloadPreloadedPEFiles + + Unload all PE files that were loaded by PAL_LOADPreloadPEFile(). + +Return value: + TRUE - success + FALSE - failure +--*/ +BOOL +PAL_LOADUnloadPreloadedPEFiles(); + +/*++ LOADInitializeCoreCLRModule Run the initialization methods for CoreCLR module. |