2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS DirectX
4 * FILE: dll/directx/ddraw/Ddraw/GetDeviceIdentifier.c
5 * PURPOSE: IDirectDraw7 Implementation
6 * PROGRAMMER: Magnus Olsen
11 * We need adding digtial signarture detections for the drivers
12 * and count out which level the signtature driver got, the value
13 * shall be save to pDDDI->dwWHQLLevel, But I do not known how todo
14 * this part yet, That is only missing feature in this functions
16 * Write a UML digram for this api
23 /* For DirectDraw 4 - 6 */
25 Main_DirectDraw_GetDeviceIdentifier(LPDDRAWI_DIRECTDRAW_INT This
,
26 LPDDDEVICEIDENTIFIER pDDDI
, DWORD dwFlags
)
28 HRESULT retVal
= DD_OK
;
29 DDDEVICEIDENTIFIER2 pDDDI2
;
31 ZeroMemory(&pDDDI2
,sizeof(DDDEVICEIDENTIFIER2
));
35 memcpy(&pDDDI2
, pDDDI
, sizeof(DDDEVICEIDENTIFIER
));
37 retVal
= Main_DirectDraw_GetDeviceIdentifier7(This
, &pDDDI2
, dwFlags
);
39 if (IsBadWritePtr(pDDDI
, sizeof(DDDEVICEIDENTIFIER
)))
41 retVal
= DDERR_INVALIDPARAMS
;
45 memcpy(pDDDI
, &pDDDI2
, sizeof(DDDEVICEIDENTIFIER
) );
48 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
58 Main_DirectDraw_GetDeviceIdentifier7(LPDDRAWI_DIRECTDRAW_INT This
,
59 LPDDDEVICEIDENTIFIER2 pDDDI
, DWORD dwFlags
)
61 HRESULT retVal
= DDERR_INVALIDPARAMS
;
65 DISPLAY_DEVICEA DisplayDeviceA
;
68 DWORD strSize
= MAX_DDDEVICEID_STRING
;
75 EnterCriticalSection( &ddcs
);
79 if ( (IsBadWritePtr( pDDDI
, sizeof(DDDEVICEIDENTIFIER2
) ) ) ||
80 (dwFlags
& ~DDGDI_GETHOSTIDENTIFIER
))
82 retVal
= DDERR_INVALIDPARAMS
;
86 /* now we can start getting the driver data */
90 ZeroMemory(&DisplayDeviceA
,sizeof(DISPLAY_DEVICEA
));
92 DisplayDeviceA
.cb
= sizeof(DISPLAY_DEVICEA
);
94 if ( EnumDisplayDevicesA( NULL
, iDevNum
, &DisplayDeviceA
, 0) == 0)
96 retVal
= DDERR_INVALIDPARAMS
;
100 if (_stricmp(DisplayDeviceA
.DeviceName
, This
->lpLcl
->lpGbl
->cDriverName
) != 0)
102 /* if we got another device like hardware mpeg decoder or video card or another drv */
105 else if (DisplayDeviceA
.StateFlags
& DISPLAY_DEVICE_PRIMARY_DEVICE
)
107 /* double check if it primary driver we just found */
108 if (!_stricmp( This
->lpLcl
->lpGbl
->cDriverName
, "DISPLAY"))
110 /* yeah we found it */
117 /* we found our driver now we start setup it */
118 if (!_strnicmp(DisplayDeviceA
.DeviceKey
,"\\REGISTRY\\Machine\\",18))
120 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
, &DisplayDeviceA
.DeviceKey
[18], 0, KEY_QUERY_VALUE
, &hKey
) == ERROR_SUCCESS
)
123 if (RegQueryValueExA(hKey
, "InstalledDisplayDrivers",0, &lpType
, (LPBYTE
)pDDDI
->szDriver
, &strSize
) != ERROR_SUCCESS
)
125 ZeroMemory(pDDDI
->szDriver
,MAX_DDDEVICEID_STRING
);
129 strcat(pDDDI
->szDriver
,".dll");
134 strcpy( pDDDI
->szDescription
, DisplayDeviceA
.DeviceString
);
135 pDDDI
->liDriverVersion
.HighPart
= 0;
136 pDDDI
->liDriverVersion
.LowPart
= 0;
138 pdest
= strstr(DisplayDeviceA
.DeviceID
,"REV_");
139 pDDDI
->dwRevision
= strtol ( &pdest
[4], &pcCnvEnd
, 16);
141 pdest
= strstr(DisplayDeviceA
.DeviceID
,"SUBSYS_");
142 pDDDI
->dwSubSysId
= strtol ( &pdest
[7], &pcCnvEnd
, 16);
144 pdest
= strstr(DisplayDeviceA
.DeviceID
,"DEV_");
145 pDDDI
->dwDeviceId
= strtol ( &pdest
[4], &pcCnvEnd
, 16);
147 pdest
= strstr(DisplayDeviceA
.DeviceID
,"VEN_");
148 pDDDI
->dwVendorId
=strtol ( &pdest
[4], &pcCnvEnd
, 16);
150 /* Count out the guidDeviceIdentifier */
151 memcpy(&pDDDI
->guidDeviceIdentifier
, &CLSID_DirectDraw
,sizeof(GUID
));
153 pDDDI
->guidDeviceIdentifier
.Data1
^= pDDDI
->dwVendorId
;
155 lpdata
= (long *)&pDDDI
->guidDeviceIdentifier
.Data2
;
156 *lpdata
^= pDDDI
->dwDeviceId
;
158 lpdata
= (long *)&pDDDI
->guidDeviceIdentifier
.Data4
;
159 *lpdata
= (*lpdata
^ pDDDI
->dwSubSysId
) ^ pDDDI
->liDriverVersion
.LowPart
;
161 lpdata
= (long *)&pDDDI
->guidDeviceIdentifier
.Data4
[4];
162 *lpdata
= (*lpdata
^ pDDDI
->dwRevision
) ^ pDDDI
->liDriverVersion
.HighPart
;
164 /* FIXME pDDDI->dwWHQLLevel
165 * we leave this with no informations, I do not known
166 * if program care for it, I mark this api done, and
167 * tested, no bugs was found in it
169 pDDDI
->dwWHQLLevel
= 0;
180 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
186 LeaveCriticalSection( &ddcs
);