ReactOS 0.4.15-dev-7924-g5949c20
main.c File Reference
#include "config.h"
#include "wine/port.h"
#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)
 
voidddraw_free_handle (struct ddraw_handle_table *t, DWORD handle, enum ddraw_handle_type type)
 
voidddraw_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 **DD, IUnknown *UnkOuter, 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_factoryimpl_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)
 
HRESULT WINAPI DllCanUnloadNow (void)
 
HRESULT WINAPI DllRegisterServer (void)
 
HRESULT WINAPI DllUnregisterServer (void)
 
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
 
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 27 of file main.c.

Function Documentation

◆ CF_CreateDirectDraw()

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

Definition at line 530 of file main.c.

532{
533 HRESULT hr;
534
535 TRACE("outer_unknown %p, riid %s, object %p.\n", UnkOuter, debugstr_guid(iid), obj);
536
538 hr = DDRAW_Create(NULL, obj, UnkOuter, iid);
540
541 return hr;
542}
#define NULL
Definition: types.h:112
static HRESULT DDRAW_Create(const GUID *guid, void **DD, IUnknown *UnkOuter, REFIID iid)
Definition: main.c:260
#define debugstr_guid
Definition: kernel32.h:35
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368

◆ CF_CreateDirectDrawClipper()

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

Definition at line 559 of file main.c.

561{
562 HRESULT hr;
563 IDirectDrawClipper *Clip;
564
565 TRACE("outer_unknown %p, riid %s, object %p.\n", UnkOuter, debugstr_guid(riid), obj);
566
568 hr = DirectDrawCreateClipper(0, &Clip, UnkOuter);
569 if (hr != DD_OK)
570 {
572 return hr;
573 }
574
575 hr = IDirectDrawClipper_QueryInterface(Clip, riid, obj);
576 IDirectDrawClipper_Release(Clip);
577
579
580 return hr;
581}
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:186

◆ ddraw_allocate_handle()

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

Definition at line 113 of file main.c.

114{
116
117 if (t->free_entries)
118 {
119 DWORD idx = t->free_entries - t->entries;
120 /* Use a free handle */
121 entry = t->free_entries;
122 if (entry->type != DDRAW_HANDLE_FREE)
123 {
124 ERR("Handle %#x (%p) is in the free list, but has type %#x.\n", idx, entry->object, entry->type);
126 }
127 t->free_entries = entry->object;
128 entry->object = object;
129 entry->type = type;
130
131 return idx;
132 }
133
134 if (!(t->entry_count < t->table_size))
135 {
136 /* Grow the table */
137 UINT new_size = t->table_size + (t->table_size >> 1);
138 struct ddraw_handle_entry *new_entries;
139
140 if (!(new_entries = heap_realloc(t->entries, new_size * sizeof(*t->entries))))
141 {
142 ERR("Failed to grow the handle table.\n");
144 }
145 t->entries = new_entries;
146 t->table_size = new_size;
147 }
148
149 entry = &t->entries[t->entry_count];
150 entry->object = object;
151 entry->type = type;
152
153 return t->entry_count++;
154}
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:71
#define ERR(fmt,...)
Definition: debug.h:110
#define DDRAW_INVALID_HANDLE
@ DDRAW_HANDLE_FREE
unsigned int idx
Definition: utils.c:41
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble GLdouble t
Definition: gl.h:2047
uint32_t entry
Definition: isohybrid.c:63
unsigned int UINT
Definition: ndis.h:50
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 643 of file main.c.

644{
647
648 TRACE("%p increasing refcount to %u.\n", factory, ref);
649
650 return ref;
651}
#define InterlockedIncrement
Definition: armddk.h:53
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: main.c:63
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 689 of file main.c.

691{
693
694 TRACE("iface %p, outer_unknown %p, riid %s, out %p.\n",
695 iface, outer_unknown, debugstr_guid(riid), out);
696
697 return factory->pfnCreateInstance(outer_unknown, riid, out);
698}
static FILE * out
Definition: regtests2xml.c:44

◆ ddraw_class_factory_LockServer()

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

Definition at line 712 of file main.c.

713{
714 FIXME("iface %p, dolock %#x stub!\n", iface, dolock);
715
716 return S_OK;
717}
#define FIXME(fmt,...)
Definition: debug.h:111
#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 617 of file main.c.

