提交 3ce6ff68 authored 作者: wangqiang's avatar wangqiang

RESET RENOOT

上级 f9e55265
...@@ -68,6 +68,7 @@ public class InstalledProgramCache { ...@@ -68,6 +68,7 @@ public class InstalledProgramCache {
String line; String line;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
line = line.trim(); line = line.trim();
log.info("程序List-Line:{}", line);
if (line.startsWith("DisplayName")) { if (line.startsWith("DisplayName")) {
info.put("name", line.replace("DisplayName", "").replace("REG_SZ", "").trim()); info.put("name", line.replace("DisplayName", "").replace("REG_SZ", "").trim());
} else if (line.startsWith("DisplayVersion")) { } else if (line.startsWith("DisplayVersion")) {
......
...@@ -29,9 +29,9 @@ public class TestDemo { ...@@ -29,9 +29,9 @@ public class TestDemo {
int result31 = IHwPortController.instanceDll.APQ_HWPORT_get_normal_device_permit(4); int result31 = IHwPortController.instanceDll.APQ_HWPORT_get_normal_device_permit(4);
log.info("APQ_HWPORT_get_normal_device_permit ret:{}", result31); log.info("APQ_HWPORT_get_normal_device_permit ret:{}", result31);
// 设置普通设备权限 // 设置普通设备权限
//int result32 = IHwPortController.instanceDll.APQ_HWPORT_set_normal_device_permit(4, 1, null); int result32 = IHwPortController.instanceDll.APQ_HWPORT_set_normal_device_permit(4, 2, null);
//log.info("APQ_HWPORT_set_normal_device_permit ret:{}", result32); log.info("APQ_HWPORT_set_normal_device_permit ret:{}", result32);
// 应用硬件接口管理模块的配置内容 //应用硬件接口管理模块的配置内容
int result5 = IHwPortController.instanceDll.APQ_HWPORT_Apply(); int result5 = IHwPortController.instanceDll.APQ_HWPORT_Apply();
log.info("APQ_HWPORT_Apply ret:{}", result5); log.info("APQ_HWPORT_Apply ret:{}", result5);
// 再次获取普通设备权限,验证 // 再次获取普通设备权限,验证
......
...@@ -54,7 +54,8 @@ import java.io.UnsupportedEncodingException; ...@@ -54,7 +54,8 @@ import java.io.UnsupportedEncodingException;
******************************************************************************************************************************/ ******************************************************************************************************************************/
public interface IHwPortController extends Library { public interface IHwPortController extends Library {
IHwPortController instanceDll = (IHwPortController) Native.loadLibrary(ParseUrlUtil.parseAbsolutePath("/dact/x64/Release/HwPortController.dll", System.getProperty("user.dir") + "\\HwPortController.dll"), IHwPortController.class); //IHwPortController instanceDll = (IHwPortController) Native.loadLibrary(ParseUrlUtil.parseAbsolutePath("/dact/x64/Release/HwPortController.dll", System.getProperty("user.dir") + "\\HwPortController.dll"), IHwPortController.class);
IHwPortController instanceDll = (IHwPortController) Native.loadLibrary("D:\\work\\priusis\\priusis-iot\\apq-iot\\apq-client\\apq-pc-control\\src\\main\\resources\\dact\\x64\\Release\\HwPortController.dll", IHwPortController.class);
/** /**
* 初始化硬件接口管理模块 * 初始化硬件接口管理模块
......
APQ_HWPORT_NET_DEVID_ETH_CARD=APQ_HWPORT_NET_PERM_ALLOW
APQ_HWPORT_NET_DEVID_ETH_CARD_SPEED=1000000
APQ_HWPORT_NORMAL_DEVID_BT=APQ_HWPORT_NORMAL_PERM_ALLOW
APQ_HWPORT_NORMAL_DEVID_CAMERA=APQ_HWPORT_NORMAL_PERM_ALLOW
APQ_HWPORT_NORMAL_DEVID_DONGLE=APQ_HWPORT_NORMAL_PERM_UNKNOWN
APQ_HWPORT_NORMAL_DEVID_GPIO=APQ_HWPORT_NORMAL_PERM_UNKNOWN
APQ_HWPORT_NORMAL_DEVID_KEYBOARD=APQ_HWPORT_NORMAL_PERM_ALLOW
APQ_HWPORT_NORMAL_DEVID_MOUSE=APQ_HWPORT_NORMAL_PERM_ALLOW
APQ_HWPORT_NORMAL_DEVID_SERIAL=APQ_HWPORT_NORMAL_PERM_ALLOW
APQ_HWPORT_NORMAL_DEVID_USB_CONVERSION=APQ_HWPORT_NORMAL_PERM_ALLOW
APQ_HWPORT_STORAGE_DEVID_CDROM=APQ_HWPORT_STORAGE_PERM_UNKNOWN
APQ_HWPORT_STORAGE_DEVID_UDISK=APQ_HWPORT_STORAGE_PERM_UNKNOWN
KEY=value
...@@ -44,13 +44,10 @@ public class ApqRegisterApplication { ...@@ -44,13 +44,10 @@ public class ApqRegisterApplication {
// ] // ]
// } // }
// 一分钟一次上报
private final Long FIXED_DELAY = 60000L;
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
@Scheduled(fixedDelay = 60000L) @Scheduled(fixedDelay = 30000L)
protected void registerProgramTask() { protected void registerProgramTask() {
log.info("软件检测上报================="); log.info("软件检测上报=================");
// 获取软件检测监控配置 params == data // 获取软件检测监控配置 params == data
...@@ -74,25 +71,17 @@ public class ApqRegisterApplication { ...@@ -74,25 +71,17 @@ public class ApqRegisterApplication {
int type = registerParamDto.getType(); int type = registerParamDto.getType();
if (type == 1) { if (type == 1) {
List<String> loadProgramList = null;
try {
loadProgramList = loadProgramList();
} catch (IOException e) {
log.error("获取软件清单异常", e);
}
if (null == loadProgramList) {
return;
}
List<RegisterParamDto.RegisterDetailParamDto> programs = registerParamDto.getPrograms(); List<RegisterParamDto.RegisterDetailParamDto> programs = registerParamDto.getPrograms();
// 上报软件检测监控数据 // 上报软件检测监控数据
Map mapRequest = new HashMap(); Map mapRequest = new HashMap();
for (RegisterParamDto.RegisterDetailParamDto program : programs) { for (RegisterParamDto.RegisterDetailParamDto program : programs) {
String name = program.getName().trim().toLowerCase(); String name = program.getName().trim();
if (loadProgramList.contains(name)) { boolean isE = WinExecuteUtils.findProcess(name);
if (isE) {
// 杀进程 // 杀进程
log.info("存在黑名单软件, 进行进程查杀: {}", name);
try { try {
WinExecuteUtils.killProc(name); WinExecuteUtils.killProc(name);
} catch (Exception e) { } catch (Exception e) {
...@@ -124,42 +113,4 @@ public class ApqRegisterApplication { ...@@ -124,42 +113,4 @@ public class ApqRegisterApplication {
} }
/**
* 获取软件清单
*
* @return
* @throws IOException
*/
protected List<String> loadProgramList() throws IOException {
List<String> programs = new ArrayList<>();
Process process = Runtime.getRuntime()
.exec("cmd /c reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\");
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"))) {
String key;
while ((key = reader.readLine()) != null) {
List<String> info = queryProgramInfo(key);
programs.addAll(info);
}
process.destroy();
}
return programs;
}
private List<String> queryProgramInfo(String key) throws IOException {
List<String> info = new ArrayList<>();
Process process = Runtime.getRuntime().exec("cmd /c reg query " + key);
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"))) {
reader.readLine();
reader.readLine();
String line;
while ((line = reader.readLine()) != null) {
line = line.trim();
if (line.startsWith("DisplayName")) {
info.add(line.replace("DisplayName", "").replace("REG_SZ", "").trim().toLowerCase());
}
}
process.destroy();
}
return info;
}
} }
cd /d %~dp0 
::start xx.exe
for /F "TOKENS=1,2,*" %%b in ('tasklist /FI "IMAGENAME eq apq.exe"') do TASKKILL /F /PID %%b
::taskkill -f -t -im %MyPID%
for /F "TOKENS=1,2,*" %%a in ('jps -m ^| findstr apq-pc-client') do set SPID=%%a
TASKKILL /F /PID %SPID%
start ../jre/bin/apq-client -Xms256m -Xmx256m -Dfile.encoding=utf-8 -jar "%~dp0\apq-pc-client-0.0.1-SNAPSHOT-boot.jar"
echo 启动服务完毕
exit
\ No newline at end of file
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<workingdirectory>%BASE%</workingdirectory> <workingdirectory>%BASE%</workingdirectory>
<logpath>logs</logpath> <logpath>logs</logpath>
<logmode>rotate</logmode> <logmode>rotate</logmode>
<!--<executable>Start-java.bat</executable>-->
<executable>apq-client</executable> <executable>apq-client</executable>
<startargument>-Dplatform=windows</startargument> <startargument>-Dplatform=windows</startargument>
<startargument>-jar</startargument> <startargument>-jar</startargument>
......
@ECHO OFF
setlocal enabledelayedexpansion
@ECHO Stopping apq-client-service ...
net stop apq-client-service
@ECHO Uninstalling apq-client-service ...
"%~dp0apq-client-service.exe" uninstall
@ECHO DONE.
:END
\ No newline at end of file
@ECHO OFF
setlocal ENABLEEXTENSIONS
@ECHO Installing apq-client ...
"%~dp0apq-client-service.exe" install
@ECHO runing apq-client ...
"%~dp0apq-client-service.exe" start
@ECHO DONE.
:END
\ No newline at end of file
@ECHO OFF cd /d %~dp0 
setlocal enabledelayedexpansion setlocal enabledelayedexpansion
@ECHO Stopping apq-client-service ... for /F "TOKENS=1,2,*" %%b in ('tasklist /FI "IMAGENAME eq apq.exe"') do TASKKILL /F /PID %%b
net stop apq-client-service ::taskkill -f -t -im %MyPID%
@ECHO Uninstalling apq-client-service ...
"%~dp0apq-client-service.exe" uninstall
@ECHO DONE. for /F "TOKENS=1,2,*" %%a in ('jps -m ^| findstr apq-pc-client') do set SPID=%%a
TASKKILL /F /PID %SPID%
:END echo 删除服务完毕
\ No newline at end of file exit
\ No newline at end of file
@ECHO OFF cd /d %~dp0 
::start xx.exe
setlocal ENABLEEXTENSIONS
@ECHO Installing apq-client ... for /F "TOKENS=1,2,*" %%b in ('tasklist /FI "IMAGENAME eq apq.exe"') do TASKKILL /F /PID %%b
"%~dp0apq-client-service.exe" install ::taskkill -f -t -im %MyPID%
@ECHO runing apq-client ...
"%~dp0apq-client-service.exe" start
@ECHO DONE. for /F "TOKENS=1,2,*" %%a in ('jps -m ^| findstr apq-pc-client') do set SPID=%%a
TASKKILL /F /PID %SPID%
:END start ../jre/bin/apq-client -Xms256m -Xmx256m -Dfile.encoding=utf-8 -jar "%~dp0\apq-pc-client-0.0.1-SNAPSHOT-boot.jar"
\ No newline at end of file echo 启动服务完毕
exit
\ No newline at end of file
...@@ -52,8 +52,12 @@ Name: "english"; MessagesFile: "compiler:Default.isl" ...@@ -52,8 +52,12 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
Source: "../apq-control/*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Source: "../apq-control/*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs;
; NOTE: Don't use "Flags: ignoreversion" on any shared system files ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Tasks]
Name: "startupicon"; Description: "开机启动"; GroupDescription: "{cm:AdditionalIcons}";
[Icons] [Icons]
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commonstartup}\{#MyAppName}"; Filename: "{app}\service\启动服务.bat"; Tasks: startupicon
[Run] [Run]
Filename: "{app}\service\启动服务.bat"; Flags: runhidden; Filename: "{app}\service\启动服务.bat"; Flags: runhidden;
...@@ -70,6 +74,8 @@ Type: dirifempty; Name: "{app}" ...@@ -70,6 +74,8 @@ Type: dirifempty; Name: "{app}"
;操作注册表 ;操作注册表
[Registry] [Registry]
Root: HKLM; Subkey: "Software\apq-control"; Flags: uninsdeletekey; Root: HKLM; Subkey: "Software\apq-control"; Flags: uninsdeletekey;
Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "testrun"; ValueData: "{app}\{#MyAppExeName}"
[Code] [Code]
function CheckProcessRunning( aProcName, function CheckProcessRunning( aProcName,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论