Fix data type

This commit is contained in:
Changhua 2024-04-28 09:16:09 +08:00
parent ebb45d3cb1
commit d8770487ed
11 changed files with 49 additions and 49 deletions

View File

@ -133,12 +133,12 @@ static bool GetFileVersion(const wchar_t *filePath, wchar_t *version)
return false; return false;
} }
DWORD verMS = pVerInfo->dwFileVersionMS; UINT64 verMS = pVerInfo->dwFileVersionMS;
DWORD verLS = pVerInfo->dwFileVersionLS; UINT64 verLS = pVerInfo->dwFileVersionLS;
DWORD major = HIWORD(verMS); UINT64 major = HIWORD(verMS);
DWORD minor = LOWORD(verMS); UINT64 minor = LOWORD(verMS);
DWORD build = HIWORD(verLS); UINT64 build = HIWORD(verLS);
DWORD revision = LOWORD(verLS); UINT64 revision = LOWORD(verLS);
delete[] pData; delete[] pData;
StringCbPrintf(version, 0x20, TEXT("%d.%d.%d.%d"), major, minor, build, revision); StringCbPrintf(version, 0x20, TEXT("%d.%d.%d.%d"), major, minor, build, revision);
@ -163,9 +163,9 @@ int GetWeChatVersion(wchar_t *version)
return ret; return ret;
} }
DWORD GetWeChatPid() UINT64 GetWeChatPid()
{ {
DWORD pid = 0; UINT64 pid = 0;
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PROCESSENTRY32 pe32 = { sizeof(PROCESSENTRY32) }; PROCESSENTRY32 pe32 = { sizeof(PROCESSENTRY32) };
while (Process32Next(hSnapshot, &pe32)) { while (Process32Next(hSnapshot, &pe32)) {
@ -179,7 +179,7 @@ DWORD GetWeChatPid()
return pid; return pid;
} }
int OpenWeChat(DWORD *pid) int OpenWeChat(UINT64 *pid)
{ {
*pid = GetWeChatPid(); *pid = GetWeChatPid();
if (*pid) { if (*pid) {
@ -208,9 +208,9 @@ int OpenWeChat(DWORD *pid)
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
int GetWstringByAddress(DWORD address, wchar_t *buffer, DWORD buffer_size) size_t GetWstringByAddress(UINT64 address, wchar_t *buffer, UINT64 buffer_size)
{ {
DWORD strLength = GET_DWORD(address + 4); size_t strLength = GET_UINT64(address + 4);
if (strLength == 0) { if (strLength == 0) {
return 0; return 0;
} else if (strLength > buffer_size) { } else if (strLength > buffer_size) {
@ -222,27 +222,27 @@ int GetWstringByAddress(DWORD address, wchar_t *buffer, DWORD buffer_size)
return strLength; return strLength;
} }
string GetStringByAddress(DWORD address) string GetStringByAddress(UINT64 address)
{ {
DWORD strLength = GET_DWORD(address + 4); UINT64 strLength = GET_UINT64(address + 4);
return Wstring2String(wstring(GET_WSTRING(address), strLength)); return Wstring2String(wstring(GET_WSTRING(address), strLength));
} }
string GetStringByStrAddr(DWORD addr) string GetStringByStrAddr(UINT64 addr)
{ {
DWORD strLength = GET_DWORD(addr + 4); UINT64 strLength = GET_UINT64(addr + 4);
return strLength ? string(GET_STRING(addr), strLength) : string(); return strLength ? string(GET_STRING(addr), strLength) : string();
} }
string GetStringByWstrAddr(DWORD addr) string GetStringByWstrAddr(UINT64 addr)
{ {
DWORD strLength = GET_DWORD(addr + 4); UINT64 strLength = GET_UINT64(addr + 4);
return strLength ? Wstring2String(wstring(GET_WSTRING(addr), strLength)) : string(); return strLength ? Wstring2String(wstring(GET_WSTRING(addr), strLength)) : string();
} }
DWORD GetMemoryIntByAddress(HANDLE hProcess, DWORD address) UINT32 GetMemoryIntByAddress(HANDLE hProcess, UINT64 address)
{ {
DWORD value = 0; UINT32 value = 0;
unsigned char data[4] = { 0 }; unsigned char data[4] = { 0 };
if (ReadProcessMemory(hProcess, (LPVOID)address, data, 4, 0)) { if (ReadProcessMemory(hProcess, (LPVOID)address, data, 4, 0)) {
@ -255,12 +255,12 @@ DWORD GetMemoryIntByAddress(HANDLE hProcess, DWORD address)
return value; return value;
} }
wstring GetUnicodeInfoByAddress(HANDLE hProcess, DWORD address) wstring GetUnicodeInfoByAddress(HANDLE hProcess, UINT64 address)
{ {
wstring value = L""; wstring value = L"";
DWORD strAddress = GetMemoryIntByAddress(hProcess, address); UINT64 strAddress = GetMemoryIntByAddress(hProcess, address);
DWORD strLen = GetMemoryIntByAddress(hProcess, address + 0x4); UINT64 strLen = GetMemoryIntByAddress(hProcess, address + 0x4);
if (strLen > 500) if (strLen > 500)
return value; return value;

View File

@ -8,10 +8,10 @@
#define WCFSPYDLL L"spy.dll" #define WCFSPYDLL L"spy.dll"
#define WCFSPYDLL_DEBUG L"spy_debug.dll" #define WCFSPYDLL_DEBUG L"spy_debug.dll"
#define GET_DWORD(addr) ((DWORD) * (DWORD *)(addr)) #define GET_UINT64(addr) ((UINT64) * (UINT64 *)(addr))
#define GET_QWORD(addr) ((uint64_t) * (uint64_t *)(addr)) #define GET_QWORD(addr) ((UINT64) * (UINT64 *)(addr))
#define GET_STRING(addr) ((CHAR *)(*(DWORD *)(addr))) #define GET_STRING(addr) ((CHAR *)(*(UINT64 *)(addr)))
#define GET_WSTRING(addr) ((WCHAR *)(*(DWORD *)(addr))) #define GET_WSTRING(addr) ((WCHAR *)(*(UINT64 *)(addr)))
#define GET_STRING_FROM_P(addr) ((CHAR *)(addr)) #define GET_STRING_FROM_P(addr) ((CHAR *)(addr))
#define GET_WSTRING_FROM_P(addr) ((WCHAR *)(addr)) #define GET_WSTRING_FROM_P(addr) ((WCHAR *)(addr))
@ -20,16 +20,16 @@ typedef struct PortPath {
char path[MAX_PATH]; char path[MAX_PATH];
} PortPath_t; } PortPath_t;
DWORD GetWeChatPid(); UINT64 GetWeChatPid();
int OpenWeChat(DWORD *pid); int OpenWeChat(UINT64 *pid);
int GetWeChatVersion(wchar_t *version); int GetWeChatVersion(wchar_t *version);
int GetWstringByAddress(DWORD address, wchar_t *buffer, DWORD buffer_size); size_t GetWstringByAddress(UINT64 address, wchar_t *buffer, UINT64 buffer_size);
DWORD GetMemoryIntByAddress(HANDLE hProcess, DWORD address); UINT32 GetMemoryIntByAddress(HANDLE hProcess, UINT64 address);
std::wstring GetUnicodeInfoByAddress(HANDLE hProcess, DWORD address); std::wstring GetUnicodeInfoByAddress(HANDLE hProcess, UINT64 address);
std::wstring String2Wstring(std::string s); std::wstring String2Wstring(std::string s);
std::string Wstring2String(std::wstring ws); std::string Wstring2String(std::wstring ws);
std::string GB2312ToUtf8(const char *gb2312); std::string GB2312ToUtf8(const char *gb2312);
std::string GetStringByAddress(DWORD address); std::string GetStringByAddress(UINT64 address);
std::string GetStringByStrAddr(DWORD addr); std::string GetStringByStrAddr(UINT64 addr);
std::string GetStringByWstrAddr(DWORD addr); std::string GetStringByWstrAddr(UINT64 addr);
void DbgMsg(const char *zcFormat, ...); void DbgMsg(const char *zcFormat, ...);

View File

@ -10,7 +10,7 @@
using namespace std; using namespace std;
extern WxCalls_t g_WxCalls; extern WxCalls_t g_WxCalls;
extern DWORD g_WeChatWinDllAddr; extern UINT64 g_WeChatWinDllAddr;
#if 0 #if 0
int AddChatroomMember(string roomid, string wxids) int AddChatroomMember(string roomid, string wxids)
{ {

View File

@ -7,7 +7,7 @@
using namespace std; using namespace std;
extern WxCalls_t g_WxCalls; extern WxCalls_t g_WxCalls;
extern DWORD g_WeChatWinDllAddr; extern UINT64 g_WeChatWinDllAddr;
#if 0 #if 0
#define FEAT_LEN 5 #define FEAT_LEN 5
static const uint8_t FEAT_COUNTRY[FEAT_LEN] = { 0xA4, 0xD9, 0x02, 0x4A, 0x18 }; static const uint8_t FEAT_COUNTRY[FEAT_LEN] = { 0xA4, 0xD9, 0x02, 0x4A, 0x18 };

View File

@ -16,7 +16,7 @@
#define OFFSET_DB_NAME 0x14 #define OFFSET_DB_NAME 0x14
#define OFFSET_DB_MSG_MGR 0x30403B8 #define OFFSET_DB_MSG_MGR 0x30403B8
extern DWORD g_WeChatWinDllAddr; extern UINT64 g_WeChatWinDllAddr;
typedef map<string, DWORD> dbMap_t; typedef map<string, DWORD> dbMap_t;
static dbMap_t dbMap; static dbMap_t dbMap;

View File

@ -23,9 +23,9 @@ namespace fs = std::filesystem;
extern bool gIsListeningPyq; extern bool gIsListeningPyq;
extern WxCalls_t g_WxCalls; extern WxCalls_t g_WxCalls;
extern DWORD g_WeChatWinDllAddr; extern UINT64 g_WeChatWinDllAddr;
int IsLogin(void) { return (int)GET_DWORD(g_WeChatWinDllAddr + g_WxCalls.login); } int IsLogin(void) { return (int)GET_UINT64(g_WeChatWinDllAddr + g_WxCalls.login); }
#if 0 #if 0
static string get_key(uint8_t header1, uint8_t header2, uint8_t *key) static string get_key(uint8_t header1, uint8_t header2, uint8_t *key)

View File

@ -19,7 +19,7 @@ extern queue<WxMsg_t> gMsgQueue;
// Defined in spy.cpp // Defined in spy.cpp
extern WxCalls_t g_WxCalls; extern WxCalls_t g_WxCalls;
extern DWORD g_WeChatWinDllAddr; extern UINT64 g_WeChatWinDllAddr;
static DWORD reg_buffer = 0; static DWORD reg_buffer = 0;
static DWORD recvMsgHookAddr = 0; static DWORD recvMsgHookAddr = 0;

View File

@ -6,7 +6,7 @@
using namespace std; using namespace std;
extern WxCalls_t g_WxCalls; extern WxCalls_t g_WxCalls;
extern DWORD g_WeChatWinDllAddr; extern UINT64 g_WeChatWinDllAddr;
#if 0 #if 0
int ReceiveTransfer(string wxid, string transferid, string transactionid) int ReceiveTransfer(string wxid, string transferid, string transactionid)
{ {

View File

@ -10,7 +10,7 @@
extern HANDLE g_hEvent; extern HANDLE g_hEvent;
extern WxCalls_t g_WxCalls; extern WxCalls_t g_WxCalls;
extern DWORD g_WeChatWinDllAddr; extern UINT64 g_WeChatWinDllAddr;
extern string GetSelfWxid(); // Defined in spy.cpp extern string GetSelfWxid(); // Defined in spy.cpp
#if 0 #if 0
void SendTextMessage(string wxid, string msg, string atWxids) void SendTextMessage(string wxid, string msg, string atWxids)

View File

@ -7,7 +7,7 @@
#include "util.h" #include "util.h"
WxCalls_t g_WxCalls = { 0 }; WxCalls_t g_WxCalls = { 0 };
DWORD g_WeChatWinDllAddr = 0; UINT64 g_WeChatWinDllAddr = 0;
void InitSpy(LPVOID args) void InitSpy(LPVOID args)
{ {
@ -16,7 +16,7 @@ void InitSpy(LPVOID args)
PortPath_t *pp = (PortPath_t *)args; PortPath_t *pp = (PortPath_t *)args;
InitLogger(pp->path); InitLogger(pp->path);
g_WeChatWinDllAddr = (DWORD)GetModuleHandle(L"WeChatWin.dll"); // 获取wechatWin模块地址 g_WeChatWinDllAddr = (UINT64)GetModuleHandle(L"WeChatWin.dll"); // 获取wechatWin模块地址
if (g_WeChatWinDllAddr == 0) { if (g_WeChatWinDllAddr == 0) {
LOG_ERROR("获取 wechatWin.dll 模块地址失败"); LOG_ERROR("获取 wechatWin.dll 模块地址失败");
return; return;

View File

@ -1,10 +1,10 @@
#include "user_info.h" #include "user_info.h"
#include "load_calls.h" #include "load_calls.h"
#include "log.h" #include "log.h"
#include "util.h" #include "util.h"
extern WxCalls_t g_WxCalls; extern WxCalls_t g_WxCalls;
extern DWORD g_WeChatWinDllAddr; extern UINT64 g_WeChatWinDllAddr;
static char home[MAX_PATH] = { 0 }; static char home[MAX_PATH] = { 0 };
@ -20,9 +20,9 @@ string GetHomePath()
string GetSelfWxid() string GetSelfWxid()
{ {
DWORD wxidType = 0; UINT64 wxidType = 0;
try { try {
wxidType = GET_DWORD(g_WeChatWinDllAddr + g_WxCalls.ui.wxid + 0x14); wxidType = GET_UINT64(g_WeChatWinDllAddr + g_WxCalls.ui.wxid + 0x14);
if (wxidType == 0xF) { if (wxidType == 0xF) {
return GET_STRING_FROM_P(g_WeChatWinDllAddr + g_WxCalls.ui.wxid); return GET_STRING_FROM_P(g_WeChatWinDllAddr + g_WxCalls.ui.wxid);
} else { } else {
@ -41,7 +41,7 @@ UserInfo_t GetUserInfo()
ui.wxid = GetSelfWxid(); ui.wxid = GetSelfWxid();
DWORD nameType = GET_DWORD(g_WeChatWinDllAddr + g_WxCalls.ui.nickName + 0x14); UINT64 nameType = GET_UINT64(g_WeChatWinDllAddr + g_WxCalls.ui.nickName + 0x14);
if (nameType == 0xF) { if (nameType == 0xF) {
ui.name = GET_STRING_FROM_P(g_WeChatWinDllAddr + g_WxCalls.ui.nickName); ui.name = GET_STRING_FROM_P(g_WeChatWinDllAddr + g_WxCalls.ui.nickName);
} else { // 0x1F } else { // 0x1F