远程桌面优化迟钝问题

This commit is contained in:
yuanyuanxiang
2019-01-07 20:46:03 +08:00
parent a98d69f434
commit c681cf0132
10 changed files with 67 additions and 29 deletions

View File

@@ -39,6 +39,12 @@ int main(int argc, const char *argv[])
std::cout<<"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n";
return -1;
}
HANDLE hMutex = ::CreateMutexA(NULL, TRUE, "ghost.exe");
if (ERROR_ALREADY_EXISTS == GetLastError())
{
CloseHandle(hMutex);
return -2;
}
SetConsoleCtrlHandler(&callback, TRUE);
const char *szServerIP = argv[1];
@@ -54,6 +60,7 @@ int main(int argc, const char *argv[])
CloseHandle(hThread);
status = E_STOP;
CloseHandle(hMutex);
return 0;
}
#else

View File

@@ -235,7 +235,7 @@ VOID IOCPClient::OnServerReceiving(char* szBuffer, ULONG ulLength)
}
int IOCPClient::OnServerSending(char* szBuffer, ULONG ulOriginalLength) //Hello
int IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength) //Hello
{
m_WriteBuffer.ClearBuffer();

View File

@@ -38,7 +38,7 @@ public:
static DWORD WINAPI WorkThreadProc(LPVOID lParam);
VOID OnServerReceiving(char* szBuffer, ULONG ulReceivedLength);
int OnServerSending(char* szBuffer, ULONG ulOriginalLength);
int OnServerSending(const char* szBuffer, ULONG ulOriginalLength);
BOOL SendWithSplit(char* szBuffer, ULONG ulLength, ULONG ulSplitLength);
BOOL IsRunning() const

View File

@@ -11,6 +11,7 @@
#else
#include <WinUser.h>
#endif
#include <time.h>
using namespace std;
//////////////////////////////////////////////////////////////////////
@@ -44,10 +45,25 @@ DWORD WINAPI CScreenManager::WorkThreadProc(LPVOID lParam)
This->WaitForDialogOpen();
This->SendFirstScreen();
clock_t last = clock();
This->SendFirstScreen();
const int fps = 8;// ֡<><D6A1>
const int sleep = 1000 / fps;// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD>䣨ms<6D><73>
while (This->m_bIsWorking)
{
This->SendNextScreen();
ULONG ulNextSendLength = 0;
const char* szBuffer = This->GetNextScreen(ulNextSendLength);
if (szBuffer)
{
int span = sleep-(clock() - last);
Sleep(span > 0 ? span : 1);
if (span < 0)
printf("SendScreen Span = %d ms\n", span);
last = clock();
This->SendNextScreen(szBuffer, ulNextSendLength);
delete[] szBuffer;
szBuffer = NULL;
}
}
cout<<"ScreenWorkThread Exit"<<endl;
@@ -196,35 +212,30 @@ VOID CScreenManager::SendFirstScreen()
szBuffer = NULL;
}
VOID CScreenManager::SendNextScreen()
const char* CScreenManager::GetNextScreen(ULONG &ulNextSendLength)
{
//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ݴ<EFBFBD>С<EFBFBD><D0A1>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD>ǵ<EFBFBD>getNextScreen<65><6E><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
LPVOID NextScreenData = NULL;
ULONG ulNextSendLength = 0;
NextScreenData = m_ScreenSpyObject->GetNextScreenData(&ulNextSendLength);
LPVOID NextScreenData = m_ScreenSpyObject->GetNextScreenData(&ulNextSendLength);
if (ulNextSendLength == 0 || NextScreenData==NULL)
{
return;
if (ulNextSendLength == 0 || NextScreenData == NULL)
{
return NULL;
}
ulNextSendLength += 1;
LPBYTE szBuffer = new BYTE[ulNextSendLength];
if (szBuffer == NULL)
{
return;
}
char* szBuffer = new char[ulNextSendLength];
szBuffer[0] = TOKEN_NEXTSCREEN;
memcpy(szBuffer + 1, NextScreenData, ulNextSendLength - 1);
m_ClientObject->OnServerSending((char*)szBuffer, ulNextSendLength);
return szBuffer;
}
delete [] szBuffer;
szBuffer = NULL;
VOID CScreenManager::SendNextScreen(const char* szBuffer, ULONG ulNextSendLength)
{
m_ClientObject->OnServerSending(szBuffer, ulNextSendLength);
}
VOID CScreenManager::ProcessCommand(LPBYTE szBuffer, ULONG ulLength)

View File

@@ -22,18 +22,19 @@ public:
HANDLE m_hWorkThread;
static DWORD WINAPI WorkThreadProc(LPVOID lParam);
VOID CScreenManager::SendBitMapInfor();
VOID CScreenManager::OnReceive(PBYTE szBuffer, ULONG ulLength);
VOID SendBitMapInfor();
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
CScreenSpy* m_ScreenSpyObject;
VOID CScreenManager::SendFirstScreen();
VOID CScreenManager::SendNextScreen();
VOID SendFirstScreen();
const char* GetNextScreen(ULONG &ulNextSendLength);
VOID SendNextScreen(const char* szBuffer, ULONG ulNextSendLength);
VOID CScreenManager::ProcessCommand(LPBYTE szBuffer, ULONG ulLength);
VOID ProcessCommand(LPBYTE szBuffer, ULONG ulLength);
BOOL m_bIsWorking;
BOOL m_bIsBlockInput;
VOID CScreenManager::SendClientClipboard();
VOID CScreenManager::UpdateClientClipboard(char *szBuffer, ULONG ulLength);
VOID SendClientClipboard();
VOID UpdateClientClipboard(char *szBuffer, ULONG ulLength);
};
#endif // !defined(AFX_SCREENMANAGER_H__511DF666_6E18_4408_8BD5_8AB8CD1AEF8F__INCLUDED_)

View File

@@ -200,10 +200,14 @@ VOID CScreenSpy::WriteRectBuffer(LPBYTE szBuffer,ULONG ulLength)
m_RectBufferOffset += ulLength;
}
VOID CScreenSpy::ScanScreen(HDC hdcDest, HDC hdcSour, ULONG ulWidth, ULONG ulHeight)
{
ULONG ulJumpLine = 50;
ULONG ulJumpSleep = ulJumpLine / 10;
#ifdef COPY_ALL
BitBlt(hdcDest, 0, 0, ulWidth, ulHeight, hdcSour, 0, 0, m_dwBitBltRop);
#else
const ULONG ulJumpLine = 50;
const ULONG ulJumpSleep = ulJumpLine / 10;
for (int i = 0, ulToJump = 0; i < ulHeight; i += ulToJump)
{
@@ -216,6 +220,7 @@ VOID CScreenSpy::ScanScreen(HDC hdcDest, HDC hdcSour, ULONG ulWidth, ULONG ulHei
BitBlt(hdcDest, 0, i, ulWidth, ulToJump, hdcSour,0, i, m_dwBitBltRop);
Sleep(ulJumpSleep);
}
#endif
}
ULONG CScreenSpy::CompareBitmap(LPBYTE CompareSourData, LPBYTE CompareDestData,

View File

@@ -9,6 +9,7 @@
#pragma once
#endif // _MSC_VER > 1000
#define ALGORITHM_DIFF 1
#define COPY_ALL 1 // <20><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>ֿ鿽<D6BF><E9BFBD><EFBFBD><EFBFBD>added by yuanyuanxiang 2019-1-7<><37>
#include "CursorInfor.h"

View File

@@ -6,5 +6,6 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments>192.168.43.165 2356</LocalDebuggerCommandArguments>
</PropertyGroup>
</Project>