This is a simple Hello World code I copied from someone.
.386
.MODEL flat, stdcall
STD_OUTPUT_HANDLE EQU -11 ; std output device
;////
; Function prototypes
GetStdHandle PROTO, nStdHandle: DWORD
WriteConsoleA PROTO, handle: DWORD, lpBuffer:PTR BYTE, nNumberOfBytesToWrite:DWORD, lpNumberOfBytesWritten:PTR DWORD, lpReserved:DWORD
ExitProcess PROTO, dwExitCode: DWORD
;////
.data
consoleOutHandle dd ?
bytesWritten dd ?
message db "Hello darkness my old friend",13,10
lmessage equ $-message
;////
.code
main PROC
INVOKE GetStdHandle, STD_OUTPUT_HANDLE
mov consoleOutHandle, eax
mov edx, offset message
pushad
mov eax, lmessage
INVOKE WriteConsoleA, consoleOutHandle, edx, eax, offset bytesWritten, 0
popad
INVOKE ExitProcess, 0
main ENDP
END main
I wondered what the pushad and popad were for, so I removed them.
This is register data before and after WriteConsoleA
is invoked:
Before: EAX = 00000014 EBX = 00B1A000 ECX = 008C1005 EDX = 008C4008 ESI = 008C1005 EDI = 008C1005 EIP = 008C1026 ESP = 0081FCE8 EBP = 0081FCF4 EFL = 00000213
After: EAX = 00000001 EBX = 00B1A000 ECX = 00000014 EDX = 008C4004 ESI = 008C1005 EDI = 008C1005 EIP = 008C103A ESP = 0081FCE8 EBP = 0081FCF4 EFL = 00000202
I looked up the msdn page for the function but couldn't find anything about it.
Is it the function doing this? Do all functions behave like this?