[dplayx 02/29] Tests for DirectPlayCreate

Ismael Barros razielmine at gmail.com
Fri Jul 11 10:11:28 CDT 2008

On 7/11/08, Michael Karcher <wine at mkarcher.dialup.fu-berlin.de> wrote:
> Am Donnerstag, den 10.07.2008, 22:04 +0300 schrieb Ismael Barros:
>> I've been checking how this is done in other tests, and it's
>> particularly interesting how they do it in ddraw/tests/refcount.c:81:
>>   hr = IDirectDraw7_CreatePalette(DDraw7, DDPCAPS_ALLOW256 | DDPCAPS_8BIT,
>> Table, &palette, (void *) 0xdeadbeef);
> I don't think this line is good style, but I still like it more than
> your program, as this will definitely crash if the pointer is
> derefenced, while your variant makes the function derefencing the
> pointer accessing uninitialized data.

If it's not that bad, would it be okay to leave it with the deadbeef
solution, with a TODO comment to do it the right way later? Right now
I would like to focus on other functionality (correct networking etc),
and maybe leave that kind of details for after GSoC. From a pragmatic
point of view, I doubt many games make use of theese COM features,
while they still can't properly enumerate service providers.

>> This is the only example in the current code. I could either do it
>> that way (not correct, but simple), or use some IUnknown interface. I
>> tried to get the IUnknown of the classes I have access to, DirectPlay
>> or DirectPlayLobby, but the current implementation is not able to
>> return an interface for IID_IUnknown (it just fails with
> Thats bad. Every COM object must return a valid interface pointer for
> IID_IUnknown. And even worse: The IID_IUnknown pointer *has* to be
> stable. So if you do the following (pretend that CreateFooBar(REFIID,
> DWORD, IUnknown*) is a factory function:
>   IFooBar *fb1, *fb2;
>   IUnknown *unk1, *unk2;
>   fb1 = CreateFooBar(IID_IFooBar, 0, NULL);
>   IFooBar_QueryInterface(fb1, IID_IUnknown, &unk1);
>   IFooBar_QueryInterface(fb1, IID_IFooBar, (IUnknown*)&fb2);
>   IFooBar_Release(fb1);
>   IFooBar_QueryInterface(fb2, IID_IUnknown, &unk2);
>   IFooBar_Release(fb2);
>   ok(unk1 == unk2, "COM violation: IUnknown interface must be stable!");
>   IUnknown_Release(unk1);
>   IUnknown_Release(unk2);
> The COM specification guarantees the test to succeed, independent of
> what type IFooBar has! DirectPlay currently has no permanent COM object,
> but creates a new object on the fly in QueryInterface; this is needed to
> support the different vtables.

Great input, I'll bear it in mind :)

More information about the wine-devel mailing list