ReactOS 0.4.17-dev-1037-g720d112
main.c File Reference
#include "ddraw_private.h"
#include "rpcproxy.h"
#include "wine/exception.h"
#include "winreg.h"
Include dependency graph for main.c:

Go to the source code of this file.

Classes

struct  callback_info
 
struct  ddraw_class_factory
 

Macros

#define DDRAW_INIT_GUID
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ddraw)
 
static BOOL CALLBACK enum_callback (GUID *guid, char *description, char *driver_name, void *context, HMONITOR monitor)
 
static void ddraw_enumerate_secondary_devices (struct wined3d *wined3d, LPDDENUMCALLBACKEXA callback, void *context)
 
BOOL ddraw_handle_table_init (struct ddraw_handle_table *t, UINT initial_size)
 
void ddraw_handle_table_destroy (struct ddraw_handle_table *t)
 
DWORD ddraw_allocate_handle (struct ddraw_handle_table *t, void *object, enum ddraw_handle_type type)
 
void * ddraw_free_handle (struct ddraw_handle_table *t, DWORD handle, enum ddraw_handle_type type)
 
void * ddraw_get_object (struct ddraw_handle_table *t, DWORD handle, enum ddraw_handle_type type)
 
HRESULT WINAPI GetSurfaceFromDC (HDC dc, IDirectDrawSurface4 **surface, HDC *device_dc)
 
static HRESULT DDRAW_Create (const GUID *guid, void **out, IUnknown *outer_unknown, REFIID iid)
 
HRESULT WINAPI DECLSPEC_HOTPATCH DirectDrawCreate (GUID *driver_guid, IDirectDraw **ddraw, IUnknown *outer)
 
HRESULT WINAPI DECLSPEC_HOTPATCH DirectDrawCreateEx (GUID *driver_guid, void **ddraw, REFIID interface_iid, IUnknown *outer)
 
HRESULT WINAPI DirectDrawEnumerateA (LPDDENUMCALLBACKA callback, void *context)
 
HRESULT WINAPI DirectDrawEnumerateExA (LPDDENUMCALLBACKEXA callback, void *context, DWORD flags)
 
HRESULT WINAPI DirectDrawEnumerateW (LPDDENUMCALLBACKW callback, void *context)
 
HRESULT WINAPI DirectDrawEnumerateExW (LPDDENUMCALLBACKEXW callback, void *context, DWORD flags)
 
static HRESULT CF_CreateDirectDraw (IUnknown *UnkOuter, REFIID iid, void **obj)
 
static HRESULT CF_CreateDirectDrawClipper (IUnknown *UnkOuter, REFIID riid, void **obj)
 
static struct ddraw_class_factory * impl_from_IClassFactory (IClassFactory *iface)
 
static HRESULT WINAPI ddraw_class_factory_QueryInterface (IClassFactory *iface, REFIID riid, void **out)
 
static ULONG WINAPI ddraw_class_factory_AddRef (IClassFactory *iface)
 
static ULONG WINAPI ddraw_class_factory_Release (IClassFactory *iface)
 
static HRESULT WINAPI ddraw_class_factory_CreateInstance (IClassFactory *iface, IUnknown *outer_unknown, REFIID riid, void **out)
 
static HRESULT WINAPI ddraw_class_factory_LockServer (IClassFactory *iface, BOOL dolock)
 
HRESULT WINAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, void **out)
 
BOOL WINAPI DllMain (HINSTANCE inst, DWORD reason, void *reserved)
 

Variables

static struct list global_ddraw_list = LIST_INIT(global_ddraw_list)
 
static HINSTANCE instance
 
DWORD force_refresh_rate = 0
 
struct ddraw_handle_table global_handle_table
 
static const struct object_creation_info object_creation []
 
static const IClassFactoryVtbl IClassFactory_Vtbl
 

Macro Definition Documentation

◆ DDRAW_INIT_GUID

#define DDRAW_INIT_GUID

Definition at line 24 of file main.c.

Function Documentation

◆ CF_CreateDirectDraw()

static HRESULT CF_CreateDirectDraw ( IUnknown *  UnkOuter,
REFIID  iid,
void **  obj 
)
static

Definition at line 554 of file main.c.

556{
557 HRESULT hr;
558
559 TRACE("outer_unknown %p, riid %s, object %p.\n", UnkOuter, debugstr_guid(iid), obj);
560
562 hr = DDRAW_Create(NULL, obj, UnkOuter, iid);
564
565 return hr;
566}
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
static HRESULT DDRAW_Create(const GUID *guid, void **out, IUnknown *outer_unknown, REFIID iid)
Definition: main.c:293
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:544
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:539

◆ CF_CreateDirectDrawClipper()

static HRESULT CF_CreateDirectDrawClipper ( IUnknown *  UnkOuter,
REFIID  riid,
void **  obj 
)
static

Definition at line 583 of file main.c.

