mirror of
https://repo.dactyloidae.xyz/Dactyloidae/DactJump.git
synced 2026-08-15 05:53:05 +09:00
83 lines
No EOL
2 KiB
C
83 lines
No EOL
2 KiB
C
#include <windows.h>
|
|
#include <stdio.h>
|
|
|
|
typedef BOOL (WINAPI *GETVERSIONEXA)(LPOSVERSIONINFOA);
|
|
|
|
BOOL WINAPI FakeGetVersionExA(LPOSVERSIONINFOA lpVersionInformation)
|
|
{
|
|
if (!lpVersionInformation) return FALSE;
|
|
|
|
lpVersionInformation->dwMajorVersion = 5;
|
|
lpVersionInformation->dwMinorVersion = 1;
|
|
lpVersionInformation->dwBuildNumber = 2600;
|
|
lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
|
|
|
|
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOA))
|
|
lstrcpyA(lpVersionInformation->szCSDVersion, "Service Pack 3");
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void PatchGetVersionEx()
|
|
{
|
|
HMODULE hKernel;
|
|
FARPROC real;
|
|
DWORD oldProtect;
|
|
BYTE *p;
|
|
DWORD rel;
|
|
|
|
hKernel = GetModuleHandleA("kernel32.dll");
|
|
if (!hKernel)
|
|
return;
|
|
|
|
real = GetProcAddress(hKernel, "GetVersionExA");
|
|
if (!real)
|
|
return;
|
|
|
|
// Allow writing to the first 5 bytes
|
|
if (!VirtualProtect((LPVOID)real, 5, PAGE_EXECUTE_READWRITE, &oldProtect))
|
|
return;
|
|
|
|
p = (BYTE*)real;
|
|
rel = (DWORD)FakeGetVersionExA - ((DWORD)real + 5);
|
|
|
|
p[0] = 0xE9; // JMP rel32
|
|
*(DWORD*)(p + 1) = rel; // Write relative offset
|
|
|
|
// Restore protection
|
|
VirtualProtect((LPVOID)real, 5, oldProtect, &oldProtect);
|
|
}
|
|
|
|
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow)
|
|
{
|
|
const char targetExe[] = "dactyloidae.exe";
|
|
char exePath[MAX_PATH];
|
|
char *p;
|
|
STARTUPINFOA si;
|
|
PROCESS_INFORMATION pi;
|
|
|
|
PatchGetVersionEx();
|
|
|
|
GetModuleFileNameA(NULL, exePath, MAX_PATH);
|
|
|
|
p = strrchr(exePath, '\\');
|
|
if (!p)
|
|
return 0;
|
|
|
|
lstrcpyA(p + 1, targetExe);
|
|
|
|
ZeroMemory(&si, sizeof(si));
|
|
ZeroMemory(&pi, sizeof(pi));
|
|
si.cb = sizeof(si);
|
|
|
|
if (!CreateProcessA(exePath, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
|
|
{
|
|
MessageBoxA(NULL, "Failed to launch Dactyloidae.", "Error", MB_ICONERROR);
|
|
return 0;
|
|
}
|
|
|
|
CloseHandle(pi.hThread);
|
|
CloseHandle(pi.hProcess);
|
|
|
|
return 0;
|
|
} |