618{
619 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
620
623 {
624 IClassFactory_AddRef(iface);
625 *out = iface;
626 return S_OK;
627 }
628
629 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
630
631 return E_NOINTERFACE;
632}
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define WARN(fmt,...)
Definition: debug.h:112
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ ddraw_class_factory_Release()

static ULONG WINAPI ddraw_class_factory_Release ( IClassFactory iface)
static

Definition at line 663 of file main.c.

664{
667
668 TRACE("%p decreasing refcount to %u.\n", factory, ref);
669
670 if (!ref)
672
673 return ref;
674}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define InterlockedDecrement
Definition: armddk.h:52

◆ DDRAW_Create()

static HRESULT DDRAW_Create ( const GUID guid,
void **  DD,
IUnknown UnkOuter,
REFIID  iid 
)
static

Definition at line 260 of file main.c.

264{
266 struct ddraw *ddraw;
267 HRESULT hr;
268 DWORD flags = 0;
269
270 TRACE("driver_guid %s, ddraw %p, outer_unknown %p, interface_iid %s.\n",
271 debugstr_guid(guid), DD, UnkOuter, debugstr_guid(iid));
272
273 *DD = NULL;
274
276 {
277 /* Use the reference device id. This doesn't actually change anything,
278 * WineD3D always uses OpenGL for D3D rendering. One could make it request
279 * indirect rendering
280 */
282 }
283 else if(guid == (GUID *) DDCREATE_HARDWAREONLY)
284 {
286 }
287 else
288 {
289 device_type = 0;
290 }
291
292 /* DDraw doesn't support aggregation, according to msdn */
293 if (UnkOuter != NULL)
295
296 if (!IsEqualGUID(iid, &IID_IDirectDraw7))
298
299 /* DirectDraw creation comes here */
300 if (!(ddraw = heap_alloc_zero(sizeof(*ddraw))))
301 {
302 ERR("Out of memory when creating DirectDraw\n");
303 return E_OUTOFMEMORY;
304 }
305
307 if (FAILED(hr))
308 {
309 WARN("Failed to initialize ddraw object, hr %#x.\n", hr);
311 return hr;
312 }
313
314 hr = IDirectDraw7_QueryInterface(&ddraw->IDirectDraw7_iface, iid, DD);
315 IDirectDraw7_Release(&ddraw->IDirectDraw7_iface);
316 if (SUCCEEDED(hr))
318 else
319 WARN("Failed to query interface %s from ddraw object %p.\n", debugstr_guid(iid), ddraw);
320
321 return hr;
322}
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:5048
static struct list global_ddraw_list
Definition: main.c:36
#define DD(x)
GLbitfield flags
Definition: glext.h:7161
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
const GUID * guid
#define DDCREATE_HARDWAREONLY
Definition: ddraw.h:198
#define DDCREATE_EMULATIONONLY
Definition: ddraw.h:199
IDirectDraw7 IDirectDraw7_iface
Definition: ddraw_private.h:79
struct list ddraw_list_entry
#define WINED3D_LEGACY_FFP_LIGHTING
Definition: wined3d.h:1323
wined3d_device_type
Definition: wined3d.h:86
@ WINED3D_DEVICE_TYPE_HAL
Definition: wined3d.h:87
@ WINED3D_DEVICE_TYPE_REF
Definition: wined3d.h:88
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662

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 59 of file main.c.

61{
62 struct wined3d_adapter_identifier adapter_id;
63 struct wined3d_output_desc output_desc;
64 BOOL cont_enum = TRUE;
65 HRESULT hr = S_OK;
66 UINT adapter = 0;
67
68 for (adapter = 0; SUCCEEDED(hr) && cont_enum; adapter++)
69 {
70 char DriverName[512] = "", DriverDescription[512] = "";
71
72 /* The Battle.net System Checker expects the GetAdapterIdentifier DeviceName to match the
73 * Driver Name, so obtain the DeviceName and GUID from D3D. */
74 memset(&adapter_id, 0x0, sizeof(adapter_id));
75 adapter_id.device_name = DriverName;
76 adapter_id.device_name_size = sizeof(DriverName);
77 adapter_id.description = DriverDescription;
78 adapter_id.description_size = sizeof(DriverDescription);
81 hr = wined3d_get_output_desc(wined3d, adapter, &output_desc);
83 if (SUCCEEDED(hr))
84 {
85 TRACE("Interface %d: %s\n", adapter, wine_dbgstr_guid(&adapter_id.device_identifier));
86 cont_enum = callback(&adapter_id.device_identifier, adapter_id.description,
87 adapter_id.device_name, context, output_desc.monitor);
88 }
89 }
90}
#define TRUE
Definition: types.h:120
unsigned int BOOL
Definition: ntddk_ex.h:94
return adapter
static IPrintDialogCallback callback
Definition: printdlg.c:326
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197
#define memset(x, y, z)
Definition: compat.h:39
Definition: http.c:7252
HRESULT CDECL wined3d_get_output_desc(const struct wined3d *wined3d, unsigned int adapter_idx, struct wined3d_output_desc *desc)
Definition: directx.c:4499
HRESULT CDECL wined3d_get_adapter_identifier(const struct wined3d *wined3d, UINT adapter_idx, DWORD flags, struct wined3d_adapter_identifier *identifier)
Definition: directx.c:4939

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 156 of file main.c.

