How do I call functions from this COM-dll when I know this?

Started by port513, June 02, 2006, 06:27:47 AM

Previous topic - Next topic

port513

I know this about a COM-DLL but how do I access this DLL?

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

[
  uuid(DDAD57DB-762A-4E14-A288-9A84FF9721BB),
  version(2.0),
  helpstring("GiroComSvr 2.0 Type Library")
]
library GIROCOMSVRLib
{
    // TLib :     // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
    importlib("stdole2.tlb");

    // Forward declare all types defined in this typelib
    interface IGiroCom;
    interface IGiroComApi;

    [
      uuid(A6C37E4C-411B-4195-87F2-6AA9958DB726),
      helpstring("GiroCom Class")
    ]
    coclass GiroCom {
        [default] interface IGiroCom;
    };

    [
      odl,
      uuid(6D566F61-9659-4208-B378-519112C45C01),
      helpstring("IGiroCom Interface"),
      dual,
      oleautomation
    ]
    interface IGiroCom : IDispatch {
        [id(0x00000001), helpstring("method Init")]
        HRESULT Init(
                        [in] long* oemkey,
                        [in] BSTR registryPath);
        [id(0x00000002), helpstring("method BgSettings")]
        HRESULT BgSettings();
        [id(0x00000003), helpstring("method BgSendFile")]
        HRESULT BgSendFile(
                        [in] BSTR filename,
                        [in] long* transmissionType);
        [id(0x00000004), helpstring("method BgFetchFiles")]
        HRESULT BgFetchFiles(
                        [in] BSTR directory,
                        [in] long* transmissionType,
                        [in] BSTR routine);
        [id(0x00000005), helpstring("method PgSettings")]
        HRESULT PgSettings();
        [id(0x00000006), helpstring("method PgSendFile")]
        HRESULT PgSendFile(
                        [in] BSTR filename,
                        [in] long* transmissionType);
        [id(0x00000007), helpstring("method PgFetchFiles")]
        HRESULT PgFetchFiles(
                        [in] BSTR directory,
                        [in] BSTR routine,
                        [in] VARIANT_BOOL refetch);
        [id(0x00000008), propget, helpstring("property PassedPointOfNoReturn")]
        HRESULT PassedPointOfNoReturn([out, retval] VARIANT_BOOL* pVal);
    };

    [
      uuid(EE5C70FC-0288-453C-A555-63BF203F6044),
      helpstring("GiroComApi Class")
    ]
    coclass GiroComApi {
        [default] interface IGiroComApi;
    };

    [
      odl,
      uuid(FEB2F668-A24C-4DC4-8726-87B71C8C2111),
      helpstring("IGiroComApi Interface"),
      dual,
      oleautomation
    ]
    interface IGiroComApi : IDispatch {
        [id(0x00000001), helpstring("method Init")]
        HRESULT Init(
                        [in] long* oemkey,
                        [in] BSTR registryPath);
        [id(0x00000002), helpstring("method BgSettings")]
        HRESULT BgSettings();
        [id(0x00000003), helpstring("method BgSendFile")]
        HRESULT BgSendFile(
                        [in] BSTR filename,
                        [in] long* transmissionType);
        [id(0x00000004), helpstring("method BgFetchFiles")]
        HRESULT BgFetchFiles(
                        [in] BSTR directory,
                        [in] BSTR routine);
        [id(0x00000005), helpstring("method PgSettings")]
        HRESULT PgSettings();
        [id(0x00000006), helpstring("method PgSendFile")]
        HRESULT PgSendFile(
                        [in] BSTR filename,
                        [in] long* transmissionType);
        [id(0x00000007), propget, helpstring("property IncompleteTransfer")]
        HRESULT IncompleteTransfer([out, retval] VARIANT_BOOL* pVal);
    };
};

If someone could point me in the right direction it would help pretty much ;)

/Henke

P1

Is this about some kind of bicycle software?  Would we helping you to violate a EULA?

Regards,  P1  :8)

port513

Quote from: P1 on June 02, 2006, 03:24:00 PM
Is this about some kind of bicycle software?  Would we helping you to violate a EULA?

Regards,  P1  :8)

