|
发表于 2020-12-6 18:49:26
|
显示全部楼层
河北省廊坊市
本帖最后由 BXV 于 2020-12-6 19:18 编辑
建议使用其他模块获取DOS数据,经过分析源码后猜测是管道过小,读取过慢,导致CMD结束后仍未读取完毕(对管道没有太多研究,但是查看源码后我认为是此问题的几率较大)。
请尝试如下代码,如问题无法解决请更换模块:
|
系统_取DOS执行结果 | 文本型 | | |
命令行文本 | 文本型 | | | | 即时回显 | 子程序指针 | | | |
变量名 | 类 型 | 静态 | 数组 | 备 注 | SECURITY_ATTRIBUTES | SECURITY_ATTRIBUTES | | | STARTUPINFO | STARTUPINFO_短整数 | | | PROCESS_INFORMATION | 精易_进程结构 | | | hWrite | 整数型 | | | hRead | 整数型 | | | txt | 字节集 | | | Length | 整数型 | | | ExitCode | 整数型 | | | retext | 文本型 | | | Buff | 文本型 | | | hook | 字节集 | | |
SECURITY_ATTRIBUTES.nLength = 1024 SECURITY_ATTRIBUTES.lpSecurityDescriptor = 0 SECURITY_ATTRIBUTES.bInheritHandle = 真 CreatePipe (hRead, hWrite, SECURITY_ATTRIBUTES, 0 ) STARTUPINFO.cb = 68 STARTUPINFO.dwFlags = 位或 ( #STARTF_USESHOWWINDOW, #STARTF_USESTDHANDLES )STARTUPINFO.wShowWindow = #SW_HIDE STARTUPINFO.hStdOutput = hWrite STARTUPINFO.hStdError = hWrite 如果 (取操作系统类别 () ≤ 2 )CreateProcess_短整数2 (0, “command.com /c ” + 命令行文本, 0, 0, 真, 0, 0, 0, STARTUPINFO, PROCESS_INFORMATION ) CreateProcess_短整数2 (0, “cmd.exe /c ” + 命令行文本, 0, 0, 真, 0, 0, 0, STARTUPINFO, PROCESS_INFORMATION ) CloseHandle (hWrite ) hook = { 85, 139, 236, 86, 139, 117, 16, 141, 78, 255, 133, 201, 124, 21, 139, 69, 12, 141, 4, 136, 65, 139, 16, 137, 85, 16, 255, 117, 16, 131, 232, 4, 73, 117, 242, 255, 85, 8, 137, 69, 12, 139, 69, 20, 133, 192, 116, 13, 141, 4, 181, 0, 0, 0, 0, 137, 69, 16, 3, 101, 16, 139, 69, 12, 94, 93, 194, 16, 0 }判断循环首 (Length ≠ -1 ) PeekNamedPipe (hRead, 0, 0, 0, Length, 0 ) 如果 (Length ≠ 0 )txt = 取空白字节集 (Length )ReadFile (hRead, txt, Length, Length, 0 ) Buff = 取字节集数据 (txt, #文本型, )如果真 (是否为空 (即时回显 ) = 假)如果真 (CallWindowProcA (取指针字节集_ (hook ), 到整数 (即时回显 ), 取指针_通用型 (Buff ), 1, 0 ) ≠ 0 )CloseHandle (hRead ) 跳出循环 ()retext = retext + BuffGetExitCodeProcess (PROCESS_INFORMATION.进程句柄, ExitCode ) 如果真 (ExitCode ≠ #STILL_ACTIVE ) CloseHandle (hRead ) 跳出循环 ()系统_处理事件 ()程序_延时 (1 )判断循环尾 ()CloseHandle (PROCESS_INFORMATION.进程句柄 )CloseHandle (PROCESS_INFORMATION.线程句柄 )返回 (retext )
|
评分
-
参与人数 1 | 荣誉 +3 |
收起
理由
|
笨潴
| + 3 |
热心帮助他人,荣誉+3,希望继续努力(*^__^*) 嘻嘻! |
查看全部评分
|