Can anyone tell me how to do this.
i use GetStdHanlde(STD_OUTPUT_HANDLE) to obtain the output handle of console,
and then use ReadFile to read the string in console buffer and display on edit.
but, this cannot work.
this method is like RadASM IDE to display complied results on edit.
:(
Welcome on board.
Check the StdIn procedure from the Masm32 package to read string in console buffer :
; #########################################################################
.386
.model flat, stdcall
option casemap :none ; case sensitive
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
.code
; #########################################################################
StdIn proc lpszBuffer:DWORD,bLen:DWORD
LOCAL hInput :DWORD
LOCAL bRead :DWORD
invoke GetStdHandle,STD_INPUT_HANDLE
mov hInput, eax
invoke SetConsoleMode,hInput,ENABLE_LINE_INPUT or \
ENABLE_ECHO_INPUT or \
ENABLE_PROCESSED_INPUT
invoke ReadFile,hInput,lpszBuffer,bLen,ADDR bRead,NULL
mov eax, bRead
ret
StdIn endp
; #########################################################################
end
I think this is what you want?
.data
Command db "\masm32\bin\ml /c /coff "
Asmfilename db "someprogram.asm",0
;**************************************************************************
; This function assumes that command has been set with a command line
; string to be executed.
;**************************************************************************
Assemble Proc hWin:DWORD, hEditbox:DWORD,pCommand:DWORD
LOCAL startupinfo :STARTUPINFO
LOCAL pinfo :PROCESS_INFORMATION
LOCAL sat :SECURITY_ATTRIBUTES
LOCAL hRead :DWORD
LOCAL hWrite :DWORD
LOCAL bytesread :DWORD
LOCAL buffer[256] :byte
invoke SendMessage,hEditbox,WM_SETTEXT,0,0
mov sat.nLength,sizeof SECURITY_ATTRIBUTES
mov sat.lpSecurityDescriptor,NULL
mov sat.bInheritHandle,TRUE
invoke CreatePipe,addr hRead,addr hWrite,addr sat,NULL
.if eax == NULL
invoke MessageBox,hWin,txt("Error, Creating pipe."),txt("Error!"),MB_ICONERROR or MB_OK
.else
mov startupinfo.cb,sizeof STARTUPINFO
invoke GetStartupInfo,addr startupinfo
mov eax,hWrite
mov startupinfo.hStdOutput,eax
mov startupinfo.hStdError,eax
mov startupinfo.dwFlags,STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES
mov startupinfo.wShowWindow,SW_HIDE
;-------------------------------------------------
; Create process
;-------------------------------------------------
invoke CreateProcess,NULL, pCommand,NULL,NULL,TRUE,NULL,NULL,NULL,addr startupinfo,addr pinfo
.if eax == NULL
invoke MessageBox,hWin,txt("Error, Creating Process."),txt("Error!"),MB_ICONERROR or MB_OK
.else
invoke CloseHandle,hWrite
.while TRUE
invoke RtlZeroMemory,addr buffer,256
invoke ReadFile,hRead,addr buffer,256,addr bytesread,NULL
.if eax == NULL
.break
.else
invoke SendMessage,hEditbox,EM_SETSEL,-1,0
invoke SendMessage,hEditbox,EM_REPLACESEL,FALSE,addr buffer
.endif
.endw
.endif
invoke CloseHandle,hRead
.endif
ret
Assemble endp
Zcoder....
thanks both Vortex and zcoder answer for me. :P
i solved this problems by using zcoder's method.
the key point is CreatePipe.
thanks.