diff options
Diffstat (limited to 'src/ToolBox/superpmi/superpmi-shim-counter/superpmi-shim-counter.cpp')
-rw-r--r-- | src/ToolBox/superpmi/superpmi-shim-counter/superpmi-shim-counter.cpp | 112 |
1 files changed, 54 insertions, 58 deletions
diff --git a/src/ToolBox/superpmi/superpmi-shim-counter/superpmi-shim-counter.cpp b/src/ToolBox/superpmi/superpmi-shim-counter/superpmi-shim-counter.cpp index ee47dd8c44..f838ea683f 100644 --- a/src/ToolBox/superpmi/superpmi-shim-counter/superpmi-shim-counter.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-counter/superpmi-shim-counter.cpp @@ -17,12 +17,12 @@ #include "spmiutil.h" #include "jithost.h" -HMODULE g_hRealJit = 0; //We leak this currently (could do the proper shutdown in process_detach) -WCHAR* g_realJitPath = nullptr; //We leak this (could do the proper shutdown in process_detach) -WCHAR* g_logPath = nullptr; //Again, we leak this one too... -char* g_logFilePath = nullptr; //We *don't* leak this, hooray! -WCHAR* g_HomeDirectory = nullptr; -WCHAR* g_DefaultRealJitPath = nullptr; +HMODULE g_hRealJit = 0; // We leak this currently (could do the proper shutdown in process_detach) +WCHAR* g_realJitPath = nullptr; // We leak this (could do the proper shutdown in process_detach) +WCHAR* g_logPath = nullptr; // Again, we leak this one too... +char* g_logFilePath = nullptr; // We *don't* leak this, hooray! +WCHAR* g_HomeDirectory = nullptr; +WCHAR* g_DefaultRealJitPath = nullptr; void SetDefaultPaths() { @@ -33,7 +33,7 @@ void SetDefaultPaths() if (g_DefaultRealJitPath == nullptr) { - size_t len = wcslen(g_HomeDirectory) + 1 + wcslen(DEFAULT_REAL_JIT_NAME_W) + 1; + size_t len = wcslen(g_HomeDirectory) + 1 + wcslen(DEFAULT_REAL_JIT_NAME_W) + 1; g_DefaultRealJitPath = new WCHAR[len]; wcscpy_s(g_DefaultRealJitPath, len, g_HomeDirectory); wcscat_s(g_DefaultRealJitPath, len, DIRECTORY_SEPARATOR_STR_W); @@ -67,52 +67,50 @@ void SetLogFilePath() } } -extern "C" -BOOL +extern "C" BOOL #ifndef FEATURE_PAL -APIENTRY + APIENTRY #endif // !FEATURE_PAL -DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) + DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { - case DLL_PROCESS_ATTACH: + case DLL_PROCESS_ATTACH: #ifdef FEATURE_PAL - if (0 != PAL_InitializeDLL()) - { - fprintf(stderr, "Error: Fail to PAL_InitializeDLL\n"); - exit(1); - } + if (0 != PAL_InitializeDLL()) + { + fprintf(stderr, "Error: Fail to PAL_InitializeDLL\n"); + exit(1); + } #endif // FEATURE_PAL - Logger::Initialize(); - SetLogFilePath(); - Logger::OpenLogFile(g_logFilePath); - break; + Logger::Initialize(); + SetLogFilePath(); + Logger::OpenLogFile(g_logFilePath); + break; - case DLL_PROCESS_DETACH: - Logger::Shutdown(); + case DLL_PROCESS_DETACH: + Logger::Shutdown(); - delete[] g_logFilePath; - g_logFilePath = nullptr; + delete[] g_logFilePath; + g_logFilePath = nullptr; - break; + break; - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - break; + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + break; } return TRUE; } // Exported via def file -extern "C" -void __stdcall jitStartup(ICorJitHost* host) +extern "C" void __stdcall jitStartup(ICorJitHost* host) { SetDefaultPaths(); SetLibName(); - //Load Library + // Load Library if (g_hRealJit == 0) { g_hRealJit = ::LoadLibraryW(g_realJitPath); @@ -136,48 +134,47 @@ void __stdcall jitStartup(ICorJitHost* host) pnjitStartup(g_ourJitHost); } -//Exported via def file -extern "C" -ICorJitCompiler* __stdcall getJit() +// Exported via def file +extern "C" ICorJitCompiler* __stdcall getJit() { - DWORD dwRetVal = 0; - PgetJit pngetJit; - interceptor_ICJC *pJitInstance = nullptr; - ICorJitCompiler *tICJI = nullptr; + DWORD dwRetVal = 0; + PgetJit pngetJit; + interceptor_ICJC* pJitInstance = nullptr; + ICorJitCompiler* tICJI = nullptr; SetDefaultPaths(); SetLibName(); SetLogPath(); - //Load Library - if(g_hRealJit == 0) + // Load Library + if (g_hRealJit == 0) { g_hRealJit = ::LoadLibraryW(g_realJitPath); - if(g_hRealJit == 0) + if (g_hRealJit == 0) { LogError("getJit() - LoadLibrary failed to load '%ws' (0x%08x)", g_realJitPath, ::GetLastError()); return nullptr; } } - //get the required entrypoints + // get the required entrypoints pngetJit = (PgetJit)::GetProcAddress(g_hRealJit, "getJit"); - if(pngetJit == 0) + if (pngetJit == 0) { LogError("getJit() - GetProcAddress 'getJit' failed (0x%08x)", ::GetLastError()); return nullptr; } tICJI = pngetJit(); - if(tICJI == nullptr) + if (tICJI == nullptr) { LogError("getJit() - pngetJit gave us null"); return nullptr; } - pJitInstance = new interceptor_ICJC(); + pJitInstance = new interceptor_ICJC(); pJitInstance->original_ICorJitCompiler = tICJI; - pJitInstance->mcs = new MethodCallSummarizer(g_logPath); + pJitInstance->mcs = new MethodCallSummarizer(g_logPath); if (g_ourJitHost != nullptr) { g_ourJitHost->setMethodCallSummarizer(pJitInstance->mcs); @@ -185,42 +182,41 @@ ICorJitCompiler* __stdcall getJit() return pJitInstance; } -//Exported via def file -extern "C" -void __stdcall sxsJitStartup(CoreClrCallbacks const & original_cccallbacks) +// Exported via def file +extern "C" void __stdcall sxsJitStartup(CoreClrCallbacks const& original_cccallbacks) { PsxsJitStartup pnsxsJitStartup; SetDefaultPaths(); SetLibName(); - //Load Library - if(g_hRealJit == 0) + // Load Library + if (g_hRealJit == 0) { g_hRealJit = ::LoadLibraryW(g_realJitPath); - if(g_hRealJit == 0) + if (g_hRealJit == 0) { LogError("sxsJitStartup() - LoadLibrary failed to load '%ws' (0x%08x)", g_realJitPath, ::GetLastError()); return; } } - //get entry point + // get entry point pnsxsJitStartup = (PsxsJitStartup)::GetProcAddress(g_hRealJit, "sxsJitStartup"); - if(pnsxsJitStartup == 0) + if (pnsxsJitStartup == 0) { LogError("sxsJitStartup() - GetProcAddress 'sxsJitStartup' failed (0x%08x)", ::GetLastError()); return; } - //Setup CoreClrCallbacks and call sxsJitStartup - original_CoreClrCallbacks = new CoreClrCallbacks(); + // Setup CoreClrCallbacks and call sxsJitStartup + original_CoreClrCallbacks = new CoreClrCallbacks(); original_CoreClrCallbacks->m_hmodCoreCLR = original_cccallbacks.m_hmodCoreCLR; original_CoreClrCallbacks->m_pfnIEE = original_cccallbacks.m_pfnIEE; original_CoreClrCallbacks->m_pfnGetCORSystemDirectory = original_cccallbacks.m_pfnGetCORSystemDirectory; original_CoreClrCallbacks->m_pfnGetCLRFunction = original_cccallbacks.m_pfnGetCLRFunction; - CoreClrCallbacks *temp = new CoreClrCallbacks(); + CoreClrCallbacks* temp = new CoreClrCallbacks(); temp->m_hmodCoreCLR = original_cccallbacks.m_hmodCoreCLR; temp->m_pfnIEE = IEE_t; |