COM Interface

Just starting out? Need help? Post your questions and find answers here.
PureGuy
Enthusiast
Enthusiast
Posts: 102
Joined: Mon Aug 30, 2010 11:51 am

COM Interface

Post by PureGuy »

As noticed in my other topic: http://www.purebasic.fr/english/viewtop ... =5&t=59640
There is something weird with passing parameters to COM objects via interfaces.

Code: Select all

HRESULT AddToSnapshotSet(
  [in]   VSS_PWSZ pwszVolumeName,
  [in]   VSS_ID ProviderId,
  [out]  VSS_ID *pidSnapshot
);
How comes that C can call the method using 3 parameters and PB x86 has to use 4.

Code: Select all

AddToSnapshotSet(pwszVolumeName, ProviderId_Part1.q, ProviderId_Part2.q, *pidSnapshot)
Also interesting http://vortex.masmcode.com/files/vscopy101.zip

from \Windows7\Source\vscopy.asm

Code: Select all

coinvoke    pBackupComponent,IVssBackupComponents,AddToSnapshotSet,\
                buffer,0,0,0,0,pSnapShotId
                
from \Windows7\Source\vscopy.inc

Code: Select all

MACRO coinvoke

MARG ppv :REQ,interface :REQ,member :REQ,params :VARARG

    FOR arg IN: params REV DO
    
        push arg

    ENDM

    mov     eax,[ppv]
    push    eax
    mov     eax,DWORD PTR [eax]
    call    [eax+&interface.&member]
    
ENDM
So how to know, how to pass parameters using PB x86?
And why does it works as expected for PB x64?
Fred
Administrator
Administrator
Posts: 16686
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: COM Interface

Post by Fred »

Well, VSS_ID is a GUID (enhance a 128-bit number) and PB doesn't support this natively. You can define it as you did for x86 (with double quad). On x64, it's just by ref for anything above 64 bit IIRC
PureGuy
Enthusiast
Enthusiast
Posts: 102
Joined: Mon Aug 30, 2010 11:51 am

Re: COM Interface

Post by PureGuy »

Thanks for the fast answer.

Yes, it seems using 2 quad is working :D
Post Reply