585{
586 HRESULT hr;
587 IDirectDrawClipper *Clip;
588
589 TRACE("outer_unknown %p, riid %s, object %p.\n", UnkOuter, debugstr_guid(riid), obj);
590
592 hr = DirectDrawCreateClipper(0, &Clip, UnkOuter);
593 if (hr != DD_OK)
594 {
596 return hr;
597 }
598
599 hr = IDirectDrawClipper_QueryInterface(Clip, riid, obj);
600 IDirectDrawClipper_Release(Clip);
601
603
604 return hr;
605}
HRESULT WINAPI DirectDrawCreateClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER *lplpDDClipper, LPUNKNOWN pUnkOuter)
Definition: main.c:55
REFIID riid
Definition: atlbase.h:39
#define DD_OK
Definition: ddraw.h:188

◆ ddraw_allocate_handle()

DWORD ddraw_allocate_handle ( struct ddraw_handle_table *  t,
void *  object,
enum ddraw_handle_type  type 
)

Definition at line 138 of file main.c.

139{
141
142 if (!t)
144
145 if (t->free_entries)
146 {
147 DWORD idx = t->free_entries - t->entries;
148 /* Use a free handle */
149 entry = t->free_entries;
150 if (entry->type != DDRAW_HANDLE_FREE)
151 {
152 ERR("Handle %#lx (%p) is in the free list, but has type %#x.\n", idx, entry->object, entry->type);
154 }
155 t->free_entries = entry->object;
156 entry->object = object;
157 entry->type = type;
158
159 return idx;
160 }
161
162 if (!(t->entry_count < t->table_size))
163 {
164 /* Grow the table */
165 UINT new_size = t->table_size + (t->table_size >> 1);
166 struct ddraw_handle_entry *new_entries;
167
168 if (!(new_entries = realloc(t->entries, new_size * sizeof(*t->entries))))
169 {
170 ERR("Failed to grow the handle table.\n");
172 }
173 t->entries = new_entries;
174 t->table_size = new_size;
175 }
176
177 entry = &t->entries[t->entry_count];
178 entry->object = object;
179 entry->type = type;
180
181 return t->entry_count++;
182}
#define ERR(fmt,...)
Definition: precomp.h:57
#define DDRAW_INVALID_HANDLE
@ DDRAW_HANDLE_FREE
#define realloc
Definition: debug_ros.c:6
struct ddraw_handle_table global_handle_table
Definition: main.c:40
unsigned int idx
Definition: utils.c:40
size_t const new_size
Definition: expand.cpp:66
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble GLdouble t
Definition: gl.h:2047
unsigned int UINT
Definition: sysinfo.c:13
uint32_t entry
Definition: isohybrid.c:63
void * object

Referenced by d3d_device1_CreateMatrix(), d3d_device7_CreateStateBlock(), d3d_device7_EndStateBlock(), d3d_material3_GetHandle(), and d3d_texture2_GetHandle().

◆ ddraw_class_factory_AddRef()

static ULONG WINAPI ddraw_class_factory_AddRef ( IClassFactory *  iface)
static

Definition at line 667 of file main.c.

668{
671
672 TRACE("%p increasing refcount to %lu.\n", factory, ref);
673
674 return ref;
675}
#define InterlockedIncrement
Definition: armddk.h:53
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: main.c:49
Definition: main.c:439
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ ddraw_class_factory_CreateInstance()

static HRESULT WINAPI ddraw_class_factory_CreateInstance ( IClassFactory *  iface,
IUnknown *  outer_unknown,
REFIID  riid,
void **  out 
)
static

Definition at line 713 of file main.c.

715{
717
718 TRACE("iface %p, outer_unknown %p, riid %s, out %p.\n",
719 iface, outer_unknown, debugstr_guid(riid), out);
720
721 return factory->pfnCreateInstance(outer_unknown, riid, out);
722}
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

◆ ddraw_class_factory_LockServer()

static HRESULT WINAPI ddraw_class_factory_LockServer ( IClassFactory *  iface,
BOOL  dolock 
)
static

Definition at line 736 of file main.c.

737{
738 FIXME("iface %p, dolock %#x stub!\n", iface, dolock);
739
740 return S_OK;
741}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define S_OK
Definition: intsafe.h:52

◆ ddraw_class_factory_QueryInterface()

static HRESULT WINAPI ddraw_class_factory_QueryInterface ( IClassFactory *  iface,
REFIID  riid,
void **  out 
)
static

Definition at line 641 of file main.c.

642{
643 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
644
647 {
648 IClassFactory_AddRef(iface);
649 *out = iface;
650 return S_OK;
651 }
652
653 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
654
655 return E_NOINTERFACE;
656}
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ ddraw_class_factory_Release()

static ULONG WINAPI ddraw_class_factory_Release ( IClassFactory *  iface)
static

Definition at line 687 of file main.c.

688{
691
692 TRACE("%p decreasing refcount to %lu.\n", factory, ref);
693
694 if (!ref)
695 free(factory);
696
697 return ref;
698}
#define InterlockedDecrement
Definition: armddk.h:52
#define free
Definition: debug_ros.c:5

◆ DDRAW_Create()

static HRESULT DDRAW_Create ( const GUID *  guid,
void **  out,
IUnknown *  outer_unknown,
REFIID  iid 
)
static

Definition at line 293 of file main.c.

