Hello
How do I understand when the pipe is empty?
The code is attached
Thank you
.data
BytesWritten dd 0
.data?
stinfo STARTUPINFO <>
.code
;++++++++++++++++++++++++++++++++++++++++++++++++++
;invoke Shell,chr$("C:\Windows\system32\cmd.exe"),chr$("dir /S /B D:\masm32\examples\"),addr outbuffer
;+++++++++++++++++++++++++++++++++++++++++++++++++
Shell proc CommandLine :DWORD,Param:DWORD,lpbuffer:DWORD
LOCAL hChildStd_In_Rd :DWORD
LOCAL hChildStd_In_Wr :DWORD
LOCAL hChildStd_Out_Rd :DWORD
LOCAL hChildStd_Out_Wr :DWORD
LOCAL hParentStd_Out :DWORD
; LOCAL pbuffer [1024]:BYTE
LOCAL security_attrib :SECURITY_ATTRIBUTES
LOCAL pinfo :PROCESS_INFORMATION
mov security_attrib.lpSecurityDescriptor,0
mov security_attrib.bInheritHandle,TRUE
mov security_attrib.nLength,sizeof SECURITY_ATTRIBUTES
invoke CreatePipe,addr hChildStd_Out_Rd ,addr hChildStd_Out_Wr,addr security_attrib,0
or eax,eax
jz EX
invoke CreatePipe,addr hChildStd_In_Rd ,addr hChildStd_In_Wr,addr security_attrib,0
or eax,eax
jz EX
invoke SetHandleInformation,hChildStd_Out_Rd,HANDLE_FLAG_INHERIT, 0
or eax,eax
jz EX
invoke SetHandleInformation,hChildStd_In_Wr,HANDLE_FLAG_INHERIT, 0
or eax,eax
jz EX
mov stinfo.cb,sizeof STARTUPINFO
mov eax,hChildStd_Out_Wr
mov stinfo.hStdError,eax
mov stinfo.hStdOutput,eax
mov eax,hChildStd_In_Rd
mov stinfo.hStdInput,eax
mov stinfo.dwFlags,STARTF_USESHOWWINDOW+STARTF_USESTDHANDLES
; mov stinfo.wShowWindow,SW_HIDE
invoke CreateProcess,CommandLine,0,0,0,TRUE,NULL,0,0,offset stinfo,addr pinfo
or eax,eax
jz EX
invoke WriteFile,hChildStd_In_Wr,Param,1024,addr BytesWritten,0
invoke CloseHandle, hChildStd_Out_Wr
invoke Sleep,50
invoke ReadFile,hChildStd_Out_Rd,lpbuffer,1024,addr BytesWritten,0
EX:
ret
Shell endp
Seems you have a simplify version of the pipe.
the readfile must entry in a loop until he received a number of ZERO byte.
Try to find a sample working well in c who perhaps here.
Here a sample (in french ??) http://luce.yves.pagesperso-orange.fr/_tut21.html (http://luce.yves.pagesperso-orange.fr/_tut21.html)
copy paste the sample must be enough
I have an example reading a pipe from child process and writing back to parent pipe, which uses a loop to keep peeking, reading and writing whilst there is stuff to read/write: https://github.com/mrfearless/EEexLoader/blob/master/EEex/EEexConsole.asm#L145
I have an example reading a pipe from child process and writing back to parent pipe, which uses a loop to keep peeking, reading and writing whilst there is stuff to read/write: https://github.com/mrfearless/EEexLoader/blob/master/EEex/EEexConsole.asm#L145
In this link, there is a lot of "EEEX_ALIGN" labels. What is "EEEX_ALIGN"? I have never seen this term before.
.CONST
EEEX_ALIGN TEXTEQU <ALIGN 16>