From eb725259f6d4950b32612774303aa4ad526e8965 Mon Sep 17 00:00:00 2001 From: Peacoor Date: Sun, 24 Sep 2023 21:40:59 +0800 Subject: [PATCH] Must require admin --- 230130-hookgamesendto/injciv6/civ6remove.cpp | 32 ++++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/230130-hookgamesendto/injciv6/civ6remove.cpp b/230130-hookgamesendto/injciv6/civ6remove.cpp index cf0fbd3..4e8887e 100644 --- a/230130-hookgamesendto/injciv6/civ6remove.cpp +++ b/230130-hookgamesendto/injciv6/civ6remove.cpp @@ -5,8 +5,16 @@ int main(int argc, char *argv[]) { bool isadmin = IsUserAnAdmin(); - DWORD pid = 0; int msgres = 0; + if (!isadmin) { + retry_runas: + if (runas_admin(argv[0])) // 成功运行就退出自己 + return 0; + msgres = MessageBoxW(0, L"请允许管理员权限", L"错误", MB_ICONERROR | MB_RETRYCANCEL); + if (msgres == IDRETRY) + goto retry_runas; + } + DWORD pid = 0; HMODULE module_handle = 0; pid = get_civ6_proc(); if (pid == 0) { @@ -18,24 +26,8 @@ int main(int argc, char *argv[]) MessageBoxW(0, L"当前没有注入DLL", L"错误", MB_ICONERROR); return 0; } -retry_remove: - if (remove_module(pid, module_handle)) { + if (remove_module(pid, module_handle)) MessageBoxW(0, L"成功移除DLL!", L"成功", MB_OK); - return 0; - } - if (isadmin) { - msgres = MessageBoxW(0, L"移除失败", L"错误", MB_RETRYCANCEL | MB_ICONERROR); - if (msgres == IDRETRY) - goto retry_remove; - return 0; - } - msgres = MessageBoxW(0, L"移除失败,是否以管理员权限重试?", L"错误", MB_ICONERROR | MB_RETRYCANCEL); - if (msgres == IDRETRY) { - retry_runas: - if (runas_admin(argv[0])) // 成功运行就退出自己 - return 0; - msgres = MessageBoxW(0, L"请在弹出的窗口中点击“是”", L"错误", MB_ICONERROR | MB_RETRYCANCEL); - if (msgres == IDRETRY) - goto retry_runas; - } + else + msgres = MessageBoxW(0, L"移除失败", L"错误", MB_ICONERROR); } -- GitLab