diff --git a/WeChatFerry/com/util.cpp b/WeChatFerry/com/util.cpp index 2481124..9bc0753 100644 --- a/WeChatFerry/com/util.cpp +++ b/WeChatFerry/com/util.cpp @@ -18,8 +18,8 @@ namespace util { -constexpr std::wstring_view WECHATEXE = L"WeChat.exe"; -constexpr std::string_view WECHATWINDLL = "WeChatWin.dll"; +constexpr char WECHATEXE[] = "WeChat.exe"; +constexpr char WECHATWINDLL[] = "WeChatWin.dll"; std::wstring s2w(const std::string &s) { @@ -63,7 +63,7 @@ static DWORD get_wechat_pid() PROCESSENTRY32 pe32 = { sizeof(PROCESSENTRY32) }; while (Process32Next(hSnapshot, &pe32)) { - if (pe32.szExeFile == WECHATEXE) { + if (pe32.szExeFile == s2w(WECHATEXE)) { pid = pe32.th32ProcessID; break; } diff --git a/WeChatFerry/com/util.h b/WeChatFerry/com/util.h index c4715cd..de61c80 100644 --- a/WeChatFerry/com/util.h +++ b/WeChatFerry/com/util.h @@ -15,7 +15,7 @@ struct PortPath { }; DWORD get_wechat_pid(); -int open_wechat(DWORD *pid); +int open_wechat(DWORD &pid); std::string get_wechat_version(); uint32_t get_memory_int_by_address(HANDLE hProcess, uint64_t addr); std::wstring get_unicode_info_by_address(HANDLE hProcess, uint64_t addr); diff --git a/WeChatFerry/sdk/sdk.cpp b/WeChatFerry/sdk/sdk.cpp index 69ff632..6f9b4c3 100644 --- a/WeChatFerry/sdk/sdk.cpp +++ b/WeChatFerry/sdk/sdk.cpp @@ -19,9 +19,10 @@ static HANDLE wcProcess = NULL; static HMODULE spyBase = NULL; static std::string spyDllPath; -constexpr std::string_view WCFSDKDLL = "sdk.dll"; -constexpr std::string_view WCFSPYDLL = "spy.dll"; -constexpr std::string_view WCFSPYDLL_DEBUG = "spy_debug.dll"; +constexpr char WCFSDKDLL[] = "sdk.dll"; +constexpr char WCFSPYDLL[] = "spy.dll"; +constexpr char WCFSPYDLL_DEBUG[] = "spy_debug.dll"; + constexpr std::string_view DISCLAIMER_FLAG = ".license_accepted.flag"; constexpr std::string_view DISCLAIMER_TEXT_FILE = "DISCLAIMER.md"; @@ -95,7 +96,7 @@ int WxInitSDK(bool debug, int port) return ERROR_FILE_NOT_FOUND; // DLL 文件路径不存在 } - status = util::open_wechat(&wcPid); + status = util::open_wechat(wcPid); if (status != 0) { MessageBoxA(NULL, "打开微信失败", "WxInitSDK", 0); return status; @@ -112,7 +113,7 @@ int WxInitSDK(bool debug, int port) pp.port = port; snprintf(pp.path, MAX_PATH, "%s", std::filesystem::current_path().string().c_str()); - if (!call_dll_func_ex(wcProcess, spyDllPath, spyBase, "InitSpy", (LPVOID)&pp, sizeof(PortPath_t), NULL)) { + if (!call_dll_func_ex(wcProcess, spyDllPath, spyBase, "InitSpy", (LPVOID)&pp, sizeof(util::PortPath), NULL)) { MessageBoxA(NULL, "初始化失败", "WxInitSDK", 0); return -1; }