ReactOS 0.4.15-dev-7906-g1b85a5f
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 645 of file newdev.c.

650{
651 PDEVINSTDATA DevInstData = NULL;
652 BOOL ret;
653 DWORD config_flags;
654 BOOL retval = FALSE;
655
656 TRACE("(%p, %p, %s, %d)\n", hWndParent, hInstance, debugstr_w(InstanceId), Show);
657
658 if (!IsUserAdmin())
659 {
660 /* XP kills the process... */
662 }
663
664 DevInstData = HeapAlloc(GetProcessHeap(), 0, sizeof(DEVINSTDATA));
665 if (!DevInstData)
666 {
667 TRACE("HeapAlloc() failed\n");
669 goto cleanup;
670 }
671
672 /* Clear devinst data */
673 ZeroMemory(DevInstData, sizeof(DEVINSTDATA));
674 DevInstData->devInfoData.cbSize = 0; /* Tell if the devInfoData is valid */
675
676 /* Fill devinst data */
678 if (DevInstData->hDevInfo == INVALID_HANDLE_VALUE)
679 {
680 TRACE("SetupDiCreateDeviceInfoListExW() failed with error 0x%x\n", GetLastError());
681 goto cleanup;
682 }
683
684 DevInstData->devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
686 DevInstData->hDevInfo,
688 NULL,
689 0, /* Open flags */
690 &DevInstData->devInfoData);
691 if (!ret)
692 {
693 TRACE("SetupDiOpenDeviceInfoW() failed with error 0x%x (InstanceId %s)\n",
695 DevInstData->devInfoData.cbSize = 0;
696 goto cleanup;
697 }
698
701 DevInstData->hDevInfo,
702 &DevInstData->devInfoData,
704 &DevInstData->regDataType,
705 NULL, 0,
706 &DevInstData->requiredSize);
707
708 if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER && DevInstData->regDataType == REG_SZ)
709 {
710 DevInstData->buffer = HeapAlloc(GetProcessHeap(), 0, DevInstData->requiredSize);
711 if (!DevInstData->buffer)
712 {
713 TRACE("HeapAlloc() failed\n");
715 }
716 else
717 {
719 DevInstData->hDevInfo,
720 &DevInstData->devInfoData,
722 &DevInstData->regDataType,
723 DevInstData->buffer, DevInstData->requiredSize,
724 &DevInstData->requiredSize);
725 }
726 }
727 if (!ret)
728 {
729 TRACE("SetupDiGetDeviceRegistryProperty() failed with error 0x%x (InstanceId %s)\n",
731 goto cleanup;
732 }
733
735 DevInstData->hDevInfo,
736 &DevInstData->devInfoData,
738 NULL,
739 (BYTE *)&config_flags,
740 sizeof(config_flags),
741 NULL))
742 {
743 if (config_flags & CONFIGFLAG_FAILEDINSTALL)
744 {
745 /* The device is disabled */
746 TRACE("Device is disabled\n");
747 retval = TRUE;
748 goto cleanup;
749 }
750 }
751
752 TRACE("Installing %s (%s)\n", debugstr_w((PCWSTR)DevInstData->buffer), debugstr_w(InstanceId));
753
754 /* Search driver in default location and removable devices */
755 if (!PrepareFoldersToScan(DevInstData, FALSE, FALSE, NULL))
756 {
757 TRACE("PrepareFoldersToScan() failed with error 0x%lx\n", GetLastError());
758 goto cleanup;
759 }
760 if (ScanFoldersForDriver(DevInstData))
761 {
762 /* Driver found ; install it */
763 retval = InstallCurrentDriver(DevInstData);
764 TRACE("InstallCurrentDriver() returned %d\n", retval);
765 if (retval && Show != SW_HIDE)
766 {
767 /* Should we display the 'Need to reboot' page? */
768 SP_DEVINSTALL_PARAMS installParams;
769 installParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS);
771 DevInstData->hDevInfo,
772 &DevInstData->devInfoData,
773 &installParams))
774 {
775 if (installParams.Flags & (DI_NEEDRESTART | DI_NEEDREBOOT))
776 {
777 TRACE("Displaying 'Reboot' wizard page\n");
778 retval = DisplayWizard(DevInstData, hWndParent, IDD_NEEDREBOOT);
779 }
780 }
781 }
782 goto cleanup;
783 }
784 else if (Show == SW_HIDE)
785 {
786 /* We can't show the wizard. Fail the install */
787 TRACE("No wizard\n");
788 goto cleanup;
789 }
790
791 /* Prepare the wizard, and display it */
792 TRACE("Need to show install wizard\n");
793 retval = DisplayWizard(DevInstData, hWndParent, IDD_WELCOMEPAGE);
794
795cleanup:
796 if (DevInstData)
797 {
798 if (DevInstData->devInfoData.cbSize != 0)
799 {
800 if (!SetupDiDestroyDriverInfoList(DevInstData->hDevInfo, &DevInstData->devInfoData, SPDIT_COMPATDRIVER))
801 TRACE("SetupDiDestroyDriverInfoList() failed with error 0x%lx\n", GetLastError());
802 }
803 if (DevInstData->hDevInfo != INVALID_HANDLE_VALUE)
804 {
805 if (!SetupDiDestroyDeviceInfoList(DevInstData->hDevInfo))
806 TRACE("SetupDiDestroyDeviceInfoList() failed with error 0x%lx\n", GetLastError());
807 }
808 HeapFree(GetProcessHeap(), 0, DevInstData->buffer);
809 HeapFree(GetProcessHeap(), 0, DevInstData);
810 }
811
812 return retval;
813}
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:420
BOOL PrepareFoldersToScan(IN PDEVINSTDATA DevInstData, IN BOOL IncludeRemovableDevices, IN BOOL IncludeCustomPath, IN HWND hwndCombo OPTIONAL)
Definition: newdev.c:455
BOOL InstallCurrentDriver(IN PDEVINSTDATA DevInstData)
Definition: newdev.c:529
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:507
#define SetupDiGetDeviceInstallParams
Definition: setupapi.h:2599
SP_DEVINSTALL_PARAMS_A SP_DEVINSTALL_PARAMS
Definition: setupapi.h:1155
#define SetupDiGetDeviceRegistryProperty
Definition: setupapi.h:2603
#define DI_NEEDREBOOT
Definition: setupapi.h:54
struct _SP_DEVINFO_DATA SP_DEVINFO_DATA
#define SPDRP_CONFIGFLAGS
Definition: setupapi.h:517
#define SPDIT_COMPATDRIVER
Definition: setupapi.h:506
#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
#define ZeroMemory
Definition: winbase.h:1712
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
#define SW_HIDE
Definition: winuser.h:768
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 818 of file newdev.c.

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

Referenced by InstallDevInst().