No ;) My company owns this code, I just wanted to call it from a low level language ;)

So it's ok to help me call this module, and you can't call this module wihtout a OEMcode so it's pretty safe to help me here ;)

/Henke

Biterider

hi port513
If you know all details of the interface, then you have several ways to call the code. If you are using an inprocess server then you can take a look at the Demo16 of the ObjAsm32 package.
If you have troubles understanding the code, feel free to ask.

Regards,

Biterider

akane

It's very easy :)
You can first register this server to access it by CoCreateInstance, or :
1. load it with LoadLibrary and get pointer to DllGetClassObject (GetProcAddress)
2. call DllGetClassObject, now you have the base inprocserver object - IClassFactory
3. call method IClassFactory::CreateInstance with an IID you will use
or
call CoGetClassObject and go to 3. (dll must be registered)

Where do I find the CLSID and IID ?
study the typelib, and you find two clsid's: CLSID_GiroComApi and CLSID_GiroCom.

this is the CLSID_GiroCom guid:
    [      uuid(A6C37E4C-411B-4195-87F2-6AA9958DB726)]
    coclass GiroCom {
        [default] interface IGiroCom;
    };


from this class you can request atleast IGiroCom interface.

Study the IGiroCom interface:
    [
      uuid(6D566F61-9659-4208-B378-519112C45C01),
      dual
    ]
    interface IGiroCom : IDispatch {

uuid is your IID_IGiroCom, dual - methods are accesible directly and by IDispatch::Invoke automation

Now if you want to call methods directly - create interface declaration.
It derieves from IDispatch, so the Init method is at 8th (one based index) position in virtual table.

a small note:[default] interface IGiroCom
if you request object IUnknown from this class, it will be IUnknown of IGiroCom interface, and probably you can call all IGiroCom methods (do not risk), well, who creates a separate IUnknown object ? :bg

You must know how to use COM and how to convert C code

port513

So I will use CoCreateInstance and CoGetClassObject

But how? ;)

As I said before, I'm new to MASM ;)


/Henke

P1

Quote from: port513 on June 04, 2006, 07:21:59 AMNo ;) My company owns this code, I just wanted to call it from a low level language ;)
It struck me as a little strange, to produce the idl file with oleview.  When it's produced normally from the dll's creation. 

So you may work for the company, but why did you not get the idl that went with the .dll file ???

Regards,  P1  :8)

port513

Very simple answer to that, I'm not allowed to show code that you haven't bought from us ;)

And this info that I got from OLE/COM Object Viewer is what everyone that have this component on their computer can see.


/Henke

P1

Quote from: port513 on June 05, 2006, 01:56:47 PMVery simple answer to that, I'm not allowed to show code that you haven't bought from us ;)
I would not considered it code  ( idl ).  It's an Interface  Description Language. 

If it was "code", then you violated IP anyway.  By Reverse Engineering "Code" with oleview.  Bottom line here is, you released the information about your company's product to people who don't have your product.  Because how could we have used oleview on something we don't have?  We have disassembler products, but you don't see us posting the output. 

We are programmers and we do deal with programming issues every day.

Hind Sight is 20/20:  You could have given an example of the problem without disclosing or exposing your company's product.

Regards,  P1  :8)

port513

As I said, this is what I'm allowed to show.

I have the IDL-file and source code etc.

I did a weird workaround for Visual FoxPro on this module and just wanted to test this module in an environment that don't have any error checks by default.

But if you out here don't want to help that's ok because I allready know that it works for all our customers right now, but it wuld be nice to know if this module will work without bugs with assembly language too.


/Henke

rags

Quote from: port513 on June 06, 2006, 02:47:28 PM
But if you out here don't want to help that's ok because I allready know that it works for all our customers right now, but it wuld be nice to know if this module will work without bugs with assembly language too.
If a module is working and bug free, what difference would the language that the module is called from make?
Rags
God made Man, but the monkey applied the glue -DEVO

port513

A huge difference.

DoModal throws an Access Violation that should be handled by the OS and almost all language do that except Visual FoxPro that catch that Access Violation. I don't know why but it's pretty annoying.

So even if a module is bugfree and working in one language it may stop working in another language.


/Henke