[devmgr]
authorChristoph von Wittich <christoph_vw@reactos.org>
Mon, 27 May 2013 18:33:18 +0000 (18:33 +0000)
committerChristoph von Wittich <christoph_vw@reactos.org>
Mon, 27 May 2013 18:33:18 +0000 (18:33 +0000)
add "update driver" button
not functional due to unimplemented DiShowUpdateDevice

svn path=/trunk/; revision=59090

reactos/dll/win32/devmgr/CMakeLists.txt
reactos/dll/win32/devmgr/advprop.c
reactos/dll/win32/devmgr/lang/de-DE.rc
reactos/dll/win32/devmgr/lang/en-US.rc
reactos/dll/win32/devmgr/precomp.h
reactos/dll/win32/devmgr/resource.h
reactos/dll/win32/newdev/stubs.c

index af6aa32..ffe276b 100644 (file)
@@ -18,6 +18,7 @@ target_link_libraries(devmgr uuid wine)
 add_importlibs(devmgr
     setupapi
     advapi32
+    newdev
     user32
     version
     msvcrt
index b4d4834..dfc8d35 100644 (file)
@@ -558,6 +558,56 @@ AdvProcDriverDlgProc(IN HWND hwndDlg,
                                        (ULONG_PTR)dap);
                         break;
                     }
