ReactOS 0.4.17-dev-1190-g4c812f4
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 670 of file newdev.c.

675{
676 PDEVINSTDATA DevInstData = NULL;
677 BOOL ret;
678 DWORD config_flags;
679 BOOL retval = FALSE;
680
681 TRACE("(%p, %p, %s, %d)\n", hWndParent, hInstance, debugstr_w(InstanceId), Show);
682
683 if (!IsUserAdmin())
684 {
685 /* XP kills the process... */
687 }
688
689 DevInstData = HeapAlloc(GetProcessHeap(), 0, sizeof(DEVINSTDATA));
690 if (!DevInstData)
691 {
692 TRACE("HeapAlloc() failed\n");
694 goto cleanup;
695 }
696
697 /* Clear devinst data */
698 ZeroMemory(DevInstData, sizeof(DEVINSTDATA));
699 DevInstData->devInfoData.cbSize = 0; /* Tell if the devInfoData is valid */
700
701 /* Fill devinst data */
703 if (DevInstData->hDevInfo == INVALID_HANDLE_VALUE)
704 {
705 TRACE("SetupDiCreateDeviceInfoListExW() failed with error 0x%x\n", GetLastError());
706 goto cleanup;
707 }
708
709 DevInstData->devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
711 DevInstData->hDevInfo,
713 NULL,
714 0, /* Open flags */
715 &DevInstData->devInfoData);
716 if (!ret)
717 {
718 TRACE("SetupDiOpenDeviceInfoW() failed with error 0x%x (InstanceId %s)\n",
720 DevInstData->devInfoData.cbSize = 0;
721 goto cleanup;
722 }
723
726 DevInstData->hDevInfo,
727 &DevInstData->devInfoData,
729 &DevInstData->regDataType,
730 NULL, 0,
731 &DevInstData->requiredSize);
732
733 if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER && DevInstData->regDataType == REG_SZ)
734 {
735 DevInstData->buffer = HeapAlloc(GetProcessHeap(), 0, DevInstData->requiredSize);
736 if (!DevInstData->buffer)
737 {
738 TRACE("HeapAlloc() failed\n");
740 }
741 else
742 {
744 DevInstData->hDevInfo,
745 &DevInstData->devInfoData,
747 &DevInstData->regDataType,
748 DevInstData->buffer, DevInstData->requiredSize,
749 &DevInstData->requiredSize);
750 }
751 }
752 if (!ret)
753 {
754 TRACE("SetupDiGetDeviceRegistryProperty() failed with error 0x%x (InstanceId %s)\n",
756 goto cleanup;
757 }
758
760 DevInstData->hDevInfo,
761 &DevInstData->devInfoData,
763 NULL,
764 (BYTE *)&config_flags,
765 sizeof(config_flags),
766 NULL))
767 {
768 if (config_flags & CONFIGFLAG_FAILEDINSTALL)
769 {
770 /* The device is disabled */
771 TRACE("Device is disabled\n");
772 retval = TRUE;
773 goto cleanup;
774 }
775 }
776
777 TRACE("Installing %s (%s)\n", debugstr_w((PCWSTR)DevInstData->buffer), debugstr_w(InstanceId));
778
779 /* Search driver in default location and removable devices */
780 if (!PrepareFoldersToScan(DevInstData, FALSE, FALSE, NULL))
781 {
782 TRACE("PrepareFoldersToScan() failed with error 0x%lx\n", GetLastError());
783 goto cleanup;
784 }
785 if (ScanFoldersForDriver(DevInstData))
786 {
787 /* Driver found ; install it */
788 retval = InstallCurrentDriver(DevInstData);
789 TRACE("InstallCurrentDriver() returned %d\n", retval);
790 if (retval && Show != SW_HIDE)
791 {
792 /* Should we display the 'Need to reboot' page? */
793 SP_DEVINSTALL_PARAMS installParams;
794 installParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS);
796 DevInstData->hDevInfo,
797 &DevInstData->devInfoData,
798 &installParams))
799 {
800 if (installParams.Flags & (DI_NEEDRESTART | DI_NEEDREBOOT))
801 {
802 TRACE("Displaying 'Reboot' wizard page\n");
804 }
805 }
806 }
807 goto cleanup;
808 }
809 else if (Show == SW_HIDE)
810 {
811 /* We can't show the wizard. Fail the install */
812 TRACE("No wizard\n");
813 goto cleanup;
814 }
815
816 /* Prepare the wizard, and display it */
817 TRACE("Need to show install wizard\n");
819
820cleanup:
821 if (DevInstData)
822 {
823 if (DevInstData->devInfoData.cbSize != 0)
824 {
825 if (!SetupDiDestroyDriverInfoList(DevInstData->hDevInfo, &DevInstData->devInfoData, SPDIT_COMPATDRIVER))
826 TRACE("SetupDiDestroyDriverInfoList() failed with error 0x%lx\n", GetLastError());
827 }
828 if (DevInstData->hDevInfo != INVALID_HANDLE_VALUE)
829 {
830 if (!SetupDiDestroyDeviceInfoList(DevInstData->hDevInfo))
831 TRACE("SetupDiDestroyDeviceInfoList() failed with error 0x%lx\n", GetLastError());
832 }
833 HeapFree(GetProcessHeap(), 0, DevInstData->buffer);
834 HeapFree(GetProcessHeap(), 0, DevInstData);
835 }
836
837 return retval;
838}
#define REG_SZ
Definition: layer.c:22
HINSTANCE hInstance
Definition: charmap.c:19
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
static void cleanup(void)
Definition: main.c:1335
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1382
#define IDD_WELCOMEPAGE
Definition: resource.h:21
#define IDD_NEEDREBOOT
Definition: resource.h:27
HDEVINFO WINAPI SetupDiCreateDeviceInfoListExW(const GUID *ClassGuid, HWND hwndParent, PCWSTR MachineName, PVOID Reserved)
Definition: devinst.c:1502
BOOL WINAPI SetupDiGetDeviceRegistryPropertyW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize)
Definition: devinst.c:3513
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:5063
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:3182
BOOL WINAPI SetupDiDestroyDriverInfoList(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN DWORD DriverType)
Definition: driver.c:1062
return ret
Definition: mutex.c:147
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ _In_opt_ PVOID _In_opt_ PVOID InstanceId
Definition: fsrtlfuncs.h:908
#define debugstr_w
Definition: kernel32.h:32
#define ZeroMemory
Definition: minwinbase.h:31
static BOOL IsUserAdmin(VOID)
Definition: netid.c:163
BOOL ScanFoldersForDriver(IN PDEVINSTDATA DevInstData)
Definition: newdev.c:441
BOOL PrepareFoldersToScan(IN PDEVINSTDATA DevInstData, IN BOOL IncludeRemovableDevices, IN BOOL IncludeCustomPath, IN HWND hwndCombo OPTIONAL)
Definition: newdev.c:476
BOOL InstallCurrentDriver(IN PDEVINSTDATA DevInstData)
Definition: newdev.c:554
BOOL DisplayWizard(IN PDEVINSTDATA DevInstData, IN HWND hwndParent, IN UINT startPage)
Definition: wizard.c:1372
#define SW_HIDE
Definition: winuser.h:779
#define CONFIGFLAG_FAILEDINSTALL
Definition: regstr.h:396
#define DI_NEEDRESTART
Definition: setupapi.h:55
#define SPDRP_DEVICEDESC
Definition: setupapi.h:510
#define SetupDiGetDeviceInstallParams
Definition: setupapi.h:2648
SP_DEVINSTALL_PARAMS_A SP_DEVINSTALL_PARAMS
Definition: setupapi.h:1158
#define SetupDiGetDeviceRegistryProperty
Definition: setupapi.h:2652
#define DI_NEEDREBOOT
Definition: setupapi.h:56
struct _SP_DEVINFO_DATA SP_DEVINFO_DATA
#define SPDRP_CONFIGFLAGS
Definition: setupapi.h:520
#define SPDIT_COMPATDRIVER
Definition: setupapi.h:509
#define TRACE(s)
Definition: solgame.cpp:4
SP_DEVINFO_DATA devInfoData
HDEVINFO hDevInfo
DWORD requiredSize
const uint16_t * PCWSTR
Definition: typedefs.h:57
int retval
Definition: wcstombs.cpp:91
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_GEN_FAILURE
Definition: winerror.h:256
unsigned char BYTE
Definition: xxhash.c:193

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}

