Fix indentation by replacing tabs by spaces. No code change
authorHervé Poussineau <hpoussin@reactos.org>
Tue, 30 May 2006 19:40:52 +0000 (19:40 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Tue, 30 May 2006 19:40:52 +0000 (19:40 +0000)
svn path=/trunk/; revision=22119

reactos/subsystems/win32/win32k/objects/dc.c

index 40193f7..4d82639 100644 (file)
@@ -53,14 +53,14 @@ static GDIDEVICE PrimarySurface;
 func_type STDCALL  func_name( HDC hdc ) \
 {                                   \
   func_type  ft;                    \
-  PDC  dc = DC_LockDc( hdc );  \
+  PDC  dc = DC_LockDc( hdc );       \
   if (!dc)                          \
   {                                 \
     SetLastWin32Error(ERROR_INVALID_HANDLE); \
     return 0;                       \
   }                                 \
   ft = dc->dc_field;                \
-  DC_UnlockDc(dc);                             \
+  DC_UnlockDc(dc);                  \
   return ft;                        \
 }
 
@@ -650,7 +650,7 @@ IntPrepareDriver()
       /* Complete initialization of the physical device */
       PrimarySurface.DriverFunctions.CompletePDEV(
          PrimarySurface.PDev,
-        (HDEV)&PrimarySurface);
+         (HDEV)&PrimarySurface);
 
       DPRINT("calling DRIVER_ReferenceDriver\n");
 
@@ -733,7 +733,7 @@ IntCreatePrimarySurface()
    RECTL SurfaceRect;
    SURFOBJ *SurfObj;
    BOOL calledFromUser;
-   
+
    if (! IntPrepareDriverIfNeeded())
    {
       return FALSE;
@@ -793,8 +793,8 @@ IntCreatePrimarySurface()
 VOID FASTCALL
 IntDestroyPrimarySurface()
   {
-    BOOL calledFromUser; 
-     
+    BOOL calledFromUser;
+
     DRIVER_UnreferenceDriver(L"DISPLAY");
 
     calledFromUser = UserIsEntered();
@@ -838,7 +838,7 @@ IntGdiCreateDC(PUNICODE_STRING Driver,
   HRGN     hVisRgn;
   UNICODE_STRING StdDriver;
   BOOL calledFromUser;
-  
+
   RtlInitUnicodeString(&StdDriver, L"DISPLAY");
 
   if (NULL == Driver || 0 == RtlCompareUnicodeString(Driver, &StdDriver, TRUE))
@@ -857,20 +857,20 @@ IntGdiCreateDC(PUNICODE_STRING Driver,
           if (!calledFromUser){
              UserEnterExclusive();
           }
-          
+
           if (! co_IntGraphicsCheck(TRUE))
           {
             if (!calledFromUser){
                UserLeave();
-            } 
+            }
             DPRINT1("Unable to initialize graphics, returning NULL dc\n");
             return NULL;
           }
-          
+
           if (!calledFromUser){
             UserLeave();
-          } 
-          
+          }
+
         }
     }
 
@@ -904,7 +904,7 @@ IntGdiCreateDC(PUNICODE_STRING Driver,
   NewDC->DevInfo = &PrimarySurface.DevInfo;
   NewDC->GDIInfo = &PrimarySurface.GDIInfo;
   memcpy(NewDC->FillPatternSurfaces, PrimarySurface.FillPatterns,
-        sizeof(NewDC->FillPatternSurfaces));
+  sizeof(NewDC->FillPatternSurfaces));
   NewDC->PDev = PrimarySurface.PDev;
   NewDC->GDIDevice = (HDEV)&PrimarySurface;
   NewDC->DriverFunctions = PrimarySurface.DriverFunctions;
@@ -1078,7 +1078,7 @@ NtGdiDeleteObjectApp(HANDLE  DCHandle)
       SetLastWin32Error(ERROR_INVALID_HANDLE);
       return FALSE;
     }
