Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; HELLO.EXE - SAY WELCOME - SAY HELLO - TAKE 2 INT'S - RETURN SUM
- ; Link With -lkernel32
- section .data ;Constants
- output_handle db 0 ;Define byte 0
- bytes_written db 0 ;Define byte 0
- bytes_written_2 db 0 ;Define byte 0
- STD_OUTPUT_HANDLE dd -11 ;Define dword -11
- welcome_msg db "Welcome",10 ;Define byte "welcome" + newline
- hello_msg db 10,"Hello World",10 ;Define byte newline + "Hello" + newline
- section .text ;Code
- global _WinMain@16 ;Define where to start
- extern _ExitProcess@4 ;Get ExitProcess Function, 4 bytes of args
- extern _GetStdHandle@4 ;Get GetStdHandle Function, 4 bytes of args
- extern _WriteConsoleA@20 ;Get WriteConsoleA Function, 20 bytes of args
- extern _Sleep@4 ;Get Sleep Function, 4 bytes of args
- extern _GetLastError@0 ;Get GetLastError Function, 0 byter of args
- _WinMain@16: ;Where to start
- call GetHandle ;Goto section GetHandle
- call WelcomeToConsole ;Goto section WriteConsole
- call GetHandle ;Goto section GetHandle
- call HelloToConsole ;Goto section HelloToConsole
- call ExitProgram ;Goto section ExitProgram
- GetHandle: ;Get Output Handle ($CONOUT)
- push dword [STD_OUTPUT_HANDLE] ;Arg of GetStdHandle, DWORD nStdHandle, (-11)
- call _GetStdHandle@4 ;Call GetStdHandle
- mov [output_handle], eax ;Move contents of CPU register eAx to mem addr of output_handle
- WelcomeToConsole: ;Write Welcome Message To Console
- push dword 0 ;Last arg of WriteConsole must be 0, LPVOID lpReserved, (0)
- push bytes_written ;Penultimate arg of WriteConsole, LPDWORD lpNumberOfCharsWritten, (mem addr of bytes_written)
- push dword 8 ;Third arg of WriteConsole, DWORD nNumberOfCharsToWrite, (9)
- push welcome_msg ;Second arg of WriteConsole, VOID *lpBuffer, (welcome_msg)
- push dword [output_handle] ;First arg of WriteConsole, HANDLE hConsoleOutput, (mem addr of output_handle, converted to dword
- call _WriteConsoleA@20 ;Call WriteConsoleA
- HelloToConsole: ;Write Hello Message To Console
- push dword 0 ;Last arg of WriteConsole must be 0, LPVOID lpReserved, (0)
- push bytes_written_2 ;Penultimate arg of WriteConsole, LPDWORD lpNumberOfCharsWritten, (mem addr of bytes_written_2)
- push dword 13 ;Third arg of WriteConsole, DWORD nNumberOfCharsToWrite, (14)
- push hello_msg ;Second arg of WriteConsole, VOID *lpBuffer, (hello_msg)
- push dword [output_handle] ;First arg of WriteConsole, HANDLE hConsoleOutput, (mem addr of output_handle, converted to dword
- call _WriteConsoleA@20 ;Call WriteConsoleA
- ExitProgram: ;Exit Program
- push dword 3000 ;Arg of Sleep, DWORD dwMilliseconds, (3000)
- call _Sleep@4 ;Call Sleep
- push dword 0 ;Arg of ExitProcess, UINT uExitCode, (0, ERROR_SUCESS)
- call _ExitProcess@4 ;Call ExitProcess
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement