use of jnc.platform.win32.STARTUPINFO in project judge by zjnu-acm.
the class WindowsExecutor method createProcess.
private PROCESS_INFORMATION createProcess(String lpCommandLine, long hIn, long hOut, long hErr, boolean redirectErrorStream, Path lpCurrentDirectory) {
STARTUPINFO startupInfo = new STARTUPINFO();
startupInfo.setCb(startupInfo.size());
startupInfo.setDesktop(DESKTOP);
PROCESS_INFORMATION lpProcessInformation = new PROCESS_INFORMATION();
// without cursor feed back
startupInfo.setFlags(STARTF_USESTDHANDLES | STARTF_FORCEOFFFEEDBACK);
startupInfo.setStdInput(hIn);
startupInfo.setStdOutput(hOut);
startupInfo.setStdError(hErr);
setInheritable(hIn);
setInheritable(hOut);
if (!redirectErrorStream) {
setInheritable(hErr);
}
try {
ProcessCreationHelper.execute(() -> {
String lpApplicationName = null;
int dwCreationFlags = CREATE_SUSPENDED | DETACHED_PROCESS | HIGH_PRIORITY_CLASS | CREATE_NEW_PROCESS_GROUP | CREATE_UNICODE_ENVIRONMENT | (Kernel32Util.getOSVersion() >= 0x602 ? 0 : CREATE_BREAKAWAY_FROM_JOB) | CREATE_NO_WINDOW;
Kernel32Util.assertTrue(Advapi32.INSTANCE.CreateProcessAsUserW(hToken.getValue(), // executable name
WString.toNative(lpApplicationName), // command line
WString.toNative(lpCommandLine), // process security attribute
null, // thread security attribute
null, // inherits system handles
true, // selected based on exe type
dwCreationFlags, EMPTY_ENV, WString.toNative(Objects.toString(lpCurrentDirectory, null)), startupInfo, lpProcessInformation));
});
} catch (Win32Exception ex) {
throw new NotExecutableException(ex);
}
return lpProcessInformation;
}
Aggregations