News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

ML64 use of PROTO, the plot thickens.

Started by hutch--, July 21, 2016, 09:23:49 AM

Previous topic - Next topic

hutch--

It would appear that ML64 still uses the PROTO notation, even if it does not need it but if you declare a prototype, it will compare the procedure declaration to the prototype and show an error if they do not match.

With this PROTO,

    WndProc PROTO :QWORD,:QWORD,:QWORD,:QWORD       ;; ,:QWORD

and this procedure declaration,

WndProc proc hWin:QWORD,uMsg:QWORD,wParam:QWORD,lParam:QWORD

If you uncomment the last extra argument in the prototype you get a form of error checking,

window8.asm(135) : error A2111:conflicting parameter definition



jj2007

Hutch,

The error checking of invoke is relevant for this type of case:

invoke CreateFile, esi, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0, 0


And for nothing else. I guess we can safely assume that everybody can write their own proc with named parameters like hWnd and the like. If then somebody is thick enough to add a fifth parameter to the PROTO list, he should really go for Scratch or Logo 8)

Btw Microsoft's CrippleWare AssemblerTM can be convinced to count the paras. I am currently a bit stuck with the PROLOGUE bug, but with ML64 jinvoke works like a charm :icon_mrgreen:

LiaoMi

Hallo,

What is the difference between the lines?

hWin:QWORD and  :QWORD

I have noticed that with the extended configuration hWin:QWORD, my program always caused an exception and the parameters passed to the C ++ dll were probably incorrect.

hutch--

 :biggrin:

> Btw Microsoft's CrippleWare AssemblerTM can be convinced to count the paras

Such are the slings and arrows of outrageous fortune when you actually cannot rely on anyone holding you hot little hand and have to write low level assembler.  :P

hutch--

Hi LiaoMi

Quote
What is the difference between the lines?
hWin:QWORD and :QWORD

Effectively nothing. Its just a notation redundancy.

> I have noticed that with the extended configuration hWin:QWORD, my program always caused an exception and the parameters passed to the C ++ dll were probably incorrect.

I am guessing but you will need to write a extern C prototype for the external module. You may also have to add stack space and copy the 4 registers into the 4 variables. This is what I have been using.

    mov QWORD PTR [rbp+10h], rcx
    mov QWORD PTR [rbp+18h], rdx
    mov QWORD PTR [rbp+20h], r8
    mov QWORD PTR [rbp+28h], r9

jj2007

Quote from: hutch-- on July 22, 2016, 12:00:01 AMyou actually cannot rely on anyone holding you hot little hand and have to write low level assembler.  :P

No problem, my friend, I just wanted to help the OP ;)

Quote from: hutch-- on July 21, 2016, 09:23:49 AMyou get a form of error checking