This commit is contained in:
snltty
2023-09-19 00:10:02 +08:00
parent a239926ec0
commit db349521e5
85 changed files with 1569 additions and 605 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,5 @@
.vs
.svn
bin
obj
node_modules

View File

@@ -20,44 +20,75 @@
[![star](https://gitee.com/snltty/cmonitor/badge/star.svg?theme=dark)](https://gitee.com/snltty/cminitor/stargazers)
[![fork](https://gitee.com/snltty/cmonitor/badge/fork.svg?theme=dark)](https://gitee.com/snltty/cminitor/members)
使用前请确保你已知其中风险
本软件仅供学习交流,请勿用于违法犯罪
适合教培机构计算机教室监控
</div>
## 说明
1. 这是一个粗略的局域网监控程序(说是局域网,你放外网也不是不行)
2. 桌面捕获很粗略,只是做了一个减小图片尺寸,没有做区域更新
## 平台
- [x] 客户端支持 **【windows】**
- [x] 服务端支持 **【windows】**、**【linux】**
## 看图
<p><img src="./readme/cmonitor.jpg"></p>
## 支持平台
- [x] 客户端支持 **【windows】**
- [x] 服务端支持 **【windows】**、**【linux】**
## 运行参数
##### 1、公共参数
##### 1、公共
- [x] **【--mode】** 运行模式 **client,server**
##### 2、客户端
- [x] **【--server】** 服务器ip **192.168.1.18**
- [x] **【--name】** 机器名 **Dns.GetHostName()**
- [ ] **【--username-key】** 用户名内存共享key谁在用此设备 **cmonitor/username**
- [ ] **【--username-len】** 用户名内存共享长度 **255**
- [ ] **【--keyboard-key】** 键盘按键内存共享key按下哪些按键 **cmonitor/keyboard**
- [ ] **【--keyboard-len】** 键盘按键内存共享长度 **255**
- [ ] **【--share-key】** 自定义其它数据共享 **cmonitor/share**
- [ ] **【--share-len】** 长度 **255**
- [x] **【--service** 服务端口 **1802**
- [ ] **【--share-key】** 自定数据共享 **cmonitor/share**每项数据长度255
- [ ] **【--share-len】** 长度 **2550**默认预留10项位置0键盘KeyBoard、1用户名UserName、2解锁Lock、3壁纸Wallpaper、4锁屏LLock
##### 3、服务端
- [x] **【--web】** 管理UI端口 **1800**
- [x] **【--api】** 管理接口端口 **1801**
- [x] **【--service】** 服务端口 **1802**
## 安装示例
##### windows计划任务
```
//client
params = " --mode client --name cmonitor --server 192.168.1.18 --service 1802 --share-key cmonitor/share --share-len 2550";
//server
params = " --mode server --web 1800 --api 1801 --service 1802";
schtasks.exe /create /tn "cmonitor" /rl highest /sc ONLOGON /delay 0000:30 /tr "\\"{exePath}\\"{params}" /f
```
##### linux服务端
```
//1、下载linux版本程序放到 /usr/local/cmonitor 文件夹,并在文件夹下创建一个 log 目录
//3、写配置文件
vim /etc/systemd/system/cmonitor.service
[Unit]
Description=cmonitor
[Service]
WorkingDirectory=/usr/local/cmonitor
ExecStart=/usr/local/cmonitor/cmonitor --mode server --web 1800 --api 1801 --service 1802
ExecStop=/bin/kill $MAINPID
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
[Install]
WantedBy=multi-user.target
//4、重新加载配置文件
systemctl daemon-reload
//5、启动或者重新启动
systemctl start cmonitor
systemctl restart cmonitor
```
## 支持作者
请作者喝一杯咖啡,使其更有精力更新代码
<p><img src="./readme/qr.jpg" width="360"></p>

View File

@@ -15,49 +15,147 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "llock.win", "llock.win\lloc
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cmonitor.win", "cmonitor.win\cmonitor.win.csproj", "{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmonitor.volume", "cmonitor.volume\cmonitor.volume.vcxproj", "{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
ReleaseLinux|Any CPU = ReleaseLinux|Any CPU
ReleaseLinux|x64 = ReleaseLinux|x64
ReleaseLinux|x86 = ReleaseLinux|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{267DE8BE-F91C-4CCB-9D58-D33FDA661126}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{267DE8BE-F91C-4CCB-9D58-D33FDA661126}.Debug|Any CPU.Build.0 = Debug|Any CPU
{267DE8BE-F91C-4CCB-9D58-D33FDA661126}.Debug|x64.ActiveCfg = Debug|Any CPU
{267DE8BE-F91C-4CCB-9D58-D33FDA661126}.Debug|x64.Build.0 = Debug|Any CPU
{267DE8BE-F91C-4CCB-9D58-D33FDA661126}.Debug|x86.ActiveCfg = Debug|Any CPU
{267DE8BE-F91C-4CCB-9D58-D33FDA661126}.Debug|x86.Build.0 = Debug|Any CPU
{267DE8BE-F91C-4CCB-9D58-D33FDA661126}.Release|Any CPU.ActiveCfg = Release|Any CPU
{267DE8BE-F91C-4CCB-9D58-D33FDA661126}.Release|Any CPU.Build.0 = Release|Any CPU
{267DE8BE-F91C-4CCB-9D58-D33FDA661126}.Release|x64.ActiveCfg = Release|Any CPU
{267DE8BE-F91C-4CCB-9D58-D33FDA661126}.Release|x64.Build.0 = Release|Any CPU
{267DE8BE-F91C-4CCB-9D58-D33FDA661126}.Release|x86.ActiveCfg = Release|Any CPU
{267DE8BE-F91C-4CCB-9D58-D33FDA661126}.Release|x86.Build.0 = Release|Any CPU
{267DE8BE-F91C-4CCB-9D58-D33FDA661126}.ReleaseLinux|Any CPU.ActiveCfg = ReleaseLinux|Any CPU
{267DE8BE-F91C-4CCB-9D58-D33FDA661126}.ReleaseLinux|Any CPU.Build.0 = ReleaseLinux|Any CPU
{267DE8BE-F91C-4CCB-9D58-D33FDA661126}.ReleaseLinux|x64.ActiveCfg = ReleaseLinux|Any CPU
{267DE8BE-F91C-4CCB-9D58-D33FDA661126}.ReleaseLinux|x64.Build.0 = ReleaseLinux|Any CPU
{267DE8BE-F91C-4CCB-9D58-D33FDA661126}.ReleaseLinux|x86.ActiveCfg = ReleaseLinux|Any CPU
{267DE8BE-F91C-4CCB-9D58-D33FDA661126}.ReleaseLinux|x86.Build.0 = ReleaseLinux|Any CPU
{00EECF97-99EB-4B12-AAEF-ED2363914275}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00EECF97-99EB-4B12-AAEF-ED2363914275}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00EECF97-99EB-4B12-AAEF-ED2363914275}.Debug|x64.ActiveCfg = Debug|Any CPU
{00EECF97-99EB-4B12-AAEF-ED2363914275}.Debug|x64.Build.0 = Debug|Any CPU
{00EECF97-99EB-4B12-AAEF-ED2363914275}.Debug|x86.ActiveCfg = Debug|Any CPU
{00EECF97-99EB-4B12-AAEF-ED2363914275}.Debug|x86.Build.0 = Debug|Any CPU
{00EECF97-99EB-4B12-AAEF-ED2363914275}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00EECF97-99EB-4B12-AAEF-ED2363914275}.Release|Any CPU.Build.0 = Release|Any CPU
{00EECF97-99EB-4B12-AAEF-ED2363914275}.Release|x64.ActiveCfg = Release|Any CPU
{00EECF97-99EB-4B12-AAEF-ED2363914275}.Release|x64.Build.0 = Release|Any CPU
{00EECF97-99EB-4B12-AAEF-ED2363914275}.Release|x86.ActiveCfg = Release|Any CPU
{00EECF97-99EB-4B12-AAEF-ED2363914275}.Release|x86.Build.0 = Release|Any CPU
{00EECF97-99EB-4B12-AAEF-ED2363914275}.ReleaseLinux|Any CPU.ActiveCfg = ReleaseLinux|Any CPU
{00EECF97-99EB-4B12-AAEF-ED2363914275}.ReleaseLinux|Any CPU.Build.0 = ReleaseLinux|Any CPU
{00EECF97-99EB-4B12-AAEF-ED2363914275}.ReleaseLinux|x64.ActiveCfg = ReleaseLinux|Any CPU
{00EECF97-99EB-4B12-AAEF-ED2363914275}.ReleaseLinux|x64.Build.0 = ReleaseLinux|Any CPU
{00EECF97-99EB-4B12-AAEF-ED2363914275}.ReleaseLinux|x86.ActiveCfg = ReleaseLinux|Any CPU
{00EECF97-99EB-4B12-AAEF-ED2363914275}.ReleaseLinux|x86.Build.0 = ReleaseLinux|Any CPU
{386F8B8F-2E83-408E-AC3A-4BD35608EDE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{386F8B8F-2E83-408E-AC3A-4BD35608EDE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{386F8B8F-2E83-408E-AC3A-4BD35608EDE3}.Debug|x64.ActiveCfg = Debug|Any CPU
{386F8B8F-2E83-408E-AC3A-4BD35608EDE3}.Debug|x64.Build.0 = Debug|Any CPU
{386F8B8F-2E83-408E-AC3A-4BD35608EDE3}.Debug|x86.ActiveCfg = Debug|Any CPU
{386F8B8F-2E83-408E-AC3A-4BD35608EDE3}.Debug|x86.Build.0 = Debug|Any CPU
{386F8B8F-2E83-408E-AC3A-4BD35608EDE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{386F8B8F-2E83-408E-AC3A-4BD35608EDE3}.Release|Any CPU.Build.0 = Release|Any CPU
{386F8B8F-2E83-408E-AC3A-4BD35608EDE3}.Release|x64.ActiveCfg = Release|Any CPU
{386F8B8F-2E83-408E-AC3A-4BD35608EDE3}.Release|x64.Build.0 = Release|Any CPU
{386F8B8F-2E83-408E-AC3A-4BD35608EDE3}.Release|x86.ActiveCfg = Release|Any CPU
{386F8B8F-2E83-408E-AC3A-4BD35608EDE3}.Release|x86.Build.0 = Release|Any CPU
{386F8B8F-2E83-408E-AC3A-4BD35608EDE3}.ReleaseLinux|Any CPU.ActiveCfg = ReleaseLinux|Any CPU
{386F8B8F-2E83-408E-AC3A-4BD35608EDE3}.ReleaseLinux|Any CPU.Build.0 = ReleaseLinux|Any CPU
{386F8B8F-2E83-408E-AC3A-4BD35608EDE3}.ReleaseLinux|x64.ActiveCfg = ReleaseLinux|Any CPU
{386F8B8F-2E83-408E-AC3A-4BD35608EDE3}.ReleaseLinux|x64.Build.0 = ReleaseLinux|Any CPU
{386F8B8F-2E83-408E-AC3A-4BD35608EDE3}.ReleaseLinux|x86.ActiveCfg = ReleaseLinux|Any CPU
{386F8B8F-2E83-408E-AC3A-4BD35608EDE3}.ReleaseLinux|x86.Build.0 = ReleaseLinux|Any CPU
{88FF2017-FF1A-4E9F-AB2E-2973C5B35C34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88FF2017-FF1A-4E9F-AB2E-2973C5B35C34}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88FF2017-FF1A-4E9F-AB2E-2973C5B35C34}.Debug|x64.ActiveCfg = Debug|Any CPU
{88FF2017-FF1A-4E9F-AB2E-2973C5B35C34}.Debug|x64.Build.0 = Debug|Any CPU
{88FF2017-FF1A-4E9F-AB2E-2973C5B35C34}.Debug|x86.ActiveCfg = Debug|Any CPU
{88FF2017-FF1A-4E9F-AB2E-2973C5B35C34}.Debug|x86.Build.0 = Debug|Any CPU
{88FF2017-FF1A-4E9F-AB2E-2973C5B35C34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88FF2017-FF1A-4E9F-AB2E-2973C5B35C34}.Release|Any CPU.Build.0 = Release|Any CPU
{88FF2017-FF1A-4E9F-AB2E-2973C5B35C34}.Release|x64.ActiveCfg = Release|Any CPU
{88FF2017-FF1A-4E9F-AB2E-2973C5B35C34}.Release|x64.Build.0 = Release|Any CPU
{88FF2017-FF1A-4E9F-AB2E-2973C5B35C34}.Release|x86.ActiveCfg = Release|Any CPU
{88FF2017-FF1A-4E9F-AB2E-2973C5B35C34}.Release|x86.Build.0 = Release|Any CPU
{88FF2017-FF1A-4E9F-AB2E-2973C5B35C34}.ReleaseLinux|Any CPU.ActiveCfg = ReleaseLinux|Any CPU
{88FF2017-FF1A-4E9F-AB2E-2973C5B35C34}.ReleaseLinux|Any CPU.Build.0 = ReleaseLinux|Any CPU
{88FF2017-FF1A-4E9F-AB2E-2973C5B35C34}.ReleaseLinux|x64.ActiveCfg = ReleaseLinux|Any CPU
{88FF2017-FF1A-4E9F-AB2E-2973C5B35C34}.ReleaseLinux|x64.Build.0 = ReleaseLinux|Any CPU
{88FF2017-FF1A-4E9F-AB2E-2973C5B35C34}.ReleaseLinux|x86.ActiveCfg = ReleaseLinux|Any CPU
{88FF2017-FF1A-4E9F-AB2E-2973C5B35C34}.ReleaseLinux|x86.Build.0 = ReleaseLinux|Any CPU
{DD7F9ABD-7718-454B-950D-A369C6D85FE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD7F9ABD-7718-454B-950D-A369C6D85FE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD7F9ABD-7718-454B-950D-A369C6D85FE4}.Debug|x64.ActiveCfg = Debug|Any CPU
{DD7F9ABD-7718-454B-950D-A369C6D85FE4}.Debug|x64.Build.0 = Debug|Any CPU
{DD7F9ABD-7718-454B-950D-A369C6D85FE4}.Debug|x86.ActiveCfg = Debug|Any CPU
{DD7F9ABD-7718-454B-950D-A369C6D85FE4}.Debug|x86.Build.0 = Debug|Any CPU
{DD7F9ABD-7718-454B-950D-A369C6D85FE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD7F9ABD-7718-454B-950D-A369C6D85FE4}.Release|Any CPU.Build.0 = Release|Any CPU
{DD7F9ABD-7718-454B-950D-A369C6D85FE4}.Release|x64.ActiveCfg = Release|Any CPU
{DD7F9ABD-7718-454B-950D-A369C6D85FE4}.Release|x64.Build.0 = Release|Any CPU
{DD7F9ABD-7718-454B-950D-A369C6D85FE4}.Release|x86.ActiveCfg = Release|Any CPU
{DD7F9ABD-7718-454B-950D-A369C6D85FE4}.Release|x86.Build.0 = Release|Any CPU
{DD7F9ABD-7718-454B-950D-A369C6D85FE4}.ReleaseLinux|Any CPU.ActiveCfg = ReleaseLinux|Any CPU
{DD7F9ABD-7718-454B-950D-A369C6D85FE4}.ReleaseLinux|Any CPU.Build.0 = ReleaseLinux|Any CPU
{DD7F9ABD-7718-454B-950D-A369C6D85FE4}.ReleaseLinux|x64.ActiveCfg = ReleaseLinux|Any CPU
{DD7F9ABD-7718-454B-950D-A369C6D85FE4}.ReleaseLinux|x64.Build.0 = ReleaseLinux|Any CPU
{DD7F9ABD-7718-454B-950D-A369C6D85FE4}.ReleaseLinux|x86.ActiveCfg = ReleaseLinux|Any CPU
{DD7F9ABD-7718-454B-950D-A369C6D85FE4}.ReleaseLinux|x86.Build.0 = ReleaseLinux|Any CPU
{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}.Debug|x64.ActiveCfg = Debug|Any CPU
{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}.Debug|x64.Build.0 = Debug|Any CPU
{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}.Debug|x86.ActiveCfg = Debug|Any CPU
{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}.Debug|x86.Build.0 = Debug|Any CPU
{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}.Release|Any CPU.Build.0 = Release|Any CPU
{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}.Release|x64.ActiveCfg = Release|Any CPU
{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}.Release|x64.Build.0 = Release|Any CPU
{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}.Release|x86.ActiveCfg = Release|Any CPU
{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}.Release|x86.Build.0 = Release|Any CPU
{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}.ReleaseLinux|Any CPU.ActiveCfg = ReleaseLinux|Any CPU
{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}.ReleaseLinux|Any CPU.Build.0 = ReleaseLinux|Any CPU
{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}.ReleaseLinux|x64.ActiveCfg = ReleaseLinux|Any CPU
{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}.ReleaseLinux|x64.Build.0 = ReleaseLinux|Any CPU
{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}.ReleaseLinux|x86.ActiveCfg = ReleaseLinux|Any CPU
{9170E23A-B7CA-485F-AE8A-6BC9D29D4C67}.ReleaseLinux|x86.Build.0 = ReleaseLinux|Any CPU
{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}.Debug|Any CPU.ActiveCfg = Debug|x64
{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}.Debug|Any CPU.Build.0 = Debug|x64
{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}.Debug|x64.ActiveCfg = Debug|x64
{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}.Debug|x64.Build.0 = Debug|x64
{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}.Debug|x86.ActiveCfg = Debug|Win32
{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}.Debug|x86.Build.0 = Debug|Win32
{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}.Release|Any CPU.ActiveCfg = Release|x64
{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}.Release|Any CPU.Build.0 = Release|x64
{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}.Release|x64.ActiveCfg = Release|x64
{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}.Release|x64.Build.0 = Release|x64
{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}.Release|x86.ActiveCfg = Release|Win32
{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}.Release|x86.Build.0 = Release|Win32
{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}.ReleaseLinux|Any CPU.ActiveCfg = Release|x64
{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}.ReleaseLinux|Any CPU.Build.0 = Release|x64
{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}.ReleaseLinux|x64.ActiveCfg = Release|x64
{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}.ReleaseLinux|x64.Build.0 = Release|x64
{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}.ReleaseLinux|x86.ActiveCfg = Release|Win32
{EDA47DD6-82DC-415C-A3CC-35A564FF0D0F}.ReleaseLinux|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -0,0 +1,160 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{eda47dd6-82dc-415c-a3cc-35a564ff0d0f}</ProjectGuid>
<RootNamespace>cmonitorvolume</RootNamespace>
<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>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)\$(ProjectName)\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;CMONITORVOLUME_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;CMONITORVOLUME_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;CMONITORVOLUME_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;CMONITORVOLUME_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="framework.h" />
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="pch.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="pch.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerCommandArguments>-lWinmm</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>

212
cmonitor.volume/dllmain.cpp Normal file
View File

@@ -0,0 +1,212 @@
// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "pch.h"
#include <Windows.h>
#include <mmdeviceapi.h>
#include <endpointvolume.h>
BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
extern "C" __declspec(dllexport) IMMDeviceEnumerator * InitEnumerator()
{
HRESULT hr;
hr = CoInitialize(nullptr);
if (FAILED(hr))
{
return NULL;
}
IMMDeviceEnumerator* pEnumerator = NULL;
hr = CoCreateInstance(
__uuidof(MMDeviceEnumerator),
NULL,
CLSCTX_ALL,
__uuidof(IMMDeviceEnumerator),
(LPVOID*)&pEnumerator
);
if (FAILED(hr))
{
return NULL;
}
return pEnumerator;
}
extern "C" __declspec(dllexport) IMMDevice * InitDevice(IMMDeviceEnumerator * pEnumerator)
{
if (pEnumerator == NULL)
{
return NULL;
}
IMMDevice* pDevice = NULL;
// 获取默认音频渲染设备
HRESULT hr = pEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &pDevice);
if (FAILED(hr)) {
// 错误处理
CoUninitialize();
return NULL;
}
return pDevice;
}
extern "C" __declspec(dllexport) IAudioEndpointVolume * InitVolume(IMMDevice * pDevice)
{
if (pDevice == NULL)
{
return NULL;
}
IAudioEndpointVolume* pEndpointVolume = NULL;
HRESULT hr;
hr = pDevice->Activate(
__uuidof(IAudioEndpointVolume),
CLSCTX_ALL,
NULL,
(LPVOID*)&pEndpointVolume
);
if (FAILED(hr))
{
CoUninitialize();
return NULL;
}
return pEndpointVolume;
}
extern "C" __declspec(dllexport) IAudioMeterInformation * InitMeterInfo(IMMDevice * pDevice) {
if (pDevice == NULL)
{
return NULL;
}
IAudioMeterInformation* pMeterInfo = NULL;
HRESULT hr = pDevice->Activate(
__uuidof(IAudioMeterInformation),
CLSCTX_ALL,
nullptr,
reinterpret_cast<void**>(&pMeterInfo));
if (FAILED(hr))
{
CoUninitialize();
return NULL;
}
return pMeterInfo;
}
extern "C" __declspec(dllexport) bool FreeVolume(IMMDeviceEnumerator * pEnumerator, IMMDevice * pDevice, IAudioEndpointVolume * pEndpointVolume, IAudioMeterInformation * pMeterInfo)
{
if (pEnumerator != NULL)
{
pEnumerator->Release();
}
if (pDevice != NULL)
{
pDevice->Release();
}
if (pEndpointVolume != NULL)
{
pEndpointVolume->Release();
}
if (pMeterInfo != NULL)
{
pMeterInfo->Release();
}
CoUninitialize();
return true;
}
extern "C" __declspec(dllexport) float GetSystemVolume(IAudioEndpointVolume * pEndpointVolume)
{
if (pEndpointVolume == NULL)
{
return 1;
}
float volume = 0.0f;
HRESULT hr = pEndpointVolume->GetMasterVolumeLevelScalar(&volume);
if (FAILED(hr))
{
return 2;
}
return 3;
}
extern "C" __declspec(dllexport) float GetSystemMasterPeak(IAudioMeterInformation * pMeterInfo)
{
if (pMeterInfo == NULL)
{
return 0;
}
float peakValue = 0.0f;
HRESULT hr = pMeterInfo->GetPeakValue(&peakValue);
if (FAILED(hr))
{
return 0;
}
return peakValue;
}
extern "C" __declspec(dllexport) int SetSystemVolume(IAudioEndpointVolume * pEndpointVolume, float volume)
{
if (pEndpointVolume == NULL)
{
return false;
}
HRESULT hr = pEndpointVolume->SetMasterVolumeLevelScalar(volume, NULL);
if (FAILED(hr))
{
return false;
}
return true;
}
extern "C" __declspec(dllexport) bool GetSystemMute(IAudioEndpointVolume * pEndpointVolume)
{
if (pEndpointVolume == NULL)
{
return 0;
}
BOOL mute;
HRESULT hr = pEndpointVolume->GetMute(&mute);
if (FAILED(hr))
{
return mute;
}
return mute;
}
extern "C" __declspec(dllexport) bool SetSystemMute(IAudioEndpointVolume * pEndpointVolume, BOOL mute)
{
if (pEndpointVolume == NULL)
{
return 0;
}
HRESULT hr = pEndpointVolume->SetMute(mute, NULL);
if (FAILED(hr))
{
return false;
}
return true;
}

View File

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

5
cmonitor.volume/pch.cpp Normal file
View File

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

13
cmonitor.volume/pch.h Normal file
View File

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

View File

@@ -0,0 +1 @@
x64\Release\\_IsIncrementalBuild

View File

@@ -0,0 +1,18 @@
d:\desktop\cmonitor\cmonitor.volume\x64\release\cmonitor.volume.pch
d:\desktop\cmonitor\cmonitor.volume\x64\release\vc143.pdb
d:\desktop\cmonitor\cmonitor.volume\x64\release\pch.obj
d:\desktop\cmonitor\cmonitor.volume\x64\release\dllmain.obj
d:\desktop\cmonitor\cmonitor.volume\x64\release\cmonitor.volume.dll
d:\desktop\cmonitor\cmonitor.volume\x64\release\cmonitor.volume.pdb
d:\desktop\cmonitor\cmonitor.volume\x64\release\cmonitor.volume.lib
d:\desktop\cmonitor\cmonitor.volume\x64\release\cmonitor.volume.exp
d:\desktop\cmonitor\cmonitor.volume\x64\release\cmonitor.volume.ipdb
d:\desktop\cmonitor\cmonitor.volume\x64\release\cmonitor.volume.iobj
d:\desktop\cmonitor\\cmonitor.volume\x64\release\cmonitor.volume.pdb
d:\desktop\cmonitor\cmonitor.volume\x64\release\cmonitor.volume.tlog\cl.command.1.tlog
d:\desktop\cmonitor\cmonitor.volume\x64\release\cmonitor.volume.tlog\cl.read.1.tlog
d:\desktop\cmonitor\cmonitor.volume\x64\release\cmonitor.volume.tlog\cl.write.1.tlog
d:\desktop\cmonitor\cmonitor.volume\x64\release\cmonitor.volume.tlog\link.command.1.tlog
d:\desktop\cmonitor\cmonitor.volume\x64\release\cmonitor.volume.tlog\link.read.1.tlog
d:\desktop\cmonitor\cmonitor.volume\x64\release\cmonitor.volume.tlog\link.write.1.tlog
d:\desktop\cmonitor\cmonitor.volume\x64\release\cmonitor.volume.tlog\link.write.2u.tlog

Binary file not shown.

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ProjectOutputs>
<ProjectOutput>
<FullPath>D:\desktop\cmonitor\cmonitor.volume\x64\Release\cmonitor.volume.dll</FullPath>
</ProjectOutput>
</ProjectOutputs>
<ContentFiles />
<SatelliteDlls />
<NonRecipeFileRefs />
</Project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,8 @@
 pch.cpp
dllmain.cpp
正在创建库 D:\desktop\cmonitor\\cmonitor.volume\x64\Release\cmonitor.volume.lib 和对象 D:\desktop\cmonitor\\cmonitor.volume\x64\Release\cmonitor.volume.exp
正在生成代码
Previous IPDB not found, fall back to full compilation.
All 11 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
已完成代码的生成
cmonitor.volume.vcxproj -> D:\desktop\cmonitor\cmonitor.volume\x64\Release\cmonitor.volume.dll

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,2 @@
PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.34.31933:TargetPlatformVersion=10.0.22621.0:
Release|x64|D:\desktop\cmonitor\|

View File

@@ -0,0 +1 @@
D:\desktop\cmonitor\cmonitor.volume\x64\Release\cmonitor.volume.dll

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -6,9 +6,9 @@ export const getActiveTimes = (name) => {
export const activeTimesClear = (name) => {
return sendWebsocketMsg('active/clear', name);
}
export const activeDisallow = (names, filenames) => {
export const activeDisallow = (names, filenames, ids) => {
return sendWebsocketMsg('active/disallow', {
names, filenames
names, filenames, ids: ids || []
});
}

View File

@@ -0,0 +1,7 @@
import { sendWebsocketMsg } from './request'
export const shareUpdate = (name, item) => {
return sendWebsocketMsg('share/update', {
name, item
});
}

View File

@@ -2,7 +2,7 @@
<div class="checkbox-wrap absolute flex flex-column">
<div class="head flex">
<span>
<el-checkbox :indeterminate="state.isIndeterminate" v-model="state.checkAll" @change="handleCheckAllChange" :label="state.title" size="large" />
<el-checkbox :indeterminate="state.isIndeterminate" v-model="state.checkAll" @change="handleCheckAllChange" :label="state.title" />
</span>
<span class="flex-1"></span>
<slot name="title"></slot>
@@ -13,7 +13,7 @@
<template v-for="(item,index) in state.data" :key="index">
<li class="flex">
<div class="flex-1">
<el-checkbox :label="item[state.label]" size="large">
<el-checkbox :label="item[state.label]">
<slot name="name" :item="item">
{{item[state.text]}}
</slot>

View File

@@ -7,7 +7,7 @@
<div class="flex-1"></div>
<div class="Exes flex flex-column">
<div class="private">
<CheckBoxWrap ref="privateExes" :data="state.privateExes" :items="[]" label="FileName" text="Desc" title="私有窗口">
<CheckBoxWrap ref="privateExes" :data="state.privateExes" :items="state.currentPrivate" label="ID" text="Desc" title="私有窗口">
<template #name="scoped">
{{scoped.item.Desc || scoped.item.FileName }}
</template>
@@ -15,7 +15,7 @@
</div>
<div class="flex-1"></div>
<div class="public">
<CheckBoxWrap ref="publicExes" :data="state.publicExes" :items="[]" label="FileName" text="Desc" title="公共窗口">
<CheckBoxWrap ref="publicExes" :data="state.publicExes" :items="state.currentPublic" label="ID" text="Desc" title="公共窗口">
<template #name="scoped">
{{scoped.item.Desc || scoped.item.FileName }}
</template>
@@ -56,7 +56,9 @@ export default {
items: computed(() => pluginState.value.activeWindow.devices),
privateExes: computed(() => user.value ? user.value.FileNames : []),
publicExes: computed(() => usePublic ? publicUser.value.FileNames : []),
loading: false
loading: false,
currentPrivate: [],
currentPublic: [],
});
watch(() => state.show, (val) => {
if (!val) {
@@ -68,16 +70,23 @@ export default {
onMounted(() => {
globalData.value.updateFlag = Date.now();
if (state.items.length == 1) {
let item = state.items[0];
state.currentPrivate = state.privateExes.filter(c => item.DisallowRunIds.indexOf(c.ID) >= 0);
state.currentPublic = state.publicExes.filter(c => item.DisallowRunIds.indexOf(c.ID) >= 0);
}
});
const devices = ref(null);
const privateExes = ref(null);
const publicExes = ref(null);
const parseRule = () => {
const _privateExes = privateExes.value.getData();
const _publicExes = publicExes.value.getData();
return _privateExes.concat(_publicExes).reduce((data, item, index) => {
let arr = item.split(',');
const _privateIds = privateExes.value.getData();
const _privateExes = state.privateExes.filter(c => _privateIds.indexOf(c.ID) >= 0);
const _publicIds = publicExes.value.getData();
const _publicExes = state.publicExes.filter(c => _publicIds.indexOf(c.ID) >= 0);
const exes = _privateExes.concat(_publicExes).reduce((data, item, index) => {
let arr = item.FileName.split(',');
for (let i = 0; i < arr.length; i++) {
if (data.indexOf(arr[i]) == -1) {
data.push(arr[i]);
@@ -85,6 +94,13 @@ export default {
}
return data;
}, []);
if (exes.length == 0) {
exes.push('snltty');
}
return {
ids: _privateIds.concat(_publicIds),
exes: exes
};
}
const handleSubmit = () => {
const _devices = devices.value.getData();
@@ -100,9 +116,12 @@ export default {
}).then(() => {
state.loading = true;
const exes = parseRule();
activeDisallow(_devices, exes).then((res) => {
activeDisallow(_devices, exes.exes, exes.ids).then((res) => {
state.loading = false;
ElMessage.success('操作成功!');
globalData.value.devices.filter(c => _devices.indexOf(c.MachineName) >= 0).forEach(device => {
device.DisallowRunIds = exes.ids;
});
}).catch((e) => {
state.loading = false;
ElMessage.error('操作失败');

View File

@@ -1,5 +1,5 @@
<template>
<a v-if="data.ActiveWindow.Pid>0" class="process flex" href="javascript:;" @click="handleCloseActive">
<a class="process flex" href="javascript:;" @click="handleCloseActive">
<span class="title flex-1">{{data.ActiveWindow.Title}}</span>
<p class="btn">
<a href="javascript:;" @click.stop="handleChoose">
@@ -54,14 +54,20 @@ export default {
}
const handleAddExe = () => {
const arr = props.data.ActiveWindow.FileName.split('\\');
const fileName = arr[arr.length - 1];
const desc = props.data.ActiveWindow.Desc;
let fileName = arr[arr.length - 1];
let desc = props.data.ActiveWindow.Desc;
const title = props.data.ActiveWindow.Title;
let html = `</p>是否确定添加到待选列表?</p>`;
html += `<p>标题:【${title}】</p>`;
if (desc != 'Application Frame Host') {
html += `<p>描述:【${desc}】</p>`;
html += `<p>文件:【${fileName}】</p>`;
html += `<p>windows商店应用可能无法阻止需要手动添加例如【计算器】以侦测程序关闭</p>`;
} else {
fileName = title;
desc = title;
}
ElMessageBox.confirm(html, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@@ -119,7 +125,7 @@ export default {
.btn {
a {
font-size: 1.6rem;
color: #adbfcc;
color: #fff;
margin-left: 0.6rem;
position: relative;
@@ -128,7 +134,7 @@ export default {
position: absolute;
right: 110%;
top: -20%;
color: #7c95a7;
color: #fff;
}
}
}

View File

@@ -34,7 +34,8 @@ a {
left: 110%;
top: 50%;
transform: translateY(-50%);
color: #7c95a7;
color: rgba(255, 255, 255, 255);
text-shadow: 1px 1px 1px rgba(0, 0, 0, 255);
font-size: 1.4rem;
}
}

View File

@@ -7,11 +7,11 @@
<div class="flex-1"></div>
<div class="rules flex flex-column">
<div class="private">
<CheckBoxWrap ref="privateRules" :data="state.privateRules" :items="[]" label="ID" text="Name" title="私有限制"></CheckBoxWrap>
<CheckBoxWrap ref="privateRules" :data="state.privateRules" :items="state.currentPrivate" label="ID" text="Name" title="私有限制"></CheckBoxWrap>
</div>
<div class="flex-1"></div>
<div class="public">
<CheckBoxWrap ref="publicRules" :data="state.publicRules" :items="[]" label="ID" text="Name" title="公共限制"></CheckBoxWrap>
<CheckBoxWrap ref="publicRules" :data="state.publicRules" :items="state.currentPublic" label="ID" text="Name" title="公共限制"></CheckBoxWrap>
</div>
</div>
</div>
@@ -24,7 +24,7 @@
<script>
import { reactive, ref } from '@vue/reactivity';
import { computed, inject, watch } from '@vue/runtime-core';
import { computed, inject, onMounted, watch } from '@vue/runtime-core';
import CheckBoxWrap from '../../boxs/CheckBoxWrap.vue'
import { ElMessage, ElMessageBox } from 'element-plus';
import { setRules } from '../../../../apis/hijack'
@@ -48,7 +48,9 @@ export default {
items: computed(() => pluginState.value.hijack.showRulesItems),
privateRules: computed(() => user.value ? user.value.Rules : []),
publicRules: computed(() => usePublic ? publicUser.value.Rules : []),
loading: false
loading: false,
currentPrivate: [],
currentPublic: [],
});
watch(() => state.show, (val) => {
if (!val) {
@@ -57,6 +59,13 @@ export default {
}, 300);
}
});
onMounted(() => {
if (state.items.length == 1) {
let item = state.items[0];
state.currentPrivate = state.privateRules.filter(c => item.RuleIds.indexOf(c.ID) >= 0);
state.currentPublic = state.publicRules.filter(c => item.RuleIds.indexOf(c.ID) >= 0);
}
});
const devices = ref(null);
const privateRules = ref(null);
@@ -89,6 +98,8 @@ export default {
});
return {
ids: _privateRules.concat(_publicRules),
list: {
AllowProcesss: res.filter(c => c.DataType == 0 && c.AllowType == 0).map(c => c.Name),
DeniedProcesss: res.filter(c => c.DataType == 0 && c.AllowType == 1).map(c => c.Name),
AllowDomains: res.filter(c => c.DataType == 1 && c.AllowType == 0).map(c => c.Name),
@@ -97,6 +108,7 @@ export default {
DeniedIPs: res.filter(c => c.DataType == 2 && c.AllowType == 1).map(c => c.Name),
}
}
}
const handleSubmit = () => {
const _devices = devices.value.getData();
if (_devices.length == 0) {
@@ -104,7 +116,6 @@ export default {
return;
}
ElMessageBox.confirm('如果未选择任何限制,则视为清空限制,是否确定应用限制?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@@ -115,13 +126,17 @@ export default {
const rules = parseRule();
setRules({
Devices: _devices,
Rules: rules
Rules: rules.list,
ids: rules.ids
}).then((errorDevices) => {
state.loading = false;
if (errorDevices && errorDevices.length > 0) {
ElMessage.error(`操作失败,失败设备:${errorDevices.join(',')}`);
} else {
ElMessage.success('操作成功!');
globalData.value.devices.filter(c => _devices.indexOf(c.MachineName) >= 0).forEach(device => {
device.RuleIds = rules.ids;
});
}
}).catch((e) => {
state.loading = false;

View File

@@ -40,7 +40,8 @@ a {
}
.light-value {
color: #7c95a7;
color: #fff;
text-shadow: 1px 1px 1px rgba(0, 0, 0, 255);
font-size: 1.4rem;
position: absolute;
right: 110%;

View File

@@ -59,8 +59,8 @@ export default {
loading: false
});
try {
if (pluginState.value.message.items.length == 1 && pluginState.value.message.items[0].Screen.UserName) {
state.prevs.push(`${pluginState.value.message.items[0].Screen.UserName}】请注意上课纪律!`);
if (pluginState.value.message.items.length == 1 && pluginState.value.message.items[0].Share.UserName) {
state.prevs.push(`${pluginState.value.message.items[0].Share.UserName}】请注意上课纪律!`);
}
} catch (e) {
}

View File

@@ -8,11 +8,7 @@ export default {
fps: 0,
fpsTimes: 0,
img: null,
LastInput: 0,
UserName: '',
KeyBoard: '',
KeyBoardOld: '',
KeyBoardLength: 0,
LastInput: 0
}
};
},
@@ -44,7 +40,6 @@ export default {
item.ctx.clearRect(0, 0, item.canvas.width, item.canvas.height);
item.ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, item.canvas.width, item.canvas.height);
this.drawFps(item);
this.drawKeyboard(item);
}
for (let j in item) {
try {
@@ -61,20 +56,6 @@ export default {
this.draw();
});
},
drawKeyboard(item) {
if (item.Screen.KeyBoard && item.Screen.KeyBoardLength < 60) {
item.Screen.KeyBoardLength++;
item.ctx.lineWidth = 10;
let top = (item.canvas.height - 100) / 2;
let left = (item.canvas.width - 50 * item.Screen.KeyBoard.length) / 2;
item.ctx.font = 'bold 100px Arial';
item.ctx.fillStyle = 'rgba(0,0,0,0.5)';
item.ctx.fillText(`${item.Screen.KeyBoard}`, left, top);
item.ctx.lineWidth = 5;
item.ctx.strokeStyle = 'rgba(255,255,255,0.7)';
item.ctx.strokeText(`${item.Screen.KeyBoard}`, left, top);
}
},
drawFps(item) {
item.ctx.lineWidth = 5;
item.ctx.font = 'bold 60px Arial';
@@ -145,12 +126,7 @@ export default {
update(item, report) {
if (report.Screen) {
item.Screen.LastInput = report.Screen.LastInput || '0';
item.Screen.UserName = report.Screen.UserName || '';
if (report.Screen.KeyBoard != item.Screen.KeyBoard) {
item.Screen.KeyBoard = report.Screen.KeyBoard || '';
item.Screen.KeyBoardLength = 0;
}
item.Screen.LastInput = report.Screen.LastInput || 0;
}
}
}

View File

@@ -0,0 +1,103 @@
<template>
<div class="share-lock-wrap" v-if="data.Share.Lock.Value == 'ask'">
<div class="inner">
<h3>请求解锁</h3>
<div>
<el-popconfirm confirm-button-text="确认" cancel-button-text="取消" title="确认驳回请求吗?" @confirm="handleReject">
<template #reference>
<el-button :loading="state.loading" type="danger" plain round size="small">驳回</el-button>
</template>
</el-popconfirm>
<el-popconfirm confirm-button-text="确认" cancel-button-text="取消" title="确认通过请求吗?" @confirm="handleConfirm">
<template #reference>
<el-button :loading="state.loading" type="success" plain round size="small">确认</el-button>
</template>
</el-popconfirm>
</div>
</div>
</div>
</template>
<script>
import { reactive } from 'vue'
import { shareUpdate } from '@/apis/share'
import { ElMessage } from 'element-plus';
export default {
props: ['data'],
setup(props) {
const state = reactive({
loading: false
});
const handleReject = () => {
state.loading = true;
shareUpdate(props.data.MachineName, {
index: props.data.Share.Lock.Index,
value: 'reject'
}).then((res) => {
state.loading = false;
if (res) {
ElMessage.success('操作成功!');
} else {
ElMessage.error('操作失败!');
}
}).catch(() => {
state.loading = false;
ElMessage.error('操作失败!');
});
}
const handleConfirm = () => {
state.loading = true;
shareUpdate(props.data.MachineName, {
index: props.data.Share.Lock.Index,
value: 'confirm'
}).then((res) => {
state.loading = false;
if (res) {
ElMessage.success('操作成功!');
} else {
ElMessage.error('操作失败!');
}
}).catch(() => {
state.loading = false;
ElMessage.error('操作失败!');
});
}
return {
data: props.data, state, handleReject, handleConfirm
}
}
}
</script>
<style lang="stylus" scoped>
.share-lock-wrap {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
// background-color: rgba(0, 0, 0, 0.2);
.inner {
position: absolute;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-70%);
text-align: center;
border: 1px solid #fff;
background-color: rgba(0, 0, 0, 0.3);
padding: 1rem;
z-index: 2;
border-radius: 0.4rem;
h3 {
font-size: 1.6rem;
font-weight: 600;
color: #fff;
padding-bottom: 1rem;
}
}
}
</style>

View File

@@ -0,0 +1,21 @@
<template>
<i class="user-name" v-if="data.Share.UserName.Value"> - {{data.Share.UserName.Value}}</i>
</template>
<script>
export default {
props: ['data'],
setup(props) {
return {
data: props.data
}
}
}
</script>
<style lang="stylus" scoped>
i.user-name {
color: #666;
}
</style>

View File

@@ -0,0 +1,42 @@
export default {
field() {
return {
Share: {
KeyBoard: { Index: 0, Value: '' },
UserName: { Index: 1, Value: '' },
Lock: { Index: 2, Value: '' },
draw(canvas, ctx) {
if (this.KeyBoard.Value) {
let top = (canvas.height - 100) / 2;
let left = (canvas.width - 50 * this.KeyBoard.Value.length) / 2;
ctx.font = 'bold 100px Arial';
ctx.fillStyle = 'rgba(0,0,0,0.5)';
ctx.fillText(`${this.KeyBoard.Value}`, left, top);
ctx.lineWidth = 5;
ctx.strokeStyle = 'rgba(255,255,255,0.7)';
ctx.strokeText(`${this.KeyBoard.Value}`, left, top);
}
}
}
};
},
init() {
},
update(item, report) {
console.log(report.Share);
if (report.Share) {
if (report.Share.UserName) {
item.Share.UserName.Index = report.Share.UserName.Index;
item.Share.UserName.Value = report.Share.UserName.Value;
}
if (report.Share.Lock) {
item.Share.Lock.Index = report.Share.Lock.Index;
item.Share.Lock.Value = report.Share.Lock.Value;
}
if (report.Share.KeyBoard) {
item.Share.KeyBoard.Index = report.Share.KeyBoard.Index;
item.Share.KeyBoard.Value = report.Share.KeyBoard.Value;
}
}
}
}

View File

@@ -47,7 +47,8 @@ a {
}
.volume-value {
color: #7c95a7;
color: #fff;
text-shadow: 1px 1px 1px rgba(0, 0, 0, 255);
font-size: 1.4rem;
position: absolute;
right: 110%;

View File

@@ -6,7 +6,9 @@
<div class="value flex">
<span class="name" :class="{connected:data.Connected}">
<span class="machine-mame">{{data.MachineName}}</span>
<i class="user-name" v-if="data.Screen.UserName"> - {{data.Screen.UserName}}</i>
<template v-for="(item,index) in titleLeftModules" :key="index">
<component :is="item" :data="data"></component>
</template>
</span>
<span class="flex-1"></span>
<template v-for="(item,index) in titleRightModules" :key="index">
@@ -57,6 +59,8 @@ export default {
setup(props, { emit }) {
const data = props.data;
const titleLeftFiles = require.context('../plugins/', true, /TitleLeft\.vue/);
const titleLeftModules = titleLeftFiles.keys().map(c => titleLeftFiles(c).default);
const titleRightFiles = require.context('../plugins/', true, /TitleRight\.vue/);
const titleRightModules = titleRightFiles.keys().map(c => titleRightFiles(c).default);
@@ -74,7 +78,7 @@ export default {
const optionModules = optionFiles.keys().map(c => optionFiles(c).default).sort((a, b) => (a.sort || 0) - (b.sort || 0));
return {
data, titleRightModules, screenModules, btnLeftModules, btnRightModules, optionModules
data, titleLeftModules, titleRightModules, screenModules, btnLeftModules, btnRightModules, optionModules
}
}
}
@@ -114,13 +118,6 @@ export default {
color: green;
font-weight: bold;
}
span.machine-mame {
}
i.user-name {
color: #666;
}
}
}

View File

@@ -27,6 +27,8 @@ using cmonitor.server.client.reports;
using common.libs.extends;
using cmonitor.server.service.messengers.light;
using System.Reflection;
using cmonitor.server.client.reports.share;
using cmonitor.server.service.messengers.share;
namespace cmonitor
{
@@ -34,48 +36,86 @@ namespace cmonitor
{
static async Task Main(string[] args)
{
//单服务
Mutex mutex = new Mutex(true, System.Diagnostics.Process.GetCurrentProcess().ProcessName, out bool isAppRunning);
if (isAppRunning == false)
{
Environment.Exit(1);
}
//全局异常
AppDomain.CurrentDomain.UnhandledException += (a, b) =>
{
Logger.Instance.Error(b.ExceptionObject + "");
};
//线程数
ThreadPool.SetMinThreads(1024, 1024);
ThreadPool.SetMaxThreads(65535, 65535);
//日志输出
LoggerConsole();
//初始化配置文件
Config config = new Config();
Dictionary<string, string> dic = ArgumentParser.Parse(args, out string error);
config.BroadcastIP = IPAddress.Parse(dic["server"]);
config.Name = dic["name"];
config.WebPort = int.Parse(dic["web"]);
config.ApiPort = int.Parse(dic["api"]);
config.ServicePort = int.Parse(dic["service"]);
config.UserNameMemoryKey = dic["username-key"];
config.UserNameMemoryLength = int.Parse(dic["username-len"]);
config.KeyboardMemoryKey = dic["keyboard-key"];
config.KeyboardMemoryLength = int.Parse(dic["keyboard-len"]);
config.ShareMemoryKey = dic["share-key"];
config.ShareMemoryLength = int.Parse(dic["share-len"]);
Logger.Instance.Debug($"config:{config.ToJson()}");
Logger.Instance.Debug($"args:{string.Join(" ", args)}");
InitConfig(config, dic);
config.IsCLient = dic.ContainsKey("mode") && dic["mode"].Contains("client");
config.IsServer = dic.ContainsKey("mode") && dic["mode"].Contains("server");
//注入对象
ServiceProvider serviceProvider = null;
ServiceCollection serviceCollection = new ServiceCollection();
//注入 依赖注入服务供应 使得可以在别的地方通过注入的方式获得 ServiceProvider 以用来获取其它服务
serviceCollection.AddSingleton((e) => serviceProvider);
//注入
serviceCollection.AddSingleton<Config>((a) => config);
AddSingleton(serviceCollection);
serviceProvider = serviceCollection.BuildServiceProvider();
//运行服务
RunService(serviceProvider,config);
GCHelper.FlushMemory();
await Helper.Await();
}
private static void RunService(ServiceProvider serviceProvider,Config config)
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
MessengerResolver messengerResolver = serviceProvider.GetService<MessengerResolver>();
messengerResolver.LoadMessenger(assemblies);
if (config.IsServer)
{
Logger.Instance.Info($"start server");
//api
IClientServer clientServer = serviceProvider.GetService<IClientServer>();
clientServer.LoadPlugins(assemblies);
clientServer.Websocket();
Logger.Instance.Info($"api listen:{config.ApiPort}");
//web
IWebServer webServer = serviceProvider.GetService<IWebServer>();
webServer.Start();
Logger.Instance.Info($"web listen:{config.WebPort}");
//服务
TcpServer tcpServer = serviceProvider.GetService<TcpServer>();
tcpServer.Start();
Logger.Instance.Info($"service listen:{config.ServicePort}");
}
if (config.IsCLient)
{
Logger.Instance.Info($"start client");
Logger.Instance.Info($"server ip {config.Server}");
ReportTransfer report = serviceProvider.GetService<ReportTransfer>();
report.LoadPlugins(assemblies);
ClientTransfer clientTransfer = serviceProvider.GetService<ClientTransfer>();
}
}
private static void AddSingleton(ServiceCollection serviceCollection)
{
serviceCollection.AddTransient(typeof(IConfigDataProvider<>), typeof(ConfigDataFileProvider<>));
//劫持
@@ -117,6 +157,7 @@ namespace cmonitor
serviceCollection.AddSingleton<VolumeMessenger>();
serviceCollection.AddSingleton<WallpaperMessenger>();
serviceCollection.AddSingleton<LightMessenger>();
serviceCollection.AddSingleton<ShareMessenger>();
//api
serviceCollection.AddSingleton<RuleConfig>();
@@ -132,54 +173,25 @@ namespace cmonitor
serviceCollection.AddSingleton<VolumeClientService>();
serviceCollection.AddSingleton<WallpaperClientService>();
serviceCollection.AddSingleton<LightClientService>();
serviceCollection.AddSingleton<ShareClientService>();
//web
serviceCollection.AddSingleton<IWebServer, WebServer>();
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
serviceProvider = serviceCollection.BuildServiceProvider();
if (config.IsCLient || config.IsServer)
{
MessengerResolver messengerResolver = serviceProvider.GetService<MessengerResolver>();
messengerResolver.LoadMessenger(assemblies);
}
if (config.IsServer)
private static void InitConfig(Config config, Dictionary<string, string> dic)
{
Logger.Instance.Info($"start server");
//api
IClientServer clientServer = serviceProvider.GetService<IClientServer>();
clientServer.LoadPlugins(assemblies);
clientServer.Websocket();
Logger.Instance.Info($"api listen:{config.ApiPort}");
config.Server = IPAddress.Parse(dic["server"]);
config.Name = dic["name"];
config.WebPort = int.Parse(dic["web"]);
config.ApiPort = int.Parse(dic["api"]);
config.ServicePort = int.Parse(dic["service"]);
config.ShareMemoryKey = dic["share-key"];
config.ShareMemoryLength = int.Parse(dic["share-len"]);
Logger.Instance.Debug($"config:{config.ToJson()}");
//Logger.Instance.Debug($"args:{string.Join(" ", args)}");
//web
IWebServer webServer = serviceProvider.GetService<IWebServer>();
webServer.Start();
Logger.Instance.Info($"web listen:{config.WebPort}");
//服务
TcpServer tcpServer = serviceProvider.GetService<TcpServer>();
tcpServer.Start();
Logger.Instance.Info($"service listen:{config.ServicePort}");
}
if (config.IsCLient)
{
Logger.Instance.Info($"start client");
Logger.Instance.Info($"server ip {config.BroadcastIP}");
ReportTransfer report = serviceProvider.GetService<ReportTransfer>();
report.LoadPlugins(assemblies);
ClientTransfer clientTransfer = serviceProvider.GetService<ClientTransfer>();
}
GCHelper.FlushMemory();
await Helper.Await();
config.IsCLient = dic.ContainsKey("mode") && dic["mode"].Contains("client");
config.IsServer = dic.ContainsKey("mode") && dic["mode"].Contains("server");
}
private static void LoggerConsole()
@@ -232,33 +244,26 @@ namespace cmonitor
public int WebPort { get; set; } = 1800;
public int ApiPort { get; set; } = 1801;
public int ServicePort { get; set; } = 1802;
public IPAddress BroadcastIP { get; set; } = IPAddress.Parse("192.168.1.35");
public bool IsCLient { get; set; }
public bool IsServer { get; set; }
public IPAddress Server { get; set; } = IPAddress.Parse("192.168.1.18");
public string WebRoot { get; set; } = "./web/";
public string Name { get; set; } = Dns.GetHostName();
public string Version { get; set; } = "1.0.0.1";
public bool IsCLient { get; set; }
public bool IsServer { get; set; }
public string ShareMemoryKey { get; set; } = "cmonitor/share";
public int ShareMemoryLength { get; set; } = ShareMemoryItemLength * 10;
public string UserNameMemoryKey { get; set; } = "cmonitor/username";
public string KeyboardMemoryKey { get; set; } = "cmonitor/keyboard";
public int UserNameMemoryLength { get; set; } = 255;
public int KeyboardMemoryLength { get; set; } = 255;
public string ShareMemoryKey { get; set; } = "cmonitor/sharememory";
public int ShareMemoryLength { get; set; } = 1024;
public const int ShareMemoryItemLength = 255;
public const int ShareMemoryKeyBoardIndex = 0;
public const int ShareMemoryUserNameIndex = 1;
public const int ShareMemoryLockIndex = 2;
public const int ShareMemoryWallpaperIndex = 3;
public const int ShareMemoryLLockIndex = 4;
public const int ReportTime = 30;
public const int ScreenTime = 200;
}
public class ArgumentParser
@@ -351,32 +356,13 @@ namespace cmonitor
static bool ValidateMemoryKey(Dictionary<string, string> dic, out string error)
{
error = string.Empty;
if (dic.ContainsKey("username-key") == false || string.IsNullOrWhiteSpace(dic["username-key"]))
{
dic["username-key"] = "cmonitor/username";
}
if (dic.ContainsKey("username-len") == false || string.IsNullOrWhiteSpace(dic["username-len"]))
{
dic["username-len"] = "255";
}
if (dic.ContainsKey("keyboard-key") == false || string.IsNullOrWhiteSpace(dic["keyboard-key"]))
{
dic["keyboard-key"] = "cmonitor/keyboard";
}
if (dic.ContainsKey("keyboard-len") == false || string.IsNullOrWhiteSpace(dic["keyboard-len"]))
{
dic["keyboard-len"] = "255";
}
if (dic.ContainsKey("share-key") == false || string.IsNullOrWhiteSpace(dic["share-key"]))
{
dic["share-key"] = "cmonitor/share";
}
if (dic.ContainsKey("share-len") == false || string.IsNullOrWhiteSpace(dic["share-len"]))
{
dic["share-len"] = "1024";
dic["share-len"] = "2550";
}
return true;
}

View File

@@ -37,6 +37,9 @@
</ItemGroup>
<ItemGroup>
<None Update="cmonitor.volume.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="nfapi.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
@@ -60,8 +63,7 @@
<ItemGroup>
<PackageReference Include="MemoryPack" Version="1.9.16" />
<PackageReference Include="NAudio" Version="2.2.0" />
<PackageReference Include="NAudio.Wasapi" Version="2.2.1" />
<PackageReference Include="System.Management" Version="7.0.2" />
</ItemGroup>

Binary file not shown.

View File

@@ -40,6 +40,8 @@ namespace cmonitor.server.api.services
{
if (signCaching.Get(param.Content, out SignCacheInfo cache) && cache.Connected)
{
cache.CLearDisallowIds();
signCaching.Update();
MessageResponeInfo resp = await messengerSender.SendReply(new MessageRequestWrap
{
Connection = cache.Connection,
@@ -57,6 +59,14 @@ namespace cmonitor.server.api.services
{
if (signCaching.Get(name, out SignCacheInfo cache) && cache.Connected)
{
if (disallowInfo.Ids != null)
{
cache.DisallowRunIds = disallowInfo.Ids;
}
else
{
cache.CLearDisallowIds();
}
await messengerSender.SendOnly(new MessageRequestWrap
{
Connection = cache.Connection,
@@ -65,6 +75,7 @@ namespace cmonitor.server.api.services
});
}
}
signCaching.Update();
return false;
}
@@ -83,5 +94,6 @@ namespace cmonitor.server.api.services
{
public string[] Names { get; set; }
public string[] FileNames { get; set; }
public uint[] Ids { get; set; }
}
}

View File

@@ -69,6 +69,15 @@ namespace cmonitor.server.api.services
{
if (signCaching.Get(setRuleParamInfo.Devices[i], out SignCacheInfo cache))
{
if (setRuleParamInfo.Ids != null)
{
cache.RuleIds = setRuleParamInfo.Ids;
}
else
{
cache.CLearRuleIds();
}
bool res = await messengerSender.SendOnly(new MessageRequestWrap
{
Connection = cache.Connection,
@@ -80,8 +89,8 @@ namespace cmonitor.server.api.services
errorDevices.Add(setRuleParamInfo.Devices[i]);
}
}
}
signCaching.Update();
}
return errorDevices;
}
@@ -90,6 +99,7 @@ namespace cmonitor.server.api.services
{
public string[] Devices { get; set; }
public SetRuleInfo Rules { get; set; }
public uint[] Ids { get; set; }
}
}
}

View File

@@ -0,0 +1,42 @@
using cmonitor.server.client.reports.share;
using cmonitor.server.service;
using cmonitor.server.service.messengers.share;
using cmonitor.server.service.messengers.sign;
using common.libs.extends;
using MemoryPack;
namespace cmonitor.server.api.services
{
public sealed class ShareClientService : IClientService
{
private readonly MessengerSender messengerSender;
private readonly SignCaching signCaching;
public ShareClientService(MessengerSender messengerSender, SignCaching signCaching)
{
this.messengerSender = messengerSender;
this.signCaching = signCaching;
}
public async Task<bool> Update(ClientServiceParamsInfo param)
{
ShareUpdateInfo info = param.Content.DeJson<ShareUpdateInfo>();
if(signCaching.Get(info.Name,out SignCacheInfo cache))
{
return await messengerSender.SendOnly(new MessageRequestWrap
{
Connection = cache.Connection,
MessengerId = (ushort)ShareMessengerIds.Update,
Payload = MemoryPackSerializer.Serialize(info.Item)
});
}
return false;
}
}
public sealed class ShareUpdateInfo
{
public string Name { get; set; }
public ShareItemInfo Item { get; set; }
}
}

View File

@@ -50,13 +50,13 @@ namespace cmonitor.server.client
Logger.Instance.Error(ex);
}
}
await Task.Delay(1000);
await Task.Delay(10000);
}
}, TaskCreationOptions.LongRunning);
}
private async Task SignIn()
{
IPAddress[] ips = new IPAddress[] { config.BroadcastIP };
IPAddress[] ips = new IPAddress[] { config.Server };
//if (Logger.Instance.LoggerLevel <= LoggerTypes.DEBUG)
Logger.Instance.Info($"get ip:{ips.ToJson()}");

View File

@@ -12,7 +12,7 @@ namespace cmonitor.server.client.reports
{
public string Name { get; }
public Dictionary<string, object> GetReports();
public object GetReports();
}
public sealed class ReportTransfer : IReport
@@ -22,34 +22,31 @@ namespace cmonitor.server.client.reports
private readonly ClientSignInState clientSignInState;
private readonly MessengerSender messengerSender;
private readonly ServiceProvider serviceProvider;
private readonly Config config;
private List<IReport> reports;
private Dictionary<string, Dictionary<string, object>> reportObj;
private Dictionary<string, object> reportObj;
public ReportTransfer(ClientSignInState clientSignInState, MessengerSender messengerSender, ServiceProvider serviceProvider, Config config)
{
this.clientSignInState = clientSignInState;
this.messengerSender = messengerSender;
this.serviceProvider = serviceProvider;
this.config = config;
if (config.IsCLient)
{
ReportTask();
}
}
public Dictionary<string, object> GetReports()
public object GetReports()
{
return new Dictionary<string, object>();
return null;
}
public void LoadPlugins(Assembly[] assembs)
{
IEnumerable<Type> types = ReflectionHelper.GetInterfaceSchieves(assembs, typeof(IReport));
reports = types.Select(c => (IReport)serviceProvider.GetService(c)).Where(c => string.IsNullOrWhiteSpace(c.Name) == false).ToList();
reportObj = new Dictionary<string, Dictionary<string, object>>(reports.Count);
reportObj = new Dictionary<string, object>(reports.Count);
}
private uint reportFlag = 0;
public void Update()
@@ -80,12 +77,15 @@ namespace cmonitor.server.client.reports
}
private async Task SendReport()
{
reportObj.Clear();
foreach (IReport item in reports)
{
if (string.IsNullOrWhiteSpace(item.Name) == false)
{
reportObj.Add(item.Name, item.GetReports());
object val = item.GetReports();
if(val != null)
{
reportObj[item.Name] = item.GetReports();
}
}
}
byte[] res = MemoryPackSerializer.Serialize(reportObj.ToJson());

View File

@@ -15,36 +15,20 @@ namespace cmonitor.server.client.reports.active
public string Name => "ActiveWindow";
private readonly ActiveWindowTimeManager activeWindowTimeManager = new ActiveWindowTimeManager();
private ActiveWindow active = new ActiveWindow();
private Dictionary<string, object> report = new Dictionary<string, object> {
{ "Title", string.Empty }, { "FileName", string.Empty }, { "Desc", string.Empty }, { "Pid", 0 }, { "Disallow", Array.Empty<string>() }
};
private string[] disallowList = Array.Empty<string>();
private ActiveReportInfo report = new ActiveReportInfo();
private List<string> disallowTitles = new List<string>();
private ActiveWindow[] backgroundWindow = Array.Empty<ActiveWindow>();
private readonly Config config;
public ActiveWindowReport(Config config)
{
this.config = config;
if (config.IsCLient)
{
Timers();
}
DisallowInit();
}
}
public Dictionary<string, object> GetReports()
public object GetReports()
{
//GetActiveWindow();
report["Title"] = active.Title;
report["FileName"] = active.FileName;
report["Desc"] = active.Desc;
report["Pid"] = active.Pid;
report["Count"] = disallowList.Length;
report["Backs"] = backgroundWindow;
return report;
}
public ActiveWindowTimeReportInfo GetActiveWindowTimes()
@@ -60,13 +44,12 @@ namespace cmonitor.server.client.reports.active
{
DisallowRun(false);
DisallowRunClear();
disallowList = names;
report.Count = names.Length;
disallowTitles = names.Where(c => c.EndsWith(".exe") == false).ToList();
if (names.Length > 0)
{
DisallowRun(true);
DisallowRunFileNames(names);
disallowTitles = names.Where(c => c.EndsWith(".exe") == false).ToList();
}
Task.Run(() =>
{
@@ -83,9 +66,9 @@ namespace cmonitor.server.client.reports.active
try
{
GetActiveWindow();
if (disallowTitles.Count > 0 && disallowTitles.Contains(active.Title))
if (disallowTitles.Count > 0 && disallowTitles.Contains(report.Title))
{
uint pid = active.Pid;
uint pid = report.Pid;
_ = Task.Run(() =>
{
CommandHelper.Windows(string.Empty, new string[] { $"taskkill /f /pid {pid}" });
@@ -93,13 +76,8 @@ namespace cmonitor.server.client.reports.active
}
else
{
activeWindowTimeManager.Update(active);
activeWindowTimeManager.Update(report);
}
WindowHelper.UpdateCurrentProcesses();
if (WindowHelper.processes != null)
{
}
}
catch (Exception ex)
{
@@ -147,16 +125,16 @@ namespace cmonitor.server.client.reports.active
{
}
active.Title = buff.ToString();
active.FileName = filename;
active.Desc = desc;
active.Pid = id;
report.Title = buff.ToString();
report.FileName = filename;
report.Desc = desc;
report.Pid = id;
return;
}
active.Title = string.Empty;
active.FileName = string.Empty;
active.Desc = string.Empty;
active.Pid = 0;
report.Title = string.Empty;
report.FileName = string.Empty;
report.Desc = string.Empty;
report.Pid = 0;
}
private void DisallowInit()
@@ -264,6 +242,15 @@ namespace cmonitor.server.client.reports.active
}
public sealed class ActiveReportInfo
{
public string Title { get; set; } = string.Empty;
public string FileName { get; set; } = string.Empty;
public string Desc { get; set; } = string.Empty;
public uint Pid { get; set; }
public int Count { get; set; }
}
public sealed class ActiveWindow
{
public string Title { get; set; } = string.Empty;
@@ -272,7 +259,6 @@ namespace cmonitor.server.client.reports.active
public uint Pid = 0;
}
public sealed class ActiveWindowTimeManager
{
private ConcurrentDictionary<string, ActiveWindowTimeInfo> dic = new ConcurrentDictionary<string, ActiveWindowTimeInfo>();
@@ -293,7 +279,7 @@ namespace cmonitor.server.client.reports.active
List = dic.Values.ToList()
};
}
public void Update(ActiveWindow active)
public void Update(ActiveReportInfo active)
{
if (string.IsNullOrWhiteSpace(active.FileName)) return;

View File

@@ -9,6 +9,7 @@ namespace cmonitor.server.client.reports.hijack
private readonly HijackEventHandler hijackEventHandler;
private readonly HijackConfig hijackConfig;
HijackReportInfo report = new HijackReportInfo();
public HijackReport(HijackEventHandler hijackEventHandler, HijackController hijackController, HijackConfig hijackConfig)
{
this.hijackEventHandler = hijackEventHandler;
@@ -26,15 +27,19 @@ namespace cmonitor.server.client.reports.hijack
}
}
public Dictionary<string, object> GetReports()
public object GetReports()
{
ulong upload = hijackEventHandler.UdpSend + hijackEventHandler.TcpSend;
ulong download = hijackEventHandler.TcpReceive + hijackEventHandler.UdpReceive;
return new Dictionary<string, object> {
{ "Upload",upload},
{ "Download",download},
{ "Count",hijackConfig.AllowIPs.Length + hijackConfig.DeniedIPs.Length + hijackConfig.AllowDomains.Length+hijackConfig.DeniedDomains.Length + hijackConfig.AllowProcesss.Length+hijackConfig.DeniedProcesss.Length }
};
report.Upload = hijackEventHandler.UdpSend + hijackEventHandler.TcpSend;
report.Download = hijackEventHandler.TcpReceive + hijackEventHandler.UdpReceive;
report.Count = hijackConfig.AllowIPs.Length + hijackConfig.DeniedIPs.Length + hijackConfig.AllowDomains.Length + hijackConfig.DeniedDomains.Length + hijackConfig.AllowProcesss.Length + hijackConfig.DeniedProcesss.Length;
return report;
}
}
public sealed class HijackReportInfo
{
public ulong Upload { get; set; }
public ulong Download { get; set; }
public int Count { get; set; }
}
}

View File

@@ -3,6 +3,7 @@
public sealed class LightReport : IReport
{
public string Name => "Light";
LightReportInfo report = new LightReportInfo();
private readonly LightWatcher lightWatcher;
public LightReport()
@@ -13,16 +14,15 @@
lightWatcher = new LightWatcher();
lightWatcher.BrightnessChanged += (e, value) =>
{
dic["Value"] = value.newBrightness;
report.Value = (int)value.newBrightness;
};
dic["Value"] = LightWmiHelper.GetBrightnessLevel();
report.Value = LightWmiHelper.GetBrightnessLevel();
}
}
Dictionary<string, object> dic = new Dictionary<string, object> { { "Value", 0 } };
public Dictionary<string, object> GetReports()
public object GetReports()
{
return dic;
return report;
}
public void SetLight(int value)
@@ -30,4 +30,9 @@
LightWmiHelper.SetBrightnessLevel(value);
}
}
public sealed class LightReportInfo
{
public int Value { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using common.libs;
using cmonitor.server.client.reports.share;
using common.libs;
namespace cmonitor.server.client.reports.llock
{
@@ -6,30 +7,43 @@ namespace cmonitor.server.client.reports.llock
{
public string Name => "LLock";
private Dictionary<string, object> report = new Dictionary<string, object>() { { "Value", false } };
public Dictionary<string, object> GetReports()
private LLockReportInfo report = new LLockReportInfo();
private readonly Config config;
private readonly ShareReport shareReport;
public LLockReport(Config config, ShareReport shareReport)
{
report["Value"] = WindowHelper.GetHasWindowByName("llock.win");
this.config = config;
this.shareReport = shareReport;
}
DateTime startTime = new DateTime(1970, 1, 1);
public object GetReports()
{
if (shareReport.GetShare(Name, out ShareItemInfo share) && string.IsNullOrWhiteSpace(share.Value) == false && long.TryParse(share.Value, out long time))
{
report.Value = (long)(DateTime.UtcNow.Subtract(startTime)).TotalMilliseconds - time < 1000;
}
return report;
}
public void Update(bool open)
{
CommandHelper.Windows(string.Empty, new string[] { "taskkill /f /t /im \"llock.win.exe\"" });
if (open)
{
Task.Run(() =>
{
CommandHelper.Windows(string.Empty, new string[] {
$"start llock.win.exe"
$"start llock.win.exe {config.ShareMemoryKey} {config.ShareMemoryLength} {Config.ShareMemoryLLockIndex}"
});
});
}
else
}
}
public sealed class LLockReportInfo
{
CommandHelper.Windows(string.Empty, new string[] {
"taskkill /f /t /im \"llock.win.exe\""
});
}
}
public bool Value { get; set; }
}
}

View File

@@ -7,9 +7,7 @@ using System.Buffers;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing;
using System.IO.MemoryMappedFiles;
#endif
using System.Text;
namespace cmonitor.server.client.reports.screen
{
@@ -18,30 +16,24 @@ namespace cmonitor.server.client.reports.screen
public string Name => "Screen";
private readonly ClientSignInState clientSignInState;
private readonly MessengerSender messengerSender;
private readonly Config config;
Dictionary<string, object> dic = new Dictionary<string, object> { { "LastInput", 0 }, { "UserName", string.Empty }, { "KeyBoard", string.Empty } };
private ScreenReportInfo report = new ScreenReportInfo();
public ScreenReport(ClientSignInState clientSignInState, MessengerSender messengerSender, Config config)
{
this.clientSignInState = clientSignInState;
this.messengerSender = messengerSender;
this.config = config;
if (config.IsCLient)
{
ScreenCaptureTask();
InitUserNameMemory();
InitLastInputInfo();
InitKeyBoard();
}
}
public Dictionary<string, object> GetReports()
public object GetReports()
{
dic["LastInput"] = GetLastInputInfo();
dic["UserName"] = GetUserNameMemory();
dic["KeyBoard"] = GetKeyBoard();
return dic;
report.LastInput = GetLastInputInfo();
return report;
}
@@ -78,8 +70,6 @@ namespace cmonitor.server.client.reports.screen
byte[] bytes = ScreenCapture();
if (bytes.Length > 0)
{
// byte[] bytes = MemoryPackSerializer.Serialize(img);
await messengerSender.SendOnly(new MessageRequestWrap
{
Connection = clientSignInState.Connection,
@@ -95,6 +85,8 @@ namespace cmonitor.server.client.reports.screen
if (OperatingSystem.IsWindows())
{
IntPtr hdc = GetDC(IntPtr.Zero);
if(hdc != IntPtr.Zero)
{
using Bitmap source = new Bitmap(GetDeviceCaps(hdc, DESKTOPHORZRES), GetDeviceCaps(hdc, DESKTOPVERTRES));
using (Graphics g = Graphics.FromImage(source))
{
@@ -135,10 +127,7 @@ namespace cmonitor.server.client.reports.screen
byte[] bytes = ArrayPool<byte>.Shared.Rent((int)ms.Length);
ms.Read(bytes);
return bytes;
//string base64 = Convert.ToBase64String(bytes, 0, (int)ms.Length);
//ArrayPool<byte>.Shared.Return(bytes);
//return base64;
}
}
#endif
return Array.Empty<byte>();
@@ -217,95 +206,11 @@ namespace cmonitor.server.client.reports.screen
public uint dwTime;
}
#endregion
#region
#if DEBUG || RELEASE
MemoryMappedFile mmf2;
MemoryMappedViewAccessor accessor2;
byte[] userNameBytes;
#endif
private void InitUserNameMemory()
{
#if DEBUG || RELEASE
userNameBytes = new byte[config.UserNameMemoryLength];
if (OperatingSystem.IsWindows())
{
mmf2 = MemoryMappedFile.CreateOrOpen(config.UserNameMemoryKey, userNameBytes.Length);
accessor2 = mmf2.CreateViewAccessor();
}
#endif
}
private string GetUserNameMemory()
public sealed class ScreenReportInfo
{
#if DEBUG || RELEASE
try
{
if (OperatingSystem.IsWindows())
{
if (accessor2 != null)
{
accessor2.Read(0, out byte length);
if (length > 0)
{
accessor2.ReadArray(1, userNameBytes, 0, length);
return Encoding.UTF8.GetString(userNameBytes.AsSpan(0, length));
}
}
}
}
catch (Exception)
{
}
#endif
return string.Empty;
}
#endregion
#region
#if DEBUG || RELEASE
MemoryMappedFile mmf3;
MemoryMappedViewAccessor accessor3;
byte[] keyBoardBytes;
#endif
private void InitKeyBoard()
{
#if DEBUG || RELEASE
keyBoardBytes = new byte[config.KeyboardMemoryLength];
if (OperatingSystem.IsWindows())
{
mmf3 = MemoryMappedFile.CreateOrOpen(config.KeyboardMemoryKey, keyBoardBytes.Length);
accessor3 = mmf3.CreateViewAccessor();
}
#endif
}
private string GetKeyBoard()
{
#if DEBUG || RELEASE
try
{
if (OperatingSystem.IsWindows())
{
if (accessor3 != null)
{
accessor3.Read(0, out byte length);
if (length > 0)
{
accessor3.ReadArray(1, keyBoardBytes, 0, length);
return Encoding.UTF8.GetString(keyBoardBytes.AsSpan(0, length));
}
}
}
}
catch (Exception)
{
}
#endif
return string.Empty;
}
#endregion
public uint LastInput { get; set; }
}
}

View File

@@ -1,27 +1,32 @@
using System.IO.MemoryMappedFiles;
using MemoryPack;
using System.IO.MemoryMappedFiles;
using System.Text;
namespace cmonitor.server.client.reports.screen
namespace cmonitor.server.client.reports.share
{
public sealed class ShareReport : IReport
{
public string Name => "Share";
private readonly Config config;
Dictionary<string, object> dic = new Dictionary<string, object> { { "Value", string.Empty}};
Dictionary<string, ShareItemInfo> dic = new Dictionary<string, ShareItemInfo>();
public ShareReport(Config config)
{
this.config = config;
InitShare();
}
public Dictionary<string, object> GetReports()
if (config.IsCLient)
{
dic["Value"] = GetShare();
InitShare();
}
}
public object GetReports()
{
GetShare();
return dic;
}
public bool GetShare(string key,out ShareItemInfo item)
{
return dic.TryGetValue(key, out item);
}
MemoryMappedFile mmf3;
@@ -29,35 +34,89 @@ namespace cmonitor.server.client.reports.screen
byte[] bytes;
private void InitShare()
{
bytes = new byte[config.ShareMemoryLength];
if (OperatingSystem.IsWindows())
{
bytes = new byte[config.ShareMemoryLength];
mmf3 = MemoryMappedFile.CreateOrOpen(config.ShareMemoryKey, bytes.Length);
accessor3 = mmf3.CreateViewAccessor();
}
}
private string GetShare()
private void GetShare()
{
try
{
if (OperatingSystem.IsWindows())
{
if (accessor3 != null)
accessor3.ReadArray(0, bytes, 0, bytes.Length);
Span<byte> span = bytes.AsSpan();
int index = 0;
/*
* 格式 5 00000 2 00 key长度+key+val长度+val
*/
while (span.Length > 0)
{
int length = accessor3.ReadInt32(0);
if (length > 0)
byte keyLen = span[0];
if (keyLen > 0)
{
accessor3.ReadArray(4, bytes, 0, length);
return Encoding.UTF8.GetString(bytes.AsSpan(0, length));
string key = Encoding.UTF8.GetString(span.Slice(1, keyLen));
string val = string.Empty;
byte valLen = span[1 + keyLen];
if (valLen > 0)
{
val = Encoding.UTF8.GetString(span.Slice(2 + keyLen, valLen));
}
dic[key] = new ShareItemInfo
{
Index = index,
Value = val
};
}
span = span.Slice(Config.ShareMemoryItemLength);
index++;
}
}
}
catch (Exception)
{
}
}
public void Update(ShareItemInfo item)
{
try
{
if (OperatingSystem.IsWindows())
{
int valIndex = item.Index * Config.ShareMemoryItemLength;
accessor3.Read(valIndex, out byte keyLen);
valIndex += 1 + keyLen;
byte[] bytes = Encoding.UTF8.GetBytes(item.Value);
if (bytes.Length < Config.ShareMemoryItemLength - 2 - keyLen)
{
accessor3.Write(valIndex, (byte)bytes.Length);
accessor3.WriteArray(valIndex + 1, bytes, 0, bytes.Length);
}
}
}
catch (Exception)
{
}
return string.Empty;
}
}
[MemoryPackable]
public sealed partial class ShareItemInfo
{
/// <summary>
/// 内存下标
/// </summary>
public int Index { get; set; }
/// <summary>
/// 内存值
/// </summary>
public string Value { get; set; }
}
}

View File

@@ -8,14 +8,15 @@ namespace cmonitor.server.client.reports.llock
public sealed class UsbReport : IReport
{
public string Name => "Usb";
private UsbReportInfo report = new UsbReportInfo();
public UsbReport()
{
UnLockUsb();
report.Value = GetHasUSBDisabled();
}
private Dictionary<string, object> report = new Dictionary<string, object>() { { "Value", false } };
public Dictionary<string, object> GetReports()
public object GetReports()
{
return report;
}
@@ -31,7 +32,7 @@ namespace cmonitor.server.client.reports.llock
UnLockUsb();
}
report["Value"] = GetHasUSBDisabled();
report.Value = GetHasUSBDisabled();
}
private bool GetHasUSBDisabled()
@@ -95,4 +96,9 @@ namespace cmonitor.server.client.reports.llock
#endif
}
}
public sealed class UsbReportInfo
{
public bool Value { get; set; }
}
}

View File

@@ -8,19 +8,18 @@ namespace cmonitor.server.client.reports.volume
public sealed class VolumeReport : IReport
{
public string Name => "Volume";
private VolumeReportInfo report = new VolumeReportInfo();
public VolumeReport()
{
Volume();
}
public Dictionary<string, object> GetReports()
public object GetReports()
{
return new Dictionary<string, object>()
{
{ "Value",GetVolume()},
{ "Mute",GetVolumeMute()},
{ "MasterPeak",GetMasterPeakValue()},
};
report.Value = GetVolume();
report.Mute = GetVolumeMute();
report.MasterPeak = GetMasterPeakValue();
return report;
}
#if DEBUG || RELEASE
@@ -128,4 +127,11 @@ namespace cmonitor.server.client.reports.volume
}
}
}
public sealed class VolumeReportInfo
{
public float Value { get; set; }
public bool Mute { get; set; }
public float MasterPeak { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using common.libs;
using cmonitor.server.client.reports.share;
using common.libs;
namespace cmonitor.server.client.reports.llock
{
@@ -6,36 +7,42 @@ namespace cmonitor.server.client.reports.llock
{
public string Name => "Wallpaper";
private Dictionary<string, object> report = new Dictionary<string, object>() { { "Value", false } };
private WallpaperReportInfo report = new WallpaperReportInfo();
private readonly Config config;
public WallpaperReport(Config config)
private readonly ShareReport shareReport;
public WallpaperReport(Config config, ShareReport shareReport)
{
this.config = config;
this.shareReport = shareReport;
}
public Dictionary<string, object> GetReports()
DateTime startTime = new DateTime(1970, 1, 1);
public object GetReports()
{
report["Value"] = WindowHelper.GetHasWindowByName("wallpaper.win");
if (shareReport.GetShare(Name, out ShareItemInfo share) && string.IsNullOrWhiteSpace(share.Value) == false && long.TryParse(share.Value, out long time))
{
report.Value = (long)(DateTime.UtcNow.Subtract(startTime)).TotalMilliseconds - time < 1000;
}
return report;
}
public void Update(bool open, string url)
{
CommandHelper.Windows(string.Empty, new string[] { "taskkill /f /t /im \"wallpaper.win.exe\"" });
if (open)
{
Task.Run(() =>
{
CommandHelper.Windows(string.Empty, new string[] {
$"start wallpaper.win.exe \"{url}\" {config.KeyboardMemoryKey} {config.KeyboardMemoryLength}"
$"start wallpaper.win.exe \"{url}\" {config.ShareMemoryKey} {config.ShareMemoryLength} {Config.ShareMemoryKeyBoardIndex} {Config.ShareMemoryWallpaperIndex}"
});
});
}
else
}
}
public sealed class WallpaperReportInfo
{
CommandHelper.Windows(string.Empty, new string[] {
"taskkill /f /t /im \"wallpaper.win.exe\""
});
}
}
public bool Value { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
using cmonitor.server.client.reports.share;
using MemoryPack;
namespace cmonitor.server.service.messengers.share
{
public sealed class ShareMessenger : IMessenger
{
private readonly ShareReport shareReport;
public ShareMessenger(ShareReport shareReport)
{
this.shareReport = shareReport;
}
[MessengerId((ushort)ShareMessengerIds.Update)]
public void Update(IConnection connection)
{
ShareItemInfo shareItemInfo = MemoryPackSerializer.Deserialize<ShareItemInfo>(connection.ReceiveRequestWrap.Payload.Span);
shareReport.Update(shareItemInfo);
}
}
}

View File

@@ -0,0 +1,9 @@
namespace cmonitor.server.service.messengers.share
{
public enum ShareMessengerIds : ushort
{
Update = 1100,
None = 1199
}
}

View File

@@ -51,6 +51,11 @@ namespace cmonitor.server.service.messengers.sign
return true;
}
public void Update()
{
changed = true;
}
private void SaveConfig()
{
Task.Factory.StartNew(() =>
@@ -79,6 +84,16 @@ namespace cmonitor.server.service.messengers.sign
{
public string MachineName { get; set; }
public string Version { get; set; } = "1.0.0.0";
public uint[] DisallowRunIds { get; set; } = Array.Empty<uint>();
public uint[] RuleIds { get; set; } = Array.Empty<uint>();
public void CLearDisallowIds()
{
DisallowRunIds = Array.Empty<uint>();
}
public void CLearRuleIds()
{
RuleIds = Array.Empty<uint>();
}
[JsonIgnore]
public int ReportFlag = 1;
@@ -117,7 +132,6 @@ namespace cmonitor.server.service.messengers.sign
return Connection != null && Connection.Connected == true;
}
}
[JsonIgnore]
public IConnection Connection { get; set; }
}

View File

@@ -6,17 +6,27 @@ namespace cmonitor.server.service.messengers.sign
public sealed class SignInMessenger : IMessenger
{
private readonly SignCaching signCaching;
public SignInMessenger(SignCaching signCaching)
private readonly Config config;
public SignInMessenger(SignCaching signCaching, Config config)
{
this.signCaching = signCaching;
this.config = config;
}
[MessengerId((ushort)SignInMessengerIds.SignIn)]
public void SignIn(IConnection connection)
{
signCaching.Sign(connection, MemoryPackSerializer.Deserialize<SignInfo>(connection.ReceiveRequestWrap.Payload.Span));
SignInfo info = MemoryPackSerializer.Deserialize<SignInfo>(connection.ReceiveRequestWrap.Payload.Span);
if (info.Version == config.Version)
{
signCaching.Sign(connection, info);
connection.Write(Helper.TrueArray);
}
else
{
connection.Write(Helper.FalseArray);
}
}
}

View File

@@ -24,15 +24,24 @@ namespace cmonitor.server.web
try
{
HttpListener http = new HttpListener();
http.IgnoreWriteExceptions = true;
http.Prefixes.Add($"http://+:{config.WebPort}/");
http.Start();
while (true)
http.BeginGetContext(Callback, http);
}
catch (Exception ex)
{
HttpListenerContext context = http.GetContext();
Logger.Instance.Error(ex);
}
}, TaskCreationOptions.LongRunning);
}
private void Callback(IAsyncResult result)
{
HttpListener http = result.AsyncState as HttpListener;
HttpListenerContext context = http.EndGetContext(result);
HttpListenerRequest request = context.Request;
using HttpListenerResponse response = context.Response;
using Stream stream = response.OutputStream;
HttpListenerResponse response = context.Response;
try
{
@@ -50,7 +59,10 @@ namespace cmonitor.server.web
response.ContentLength64 = bytes.Length;
response.ContentType = GetContentType(path);
response.Headers.Set("Last-Modified", File.GetLastWriteTimeUtc(path).ToString());
stream.Write(bytes, 0, bytes.Length);
response.OutputStream.Write(bytes, 0, bytes.Length);
response.OutputStream.Flush();
response.OutputStream.Close();
}
else
{
@@ -61,15 +73,10 @@ namespace cmonitor.server.web
{
response.StatusCode = (int)HttpStatusCode.BadRequest;
}
stream.Close();
stream.Dispose();
}
}
catch (Exception ex)
{
Logger.Instance.Error(ex);
}
}, TaskCreationOptions.LongRunning);
response.Close();
http.BeginGetContext(Callback, http);
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>cmonitor.web</title><script defer="defer" src="/js/chunk-vendors.d3224db2.js"></script><script defer="defer" src="/js/app.3d96c181.js"></script><link href="/css/chunk-vendors.faad7142.css" rel="stylesheet"><link href="/css/app.97eae421.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but cmonitor.web doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>cmonitor.web</title><script defer="defer" src="/js/chunk-vendors.d3224db2.js"></script><script defer="defer" src="/js/app.2edd5583.js"></script><link href="/css/chunk-vendors.faad7142.css" rel="stylesheet"><link href="/css/app.97eae421.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but cmonitor.web doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

View File

@@ -1,23 +1,6 @@
using System;
using System.Diagnostics;
using System.Linq;
namespace common.libs
namespace common.libs
{
public class WindowHelper
{
#region
public static Process[] processes;
public static void UpdateCurrentProcesses()
{
processes = Process.GetProcesses();
}
public static bool GetHasWindowByName(string name)
{
return processes != null && processes.Any(c => c.ProcessName.Equals(name, StringComparison.OrdinalIgnoreCase));
}
#endregion
}
}

View File

@@ -1,8 +1,9 @@
using Microsoft.Win32;
using System;
using System.Net;
using System.IO.MemoryMappedFiles;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace llock.win
@@ -10,8 +11,17 @@ namespace llock.win
public partial class Form1 : Form
{
Hook hook = new Hook();
public Form1()
private string shareMkey;
private int shareMLength;
private int shareIndex;
public Form1(string shareMkey, int shareMLength, int shareIndex)
{
this.shareMkey = shareMkey;
this.shareMLength = shareMLength;
this.shareIndex = shareIndex;
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;
this.StartPosition = FormStartPosition.CenterScreen;
@@ -51,6 +61,39 @@ namespace llock.win
groupBox1.Location = new System.Drawing.Point((this.Width - groupBox1.Width) / 2, (this.Height - groupBox1.Height) / 2);
mmf2 = MemoryMappedFile.CreateOrOpen(this.shareMkey, this.shareMLength);
accessor2 = mmf2.CreateViewAccessor();
new Thread(() =>
{
while (true)
{
WriteLLock();
Thread.Sleep(100);
}
}).Start();
}
MemoryMappedFile mmf2;
MemoryMappedViewAccessor accessor2;
DateTime startTime = new DateTime(1970, 1, 1);
byte[] keyBytes = Encoding.UTF8.GetBytes("LLock");
private void WriteLLock()
{
long time = (long)(DateTime.UtcNow.Subtract(startTime)).TotalMilliseconds;
WriteMemory(this.shareIndex, keyBytes, Encoding.UTF8.GetBytes(time.ToString()));
}
private void WriteMemory(int index, byte[] key, byte[] value)
{
int keyIndex = index * 255;
accessor2.Write(keyIndex, (byte)key.Length);
keyIndex++;
accessor2.WriteArray(keyIndex, key, 0, key.Length);
keyIndex += key.Length;
accessor2.Write(keyIndex, (byte)value.Length);
keyIndex++;
accessor2.WriteArray(keyIndex, value, 0, value.Length);
keyIndex += value.Length;
}
private void OnClose(object sender, FormClosingEventArgs e)
@@ -67,42 +110,24 @@ namespace llock.win
loading = true;
button1.Text = "ing.";
Task.Run(async () =>
{
try
{
WebClient webClient = new WebClient();
Task<string> result = webClient.DownloadStringTaskAsync("https://api.qbcode.cn:8081/api/vclass/lock/password");
await Task.Delay(1000);
loading = false;
button1.Text = "解锁";
if (result.IsCompleted)
DateTime dt = DateTime.Now;
string psd = $"{dt.Hour / 10 % 10}{dt.Minute / 10 % 10}{dt.Hour % 10}&{dt.Minute % 10}{dt.Month}{dt.Date}";
if (psd == textBox1.Text)
{
this.Invoke(new EventHandler(delegate
{
try
{
if (result.Result.Contains("\"Data\":\"" + textBox1.Text))
{
hook.Close();
this.Close();
}
}
catch (Exception)
{
}
}));
}
webClient.Dispose();
}
catch (Exception)
{
loading = false;
button1.Text = "解锁";
}
});
}
}

View File

@@ -10,7 +10,7 @@ namespace llock.win
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
static void Main(string[] arg)
{
Mutex mutex = new Mutex(true, System.Diagnostics.Process.GetCurrentProcess().ProcessName, out bool isAppRunning);
if (isAppRunning == false)
@@ -18,9 +18,13 @@ namespace llock.win
Environment.Exit(1);
}
string shareMkey = arg[0];
int shareMLength = int.Parse(arg[1]);
int shareIndex= int.Parse(arg[2]);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Application.Run(new Form1(shareMkey, shareMLength, shareIndex));
}
}
}

