Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;CGI Hello World with NASM and win32 API
- ;version: 1.0.0
- BITS 32
- STD_OUTPUT_HANDLE equ -11
- section .data
- HTTPheader: db "Content-Type:text/html;charset=us-ascii", 0xa, 0xa
- HH_LEN equ $-HTTPheader
- WebPage: db "<html><body><code>Hello World</code></body></html>"
- WP_LEN equ $-WebPage
- section .code
- extern _GetStdHandle@4
- extern _WriteFile@20
- global _WinMain@16
- _WinMain@16:
- push ebp
- mov ebp,esp
- sub esp,12
- ;[ebp-4] : stdout
- ;[ebp-8] : &bytesWritten
- ;[ebp-12] : bytesWritten
- ;get and store ptr to bytesWritten
- mov edx,ebp
- sub edx,12
- mov dword[ebp-8],edx
- ;get stdout
- push STD_OUTPUT_HANDLE
- call _GetStdHandle@4
- mov dword[ebp-4],eax ;store stdout handle
- ;send header
- push 0
- push dword[ebp-8] ;&bytesWritten
- push HH_LEN
- push HTTPheader
- push dword[ebp-4] ;stdout
- call _WriteFile@20
- ;send web page
- push 0
- push dword[ebp-8] ;&bytesWritten
- push WP_LEN
- push WebPage
- push dword[ebp-4] ;stdout
- call _WriteFile@20
- .ret:
- xor eax,eax
- mov esp,ebp
- pop ebp
- ret
Advertisement
Add Comment
Please, Sign In to add comment