294{
296 struct ddraw *ddraw;
297 DWORD flags = 0;
298 HRESULT hr;
299
300 TRACE("driver_guid %s, ddraw %p, outer_unknown %p, interface_iid %s.\n",
301 debugstr_guid(guid), out, outer_unknown, debugstr_guid(iid));
302
303 *out = NULL;
304
306 {
308 }
309 else if (guid == (GUID *) DDCREATE_HARDWAREONLY)
310 {
312 }
313 else
314 {
316 }
317
318 /* DDraw doesn't support aggregation, according to msdn */
319 if (outer_unknown != NULL)
321
322 if (!IsEqualGUID(iid, &IID_IDirectDraw7))
324
325 if (!(ddraw = calloc(1, sizeof(*ddraw))))
326 {
327 ERR("Out of memory when creating DirectDraw.\n");
328 return E_OUTOFMEMORY;
329 }
330
332 {
333 WARN("Failed to initialize ddraw object, hr %#lx.\n", hr);
334 free(ddraw);
335 return hr;
336 }
337
338 hr = IDirectDraw7_QueryInterface(&ddraw->IDirectDraw7_iface, iid, out);
339 IDirectDraw7_Release(&ddraw->IDirectDraw7_iface);
340 if (SUCCEEDED(hr))
342 else
343 WARN("Failed to query interface %s from ddraw object %p.\n", debugstr_guid(iid), ddraw);
344
345 return hr;
346}
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
device_type
HRESULT ddraw_init(struct ddraw *ddraw, DWORD flags, enum wined3d_device_type device_type)
Definition: ddraw.c:5079
static struct list global_ddraw_list
Definition: main.c:33
GUID guid
Definition: version.c:147
GLbitfield flags
Definition: glext.h:7161
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define calloc
Definition: rosglue.h:14
#define DDCREATE_HARDWAREONLY
Definition: ddraw.h:200
#define DDCREATE_EMULATIONONLY
Definition: ddraw.h:201
IDirectDraw7 IDirectDraw7_iface
Definition: ddraw_private.h:83
struct list ddraw_list_entry
#define WINED3D_LEGACY_FFP_LIGHTING
Definition: wined3d.h:1329
wined3d_device_type
Definition: wined3d.h:90
@ WINED3D_DEVICE_TYPE_HAL
Definition: wined3d.h:91
@ WINED3D_DEVICE_TYPE_REF
Definition: wined3d.h:92
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:3771

Referenced by CF_CreateDirectDraw(), DirectDrawCreate(), and DirectDrawCreateEx().

◆ ddraw_enumerate_secondary_devices()

static void ddraw_enumerate_secondary_devices ( struct wined3d *  wined3d,
LPDDENUMCALLBACKEXA  callback,
void *  context 
)
static

Definition at line 58 of file main.c.

60{
61 struct wined3d_adapter_identifier adapter_id;
63 struct wined3d_output_desc output_desc;
65 unsigned int interface_count = 0;
66 unsigned int adapter_idx = 0;
67 unsigned int output_idx;
68 BOOL cont_enum = TRUE;
69 HRESULT hr;
70
71 while (cont_enum && (wined3d_adapter = wined3d_get_adapter(wined3d, adapter_idx)))
72 {
73 char device_name[512] = "", description[512] = "";
74
75 /* The Battle.net System Checker expects the GetAdapterIdentifier DeviceName to match the
76 * Driver Name, so obtain the DeviceName and GUID from D3D. */
77 memset(&adapter_id, 0x0, sizeof(adapter_id));
78 adapter_id.description = description;
79 adapter_id.description_size = sizeof(description);
80
83 {
84 WARN("Failed to get adapter identifier, hr %#lx.\n", hr);
86 break;
87 }
89
90 for (output_idx = 0; cont_enum && (wined3d_output = wined3d_adapter_get_output(
91 wined3d_adapter, output_idx)); ++output_idx)
92 {
94 if (FAILED(hr = wined3d_output_get_desc(wined3d_output, &output_desc)))
95 {
96 WARN("Failed to get output description, hr %#lx.\n", hr);
98 break;
99 }
101
102 TRACE("Interface %u: %s\n", interface_count++,
103 wine_dbgstr_guid(&adapter_id.device_identifier));
104 WideCharToMultiByte(CP_ACP, 0, output_desc.device_name, -1, device_name,
105 sizeof(device_name), NULL, NULL);
106 cont_enum = callback(&adapter_id.device_identifier, adapter_id.description,
107 device_name, context, output_desc.monitor);
108 }
109
110 if (FAILED(hr))
111 break;
112
113 ++adapter_idx;
114 }
115}
void * description
#define TRUE
Definition: types.h:120
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
static const WCHAR device_name[]
Definition: btrfs.c:60
unsigned int BOOL
Definition: ntddk_ex.h:94
static IPrintDialogCallback callback
Definition: printdlg.c:325
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:181
#define memset(x, y, z)
Definition: compat.h:39
Definition: http.c:7252
HRESULT CDECL wined3d_output_get_desc(const struct wined3d_output *output, struct wined3d_output_desc *desc)
Definition: directx.c:1256
HRESULT CDECL wined3d_adapter_get_identifier(const struct wined3d_adapter *adapter, uint32_t flags, struct wined3d_adapter_identifier *identifier)
Definition: directx.c:1785
struct wined3d_adapter *CDECL wined3d_get_adapter(const struct wined3d *wined3d, unsigned int idx)
Definition: directx.c:1009
struct wined3d_output *CDECL wined3d_adapter_get_output(const struct wined3d_adapter *adapter, unsigned int idx)
Definition: directx.c:1027

