Skip to content

Commit

Permalink
fix #149 save settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciremun committed Apr 18, 2024
1 parent 6141eee commit 8c8f6b2
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
4 changes: 4 additions & 0 deletions freedom/dll/dll_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ static bool init = false;
HWND g_hwnd = NULL;
HANDLE g_process = NULL;
HMODULE g_module = NULL;
LPVOID g_config_path = NULL;
IDirect3DDevice9 *g_d3d9_device = 0;
void *pDeviceTable[D3DDEV9_LEN];

Expand Down Expand Up @@ -203,6 +204,9 @@ DWORD WINAPI freedom_main(HMODULE hModule)
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{
g_config_path = lpReserved;
CloseHandle(CreateThread(0, 0, (LPTHREAD_START_ROUTINE)freedom_main, hModule, 0, 0));
}
return TRUE;
}
1 change: 1 addition & 0 deletions freedom/standalone/standalone_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
HWND g_hwnd = NULL;
HANDLE g_process = NULL;
HMODULE g_module = NULL;
LPVOID g_config_path = NULL;
bool compatibility_mode = false;
IDirect3DDevice9 *g_d3d9_device = 0;
void unload_dll() {}
Expand Down
18 changes: 17 additions & 1 deletion freedom/ui/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,23 @@ const char *get_imgui_ini_filename(HMODULE hMod)
if (module_path_length == 0)
{
FR_INFO_FMT("[!] GetModuleFileName (0x%X)", GetLastError());
return 0;

// NOTE(Ciremun): config path from freedom_injector
extern LPVOID g_config_path;
if (g_config_path == NULL)
return 0;

uint8_t test_byte = 0;
if (!internal_memory_read(g_process, (uintptr_t)g_config_path, &test_byte))
return 0;

module_path_length = wcslen((wchar_t *)g_config_path);
if (module_path_length == 0)
return 0;

memcpy(module_path, g_config_path, (module_path_length + 1) * sizeof(wchar_t));
SecureZeroMemory(g_config_path, (module_path_length + 1) * sizeof(wchar_t));
VirtualFreeEx(g_process, g_config_path, 0, MEM_RELEASE);
}

static char module_path_u8[MAX_PATH * 2];
Expand Down
4 changes: 2 additions & 2 deletions include/baked_utils_dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ static const unsigned int utils_dll_data[9728/4] =
{
0x00905a4d, 0x00000003, 0x00000004, 0x0000ffff, 0x000000b8, 0x00000000, 0x00000040, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000080, 0x0eba1f0e, 0xcd09b400, 0x4c01b821, 0x685421cd, 0x70207369, 0x72676f72, 0x63206d61, 0x6f6e6e61,
0x65622074, 0x6e757220, 0x206e6920, 0x20534f44, 0x65646f6d, 0x0a0d0d2e, 0x00000024, 0x00000000, 0x00004550, 0x0003014c, 0x661efca3, 0x00000000,
0x65622074, 0x6e757220, 0x206e6920, 0x20534f44, 0x65646f6d, 0x0a0d0d2e, 0x00000024, 0x00000000, 0x00004550, 0x0003014c, 0x6621a31b, 0x00000000,
0x00000000, 0x202200e0, 0x0030010b, 0x00001e00, 0x00000600, 0x00000000, 0x00003c26, 0x00002000, 0x00004000, 0x10000000, 0x00002000, 0x00000200,
0x00000004, 0x00000000, 0x00000004, 0x00000000, 0x00008000, 0x00000200, 0x00000000, 0x85400003, 0x00100000, 0x00001000, 0x00100000, 0x00001000,
0x00000000, 0x00000010, 0x00000000, 0x00000000, 0x00003bd4, 0x0000004f, 0x00004000, 0x00000298, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
Expand Down Expand Up @@ -148,7 +148,7 @@ static const unsigned int utils_dll_data[9728/4] =
0x00300054, 0x003d006f, 0x00233f00, 0x007a003d, 0x00300045, 0x00440056, 0x0066005a, 0x004a0077, 0x00480045, 0x007a0033, 0x00440036, 0x00580033,
0x00710047, 0x0054006d, 0x0044006b, 0x00460052, 0x0077006b, 0x00470066, 0x3f000100, 0x003d0023, 0x004e007a, 0x00740044, 0x00300073, 0x00360067,
0x0058004a, 0x00240045, 0x005f0059, 0x00700059, 0x00650068, 0x00760053, 0x00670062, 0x007a007a, 0x007a0068, 0x006f0070, 0x17000051, 0x003d0023,
0x004f007a, 0x00710035, 0x0062006d, 0x00550070, 0x0000003d, 0xd4b5e313, 0x4f66c0c0, 0x2a6661b7, 0xe73a6e6d, 0x01200400, 0x20030801, 0x20050100,
0x004f007a, 0x00710035, 0x0062006d, 0x00550070, 0x0000003d, 0x3ee6b8b3, 0x4705a61b, 0x33f9a8a1, 0x72ec81e5, 0x01200400, 0x20030801, 0x20050100,
0x11110101, 0x01012005, 0x07041d11, 0x04311101, 0x65120000, 0x12012005, 0x20050e35, 0x0e391201, 0x11002004, 0x00200331, 0x01000418, 0x07061808,
0x112d1102, 0x1215072d, 0x110e0229, 0x0120052d, 0x06001302, 0x01130120, 0x00050013, 0x08181802, 0x11020007, 0x71111c2d, 0x01022007, 0x01130013,
0x11010704, 0x0307082d, 0x0824111d, 0x20032411, 0x20030e00, 0x070e0800, 0x113d1106, 0x113d113d, 0x41121d3d, 0x00200408, 0x20043d11, 0x04591100,
Expand Down
8 changes: 7 additions & 1 deletion injector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,13 @@ int wmain(int argc, wchar_t **argv, wchar_t **envp)
return 1;
}

manual_map_dll(hProc, (BYTE *)module_file.start);
LPVOID config_path = _VirtualAllocEx(hProc, NULL, sizeof(module_path), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
if (!config_path)
log_warn("Couldn't allocate config path 0x%X", _GetLastError());
else if (!_WriteProcessMemory(hProc, config_path, module_path, sizeof(module_path), NULL))
log_warn("Couldn't write config path 0x%X", _GetLastError());

manual_map_dll(hProc, (BYTE *)module_file.start, true, true, true, true, DLL_PROCESS_ATTACH, config_path);

unmap_file(module_file);
close_file(module_file.handle);
Expand Down
Binary file modified nobuild.exe
Binary file not shown.

0 comments on commit 8c8f6b2

Please sign in to comment.