Format codes
This commit is contained in:
parent
f757c95e0d
commit
1299128bf1
@ -1,19 +1,14 @@
|
|||||||
// dllmain.cpp : 定义 DLL 应用程序的入口点。
|
// dllmain.cpp : 定义 DLL 应用程序的入口点。
|
||||||
#include "framework.h"
|
#include "framework.h"
|
||||||
|
|
||||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||||
DWORD ul_reason_for_call,
|
|
||||||
LPVOID lpReserved
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
switch (ul_reason_for_call)
|
switch (ul_reason_for_call) {
|
||||||
{
|
case DLL_PROCESS_ATTACH:
|
||||||
case DLL_PROCESS_ATTACH:
|
case DLL_THREAD_ATTACH:
|
||||||
case DLL_THREAD_ATTACH:
|
case DLL_THREAD_DETACH:
|
||||||
case DLL_THREAD_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
case DLL_PROCESS_DETACH:
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ static void *GetFuncAddr(LPCWSTR dllPath, HMODULE dllBase, LPCSTR funcName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *absAddr = GetProcAddress(hLoaded, funcName);
|
void *absAddr = GetProcAddress(hLoaded, funcName);
|
||||||
DWORD offset = (DWORD)absAddr - (DWORD)hLoaded;
|
DWORD offset = (DWORD)absAddr - (DWORD)hLoaded;
|
||||||
|
|
||||||
FreeLibrary(hLoaded);
|
FreeLibrary(hLoaded);
|
||||||
|
|
||||||
|
@ -8,9 +8,9 @@
|
|||||||
#include "sdk.h"
|
#include "sdk.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
static DWORD wcPid = 0;
|
static DWORD wcPid = 0;
|
||||||
static HANDLE wcProcess = NULL;
|
static HANDLE wcProcess = NULL;
|
||||||
static HMODULE spyBase = NULL;
|
static HMODULE spyBase = NULL;
|
||||||
static WCHAR spyDllPath[MAX_PATH] = { 0 };
|
static WCHAR spyDllPath[MAX_PATH] = { 0 };
|
||||||
|
|
||||||
int WxInitSDK()
|
int WxInitSDK()
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
extern WxCalls_t g_WxCalls;
|
extern WxCalls_t g_WxCalls;
|
||||||
extern DWORD g_WeChatWinDllAddr;
|
extern DWORD g_WeChatWinDllAddr;
|
||||||
|
|
||||||
bool GetContacts(wcf::Contacts* contacts)
|
bool GetContacts(wcf::Contacts *contacts)
|
||||||
{
|
{
|
||||||
DWORD baseAddr = g_WeChatWinDllAddr + g_WxCalls.contact.base;
|
DWORD baseAddr = g_WeChatWinDllAddr + g_WxCalls.contact.base;
|
||||||
DWORD tempAddr = GET_DWORD(baseAddr);
|
DWORD tempAddr = GET_DWORD(baseAddr);
|
||||||
@ -15,7 +15,7 @@ bool GetContacts(wcf::Contacts* contacts)
|
|||||||
DWORD node = GET_DWORD(head);
|
DWORD node = GET_DWORD(head);
|
||||||
|
|
||||||
while (node != head) {
|
while (node != head) {
|
||||||
wcf::Contact* cnt = contacts->add_contacts();
|
wcf::Contact *cnt = contacts->add_contacts();
|
||||||
cnt->set_wxid(GetStringByAddress(node + g_WxCalls.contact.wxId));
|
cnt->set_wxid(GetStringByAddress(node + g_WxCalls.contact.wxId));
|
||||||
cnt->set_code(GetStringByAddress(node + g_WxCalls.contact.wxCode));
|
cnt->set_code(GetStringByAddress(node + g_WxCalls.contact.wxCode));
|
||||||
cnt->set_name(GetStringByAddress(node + g_WxCalls.contact.wxName));
|
cnt->set_name(GetStringByAddress(node + g_WxCalls.contact.wxName));
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
#define LOGGER_MAX_SIZE 1024 * 1024 * 10 // 10M
|
#define LOGGER_MAX_SIZE 1024 * 1024 * 10 // 10M
|
||||||
#define LOGGER_MAX_FILES 10 // 10 files
|
#define LOGGER_MAX_FILES 10 // 10 files
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void InitLogger()
|
void InitLogger()
|
||||||
{
|
{
|
||||||
static std::shared_ptr<spdlog::logger> gLogger = nullptr;
|
static std::shared_ptr<spdlog::logger> gLogger = nullptr;
|
||||||
|
@ -21,9 +21,9 @@ extern condition_variable gCv;
|
|||||||
extern WxCalls_t g_WxCalls;
|
extern WxCalls_t g_WxCalls;
|
||||||
extern DWORD g_WeChatWinDllAddr;
|
extern DWORD g_WeChatWinDllAddr;
|
||||||
|
|
||||||
static DWORD reg_buffer = 0;
|
static DWORD reg_buffer = 0;
|
||||||
static DWORD recvMsgHookAddr = 0;
|
static DWORD recvMsgHookAddr = 0;
|
||||||
static DWORD recvMsgCallAddr = 0;
|
static DWORD recvMsgCallAddr = 0;
|
||||||
static DWORD recvMsgJumpBackAddr = 0;
|
static DWORD recvMsgJumpBackAddr = 0;
|
||||||
static CHAR recvMsgBackupCode[5] = { 0 };
|
static CHAR recvMsgBackupCode[5] = { 0 };
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ void HookAddress(DWORD hookAddr, LPVOID funcAddr, CHAR recvMsgBackupCode[5])
|
|||||||
{
|
{
|
||||||
//组装跳转数据
|
//组装跳转数据
|
||||||
BYTE jmpCode[5] = { 0 };
|
BYTE jmpCode[5] = { 0 };
|
||||||
jmpCode[0] = 0xE9;
|
jmpCode[0] = 0xE9;
|
||||||
|
|
||||||
//计算偏移
|
//计算偏移
|
||||||
*(DWORD *)&jmpCode[1] = (DWORD)funcAddr - hookAddr - 5;
|
*(DWORD *)&jmpCode[1] = (DWORD)funcAddr - hookAddr - 5;
|
||||||
@ -113,7 +113,7 @@ __declspec(naked) void RecieveMsgFunc()
|
|||||||
|
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
call recvMsgCallAddr // 这个为被覆盖的call
|
call recvMsgCallAddr // 这个为被覆盖的call
|
||||||
jmp recvMsgJumpBackAddr // 跳回被HOOK指令的下一条指令
|
jmp recvMsgJumpBackAddr // 跳回被HOOK指令的下一条指令
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,8 +125,8 @@ void ListenMessage()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
recvMsgHookAddr = g_WeChatWinDllAddr + g_WxCalls.recvMsg.hook;
|
recvMsgHookAddr = g_WeChatWinDllAddr + g_WxCalls.recvMsg.hook;
|
||||||
recvMsgCallAddr = g_WeChatWinDllAddr + g_WxCalls.recvMsg.call;
|
recvMsgCallAddr = g_WeChatWinDllAddr + g_WxCalls.recvMsg.call;
|
||||||
recvMsgJumpBackAddr = recvMsgHookAddr + 5;
|
recvMsgJumpBackAddr = recvMsgHookAddr + 5;
|
||||||
|
|
||||||
HookAddress(recvMsgHookAddr, RecieveMsgFunc, recvMsgBackupCode);
|
HookAddress(recvMsgHookAddr, RecieveMsgFunc, recvMsgBackupCode);
|
||||||
|
@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
void ListenMessage();
|
void ListenMessage();
|
||||||
void UnListenMessage();
|
void UnListenMessage();
|
||||||
void GetMsgTypes(wcf::MsgTypes* types);
|
void GetMsgTypes(wcf::MsgTypes *types);
|
||||||
|
@ -139,8 +139,8 @@ public:
|
|||||||
|
|
||||||
ServerUnaryReactor *RpcSendTextMsg(CallbackServerContext *context, const TextMsg *msg, Response *rsp) override
|
ServerUnaryReactor *RpcSendTextMsg(CallbackServerContext *context, const TextMsg *msg, Response *rsp) override
|
||||||
{
|
{
|
||||||
wstring wswxid = String2Wstring(msg->receiver());
|
wstring wswxid = String2Wstring(msg->receiver());
|
||||||
wstring wsmsg = String2Wstring(msg->msg());
|
wstring wsmsg = String2Wstring(msg->msg());
|
||||||
wstring wsatusers = String2Wstring(msg->aters());
|
wstring wsatusers = String2Wstring(msg->aters());
|
||||||
|
|
||||||
SendTextMessage(wswxid.c_str(), wsmsg.c_str(), wsatusers.c_str());
|
SendTextMessage(wswxid.c_str(), wsmsg.c_str(), wsatusers.c_str());
|
||||||
@ -173,7 +173,7 @@ public:
|
|||||||
|
|
||||||
ServerUnaryReactor *RpcGetContacts(CallbackServerContext *context, const Empty *empty, Contacts *rsp) override
|
ServerUnaryReactor *RpcGetContacts(CallbackServerContext *context, const Empty *empty, Contacts *rsp) override
|
||||||
{
|
{
|
||||||
bool ret = GetContacts(rsp);
|
bool ret = GetContacts(rsp);
|
||||||
auto *reactor = context->DefaultReactor();
|
auto *reactor = context->DefaultReactor();
|
||||||
if (ret) {
|
if (ret) {
|
||||||
reactor->Finish(Status::OK);
|
reactor->Finish(Status::OK);
|
||||||
@ -214,7 +214,7 @@ public:
|
|||||||
ServerUnaryReactor *RpcAcceptNewFriend(CallbackServerContext *context, const Verification *v,
|
ServerUnaryReactor *RpcAcceptNewFriend(CallbackServerContext *context, const Verification *v,
|
||||||
Response *rsp) override
|
Response *rsp) override
|
||||||
{
|
{
|
||||||
bool ret = AcceptNewFriend(String2Wstring(v->v3()), String2Wstring(v->v4()));
|
bool ret = AcceptNewFriend(String2Wstring(v->v3()), String2Wstring(v->v4()));
|
||||||
auto *reactor = context->DefaultReactor();
|
auto *reactor = context->DefaultReactor();
|
||||||
if (ret) {
|
if (ret) {
|
||||||
rsp->set_status(0);
|
rsp->set_status(0);
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "spy_types.h"
|
|
||||||
#include "send_msg.h"
|
#include "send_msg.h"
|
||||||
|
#include "spy_types.h"
|
||||||
|
|
||||||
extern HANDLE g_hEvent;
|
extern HANDLE g_hEvent;
|
||||||
extern WxCalls_t g_WxCalls;
|
extern WxCalls_t g_WxCalls;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "rpc_server.h"
|
#include "rpc_server.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
WxCalls_t g_WxCalls = { 0 };
|
WxCalls_t g_WxCalls = { 0 };
|
||||||
DWORD g_WeChatWinDllAddr = 0;
|
DWORD g_WeChatWinDllAddr = 0;
|
||||||
|
|
||||||
void InitSpy()
|
void InitSpy()
|
||||||
|
Loading…
Reference in New Issue
Block a user