Referenced by DirectDrawEnumerateExA().

◆ ddraw_free_handle()

void * ddraw_free_handle ( struct ddraw_handle_table *  t,
DWORD  handle,
enum ddraw_handle_type  type 
)

Definition at line 184 of file main.c.

185{
187 void *object;
188
189 if (!t)
191
192 if (handle == DDRAW_INVALID_HANDLE || handle >= t->entry_count)
193 {
194 WARN("Invalid handle %#lx passed.\n", handle);
195 return NULL;
196 }
197
198 entry = &t->entries[handle];
199 if (entry->type != type)
200 {
201 WARN("Handle %#lx (%p) is not of type %#x.\n", handle, entry->object, type);
202 return NULL;
203 }
204
205 object = entry->object;
206 entry->object = t->free_entries;
207 entry->type = DDRAW_HANDLE_FREE;
208 t->free_entries = entry;
209
210 return object;
211}

Referenced by d3d_device1_DeleteMatrix(), d3d_device7_DeleteStateBlock(), d3d_material3_Release(), and ddraw_surface_wined3d_object_destroyed().

◆ ddraw_get_object()

void * ddraw_get_object ( struct ddraw_handle_table *  t,
DWORD  handle,
enum ddraw_handle_type  type 
)

Definition at line 213 of file main.c.

214{
216
217 if (!t)
219
220 if (handle == DDRAW_INVALID_HANDLE || handle >= t->entry_count)
221 {
222 WARN("Invalid handle %#lx passed.\n", handle);
223 return NULL;
224 }
225
226 entry = &t->entries[handle];
227 if (entry->type != type)
228 {
229 WARN("Handle %#lx (%p) is not of type %#x.\n", handle, entry->object, type);
230 return NULL;
231 }
232
233 return entry->object;
234}

Referenced by d3d_device1_GetMatrix(), d3d_device1_SetMatrix(), d3d_device3_SetLightState(), d3d_device3_SetRenderState(), d3d_device7_ApplyStateBlock(), d3d_device7_CaptureStateBlock(), and d3d_viewport_SetBackground().

◆ ddraw_handle_table_destroy()

void ddraw_handle_table_destroy ( struct ddraw_handle_table *  t)

Definition at line 132 of file main.c.

133{
134 free(t->entries);
135 memset(t, 0, sizeof(*t));
136}

Referenced by d3d_device_init(), d3d_device_inner_Release(), and DllMain().

◆ ddraw_handle_table_init()

BOOL ddraw_handle_table_init ( struct ddraw_handle_table *  t,
UINT  initial_size 
)

Definition at line 118 of file main.c.

119{
120 if (!(t->entries = calloc(initial_size, sizeof(*t->entries))))
121 {
122 ERR("Failed to allocate handle table memory.\n");
123 return FALSE;
124 }
125 t->free_entries = NULL;
126 t->table_size = initial_size;
127 t->entry_count = 0;
128
129 return TRUE;
130}
#define FALSE
Definition: types.h:117

Referenced by d3d_device_init(), and DllMain().

◆ DirectDrawCreate()

HRESULT WINAPI DECLSPEC_HOTPATCH DirectDrawCreate ( GUID *  driver_guid,
IDirectDraw **  ddraw,
IUnknown *  outer 
)

Definition at line 357 of file main.c.

358{
359 HRESULT hr;
360
361 TRACE("driver_guid %s, ddraw %p, outer %p.\n",
362 debugstr_guid(driver_guid), ddraw, outer);
363
365 hr = DDRAW_Create(driver_guid, (void **)ddraw, outer, &IID_IDirectDraw);
367
368 if (SUCCEEDED(hr))
369 {
370 if (FAILED(hr = IDirectDraw_Initialize(*ddraw, driver_guid)))
371 IDirectDraw_Release(*ddraw);
372 }
373
374 return hr;
375}
static IUnknown * outer
Definition: compobj.c:82

◆ DirectDrawCreateEx()

HRESULT WINAPI DECLSPEC_HOTPATCH DirectDrawCreateEx ( GUID *  driver_guid,
void **  ddraw,
REFIID  interface_iid,
IUnknown *  outer 
)

Definition at line 386 of file main.c.

388{
389 HRESULT hr;
390
391 TRACE("driver_guid %s, ddraw %p, interface_iid %s, outer %p.\n",
392 debugstr_guid(driver_guid), ddraw, debugstr_guid(interface_iid), outer);
393
394 if (!IsEqualGUID(interface_iid, &IID_IDirectDraw7))
395 return DDERR_INVALIDPARAMS;
396
398 hr = DDRAW_Create(driver_guid, ddraw, outer, interface_iid);
400
401 if (SUCCEEDED(hr))
402 {
403 IDirectDraw7 *ddraw7 = *(IDirectDraw7 **)ddraw;
404 hr = IDirectDraw7_Initialize(ddraw7, driver_guid);
405 if (FAILED(hr))
406 IDirectDraw7_Release(ddraw7);
407 }
408
409 return hr;
410}
DWORD IDirectDraw7
Definition: vmrender.idl:21
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:81

