ReactOS 0.4.16-dev-2110-ge3521eb
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 657 of file newdev.c.

662{
663 PDEVINSTDATA DevInstData = NULL;
664 BOOL ret;
665 DWORD config_flags;
666 BOOL retval = FALSE;
667
668 TRACE("(%p, %p, %s, %d)\n", hWndParent, hInstance, debugstr_w(InstanceId), Show);
669
670 if (!IsUserAdmin())
671 {
672 /* XP kills the process... */
674 }
675
676 DevInstData = HeapAlloc(GetProcessHeap(), 0, sizeof(DEVINSTDATA));
677 if (!DevInstData)
678 {
679 TRACE("HeapAlloc() failed\n");
681 goto cleanup;
682 }
683
684 /* Clear devinst data */
685 ZeroMemory(DevInstData, sizeof(DEVINSTDATA));
686 DevInstData->devInfoData.cbSize = 0; /* Tell if the devInfoData is valid */
687
688 /* Fill devinst data */
690 if (DevInstData->hDevInfo == INVALID_HANDLE_VALUE)
691 {
692 TRACE("SetupDiCreateDeviceInfoListExW() failed with error 0x%x\n", GetLastError());
693 goto cleanup;
694 }
695
696 DevInstData->devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
698 DevInstData->hDevInfo,
700 NULL,
701 0, /* Open flags */
702 &DevInstData->devInfoData);
703 if (!ret)
704 {
705 TRACE("SetupDiOpenDeviceInfoW() failed with error 0x%x (InstanceId %s)\n",
707 DevInstData->devInfoData.cbSize = 0;
708 goto cleanup;
709 }
710
713 DevInstData->hDevInfo,
714 &DevInstData->devInfoData,
716 &DevInstData->regDataType,
717 NULL, 0,
718 &DevInstData->requiredSize);
719
720 if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER && DevInstData->regDataType == REG_SZ)
721 {
722 DevInstData->buffer = HeapAlloc(GetProcessHeap(), 0, DevInstData->requiredSize);
723 if (!DevInstData->buffer)
724 {
725 TRACE("HeapAlloc() failed\n");
727 }
728 else
729 {
731 DevInstData->hDevInfo,
732 &DevInstData->devInfoData,
734 &DevInstData->regDataType,
735 DevInstData->buffer, DevInstData->requiredSize,
736 &DevInstData->requiredSize);
737 }
738 }
739 if (!ret)
740 {
741 TRACE("SetupDiGetDeviceRegistryProperty() failed with error 0x%x (InstanceId %s)\n",
743 goto cleanup;
744 }
745
747 DevInstData->hDevInfo,
748 &DevInstData->devInfoData,
750 NULL,
751 (BYTE *)&config_flags,
752 sizeof(config_flags),
753 NULL))
754 {
755 if (config_flags & CONFIGFLAG_FAILEDINSTALL)
756 {
757 /* The device is disabled */
758 TRACE("Device is disabled\n");
759 retval = TRUE;
760 goto cleanup;
761 }
762 }
763
764 TRACE("Installing %s (%s)\n", debugstr_w((PCWSTR)DevInstData->buffer), debugstr_w(InstanceId));
765
766 /* Search driver in default location and removable devices */
767 if (!PrepareFoldersToScan(DevInstData, FALSE, FALSE, NULL))
768 {
769 TRACE("PrepareFoldersToScan() failed with error 0x%lx\n", GetLastError());
770 goto cleanup;
771 }
772 if (ScanFoldersForDriver(DevInstData))
773 {
774 /* Driver found ; install it */
775 retval = InstallCurrentDriver(DevInstData);
776 TRACE("InstallCurrentDriver() returned %d\n", retval);
777 if (retval && Show != SW_HIDE)
778 {
779 /* Should we display the 'Need to reboot' page? */
780 SP_DEVINSTALL_PARAMS installParams;
781 installParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS);
783 DevInstData->hDevInfo,
784 &DevInstData->devInfoData,
785 &installParams))
786 {
787 if (installParams.Flags & (DI_NEEDRESTART | DI_NEEDREBOOT))
788 {
789 TRACE("Displaying 'Reboot' wizard page\n");
791 }
792 }
793 }
794 goto cleanup;
795 }
796 else if (Show == SW_HIDE)
797 {
798 /* We can't show the wizard. Fail the install */
799 TRACE("No wizard\n");
800 goto cleanup;
801 }
802
803 /* Prepare the wizard, and display it */
804 TRACE("Need to show install wizard\n");
806
807cleanup:
808 if (DevInstData)
809 {
810 if (DevInstData->devInfoData.cbSize != 0)
811 {
812 if (!SetupDiDestroyDriverInfoList(DevInstData->hDevInfo, &DevInstData->devInfoData, SPDIT_COMPATDRIVER))
813 TRACE("SetupDiDestroyDriverInfoList() failed with error 0x%lx\n", GetLastError());
814 }
815 if (DevInstData->hDevInfo != INVALID_HANDLE_VALUE)
816 {
817 if (!SetupDiDestroyDeviceInfoList(DevInstData->hDevInfo))
818 TRACE("SetupDiDestroyDeviceInfoList() failed with error 0x%lx\n", GetLastError());
819 }
820 HeapFree(GetProcessHeap(), 0, DevInstData->buffer);
821 HeapFree(GetProcessHeap(), 0, DevInstData);
822 }
823
824 return retval;
825}
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:1489
#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:1259
BOOL WINAPI SetupDiGetDeviceRegistryPropertyW(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize)
Definition: devinst.c:3224
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:4774
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2893
BOOL WINAPI SetupDiDestroyDriverInfoList(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN DWORD DriverType)
Definition: driver.c:1208
return ret
Definition: mutex.c:146
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 REG_SZ
Definition: layer.c:22
#define ZeroMemory
Definition: minwinbase.h:31
static BOOL IsUserAdmin(VOID)
Definition: netid.c:163
BOOL ScanFoldersForDriver(IN PDEVINSTDATA DevInstData)
Definition: newdev.c:428
BOOL PrepareFoldersToScan(IN PDEVINSTDATA DevInstData, IN BOOL IncludeRemovableDevices, IN BOOL IncludeCustomPath, IN HWND hwndCombo OPTIONAL)
Definition: newdev.c:463
BOOL InstallCurrentDriver(IN PDEVINSTDATA DevInstData)
Definition: newdev.c:541
BOOL DisplayWizard(IN PDEVINSTDATA DevInstData, IN HWND hwndParent, IN UINT startPage)
Definition: wizard.c:1372
#define CONFIGFLAG_FAILEDINSTALL
Definition: regstr.h:396
#define DI_NEEDRESTART
Definition: setupapi.h:53
#define SPDRP_DEVICEDESC
Definition: setupapi.h:508
#define SetupDiGetDeviceInstallParams
Definition: setupapi.h:2600
SP_DEVINSTALL_PARAMS_A SP_DEVINSTALL_PARAMS
Definition: setupapi.h:1156
#define SetupDiGetDeviceRegistryProperty
Definition: setupapi.h:2604
#define DI_NEEDREBOOT
Definition: setupapi.h:54
struct _SP_DEVINFO_DATA SP_DEVINFO_DATA
#define SPDRP_CONFIGFLAGS
Definition: setupapi.h:518
#define SPDIT_COMPATDRIVER
Definition: setupapi.h:507
#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
#define SW_HIDE
Definition: winuser.h:779
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 830 of file newdev.c.

