MCPcopy Create free account
hub / github.com/call-042PE/PyInjector / InitCPython

Method InitCPython

PyInjector/SDK.cpp:9–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7_PyRun_SimpleStringFlags PyRun_SimpleStringFlags;
8
9void SDK::InitCPython()
10{
11 HMODULE hPython = 0x0;
12 const char* pythonVersions[] = { "37", "38", "39", "310", "311", "312" };
13 const int numVersions = sizeof(pythonVersions) / sizeof(pythonVersions[0]);
14
15 for (int i = 0; i < numVersions; ++i) {
16 char pythonDllName[15];
17 snprintf(pythonDllName, sizeof(pythonDllName), "Python%s.dll", pythonVersions[i]);
18
19 hPython = GetModuleHandleA(pythonDllName);
20
21 if (hPython)
22 break;
23 }
24
25 Py_SetProgramName = (_Py_SetProgramName)(GetProcAddress(hPython, "Py_SetProgramName"));
26 PyEval_InitThreads = (_PyEval_InitThreads)(GetProcAddress(hPython, "PyEval_InitThreads"));
27 PyGILState_Ensure = (_PyGILState_Ensure)(GetProcAddress(hPython, "PyGILState_Ensure"));
28 PyGILState_Release = (_PyGILState_Release)(GetProcAddress(hPython, "PyGILState_Release"));
29 PyRun_SimpleStringFlags = (_PyRun_SimpleStringFlags)(GetProcAddress(hPython, "PyRun_SimpleStringFlags"));
30}

Callers 1

MainThreadFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected