Paste number 22514: Win32 ASM Clip

Paste number 22514: Win32 ASM Clip
Pasted by: TheAbysmal
When:2 years, 11 months ago
Share:Tweet this! | http://paste.lisp.org/+HDE
Channel:#programmering
Paste contents:
Raw Source | XML | Display As
extern GetModuleHandleA
import GetModuleHandleA  kernel32.dll

extern GetCommandLineA
import GetCommandLineA   kernel32.dll

extern ExitProcess
import ExitProcess       kernel32.dll

extern LoadIconA
import LoadIconA         user32.dll

extern LoadCursorA
import LoadCursorA       user32.dll

extern RegisterClassExA
import RegisterClassExA  user32.dll

extern CreateWindowExA
import CreateWindowExA   user32.dll

extern ShowWindow
import ShowWindow        user32.dll

extern DefWindowProcA
import DefWindowProcA    user32.dll

extern UpdateWindow
import UpdateWindow      user32.dll

extern GetMessageA
import GetMessageA       user32.dll

extern TranslateMessage
import TranslateMessage  user32.dll

extern DispatchMessageA
import DispatchMessageA  user32.dll

extern MessageBoxA
import MessageBoxA       user32.dll


section rdata use32

NULL            equ 0

SW_SHOW         equ 5
SW_SHOWDEFAULT  equ 10

CS_VREDRAW      equ 1h
CS_HREDRAW      equ 2h

COLOR_WINDOW    equ 5

IDI_APPLICATION equ 32512
IDC_ARROW       equ 32512

CW_USEDEFAULT   equ 80000000h

WS_OVERLAPPED   equ 0h
WS_CAPTION      equ 0C00000h
WS_SYSMENU      equ 80000h
WS_THICKFRAME   equ 40000h
WS_MINIMIZEBOX  equ 20000h
WS_MAXIMIZEBOX  equ 10000h

WM_DESTROY      equ 2h


section data use32

ClassName db 'SimpleWinClass', 0
AppName   db 'Our First Window', 0


section bss use32

hInstance   resd 1
CommandLine resd 1


section code use32

..start:

  ;Save the Instance Handle
  push dword NULL
  call [GetModuleHandleA]
  mov  [hInstance], eax

  ;Save the Command Line
  call [GetCommandLineA]
  mov  [CommandLine], eax

  ;Start the Main Window
  push dword SW_SHOWDEFAULT
  push dword CommandLine
  push dword NULL
  push dword [hInstance]
  call WinMain

  ;Quit the Application
  xor  eax, eax
  push eax
  call [ExitProcess]

WinMain:

  ;Allocate the Stack Frame
  push ebp
  mov  ebp, esp

  ;Allocate Local Storage

  ;Display a Message Box
  push dword 0h ;MB_OK
  push dword ClassName
  push dword CommandLine
  push dword NULL
  call [MessageBoxA]

  ;Destroy the Stack Frame
  mov  esp, ebp
  pop  ebp

  ;Remove the Parameters
  sub esp, 16

  ret

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.