836{
837 PDEVINSTDATA DevInstData = NULL;
838 BOOL ret;
839 BOOL retval = FALSE;
840
841 TRACE("InstllDevInstEx(%p, %s, %d, %p, %lx)\n",
842 hWndParent, debugstr_w(InstanceId), bUpdate, lpReboot, Unknown);
843
844 DevInstData = HeapAlloc(GetProcessHeap(), 0, sizeof(DEVINSTDATA));
845 if (!DevInstData)
846 {
847 TRACE("HeapAlloc() failed\n");
849 goto cleanup;
850 }
851
852 /* Clear devinst data */
853 ZeroMemory(DevInstData, sizeof(DEVINSTDATA));
854 DevInstData->devInfoData.cbSize = 0; /* Tell if the devInfoData is valid */
855 DevInstData->bUpdate = bUpdate;
856
857 /* Fill devinst data */
859 if (DevInstData->hDevInfo == INVALID_HANDLE_VALUE)
860 {
861 TRACE("SetupDiCreateDeviceInfoListExW() failed with error 0x%x\n", GetLastError());
862 goto cleanup;
863 }
864
865 DevInstData->devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
867 DevInstData->hDevInfo,
869 NULL,
870 0, /* Open flags */
871 &DevInstData->devInfoData);
872 if (!ret)
873 {
874 TRACE("SetupDiOpenDeviceInfoW() failed with error 0x%x (InstanceId %s)\n",
876 DevInstData->devInfoData.cbSize = 0;
877 goto cleanup;
878 }
879
882 DevInstData->hDevInfo,
883 &DevInstData->devInfoData,
885 &DevInstData->regDataType,
886 NULL, 0,
887 &DevInstData->requiredSize);
888
889 if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER && DevInstData->regDataType == REG_SZ)
890 {
891 DevInstData->buffer = HeapAlloc(GetProcessHeap(), 0, DevInstData->requiredSize);
892 if (!DevInstData->buffer)
893 {
894 TRACE("HeapAlloc() failed\n");
896 }
897 else
898 {
900 DevInstData->hDevInfo,
901 &DevInstData->devInfoData,
903 &DevInstData->regDataType,
904 DevInstData->buffer, DevInstData->requiredSize,
905 &DevInstData->requiredSize);
906 }
907 }
908
909 if (!ret)
910 {
911 TRACE("SetupDiGetDeviceRegistryProperty() failed with error 0x%x (InstanceId %s)\n",
913 goto cleanup;
914 }
915
916 /* Prepare the wizard, and display it */
917 TRACE("Need to show install wizard\n");
919
920cleanup:
921 if (DevInstData)
922 {
923 if (DevInstData->devInfoData.cbSize != 0)
924 {
925 if (!SetupDiDestroyDriverInfoList(DevInstData->hDevInfo, &DevInstData->devInfoData, SPDIT_COMPATDRIVER))
926 TRACE("SetupDiDestroyDriverInfoList() failed with error 0x%lx\n", GetLastError());
927 }
928 if (DevInstData->hDevInfo != INVALID_HANDLE_VALUE)
929 {
930 if (!SetupDiDestroyDeviceInfoList(DevInstData->hDevInfo))
931 TRACE("SetupDiDestroyDeviceInfoList() failed with error 0x%lx\n", GetLastError());
932 }
933 HeapFree(GetProcessHeap(), 0, DevInstData->buffer);
934 HeapFree(GetProcessHeap(), 0, DevInstData);
935 }
936
937 return retval;
938}
@ Unknown
Definition: i8042prt.h:114

Referenced by InstallDevInst().