157{
159 void *object;
160
161 if (handle == DDRAW_INVALID_HANDLE || handle >= t->entry_count)
162 {
163 WARN("Invalid handle %#x passed.\n", handle);
164 return NULL;
165 }
166
167 entry = &t->entries[handle];
168 if (entry->type != type)
169 {
170 WARN("Handle %#x (%p) is not of type %#x.\n", handle, entry->object, type);
171 return NULL;
172 }
173
174 object = entry->object;
175 entry->object = t->free_entries;
176 entry->type = DDRAW_HANDLE_FREE;
177 t->free_entries = entry;
178
179 return object;
180}

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 182 of file main.c.

183{
185
186 if (handle == DDRAW_INVALID_HANDLE || handle >= t->entry_count)
187 {
188 WARN("Invalid handle %#x passed.\n", handle);
189 return NULL;
190 }
191
192 entry = &t->entries[handle];
193 if (entry->type != type)
194 {
195 WARN("Handle %#x (%p) is not of type %#x.\n", handle, entry->object, type);
196 return NULL;
197 }
198
199 return entry->object;
200}

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 107 of file main.c.

108{
109 heap_free(t->entries);
110 memset(t, 0, sizeof(*t));
111}

Referenced by d3d_device_init(), and d3d_device_inner_Release().

◆ ddraw_handle_table_init()

BOOL ddraw_handle_table_init ( struct ddraw_handle_table t,
UINT  initial_size 
)

Definition at line 93 of file main.c.

94{
95 if (!(t->entries = heap_alloc_zero(initial_size * sizeof(*t->entries))))
96 {
97 ERR("Failed to allocate handle table memory.\n");
98 return FALSE;
99 }
100 t->free_entries = NULL;
101 t->table_size = initial_size;
102 t->entry_count = 0;
103
104 return TRUE;
105}
#define FALSE
Definition: types.h:117

Referenced by d3d_device_init().

◆ DirectDrawCreate()

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

Definition at line 333 of file main.c.

334{
335 HRESULT hr;
336
337 TRACE("driver_guid %s, ddraw %p, outer %p.\n",
338 debugstr_guid(driver_guid), ddraw, outer);
339
341 hr = DDRAW_Create(driver_guid, (void **)ddraw, outer, &IID_IDirectDraw);
343
344 if (SUCCEEDED(hr))
345 {
346 if (FAILED(hr = IDirectDraw_Initialize(*ddraw, driver_guid)))
347 IDirectDraw_Release(*ddraw);
348 }
349
350 return hr;
351}

◆ DirectDrawCreateEx()

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

Definition at line 362 of file main.c.

364{
365 HRESULT hr;
366
367 TRACE("driver_guid %s, ddraw %p, interface_iid %s, outer %p.\n",
368 debugstr_guid(driver_guid), ddraw, debugstr_guid(interface_iid), outer);
369
370 if (!IsEqualGUID(interface_iid, &IID_IDirectDraw7))
371 return DDERR_INVALIDPARAMS;
372
374 hr = DDRAW_Create(driver_guid, ddraw, outer, interface_iid);
376
377 if (SUCCEEDED(hr))
378 {
379 IDirectDraw7 *ddraw7 = *(IDirectDraw7 **)ddraw;
380 hr = IDirectDraw7_Initialize(ddraw7, driver_guid);
381 if (FAILED(hr))
382 IDirectDraw7_Release(ddraw7);
383 }
384
385 return hr;
386}
DWORD IDirectDraw7
Definition: vmrender.idl:21
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79

◆ DirectDrawEnumerateA()

