Author Topic: coinvoke MACRO  (Read 2337 times)

ToutEnMasm

  • Member
  • *****
  • Posts: 1189
    • EditMasm
coinvoke MACRO
« on: October 15, 2014, 03:12:35 AM »

Here is the coinvoke macro to use with the translated sdk header.
This allow to change the header of a source code,without too many problems.
Tested with http://masm32.com/board/index.php?topic=3568.msg37519#msg37519
Quote
coinvoke MACRO pInterface:REQ, Interface:REQ, Function:REQ, args:VARARG
    LOCAL istatement, arg
    FOR arg, <args>     ;; run thru args to see if edx is lurking in there
        IFIDNI <&arg>, <edx>
            .ERR <edx is not allowed as a coinvoke parameter>
        ENDIF
    ENDM
    IFIDNI <&pInterface>, <edx>
        .ERR <edx is not allowed as a coinvoke parameter>
    ENDIF
    istatement CATSTR <invoke (ST&Interface PTR[edx]).>,<&Function, pInterface>
    IFNB <args>     ;; add the list of parameter arguments if any
        istatement CATSTR istatement, <, >, <&args>
    ENDIF
    mov edx, pInterface
    mov edx, [edx]
    istatement
ENDM
Fa is a musical note to play with CL

Vortex

  • Member
  • *****
  • Posts: 1704
Re: coinvoke MACRO
« Reply #1 on: October 15, 2014, 05:37:21 AM »
Hi ToutEnMasm,

Here is my version :

Code: [Select]
coinvoke MACRO ppv:REQ,interface:REQ,member:REQ,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16

    FOR arg,<p16,p15,p14,p13,p12,p11,p10,p9,p8,p7,p6,p5,p4,p3,p2,p1>

        IFNB <arg>

            push arg

        ENDIF

    ENDM

    mov     eax,ppv
    push    eax
    mov     eax,DWORD PTR [eax]
    call    @CatStr(interface,<.>,member)[eax]

ENDM

Siekmanski

  • Member
  • *****
  • Posts: 1093
Re: coinvoke MACRO
« Reply #2 on: October 15, 2014, 07:38:16 AM »
another one,

Code: [Select]
Asio_invoke MACRO pInterface:REQ,Function:REQ,Args:VARARG
LOCAL ArgList
ArgList TEXTEQU <>
     
IFNB <Args>
FOR Arg,<Args>
ArgList CATSTR <Arg>,<,>,ArgList
ENDM
ArgList SUBSTR ArgList,1,@SizeStr(%ArgList)-1
ArgList CATSTR <!<>,ArgList,<!>>

%FOR parameter,ArgList
push parameter
ENDM
ENDIF
       
mov ecx,pInterface
mov eax,[ecx]
call DWORD PTR [eax+Function]
ENDM

ToutEnMasm

  • Member
  • *****
  • Posts: 1189
    • EditMasm
Re: coinvoke MACRO
« Reply #3 on: October 15, 2014, 05:15:19 PM »
If Siekmanski allow me this,as a test,i have changed the include files of his source code for the translated sdk.
The coinvoke macro posted upper is in use here.
If you don't agree,i just delet this post.
 
There is just a little modify of the sdk32.inc file to do to make it work.
Quote
        .686P   
      .XMM
      ;.MMX    ;-------------------- create a problem with other instructions
                                 
Fa is a musical note to play with CL

dedndave

  • Member
  • *****
  • Posts: 8734
  • Still using Abacus 2.0
    • DednDave
Re: coinvoke MACRO
« Reply #4 on: October 15, 2014, 06:07:08 PM »
hi Yves
it might be the order...
Code: [Select]
        .686p
        .MMX
        .XMM

ToutEnMasm

  • Member
  • *****
  • Posts: 1189
    • EditMasm
Re: coinvoke MACRO
« Reply #5 on: October 15, 2014, 06:21:17 PM »
Quote
it might be the order...
 .686p
        .MMX
        .XMM
OK ,it work.

Fa is a musical note to play with CL

Siekmanski

  • Member
  • *****
  • Posts: 1093
Re: coinvoke MACRO
« Reply #6 on: October 15, 2014, 07:18:11 PM »
I didn't write the coinvoke macro, picked it up in 2003 when i transalated the d3d9 includes.
Believe it was written by a guy named ernie.

feel free to use and change anything i post here.