MCPcopy Create free account
hub / github.com/DrewKestell/BloogBot / ThreadMain

Function ThreadMain

Loader/dllmain.cpp:55–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53#define MB(s) MessageBoxW(NULL, s, NULL, MB_OK);
54
55unsigned __stdcall ThreadMain(void* pParam)
56{
57 AllocConsole();
58 freopen("CONOUT$", "w", stdout);
59
60#if _DEBUG
61 std::cout << std::string("Attach a debugger now to WoW.exe if you want to debug Loader.dll. Waiting 10 seconds...") << std::endl;
62
63 HANDLE hEvent = CreateEvent(nullptr, TRUE, FALSE, L"MyDebugEvent");
64 WaitForSingleObject(hEvent, 10000); // Wait for 10 seconds
65 bool isDebuggerAttached = IsDebuggerPresent() != FALSE;
66
67 if (isDebuggerAttached)
68 {
69 std::cout << std::string("Debugger found.") << std::endl;
70 }
71 else
72 {
73 std::cout << std::string("Debugger not found.") << std::endl;
74 }
75
76 SetEvent(hEvent);
77 CloseHandle(hEvent);
78#endif
79
80
81 HRESULT hr = CLRCreateInstance(CLSID_CLRMetaHostPolicy, IID_ICLRMetaHostPolicy, (LPVOID*)&g_pMetaHost);
82
83 if (FAILED(hr))
84 {
85 MB(L"Could not create instance of ICLRMetaHost");
86 return 1;
87 }
88
89 //hr = g_pMetaHost->GetRuntime(L"v4.0.30128", IID_ICLRRuntimeInfo, (LPVOID*)&g_pRuntimeInfo);
90
91 // Use this if your lazy. Just make sure to change the ICLRMetaHost
92 // to an ICLRMetaHostPolicy instead.
93 DWORD pcchVersion = 0;
94 DWORD dwConfigFlags = 0;
95
96 //wchar_t tmpbuff[1024];
97 //wsprintf(tmpbuff, L"dllLocation: %s pcchVersion: %d dwConfigFlags: %d g_pMetaHost: 0x%lx", dllLocation, pcchVersion, dwConfigFlags, g_pMetaHost);
98 //MB(tmpbuff);
99
100 hr = g_pMetaHost->GetRequestedRuntime(METAHOST_POLICY_HIGHCOMPAT,
101 dllLocation, NULL,
102 NULL, &pcchVersion,
103 NULL, NULL,
104 &dwConfigFlags,
105 IID_ICLRRuntimeInfo,
106 (LPVOID*)&g_pRuntimeInfo);
107
108 if (FAILED(hr))
109 {
110 if (hr == E_POINTER)
111 {
112 MB(L"Could not get an instance of ICLRRuntimeInfo -- E_POINTER");

Callers

nothing calls this directly

Calls 1

StartMethod · 0.45

Tested by

no test coverage detected