wrong size of memory was alloc in startup.c
[reactos.git] / reactos / dll / directx / ddraw / startup.c
1 /* $Id: main.c 21434 2006-04-01 19:12:56Z greatlrd $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: lib/ddraw/ddraw.c
6 * PURPOSE: DirectDraw Library
7 * PROGRAMMER: Magnus Olsen (greatlrd)
8 *
9 */
10
11 #include "rosdraw.h"
12 #include "ddrawgdi.h"
13
14 DDRAWI_DIRECTDRAW_GBL ddgbl;
15 DDRAWI_DIRECTDRAW_INT primaryDirectDrawInt;
16 DDRAWI_DDRAWSURFACE_GBL ddSurfGbl;
17
18 WCHAR classname[128];
19 WNDCLASSW wnd_class;
20
21
22 HRESULT WINAPI
23 Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface,
24 REFIID id, BOOL ex)
25 {
26 LPDDRAWI_DIRECTDRAW_INT This;
27
28 DX_WINDBG_trace();
29
30 if ((IsBadReadPtr(pIface,sizeof(LPDIRECTDRAW))) ||
31 (IsBadWritePtr(pIface,sizeof(LPDIRECTDRAW))))
32 {
33 return DDERR_INVALIDPARAMS;
34 }
35
36 DX_STUB_str("here\n");
37
38 This = (LPDDRAWI_DIRECTDRAW_INT)*pIface;
39
40 /* fixme linking too second link when we shall not doing it */
41 if (IsBadReadPtr(This,sizeof(LPDIRECTDRAW)))
42 {
43 DX_STUB_str("1. no linking\n");
44 /* We do not have a DirectDraw interface, we need alloc it*/
45 LPDDRAWI_DIRECTDRAW_INT memThis;
46
47 DX_STUB_str("here\n");
48
49 memThis = &primaryDirectDrawInt;
50
51 RtlZeroMemory(memThis, sizeof(DDRAWI_DIRECTDRAW_INT));
52
53 DX_STUB_str("here\n")
54
55 if (memThis == NULL)
56 {
57 DX_STUB_str("DDERR_OUTOFMEMORY\n");
58 return DDERR_OUTOFMEMORY;
59 }
60
61 This = memThis;
62
63
64 DX_STUB_str("here\n");
65
66 /* Fixme release memory alloc if we fail */
67
68 DxHeapMemAlloc(This->lpLcl, sizeof(DDRAWI_DIRECTDRAW_LCL));
69 if (This->lpLcl == NULL)
70 {
71 DX_STUB_str("DDERR_OUTOFMEMORY\n");
72 return DDERR_OUTOFMEMORY;
73 }
74
75 DX_STUB_str("here\n");
76 }
77 else
78 {
79 DX_STUB_str("2.linking\n");
80 /* We got the DirectDraw interface alloc and we need create the link */
81 LPDDRAWI_DIRECTDRAW_INT newThis;
82
83 DX_STUB_str("here\n");
84
85 /* step 1.Alloc the new DDRAWI_DIRECTDRAW_INT for the lnking */
86 DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
87 if (newThis == NULL)
88 {
89 DX_STUB_str("DDERR_OUTOFMEMORY\n");
90 return DDERR_OUTOFMEMORY;
91 }
92
93 DX_STUB_str("here\n");
94
95 /* step 2 check if it not DDCREATE_HARDWAREONLY we got if so we fail */
96 if ((pGUID) && (pGUID != (LPGUID)DDCREATE_HARDWAREONLY))
97 {
98 if (pGUID !=NULL)
99 {
100 This = newThis;
101 DX_STUB_str("DDERR_INVALIDDIRECTDRAWGUID\n");
102 return DDERR_INVALIDDIRECTDRAWGUID;
103 }
104 }
105
106 DX_STUB_str("here\n");
107
108 /* step 3 do the link the old interface are store in the new one */
109 newThis->lpLink = This;
110
111 /* step 4 we need create new local directdraw struct for the new linked interface */
112 DxHeapMemAlloc(newThis->lpLcl, sizeof(DDRAWI_DIRECTDRAW_LCL));
113 if (newThis->lpLcl == NULL)
114 {
115 This = newThis;
116 DX_STUB_str("DDERR_OUTOFMEMORY\n");
117 return DDERR_OUTOFMEMORY;
118 }
119
120 DX_STUB_str("here\n");
121
122 This = newThis;
123 }
124
125
126 This->lpLcl->lpGbl = &ddgbl;
127
128 *pIface = (LPDIRECTDRAW)This;
129
130 /* Get right interface we whant */
131 if (Main_DirectDraw_QueryInterface((LPDIRECTDRAW7)This, id, (void**)&pIface) == DD_OK)
132 {
133 DX_STUB_str("Got iface\n");
134
135 if (StartDirectDraw((LPDIRECTDRAW)This, pGUID, FALSE) == DD_OK);
136 {
137 /*
138 RtlZeroMemory(&wnd_class, sizeof(wnd_class));
139 wnd_class.style = CS_HREDRAW | CS_VREDRAW;
140 wnd_class.lpfnWndProc = DefWindowProcW;
141 wnd_class.cbClsExtra = 0;
142 wnd_class.cbWndExtra = 0;
143 wnd_class.hInstance = GetModuleHandleW(0);
144 wnd_class.hIcon = 0;
145 wnd_class.hCursor = 0;
146 wnd_class.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
147 wnd_class.lpszMenuName = NULL;
148 wnd_class.lpszClassName = classname;
149 if(!RegisterClassW(&wnd_class))
150 {
151 DX_STUB_str("DDERR_GENERIC");
152 return DDERR_GENERIC;
153 }
154 */
155
156 DX_STUB_str("DD_OK\n");
157 return DD_OK;
158 }
159 }
160
161 DX_STUB_str("DDERR_INVALIDPARAMS\n");
162 return DDERR_INVALIDPARAMS;
163 }
164
165
166 HRESULT WINAPI
167 StartDirectDraw(LPDIRECTDRAW iface, LPGUID lpGuid, BOOL reenable)
168 {
169 LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
170 DWORD hal_ret = DD_FALSE;
171 DWORD hel_ret = DD_FALSE;
172 DWORD devicetypes = 0;
173 DWORD dwFlags = 0;
174
175 DX_WINDBG_trace();
176
177 /*
178 * ddgbl.dwPDevice is not longer in use in windows 2000 and higher
179 * I am using it for device type
180 * devicetypes = 1 : both hal and hel are enable
181 * devicetypes = 2 : both hal are enable
182 * devicetypes = 3 : both hel are enable
183 * devicetypes = 4 :loading a guid drv from the register
184 */
185
186 if (reenable == FALSE)
187 {
188 if ((!IsBadReadPtr(This->lpLink,sizeof(LPDIRECTDRAW))) && (This->lpLink == NULL))
189 {
190 RtlZeroMemory(&ddgbl, sizeof(DDRAWI_DIRECTDRAW_GBL));
191 This->lpLcl->lpGbl->dwRefCnt++;
192 if (ddgbl.lpDDCBtmp == NULL)
193 {
194 // LPDDHAL_CALLBACKS
195 DxHeapMemAlloc( ddgbl.lpDDCBtmp , sizeof(DDHAL_CALLBACKS));
196 if (ddgbl.lpDDCBtmp == NULL)
197 {
198 DX_STUB_str("Out of memmory\n");
199 return DD_FALSE;
200 }
201 }
202 }
203 }
204
205 DX_STUB_str("here\n");
206
207 if (reenable == FALSE)
208 {
209 if (lpGuid == NULL)
210 {
211 DX_STUB_str("lpGuid == NULL\n");
212 devicetypes= 1;
213
214 /* Create HDC for default, hal and hel driver */
215 This->lpLcl->hWnd = (ULONG_PTR) GetActiveWindow();
216 This->lpLcl->hDC = (ULONG_PTR) GetDC((HWND)This->lpLcl->hWnd);
217
218 /* cObsolete is undoc in msdn it being use in CreateDCA */
219 RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
220 RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7);
221 dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV;
222
223
224 }
225 else if (lpGuid == (LPGUID) DDCREATE_HARDWAREONLY)
226 {
227 devicetypes = 2;
228 /* Create HDC for default, hal driver */
229 This->lpLcl->hWnd =(ULONG_PTR) GetActiveWindow();
230 This->lpLcl->hDC = (ULONG_PTR) GetDC((HWND)This->lpLcl->hWnd);
231
232 /* cObsolete is undoc in msdn it being use in CreateDCA */
233 RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
234 RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7);
235 dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV;
236 }
237 else if (lpGuid == (LPGUID) DDCREATE_EMULATIONONLY)
238 {
239 devicetypes = 3;
240
241 /* Create HDC for default, hal and hel driver */
242 This->lpLcl->hWnd = (ULONG_PTR) GetActiveWindow();
243 This->lpLcl->hDC = (ULONG_PTR) GetDC((HWND)This->lpLcl->hWnd);
244
245 /* cObsolete is undoc in msdn it being use in CreateDCA */
246 RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
247 RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7);
248
249 dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV;
250 }
251 else
252 {
253 /* FIXME : need getting driver from the GUID that have been pass in from
254 * the register. we do not support that yet
255 */
256 devicetypes = 4;
257 This->lpLcl->hDC = (ULONG_PTR) NULL ;
258 This->lpLcl->hWnd = (ULONG_PTR) GetActiveWindow();
259 }
260
261 if ( (HDC)This->lpLcl->hDC == NULL)
262 {
263 DX_STUB_str("DDERR_OUTOFMEMORY\n");
264 return DDERR_OUTOFMEMORY ;
265 }
266 }
267
268 This->lpLcl->lpDDCB = ddgbl.lpDDCBtmp;
269
270 /* Startup HEL and HAL */
271 This->lpLcl->lpDDCB = This->lpLcl->lpGbl->lpDDCBtmp;
272 This->lpLcl->dwProcessId = GetCurrentProcessId();
273
274 switch (devicetypes)
275 {
276 case 2:
277 hal_ret = StartDirectDrawHal(iface, reenable);
278 This->lpLcl->lpDDCB->HELDD.dwFlags = 0;
279 break;
280
281 case 3:
282 hel_ret = StartDirectDrawHel(iface, reenable);
283 This->lpLcl->lpDDCB->HALDD.dwFlags = 0;
284 break;
285
286 default:
287 hal_ret = StartDirectDrawHal(iface, reenable);
288 hel_ret = StartDirectDrawHel(iface, reenable);
289 }
290
291 DX_STUB_str("return\n");
292
293 if (hal_ret!=DD_OK)
294 {
295 if (hel_ret!=DD_OK)
296 {
297 DX_STUB_str("DDERR_NODIRECTDRAWSUPPORT\n");
298 return DDERR_NODIRECTDRAWSUPPORT;
299 }
300 dwFlags |= DDRAWI_NOHARDWARE;
301 }
302
303 if (hel_ret!=DD_OK)
304 {
305 dwFlags |= DDRAWI_NOEMULATION;
306
307 }
308 else
309 {
310 dwFlags |= DDRAWI_EMULATIONINITIALIZED;
311 }
312
313 /* Fill some basic info for Surface */
314 This->lpLcl->lpGbl->dwFlags = dwFlags | DDRAWI_ATTACHEDTODESKTOP;
315 This->lpLcl->lpDDCB = This->lpLcl->lpGbl->lpDDCBtmp;
316 This->lpLcl->hDD = This->lpLcl->lpGbl->hDD;
317 ddgbl.hDD = This->lpLcl->lpGbl->hDD;
318
319 DX_STUB_str("DD_OK\n");
320 return DD_OK;
321 }
322
323 HRESULT WINAPI
324 StartDirectDrawHel(LPDIRECTDRAW iface, BOOL reenable)
325 {
326 LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
327
328 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CanCreateSurface = HelDdCanCreateSurface;
329 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CreateSurface = HelDdCreateSurface;
330 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CreatePalette = HelDdCreatePalette;
331 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.DestroyDriver = HelDdDestroyDriver;
332 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.FlipToGDISurface = HelDdFlipToGDISurface;
333 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.GetScanLine = HelDdGetScanLine;
334 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.SetColorKey = HelDdSetColorKey;
335 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.SetExclusiveMode = HelDdSetExclusiveMode;
336 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.SetMode = HelDdSetMode;
337 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.WaitForVerticalBlank = HelDdWaitForVerticalBlank;
338
339 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.dwFlags = DDHAL_CB32_CANCREATESURFACE |
340 DDHAL_CB32_CREATESURFACE |
341 DDHAL_CB32_CREATEPALETTE |
342 DDHAL_CB32_DESTROYDRIVER |
343 DDHAL_CB32_FLIPTOGDISURFACE |
344 DDHAL_CB32_GETSCANLINE |
345 DDHAL_CB32_SETCOLORKEY |
346 DDHAL_CB32_SETEXCLUSIVEMODE |
347 DDHAL_CB32_SETMODE |
348 DDHAL_CB32_WAITFORVERTICALBLANK ;
349
350 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.dwSize = sizeof(This->lpLcl->lpDDCB->HELDD);
351
352 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.AddAttachedSurface = HelDdSurfAddAttachedSurface;
353 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Blt = HelDdSurfBlt;
354 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.DestroySurface = HelDdSurfDestroySurface;
355 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Flip = HelDdSurfFlip;
356 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.GetBltStatus = HelDdSurfGetBltStatus;
357 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.GetFlipStatus = HelDdSurfGetFlipStatus;
358 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Lock = HelDdSurfLock;
359 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.reserved4 = HelDdSurfreserved4;
360 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetClipList = HelDdSurfSetClipList;
361 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetColorKey = HelDdSurfSetColorKey;
362 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetOverlayPosition = HelDdSurfSetOverlayPosition;
363 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetPalette = HelDdSurfSetPalette;
364 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Unlock = HelDdSurfUnlock;
365 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.UpdateOverlay = HelDdSurfUpdateOverlay;
366 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.dwFlags = DDHAL_SURFCB32_ADDATTACHEDSURFACE |
367 DDHAL_SURFCB32_BLT |
368 DDHAL_SURFCB32_DESTROYSURFACE |
369 DDHAL_SURFCB32_FLIP |
370 DDHAL_SURFCB32_GETBLTSTATUS |
371 DDHAL_SURFCB32_GETFLIPSTATUS |
372 DDHAL_SURFCB32_LOCK |
373 DDHAL_SURFCB32_RESERVED4 |
374 DDHAL_SURFCB32_SETCLIPLIST |
375 DDHAL_SURFCB32_SETCOLORKEY |
376 DDHAL_SURFCB32_SETOVERLAYPOSITION |
377 DDHAL_SURFCB32_SETPALETTE |
378 DDHAL_SURFCB32_UNLOCK |
379 DDHAL_SURFCB32_UPDATEOVERLAY;
380
381 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.dwSize = sizeof(This->lpLcl->lpDDCB->HELDDSurface);
382
383 /*
384 This->lpLcl->lpDDCB->HELDDPalette.DestroyPalette = HelDdPalDestroyPalette;
385 This->lpLcl->lpDDCB->HELDDPalette.SetEntries = HelDdPalSetEntries;
386 This->lpLcl->lpDDCB->HELDDPalette.dwSize = sizeof(This->lpLcl->lpDDCB->HELDDPalette);
387 */
388
389 /*
390 This->lpLcl->lpDDCB->HELDDExeBuf.CanCreateExecuteBuffer = HelDdExeCanCreateExecuteBuffer;
391 This->lpLcl->lpDDCB->HELDDExeBuf.CreateExecuteBuffer = HelDdExeCreateExecuteBuffer;
392 This->lpLcl->lpDDCB->HELDDExeBuf.DestroyExecuteBuffer = HelDdExeDestroyExecuteBuffer;
393 This->lpLcl->lpDDCB->HELDDExeBuf.LockExecuteBuffer = HelDdExeLockExecuteBuffer;
394 This->lpLcl->lpDDCB->HELDDExeBuf.UnlockExecuteBuffer = HelDdExeUnlockExecuteBuffer;
395 */
396
397 return DD_OK;
398 }
399
400
401 HRESULT WINAPI
402 StartDirectDrawHal(LPDIRECTDRAW iface, BOOL reenable)
403 {
404 LPDWORD mpFourCC = NULL;
405 DDHALINFO mHALInfo;
406 BOOL newmode = FALSE;
407 LPDDSURFACEDESC mpTextures;
408 D3DHAL_CALLBACKS mD3dCallbacks;
409 D3DHAL_GLOBALDRIVERDATA mD3dDriverData;
410 DDHAL_DDEXEBUFCALLBACKS mD3dBufferCallbacks;
411 LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
412
413 DX_WINDBG_trace();
414
415 RtlZeroMemory(&mHALInfo, sizeof(DDHALINFO));
416 RtlZeroMemory(&mD3dCallbacks, sizeof(D3DHAL_CALLBACKS));
417 RtlZeroMemory(&mD3dDriverData, sizeof(D3DHAL_GLOBALDRIVERDATA));
418 RtlZeroMemory(&mD3dBufferCallbacks, sizeof(DDHAL_DDEXEBUFCALLBACKS));
419
420 if (reenable == FALSE)
421 {
422 if (ddgbl.lpDDCBtmp == NULL)
423 {
424 DxHeapMemAlloc(ddgbl.lpDDCBtmp, sizeof(DDHAL_CALLBACKS));
425 if ( ddgbl.lpDDCBtmp == NULL)
426 {
427 return DD_FALSE;
428 }
429 }
430 }
431 else
432 {
433 RtlZeroMemory(ddgbl.lpDDCBtmp,sizeof(DDHAL_CALLBACKS));
434 }
435
436 /*
437 * Startup DX HAL step one of three
438 */
439 if (!DdCreateDirectDrawObject(This->lpLcl->lpGbl, (HDC)This->lpLcl->hDC))
440 {
441 DxHeapMemFree(ddgbl.lpDDCBtmp);
442 return DD_FALSE;
443 }
444
445 /* Some card disable the dx after it have been created so
446 * we are force reanble it
447 */
448 if (!DdReenableDirectDrawObject(This->lpLcl->lpGbl, &newmode))
449 {
450 DxHeapMemFree(ddgbl.lpDDCBtmp);
451 return DD_FALSE;
452 }
453
454 if (!DdQueryDirectDrawObject(This->lpLcl->lpGbl,
455 &mHALInfo,
456 &ddgbl.lpDDCBtmp->HALDD,
457 &ddgbl.lpDDCBtmp->HALDDSurface,
458 &ddgbl.lpDDCBtmp->HALDDPalette,
459 &mD3dCallbacks,
460 &mD3dDriverData,
461 &mD3dBufferCallbacks,
462 NULL,
463 mpFourCC,
464 NULL))
465 {
466 DxHeapMemFree(This->lpLcl->lpGbl->lpModeInfo);
467 DxHeapMemFree(ddgbl.lpDDCBtmp);
468 // FIXME Close DX fristcall and second call
469 return DD_FALSE;
470 }
471
472 #if 0
473 DX_STUB_str("Trying alloc FourCCC \n");
474
475 /* Alloc mpFourCC */
476 if (This->lpLcl->lpGbl->lpdwFourCC != NULL)
477 {
478 DxHeapMemFree(This->lpLcl->lpGbl->lpdwFourCC);
479 }
480
481 if (mHALInfo.ddCaps.dwNumFourCCCodes > 0 )
482 {
483 DxHeapMemAlloc(mpFourCC, sizeof(DWORD) * 21);
484
485 mpFourCC = (DWORD *) DxHeapMemAlloc(sizeof(DWORD) * (mHALInfo.ddCaps.dwNumFourCCCodes + 2));
486
487 if (mpFourCC == NULL)
488 {
489 DxHeapMemFree(ddgbl.lpDDCBtmp);
490 // FIXME Close DX fristcall and second call
491 return DD_FALSE;
492 }
493 }
494
495 DX_STUB_str("End Trying alloc FourCCC\n");
496 #endif
497
498
499
500
501 /* Alloc mpTextures */
502 #if 0
503 DX_STUB_str("1 Here\n");
504
505 if (This->lpLcl->lpGbl->texture != NULL)
506 {
507 DxHeapMemFree(This->lpLcl->lpGbl->texture;
508 }
509
510 mpTextures = NULL;
511 if (mD3dDriverData.dwNumTextureFormats > 0)
512 {
513 mpTextures = (DDSURFACEDESC*) DxHeapMemAlloc(sizeof(DDSURFACEDESC) * mD3dDriverData.dwNumTextureFormats);
514 if (mpTextures == NULL)
515 {
516 DxHeapMemFree(mpFourCC);
517 DxHeapMemFree(ddgbl.lpDDCBtmp);
518 // FIXME Close DX fristcall and second call
519 }
520 }
521
522 DX_STUB_str("2 Here\n");
523
524 #else
525 mpTextures = NULL;
526 #endif
527
528
529 /* Get all basic data from the driver */
530 if (!DdQueryDirectDrawObject(
531 This->lpLcl->lpGbl,
532 &mHALInfo,
533 &ddgbl.lpDDCBtmp->HALDD,
534 &ddgbl.lpDDCBtmp->HALDDSurface,
535 &ddgbl.lpDDCBtmp->HALDDPalette,
536 &mD3dCallbacks,
537 &mD3dDriverData,
538 &ddgbl.lpDDCBtmp->HALDDExeBuf,
539 (DDSURFACEDESC*)mpTextures,
540 mpFourCC,
541 NULL))
542 {
543 DxHeapMemFree(mpFourCC);
544 DxHeapMemFree(mpTextures);
545 DxHeapMemFree(ddgbl.lpDDCBtmp);
546 // FIXME Close DX fristcall and second call
547 return DD_FALSE;
548 }
549
550 memcpy(&ddgbl.vmiData, &mHALInfo.vmiData,sizeof(VIDMEMINFO));
551
552
553 memcpy(&ddgbl.ddCaps, &mHALInfo.ddCaps,sizeof(DDCORECAPS));
554
555 This->lpLcl->lpGbl->dwNumFourCC = mHALInfo.ddCaps.dwNumFourCCCodes;
556 This->lpLcl->lpGbl->lpdwFourCC = mpFourCC;
557 This->lpLcl->lpGbl->dwMonitorFrequency = mHALInfo.dwMonitorFrequency;
558 This->lpLcl->lpGbl->dwModeIndex = mHALInfo.dwModeIndex;
559 This->lpLcl->lpGbl->dwNumModes = mHALInfo.dwNumModes;
560 This->lpLcl->lpGbl->lpModeInfo = mHALInfo.lpModeInfo;
561
562 DX_STUB_str("Here\n");
563
564 /* FIXME convert mpTextures to DDHALMODEINFO */
565 // DxHeapMemFree( mpTextures);
566
567 /* FIXME D3D setup mD3dCallbacks and mD3dDriverData */
568 DDHAL_GETDRIVERINFODATA DdGetDriverInfo = { 0 };
569 DdGetDriverInfo.dwSize = sizeof (DDHAL_GETDRIVERINFODATA);
570 DdGetDriverInfo.guidInfo = GUID_MiscellaneousCallbacks;
571
572 DdGetDriverInfo.lpvData = (PVOID)&ddgbl.lpDDCBtmp->HALDDMiscellaneous;
573
574 DdGetDriverInfo.dwExpectedSize = sizeof (DDHAL_DDMISCELLANEOUSCALLBACKS);
575
576 if(mHALInfo.GetDriverInfo (&DdGetDriverInfo) == DDHAL_DRIVER_NOTHANDLED || DdGetDriverInfo.ddRVal != DD_OK)
577 {
578 DxHeapMemFree(mpFourCC);
579 DxHeapMemFree(mpTextures);
580 DxHeapMemFree(ddgbl.lpDDCBtmp);
581 // FIXME Close DX fristcall and second call
582 return DD_FALSE;
583 }
584
585 return DD_OK;
586 }