◆ DirectDrawEnumerateA()

HRESULT WINAPI DirectDrawEnumerateA ( LPDDENUMCALLBACKA  callback,
void *  context 
)

Definition at line 432 of file main.c.

433{
434 struct callback_info info;
435
436 TRACE("callback %p, context %p.\n", callback, context);
437
438 info.callback = callback;
439 info.context = context;
441}
HRESULT WINAPI DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags)
Definition: main.c:208
static BOOL CALLBACK enum_callback(GUID *guid, char *description, char *driver_name, void *context, HMONITOR monitor)
Definition: main.c:50
void * context
Definition: main.c:46

◆ DirectDrawEnumerateExA()

HRESULT WINAPI DirectDrawEnumerateExA ( LPDDENUMCALLBACKEXA  callback,
void *  context,
DWORD  flags 
)

Definition at line 452 of file main.c.

453{
454 struct wined3d *wined3d;
455
456 TRACE("callback %p, context %p, flags %#lx.\n", callback, context, flags);
457
461 return DDERR_INVALIDPARAMS;
462
464 FIXME("flags %#lx not handled\n", flags & ~DDENUM_ATTACHEDSECONDARYDEVICES);
465
466 TRACE("Enumerating ddraw interfaces\n");
468 {
470 {
471 WARN("Failed to create a wined3d object.\n");
472 return E_FAIL;
473 }
474
475 WARN("Created a wined3d object without 3D support.\n");
476 }
477
478 __TRY
479 {
480 /* QuickTime expects the description "DirectDraw HAL" */
481 static CHAR driver_desc[] = "DirectDraw HAL",
482 driver_name[] = "display";
483 BOOL cont_enum;
484
485 TRACE("Default interface: DirectDraw HAL\n");
486 cont_enum = callback(NULL, driver_desc, driver_name, context, 0);
487
488 /* The Battle.net System Checker expects both a NULL device and a GUID-based device */
489 if (cont_enum && (flags & DDENUM_ATTACHEDSECONDARYDEVICES))
491 }
493 {
495 return DDERR_INVALIDPARAMS;
496 }
497 __ENDTRY;
498
500 TRACE("End of enumeration\n");
501 return DD_OK;
502}
#define DDRAW_WINED3D_FLAGS
Definition: ddraw_private.h:63
#define E_FAIL
Definition: ddrawi.h:102
static void ddraw_enumerate_secondary_devices(struct wined3d *wined3d, LPDDENUMCALLBACKEXA callback, void *context)
Definition: main.c:58
#define __TRY
Definition: compat.h:80
#define __ENDTRY
Definition: compat.h:82
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:81
char CHAR
Definition: pedump.c:57
#define DDENUM_ATTACHEDSECONDARYDEVICES
Definition: ddraw.h:193
#define DDENUM_DETACHEDSECONDARYDEVICES
Definition: ddraw.h:194
#define DDENUM_NONDISPLAYDEVICES
Definition: ddraw.h:195
ULONG CDECL wined3d_decref(struct wined3d *wined3d)
Definition: directx.c:198
#define WINED3D_NO3D
Definition: wined3d.h:1323
struct wined3d *CDECL wined3d_create(uint32_t flags)
Definition: wined3d_main.c:142

◆ DirectDrawEnumerateExW()

HRESULT WINAPI DirectDrawEnumerateExW ( LPDDENUMCALLBACKEXW  callback,
void *  context,
DWORD  flags 
)

Definition at line 528 of file main.c.

529{
530 TRACE("callback %p, context %p, flags %#lx.\n", callback, context, flags);
531
532 return DDERR_UNSUPPORTED;
533}
#define DDERR_UNSUPPORTED
Definition: ddraw.h:129

◆ DirectDrawEnumerateW()

HRESULT WINAPI DirectDrawEnumerateW ( LPDDENUMCALLBACKW  callback,
void *  context 
)

Definition at line 511 of file main.c.

512{
513 TRACE("callback %p, context %p.\n", callback, context);
514
515 if (!callback)
516 return DDERR_INVALIDPARAMS;
517 else
518 return DDERR_UNSUPPORTED;
519}

◆ DllGetClassObject()

HRESULT WINAPI DllGetClassObject ( REFCLSID  rclsid,
REFIID  riid,
void **  out 
)

Definition at line 755 of file main.c.

