Make url configurable

This commit is contained in:
Changhua
2023-04-08 18:58:10 +08:00
parent ac85c144bf
commit dd02c4b6ff
9 changed files with 33 additions and 23 deletions
+6 -7
View File
@@ -560,21 +560,20 @@ static bool dispatcher(uint8_t *in, size_t in_len, uint8_t *out, size_t *out_len
return ret;
}
static int RunServer()
static int RunServer(LPVOID url)
{
int rv = 0;
char *url = (char *)CMD_URL;
int rv = 0;
if ((rv = nng_pair1_open(&sock)) != 0) {
LOG_ERROR("nng_pair0_open error {}", nng_strerror(rv));
return rv;
}
if ((rv = nng_listen(sock, url, NULL, 0)) != 0) {
if ((rv = nng_listen(sock, (char *)url, NULL, 0)) != 0) {
LOG_ERROR("nng_listen error {}", nng_strerror(rv));
return rv;
}
LOG_INFO("CMD Server listening on {}", url);
LOG_INFO("CMD Server listening on {}", (char *)url);
if ((rv = nng_setopt_ms(sock, NNG_OPT_SENDTIMEO, 1000)) != 0) {
LOG_ERROR("nng_setopt_ms error: {}", nng_strerror(rv));
return rv;
@@ -613,13 +612,13 @@ static int RunServer()
return rv;
}
int RpcStartServer()
int RpcStartServer(const char *url)
{
if (lIsRunning) {
return 0;
}
HANDLE rpcThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)RunServer, NULL, NULL, &lThreadId);
HANDLE rpcThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)RunServer, (LPVOID)url, NULL, &lThreadId);
if (rpcThread != 0) {
CloseHandle(rpcThread);
}
+1 -1
View File
@@ -6,5 +6,5 @@
#define SPY_API __declspec(dllimport)
#endif
int RpcStartServer();
int RpcStartServer(const char *url);
int RpcStopServer();
+3 -2
View File
@@ -7,7 +7,7 @@
WxCalls_t g_WxCalls = { 0 };
DWORD g_WeChatWinDllAddr = 0;
void InitSpy()
void InitSpy(const char *url)
{
wchar_t version[16] = { 0 };
InitLogger();
@@ -24,10 +24,11 @@ void InitSpy()
LOG_DEBUG("WeChat version: {}", Wstring2String(version).c_str());
if (LoadCalls(version, &g_WxCalls) != 0) { // 加载微信版本对应的Call地址
LOG_ERROR("不支持当前版本");
MessageBox(NULL, L"不支持当前版本", L"错误", 0);
return;
}
RpcStartServer();
RpcStartServer(url);
}
void CleanupSpy()