◆ InstallDevInstEx()

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

Definition at line 843 of file newdev.c.

849{
850 PDEVINSTDATA DevInstData = NULL;
851 BOOL ret;
852 BOOL retval = FALSE;
853
854 TRACE("InstllDevInstEx(%p, %s, %d, %p, %lx)\n",
855 hWndParent, debugstr_w(InstanceId), bUpdate, lpReboot, Unknown);
856
857 DevInstData = HeapAlloc(GetProcessHeap(), 0, sizeof(DEVINSTDATA));
858 if (!DevInstData)
859 {
860 TRACE("HeapAlloc() failed\n");
862 goto cleanup;
863 }
864
865 /* Clear devinst data */
866 ZeroMemory(DevInstData, sizeof(DEVINSTDATA));
867 DevInstData->devInfoData.cbSize = 0; /* Tell if the devInfoData is valid */
868 DevInstData->bUpdate = bUpdate;
869
870 /* Fill devinst data */
872 if (DevInstData->hDevInfo == INVALID_HANDLE_VALUE)
873 {
874 TRACE("SetupDiCreateDeviceInfoListExW() failed with error 0x%x\n", GetLastError());
875 goto cleanup;
876 }
877
878 DevInstData->devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
880 DevInstData->hDevInfo,
882 NULL,
883 0, /* Open flags */
884 &DevInstData->devInfoData);
885 if (!ret)
886 {
887 TRACE("SetupDiOpenDeviceInfoW() failed with error 0x%x (InstanceId %s)\n",
889 DevInstData->devInfoData.cbSize = 0;
890 goto cleanup;
891 }
892
895 DevInstData->hDevInfo,
896 &DevInstData->devInfoData,
898 &DevInstData->regDataType,
899 NULL, 0,
900 &DevInstData->requiredSize);
901
902 if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER && DevInstData->regDataType == REG_SZ)
903 {
904 DevInstData->buffer = HeapAlloc(GetProcessHeap(), 0, DevInstData->requiredSize);
905 if (!DevInstData->buffer)
906 {
907 TRACE("HeapAlloc() failed\n");
909 }
910 else
911 {
913 DevInstData->hDevInfo,
914 &DevInstData->devInfoData,
916 &DevInstData->regDataType,
917 DevInstData->buffer, DevInstData->requiredSize,
918 &DevInstData->requiredSize);
919 }
920 }
921
922 if (!ret)
923 {
924 TRACE("SetupDiGetDeviceRegistryProperty() failed with error 0x%x (InstanceId %s)\n",
926 goto cleanup;
927 }
928
929 /* Prepare the wizard, and display it */
930 TRACE("Need to show install wizard\n");
932
933cleanup:
934 if (DevInstData)
935 {
936 if (DevInstData->devInfoData.cbSize != 0)
937 {
938 if (!SetupDiDestroyDriverInfoList(DevInstData->hDevInfo, &DevInstData->devInfoData, SPDIT_COMPATDRIVER))
939 TRACE("SetupDiDestroyDriverInfoList() failed with error 0x%lx\n", GetLastError());
940 }
941 if (DevInstData->hDevInfo != INVALID_HANDLE_VALUE)
942 {
943 if (!SetupDiDestroyDeviceInfoList(DevInstData->hDevInfo))
944 TRACE("SetupDiDestroyDeviceInfoList() failed with error 0x%lx\n", GetLastError());
945 }
946 HeapFree(GetProcessHeap(), 0, DevInstData->buffer);
947 HeapFree(GetProcessHeap(), 0, DevInstData);
948 }
949
950 return retval;
951}
@ Unknown
Definition: i8042prt.h:114

Referenced by InstallDevInst().