HRESULT WINAPI DirectDrawEnumerateA ( LPDDENUMCALLBACKA  callback,
void context 
)

Definition at line 408 of file main.c.

409{
410 struct callback_info info;
411
412 TRACE("callback %p, context %p.\n", callback, context);
413
414 info.callback = callback;
415 info.context = context;
417}
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:51
void * context
Definition: main.c:47

◆ DirectDrawEnumerateExA()

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

Definition at line 428 of file main.c.

429{
430 struct wined3d *wined3d;
431
432 TRACE("callback %p, context %p, flags %#x.\n", callback, context, flags);
433
437 return DDERR_INVALIDPARAMS;
438
440 FIXME("flags 0x%08x not handled\n", flags & ~DDENUM_ATTACHEDSECONDARYDEVICES);
441
442 TRACE("Enumerating ddraw interfaces\n");
444 {
446 {
447 WARN("Failed to create a wined3d object.\n");
448 return E_FAIL;
449 }
450
451 WARN("Created a wined3d object without 3D support.\n");
452 }
453
454 __TRY
455 {
456 /* QuickTime expects the description "DirectDraw HAL" */
457 static CHAR driver_desc[] = "DirectDraw HAL",
458 driver_name[] = "display";
459 BOOL cont_enum;
460
461 TRACE("Default interface: DirectDraw HAL\n");
462 cont_enum = callback(NULL, driver_desc, driver_name, context, 0);
463
464 /* The Battle.net System Checker expects both a NULL device and a GUID-based device */
465 if (cont_enum && (flags & DDENUM_ATTACHEDSECONDARYDEVICES))
467 }
469 {
471 return DDERR_INVALIDPARAMS;
472 }
473 __ENDTRY;
474
476 TRACE("End of enumeration\n");
477 return DD_OK;
478}
#define DDRAW_WINED3D_FLAGS
Definition: ddraw_private.h:64
#define E_FAIL
Definition: ddrawi.h:102
static void ddraw_enumerate_secondary_devices(struct wined3d *wined3d, LPDDENUMCALLBACKEXA callback, void *context)
Definition: main.c:59
#define __TRY
Definition: compat.h:80
#define __ENDTRY
Definition: compat.h:82
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:81
#define DDENUM_ATTACHEDSECONDARYDEVICES
Definition: ddraw.h:191
#define DDENUM_DETACHEDSECONDARYDEVICES
Definition: ddraw.h:192
#define DDENUM_NONDISPLAYDEVICES
Definition: ddraw.h:193
ULONG CDECL wined3d_decref(struct wined3d *wined3d)
Definition: directx.c:465
#define WINED3D_NO3D
Definition: wined3d.h:1316
struct wined3d *CDECL wined3d_create(DWORD flags)
Definition: wined3d_main.c:97
char CHAR
Definition: xmlstorage.h:175

◆ DirectDrawEnumerateExW()

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

Definition at line 504 of file main.c.

505{
506 TRACE("callback %p, context %p, flags %#x.\n", callback, context, flags);
507
508 return DDERR_UNSUPPORTED;
509}
#define DDERR_UNSUPPORTED
Definition: ddraw.h:127

◆ DirectDrawEnumerateW()

HRESULT WINAPI DirectDrawEnumerateW ( LPDDENUMCALLBACKW  callback,
void context 
)

Definition at line 487 of file main.c.

488{
489 TRACE("callback %p, context %p.\n", callback, context);
490
491 if (!callback)
492 return DDERR_INVALIDPARAMS;
493 else
494 return DDERR_UNSUPPORTED;
495}

◆ DllCanUnloadNow()

HRESULT WINAPI DllCanUnloadNow ( void  )

Definition at line 775 of file main.c.

776{
777 TRACE("\n");
778
779 return S_FALSE;
780}
#define S_FALSE
Definition: winerror.h:2357

◆ DllGetClassObject()

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

Definition at line 731 of file main.c.

