@@ -24,6 +24,24 @@ typedef struct napi_env__* napi_env;
2424typedef enum { napi_ok } napi_status;
2525static napi_status (*napi_get_uv_event_loop)(napi_env env, struct uv_loop_s ** loop);
2626
27+ #if defined(_WIN32)
28+ #define WIN32_LEAN_AND_MEAN
29+ #include < windows.h>
30+
31+ extern " C" void app_init (const char *path)
32+ {
33+ SetProcessDpiAwarenessContext (DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
34+ }
35+
36+ extern " C" void app_activate (void )
37+ {
38+ }
39+
40+ extern " C" void display_link (void (*cb)(uv_idle_t *), uv_idle_t *data)
41+ {
42+ }
43+ #endif
44+
2745using namespace il2cpp ;
2846
2947extern " C" void UnityFiberProc ()
@@ -44,39 +62,24 @@ extern "C" void UnityFiberProc()
4462 abort ();
4563 }
4664
47- #if defined(__APPLE__)
48- extern int PlayerMain (int argc, const char *argv[]);
49- auto playerProc = (decltype (&PlayerMain))Baselib_DynamicLibrary_GetFunction (playerLib, " _Z10PlayerMainiPPKc" , &errorState);
50- #elif defined(_WIN32)
51- extern int UnityMain2 (void *hInstance, const wchar_t *customDataFolder, wchar_t *lpCmdLine, int nShowCmd);
52- auto playerProc = (decltype (&UnityMain2))Baselib_DynamicLibrary_GetFunction (playerLib, " UnityMain2" , &errorState);
53- #endif
54-
55- if (!playerProc)
56- {
57- printf (" error: %s\n " , utils::Exception::FormatBaselibErrorState (errorState).c_str ());
58- abort ();
59- }
60-
61- #if defined(__APPLE__)
6265 imagePath = imagePath.substr (0 , imagePath.find_last_of (IL2CPP_DIR_SEPARATOR));
66+ auto dataPath = utils::StringUtils::Utf8ToNativeString (imagePath + " \\ unode-module_Data" );
6367 imagePath = imagePath.substr (0 , imagePath.find_last_of (IL2CPP_DIR_SEPARATOR));
6468 imagePath = imagePath.substr (0 , imagePath.find_last_of (IL2CPP_DIR_SEPARATOR));
69+
6570 extern void app_init (const char *path);
6671 app_init (imagePath.c_str ());
67-
72+
73+ #if defined(__APPLE__)
74+ extern int PlayerMain (int argc, const char *argv[]);
75+ auto playerProc = (decltype (&PlayerMain))Baselib_DynamicLibrary_GetFunction (playerLib, " _Z10PlayerMainiPPKc" , &errorState);
6876 const char *argv[] = { os::Image::GetImageName (), " -logfile" , " -" };
6977 playerProc (1 , argv);
7078#elif defined(_WIN32)
71- imagePath = imagePath.substr (0 , imagePath.find_last_of (IL2CPP_DIR_SEPARATOR));
72- imagePath += " \\ unode-module_Data" ;
73- auto dataPath = utils::StringUtils::Utf8ToNativeString (imagePath);
74-
75- extern IMPORTED_SYMBOL int SetProcessDpiAwarenessContext (int );
76- SetProcessDpiAwarenessContext (-4 );
77-
78- extern IMPORTED_SYMBOL void *GetModuleHandleW (wchar_t *);
79- playerProc (GetModuleHandleW (nullptr ), dataPath.c_str (), L" -logfile -" , 5 );
79+ extern int UnityMain2 (void *hInstance, const wchar_t *customDataFolder, wchar_t *lpCmdLine, int nShowCmd);
80+ auto playerProc = (decltype (&UnityMain2))Baselib_DynamicLibrary_GetFunction (playerLib, " UnityMain2" , &errorState);
81+ auto hInstance = GetModuleHandleW (nullptr );
82+ playerProc (hInstance, dataPath.c_str (), L" -logfile -" , 5 );
8083#endif
8184
8285 Baselib_DynamicLibrary_Close (playerLib);
0 commit comments