ReactOS  0.4.15-dev-1150-g593bcce
newdevp.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

BOOL WINAPI DevInstallW (IN HWND hWndParent, IN HINSTANCE hInstance, IN LPCWSTR InstanceId, IN INT Show)
 
BOOL WINAPI InstallDevInst (IN HWND hWndParent, IN LPCWSTR InstanceId, IN BOOL bUpdate, OUT LPDWORD lpReboot)
 
BOOL WINAPI InstallDevInstEx (IN HWND hWndParent, IN LPCWSTR InstanceId, IN BOOL bUpdate, OUT LPDWORD lpReboot, IN DWORD Unknown)
 

Function Documentation

◆ DevInstallW()

BOOL WINAPI DevInstallW ( IN HWND  hWndParent,
IN HINSTANCE  hInstance,
IN LPCWSTR  InstanceId,
IN INT  Show 
)

Definition at line 637 of file newdev.c.

642 {
643  PDEVINSTDATA DevInstData = NULL;
644  BOOL ret;
645  DWORD config_flags;
646  BOOL retval = FALSE;
647 
648  TRACE("(%p, %p, %s, %d)\n", hWndParent, hInstance, debugstr_w(InstanceId), Show);
649 
650  if (!IsUserAdmin())
651  {
652  /* XP kills the process... */
654  }
655 
656  DevInstData = HeapAlloc(GetProcessHeap(), 0, sizeof(DEVINSTDATA));
657  if (!DevInstData)
658  {
659  TRACE("HeapAlloc() failed\n");
661  goto cleanup;
662  }
663 
664  /* Clear devinst data */
665  ZeroMemory(DevInstData, sizeof(DEVINSTDATA));
666  DevInstData->devInfoData.cbSize = 0; /* Tell if the devInfoData is valid */
667 
668  /* Fill devinst data */
670  if (DevInstData->hDevInfo == INVALID_HANDLE_VALUE)
671  {
672  TRACE("SetupDiCreateDeviceInfoListExW() failed with error 0x%x\n", GetLastError());
673  goto cleanup;
674  }
675 
676  DevInstData->devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
678  DevInstData->hDevInfo,
679  InstanceId,
680  NULL,
681  0, /* Open flags */
682  &DevInstData->devInfoData);
683  if (!ret)
684  {
685  TRACE("SetupDiOpenDeviceInfoW() failed with error 0x%x (InstanceId %s)\n",
687  DevInstData->devInfoData.cbSize = 0;
688  goto cleanup;
689  }
690 
693  DevInstData->hDevInfo,
694  &DevInstData->devInfoData,
696  &DevInstData->regDataType,
697  NULL, 0,
698  &DevInstData->requiredSize);
699 
700  if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER && DevInstData->regDataType == REG_SZ)
701  {
702  DevInstData->buffer = HeapAlloc(GetProcessHeap(), 0, DevInstData->requiredSize);
703  if (!DevInstData->buffer)
704  {
705  TRACE("HeapAlloc() failed\n");
707  }
708  else
709  {
711  DevInstData->hDevInfo,
712  &DevInstData->devInfoData,
714  &DevInstData->regDataType,
715  DevInstData->buffer, DevInstData->requiredSize,
716  &DevInstData->requiredSize);
717  }
718  }
719  if (!ret)
720  {
721  TRACE("SetupDiGetDeviceRegistryProperty() failed with error 0x%x (InstanceId %s)\n",
723  goto cleanup;
724  }
725 
727  DevInstData->hDevInfo,
728  &DevInstData->devInfoData,
730  NULL,
731  (BYTE *)&config_flags,
732  sizeof(config_flags),
733  NULL))
734  {
735  if (config_flags & CONFIGFLAG_FAILEDINSTALL)
736  {
737  /* The device is disabled */
738  TRACE("Device is disabled\n");
739  retval = TRUE;
740  goto cleanup;
741  }
742  }
743 
744  TRACE("Installing %s (%s)\n", debugstr_w((PCWSTR)DevInstData->buffer), debugstr_w(InstanceId));
745 
746  /* Search driver in default location and removable devices */
747  if (!PrepareFoldersToScan(DevInstData, FALSE, FALSE, NULL))
748  {
749  TRACE("PrepareFoldersToScan() failed with error 0x%lx\n", GetLastError());
750  goto cleanup;
751  }
752  if (ScanFoldersForDriver(DevInstData))
753  {
754  /* Driver found ; install it */
755  retval = InstallCurrentDriver(DevInstData);
756  TRACE("InstallCurrentDriver() returned %d\n", retval);
757  if (retval && Show != SW_HIDE)
758  {
759  /* Should we display the 'Need to reboot' page? */
760  SP_DEVINSTALL_PARAMS installParams;
761  installParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS);
763  DevInstData->hDevInfo,
764  &DevInstData->devInfoData,
765  &installParams))
766  {
767  if (installParams.Flags & (DI_NEEDRESTART | DI_NEEDREBOOT))
768  {
769  TRACE("Displaying 'Reboot' wizard page\n");
770  retval = DisplayWizard(DevInstData, hWndParent, IDD_NEEDREBOOT);
771  }
772  }
773  }
774  goto cleanup;
775  }
776  else if (Show == SW_HIDE)
777  {
778  /* We can't show the wizard. Fail the install */
779  TRACE("No wizard\n");
780  goto cleanup;
781  }
782 
783  /* Prepare the wizard, and display it */
784  TRACE("Need to show install wizard\n");
785  retval = DisplayWizard(DevInstData, hWndParent, IDD_WELCOMEPAGE);
786 
787 cleanup:
788  if (DevInstData)
789  {
790  if (DevInstData->devInfoData.cbSize != 0)
791  {
792  if (!SetupDiDestroyDriverInfoList(DevInstData->hDevInfo, &DevInstData->devInfoData, SPDIT_COMPATDRIVER))
793  TRACE("SetupDiDestroyDriverInfoList() failed with error 0x%lx\n", GetLastError());
794  }
795  if (DevInstData->hDevInfo != INVALID_HANDLE_VALUE)
796  {
797  if (!SetupDiDestroyDeviceInfoList(DevInstData->hDevInfo))
798  TRACE("SetupDiDestroyDeviceInfoList() failed with error 0x%lx\n", GetLastError());
799  }
800  HeapFree(GetProcessHeap(), 0, DevInstData->buffer);
801  HeapFree(GetProcessHeap(), 0, DevInstData);
802  }
803 
804  return retval;
805 }
const uint16_t * PCWSTR
Definition: typedefs.h:57
SP_DEVINFO_DATA devInfoData
#define DI_NEEDREBOOT
Definition: setupapi.h:54
#define TRUE
Definition: types.h:120
#define SW_HIDE
Definition: winuser.h:762
#define SetupDiGetDeviceInstallParams
Definition: setupapi.h:2594
HDEVINFO WINAPI SetupDiCreateDeviceInfoListExW(const GUID *ClassGuid, HWND hwndParent, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:1268
BOOL WINAPI SetupDiGetDeviceRegistryPropertyW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize)
Definition: devinst.c:3229
#define IDD_NEEDREBOOT
Definition: resource.h:27
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1487
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define ZeroMemory
Definition: winbase.h:1648
#define SetupDiGetDeviceRegistryProperty
Definition: setupapi.h:2598
DWORD requiredSize
HINSTANCE hInstance
Definition: charmap.c:20
#define FALSE
Definition: types.h:117
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL IsUserAdmin(VOID)
Definition: netid.c:163
#define debugstr_w
Definition: kernel32.h:32
_Must_inspect_result_ _In_opt_ PVOID _In_opt_ PVOID InstanceId
Definition: fsrtlfuncs.h:907
smooth NULL
Definition: ftsmooth.c:416
#define SPDIT_COMPATDRIVER
Definition: setupapi.h:501
#define IDD_WELCOMEPAGE
Definition: resource.h:21
struct _SP_DEVINFO_DATA SP_DEVINFO_DATA
BOOL DisplayWizard(IN PDEVINSTDATA DevInstData, IN HWND hwndParent, IN UINT startPage)
Definition: wizard.c:1298
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2898
unsigned long DWORD
Definition: ntddk_ex.h:95
SP_DEVINSTALL_PARAMS_A SP_DEVINSTALL_PARAMS
Definition: setupapi.h:1150
#define SetLastError(x)
Definition: compat.h:500
HDEVINFO hDevInfo
int ret
BOOL InstallCurrentDriver(IN PDEVINSTDATA DevInstData)
Definition: newdev.c:521
#define SPDRP_DEVICEDESC
Definition: setupapi.h:502
unsigned char BYTE
Definition: xxhash.c:193
BOOL WINAPI SetupDiDestroyDriverInfoList(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN DWORD DriverType)
Definition: driver.c:1208
#define SPDRP_CONFIGFLAGS
Definition: setupapi.h:512
BOOL WINAPI SetupDiOpenDeviceInfoW(IN HDEVINFO DeviceInfoSet, IN PCWSTR DeviceInstanceId, IN HWND hwndParent OPTIONAL, IN DWORD OpenFlags, OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
Definition: devinst.c:4779
char * cleanup(char *str)
Definition: wpickclick.c:99
BOOL PrepareFoldersToScan(IN PDEVINSTDATA DevInstData, IN BOOL IncludeRemovableDevices, IN BOOL IncludeCustomPath, IN HWND hwndCombo OPTIONAL)
Definition: newdev.c:447
#define DI_NEEDRESTART
Definition: setupapi.h:53
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
BOOL ScanFoldersForDriver(IN PDEVINSTDATA DevInstData)
Definition: newdev.c:412
#define HeapFree(x, y, z)
Definition: compat.h:483
#define CONFIGFLAG_FAILEDINSTALL
Definition: regstr.h:396
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define REG_SZ
Definition: layer.c:22

Referenced by ClientSideInstallW().

◆ InstallDevInst()

BOOL WINAPI InstallDevInst ( IN HWND  hWndParent,
IN LPCWSTR  InstanceId,
IN BOOL  bUpdate,
OUT LPDWORD  lpReboot 
)

Definition at line 24 of file stubs.cpp.

29 {
30  return FALSE;
31 }
#define FALSE
Definition: types.h:117

◆ InstallDevInstEx()

BOOL WINAPI InstallDevInstEx ( IN HWND  hWndParent,
IN LPCWSTR  InstanceId,
IN BOOL  bUpdate,
OUT LPDWORD  lpReboot,
IN DWORD  Unknown 
)

Definition at line 810 of file newdev.c.

816 {
817  PDEVINSTDATA DevInstData = NULL;
818  BOOL ret;
819  BOOL retval = FALSE;
820 
821  TRACE("InstllDevInstEx(%p, %s, %d, %p, %lx)\n",
822  hWndParent, debugstr_w(InstanceId), bUpdate, lpReboot, Unknown);
823 
824  DevInstData = HeapAlloc(GetProcessHeap(), 0, sizeof(DEVINSTDATA));
825  if (!DevInstData)
826  {
827  TRACE("HeapAlloc() failed\n");
829  goto cleanup;
830  }
831 
832  /* Clear devinst data */
833  ZeroMemory(DevInstData, sizeof(DEVINSTDATA));
834  DevInstData->devInfoData.cbSize = 0; /* Tell if the devInfoData is valid */
835  DevInstData->bUpdate = bUpdate;
836 
837  /* Fill devinst data */
839  if (DevInstData->hDevInfo == INVALID_HANDLE_VALUE)
840  {
841  TRACE("SetupDiCreateDeviceInfoListExW() failed with error 0x%x\n", GetLastError());
842  goto cleanup;
843  }
844 
845  DevInstData->devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
847  DevInstData->hDevInfo,
848  InstanceId,
849  NULL,
850  0, /* Open flags */
851  &DevInstData->devInfoData);
852  if (!ret)
853  {
854  TRACE("SetupDiOpenDeviceInfoW() failed with error 0x%x (InstanceId %s)\n",
856  DevInstData->devInfoData.cbSize = 0;
857  goto cleanup;
858  }
859 
862  DevInstData->hDevInfo,
863  &DevInstData->devInfoData,
865  &DevInstData->regDataType,
866  NULL, 0,
867  &DevInstData->requiredSize);
868 
869  if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER && DevInstData->regDataType == REG_SZ)
870  {
871  DevInstData->buffer = HeapAlloc(GetProcessHeap(), 0, DevInstData->requiredSize);
872  if (!DevInstData->buffer)
873  {
874  TRACE("HeapAlloc() failed\n");
876  }
877  else
878  {
880  DevInstData->hDevInfo,
881  &DevInstData->devInfoData,
883  &DevInstData->regDataType,
884  DevInstData->buffer, DevInstData->requiredSize,
885  &DevInstData->requiredSize);
886  }
887  }
888 
889  if (!ret)
890  {
891  TRACE("SetupDiGetDeviceRegistryProperty() failed with error 0x%x (InstanceId %s)\n",
893  goto cleanup;
894  }
895 
896  /* Prepare the wizard, and display it */
897  TRACE("Need to show install wizard\n");
898  retval = DisplayWizard(DevInstData, hWndParent, IDD_WELCOMEPAGE);
899 
900 cleanup:
901  if (DevInstData)
902  {
903  if (DevInstData->devInfoData.cbSize != 0)
904  {
905  if (!SetupDiDestroyDriverInfoList(DevInstData->hDevInfo, &DevInstData->devInfoData, SPDIT_COMPATDRIVER))
906  TRACE("SetupDiDestroyDriverInfoList() failed with error 0x%lx\n", GetLastError());
907  }
908  if (DevInstData->hDevInfo != INVALID_HANDLE_VALUE)
909  {
910  if (!SetupDiDestroyDeviceInfoList(DevInstData->hDevInfo))
911  TRACE("SetupDiDestroyDeviceInfoList() failed with error 0x%lx\n", GetLastError());
912  }
913  HeapFree(GetProcessHeap(), 0, DevInstData->buffer);
914  HeapFree(GetProcessHeap(), 0, DevInstData);
915  }
916 
917  return retval;
918 }
SP_DEVINFO_DATA devInfoData
HDEVINFO WINAPI SetupDiCreateDeviceInfoListExW(const GUID *ClassGuid, HWND hwndParent, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:1268
BOOL WINAPI SetupDiGetDeviceRegistryPropertyW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize)
Definition: devinst.c:3229
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define ZeroMemory
Definition: winbase.h:1648
#define SetupDiGetDeviceRegistryProperty
Definition: setupapi.h:2598
DWORD requiredSize
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
_Must_inspect_result_ _In_opt_ PVOID _In_opt_ PVOID InstanceId
Definition: fsrtlfuncs.h:907
smooth NULL
Definition: ftsmooth.c:416
#define SPDIT_COMPATDRIVER
Definition: setupapi.h:501
#define IDD_WELCOMEPAGE
Definition: resource.h:21
struct _SP_DEVINFO_DATA SP_DEVINFO_DATA
BOOL DisplayWizard(IN PDEVINSTDATA DevInstData, IN HWND hwndParent, IN UINT startPage)
Definition: wizard.c:1298
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2898
#define SetLastError(x)
Definition: compat.h:500
HDEVINFO hDevInfo
int ret
#define SPDRP_DEVICEDESC
Definition: setupapi.h:502
BOOL WINAPI SetupDiDestroyDriverInfoList(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN DWORD DriverType)
Definition: driver.c:1208
BOOL WINAPI SetupDiOpenDeviceInfoW(IN HDEVINFO DeviceInfoSet, IN PCWSTR DeviceInstanceId, IN HWND hwndParent OPTIONAL, IN DWORD OpenFlags, OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
Definition: devinst.c:4779
char * cleanup(char *str)
Definition: wpickclick.c:99
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
#define HeapFree(x, y, z)
Definition: compat.h:483
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define REG_SZ
Definition: layer.c:22

Referenced by InstallDevInst().