732{
734 unsigned int i;
735
736 TRACE("rclsid %s, riid %s, out %p.\n",
738
741 return E_NOINTERFACE;
742
743 for (i=0; i < ARRAY_SIZE(object_creation); i++)
744 {
745 if (IsEqualGUID(object_creation[i].clsid, rclsid))
746 break;
747 }
748
750 {
751 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
753 }
754
755 if (!(factory = heap_alloc_zero(sizeof(*factory))))
756 return E_OUTOFMEMORY;
757
759 factory->ref = 1;
760
761 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
762
763 *out = factory;
764 return S_OK;
765}
#define ARRAY_SIZE(A)
Definition: main.h:33
static const struct object_creation_info object_creation[]
Definition: main.c:74
static const IClassFactoryVtbl IClassFactory_Vtbl
Definition: main.c:722
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
REFCLSID clsid
Definition: msctf.c:82
IClassFactory IClassFactory_iface
Definition: main.c:440
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663

◆ DllMain()

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

Definition at line 801 of file main.c.

802{
803 switch (reason)
804 {
806 {
807 static HMODULE ddraw_self;
808 HKEY hkey = 0;
809 WNDCLASSA wc;
810
811 /* Register the window class. This is used to create a hidden window
812 * for D3D rendering, if the application didn't pass one. It can also
813 * be used for creating a device window from SetCooperativeLevel(). */
816 wc.cbClsExtra = 0;
817 wc.cbWndExtra = 0;
818 wc.hInstance = inst;
819 wc.hIcon = 0;
820 wc.hCursor = 0;
822 wc.lpszMenuName = NULL;
824 if (!RegisterClassA(&wc))
825 {
826 ERR("Failed to register ddraw window class, last error %#x.\n", GetLastError());
827 return FALSE;
828 }
829
830 /* On Windows one can force the refresh rate that DirectDraw uses by
831 * setting an override value in dxdiag. This is documented in KB315614
832 * (main article), KB230002, and KB217348. By comparing registry dumps
833 * before and after setting the override, we see that the override value
834 * is stored in HKLM\Software\Microsoft\DirectDraw\ForceRefreshRate as a
835 * DWORD that represents the refresh rate to force. We use this
836 * registry entry to modify the behavior of SetDisplayMode so that Wine
837 * users can override the refresh rate in a Windows-compatible way.
838 *
839 * dxdiag will not accept a refresh rate lower than 40 or higher than
840 * 120 so this value should be within that range. It is, of course,
841 * possible for a user to set the registry entry value directly so that
842 * assumption might not hold.
843 *
844 * There is no current mechanism for setting this value through the Wine
845 * GUI. It would be most appropriate to set this value through a dxdiag
846 * clone, but it may be sufficient to use winecfg.
847 *
848 * TODO: Create a mechanism for setting this value through the Wine GUI.
849 */
850 if ( !RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Microsoft\\DirectDraw", &hkey ) )
851 {
853
854 size = sizeof(data);
855 if (!RegQueryValueExA(hkey, "ForceRefreshRate", NULL, &type, (BYTE *)&data, &size) && type == REG_DWORD)
856 {
857 TRACE("ForceRefreshRate set; overriding refresh rate to %d Hz\n", data);
859 }
860 RegCloseKey( hkey );
861 }
862
863 /* Prevent the ddraw module from being unloaded. When switching to
864 * exclusive mode, we replace the window proc of the ddraw window. If
865 * an application would unload ddraw from the WM_DESTROY handler for
866 * that window, it would return to unmapped memory and die. Apparently
867 * this is supposed to work on Windows. */
868
869 /* ReactOS r61844: Comment out usage of GET_MODULE_HANDLE_EX_FLAG_PIN because it doesn't work */
870 if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS /*| GET_MODULE_HANDLE_EX_FLAG_PIN*/,
871 (const WCHAR *)&ddraw_self, &ddraw_self))
872 ERR("Failed to get own module handle.\n");
873
874 instance = inst;
876 break;
877 }
878
880 if (WARN_ON(ddraw))
881 {
882 struct ddraw *ddraw;
883
885 {
886 struct ddraw_surface *surface;
887
888 WARN("DirectDraw object %p has reference counts {%u, %u, %u, %u, %u}.\n",
890
891 if (ddraw->d3ddevice)
892 WARN("DirectDraw object %p has Direct3D device %p attached.\n", ddraw, ddraw->d3ddevice);
893
895 {
896 WARN("Surface %p has reference counts {%u, %u, %u, %u, %u, %u}.\n",
897 surface, surface->ref7, surface->ref4, surface->ref3,
898 surface->ref2, surface->ref1, surface->gamma_count);
899 }
900 }
901 }
902
903 if (reserved) break;
905 }
906
907 return TRUE;
908}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define DDRAW_WINDOW_CLASS_NAME
static HINSTANCE instance
Definition: main.c:40
DWORD force_refresh_rate
Definition: main.c:41
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:1904
#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
#define REG_DWORD
Definition: sdbapi.c:596
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
HBRUSH hbrBackground
Definition: winuser.h:3170
HICON hIcon
Definition: winuser.h:3168
HINSTANCE hInstance
Definition: winuser.h:3167
HCURSOR hCursor
Definition: winuser.h:3169
int cbWndExtra
Definition: winuser.h:3166
UINT style
Definition: winuser.h:3163
LPCSTR lpszMenuName
Definition: winuser.h:3171
LPCSTR lpszClassName
Definition: winuser.h:3172
WNDPROC lpfnWndProc
Definition: winuser.h:3164
int cbClsExtra
Definition: winuser.h:3165
struct list surface_list_entry
struct d3d_device * d3ddevice
LONG ref1
Definition: ddraw_private.h:90
LONG ref7
Definition: ddraw_private.h:90
struct list surface_list
LONG ref4
Definition: ddraw_private.h:90
LONG ref2
Definition: ddraw_private.h:90
LONG ref3
Definition: ddraw_private.h:90
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
#define CS_VREDRAW
Definition: winuser.h:658
BOOL WINAPI UnregisterClassA(_In_ LPCSTR, HINSTANCE)
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CS_HREDRAW
Definition: winuser.h:653
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193

◆ DllRegisterServer()

HRESULT WINAPI DllRegisterServer ( void  )

Definition at line 783 of file main.c.

784{
786}
HRESULT __wine_register_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:98

◆ DllUnregisterServer()

HRESULT WINAPI DllUnregisterServer ( void  )

Definition at line 788 of file main.c.

789{
791}
HRESULT __wine_unregister_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:110

◆ enum_callback()

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

Definition at line 51 of file main.c.

53{
54 const struct callback_info *info = context;
55
56 return info->callback(guid, description, driver_name, info->context);
57}
const char * description
Definition: directx.c:2497

Referenced by DirectDrawEnumerateA().

◆ GetSurfaceFromDC()

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

Definition at line 202 of file main.c.

203{
204 struct ddraw *ddraw;
205
206 TRACE("dc %p, surface %p, device_dc %p.\n", dc, surface, device_dc);
207
208 if (!surface)
209 return E_INVALIDARG;
210
211 if (!device_dc)
212 {
213 *surface = NULL;
214
215 return E_INVALIDARG;
216 }
217
220 {
221 if (FAILED(IDirectDraw4_GetSurfaceFromDC(&ddraw->IDirectDraw4_iface, dc, surface)))
222 continue;
223
224 *device_dc = NULL; /* FIXME */
226 return DD_OK;
227 }
229
230 *surface = NULL;
231 *device_dc = NULL;
232
233 return DDERR_NOTFOUND;
234}
#define E_INVALIDARG
Definition: ddrawi.h:101
static const WCHAR dc[]
#define DDERR_NOTFOUND
Definition: ddraw.h:97
IDirectDraw4 IDirectDraw4_iface
Definition: ddraw_private.h:80

◆ impl_from_IClassFactory()

static struct ddraw_class_factory * impl_from_IClassFactory ( IClassFactory iface)
inlinestatic

Definition at line 598 of file main.c.

599{
600 return CONTAINING_RECORD(iface, struct ddraw_class_factory, IClassFactory_iface);
601}
#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 41 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 36 of file main.c.

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

◆ IClassFactory_Vtbl

const IClassFactoryVtbl IClassFactory_Vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI ddraw_class_factory_LockServer(IClassFactory *iface, BOOL dolock)
Definition: main.c:712
static HRESULT WINAPI ddraw_class_factory_QueryInterface(IClassFactory *iface, REFIID riid, void **out)
Definition: main.c:617
static ULONG WINAPI ddraw_class_factory_AddRef(IClassFactory *iface)
Definition: main.c:643
static HRESULT WINAPI ddraw_class_factory_CreateInstance(IClassFactory *iface, IUnknown *outer_unknown, REFIID riid, void **out)
Definition: main.c:689
static ULONG WINAPI ddraw_class_factory_Release(IClassFactory *iface)
Definition: main.c:663

Definition at line 722 of file main.c.

Referenced by DllGetClassObject().

◆ instance

HINSTANCE instance
static

Definition at line 38 of file main.c.

◆ 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:559
static HRESULT CF_CreateDirectDraw(IUnknown *UnkOuter, REFIID iid, void **obj)
Definition: main.c:530

Definition at line 583 of file main.c.