ReactOS 0.4.16-dev-1063-gd722e70
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 653 of file newdev.c.

658{
659 PDEVINSTDATA DevInstData = NULL;
660 BOOL ret;
661 DWORD config_flags;
662 BOOL retval = FALSE;
663
664 TRACE("(%p, %p, %s, %d)\n", hWndParent, hInstance, debugstr_w(InstanceId), Show);
665
666 if (!IsUserAdmin())
667 {
668 /* XP kills the process... */
670 }
671
672 DevInstData = HeapAlloc(GetProcessHeap(), 0, sizeof(DEVINSTDATA));
673 if (!DevInstData)
674 {
675 TRACE("HeapAlloc() failed\n");
677 goto cleanup;
678 }
679
680 /* Clear devinst data */
681 ZeroMemory(DevInstData, sizeof(DEVINSTDATA));
682 DevInstData->devInfoData.cbSize = 0; /* Tell if the devInfoData is valid */
683
684 /* Fill devinst data */
686 if (DevInstData->hDevInfo == INVALID_HANDLE_VALUE)
687 {
688 TRACE("SetupDiCreateDeviceInfoListExW() failed with error 0x%x\n", GetLastError());
689 goto cleanup;
690 }
691
692 DevInstData->devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
694 DevInstData->hDevInfo,
696 NULL,
697 0, /* Open flags */
698 &DevInstData->devInfoData);
699 if (!ret)
700 {
701 TRACE("SetupDiOpenDeviceInfoW() failed with error 0x%x (InstanceId %s)\n",
703 DevInstData->devInfoData.cbSize = 0;
704 goto cleanup;
705 }
706
709 DevInstData->hDevInfo,
710 &DevInstData->devInfoData,
712 &DevInstData->regDataType,
713 NULL, 0,
714 &DevInstData->requiredSize);
715
716 if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER && DevInstData->regDataType == REG_SZ)
717 {
718 DevInstData->buffer = HeapAlloc(GetProcessHeap(), 0, DevInstData->requiredSize);
719 if (!DevInstData->buffer)
720 {
721 TRACE("HeapAlloc() failed\n");
723 }
724 else
725 {
727 DevInstData->hDevInfo,
728 &DevInstData->devInfoData,
730 &DevInstData->regDataType,
731 DevInstData->buffer, DevInstData->requiredSize,
732 &DevInstData->requiredSize);
733 }
734 }
735 if (!ret)
736 {
737 TRACE("SetupDiGetDeviceRegistryProperty() failed with error 0x%x (InstanceId %s)\n",
739 goto cleanup;
740 }
741
743 DevInstData->hDevInfo,
744 &DevInstData->devInfoData,
746 NULL,
747 (BYTE *)&config_flags,
748 sizeof(config_flags),
749 NULL))
750 {
751 if (config_flags & CONFIGFLAG_FAILEDINSTALL)
752 {
753 /* The device is disabled */
754 TRACE("Device is disabled\n");
755 retval = TRUE;
756 goto cleanup;
757 }
758 }
759
760 TRACE("Installing %s (%s)\n", debugstr_w((PCWSTR)DevInstData->buffer), debugstr_w(InstanceId));
761
762 /* Search driver in default location and removable devices */
763 if (!PrepareFoldersToScan(DevInstData, FALSE, FALSE, NULL))
764 {
765 TRACE("PrepareFoldersToScan() failed with error 0x%lx\n", GetLastError());
766 goto cleanup;
767 }
768 if (ScanFoldersForDriver(DevInstData))
769 {
770 /* Driver found ; install it */
771 retval = InstallCurrentDriver(DevInstData);
772 TRACE("InstallCurrentDriver() returned %d\n", retval);
773 if (retval && Show != SW_HIDE)
774 {
775 /* Should we display the 'Need to reboot' page? */
776 SP_DEVINSTALL_PARAMS installParams;
777 installParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS);
779 DevInstData->hDevInfo,
780 &DevInstData->devInfoData,
781 &installParams))
782 {
783 if (installParams.Flags & (DI_NEEDRESTART | DI_NEEDREBOOT))
784 {
785 TRACE("Displaying 'Reboot' wizard page\n");
787 }
788 }
789 }
790 goto cleanup;
791 }
792 else if (Show == SW_HIDE)
793 {
794 /* We can't show the wizard. Fail the install */
795 TRACE("No wizard\n");
796 goto cleanup;
797 }
798
799 /* Prepare the wizard, and display it */
800 TRACE("Need to show install wizard\n");
802
803cleanup:
804 if (DevInstData)
805 {
806 if (DevInstData->devInfoData.cbSize != 0)
807 {
808 if (!SetupDiDestroyDriverInfoList(DevInstData->hDevInfo, &DevInstData->devInfoData, SPDIT_COMPATDRIVER))
809 TRACE("SetupDiDestroyDriverInfoList() failed with error 0x%lx\n", GetLastError());
810 }
811 if (DevInstData->hDevInfo != INVALID_HANDLE_VALUE)
812 {
813 if (!SetupDiDestroyDeviceInfoList(DevInstData->hDevInfo))
814 TRACE("SetupDiDestroyDeviceInfoList() failed with error 0x%lx\n", GetLastError());
815 }
816 HeapFree(GetProcessHeap(), 0, DevInstData->buffer);
817 HeapFree(GetProcessHeap(), 0, DevInstData);
818 }
819
820 return retval;
821}
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:1487
#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
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
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:537
BOOL DisplayWizard(IN PDEVINSTDATA DevInstData, IN HWND hwndParent, IN UINT startPage)
Definition: wizard.c:1378
#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 ret
int retval
Definition: wcstombs.cpp:91
#define ZeroMemory
Definition: winbase.h:1743
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
#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 826 of file newdev.c.

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

Referenced by InstallDevInst().