Author Topic: How to program GUI applications using MASM but without MASM-SDK?  (Read 701 times)

nidud

  • Member
  • *****
  • Posts: 1800
    • https://github.com/nidud/asmc
Re: How to program GUI applications using MASM but without MASM-SDK?
« Reply #15 on: September 13, 2019, 09:11:24 PM »
It's possible to call a forward label but not invoke it. Invoke needs a prototype or proc declaration. This logic is the same for ML, ML64 and JWASM.

    call foo

foo proc a:ptr, b:byte
    ret
foo endp

So the prototype is still valid in ML64 and holds the same information as before except for the calling convention. In the sample above pascal is just the name of the first argument. This means the prototype must be equal to the proc declaration so this will fail:

foo proto :ptr

foo proc a:ptr, b:byte
    ret
foo endp
error A2111:conflicting parameter definition

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6768
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: How to program GUI applications using MASM but without MASM-SDK?
« Reply #16 on: September 13, 2019, 09:30:09 PM »
You can make local prototypes as they are matched against the "proc" line of a procedure but it does not work with external API function calls. I bothered to make a macro that manages the prototype from the TYPEDEF and got it to work (IE:not show an error) but the prototype done this way still does not work in terms of argument count. While this example below runs correctly, you can add a series of extra arguments which show up in the dis-assembly and no error is reported. It still runs but the extra arguments are ignored.

The only method I have got to work is with the commented out macro as the pre-processor checks the argument count.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include64\masm64rt.inc

  ; ************************************************

    PPROTO MACRO func_addr:REQ,arglist:VARARG
      LOCAL var
      .const
      var TYPEDEF PROTO arglist
      EXITM <equ <(TYPE QWORD PTR var) PTR func_addr>>
    ENDM

    msgbox PPROTO(__imp_MessageBoxA,:QWORD,:QWORD,:QWORD,:QWORD)

 ;     msgbox MACRO a1,a2,a3,a4
 ;       rcall __imp_MessageBoxA,a1,a2,a3,a4
 ;     ENDM

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    rcall msgbox,0,"Text Message","Title",MB_OK

    .exit

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end

 ; .text:0000000140001008 48C7C100000000             mov rcx, 0x0
 ; .text:000000014000100f 488B1557100000             mov rdx, qword ptr [0x14000206d]
 ; .text:0000000140001016 4C8B0569100000             mov r8, qword ptr [0x140002086]
 ; .text:000000014000101d 49C7C100000000             mov r9, 0x0
 ; .text:0000000140001024 FF15D2100000               call qword ptr [MessageBoxA]
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: