News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

CommandLine in console

Started by six_L, November 29, 2007, 05:03:03 AM

Previous topic - Next topic

six_L

.386
.model flat, stdcall
option casemap :none   ; case sensitive

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib

include \masm32\macros\macros.asm

Main   PROTO

.data
InputBuffer db "ping 127.1.1.1 /t",13,10,0
OutputBuffer db 1024 dup(0),0
_hConsoleIn dd 0
_hConsoleOut dd 0
.code

start:
invoke Main
mov eax,input("ENTRY for exit.")
invoke ExitProcess,0

Main proc
Local _iWritten:dword

invoke GetStdHandle,STD_OUTPUT_HANDLE
mov _hConsoleOut,eax
invoke GetStdHandle,STD_INPUT_HANDLE
mov _hConsoleIn,eax

invoke ClearScreen
invoke lstrlen,Offset InputBuffer
mov ebx,eax
invoke WriteConsole,_hConsoleOut,Offset InputBuffer,ebx,addr _iWritten,0
invoke ReadConsole,_hConsoleIn,addr OutputBuffer,1024,addr _iWritten,0

ret

Main endp

end start

the above code can't work.
regards

Tedd

If you're trying to get commands to execute, then no it won't :bdg

The read- and writeconsole functions read/write strings from/to the console, but what you do with those strings is up to you - the command processor never sees them.

"CreateProcess" may be what you're looking for.
No snowflake in an avalanche feels responsible.

six_L

regards