diff --git a/unlockfps/main.cpp b/unlockfps/main.cpp index f49d4ed..bbc50fe 100644 --- a/unlockfps/main.cpp +++ b/unlockfps/main.cpp @@ -16,7 +16,7 @@ std::string GamePath{}; int FpsValue = FPS_TARGET; -// 特征搜索 - 不是我写的 - 忘了在哪拷的 +// 鐗瑰緛鎼滅储 - 涓嶆槸鎴戝啓鐨 - 蹇樹簡鍦ㄥ摢鎷风殑 uintptr_t PatternScan(void* module, const char* signature) { static auto pattern_to_byte = [](const char* pattern) { @@ -73,7 +73,7 @@ std::string GetLastErrorAsString(DWORD code) return ret; } -// 获取目标进程DLL信息 +// 鑾峰彇鐩爣杩涚▼DLL淇℃伅 bool GetModule(DWORD pid, std::string ModuleName, PMODULEENTRY32 pEntry) { if (!pEntry) @@ -98,7 +98,7 @@ bool GetModule(DWORD pid, std::string ModuleName, PMODULEENTRY32 pEntry) return pEntry->modBaseAddr; } -// 通过进程名搜索进程ID +// 閫氳繃杩涚▼鍚嶆悳绱㈣繘绋婭D DWORD GetPID(std::string ProcessName) { DWORD pid = 0; @@ -119,7 +119,7 @@ DWORD GetPID(std::string ProcessName) bool WriteConfig(std::string GamePath, int fps) { - HANDLE hFile = CreateFileA("fps_config.ini", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); + HANDLE hFile = CreateFileA("fps_config.ini", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_HIDDEN, nullptr); if (hFile == INVALID_HANDLE_VALUE) { DWORD code = GetLastError(); @@ -145,16 +145,16 @@ void LoadConfig() INIReader reader("fps_config.ini"); if (reader.ParseError() != 0) { - printf("配置不存在\n请不要关闭此进程 - 然后手动开启游戏\n这只需要进行一次 - 用于获取游戏路经\n"); - printf("\n等待游戏启动...\n"); + printf("閰嶇疆涓嶅瓨鍦╘n璇蜂笉瑕佸叧闂杩涚▼ - 鐒跺悗鎵嬪姩寮鍚父鎴廫n杩欏彧闇瑕佽繘琛屼竴娆 - 鐢ㄤ簬鑾峰彇娓告垙璺粡\n"); + printf("\n绛夊緟娓告垙鍚姩...\n"); DWORD pid = 0; while (!(pid = GetPID("YuanShen.exe")) && !(pid = GetPID("GenshinImpact.exe"))) std::this_thread::sleep_for(std::chrono::milliseconds(200)); - // 获取进程句柄 - 这权限很低的了 - 不应该获取不了 - // PROCESS_QUERY_LIMITED_INFORMATION - 用于查询进程路经 (K32GetModuleFileNameExA) - // SYNCHRONIZE - 用于等待进程结束 (WaitForSingleObject) + // 鑾峰彇杩涚▼鍙ユ焺 - 杩欐潈闄愬緢浣庣殑浜 - 涓嶅簲璇ヨ幏鍙栦笉浜 + // PROCESS_QUERY_LIMITED_INFORMATION - 鐢ㄤ簬鏌ヨ杩涚▼璺粡 (K32GetModuleFileNameExA) + // SYNCHRONIZE - 鐢ㄤ簬绛夊緟杩涚▼缁撴潫 (WaitForSingleObject) HANDLE hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION | SYNCHRONIZE, FALSE, pid); if (!hProcess) { @@ -195,13 +195,13 @@ void LoadConfig() if (GetFileAttributesA(GamePath.c_str()) == INVALID_FILE_ATTRIBUTES) { - printf("配置里的游戏路经改变了 - 开始重新配置\n"); + printf("閰嶇疆閲岀殑娓告垙璺粡鏀瑰彉浜 - 寮濮嬮噸鏂伴厤缃甛n"); DeleteFileA("config.ini"); LoadConfig(); } } -// 热键线程 +// 鐑敭绾跨▼ DWORD __stdcall Thread1(LPVOID p) { if (!p) @@ -251,7 +251,7 @@ int main(int argc, char** argv) CommandLine += argv[i] + std::string(" "); } - // 读取配置 + // 璇诲彇閰嶇疆 LoadConfig(); int TargetFPS = FpsValue; std::string ProcessPath = GamePath; @@ -260,16 +260,16 @@ int main(int argc, char** argv) if (ProcessPath.length() < 8) return 0; - printf("FPS 解锁器 v1.4.2\n"); - printf("游戏路经: %s\n\n", ProcessPath.c_str()); + printf("FPS 瑙i攣鍣 v1.4.2\n"); + printf("娓告垙璺粡: %s\n\n", ProcessPath.c_str()); ProcessDir = ProcessPath.substr(0, ProcessPath.find_last_of("\\")); DWORD pid = GetPID(ProcessPath.substr(ProcessPath.find_last_of("\\") + 1)); if (pid) { - printf("检测到游戏已在运行!\n"); - printf("手动启动游戏会导致失效的\n"); - printf("请手动关闭游戏 - 解锁器会自动启动游戏\n"); + printf("妫娴嬪埌娓告垙宸插湪杩愯锛乗n"); + printf("鎵嬪姩鍚姩娓告垙浼氬鑷村け鏁堢殑\n"); + printf("璇锋墜鍔ㄥ叧闂父鎴 - 瑙i攣鍣ㄤ細鑷姩鍚姩娓告垙\n"); return 0; } @@ -285,7 +285,7 @@ int main(int argc, char** argv) CloseHandle(pi.hThread); printf("PID: %d\n", pi.dwProcessId); - // 等待UnityPlayer.dll加载和获取DLL信息 + // 绛夊緟UnityPlayer.dll鍔犺浇鍜岃幏鍙朌LL淇℃伅 MODULEENTRY32 hUnityPlayer{}; MODULEENTRY32 hUserAssembly{}; while (!GetModule(pi.dwProcessId, "UnityPlayer.dll", &hUnityPlayer)) @@ -296,7 +296,7 @@ int main(int argc, char** argv) printf("UnityPlayer: %X%X\n", (uintptr_t)hUnityPlayer.modBaseAddr >> 32 & -1, hUnityPlayer.modBaseAddr); printf("UserAssembly: %X%X\n", (uintptr_t)hUnityPlayer.modBaseAddr >> 32 & -1, hUserAssembly.modBaseAddr); - // 在本进程内申请UnityPlayer.dll大小的内存 - 用于特征搜索 + // 鍦ㄦ湰杩涚▼鍐呯敵璇稶nityPlayer.dll澶у皬鐨勫唴瀛 - 鐢ㄤ簬鐗瑰緛鎼滅储 //LPVOID mem = VirtualAlloc(nullptr, hUnityPlayer.modBaseSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); LPVOID up = VirtualAlloc(nullptr, hUnityPlayer.modBaseSize + hUserAssembly.modBaseSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); if (!up) @@ -306,7 +306,7 @@ int main(int argc, char** argv) return 0; } - // 把整个模块读出来 + // 鎶婃暣涓ā鍧楄鍑烘潵 ReadProcessMemory(pi.hProcess, hUnityPlayer.modBaseAddr, up, hUnityPlayer.modBaseSize, nullptr); LPVOID ua = (LPVOID)((uintptr_t)up + hUnityPlayer.modBaseSize); ReadProcessMemory(pi.hProcess, hUserAssembly.modBaseAddr, ua, hUserAssembly.modBaseSize, nullptr); @@ -322,7 +322,7 @@ int main(int argc, char** argv) return 0; } - // 计算相对地址 (FPS) + // 璁$畻鐩稿鍦板潃 (FPS) uintptr_t pfps = 0; { uintptr_t rip = address; @@ -344,7 +344,7 @@ int main(int argc, char** argv) pfps = (uintptr_t)hUnityPlayer.modBaseAddr + pfps; } - // 计算相对地址 (垂直同步) + // 璁$畻鐩稿鍦板潃 (鍨傜洿鍚屾) address = PatternScan(up, "E8 ? ? ? ? 8B E8 49 8B 1E"); uintptr_t pvsync = 0; if (address) @@ -373,13 +373,13 @@ int main(int argc, char** argv) VirtualFree(up, 0, MEM_RELEASE); printf("Done\n\n"); - printf("用右ctrl + 箭头键更改限制:\n"); - printf(" 右ctrl + 上: +20\n"); - printf(" 右ctrl + 下: -20\n"); - printf(" 右ctrl + 左: -2\n"); - printf(" 右ctrl + 右: +2\n\n"); + printf("鐢ㄥ彸ctrl + 绠ご閿洿鏀归檺鍒:\n"); + printf(" 鍙砪trl + 涓: +20\n"); + printf(" 鍙砪trl + 涓: -20\n"); + printf(" 鍙砪trl + 宸: -2\n"); + printf(" 鍙砪trl + 鍙: +2\n\n"); - // 创建热键线程 + // 鍒涘缓鐑敭绾跨▼ HANDLE hThread = CreateThread(nullptr, 0, Thread1, &TargetFPS, 0, nullptr); if (hThread) CloseHandle(hThread); @@ -389,7 +389,7 @@ int main(int argc, char** argv) { GetExitCodeProcess(pi.hProcess, &dwExitCode); - // 每两秒检查一次 + // 姣忎袱绉掓鏌ヤ竴娆 std::this_thread::sleep_for(std::chrono::seconds(2)); int fps = 0; ReadProcessMemory(pi.hProcess, (LPVOID)pfps, &fps, sizeof(fps), nullptr); @@ -403,7 +403,7 @@ int main(int argc, char** argv) if (vsync) { vsync = 0; - // 关闭垂直同步 + // 鍏抽棴鍨傜洿鍚屾 WriteProcessMemory(pi.hProcess, (LPVOID)pvsync, &vsync, sizeof(vsync), nullptr); } } @@ -412,4 +412,4 @@ int main(int argc, char** argv) TerminateProcess((HANDLE)-1, 0); return 0; -} \ No newline at end of file +}