Need help in debugging a stack corruption

Lionel Ulmer lionel.ulmer at free.fr
Sat Jan 7 03:14:44 CST 2006


On Tue, Jan 03, 2006 at 09:17:14PM +0100, Stefan Dösinger wrote:
> To create interfaces for IDirectDraw1 to 7, I created 4 lpVtbl structures for 
> each version, and I cast most DD7 funtions info the older versions. Only 
> where the type or the number of parameters is different, I use a wrapper 
> function. At DD creation, I use whatever version was requested by the app for 
> the new object. The old dd version used a number of macros to cast the 
> various interfaces(defined in ddcomimpl.h). I don't use them. Might this 
> cause the problem?

Best would to see the actual code for that as I do not really understand
what you did by reading your description of it. 

But I still find what you wrote suspicious: if you have 4 VTables you should
NEVER cast functions even if they have the same signature - casts are only
useful if multiple object versions share the same VTable. Basically (from
what I remember :-) ), the pointer to the VTable is stored at the address
returned to the application as the COM object. Wine then use a fixed offset
to find it's private data from the COM object (basically, the offset between
the start of Wine's data to the VTable it returned to the application). Of
course, if you have 4 VTables, these offsets are different => you cannot
find the address of Wine's internal data without knowing exactly which
object was given as an argument to the function.

So by just casting, you will apply the wrong offset and so have completely
bogus internal datas (for example, if you do another DDraw call inside the
called DDraw function), you may use completely bogus values to do the jump
(and so maybe jump to a function which does not have the correct signature
=> stack corruption).

        Lionel

-- 
		 Lionel Ulmer - http://www.bbrox.org/



More information about the wine-devel mailing list