1. RE: Brute Force Method Might Wrap DX Into Euphoria Library?

--- Matthew Lewis <matthewwalkerlewis at YAHOO.COM>
wrote:
> > 
> Discuss Tech News as It Happens!
> Keep up with the latest happenings in high tech --
> FREE!
>
> >
------------------------------------------------------------
> 
> 
> > -----Original Message-----
> > From: Mike The Spike [mailto:mtsreborn at yahoo.com]
>  
> > This is how I imagined it;
> > 
> > If you have the following code in C:
> > d3drm->lpVtbl->CreateDeviceFromClipper(d3drm,
> lpclip,
> > NULL, 640, 480, &lpdev)
> > 
> > Wouldn't it be possible to get the address of
> d3drm,
> > and peek the value of CreateDeviceFromClipper from
> the
> > result of the subtraction of the address of d3drm
> and
> > the address of lpVtbl, added to the address of
> d3drm?
> > This is what above could could look like in Eu;
> > 
> > atom CreateDeviceFromClipper
> > 
> > CreateDeviceFromClipper = 
> >
> peek4(d3drm_address+(lpvtbl_address-d3drm_address))
> > 
> > call( CreateDeviceFromClipper )
> > 
> > Would this work?
> > I think it would if all addresses remained
> constant
> > accross threads, wich is what COM is all about
> > anyways...
> > 
> > Correct me if I'm wrong on this one...
> > 
> > If I'm not, then expect Rebirth to go Euphoria!
> 
> Nope.  You haven't passed any parameters, and you
> won't be able to using
> call() alone.  The reason is that the stack will be
> messed up.  Check out my
> post a week ago or so.  It uses a short asm routine
> that allows you to call
> by pointer.  Then, it can work.

I know I know, but it's just an example, I didn't want
to show any machine code in it.

> It's really not difficult to get the address of the
> functions.  All you need
> is the value of lpvtbl and the order in which the
> interface functions are
> declared.  Then you can treat vtbl as an array of
> pointers (because that's
> exactly what it is).  I haven't looked at any DX
> interfaces, but all
> interfaces start with IUnknown, where the first
> function (lpvtbl+0) is
> QueryInterface, then AddRef and Release.
> 
> Here is how you can use COM.  Link to ole32.dll
> (this is the COM automation
> server on Windows).  Call OleInitialize to
> initialize OLE/COM.  Call
> CoCreateInstance to initialize a class id (CLSID). 
> You'll also have to
> specify an interface (IID).  I simply use IUnknown,
> since every COM object
> has it.  Then, you can use IUnknown::QueryInterface
> to get the lpvtbl's to
> any interface you're interested in.  Just remember
> that the first parameter
> you pass has to be the pointer you got from
> CoCreateInstance (hint: it's the
> value returned in ppv--see MSDN for details).  This
> is to emulate the
> implicit passing that C++ does (it's the equivalent
> of 'this', if that makes
> sense to you :).  Also, remember that any string you
> pass has to be unicode
> (see WideToMultiByte / MultiByteToWide ).
> 
> Remember to release any interface you've used, and
> to call OleUninitialize
> when you exit, otherwise, you may not free up
> resources properly.
> 
> As I think I mentioned, I'm now able to call COM
> interfaces successfully,
> it's just a matter of wrapping the API to make it
> more friendly to use.  I
> should have something meaningful to share later this
> week--most likely a way
> to use ActiveX objects with Eu.
> 
> Matt Lewis
> 


Mike The Spike

>

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu