ReactOS  0.4.14-dev-49-gfb4591c
classinst.c File Reference
#include "desk.h"
#include <debug.h>
Include dependency graph for classinst.c:

Go to the source code of this file.

Functions

DWORD WINAPI DisplayClassInstaller (IN DI_FUNCTION InstallFunction, IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
 
DWORD WINAPI MonitorClassInstaller (IN DI_FUNCTION InstallFunction, IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
 

Function Documentation

◆ DisplayClassInstaller()

DWORD WINAPI DisplayClassInstaller ( IN DI_FUNCTION  InstallFunction,
IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA DeviceInfoData  OPTIONAL 
)

Definition at line 16 of file classinst.c.

20 {
21  SP_DEVINSTALL_PARAMS InstallParams;
22  SP_DRVINFO_DATA DriverInfoData;
24  TCHAR SectionName[MAX_PATH];
26  SP_DRVINFO_DETAIL_DATA DriverInfoDetailData;
27  HKEY hDriverKey = INVALID_HANDLE_VALUE; /* SetupDiOpenDevRegKey returns INVALID_HANDLE_VALUE in case of error! */
28  HKEY hSettingsKey = NULL;
30  HKEY hServiceKey = NULL;
31  HKEY hDeviceSubKey = NULL;
32  DWORD disposition, cchMax, cbData;
33  BOOL result;
34  LONG rc;
35  HRESULT hr;
36 
37  if (InstallFunction != DIF_INSTALLDEVICE)
38  return ERROR_DI_DO_DEFAULT;
39 
40  /* Set DI_DONOTCALLCONFIGMG flag */
41  InstallParams.cbSize = sizeof(InstallParams);
43  if (!result)
44  {
45  rc = GetLastError();
46  DPRINT("SetupDiGetDeviceInstallParams() failed with error 0x%lx\n", rc);
47  goto cleanup;
48  }
49 
50  InstallParams.Flags |= DI_DONOTCALLCONFIGMG;
51 
53  if (!result)
54  {
55  rc = GetLastError();
56  DPRINT("SetupDiSetDeviceInstallParams() failed with error 0x%lx\n", rc);
57  goto cleanup;
58  }
59 
60  /* Do normal install */
62  if (!result)
63  {
64  rc = GetLastError();
65  DPRINT("SetupDiInstallDevice() failed with error 0x%lx\n", rc);
66  goto cleanup;
67  }
68 
69  /* Get .inf file name and section name */
70  DriverInfoData.cbSize = sizeof(DriverInfoData);
72  if (!result)
73  {
74  rc = GetLastError();
75  DPRINT("SetupDiGetSelectedDriver() failed with error 0x%lx\n", rc);
76  goto cleanup;
77  }
78 
79  DriverInfoDetailData.cbSize = sizeof(DriverInfoDetailData);
81  &DriverInfoData, &DriverInfoDetailData,
82  sizeof(DriverInfoDetailData), NULL);
84  {
85  rc = GetLastError();
86  DPRINT("SetupDiGetDriverInfoDetail() failed with error 0x%lx\n", rc);
87  goto cleanup;
88  }
89 
90  hInf = SetupOpenInfFile(DriverInfoDetailData.InfFileName, NULL, INF_STYLE_WIN4, NULL);
91  if (hInf == INVALID_HANDLE_VALUE)
92  {
93  rc = GetLastError();
94  DPRINT("SetupOpenInfFile() failed with error 0x%lx\n", rc);
95  goto cleanup;
96  }
97 
98  cchMax = MAX_PATH - (sizeof(_T(".SoftwareSettings")) / sizeof(TCHAR));
100  DriverInfoDetailData.SectionName,
101  SectionName,
102  cchMax,
103  NULL,
104  NULL);
105  if (!result)
106  {
107  rc = GetLastError();
108  DPRINT("SetupDiGetActualSectionToInstall() failed with error 0x%lx\n", rc);
109  goto cleanup;
110  }
111  hr = StringCbCat(SectionName, sizeof(SectionName), _T(".SoftwareSettings"));
112  if (FAILED(hr))
113  {
115  goto cleanup;
116  }
117 
118  /* Open driver registry key and create Settings subkey */
119  hDriverKey = SetupDiOpenDevRegKey(
123  if (hDriverKey == INVALID_HANDLE_VALUE)
124  {
125  rc = GetLastError();
126  DPRINT("SetupDiOpenDevRegKey() failed with error 0x%lx\n", rc);
127  goto cleanup;
128  }
129  rc = RegCreateKeyEx(
130  hDriverKey, L"Settings",
132 #if _WIN32_WINNT >= 0x502
134 #else
136 #endif
137  NULL, &hSettingsKey, &disposition);
138  if (rc != ERROR_SUCCESS)
139  {
140  DPRINT("RegCreateKeyEx() failed with error 0x%lx\n", rc);
141  goto cleanup;
142  }
143 
144  /* Install .SoftwareSettings to Settings subkey */
146  InstallParams.hwndParent, hInf, SectionName,
147  SPINST_REGISTRY, hSettingsKey,
148  NULL, 0, NULL, NULL,
149  NULL, NULL);
150  if (!result)
151  {
152  rc = GetLastError();
153  DPRINT("SetupInstallFromInfSection() failed with error 0x%lx\n", rc);
154  goto cleanup;
155  }
156 
157  /* Get service name and open service registry key */
162  if (!result)
163  {
164  rc = GetLastError();
165  DPRINT("SetupDiGetDeviceRegistryProperty() failed with error 0x%lx\n", rc);
166  goto cleanup;
167  }
168 
169  rc = RegOpenKeyEx(
170  HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\Services"),
172  if (rc != ERROR_SUCCESS)
173  {
174  DPRINT("RegOpenKeyEx() failed with error 0x%lx\n", rc);
175  goto cleanup;
176  }
177  rc = RegOpenKeyEx(
179  0, KEY_CREATE_SUB_KEY, &hServiceKey);
180  if (rc != ERROR_SUCCESS)
181  {
182  DPRINT("RegOpenKeyEx() failed with error 0x%lx\n", rc);
183  goto cleanup;
184  }
185 
186  /* Create a Device0 subkey (FIXME: do a loop to find a free number?) */
187  rc = RegCreateKeyEx(
188  hServiceKey, _T("Device0"), 0, NULL,
190  &hDeviceSubKey, &disposition);
191  if (rc != ERROR_SUCCESS)
192  {
193  DPRINT("RegCreateKeyEx() failed with error 0x%lx\n", rc);
194  goto cleanup;
195  }
196  if (disposition != REG_CREATED_NEW_KEY)
197  {
198  rc = ERROR_GEN_FAILURE;
199  DPRINT("RegCreateKeyEx() failed\n");
200  goto cleanup;
201  }
202 
203  /* Install SoftwareSettings section */
204  /* Yes, we're installing this section for the second time.
205  * We don't want to create a link to Settings subkey */
207  InstallParams.hwndParent, hInf, SectionName,
208  SPINST_REGISTRY, hDeviceSubKey,
209  NULL, 0, NULL, NULL,
210  NULL, NULL);
211  if (!result)
212  {
213  rc = GetLastError();
214  DPRINT("SetupInstallFromInfSection() failed with error 0x%lx\n", rc);
215  goto cleanup;
216  }
217 
218  /* Add Device Description string */
219  cbData = (DWORD)(_tcslen(DriverInfoData.Description) + 1) * sizeof(TCHAR);
220  rc = RegSetValueEx(hDeviceSubKey,
221  _T("Device Description"),
222  0,
223  REG_SZ,
224  (const BYTE*)DriverInfoData.Description,
225  cbData);
226  if (rc != ERROR_SUCCESS)
227  {
228  DPRINT("RegSetValueEx() failed with error 0x%lx\n", rc);
229  goto cleanup;
230  }
231 
232  /* FIXME: install OpenGLSoftwareSettings section */
233 
234  rc = ERROR_SUCCESS;
235 
236 cleanup:
237  if (hInf != INVALID_HANDLE_VALUE)
238  SetupCloseInfFile(hInf);
239  if (hDriverKey != INVALID_HANDLE_VALUE)
240  {
241  /* SetupDiOpenDevRegKey returns INVALID_HANDLE_VALUE in case of error! */
242  RegCloseKey(hDriverKey);
243  }
244  if (hSettingsKey != NULL)
245  RegCloseKey(hSettingsKey);
246  if (hServicesKey != NULL)
248  if (hServiceKey != NULL)
249  RegCloseKey(hServiceKey);
250  if (hDeviceSubKey != NULL)
251  RegCloseKey(hDeviceSubKey);
252 
253  return rc;
254 }
#define _WIN32_WINNT
Definition: precomp.h:14
#define INF_STYLE_WIN4
Definition: infsupp.h:41
#define SetupInstallFromInfSection
Definition: setupapi.h:2640
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define KEY_READ
Definition: nt_native.h:1023
#define SetupDiGetDeviceInstallParams
Definition: setupapi.h:2594
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define SetupDiGetDeviceRegistryProperty
Definition: setupapi.h:2598
#define SetupDiGetSelectedDriver
Definition: setupapi.h:2605
#define DWORD
Definition: nt_native.h:44
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:43
CHAR SectionName[LINE_LEN]
Definition: setupapi.h:1060
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define SetupDiGetActualSectionToInstall
Definition: setupapi.h:2583
#define DI_DONOTCALLCONFIGMG
Definition: setupapi.h:63
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
BOOL WINAPI SetupDiInstallDevice(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:5354
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
#define SPINST_REGISTRY
Definition: setupapi.h:585
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1084
#define DIF_INSTALLDEVICE
Definition: setupapi.h:121
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
static HANDLE hServicesKey
Definition: devinst.c:21
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define StringCbCat
Definition: strsafe.h:334
LPTSTR ServiceName
Definition: ServiceMain.c:15
LONG HRESULT
Definition: typedefs.h:77
#define SetupDiSetDeviceInstallParams
Definition: setupapi.h:2614
#define MAX_PATH
Definition: compat.h:26
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1523
unsigned long DWORD
Definition: ntddk_ex.h:95
UINT cchMax
static const WCHAR L[]
Definition: oid.c:1250
unsigned char BYTE
Definition: mem.h:68
#define SPDRP_SERVICE
Definition: setupapi.h:506
HKEY WINAPI SetupDiOpenDevRegKey(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, REGSAM samDesired)
Definition: devinst.c:5919
#define SetupDiGetDriverInfoDetail
Definition: setupapi.h:2599
#define RegOpenKeyEx
Definition: winreg.h:520
#define DICS_FLAG_GLOBAL
Definition: setupapi.h:113
CHAR Description[LINE_LEN]
Definition: setupapi.h:1001
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define ERROR_DI_DO_DEFAULT
Definition: setupapi.h:305
#define DIREG_DRV
Definition: setupapi.h:182
char * cleanup(char *str)
Definition: wpickclick.c:99
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
CHAR InfFileName[MAX_PATH]
Definition: setupapi.h:1061
GLuint64EXT * result
Definition: glext.h:11304
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
BYTE * PBYTE
Definition: pedump.c:66
#define RegSetValueEx
Definition: winreg.h:533
#define RegCreateKeyEx
Definition: winreg.h:501
#define SetupOpenInfFile
Definition: setupapi.h:2647
#define MAX_SERVICE_NAME_LEN
Definition: setupapi.h:25
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define REG_SZ
Definition: layer.c:22

◆ MonitorClassInstaller()

DWORD WINAPI MonitorClassInstaller ( IN DI_FUNCTION  InstallFunction,
IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA DeviceInfoData  OPTIONAL 
)

Definition at line 257 of file classinst.c.

261 {
262  return ERROR_DI_DO_DEFAULT;
263 }
#define ERROR_DI_DO_DEFAULT
Definition: setupapi.h:305