fix QueryServerAlreadyOpen func error ret
This commit is contained in:
@@ -1,87 +0,0 @@
|
||||
#include "client_palpit.h"
|
||||
#include "client_comm_shared.h"
|
||||
|
||||
namespace client_palpit
|
||||
{
|
||||
DWORD WINAPI palpit_thread(LPVOID parmar)
|
||||
{
|
||||
static int break_count_fail = 0;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
auto mapping_data = reinterpret_cast<PMAPPING_USER_MEMORY>(parmar);
|
||||
|
||||
/*strcpy_s(mapping_data->str, "fail");
|
||||
mapping_data->add_index_code = TRUE;
|
||||
|
||||
auto val = 100;
|
||||
mapping_data->Index = val;
|
||||
|
||||
while (strcmp(mapping_data->str, "ok")) {
|
||||
|
||||
if (break_count_fail > 5) {
|
||||
MessageBoxA(NULL, "[client] 请求超时 错误代码:-502", NULL, NULL);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
break_count_fail++;
|
||||
|
||||
Sleep(1000);
|
||||
|
||||
}
|
||||
|
||||
if ((val + 1) != mapping_data->Index)
|
||||
{
|
||||
MessageBoxA(NULL, "[client] 组件发生异常 错误代码:-501", NULL, NULL);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
break_count_fail = 0;*/
|
||||
|
||||
//
|
||||
// 检测进程是否退出
|
||||
//
|
||||
if (!mapping_data->client_pid)
|
||||
mapping_data->client_pid = GetCurrentProcessId();
|
||||
|
||||
//static int fail_index = 0;
|
||||
//static HANDLE hProcess = 0;
|
||||
|
||||
//auto server_pid = mapping_data->server_pid;
|
||||
//if (hProcess == NULL)
|
||||
//{
|
||||
// if (fail_index > 3) {
|
||||
// exit(0);
|
||||
// }
|
||||
//
|
||||
|
||||
// hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, server_pid);
|
||||
// fail_index++;
|
||||
// continue;
|
||||
//}
|
||||
|
||||
////
|
||||
////监控客户端进程是否退出
|
||||
////
|
||||
//DWORD exitCode;
|
||||
//if (GetExitCodeProcess(hProcess, &exitCode)) {
|
||||
// if (exitCode != STILL_ACTIVE) {
|
||||
// exit(0);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
Sleep(1000);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
auto create_papit_thread(LPVOID parmar) -> void
|
||||
{
|
||||
CloseHandle(CreateThread(nullptr, 0, palpit_thread, parmar, 0, nullptr));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
#ifndef CHLENT_PALPIT
|
||||
#define CHLENT_PALPIT
|
||||
#include "Base.h"
|
||||
|
||||
|
||||
namespace client_palpit
|
||||
{
|
||||
auto create_papit_thread(LPVOID parmar) -> void;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // !client_palpit
|
||||
@@ -189,6 +189,12 @@ static bool ConnectToServer(HANDLE& pipe)
|
||||
DWORD err = GetLastError();
|
||||
if (err == ERROR_PIPE_BUSY)
|
||||
{
|
||||
LogA(
|
||||
"[dll-client] CreateFileW(%ls) failed: %lu\n",
|
||||
kPipeName,
|
||||
err);
|
||||
|
||||
|
||||
if (!WaitNamedPipeW(kPipeName, 1000))
|
||||
Sleep(250);
|
||||
continue;
|
||||
@@ -540,9 +546,21 @@ BOOL QueryServerAlreadyOpen()
|
||||
0,
|
||||
nullptr);
|
||||
|
||||
if (pipe == INVALID_HANDLE_VALUE)
|
||||
|
||||
|
||||
|
||||
if (pipe == INVALID_HANDLE_VALUE) {
|
||||
|
||||
|
||||
DWORD err = GetLastError();
|
||||
|
||||
LogA("[dll-client] CreateFileW failed, err=%lu\n", err);
|
||||
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
DWORD mode = PIPE_READMODE_MESSAGE;
|
||||
SetNamedPipeHandleState(pipe, &mode, nullptr, nullptr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user