; Example of 64-bit PE program
format PE64 GUI
entry start
section '.text' code readable executable
start:
sub rsp,8*5 ; reserve stack for API use and make stack dqword aligned
xor r9d,r9d
lea r8,[_caption]
lea rdx,[_message]
xor rcx,rcx
call [MessageBoxW]
mov ecx,eax
call [ExitProcess]
section '.const' data readable
_caption du 'Win64 assembly program',0
_message du 'Hello, World!',0
section '.idata' import data readable
dd 0,0,0,RVA kernel_name,RVA kernel_table
dd 0,0,0,RVA user_name,RVA user_table
dd 0,0,0,0,0
kernel_table:
ExitProcess dq RVA _ExitProcess
dq 0
user_table:
MessageBoxW dq RVA _MessageBoxW
dq 0
kernel_name db 'KERNEL32.DLL',0
user_name db 'USER32.DLL',0
_ExitProcess dw 0
db 'ExitProcess',0
_MessageBoxW dw 0
db 'MessageBoxW',0
org 100h
mov ah,9h
mov dx,hello
int 21h
mov ah,8h
int 21h
int 20h
hello db 13,10,"Hello, World!$"
TCHAR buffer[UNLEN + 1]; // буфер
DWORD size = sizeof(buffer) / sizeof(*buffer); // размер буфера
GetUserName(buffer, &size);
basic_string<TCHAR> userName = buffer;