flat assembler
Message board for the users of flat assembler.

Index > Windows > Type library and FASM

Author
Thread Post new topic Reply to topic
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek
Dear all,

I'm trying to make use of one COM object, but have no clue how to do it right.

I have a type library, which works ok (tested it using C#). I'm trying to invoke different methods but they doesn't seem to work.

CoCreateInstance works ok:
Code:
section '.code' code readable executable

start:
       invoke  CoInitialize,NULL
   cmp     eax,S_OK
    jne     error
       invoke  CoCreateInstance,CLSID_SiebelDataBusObjInterface,NULL,CLSCTX_INPROC_SERVER,IID_SiebelApplication,sApp ;initializing interface
       cmp     eax,S_OK
    jne     error
       cmp     [sApp],0
    jz      error
;...
section '.data' data readable writeable

CLSID_SiebelDataBusObjInterface GUID 6AD52085-E86F-11CF-A52E-00C04FD20274
IID_SiebelApplication GUID 6AD52084-E86F-11CF-A52E-00C04FD20274

sApp      SiebelApplication

    


But then, when I'm trying to cominvk different methods, I'm receiving unexpected results. here's the definition I made manually from the typelib:
Code:
interface SiebelApplication,\
  LoadObjects,\
      Login,\
    GetBusObject,\
     GetLastErrText,\
   LoginId,\
  LoginName,\
        PositionId,\
       PositionName,\
     CurrencyCode,\
     GetSharedGlobal,\
  SetSharedGlobal,\
  TraceOn,\
  TraceOff,\
 InvokeMethod,\
     Trace,\
    GetService,\
       NewPropertySet,\
   GetProfileAttr,\
   SetProfileAttr,\
   SetPositionId,\
    SetPositionName
    


I'm thinking that there's something I'm doing the way it shouldn't be done. Any advice would be appreciated.

Here's the typelib:

Code:

// Generated .IDL file (by the OLE/COM Object Viewer)
// 
// typelib filename: sobjsrv.tlb

[
  uuid(6AD52081-E86F-11CF-A52E-00C04FD20274),
  version(1.0),
  helpstring("Siebel Data BusObject Interfaces"),
  custom(DE77BA64-517C-11D1-A2DA-0000F8773CE9, 100663657),
  custom(DE77BA63-517C-11D1-A2DA-0000F8773CE9, 1213811687),
  custom(DE77BA65-517C-11D1-A2DA-0000F8773CE9, "Created by MIDL version 6.00.0361 at Wed Jun 18 11:54:42 2008
")

]
library SiebelDataServer
{
    // TLib :     // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
    importlib("stdole2.tlb");

    // Forward declare all types defined in this typelib
    dispinterface SiebelApplication;
    dispinterface SiebelBusObject;
    dispinterface SiebelBusComp;
    dispinterface SiebelService;
    dispinterface SiebelPropertySet;

    [
      uuid(6AD52084-E86F-11CF-A52E-00C04FD20274)
    ]
    dispinterface SiebelApplication {
        properties:
        methods:
            [id(0x00000001)]
            void LoadObjects(
                            BSTR Configuration, 
                            short* errCode);
            [id(0x00000002)]
            void Login(
                            BSTR UserName, 
                            BSTR Password, 
                            short* errCode);
            [id(0x00000003)]
            IDispatch* GetBusObject(
                            BSTR BusObjectName, 
                            short* errCode);
            [id(0x00000004)]
            BSTR GetLastErrText();
            [id(0x00000005)]
            BSTR LoginId(short* errCode);
            [id(0x00000006)]
            BSTR LoginName(short* errCode);
            [id(0x00000007)]
            BSTR PositionId(short* errCode);
            [id(0x00000008)]
            BSTR PositionName(short* errCode);
            [id(0x00000009)]
            BSTR CurrencyCode(short* errCode);
            [id(0x0000000a)]
            BSTR GetSharedGlobal(
                            BSTR varName, 
                            short* errCode);
            [id(0x0000000b)]
            void SetSharedGlobal(
                            BSTR varName, 
                            BSTR value, 
                            short* errCode);
            [id(0x0000000c)]
            void TraceOn(
                            BSTR FileName, 
                            BSTR Category, 
                            BSTR Source, 
                            short* errCode);
            [id(0x0000000d)]
            void TraceOff(short* errCode);
            [id(0x0000000e)]
            BSTR InvokeMethod(
                            BSTR methodName, 
                            VARIANT* methodArgs, 
                            short* errCode);
            [id(0x0000000f)]
            void Trace(
                            BSTR Message, 
                            short* errCode);
            [id(0x00000010)]
            IDispatch* GetService(
                            BSTR ServiceName, 
                            short* errCode);
            [id(0x00000011)]
            IDispatch* NewPropertySet(short* errCode);
            [id(0x00000012)]
            BSTR GetProfileAttr(
                            BSTR name, 
                            short* errCode);
            [id(0x00000013)]
            void SetProfileAttr(
                            BSTR name, 
                            BSTR value, 
                            short* errCode);
            [id(0x00000014)]
            void SetPositionId(
                            BSTR value, 
                            short* errCode);
            [id(0x00000015)]
            void SetPositionName(
                            BSTR value, 
                            short* errCode);
    };

    [
      uuid(6AD52086-E86F-11CF-A52E-00C04FD20274)
    ]
    dispinterface SiebelBusObject {
        properties:
        methods:
            [id(0x00000001)]
            IDispatch* GetBusComp(
                            BSTR BusCompName, 
                            short* errCode);
            [id(0x00000002)]
            BSTR name(short* errCode);
    };

    [
      uuid(6AD52089-E86F-11CF-A52E-00C04FD20274)
    ]
    dispinterface SiebelBusComp {
        properties:
        methods:
            [id(0x00000001)]
            void SetSortSpec(
                            BSTR SortSpec, 
                            short* errCode);
            [id(0x00000002)]
            void ExecuteQuery(
                            VARIANT_BOOL cursorMode, 
                            short* errCode);
            [id(0x00000003)]
            VARIANT_BOOL FirstRecord(short* errCode);
            [id(0x00000004)]
            VARIANT_BOOL NextRecord(short* errCode);
            [id(0x00000005)]
            BSTR GetFieldValue(
                            BSTR FieldName, 
                            short* errCode);
            [id(0x00000006)]
            void SetFieldValue(
                            BSTR FieldName, 
                            BSTR FieldValue, 
                            short* errCode);
            [id(0x00000007)]
            void WriteRecord(short* errCode);
            [id(0x00000008)]
            VARIANT_BOOL LastRecord(short* errCode);
            [id(0x00000009)]
            VARIANT_BOOL PreviousRecord(short* errCode);
            [id(0x0000000a)]
            void SetSearchSpec(
                            BSTR FieldName, 
                            BSTR SearchSpec, 
                            short* errCode);
            [id(0x0000000b)]
            void NewRecord(
                            short where, 
                            short* errCode);
            [id(0x0000000c)]
            void DeleteRecord(short* errCode);
            [id(0x0000000d)]
            BSTR name(short* errCode);
            [id(0x0000000e)]
            void ClearToQuery(short* errCode);
            [id(0x0000000f)]
            void RefineQuery(short* errCode);
            [id(0x00000010)]
            IDispatch* GetMVGBusComp(
                            BSTR FieldName, 
                            short* errCode);
            [id(0x00000011)]
            IDispatch* GetAssocBusComp(short* errCode);
            [id(0x00000012)]
            IDispatch* ParentBusComp(short* errCode);
            [id(0x00000013)]
            void DeactivateFields(short* errCode);
            [id(0x00000014)]
            void ActivateField(
                            BSTR FieldName, 
                            short* errCode);
            [id(0x00000015)]
            IDispatch* GetPicklistBusComp(
                            BSTR FieldName, 
                            short* errCode);
            [id(0x00000016)]
            short GetViewMode(short* errCode);
            [id(0x00000017)]
            void SetViewMode(
                            short mode, 
                            short* errCode);
            [id(0x00000018)]
            void Pick(short* errCode);
            [id(0x00000019)]
            void Associate(
                            short where, 
                            short* errCode);
            [id(0x0000001a)]
            void SetUserProperty(
                            BSTR Property, 
                            BSTR value, 
                            short* errCode);
            [id(0x0000001b)]
            BSTR GetUserProperty(
                            BSTR Property, 
                            short* errCode);
            [id(0x0000001c), hidden]
            BSTR InvokeMethod(
                            BSTR methodName, 
                            VARIANT* methodArgs, 
                            short* errCode);
            [id(0x0000001d)]
            void ExecuteQuery2(
                            VARIANT_BOOL cursorMode, 
                            VARIANT_BOOL ignoreMaxCursorSize, 
                            short* errCode);
            [id(0x0000001e)]
            BSTR GetFormattedFieldValue(
                            BSTR FieldName, 
                            short* errCode);
            [id(0x0000001f)]
            void SetFormattedFieldValue(
                            BSTR FieldName, 
                            BSTR FieldValue, 
                            short* errCode);
            [id(0x00000020)]
            BSTR GetNamedSearch(
                            BSTR searchName, 
                            short* errCode);
            [id(0x00000021)]
            void SetNamedSearch(
                            BSTR searchName, 
                            BSTR searchText, 
                            short* errCode);
            [id(0x00000022)]
            BSTR GetSearchSpec(
                            BSTR FieldName, 
                            short* errCode);
            [id(0x00000023)]
            BSTR GetSearchExpr(short* errCode);
            [id(0x00000024)]
            void SetSearchExpr(
                            BSTR searchText, 
                            short* errCode);
            [id(0x00000025)]
            void UndoRecord(short* errCode);
            [id(0x00000026)]
            IDispatch* BusObject(short* errCode);
            [id(0x00000027)]
            void ActivateMultipleFields(
                            IDispatch* fields, 
                            short* errCode);
            [id(0x00000028)]
            void GetMultipleFieldValues(
                            IDispatch* fields, 
                            IDispatch* values, 
                            short* errCode);
            [id(0x00000029)]
            void SetMultipleFieldValues(
                            IDispatch* values, 
                            short* errCode);
            [id(0x0000002a)]
            BSTR GetSortSpec(short* errCode);
    };

    [
      uuid(A98767CF-3D31-4305-98A0-A9E3615ED2F6)
    ]
    dispinterface SiebelService {
        properties:
        methods:
            [id(0x00000001)]
            BSTR name(short* errCode);
            [id(0x00000002)]
            BSTR GetProperty(
                            BSTR propName, 
                            short* errCode);
            [id(0x00000003)]
            void SetProperty(
                            BSTR propName, 
                            BSTR propValue, 
                            short* errCode);
            [id(0x00000004)]
            VARIANT_BOOL PropertyExists(
                            BSTR propName, 
                            short* errCode);
            [id(0x00000005)]
            void RemoveProperty(
                            BSTR propName, 
                            short* errCode);
            [id(0x00000006)]
            BSTR GetFirstProperty(short* errCode);
            [id(0x00000007)]
            BSTR GetNextProperty(short* errCode);
            [id(0x00000008)]
            void InvokeMethod(
                            BSTR method, 
                            IDispatch* inputs, 
                            IDispatch* outputs, 
                            short* errCode);
    };

    [
      uuid(0E991004-564A-439E-93A0-DDBD88D89642)
    ]
    dispinterface SiebelPropertySet {
        properties:
        methods:
            [id(0x00000001)]
            BSTR GetType(short* errCode);
            [id(0x00000002)]
            void SetType(
                            BSTR type, 
                            short* errCode);
            [id(0x00000003)]
            BSTR GetValue(short* errCode);
            [id(0x00000004)]
            void SetValue(
                            BSTR value, 
                            short* errCode);
            [id(0x00000005)]
            BSTR GetProperty(
                            BSTR propName, 
                            short* errCode);
            [id(0x00000006)]
            void SetProperty(
                            BSTR propName, 
                            BSTR propValue, 
                            short* errCode);
            [id(0x00000007)]
            VARIANT_BOOL PropertyExists(
                            BSTR propName, 
                            short* errCode);
            [id(0x00000008)]
            void RemoveProperty(
                            BSTR propName, 
                            short* errCode);
            [id(0x00000009)]
            BSTR GetFirstProperty(short* errCode);
            [id(0x0000000a)]
            BSTR GetNextProperty(short* errCode);
            [id(0x0000000b)]
            int AddChild(
                            IDispatch* child, 
                            short* errCode);
            [id(0x0000000c)]
            IDispatch* GetChild(
                            int index, 
                            short* errCode);
            [id(0x0000000d)]
            int GetChildCount(short* errCode);
            [id(0x0000000e)]
            void InsertChildAt(
                            IDispatch* child, 
                            int index, 
                            short* errCode);
            [id(0x0000000f)]
            void RemoveChild(
                            int index, 
                            short* errCode);
            [id(0x00000010)]
            IDispatch* Copy(short* errCode);
            [id(0x00000011)]
            void Reset(short* errCode);
            [id(0x00000012)]
            int GetPropertyCount(short* errCode);
    };

    typedef [public]
    __MIDL___MIDL_itf_sobjsrv_0000_0001 SiebelQueryConstants;

    typedef enum {
        ForwardBackward = 0,
        ForwardOnly = 1
    } __MIDL___MIDL_itf_sobjsrv_0000_0001;

    typedef [public]
    __MIDL___MIDL_itf_sobjsrv_0000_0002 SiebelNewRecordConstants;

    typedef enum {
        NewBefore = 0,
        NewAfter = 1,
        NewBeforeCopy = 2,
        NewAfterCopy = 3
    } __MIDL___MIDL_itf_sobjsrv_0000_0002;

    typedef [public]
    __MIDL___MIDL_itf_sobjsrv_0000_0003 SiebelViewModeConstants;

    typedef enum {
        SalesRepView = 0,
        ManagerView = 1,
        PersonalView = 2,
        AllView = 3,
        NoneSetView = 4,
        OrgView = 5,
        ContactView = 6,
        SubOrgView = 7,
        GroupView = 8,
        CatalogView = 9
    } __MIDL___MIDL_itf_sobjsrv_0000_0003;

    typedef [public]
    __MIDL___MIDL_itf_sobjsrv_0000_0004 SiebelEnumErrCode;

    typedef enum {
        SSGenErrInternal = 4096,
        SSELErrAppletNotActive = 4097,
        SSELErrAppletHasNoBusComp = 4098,
        SSELErrBadNewWhere = 4099,
        SSELErrBadViewModeNum = 4100,
        SSELErrControlNotInApplet = 4101,
        SSELErrGotoViewActiveBusObj = 4102,
        SSELErrInactiveApplet = 4103,
        SSELErrMethodNotSupported = 4104,
        SSELErrNoAppletName = 4105,
        SSELErrNoControlName = 4106,
        SSELErrNoVariableName = 4107,
        SSELErrNoViewName = 4108,
        SSELErrNotAssocList = 4109,
        SSELErrOutOfScope = 4110,
        SSELErrUnknownApplet = 4111,
        SSELErrUnknownControl = 4112,
        SSELErrUnknownView = 4113,
        SSOleErrOleDisabled = 4114,
        SSOleErrInternal = 4115,
        SSOleErrMemory = 4116,
        SSOleErrMissingAppletArg = 4117,
        SSOleErrMissingControlArg = 4118,
        SSOleErrMissingStringArg = 4119,
        SSOleErrMissingOrInvalidConfigFile = 4120,
        SSOleErrStringArrayExpected = 4121,
        SSOleErrUnableToLogin = 4122,
        SSOMErrActRowChanged = 4123,
        SSOMErrActiveRow = 4124,
        SSOMErrAddAssoc = 4125,
        SSOMErrAssocCurRow = 4126,
        SSOMErrAssocList = 4127,
        SSOMErrBOBusComp = 4128,
        SSOMErrBOQuerySyntax = 4129,
        SSOMErrBoundedPick = 4130,
        SSOMErrBusObjProp = 4131,
        SSOMErrConstrBusComp = 4132,
        SSOMErrContextSyntax = 4133,
        SSOMErrDeleteRecord = 4134,
        SSOMErrEOWS = 4135,
        SSOMErrEmptyMVGParent = 4136,
        SSOMErrEnd = 4137,
        SSOMErrExec = 4138,
        SSOMErrGetBusComp = 4139,
        SSOMErrGetContext = 4140,
        SSOMErrGetMVGroup = 4141,
        SSOMErrGetQuerySpec = 4142,
        SSOMErrGotoBookmark = 4143,
        SSOMErrHome = 4144,
        SSOMErrInvalidLogin = 4145,
        SSOMErrMVGCopyRec = 4146,
        SSOMErrMVGQuery = 4147,
        SSOMErrMVSrcInactive = 4148,
        SSOMErrNewRecIdValue = 4149,
        SSOMErrNewRecord = 4150,
        SSOMErrNextRecord = 4151,
        SSOMErrNextSet = 4152,
        SSOMErrNoAssocList = 4153,
        SSOMErrNoAssocMVGAllowed = 4154,
        SSOMErrNoDelete = 4155,
        SSOMErrNoInsert = 4156,
        SSOMErrParentBCRequired = 4157,
        SSOMErrParentMVGEmpty = 4158,
        SSOMErrPickCurRow = 4159,
        SSOMErrPopupRequired = 4160,
        SSOMErrPriorRecord = 4161,
        SSOMErrPriorSet = 4162,
        SSOMErrScrollWorkSet = 4163,
        SSOMErrSearchNotSupp = 4164,
        SSOMErrSetActiveRow = 4165,
        SSOMErrSetContext = 4166,
        SSOMErrSetFieldValue = 4167,
        SSOMErrSetMVGPrimaryId = 4168,
        SSOMErrSortNotSupp = 4169,
        SSOMErrUpdRecord = 4170,
        SSOMErrUserAbort = 4171,
        SSSqlErrAssocObj = 4172,
        SSSqlErrBOF = 4173,
        SSSqlErrDupConflict = 4174,
        SSSqlErrDupConflict2 = 4175,
        SSSqlErrEOF = 4176,
        SSSqlErrEndNoSort = 4177,
        SSSqlErrEndTrx = 4178,
        SSSqlErrEvalFieldExpr = 4179,
        SSSqlErrFieldExist = 4180,
        SSSqlErrFieldNoQBE = 4181,
        SSSqlErrFieldReadOnly = 4182,
        SSSqlErrFieldSearch = 4183,
        SSSqlErrLogon = 4184,
        SSSqlErrRecordDeleted = 4185,
        SSSqlErrReqField = 4186,
        SSSqlErrRsltsDiscarded = 4187,
        SSELErrBadAssocWhere = 4188,
        SSELErrBadDrilldownName = 4189,
        SSCorbaErrCorbaDisabled = 4190,
        SSCorbaErrInternal = 4191,
        SSCorbaErrMemory = 4192,
        SSCorbaErrMissingAppletArg = 4193,
        SSCorbaErrMissingControlArg = 4194,
        SSCorbaErrMissingStringArg = 4195,
        SSCorbaErrMissingOrInvalidConfigFile = 4196,
        SSCorbaErrStringArrayExpected = 4197,
        SSCorbaErrUnableToLogin = 4198,
        SSELErrBusCompNameRequired = 4199,
        SSELErrCannotCreateService = 4200,
        SSELErrMethodNameRequired = 4201,
        SSELErrServiceNameRequired = 4202,
        SSELErrUserDefinedError = 4203
    } __MIDL___MIDL_itf_sobjsrv_0000_0004;
};
    
Post 25 Jul 2012, 10:17
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
What does the documentation say. Or how are the interface's functions defined. Usually most of them inherit from the IUnknown object and therefore must begin with the latter's functions. I.e. AddRef etc
Post 25 Jul 2012, 13:23
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode
this paper for COM client/server
http://www.codeproject.com/Articles/901/Introduction-to-COM-Part-II-Behind-the-Scenes-of-a#_comments
every standard COM interface must implement IUnkown. now
the Siebel complex object has one IUnknown for every disp-interface too (not reported by MIDL). you pick them by their UUID
also, because of nesting it, with fasm an easy way would be by struc. the iUnknown
Code:
 virtual at 0
 struc iUnknown {
  .QueryInterface dq ?
  .AddRef dq ?
  .Release dq ?
 } iUnknown iUnknown
  sizeof.iUnknown = $-iUnknown
  end virtual     
then, example nesting,
Code:
 virtual at 0
 struc iClassFactory {
  .iUnknown iUnknown
  .CreateInstance dq ?
  .LockServer     dq ?
 } iClassFactory\
   iClassFactory
   end virtual
   sizeof.iClassFactory\
   = $-iClassFactory     

then a complex object
Code:
 virtual at 0
 struc iComplex {
  .iUnknown iUnknown
  .iClassFactory iClassFactory
  .pepsi dq ?
  .alpha dq ?
  } iComplex\
    iComplex
  end virtual
  sizeof.iComplex\
  = $-iComplex    
and that allows you this code
Code:
 myStaticCF iClassFactory    ;--- static 
 theComplex iComplex ;--- static
;--- data
 call [myStaticCF.iUnknown.AddRef] ;--- code call issue
 call [myStaticCF.LockServer] ;--- code call issue
;--- and
 call [theComplex.iClassFactory.iUnknown.AddRef]     

Cheers,

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 25 Jul 2012, 15:01
View user's profile Send private message Visit poster's website Reply with quote
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek
Thanks for the replies!

typedef, Siebel programming documentation is targeted on VB, eScript and MFC (a little), and there you do everything by checking checkboxes, running wizards etc. and such stuff. They don't describe the interface and do not enum methods in it, unfortunately.

hopcode, thank you, Marc! It'll take time for me to analyse this information
Post 25 Jul 2012, 19:10
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 YouTube, Twitter.

Website powered by rwasa.