flat assembler
Message board for the users of flat assembler.

Index > Windows > Down to One Line of Code

Author
Thread Post new topic Reply to topic
iic2



Joined: 26 Jun 2008
Posts: 123
iic2
I'm having trouble with this one line of code. I think I got everything else translated to FASM correctly. It all based on FASM usecom example and need to be comcall or cominvk macro. I think comcall but not sure how to translate it.

CoInvoke(psl,IShellLink.IUnknown.QueryInterface, offset IID_IPersistFile, offset ppf)
Post 12 Aug 2008, 23:46
View user's profile Send private message Reply with quote
iic2



Joined: 26 Jun 2008
Posts: 123
iic2
Well, I guest most FASM people are Drivers and OS coders, much deep about the system itself. Seem no one knows or even care about COM or standard Windows coding. Only two real related threads to be founded from day 1. Thanks anyway everybody.
Post 13 Aug 2008, 03:30
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel
Code:
cominvk psl,QueryInterface,IID_IPersistFile,ppf    
Post 13 Aug 2008, 06:50
View user's profile Send private message Reply with quote
iic2



Joined: 26 Jun 2008
Posts: 123
iic2
Quote:
cominvk psl,QueryInterface,IID_IPersistFile,ppf

I must have a lot to learn... what about the IShellLink part ???

I'm not doubting you ManOfSteel it took me forever to figure out what the Fasm manual was saying. It seems there are three parameters and I thought I had to call them all separately like in the USECOM ...

comcall psl,IShellLink.IUnknown.QueryInterface,\
IID_IPersistFile, [pff]

mov ebx,[psl]
comcall ebx,IShellLink,IUnknown,[pff]
comcall ebx,IShellLink,QueryInterface,[pff]
comcall ebx,IShellLink,IID_IPersistFile,[pff]

;;;;;;;;;;
Example 2:

lea eax, ssIShellLink
push eax
lea eax, IID_IPersistFile
push eax
push [ssIShellLink]
mov edi,[ssIShellLink]
mov edi,[edi]
xxx call [edi+IShellLink.IUnknown.QueryInterface]

would be:
comcall edi,IShellLink,IUnknown
comcall edi,IShellLink,QueryInterface


Is what I been during here all day is ALL wrong. If so, are you sure your combination is correct. If true, I will be on it from this point.

Again, Thanks ManOfSteel ... COM and macros are a trip. I never tried neither until now. comcall is has made it more than interesting to me anyway.
Post 13 Aug 2008, 08:56
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel
Define CLSIDs and other IDs with the GUID macro.


Define your interfaces with the interface macro:
Code:
interface IShellLink,\
             QueryInterface,\
             AddRef,\
             Release,\
             GetPath,\
             ...
    



Define 'pointers' to your interfaces (and methods):
Code:
psl IShellLink
ppf IPersistFile
...
    



Get a pointer to the interface you'll be using (with CoCreateInstance for example):
Code:
invoke CoCreateInstance,CLSID_ShellLink,0,CLSCTX_INPROC_SERVER,IID_IShellLink,psl    

This will fill the psl pointer from above.


Now, you can use any method defined in the interface. For example, the following would query IShellLink for the IPersistFile interface and return a pointer in ppf:
Code:
cominvk psl,QueryInterface,IID_IPersistFile,ppf    
Post 13 Aug 2008, 11:50
View user's profile Send private message Reply with quote
iic2



Joined: 26 Jun 2008
Posts: 123
iic2
I'll say Thanks right now because this should be my final posting to this thread about translating COM to FASM. I think i understand the bulk of it now. .. Ok, when translating:
Code:
coInvoke psl,IshellLink.IUknown.QueryInterface,
IID_IPersistFile, [ppf]    

We strip the extra variable (or) pointer [IshellLink.] because we have a pointer to it already [psl] to CALL the interface. We strip [IUknown] because it's under our Interface and is not a separate structure like under MASM. Than we call it with cominvk like so:
Code:
cominvk psl,QueryInterface,IID_IPersistFile, [ppf]    

...............................
...............................
But when I do the same thing to code below, things are difference;

ShellTaskBar ItaskBarList

usecome original

mov ebx,[ShellTaskBar]
comcall ebx,ITaskBarList,HrInit
comcall ebx,ITaskBarList,AddTab,[hwnd]
comcall ebx,ITaskBarList,ActivateTab,[hwnd]
......................
From ½ from your Idea:
This Work no striping:

comcall ShellTaskBar,ITaskBarList,HrInit
comcall ShellTaskBar,ITaskBarList,AddTab,[hwnd]
comcall ShellTaskBar,ITaskBarList,ActivateTab,[hwnd]
......................
This Don't Work:
stripped:
mov ebx,[ShellTaskBar]
comcall ebx,HrInit
comcall ebx,AddTab,[hwnd]
comcall ebx,ActivateTab,[hwnd]
......................
This Don't Work:
stripped:
mov ebx,[ShellTaskBar]
cominvk ebx,HrInit
cominvk ebx,AddTab,[hwnd]
cominvk ebx,ActivateTab,[hwnd]
......................
......................
ShellTaskBar is ItaskBarList pointer to the interface ItaskBarList just as in your workable sample.

What's going on here ?

Do not using CLSID has anything to do with it ?


Final Question:
Code Like:

CALL [edi+IShellLink.IUnknown.QueryInterface]

should be:
comcall edi,IShellLink.QueryInterface
or
cominvk edi,IShellLink.QueryInterface
or
CALL edi,IShellLink.QueryInterface

..............................................
If this is correct. What would be some of the others ways to do it. Could you include any possible manually coding only if you have the time.

Have a great day everybody


Special Thanks to ManOfSteel


Sorry for double post. I was here post went over there. Must be a bug or I slip this time ... Not sure.
Post 13 Aug 2008, 20:59
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.