汇编写一个WINFORM的CMD,通过管道,命令可以执行,但是获取不到输出值,求解
代码:
_CreateCmd proc hWnd
LOCAL hsi:STARTUPINFO
LOCAL pi:PROCESS_INFORMATION
LOCAL sa:SECURITY_ATTRIBUTES
LOCAL bytesRead
LOCAL szBuffer[4096]:byte
LOCAL hRead:DWORD
LOCAL hWrite:DWORD
LOCAL ExitCode
xor eax,eax
mov bytesRead,eax
mov sa.nLength,sizeof SECURITY_ATTRIBUTES
mov sa.lpSecurityDescriptor,NULL
mov sa.bInheritHandle,TRUE
mov hsi.cb ,sizeof STARTUPINFO
invoke GetStartupInfo, addr hsi
mov eax,hRead
mov hsi.hStdInput,eax
mov eax,hWrite
mov hsi.hStdOutput,eax
mov hsi.hStdError, eax
mov hsi.wShowWindow,SW_HIDE
mov hsi.dwFlags,STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES
invoke GetDlgItemText,hWnd,ICE_CMD,offset CMDbuffer,offset CMDbuffer
.if eax==0
invoke MessageBox,hWnd,offset ERRBuffer,ERRBuffer,MB_ICONERROR
.else
invoke lstrcat,offset szCMDEXET, offset CMDbuffer
invoke MessageBox,hWnd,offset szCMDEXET,offset szCMDEXET,MB_OK
invoke CreatePipe,addr hRead, addr hWrite,addr sa,0
invoke CreateProcess,NULL,offset szCMDEXET,NULL,NULL,TRUE,NULL,NULL,NULL,addr hsi,addr pi
invoke CloseHandle,hWrite
.while TRUE
invoke RtlZeroMemory,addr szBuffer,sizeof szBuffer
lea esi,szBuffer
invoke ReadFile,hRead,esi,sizeof szBuffer,addr bytesRead,0
invoke MessageBox,hWnd, addr szBuffer,addr szBuffer,MB_OK
;.if eax!=NULL
invoke lstrcat,addr strResult,addr szBuffer
invoke SetDlgItemText,hWnd,ICE_OVER,offset strResult
invoke OutputDebugString,addr szBuffer
;.else
;mov eax, FALSE
;ret
;.endif
;invoke CloseHandle,hRead
.endw
.endif
mov eax,TRUE
ret
_CreateCmd endp
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课