refactor(capture): screen capture in subprocess
- Move screen capture to child process - Isolate GDI/BitBlt crashes from agent - Use -capture flag for internal helper mode - Add protocol for frame request/response - Make monitor enumeration thread-safe
This commit is contained in:
@@ -14,6 +14,7 @@ var (
|
||||
procSetConsoleCtrl = kernel32.NewProc("SetConsoleCtrlHandler")
|
||||
procAllocConsole = kernel32.NewProc("AllocConsole")
|
||||
procGetStdHandle = kernel32.NewProc("GetStdHandle")
|
||||
procGetFileType = kernel32.NewProc("GetFileType")
|
||||
user32 = syscall.NewLazyDLL("user32.dll")
|
||||
procShowWindow = user32.NewProc("ShowWindow")
|
||||
consoleCtrlCallback uintptr
|
||||
@@ -81,6 +82,9 @@ func consoleCtrlHandler(ctrlType uintptr) uintptr {
|
||||
}
|
||||
|
||||
func redirectStdioToNul() {
|
||||
if stdioIsPipe() {
|
||||
return
|
||||
}
|
||||
nul, err := os.OpenFile("NUL", os.O_RDWR, 0)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -89,3 +93,12 @@ func redirectStdioToNul() {
|
||||
os.Stdout = nul
|
||||
os.Stderr = nul
|
||||
}
|
||||
|
||||
func stdioIsPipe() bool {
|
||||
const fileTypePipe = 3
|
||||
stdin, _, _ := procGetStdHandle.Call(^uintptr(9))
|
||||
stdout, _, _ := procGetStdHandle.Call(^uintptr(10))
|
||||
inType, _, _ := procGetFileType.Call(stdin)
|
||||
outType, _, _ := procGetFileType.Call(stdout)
|
||||
return inType == fileTypePipe || outType == fileTypePipe
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user