Impl x32/x64 check
This commit is contained in:
parent
0279b1136e
commit
478bbdfdab
@ -180,6 +180,34 @@ DWORD GetWeChatPid()
|
|||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class WindowsArchiture { x32, x64 };
|
||||||
|
static WindowsArchiture GetWindowsArchitecture()
|
||||||
|
{
|
||||||
|
#ifdef _WIN64
|
||||||
|
return WindowsArchiture::x64;
|
||||||
|
#else
|
||||||
|
return WindowsArchiture::x32;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL IsProcessX64(DWORD pid)
|
||||||
|
{
|
||||||
|
BOOL isWow64 = false;
|
||||||
|
HANDLE hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, pid);
|
||||||
|
if (!hProcess)
|
||||||
|
return false;
|
||||||
|
BOOL result = IsWow64Process(hProcess, &isWow64);
|
||||||
|
CloseHandle(hProcess);
|
||||||
|
if (!result)
|
||||||
|
return false;
|
||||||
|
if (isWow64)
|
||||||
|
return false;
|
||||||
|
else if (GetWindowsArchitecture() == WindowsArchiture::x32)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int OpenWeChat(DWORD *pid)
|
int OpenWeChat(DWORD *pid)
|
||||||
{
|
{
|
||||||
*pid = GetWeChatPid();
|
*pid = GetWeChatPid();
|
||||||
|
@ -24,6 +24,7 @@ typedef struct PortPath {
|
|||||||
} PortPath_t;
|
} PortPath_t;
|
||||||
|
|
||||||
DWORD GetWeChatPid();
|
DWORD GetWeChatPid();
|
||||||
|
BOOL IsProcessX64(DWORD pid);
|
||||||
int OpenWeChat(DWORD *pid);
|
int OpenWeChat(DWORD *pid);
|
||||||
int GetWeChatVersion(wchar_t *version);
|
int GetWeChatVersion(wchar_t *version);
|
||||||
size_t GetWstringByAddress(UINT64 address, wchar_t *buffer, UINT64 buffer_size);
|
size_t GetWstringByAddress(UINT64 address, wchar_t *buffer, UINT64 buffer_size);
|
||||||
|
@ -47,6 +47,11 @@ int WxInitSDK(bool debug, int port)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!IsProcessX64(wcPid)) {
|
||||||
|
MessageBox(NULL, L"只支持 64 位微信", L"WxInitSDK", 0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
Sleep(2000); // 等待微信打开
|
Sleep(2000); // 等待微信打开
|
||||||
wcProcess = InjectDll(wcPid, spyDllPath, &spyBase);
|
wcProcess = InjectDll(wcPid, spyDllPath, &spyBase);
|
||||||
if (wcProcess == NULL) {
|
if (wcProcess == NULL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user