Author Topic: Invoke Win32  (Read 11051 times)

Offline nimday

  • Jr. Member
  • *
  • Posts: 2
  • Country: id
Invoke Win32
« on: May 04, 2014, 09:23:27 PM »
Hello , how to create invoke like masm , i read nasmx but to complex to me
Can somebody give a small example to improve this code
Thanks

Code: [Select]
%macro Invoke1 2
 push %2
 call %1
%endmacro

%macro Invoke4 5
 push %5
 push %4
 push %3
 push %2
 call %1
%endmacro

extern _ExitProcess@4
extern _MessageBoxA@16

global _main

section .data
msg db "Hello",0
caption db "title",0

section .text

_main:

    Invoke4 _MessageBoxA@16,0,msg,caption,0
    Invoke1 _ExitProcess@4,0

Offline encryptor256

  • Full Member
  • **
  • Posts: 250
  • Country: lv
  • Win64 .
    • On Youtube: encryptor256
Re: Invoke Win32
« Reply #1 on: May 05, 2014, 12:20:31 PM »
Hi,
this might work!

Win32, invoke stdcall routine:
Code: [Select]
%macro invoke 1-*

%assign max %0 - 1

%if max > 0

%rotate max

%rep max

%warning %1

push %1

%rotate -1
%endrep

%endif

call %1
%endmacro

I suggest using NASMX,
because in win32 there is an 'N' various calling conventions,
which NASMX has worked out.
Encryptor256's Investigation \ Research Department.

Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 429
  • Country: us
Re: Invoke Win32
« Reply #2 on: May 05, 2014, 03:35:42 PM »
Hello , how to create invoke like masm , i read nasmx but to complex to me

What part is too complex?  As the current NASMX lead designer I'm very interested in where you get stuck.  NASMX should be very familiar to Masm users.

Can somebody give a small example to improve this code

As encryptor256 points out NASMX has already worked through all the issues you're likely to encounter when writing code.  At your level I don't recommend attempting to read through the macro definitions themselves as they are rather complex but rather simply use them until you become more comfortable.

Check out nasmx/demos/win32/ and start with DEMO1.  Each directory has a small example which shows you how to achieve what you're attempting.

Offline nimday

  • Jr. Member
  • *
  • Posts: 2
  • Country: id
Re: Invoke Win32
« Reply #3 on: May 05, 2014, 07:43:24 PM »
@encryptor256 , Thanks it's working for me :)
@Rob Neff , You are right , maybe i read too much from nasmx.inc  :-[

Thanks all