-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathmain.cpp
More file actions
65 lines (55 loc) · 1.16 KB
/
Copy pathmain.cpp
File metadata and controls
65 lines (55 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <Windows.h>
#include <cstdio>
#include <exception>
#include "UniDumperSdk.h"
namespace
{
HMODULE gModule = nullptr;
DWORD WINAPI RunExample(LPVOID)
{
AllocConsole();
FILE* consoleStream = nullptr;
freopen_s(&consoleStream, "CONOUT$", "w", stdout);
if (!UniResolver.Setup())
{
std::printf("UniResolver setup failed.\n");
}
else
{
try
{
std::printf(
"Unity version: %s\n",
UnityEngine::Application::get_unityVersion().c_str());
std::printf(
"Game version: %s\n",
UnityEngine::Application::get_version().c_str());
}
catch (const std::exception& exception)
{
std::printf("Managed call failed: %s\n", exception.what());
}
UniResolver.Destroy();
}
if (consoleStream != nullptr)
{
std::fclose(consoleStream);
}
FreeConsole();
FreeLibraryAndExitThread(gModule, 0U);
}
}
BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID)
{
if (reason == DLL_PROCESS_ATTACH)
{
gModule = module;
DisableThreadLibraryCalls(module);
if (HANDLE thread = CreateThread(nullptr, 0U, RunExample, nullptr, 0U, nullptr);
thread != nullptr)
{
CloseHandle(thread);
}
}
return TRUE;
}