The MASM Forum

General => The Campus => Topic started by: Raistlin on January 10, 2018, 07:31:30 PM

Title: Invoke Intellisense issue
Post by: Raistlin on January 10, 2018, 07:31:30 PM
Hi all, a slight issue that needs solving please.

Step1) A TYPEDEF PROTO with pointer is created
ZLPFN_WSASENDMSG TYPEDEF PROTO s:DWORD,lpMsg:DWORD,dwFlags:DWORD,lpNumberOfBytesSent:DWORD,lpOverlapped:DWORD
PFUNC_WSASENDMSG TYPEDEF PTR ZLPFN_WSASENDMSG


Step2) A Data variable is assigned as pointer to the typedef
.data?
fnWSASendMsg PFUNC_WSASENDMSG ?


Step3) We should be able to Invoke the pointer once populated in code.
invoke fnWSASendMsg,.......

Unfortunately - in the editor, there'll be no intellisense during the INVOKE coding.
Is there a workaround, perhaps using ASSUME or something?

Thanks
Raistlin
Title: Re: Invoke Intellisense issue
Post by: jj2007 on January 10, 2018, 07:41:35 PM
Quote from: Raistlin on January 10, 2018, 07:31:30 PMin the editor, there'll be no intellisense during the INVOKE coding.

Which editor?
Title: Re: Invoke Intellisense issue
Post by: Raistlin on January 10, 2018, 07:43:39 PM
@JJ2007: oops - sorry = Both RADASM and EASYCode has currently the same behavior
Title: Re: Invoke Intellisense issue
Post by: aw27 on January 10, 2018, 08:16:03 PM
Quote from: Raistlin on January 10, 2018, 07:31:30 PM
Hi all, a slight issue that needs solving please.

Step1) A TYPEDEF PROTO with pointer is created
ZLPFN_WSASENDMSG TYPEDEF PROTO s:DWORD,lpMsg:DWORD,dwFlags:DWORD,lpNumberOfBytesSent:DWORD,lpOverlapped:DWORD
PFUNC_WSASENDMSG TYPEDEF PTR ZLPFN_WSASENDMSG


Step2) A Data variable is assigned as pointer to the typedef
.data?
fnWSASendMsg PFUNC_WSASENDMSG ?


Step3) We should be able to Invoke the pointer once populated in code.
invoke fnWSASendMsg,.......

Unfortunately - in the editor, there'll be no intellisense during the INVOKE coding.
Is there a workaround, perhaps using ASSUME or something?

Thanks
Raistlin

Something like this?

mov r10, fnWSASendMsg
assume r10 : PFUNC_WSASENDMSG
invoke r10, ....
Title: Re: Invoke Intellisense issue
Post by: Raistlin on January 10, 2018, 08:33:31 PM
@aw27 - Thanks, but unfortunately still nothing.. problem persists

It just seems strange that we have the PROTOs (code in first post), so why does the editor not cross reference,
it does so easily on everything else re: standard PROTO, STRUCT, winapi
Title: Re: Invoke Intellisense issue
Post by: jj2007 on January 10, 2018, 08:40:51 PM
Yes, but those hang around in a fixed set of include files that an editor can scan once in a while...
Title: Re: Invoke Intellisense issue
Post by: aw27 on January 10, 2018, 08:47:27 PM
I feel sorry. I don't use smart editors, only the dumb ones, namely notepad++.
Title: Re: Invoke Intellisense issue
Post by: Raistlin on January 10, 2018, 09:05:10 PM
hmmm - thanks guys - this sux - perhaps a means to alias the existing "known" API ?
Title: Re: Invoke Intellisense issue
Post by: hutch-- on January 10, 2018, 09:08:32 PM
Rudi,

There are a pair of macros in the 32 bit macro file, SPROTO and CPROTO that are designed for the task you have in mind.
Title: Re: Invoke Intellisense issue
Post by: Raistlin on January 10, 2018, 09:50:24 PM
@hutch : thanx, that's indeed a quicker way to create the TYPEDEF's and assign a variable  :t
              but still does'nt solve my editor problems. I've tested the invokes on pointer variable (per above code) and
              at least the assembler is doing the parameter checking. Just not showing up in the editors' Intellisense during coding.
Title: Re: Invoke Intellisense issue
Post by: HSE on January 10, 2018, 11:41:59 PM
I think there is no issue. Intellisense is not in the code.
You have to declare the procedure in some winxxx.api file (in EasyCode is ApiCalls.txt)
Title: Re: Invoke Intellisense issue
Post by: aw27 on January 11, 2018, 01:08:28 AM
If I am seeing well the movie, Raistlin wants to over the mouse on the invoke instruction and see where the call will be done. We have here a supplementary level of indirection and the smart editors may be choking at that.
An alternative will be to transform the indirect call in a direct call. For that we need a READ/WRITE/EXECUTE code segment and some old days flavour programming.


.386
.model flat, stdcall 
option casemap :none 

includelib \masm32\lib\msvcrt.lib
printf proto C :ptr, :vararg

_printf typedef proto C :ptr, :vararg
_pprintf TYPEDEF ptr _printf

_DATA SEGMENT PUBLIC 'DATA'
    msg db "This year is: %d",0Ah,0
_DATA ENDS

_BSS SEGMENT PARA PUBLIC 'BSS'
pprintf _pprintf ?
_BSS ends

_TEXT1 SEGMENT PARA PUBLIC READ WRITE EXECUTE 'CODE'

start:
mov eax, offset printf
mov pprintf, eax
; ...
push 2018
push offset msg
mov eax, pprintf
sub eax, offset _offlbl
mov _off, eax
db 0e8h
_off dd ?
_offlbl:
add esp, 8
ret
end start

_TEXT1 ends


Even with this I am not sure the smart editors will figure it out, they probably have things cached somewhere and will not update in real time.
Title: Re: Invoke Intellisense issue
Post by: Raistlin on January 11, 2018, 02:06:11 AM
WOW, that takes me back 25 years.
But yes, just "temporarily" editing the
editor API reference files seems to work OK.
Not ideal, but that's all we can do I guess.
Title: Re: Invoke Intellisense issue
Post by: HSE on January 11, 2018, 02:20:27 AM
Quote from: Raistlin on January 11, 2018, 02:06:11 AM
that's all we can do I guess.

      You can write a revolutionary editor!  :biggrin:
Title: Re: Invoke Intellisense issue
Post by: ragdog on January 11, 2018, 07:22:50 AM
QuoteYou can write a revolutionary editor!

Not easy look on Winasm since open source not any updateor Radasm too.
But i use Radasm and i think is the best asm editor.

Title: Re: Invoke Intellisense issue
Post by: HSE on January 11, 2018, 11:54:53 AM
Quote from: ragdog on January 11, 2018, 07:22:50 AM
But i use Radasm and i think is the best asm editor.
:t
It's a little unfinished and, unfortunally, the code is poorly documented.

The idea of Raistlin that Intellisense make sugerences from declarations in the code it's posible, but a lot of work in the editor and the includes :biggrin: .
Title: Re: Invoke Intellisense issue
Post by: rsala on January 12, 2018, 06:21:46 AM
Well that does not work in Easy Code. I am afraid it would be difficult to implement and the most important it would make the editor to work slowly. First it would have to check for the TYPEDEF key in the whole text and then check if the PROTO key is after TYPEDEF.
Title: Re: Invoke Intellisense issue
Post by: HSE on January 12, 2018, 11:12:10 AM
Yes, mostly a fantasy. And in the end, the result not much better that how Intellisense work now. :t