+                    case IDC_UPDATEDRIVER:
+                    {
+                        if (dap->CurrentDeviceInfoSet != INVALID_HANDLE_VALUE)
+                        {
+                            BOOL NeedReboot;
+                            if (DiShowUpdateDevice(hwndDlg, dap->CurrentDeviceInfoSet, &dap->CurrentDeviceInfoData, 0, &NeedReboot))
+                            {
+                                if (NeedReboot)
+                                {                              
+                                    //FIXME: load text from resource file
+                                    if(MessageBoxW(hwndDlg, L"Reboot now?", L"Reboot required", MB_YESNO | MB_ICONQUESTION) == IDYES)
+                                    {
+                                        HANDLE hToken;
+                                        TOKEN_PRIVILEGES Privileges;
+
+                                        if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
+                                        {
+                                            DPRINT("OpenProcessToken failed\n");
+                                            break;
+                                        }
+
+                                        /* Get the LUID for the Shutdown privilege */
+                                        if (!LookupPrivilegeValueW(NULL, SE_SHUTDOWN_NAME, &Privileges.Privileges[0].Luid))
+                                        {
+                                            DPRINT("LookupPrivilegeValue failed\n");
+                                            break;
+                                        }
+
+                                        /* Assign the Shutdown privilege to our process */
+                                        Privileges.PrivilegeCount = 1;
+                                        Privileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+
+                                        if (!AdjustTokenPrivileges(hToken, FALSE, &Privileges, 0, NULL, NULL))
+                                        {
+                                            DPRINT("AdjustTokenPrivileges failed\n");
+                                            break;
+                                        }
+
+                                        /* Finally shut down the system */
+                                        if(!ExitWindowsEx(EWX_POWEROFF, SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER | SHTDN_REASON_FLAG_PLANNED))
+                                        {
+                                            DPRINT("ExitWindowsEx failed\n");
+                                            break;
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                        break;
+                    }
                 }
                 break;
             }
index b674d2b..d8c7d20 100644 (file)
@@ -172,8 +172,10 @@ BEGIN
      EDITTEXT IDC_DRVVERSION, 100, 67, 145, 12, NOT WS_TABSTOP | NOT WS_BORDER | ES_AUTOHSCROLL | ES_READONLY
      LTEXT "Signaturgeber:", -1, 37, 81, 60, 8, SS_NOPREFIX
      EDITTEXT IDC_DIGITALSIGNER, 100, 81, 145, 12, NOT WS_TABSTOP | NOT WS_BORDER | ES_AUTOHSCROLL | ES_READONLY
-     PUSHBUTTON "&Treiberdetails...", IDC_DRIVERDETAILS, 7, 106, 70, 15
+     PUSHBUTTON "&Treiberdetails...", IDC_DRIVERDETAILS, 7, 106, 75, 15
      LTEXT "Einzelheiten ├╝ber die Treiberdateien anzeigen.", -1, 91, 110, 154, 17, SS_NOPREFIX
+     PUSHBUTTON "Treiber &aktualisieren...", IDC_UPDATEDRIVER, 7, 126, 75, 15
+     LTEXT "Aktualisiert den Ger├Ątetreiber.", -1, 91, 130, 154, 17, SS_NOPREFIX 
 END
 
 IDD_DRIVERDETAILS DIALOGEX DISCARDABLE  0, 0, 224, 230
index ac8af43..6a1a891 100644 (file)
@@ -172,8 +172,10 @@ BEGIN
      EDITTEXT IDC_DRVVERSION, 100, 67, 145, 12, NOT WS_TABSTOP | NOT WS_BORDER | ES_AUTOHSCROLL | ES_READONLY
      LTEXT "Digital Signer:", -1, 37, 81, 60, 8, SS_NOPREFIX
      EDITTEXT IDC_DIGITALSIGNER, 100, 81, 145, 12, NOT WS_TABSTOP | NOT WS_BORDER | ES_AUTOHSCROLL | ES_READONLY
-     PUSHBUTTON "&Driver Details...", IDC_DRIVERDETAILS, 7, 106, 70, 15
+     PUSHBUTTON "&Driver Details", IDC_DRIVERDETAILS, 7, 106, 75, 15
      LTEXT "To view details about the driver files.", -1, 91, 110, 154, 17, SS_NOPREFIX
+     PUSHBUTTON "&Update Driver...", IDC_UPDATEDRIVER, 7, 126, 75, 15
+     LTEXT "Update the device driver.", -1, 91, 130, 154, 17, SS_NOPREFIX 
 END
 
 IDD_DRIVERDETAILS DIALOGEX DISCARDABLE  0, 0, 224, 230
index 6bffcfd..f403bf5 100644 (file)
@@ -8,6 +8,9 @@
 #include <regstr.h>
 #include <setupapi.h>
 #include <cfgmgr32.h>
+#undef WINVER
+#define WINVER _WIN32_WINNT_VISTA
+#include <newdev.h>
 #include <dll/devmgr/devmgr.h>
 
 #include "resource.h"
index 4c038b2..a2b2039 100644 (file)
@@ -40,6 +40,7 @@
 #define IDC_FILECOPYRIGHT      0x595
 #define IDC_DETAILSPROPNAME    0x596
 #define IDC_DETAILSPROPVALUE   0x597
+#define IDC_UPDATEDRIVER       0x598
 
 #define IDS_NAME               0x100
 #define IDS_TYPE               0x101
index 4c1164e..ba846aa 100644 (file)
@@ -57,13 +57,19 @@ InstallSelectedDriverW(
 */
 BOOL WINAPI
 DiShowUpdateDevice(
-       IN HWND hwndParent OPTIONAL,
-       IN HDEVINFO DeviceInfoSet,
-       IN PSP_DEVINFO_DATA DeviceInfoData,
-       IN DWORD Flags,
-       OUT PBOOL NeedReboot OPTIONAL)
+    IN HWND hwndParent OPTIONAL,
+    IN HDEVINFO DeviceInfoSet,
+    IN PSP_DEVINFO_DATA DeviceInfoData,
+    IN DWORD Flags,
+    OUT PBOOL NeedReboot OPTIONAL)
 {
-       UNIMPLEMENTED;
-       SetLastError(ERROR_GEN_FAILURE);
-       return FALSE;
+    if (Flags != 0)
+    {
+        SetLastError(ERROR_INVALID_FLAGS);
+        return FALSE;
+    }
+    UNIMPLEMENTED;
+    SetLastError(ERROR_GEN_FAILURE);
+    return FALSE;
 }