MCPcopy Create free account
hub / github.com/WinDurango/WinDurango / KernelxInitialize

Function KernelxInitialize

projects/WinDurango.KernelX/src/dllmain.cpp:10–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#define RETURN_IF_FAILED(hr) if (FAILED(hr)) return hr
9
10void KernelxInitialize(HINSTANCE hinstDLL)
11{
12 if (!GetConsoleWindow())
13 {
14 AllocConsole();
15 FILE *f;
16 freopen_s(&f, "CONOUT$", "w", stdout);
17 freopen_s(&f, "CONOUT$", "w", stderr);
18 freopen_s(&f, "CONIN$", "r", stdin);
19
20 SetConsoleTitleW(L"WinDurango");
21 }
22
23 auto AppxManifestFile = ReadFile(L"AppxManifest.xml");
24 auto TitleID = ExtractAttribute(AppxManifestFile, L"TitleId");
25 auto Version = ExtractAttribute(AppxManifestFile, L"Version");
26
27 if (ReasonForCall == DLL_PROCESS_ATTACH || ReasonForCall == DLL_THREAD_ATTACH)
28 {
29 DetourRestoreAfterWith();
30 DetourTransactionBegin();
31 DetourUpdateThread(GetCurrentThread());
32 XWinePatchImport(GetModuleHandleW(nullptr), GetRuntimeModule(),
33 "?GetActivationFactoryByPCWSTR@@YAJPEAXAEAVGuid@Platform@@PEAPEAX@Z",
34 GetActivationFactoryRedirect);
35
36 //This is needed for DXVK.
37 if (!User32) User32 = LoadLibraryA("user32.dll");
38 if (User32)
39 {
40 FARPROC CreateWindowInBandEx = GetProcAddress(User32, "CreateWindowInBandEx");
41 TrueCreateWindowInBandEx = reinterpret_cast<PCreateWindowInBandEx>(CreateWindowInBandEx);
42 DetourAttach(&reinterpret_cast<PVOID &>(TrueCreateWindowInBandEx), EraCreateWindowInBandEx);
43 }
44
45 //Halo 5: Guardians
46 if (TitleID == L"0D174C79")
47 {
48 HMODULE XboxLiveWrapper = LoadLibraryW(L"XboxLiveServicesWrapperLib_Release.dll");
49 XWinePatchImport(XboxLiveWrapper, GetRuntimeModule(),
50 "?GetActivationFactoryByPCWSTR@@YAJPEAXAEAVGuid@Platform@@PEAPEAX@Z",
51 GetActivationFactoryRedirect);
52
53 *(void**)&P_Halo5VectoredExceptionHandler = (char*)GetModuleHandleW(nullptr) + 0xA54024;
54 DetourAttach((void**)&P_Halo5VectoredExceptionHandler, &D_Halo5VectoredExceptionHandler);
55 }
56
57 //Forza Horizon 2 Demo
58 if (TitleID == L"265E1020" && Version == L"1.0.0.5")
59 {
60 *(void**)&P_StartForzaThread = (char*)GetModuleHandleW(nullptr) + 0xFE6920;
61 DetourAttach((void**)&P_StartForzaThread, &D_StartForzaThread);
62 }
63
64 //Forza Horizon 2
65 if (TitleID == L"1A96545B" && Version == L"1.0.0.64")
66 {
67 *(void**)&P_StartForzaThread = (char*)GetModuleHandleW(nullptr) + 0x1081A90;

Callers 1

DllMainFunction · 0.85

Calls 5

XWinePatchImportFunction · 0.85
GetRuntimeModuleFunction · 0.85
GetProcAddressFunction · 0.85
FamilyNameMethod · 0.80
IdMethod · 0.45

Tested by

no test coverage detected