756{
758 unsigned int i;
759
760 TRACE("rclsid %s, riid %s, out %p.\n",
762
765 return E_NOINTERFACE;
766
767 for (i=0; i < ARRAY_SIZE(object_creation); i++)
768 {
769 if (IsEqualGUID(object_creation[i].clsid, rclsid))
770 break;
771 }
772
774 {
775 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
777 }
778
779 if (!(factory = calloc(1, sizeof(*factory))))
780 return E_OUTOFMEMORY;
781
783 factory->ref = 1;
784
785 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
786
787 *out = factory;
788 return S_OK;
789}
#define ARRAY_SIZE(A)
Definition: main.h:20
static const struct object_creation_info object_creation[]
Definition: main.c:60
static const IClassFactoryVtbl IClassFactory_Vtbl
Definition: main.c:746
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
const CLSID * clsid
Definition: msctf.cpp:50
IClassFactory IClassFactory_iface
Definition: main.c:440
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:3772

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  inst,
DWORD  reason,
void *  reserved 
)

Definition at line 800 of file main.c.

801{
802 switch (reason)
803 {
805 {
806 static HMODULE ddraw_self;
807 HKEY hkey = 0;
808 WNDCLASSA wc;
809
810 /* Register the window class. This is used to create a hidden window
811 * for D3D rendering, if the application didn't pass one. It can also
812 * be used for creating a device window from SetCooperativeLevel(). */
815 wc.cbClsExtra = 0;
816 wc.cbWndExtra = 0;
817 wc.hInstance = inst;
818 wc.hIcon = 0;
819 wc.hCursor = 0;
821 wc.lpszMenuName = NULL;
823 if (!RegisterClassA(&wc))
824 {
825 ERR("Failed to register ddraw window class, last error %#lx.\n", GetLastError());
826 return FALSE;
827 }
828
830 {
832 return FALSE;
833 }
834
835 /* On Windows one can force the refresh rate that DirectDraw uses by
836 * setting an override value in dxdiag. This is documented in KB315614
837 * (main article), KB230002, and KB217348. By comparing registry dumps
838 * before and after setting the override, we see that the override value
839 * is stored in HKLM\Software\Microsoft\DirectDraw\ForceRefreshRate as a
840 * DWORD that represents the refresh rate to force. We use this
841 * registry entry to modify the behavior of SetDisplayMode so that Wine
842 * users can override the refresh rate in a Windows-compatible way.
843 *
844 * dxdiag will not accept a refresh rate lower than 40 or higher than
845 * 120 so this value should be within that range. It is, of course,
846 * possible for a user to set the registry entry value directly so that
847 * assumption might not hold.
848 *
849 * There is no current mechanism for setting this value through the Wine
850 * GUI. It would be most appropriate to set this value through a dxdiag
851 * clone, but it may be sufficient to use winecfg.
852 *
853 * TODO: Create a mechanism for setting this value through the Wine GUI.
854 */
855 if ( !RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Microsoft\\DirectDraw", &hkey ) )
856 {
858
859 size = sizeof(data);
860 if (!RegQueryValueExA(hkey, "ForceRefreshRate", NULL, &type, (BYTE *)&data, &size) && type == REG_DWORD)
861 {
862 TRACE("ForceRefreshRate set; overriding refresh rate to %ld Hz\n", data);
864 }
865 RegCloseKey( hkey );
866 }
867
868 /* Prevent the ddraw module from being unloaded. When switching to
869 * exclusive mode, we replace the window proc of the ddraw window. If
870 * an application would unload ddraw from the WM_DESTROY handler for
871 * that window, it would return to unmapped memory and die. Apparently
872 * this is supposed to work on Windows. */
873 if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN,
874 (const WCHAR *)&ddraw_self, &ddraw_self))
875 ERR("Failed to get own module handle.\n");
876
877 instance = inst;
879 break;
880 }
881
883 if (WARN_ON(ddraw))
884 {
885 struct ddraw *ddraw;
886 unsigned int i;
887
889 {
890 struct ddraw_surface *surface;
891
892 WARN("DirectDraw object %p has reference counts {%lu, %lu, %lu, %lu, %lu}.\n",
894
896 WARN("DirectDraw object %p has Direct3D device(s) attached.\n", ddraw);
897
899 {
900 WARN("Surface %p has reference counts {%lu, %lu, %lu, %lu, %lu, %lu}.\n",
901 surface, surface->ref7, surface->ref4, surface->ref3,
902 surface->ref2, surface->ref1, surface->gamma_count);
903 }
904 }
905
906 for (i = 0; i < global_handle_table.entry_count; ++i)
907 {
908 struct ddraw_handle_entry *entry = &global_handle_table.entries[i];
909
910 switch (entry->type)
911 {
913 break;
914
916 WARN("Material handle %#x (%p) not unset properly.\n", i + 1, entry->object);
917 break;
918
920 WARN("Texture handle %#x (%p) not unset properly.\n", i + 1, entry->object);
921 break;
922
924 WARN("Leftover matrix handle %#x (%p), deleting.\n", i + 1, entry->object);
925 break;
926
927 default:
928 WARN("Handle %#x (%p) has unknown type %#x.\n", i + 1, entry->object, entry->type);
929 break;
930 }
931 }
933 }
934
935 if (reserved) break;
937 }
938
939 return TRUE;
940}
static int list_empty(struct list_entry *head)
Definition: list.h:58
#define RegCloseKey(hKey)
Definition: registry.h:49
#define DDRAW_WINDOW_CLASS_NAME
@ DDRAW_HANDLE_SURFACE
@ DDRAW_HANDLE_MATRIX
@ DDRAW_HANDLE_MATERIAL
DWORD force_refresh_rate
Definition: main.c:38
static HINSTANCE instance
Definition: main.c:35
void ddraw_handle_table_destroy(struct ddraw_handle_table *t)
Definition: main.c:132
BOOL ddraw_handle_table_init(struct ddraw_handle_table *t, UINT initial_size)
Definition: main.c:118
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3234
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1971
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
BOOL WINAPI GetModuleHandleExW(IN DWORD dwFlags, IN LPCWSTR lpwModuleName OPTIONAL, OUT HMODULE *phModule)
Definition: loader.c:866
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
r reserved
Definition: btrfs.c:3006
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
#define WARN_ON(c)
Definition: module.h:257
short WCHAR
Definition: pedump.c:58
#define CS_VREDRAW
Definition: winuser.h:666
BOOL WINAPI UnregisterClassA(_In_ LPCSTR, HINSTANCE)
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CS_HREDRAW
Definition: winuser.h:661
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
#define REG_DWORD
Definition: sdbapi.c:615
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:236
HBRUSH hbrBackground
Definition: winuser.h:3278
HICON hIcon
Definition: winuser.h:3276
HINSTANCE hInstance
Definition: winuser.h:3275
HCURSOR hCursor
Definition: winuser.h:3277
int cbWndExtra
Definition: winuser.h:3274
UINT style
Definition: winuser.h:3271
LPCSTR lpszMenuName
Definition: winuser.h:3279
LPCSTR lpszClassName
Definition: winuser.h:3280
WNDPROC lpfnWndProc
Definition: winuser.h:3272
int cbClsExtra
Definition: winuser.h:3273
struct list surface_list_entry
LONG ref1
Definition: ddraw_private.h:94
LONG ref7
Definition: ddraw_private.h:94
struct list d3ddevice_list
struct list surface_list
LONG ref4
Definition: ddraw_private.h:94
LONG ref2
Definition: ddraw_private.h:94
LONG ref3
Definition: ddraw_private.h:94
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define BLACK_BRUSH
Definition: wingdi.h:896
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
unsigned char BYTE
Definition: xxhash.c:193

