forked from PretendoNetwork/cemu-patcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhook_curl.cpp
42 lines (34 loc) · 1.58 KB
/
hook_curl.cpp
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
#include <windows.h>
#include <fstream>
#include <string>
#include <iostream>
void HookCurl()
{
DWORD current_process_id = GetCurrentProcessId();
HANDLE cemu_process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, current_process_id);
if (cemu_process)
{
//MessageBox(NULL, "CemuHook found. Attempting injection. This is widely untested and not officially support by Rajkosto. Use at your own risk", "Warning", MB_ICONWARNING);
char cemuhook_path[MAX_PATH];
GetFullPathName("CurlHook.dll", MAX_PATH, cemuhook_path, NULL);
long cemuhook_path_size = strlen(cemuhook_path) + 1;
LPVOID cemuhook_memory = VirtualAllocEx(cemu_process, NULL, cemuhook_path_size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (cemuhook_memory == NULL)
{
MessageBox(NULL, "Failed to allocate memory in Cemu", "Error", MB_ICONERROR);
return;
}
if (!WriteProcessMemory(cemu_process, cemuhook_memory, cemuhook_path, cemuhook_path_size, 0))
{
MessageBox(NULL, "Failed to write to Cemu process", "Error", MB_ICONERROR);
return;
}
LPTHREAD_START_ROUTINE load_library_a_addr = (LPTHREAD_START_ROUTINE)GetProcAddress(LoadLibrary("kernel32"), "LoadLibraryA");
if (!CreateRemoteThread(cemu_process, NULL, 0, load_library_a_addr, cemuhook_memory, 0, NULL))
{
MessageBox(NULL, "Failed to create Remote Thread", "Error", MB_ICONERROR);
return;
}
MessageBox(NULL, "Injected CemuHook", "Success", MB_OK);
}
}