fix(rpc): fix enable/disable message receiving
This commit is contained in:
parent
8ca1e4e996
commit
8128835e5f
@ -204,7 +204,8 @@ int Handler::DisableLog()
|
||||
{
|
||||
if (!isLogging) return 1;
|
||||
if (MH_DisableHook(funcWxLog) != MH_OK) return -1;
|
||||
if (UninitializeHook() != MH_OK) return -2;
|
||||
if (MH_RemoveHook(funcWxLog) != MH_OK) return -2;
|
||||
if (UninitializeHook() != MH_OK) return -3;
|
||||
*pLogLevel = 6;
|
||||
isLogging = false;
|
||||
return 0;
|
||||
@ -216,8 +217,8 @@ int Handler::ListenMsg()
|
||||
|
||||
funcRecvMsg = Spy::getFunction<funcRecvMsg_t>(OsRecv::CALL);
|
||||
if (InitializeHook() != MH_OK) return -1;
|
||||
if (MH_CreateHook(funcRecvMsg, &DispatchMsg, reinterpret_cast<LPVOID *>(&realRecvMsg)) != MH_OK) return -1;
|
||||
if (MH_EnableHook(funcRecvMsg) != MH_OK) return -1;
|
||||
if (MH_CreateHook(funcRecvMsg, &DispatchMsg, reinterpret_cast<LPVOID *>(&realRecvMsg)) != MH_OK) return -2;
|
||||
if (MH_EnableHook(funcRecvMsg) != MH_OK) return -3;
|
||||
|
||||
isListeningMsg = true;
|
||||
return 0;
|
||||
@ -227,7 +228,8 @@ int Handler::UnListenMsg()
|
||||
{
|
||||
if (!isListeningMsg) return 1;
|
||||
if (MH_DisableHook(funcRecvMsg) != MH_OK) return -1;
|
||||
if (UninitializeHook() != MH_OK) return -1;
|
||||
if (MH_RemoveHook(funcRecvMsg) != MH_OK) return -2;
|
||||
if (UninitializeHook() != MH_OK) return -3;
|
||||
isListeningMsg = false;
|
||||
return 0;
|
||||
}
|
||||
@ -249,7 +251,8 @@ int Handler::UnListenPyq()
|
||||
{
|
||||
if (!isListeningPyq) return 1;
|
||||
if (MH_DisableHook(funcRecvPyq) != MH_OK) return -1;
|
||||
if (UninitializeHook() != MH_OK) return -1;
|
||||
if (MH_RemoveHook(funcRecvPyq) != MH_OK) return -2;
|
||||
if (UninitializeHook() != MH_OK) return -3;
|
||||
isListeningPyq = false;
|
||||
return 0;
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ bool RpcServer::start_message_listener(bool pyq, uint8_t *out, size_t *len)
|
||||
{
|
||||
return fill_response<Functions_FUNC_ENABLE_RECV_TXT>(out, len, [&](Response &rsp) {
|
||||
rsp.msg.status = handler_.ListenMsg();
|
||||
if (rsp.msg.status == 0) {
|
||||
if (rsp.msg.status >= 0) {
|
||||
if (pyq) {
|
||||
handler_.ListenPyq();
|
||||
}
|
||||
@ -227,7 +227,7 @@ bool RpcServer::stop_message_listener(uint8_t *out, size_t *len)
|
||||
{
|
||||
return fill_response<Functions_FUNC_DISABLE_RECV_TXT>(out, len, [&](Response &rsp) {
|
||||
rsp.msg.status = handler_.UnListenMsg();
|
||||
if (rsp.msg.status == 0) {
|
||||
if (rsp.msg.status >= 0) {
|
||||
handler_.UnListenPyq();
|
||||
if (msgThread_.joinable()) {
|
||||
msgThread_.join();
|
||||
|
Loading…
Reference in New Issue
Block a user