-  
+
   DCToDelete = DC_LockDc(DCHandle);
   if (DCToDelete == NULL)
     {
@@ -1411,104 +1411,104 @@ NtGdiSetDCState ( HDC hDC, HDC hDCSave )
     {
       if ( dcs->w.flags & DC_SAVED )
       {
-       dc->w.flags            = dcs->w.flags & ~DC_SAVED;
+        dc->w.flags            = dcs->w.flags & ~DC_SAVED;
 
-       dc->w.hFirstBitmap     = dcs->w.hFirstBitmap;
+        dc->w.hFirstBitmap     = dcs->w.hFirstBitmap;
 
 #if 0
-       dc->w.hDevice          = dcs->w.hDevice;
+        dc->w.hDevice          = dcs->w.hDevice;
 #endif
 
-       dc->w.totalExtent      = dcs->w.totalExtent;
-       dc->w.ROPmode          = dcs->w.ROPmode;
-       dc->w.polyFillMode     = dcs->w.polyFillMode;
-       dc->w.stretchBltMode   = dcs->w.stretchBltMode;
-       dc->w.relAbsMode       = dcs->w.relAbsMode;
-       dc->w.backgroundMode   = dcs->w.backgroundMode;
-       dc->w.backgroundColor  = dcs->w.backgroundColor;
-       dc->w.textColor        = dcs->w.textColor;
-       dc->w.brushOrgX        = dcs->w.brushOrgX;
-       dc->w.brushOrgY        = dcs->w.brushOrgY;
-       dc->w.textAlign        = dcs->w.textAlign;
-       dc->w.charExtra        = dcs->w.charExtra;
-       dc->w.breakTotalExtra  = dcs->w.breakTotalExtra;
-       dc->w.breakCount       = dcs->w.breakCount;
-       dc->w.breakExtra       = dcs->w.breakExtra;
-       dc->w.breakRem         = dcs->w.breakRem;
-       dc->w.MapMode          = dcs->w.MapMode;
-       dc->w.GraphicsMode     = dcs->w.GraphicsMode;
+        dc->w.totalExtent      = dcs->w.totalExtent;
+        dc->w.ROPmode          = dcs->w.ROPmode;
+        dc->w.polyFillMode     = dcs->w.polyFillMode;
+        dc->w.stretchBltMode   = dcs->w.stretchBltMode;
+        dc->w.relAbsMode       = dcs->w.relAbsMode;
+        dc->w.backgroundMode   = dcs->w.backgroundMode;
+        dc->w.backgroundColor  = dcs->w.backgroundColor;
+        dc->w.textColor        = dcs->w.textColor;
+        dc->w.brushOrgX        = dcs->w.brushOrgX;
+        dc->w.brushOrgY        = dcs->w.brushOrgY;
+        dc->w.textAlign        = dcs->w.textAlign;
+        dc->w.charExtra        = dcs->w.charExtra;
+        dc->w.breakTotalExtra  = dcs->w.breakTotalExtra;
+        dc->w.breakCount       = dcs->w.breakCount;
+        dc->w.breakExtra       = dcs->w.breakExtra;
+        dc->w.breakRem         = dcs->w.breakRem;
+        dc->w.MapMode          = dcs->w.MapMode;
+        dc->w.GraphicsMode     = dcs->w.GraphicsMode;
 #if 0
-       /* Apparently, the DC origin is not changed by [GS]etDCState */
-       dc->w.DCOrgX           = dcs->w.DCOrgX;
-       dc->w.DCOrgY           = dcs->w.DCOrgY;
+        /* Apparently, the DC origin is not changed by [GS]etDCState */
+        dc->w.DCOrgX           = dcs->w.DCOrgX;
+        dc->w.DCOrgY           = dcs->w.DCOrgY;
 #endif
-       dc->w.CursPosX         = dcs->w.CursPosX;
-       dc->w.CursPosY         = dcs->w.CursPosY;
-       dc->w.ArcDirection     = dcs->w.ArcDirection;
-
-       dc->w.xformWorld2Wnd   = dcs->w.xformWorld2Wnd;
-       dc->w.xformWorld2Vport = dcs->w.xformWorld2Vport;
-       dc->w.xformVport2World = dcs->w.xformVport2World;
-       dc->w.vport2WorldValid = dcs->w.vport2WorldValid;
-
-       dc->wndOrgX            = dcs->wndOrgX;
-       dc->wndOrgY            = dcs->wndOrgY;
-       dc->wndExtX            = dcs->wndExtX;
-       dc->wndExtY            = dcs->wndExtY;
-       dc->vportOrgX          = dcs->vportOrgX;
-       dc->vportOrgY          = dcs->vportOrgY;
-       dc->vportExtX          = dcs->vportExtX;
-       dc->vportExtY          = dcs->vportExtY;
+        dc->w.CursPosX         = dcs->w.CursPosX;
+        dc->w.CursPosY         = dcs->w.CursPosY;
+        dc->w.ArcDirection     = dcs->w.ArcDirection;
+
+        dc->w.xformWorld2Wnd   = dcs->w.xformWorld2Wnd;
+        dc->w.xformWorld2Vport = dcs->w.xformWorld2Vport;
+        dc->w.xformVport2World = dcs->w.xformVport2World;
+        dc->w.vport2WorldValid = dcs->w.vport2WorldValid;
+
+        dc->wndOrgX            = dcs->wndOrgX;
+        dc->wndOrgY            = dcs->wndOrgY;
+        dc->wndExtX            = dcs->wndExtX;
+        dc->wndExtY            = dcs->wndExtY;
+        dc->vportOrgX          = dcs->vportOrgX;
+        dc->vportOrgY          = dcs->vportOrgY;
+        dc->vportExtX          = dcs->vportExtX;
+        dc->vportExtY          = dcs->vportExtY;
         dc->PalIndexed         = dcs->PalIndexed;
 
-       if (!(dc->w.flags & DC_MEMORY))
-       {
-         dc->w.bitsPerPixel = dcs->w.bitsPerPixel;
-       }
+        if (!(dc->w.flags & DC_MEMORY))
+        {
+          dc->w.bitsPerPixel = dcs->w.bitsPerPixel;
+        }
 
 #if 0
-       if (dcs->w.hClipRgn)
-       {
-         if (!dc->w.hClipRgn)
-         {
-           dc->w.hClipRgn = NtGdiCreateRectRgn( 0, 0, 0, 0 );
-         }
-         NtGdiCombineRgn( dc->w.hClipRgn, dcs->w.hClipRgn, 0, RGN_COPY );
-       }
-       else
-       {
-         if (dc->w.hClipRgn)
-         {
-           NtGdiDeleteObject( dc->w.hClipRgn );
-         }
-
-         dc->w.hClipRgn = 0;
-       }
-       {
-               int res;
-               res = CLIPPING_UpdateGCRegion( dc );
-               ASSERT ( res != ERROR );
-       }
-       DC_UnlockDc ( dc );
+        if (dcs->w.hClipRgn)
+        {
+          if (!dc->w.hClipRgn)
+          {
+            dc->w.hClipRgn = NtGdiCreateRectRgn( 0, 0, 0, 0 );
+          }
+          NtGdiCombineRgn( dc->w.hClipRgn, dcs->w.hClipRgn, 0, RGN_COPY );
+        }
+        else
+        {
+          if (dc->w.hClipRgn)
+          {
+            NtGdiDeleteObject( dc->w.hClipRgn );
+          }
+
+          dc->w.hClipRgn = 0;
+        }
+        {
+          int res;
+          res = CLIPPING_UpdateGCRegion( dc );
+          ASSERT ( res != ERROR );
+        }
+        DC_UnlockDc ( dc );
 #else
-       DC_UnlockDc ( dc );
-       NtGdiSelectClipRgn(hDC, dcs->w.hClipRgn);
+        DC_UnlockDc ( dc );
+        NtGdiSelectClipRgn(hDC, dcs->w.hClipRgn);
 #endif
 
-       NtGdiSelectObject( hDC, dcs->w.hBitmap );
-       NtGdiSelectObject( hDC, dcs->w.hBrush );
-       NtGdiSelectObject( hDC, dcs->w.hFont );
-       NtGdiSelectObject( hDC, dcs->w.hPen );
-       NtGdiSetBkColor( hDC, dcs->w.backgroundColor);
-       NtGdiSetTextColor( hDC, dcs->w.textColor);
+        NtGdiSelectObject( hDC, dcs->w.hBitmap );
+        NtGdiSelectObject( hDC, dcs->w.hBrush );
+        NtGdiSelectObject( hDC, dcs->w.hFont );
+        NtGdiSelectObject( hDC, dcs->w.hPen );
+        NtGdiSetBkColor( hDC, dcs->w.backgroundColor);
+        NtGdiSetTextColor( hDC, dcs->w.textColor);
 
-       NtGdiSelectPalette( hDC, dcs->w.hPalette, FALSE );
+        NtGdiSelectPalette( hDC, dcs->w.hPalette, FALSE );
 
 #if 0
-       GDISelectPalette16( hDC, dcs->w.hPalette, FALSE );
+        GDISelectPalette16( hDC, dcs->w.hPalette, FALSE );
 #endif
       } else {
-       DC_UnlockDc(dc);
+        DC_UnlockDc(dc);
       }
       DC_UnlockDc ( dcs );
     } else {
@@ -1624,7 +1624,7 @@ IntGdiGetDeviceCaps(PDC dc, INT Index)
       }
       else
       {
-       ret = 0;
+        ret = 0;
       }
       break;
 
@@ -1635,7 +1635,7 @@ IntGdiGetDeviceCaps(PDC dc, INT Index)
       }
       else
       {
-       ret = 0;
+        ret = 0;
       }
       break;
 