◆ enum_callback()

static BOOL CALLBACK enum_callback ( GUID *  guid,
char *  description,
char *  driver_name,
void *  context,
HMONITOR  monitor 
)
static

Definition at line 50 of file main.c.

52{
53 const struct callback_info *info = context;
54
55 return info->callback(guid, description, driver_name, info->context);
56}

Referenced by DirectDrawEnumerateA().

◆ GetSurfaceFromDC()

HRESULT WINAPI GetSurfaceFromDC ( HDC  dc,
IDirectDrawSurface4 **  surface,
HDC *  device_dc 
)

Definition at line 236 of file main.c.

237{
238 struct ddraw *ddraw;
239
240 TRACE("dc %p, surface %p, device_dc %p.\n", dc, surface, device_dc);
241
242 if (!surface)
243 return E_INVALIDARG;
244
245 if (!device_dc)
246 {
247 *surface = NULL;
248
249 return E_INVALIDARG;
250 }
251
254 {
255 if (FAILED(IDirectDraw4_GetSurfaceFromDC(&ddraw->IDirectDraw4_iface, dc, surface)))
256 continue;
257
258 *device_dc = NULL; /* FIXME */
260 return DD_OK;
261 }
263
264 *surface = NULL;
265 *device_dc = NULL;
266
267 return DDERR_NOTFOUND;
268}
HDC dc
Definition: cylfrac.c:34
#define E_INVALIDARG
Definition: ddrawi.h:101
#define DDERR_NOTFOUND
Definition: ddraw.h:99
IDirectDraw4 IDirectDraw4_iface
Definition: ddraw_private.h:84

◆ impl_from_IClassFactory()

static struct ddraw_class_factory * impl_from_IClassFactory ( IClassFactory *  iface)
inlinestatic

Definition at line 622 of file main.c.

623{
624 return CONTAINING_RECORD(iface, struct ddraw_class_factory, IClassFactory_iface);
625}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ddraw  )

Variable Documentation

◆ force_refresh_rate

DWORD force_refresh_rate = 0

Definition at line 38 of file main.c.

Referenced by ddraw7_SetDisplayMode(), and DllMain().

◆ global_ddraw_list

struct list global_ddraw_list = LIST_INIT(global_ddraw_list)
static

Definition at line 33 of file main.c.

Referenced by DDRAW_Create(), DllMain(), and GetSurfaceFromDC().

◆ global_handle_table

◆ IClassFactory_Vtbl

const IClassFactoryVtbl IClassFactory_Vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI ddraw_class_factory_LockServer(IClassFactory *iface, BOOL dolock)
Definition: main.c:736
static HRESULT WINAPI ddraw_class_factory_QueryInterface(IClassFactory *iface, REFIID riid, void **out)
Definition: main.c:641
static ULONG WINAPI ddraw_class_factory_AddRef(IClassFactory *iface)
Definition: main.c:667
static HRESULT WINAPI ddraw_class_factory_CreateInstance(IClassFactory *iface, IUnknown *outer_unknown, REFIID riid, void **out)
Definition: main.c:713
static ULONG WINAPI ddraw_class_factory_Release(IClassFactory *iface)
Definition: main.c:687

