NO

Author Topic: 64 bit Poasm window example  (Read 543 times)

Offline Mikl___

  • Member
  • *
  • Posts: 15
64 bit Poasm window example
« on: October 08, 2016, 10:45:21 am »
Hi, all!
64 bit simple window size of exe-file 848 bytes
build.bat
Code: [Select]
cls
set pelleasm=\poasm_new
set filename=%1
if exist %filename%.exe del if exist %filename%.exe
if exist %filename%.rc (
%pelleasm%\bin\porc /I%pelleasm%\include %filename%.rc
%pelleasm%\bin\poasm /I%pelleasm%\include /AAMD64 %filename%.asm
%pelleasm%\bin\polink /SUBSYSTEM:WINDOWS /ALIGN:16 /MERGE:.data=.text ^
/LARGEADDRESSAWARE:NO /LIBPATH:%pelleasm%\lib /BASE:0x400000 ^
/STUB:%pelleasm%\bin\stubby.exe %filename%.obj %filename%.res
del %filename%.res
) else (
%pelleasm%\bin\poasm /I%pelleasm%\include /AAMD64 %filename%.asm
%pelleasm%\bin\polink /SUBSYSTEM:WINDOWS /ALIGN:16 /MERGE:.data=.text ^
/LARGEADDRESSAWARE:NO /LIBPATH:%pelleasm%\lib /BASE:0x400000 ^
/STUB:%pelleasm%\bin\stubby.exe %filename%.obj
)
del %filename%.obj
SimpleWnd.asm
Code: [Select]
include win64a.inc
extern __imp_ExitProcess:qword
extern __imp_DefWindowProcA:qword
extern __imp_DispatchMessageA:qword
extern __imp_GetMessageA:qword
extern __imp_RegisterClassExA:qword
extern __imp_CreateWindowExA:qword
.code

start:
        sub esp,30h+sizeof MSG

msg equ rsp+sizeof MSG

xor ebx,ebx
mov eax,10027h
mov esi,IMAGE_BASE
db 0BFh
dd ClassName ;mov edi,offset ClassName
push rax ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
db 68h
dd COLOR_WINDOW;hbrBackground
db 68h
dd 10003h ;hCursor
push rax      ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc
db 68h
dd SIZEOF WNDCLASSEXA
mov ecx,esp
call __imp_RegisterClassExA

push rbx
push rsi ;rsi=400000h
shl esi,9 ;rsi=CW_USEDEFAULT
push rbx
push rbx
push rsi
push rsi
push rsi
push rsi
mov r9d,WS_OVERLAPPEDWINDOW or WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h
call __imp_CreateWindowExA
lea edi,msg
    .WHILE (1)
xor r9,r9
xor r8,r8
xor edx,edx
mov ecx,edi
        call __imp_GetMessageA
mov ecx,edi
        call __imp_DispatchMessageA
    .ENDW
;--------------------------------
WndProc:
cmp edx,WM_DESTROY
jnz @f
xor ecx,ecx
        call __imp_ExitProcess
@@:
        jmp __imp_DefWindowProcA
;data-------------------------------
ClassName  db "WndClass",0
END start
« Last Edit: October 08, 2016, 01:18:17 pm by Mikl___ »

Offline Vortex

  • Member
  • *
  • Posts: 501
    • http://www.vortex.masmcode.com
Re: 64 bit Poasm window example
« Reply #1 on: October 08, 2016, 11:14:06 am »
Hi  Mikl,

Nice work. Thanks.
Code it... That's all...

Offline Mikl___

  • Member
  • *
  • Posts: 15
Re: 64 bit Poasm window example
« Reply #2 on: October 08, 2016, 01:09:58 pm »
Hi, Vortex!
I'm here because I have seen your topics 64 bit Poasm dialog box example and 64 bit Poasm window example. Do you know where in the PoAsm, may to see the macro described "invoke"?
« Last Edit: October 08, 2016, 01:15:17 pm by Mikl___ »

Offline Vortex

  • Member
  • *
  • Posts: 501
    • http://www.vortex.masmcode.com
Re: 64 bit Poasm window example
« Reply #3 on: October 08, 2016, 01:18:12 pm »
Hi  Mikl,

Like HJWasm, Poasm has built-in invoke macro support. Just like ml.exe for 32-bit programming, it provides an invoke macro.

Checking the help file of Pelles C, \PellesC\Bin\Help\help0009.chm, commandline tools -> POASM macro assembler -> Pseudo instructions -> INVOKE :

Quote
INVOKE (IA32, AMD64)

Purpose:
Invokes a procedure.

Syntax:
INVOKE name [ , argument list ]

Description:
The INVOKE pseudo-instruction simplifies invoking a procedure. The assembler will make sure arguments are passed correctly, according to the convention used by the procedure. This includes, but is not limited to, sign/zero extending some arguments.

The name and arguments of the procedure must already be known by the assembler, so always use a PROC or PROTO directive before INVOKE.

The argument list is a sequence of zero or more comma-separated expressions. The assembler will add the appropriate PUSH or MOV instruction (sometimes more), so it is usually best to think of the expressions as instruction operands.

Example:

INVOKE InitCommonControls
INVOKE MessageBox, NULL, ADDR msg, ADDR caption, (MB_OK or MB_ICONINFORMATION)

Thanks again for your code. Nice combination of manual coding and HLL constructs.
Code it... That's all...