@@ -1646,7 +1646,7 @@ IntGdiGetDeviceCaps(PDC dc, INT Index)
       }
       else
       {
-       ret = 0;
+        ret = 0;
       }
       break;
 
@@ -1657,7 +1657,7 @@ IntGdiGetDeviceCaps(PDC dc, INT Index)
       }
       else
       {
-       ret = 0;
+        ret = 0;
       }
       break;
 
@@ -1672,7 +1672,7 @@ IntGdiGetDeviceCaps(PDC dc, INT Index)
       }
       else
       {
-       ret = 0;
+        ret = 0;
       }
       break;
 
@@ -1683,7 +1683,7 @@ IntGdiGetDeviceCaps(PDC dc, INT Index)
       }
       else
       {
-       ret = 0;
+        ret = 0;
       }
       break;
 
@@ -1802,12 +1802,12 @@ NtGdiGetObject(HANDLE handle, INT count, LPVOID buffer)
 
   /* From Wine: GetObject does not SetLastError() on a null object */
   if (!handle) return 0;
-  
+
   if (count <= 0)
   {
     return 0;
   }
-  
+
   _SEH_TRY
   {
     ProbeForWrite(buffer,
@@ -1819,7 +1819,7 @@ NtGdiGetObject(HANDLE handle, INT count, LPVOID buffer)
     Status = _SEH_GetExceptionCode();
   }
   _SEH_END;
-  
+
   if(!NT_SUCCESS(Status))
   {
     SetLastNtError(Status);
@@ -1985,7 +1985,7 @@ NtGdiRestoreDC(HDC  hDC, INT  SaveLevel)
     DC_SetNextDC (dcs, DC_GetNextDC (dcs));
     if (--dc->saveLevel < SaveLevel)
       {
-       DC_UnlockDc( dc );
+        DC_UnlockDc( dc );
         DC_UnlockDc( dcs );
         NtGdiSetDCState(hDC, hdcs);
 #if 0
@@ -1996,11 +1996,11 @@ NtGdiRestoreDC(HDC  hDC, INT  SaveLevel)
           success = FALSE;
         }
 #endif
-       dc = DC_LockDc(hDC);
-       if(!dc)
-       {
-         return FALSE;
-       }
+        dc = DC_LockDc(hDC);
+        if(!dc)
+        {
+          return FALSE;
+        }
       }
     else
       {
@@ -2077,17 +2077,17 @@ NtGdiSelectObject(HDC  hDC, HGDIOBJ  hGDIObj)
   HRGN hVisRgn;
   BOOLEAN Failed;
 
-  if (!hDC || !hGDIObj) 
+  if (!hDC || !hGDIObj)
     {
     /* From Wine:
      * SelectObject() with a NULL DC returns 0 and sets ERROR_INVALID_HANDLE.
      * Note: Under XP at least invalid ptrs can also be passed, not just NULL;
      *       Don't test that here in case it crashes earlier win versions.
      */
-       if (!hDC) SetLastWin32Error(ERROR_INVALID_HANDLE); 
+       if (!hDC) SetLastWin32Error(ERROR_INVALID_HANDLE);
        return NULL;
     }
-    
+
   dc = DC_LockDc(hDC);
   if (NULL == dc)
     {
@@ -2162,11 +2162,11 @@ NtGdiSelectObject(HDC  hDC, HGDIOBJ  hGDIObj)
         }
       pb = BITMAPOBJ_LockBitmap(hGDIObj);
       if (NULL == pb)
-       {
-         SetLastWin32Error(ERROR_INVALID_HANDLE);
+        {
+          SetLastWin32Error(ERROR_INVALID_HANDLE);
           DC_UnlockDc(dc);
-         return NULL;
-       }
+          return NULL;
+        }
       objOrg = (HGDIOBJ)dc->w.hBitmap;
 
       /* Release the old bitmap, lock the new one and convert it to a SURF */
@@ -2758,7 +2758,7 @@ IntChangeDisplaySettings(
    DPRINT1("flag CDS_TEST UNIMPLEMENT");
    Ret = DISP_CHANGE_FAILED;
   }
-  
+
   if ((dwflags & CDS_FULLSCREEN) == CDS_FULLSCREEN)
   {
    DEVMODE lpDevMode;
@@ -2783,143 +2783,142 @@ IntChangeDisplaySettings(
    if ((lpDevMode.dmBitsPerPel == DevMode->dmBitsPerPel) &&
        (lpDevMode.dmPelsWidth  == DevMode->dmPelsWidth) &&
        (lpDevMode.dmPelsHeight == DevMode->dmPelsHeight))
-          Ret = DISP_CHANGE_SUCCESSFUL; 
+         Ret = DISP_CHANGE_SUCCESSFUL;
   }
 
   if ((dwflags & CDS_VIDEOPARAMETERS) == CDS_VIDEOPARAMETERS)
-  {  
+  {
     dwflags &= ~CDS_VIDEOPARAMETERS;
-    if (lParam == NULL) Ret=DISP_CHANGE_BADPARAM;
-       else
-       {
-               DPRINT1("flag CDS_VIDEOPARAMETERS UNIMPLEMENT");
-               Ret = DISP_CHANGE_FAILED;
-       }
+    if (lParam == NULL)
+      Ret=DISP_CHANGE_BADPARAM;
+    else
+    {
+      DPRINT1("flag CDS_VIDEOPARAMETERS UNIMPLEMENT");
+      Ret = DISP_CHANGE_FAILED;
+    }
 
-  }    
+  }
 
   if ((dwflags & CDS_UPDATEREGISTRY) == CDS_UPDATEREGISTRY)
-  {  
-  
-               UNICODE_STRING ObjectName;
-               UNICODE_STRING KernelModeName;
-               WCHAR KernelModeNameBuffer[256];
-               UNICODE_STRING RegistryKey;
-               WCHAR RegistryKeyBuffer[512];
-               PDEVICE_OBJECT DeviceObject;            
-               ULONG LastSlash;
-               OBJECT_ATTRIBUTES ObjectAttributes;
-               HANDLE DevInstRegKey;
-               ULONG NewValue;
-               
-
-               DPRINT1("set CDS_UPDATEREGISTRY \n");
-               
-               dwflags &= ~CDS_UPDATEREGISTRY; 
-
-               /* Get device name (pDeviceName is "\.\xxx") */
-               for (LastSlash = pDeviceName->Length / sizeof(WCHAR); LastSlash > 0; LastSlash--)
-               {
-                       if (pDeviceName->Buffer[LastSlash - 1] == L'\\')
-                               break;
-               }
-               
-               if (LastSlash == 0) return DISP_CHANGE_RESTART;
-               ObjectName = *pDeviceName;
-               ObjectName.Length -= LastSlash * sizeof(WCHAR);
-               ObjectName.MaximumLength -= LastSlash * sizeof(WCHAR);
-               ObjectName.Buffer += LastSlash;
-
-               KernelModeName.Length = 0;
-               KernelModeName.MaximumLength = sizeof(KernelModeNameBuffer);
-               KernelModeName.Buffer = KernelModeNameBuffer;
-
-               /* Open \??\xxx (ex: "\??\DISPLAY1") */
-               Status = RtlAppendUnicodeToString(&KernelModeName, L"\\??\\");
-               
-               if (!NT_SUCCESS(Status)) return DISP_CHANGE_FAILED;
-               Status = RtlAppendUnicodeStringToString(&KernelModeName, &ObjectName);
-               
-               if (!NT_SUCCESS(Status)) return DISP_CHANGE_FAILED;
-               Status = ObReferenceObjectByName(
-                       &KernelModeName,
-                       OBJ_CASE_INSENSITIVE,
-                       NULL,
-                       0,
-                       IoDeviceObjectType,
-                       KernelMode,
-                       NULL,
-                       (PVOID*)&DeviceObject);
-
-               if (!NT_SUCCESS(Status)) return DISP_CHANGE_FAILED;
-               /* Get associated driver name (ex: "VBE") */
-               for (LastSlash = DeviceObject->DriverObject->DriverName.Length / sizeof(WCHAR); LastSlash > 0; LastSlash--)
-               {
-                       if (DeviceObject->DriverObject->DriverName.Buffer[LastSlash - 1] == L'\\')
-                               break;
-               }
-
-               if (LastSlash == 0) { ObDereferenceObject(DeviceObject); return DISP_CHANGE_FAILED; }
-               ObjectName = DeviceObject->DriverObject->DriverName;
-               ObjectName.Length -= LastSlash * sizeof(WCHAR);
-               ObjectName.MaximumLength -= LastSlash * sizeof(WCHAR);
-               ObjectName.Buffer += LastSlash;
-
-               RegistryKey.Length = 0;
-               RegistryKey.MaximumLength = sizeof(RegistryKeyBuffer);
-               RegistryKey.Buffer = RegistryKeyBuffer;
-
-               /* Open registry key */
-               Status = RtlAppendUnicodeToString(&RegistryKey,
-                       L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\");
-               
-               if (!NT_SUCCESS(Status)) { ObDereferenceObject(DeviceObject); return DISP_CHANGE_FAILED; }
-               Status = RtlAppendUnicodeStringToString(&RegistryKey, &ObjectName);
-
-               if (!NT_SUCCESS(Status)) { ObDereferenceObject(DeviceObject); return DISP_CHANGE_FAILED; }
-               Status = RtlAppendUnicodeToString(&RegistryKey,
-                       L"\\Device0");
-
-               if (!NT_SUCCESS(Status)) { ObDereferenceObject(DeviceObject); return DISP_CHANGE_FAILED; }
-
-               InitializeObjectAttributes(&ObjectAttributes, &RegistryKey,
-                       OBJ_CASE_INSENSITIVE, NULL, NULL);
-               Status = ZwOpenKey(&DevInstRegKey, GENERIC_READ | GENERIC_WRITE, &ObjectAttributes);
-               ObDereferenceObject(DeviceObject);
-               if (!NT_SUCCESS(Status)) return DISP_CHANGE_FAILED;
-
-               /* Update needed fields */
-               if (NT_SUCCESS(Status) && DevMode->dmFields & DM_BITSPERPEL)
-               {
-                       RtlInitUnicodeString(&RegistryKey, L"DefaultSettings.BitsPerPel");
-                       NewValue = DevMode->dmBitsPerPel;
-                       Status = ZwSetValueKey(DevInstRegKey, &RegistryKey, 0, REG_DWORD, &NewValue, sizeof(NewValue));                 
-               }
-
-               if (NT_SUCCESS(Status) && DevMode->dmFields & DM_PELSWIDTH)
-               {
-                       RtlInitUnicodeString(&RegistryKey, L"DefaultSettings.XResolution");
-                       NewValue = DevMode->dmPelsWidth;                        
-                       Status = ZwSetValueKey(DevInstRegKey, &RegistryKey, 0, REG_DWORD, &NewValue, sizeof(NewValue));                 
-               }
-
-               if (NT_SUCCESS(Status) && DevMode->dmFields & DM_PELSHEIGHT)
-               {
-                       RtlInitUnicodeString(&RegistryKey, L"DefaultSettings.YResolution");
-                       NewValue = DevMode->dmPelsHeight;
-                       Status = ZwSetValueKey(DevInstRegKey, &RegistryKey, 0, REG_DWORD, &NewValue, sizeof(NewValue));                 
-               }
-
-               ZwClose(DevInstRegKey);
-               if (NT_SUCCESS(Status))
-                       Ret = DISP_CHANGE_RESTART;
-               else
-                       /* return DISP_CHANGE_NOTUPDATED when we can save to reg only vaild for NT */ 
-                       Ret = DISP_CHANGE_NOTUPDATED;
-               
+  {
+
+    UNICODE_STRING ObjectName;
+    UNICODE_STRING KernelModeName;
+    WCHAR KernelModeNameBuffer[256];
+    UNICODE_STRING RegistryKey;
+    WCHAR RegistryKeyBuffer[512];
+    PDEVICE_OBJECT DeviceObject;
+    ULONG LastSlash;
+    OBJECT_ATTRIBUTES ObjectAttributes;
+    HANDLE DevInstRegKey;
+    ULONG NewValue;
+
+    DPRINT1("set CDS_UPDATEREGISTRY \n");
+
+    dwflags &= ~CDS_UPDATEREGISTRY;
+
+    /* Get device name (pDeviceName is "\.\xxx") */
+    for (LastSlash = pDeviceName->Length / sizeof(WCHAR); LastSlash > 0; LastSlash--)
+    {
+      if (pDeviceName->Buffer[LastSlash - 1] == L'\\')
+        break;
+    }
+
+    if (LastSlash == 0) return DISP_CHANGE_RESTART;
+    ObjectName = *pDeviceName;
+    ObjectName.Length -= LastSlash * sizeof(WCHAR);
+    ObjectName.MaximumLength -= LastSlash * sizeof(WCHAR);
+    ObjectName.Buffer += LastSlash;
+
+    KernelModeName.Length = 0;
+    KernelModeName.MaximumLength = sizeof(KernelModeNameBuffer);
+    KernelModeName.Buffer = KernelModeNameBuffer;
+
+    /* Open \??\xxx (ex: "\??\DISPLAY1") */
+    Status = RtlAppendUnicodeToString(&KernelModeName, L"\\??\\");
+
+    if (!NT_SUCCESS(Status)) return DISP_CHANGE_FAILED;
+    Status = RtlAppendUnicodeStringToString(&KernelModeName, &ObjectName);
+
+    if (!NT_SUCCESS(Status)) return DISP_CHANGE_FAILED;
+    Status = ObReferenceObjectByName(
+      &KernelModeName,
+      OBJ_CASE_INSENSITIVE,
+      NULL,
+      0,
+      IoDeviceObjectType,
+      KernelMode,
+      NULL,
+      (PVOID*)&DeviceObject);
+
+    if (!NT_SUCCESS(Status)) return DISP_CHANGE_FAILED;
+    /* Get associated driver name (ex: "VBE") */
+    for (LastSlash = DeviceObject->DriverObject->DriverName.Length / sizeof(WCHAR); LastSlash > 0; LastSlash--)
+    {
+      if (DeviceObject->DriverObject->DriverName.Buffer[LastSlash - 1] == L'\\')
+        break;
+    }
+
+    if (LastSlash == 0) { ObDereferenceObject(DeviceObject); return DISP_CHANGE_FAILED; }
+    ObjectName = DeviceObject->DriverObject->DriverName;
+    ObjectName.Length -= LastSlash * sizeof(WCHAR);
+    ObjectName.MaximumLength -= LastSlash * sizeof(WCHAR);
+    ObjectName.Buffer += LastSlash;
+
+    RegistryKey.Length = 0;
+    RegistryKey.MaximumLength = sizeof(RegistryKeyBuffer);
+    RegistryKey.Buffer = RegistryKeyBuffer;
+
+    /* Open registry key */
+    Status = RtlAppendUnicodeToString(&RegistryKey,
+      L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\");
+
+    if (!NT_SUCCESS(Status)) { ObDereferenceObject(DeviceObject); return DISP_CHANGE_FAILED; }
+    Status = RtlAppendUnicodeStringToString(&RegistryKey, &ObjectName);
+
+    if (!NT_SUCCESS(Status)) { ObDereferenceObject(DeviceObject); return DISP_CHANGE_FAILED; }
+    Status = RtlAppendUnicodeToString(&RegistryKey,
+      L"\\Device0");
+
+    if (!NT_SUCCESS(Status)) { ObDereferenceObject(DeviceObject); return DISP_CHANGE_FAILED; }
+
+    InitializeObjectAttributes(&ObjectAttributes, &RegistryKey,
+      OBJ_CASE_INSENSITIVE, NULL, NULL);
+    Status = ZwOpenKey(&DevInstRegKey, GENERIC_READ | GENERIC_WRITE, &ObjectAttributes);
+    ObDereferenceObject(DeviceObject);
+    if (!NT_SUCCESS(Status)) return DISP_CHANGE_FAILED;
+
+    /* Update needed fields */
+    if (NT_SUCCESS(Status) && DevMode->dmFields & DM_BITSPERPEL)
+    {
+      RtlInitUnicodeString(&RegistryKey, L"DefaultSettings.BitsPerPel");
+      NewValue = DevMode->dmBitsPerPel;
+      Status = ZwSetValueKey(DevInstRegKey, &RegistryKey, 0, REG_DWORD, &NewValue, sizeof(NewValue));
     }
- if (dwflags != 0)  
+
+    if (NT_SUCCESS(Status) && DevMode->dmFields & DM_PELSWIDTH)
+    {
+      RtlInitUnicodeString(&RegistryKey, L"DefaultSettings.XResolution");
+      NewValue = DevMode->dmPelsWidth;
+      Status = ZwSetValueKey(DevInstRegKey, &RegistryKey, 0, REG_DWORD, &NewValue, sizeof(NewValue));
+    }
+
+    if (NT_SUCCESS(Status) && DevMode->dmFields & DM_PELSHEIGHT)
+    {
+      RtlInitUnicodeString(&RegistryKey, L"DefaultSettings.YResolution");
+      NewValue = DevMode->dmPelsHeight;
+      Status = ZwSetValueKey(DevInstRegKey, &RegistryKey, 0, REG_DWORD, &NewValue, sizeof(NewValue));
+    }
+
+    ZwClose(DevInstRegKey);
+    if (NT_SUCCESS(Status))
+      Ret = DISP_CHANGE_RESTART;
+    else
+      /* return DISP_CHANGE_NOTUPDATED when we can save to reg only valid for NT */
+      Ret = DISP_CHANGE_NOTUPDATED;
+    }
+
+ if (dwflags != 0)
     Ret = DISP_CHANGE_BADFLAGS;
 
   return Ret;