View File

@@ -4,7 +4,7 @@ rd /s /q public\\publish
rd /s /q public\\publish-zip
mkdir public\\publish-zip
dotnet publish ./cmonitor -c release -f net7.0 -o ./public/publish/win-x64 -r win-x64 --self-contained true -p:TieredPGO=true -p:DebugType=none -p:DebugSymbols=false -p:PublishSingleFile=true -p:EnableCompressionInSingleFile=true -p:DebuggerSupport=false -p:EnableUnsafeBinaryFormatterSerialization=false -p:EnableUnsafeUTF7Encoding=false -p:HttpActivityPropagationSupport=false -p:InvariantGlobalization=true -p:MetadataUpdaterSupport=false -p:UseSystemResourceKeys=true -p:TrimMode=partial
dotnet publish ./cmonitor -c release -f net7.0 -o ./public/publish/win-x64 -r win-x64 -p:TrimMode=partial --self-contained true -p:TieredPGO=true -p:DebugType=none -p:DebugSymbols=false -p:PublishSingleFile=true -p:EnableCompressionInSingleFile=true -p:DebuggerSupport=false -p:EnableUnsafeBinaryFormatterSerialization=false -p:EnableUnsafeUTF7Encoding=false -p:HttpActivityPropagationSupport=false -p:InvariantGlobalization=true -p:MetadataUpdaterSupport=false -p:UseSystemResourceKeys=true
dotnet publish ./cmonitor -c releaselinux -f net7.0 -o ./public/publish/linux-x64 -r linux-x64 -p:PublishTrimmed=true --self-contained true -p:TieredPGO=true -p:DebugType=none -p:DebugSymbols=false -p:PublishSingleFile=true -p:EnableCompressionInSingleFile=true -p:DebuggerSupport=false -p:EnableUnsafeBinaryFormatterSerialization=false -p:EnableUnsafeUTF7Encoding=false -p:HttpActivityPropagationSupport=false -p:InvariantGlobalization=true -p:MetadataUpdaterSupport=false -p:UseSystemResourceKeys=true -p:TrimMode=partial
@@ -17,7 +17,7 @@ echo F|xcopy "cmonitor\\web\\wallpaper.win.exe" "public\\publish\\win-x64\\wallp
echo F|xcopy "cmonitor\\web\\cmonitor.win.exe" "public\\publish\\win-x64\\cmonitor.win.exe" /s /f /h /y
for %%r in (linux-x64,linux-x64-any) do (
for %%f in (nfapi.dll,nfdriver.sys) do (
for %%f in (nfapi.dll,nfdriver.sys,cmonitor.volume.dll) do (
del "public\\publish\\%%r\\%%f"
)
)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

After

Width:  |  Height:  |  Size: 366 KiB

View File

@@ -1,12 +1,10 @@
using Microsoft.Win32;
using System;
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace wallpaper.win
@@ -16,9 +14,11 @@ namespace wallpaper.win
private IntPtr programIntPtr = IntPtr.Zero;
private Hook hook;
private string img;
private string key;
private int len;
private string imgUrl;
private string shareMkey;
private int shareMLength;
private int shareKeyBoardIndex;
private int shareWallpaperIndex;
protected override CreateParams CreateParams
{
@@ -32,19 +32,22 @@ namespace wallpaper.win
return cp;
}
}
public Form1(string img, string key,int len)
public Form1(string imgUrl, string shareMkey, int shareMLength, int shareKeyBoardIndex, int shareWallpaperIndex)
{
this.img = img;
this.key = key;
this.len = len;
this.imgUrl = imgUrl;
this.shareMkey = shareMkey;
this.shareMLength = shareMLength;
this.shareKeyBoardIndex = shareKeyBoardIndex;
this.shareWallpaperIndex = shareWallpaperIndex;
this.WindowState = FormWindowState.Maximized;
this.FormBorderStyle = FormBorderStyle.None;
InitializeComponent();
hook = new Hook();
AppDomain.CurrentDomain.ProcessExit += (s, e) => hook.Close();
Application.ApplicationExit += (s, e) => hook.Close();
}
private void Find()
@@ -82,9 +85,16 @@ namespace wallpaper.win
}
}
MemoryMappedFile mmf2;
MemoryMappedViewAccessor accessor2;
byte[] keyBytes = Encoding.UTF8.GetBytes("KeyBoard");
byte[] wallpaperBytes = Encoding.UTF8.GetBytes("Wallpaper");
DateTime startTime = new DateTime(1970, 1, 1);
byte[] emptyArray = new byte[0];
private void OnLoad(object sender, EventArgs e)
{
pictureBox1.ImageLocation = img;
pictureBox1.ImageLocation = imgUrl;
this.Dock = DockStyle.Fill;
ShowInTaskbar = false;
@@ -111,15 +121,21 @@ namespace wallpaper.win
}).Start();
MemoryMappedFile mmf2 = MemoryMappedFile.CreateOrOpen(this.key, this.len);
MemoryMappedViewAccessor accessor2 = mmf2.CreateViewAccessor();
mmf2 = MemoryMappedFile.CreateOrOpen(this.shareMkey, this.shareMLength);
accessor2 = mmf2.CreateViewAccessor();
WriteKeyBoard("init");
new Thread(() =>
{
StringBuilder sb = new StringBuilder();
while (true)
{
if (Hook.CurrentKeys == Keys.None)
{
ClearKeyBoard();
}
else
{
sb.Clear();
if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
{
sb.Append("Ctrl+");
@@ -134,14 +150,46 @@ namespace wallpaper.win
}
sb.Append(Hook.CurrentKeys.ToString());
byte[] bytes = Encoding.UTF8.GetBytes(sb.ToString());
accessor2.Write(0, (byte)bytes.Length);
accessor2.WriteArray(1, bytes, 0, bytes.Length);
WriteKeyBoard(sb.ToString());
}
WriteWallpaper();
Thread.Sleep(30);
}
}).Start();
}
private void WriteKeyBoard(string value)
{
WriteMemory(this.shareKeyBoardIndex, keyBytes, Encoding.UTF8.GetBytes(value));
}
private void ClearKeyBoard()
{
WriteMemory(this.shareKeyBoardIndex, keyBytes, emptyArray);
}
private void WriteWallpaper()
{
long time = (long)(DateTime.UtcNow.Subtract(startTime)).TotalMilliseconds;
WriteMemory(this.shareWallpaperIndex, wallpaperBytes, Encoding.UTF8.GetBytes(time.ToString()));
}
private void WriteMemory(int index, byte[] key, byte[] value)
{
int keyIndex = index * 255;
if (value.Length > 0)
accessor2.Write(keyIndex, (byte)key.Length);
keyIndex++;
if (value.Length > 0)
accessor2.WriteArray(keyIndex, key, 0, key.Length);
keyIndex += key.Length;
accessor2.Write(keyIndex, (byte)value.Length);
if (value.Length > 0)
{
keyIndex++;
accessor2.WriteArray(keyIndex, value, 0, value.Length);
keyIndex += value.Length;
}
}
}
public static class Win32
@@ -201,6 +249,18 @@ namespace wallpaper.win
if (hHook == 0)
Close();
}
new Thread(() =>
{
while (true)
{
if ((DateTime.Now - Hook.DateTime).TotalMilliseconds > 1000)
{
CurrentKeys = Keys.None;
}
Thread.Sleep(1000);
}
}).Start();
}
public void Close()
{
@@ -212,12 +272,14 @@ namespace wallpaper.win
}
public static Keys CurrentKeys = Keys.None;
public static DateTime DateTime = DateTime.Now;
public static int KeyBoardHookProc(int nCode, int wParam, IntPtr lParam)
{
if (nCode >= 0)
{
KeyBoardHookStruct kbh = (KeyBoardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyBoardHookStruct));
CurrentKeys = (Keys)kbh.vkCode;
DateTime = DateTime.Now;
}
return CallNextHookEx(hHook, nCode, wParam, lParam);
}

View File

@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
@@ -20,25 +18,14 @@ namespace wallpaper.win
Environment.Exit(1);
}
string img = "https://www.qbcode.cn/images/carousel-cpp.jpg";
string key = "cmonitor/keyboard";
int len = 1024;
if(arg.Length > 0)
{
img = arg[0];
}
if (arg.Length > 1)
{
key = arg[1];
}
if (arg.Length > 2)
{
len = int.Parse(arg[2]);
}
string imgUrl = arg[0];
string shareMkey = arg[1];
int shareMLength = int.Parse(arg[2]);
int shareKeyBoardIndex = int.Parse(arg[3]);
int shareWallpaperIndex = int.Parse(arg[4]);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1(img, key, len));
Application.Run(new Form1(imgUrl, shareMkey, shareMLength, shareKeyBoardIndex, shareWallpaperIndex));
}
}
}