Definition at line 746 of file main.c.

Referenced by DllGetClassObject().

◆ instance

HINSTANCE instance
static

Definition at line 35 of file main.c.

Referenced by _dump_EnumObjects_flags(), CExplorerBand::_GetTitle(), AtlAxDialogBoxA(), AtlAxDialogBoxW(), CallbackMayRunLong(), connection_collector(), CreateWindowExA(), CreateWindowExW(), d3d12_device_create(), d3d12_device_init(), d3d12_get_vk_physical_device(), D3D12CreateDevice(), dde_execute(), dde_request(), DECLARE_INTERFACE_(), disassociate2_cb(), disassociate3_cb(), disassociate_cb(), DllMain(), DllRegisterServer(), DllUnregisterServer(), DP_IF_EnumGroupPlayers(), DP_IF_EnumGroupsInGroup(), dummy_callback(), enum_devices_callback(), factory_ActivateInstance(), fake_dll_main(), FilterMapper3_RegisterFilter(), FilterMapper3_UnregisterFilter(), get_dom_element(), getItemAndInstanceFromTable(), getItemAndIntegerInstanceFromOid(), ICONTITLE_Create(), IDirectPlay2AImpl_EnumGroupPlayers(), IDirectPlay2AImpl_EnumGroups(), IDirectPlay2AImpl_EnumPlayers(), IDirectPlay2Impl_EnumGroupPlayers(), IDirectPlay2Impl_EnumGroups(), IDirectPlay2Impl_EnumPlayers(), IDirectPlay3AImpl_EnumGroupPlayers(), IDirectPlay3AImpl_EnumGroups(), IDirectPlay3AImpl_EnumGroupsInGroup(), IDirectPlay3AImpl_EnumPlayers(), IDirectPlay3Impl_EnumGroupPlayers(), IDirectPlay3Impl_EnumGroups(), IDirectPlay3Impl_EnumGroupsInGroup(), IDirectPlay3Impl_EnumPlayers(), IDirectPlay4AImpl_EnumGroupPlayers(), IDirectPlay4AImpl_EnumGroups(), IDirectPlay4AImpl_EnumGroupsInGroup(), IDirectPlay4AImpl_EnumPlayers(), IDirectPlay4Impl_EnumGroupPlayers(), IDirectPlay4Impl_EnumGroups(), IDirectPlay4Impl_EnumGroupsInGroup(), IDirectPlay4Impl_EnumPlayers(), impl_from_TP_CALLBACK_INSTANCE(), instance_semaphore_completion_cb(), ldap_cleanup(), ldap_startup(), load_string(), LoadStringA(), LoadStringW(), map_A_to_W(), map_W_to_A(), MPEG3_StreamClose(), MPEG3_StreamConvert(), MPEG3_StreamOpen(), NPP_Destroy(), NPP_New(), NPP_SetWindow(), PdhMakeCounterPathW(), PerfCreateInstance(), PerfDeleteInstance(), PerfSetCounterRefValue(), property_set_Get(), property_set_Set(), RoActivateInstance(), setOidWithItemAndInteger(), simple_group_cancel_cb(), SortTest::sort4(), START_TEST(), task_callback(), test_build_action_map(), test_desktop_winproc(), test_parser(), test_progman_dde(), test_progman_dde2(), test_provider_init(), test_request_groups(), time_stamp_callback(), tp_io_callback(), tp_object_execute(), TpCallbackLeaveCriticalSectionOnCompletion(), TpCallbackMayRunLong(), TpCallbackReleaseMutexOnCompletion(), TpCallbackReleaseSemaphoreOnCompletion(), TpCallbackSetEventOnCompletion(), TpCallbackUnloadDllOnCompletion(), TpDisassociateCallback(), vkd3d_create_device(), vkd3d_create_instance(), vkd3d_create_thread(), vkd3d_destroy_instance(), vkd3d_init_debug_report(), vkd3d_init_instance_caps(), vkd3d_init_vk_global_procs(), vkd3d_instance_decref(), vkd3d_instance_get_vk_instance(), vkd3d_instance_incref(), vkd3d_instance_init(), vkd3d_join_thread(), vkd3d_load_vk_instance_procs(), vkd3d_select_physical_device(), VSSAPI_CVssWriter_Initialize(), and wined3d_init_vulkan().

◆ object_creation

const struct object_creation_info object_creation[]
static
Initial value:
=
{
{ &CLSID_DirectDraw, CF_CreateDirectDraw },
{ &CLSID_DirectDraw7, CF_CreateDirectDraw },
{ &CLSID_DirectDrawClipper, CF_CreateDirectDrawClipper }
}
static HRESULT CF_CreateDirectDrawClipper(IUnknown *UnkOuter, REFIID riid, void **obj)
Definition: main.c:583
static HRESULT CF_CreateDirectDraw(IUnknown *UnkOuter, REFIID iid, void **obj)
Definition: main.c:554

Definition at line 607 of file main.c.