indent with astyle v1.15.3: --style=ansi -c -s3 -S --convert-tabs
authorGunnar Dalsnes <hardon@online.no>
Wed, 7 Sep 2005 21:25:42 +0000 (21:25 +0000)
committerGunnar Dalsnes <hardon@online.no>
Wed, 7 Sep 2005 21:25:42 +0000 (21:25 +0000)
svn path=/trunk/; revision=17730

34 files changed:
reactos/subsys/win32k/ntuser/accelerator.c
reactos/subsys/win32k/ntuser/callback.c
reactos/subsys/win32k/ntuser/caret.c
reactos/subsys/win32k/ntuser/class.c
reactos/subsys/win32k/ntuser/clipboard.c
reactos/subsys/win32k/ntuser/csr.c
reactos/subsys/win32k/ntuser/cursoricon.c
reactos/subsys/win32k/ntuser/desktop.c
reactos/subsys/win32k/ntuser/focus.c
reactos/subsys/win32k/ntuser/guicheck.c
reactos/subsys/win32k/ntuser/hook.c
reactos/subsys/win32k/ntuser/hotkey.c
reactos/subsys/win32k/ntuser/input.c
reactos/subsys/win32k/ntuser/keyboard.c
reactos/subsys/win32k/ntuser/menu.c
reactos/subsys/win32k/ntuser/message.c
reactos/subsys/win32k/ntuser/metric.c
reactos/subsys/win32k/ntuser/misc.c
reactos/subsys/win32k/ntuser/monitor.c
reactos/subsys/win32k/ntuser/msgqueue.c
reactos/subsys/win32k/ntuser/ntuser.c
reactos/subsys/win32k/ntuser/object.c
reactos/subsys/win32k/ntuser/painting.c
reactos/subsys/win32k/ntuser/prop.c
reactos/subsys/win32k/ntuser/scrollbar.c
reactos/subsys/win32k/ntuser/ssec.c
reactos/subsys/win32k/ntuser/stubs.c
reactos/subsys/win32k/ntuser/timer.c
reactos/subsys/win32k/ntuser/useratom.c
reactos/subsys/win32k/ntuser/vis.c
reactos/subsys/win32k/ntuser/windc.c
reactos/subsys/win32k/ntuser/window.c
reactos/subsys/win32k/ntuser/winpos.c
reactos/subsys/win32k/ntuser/winsta.c

index 59426ad..7bd8ed5 100644 (file)
 NTSTATUS FASTCALL
 InitAcceleratorImpl(VOID)
 {
-  return(STATUS_SUCCESS);
+   return(STATUS_SUCCESS);
 }
 
 NTSTATUS FASTCALL
 CleanupAcceleratorImpl(VOID)
 {
-  return(STATUS_SUCCESS);
+   return(STATUS_SUCCESS);
 }
 
 
@@ -73,7 +73,7 @@ static
 PACCELERATOR_TABLE FASTCALL UserGetAccelObject(HACCEL hAccel)
 {
    PACCELERATOR_TABLE Accel= UserGetObject(&gHandleTable, hAccel,  otAccel);
-   
+
    if (Accel)
    {
       ASSERT(USER_BODY_TO_HEADER(Accel)->RefCount >= 0);
@@ -92,132 +92,132 @@ PACCELERATOR_TABLE FASTCALL UserGetAccelObject(HACCEL hAccel)
 int
 STDCALL
 NtUserCopyAcceleratorTable(
-  HACCEL hAccel,
-  LPACCEL Entries,
-  int EntriesCount)
+   HACCEL hAccel,
+   LPACCEL Entries,
+   int EntriesCount)
 {
-  PWINSTATION_OBJECT WindowStation;
-  PACCELERATOR_TABLE Accel;
-  NTSTATUS Status;
-  int Ret;
-  DECLARE_RETURN(int);
-
-  DPRINT("Enter NtUserCopyAcceleratorTable\n");
-  UserEnterShared();
-
-  Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
-    UserMode,
-       0,
-       &WindowStation);
-   
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastNtError(STATUS_ACCESS_DENIED);
-    RETURN(0);
-  }
-
-  if (!(Accel = UserGetAccelObject(hAccel)))
-  {
-    ObDereferenceObject(WindowStation);
-    RETURN(0);
-  }
-
-  if(Entries)
-  {
-    Ret = min(EntriesCount, Accel->Count);
-    Status = MmCopyToCaller(Entries, Accel->Table, Ret * sizeof(ACCEL));
-    if (!NT_SUCCESS(Status))
-    {
+   PWINSTATION_OBJECT WindowStation;
+   PACCELERATOR_TABLE Accel;
+   NTSTATUS Status;
+   int Ret;
+   DECLARE_RETURN(int);
+
+   DPRINT("Enter NtUserCopyAcceleratorTable\n");
+   UserEnterShared();
+
+   Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
+                                           UserMode,
+                                           0,
+                                           &WindowStation);
+
+   if (!NT_SUCCESS(Status))
+   {
+      SetLastNtError(STATUS_ACCESS_DENIED);
+      RETURN(0);
+   }
+
+   if (!(Accel = UserGetAccelObject(hAccel)))
+   {
       ObDereferenceObject(WindowStation);
-      SetLastNtError(Status);
       RETURN(0);
-    }
-  }
-  else
-  {
-    Ret = Accel->Count;
-  }
+   }
+
+   if(Entries)
+   {
+      Ret = min(EntriesCount, Accel->Count);
+      Status = MmCopyToCaller(Entries, Accel->Table, Ret * sizeof(ACCEL));
+      if (!NT_SUCCESS(Status))
+      {
+         ObDereferenceObject(WindowStation);
+         SetLastNtError(Status);
+         RETURN(0);
+      }
+   }
+   else
+   {
+      Ret = Accel->Count;
+   }
+
+   ObDereferenceObject(WindowStation);
 
-  ObDereferenceObject(WindowStation);
+   RETURN(Ret);
 
-  RETURN(Ret);
-  
 CLEANUP:
-  DPRINT("Leave NtUserCopyAcceleratorTable, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserCopyAcceleratorTable, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 HACCEL
 STDCALL
 NtUserCreateAcceleratorTable(
-  LPACCEL Entries,
-  SIZE_T EntriesCount)
+   LPACCEL Entries,
+   SIZE_T EntriesCount)
 {
-  PWINSTATION_OBJECT WindowStation;
-  PACCELERATOR_TABLE Accel;
-  NTSTATUS Status;
-  HACCEL hAccel;
-  DECLARE_RETURN(HACCEL);
+   PWINSTATION_OBJECT WindowStation;
+   PACCELERATOR_TABLE Accel;
+   NTSTATUS Status;
+   HACCEL hAccel;
+   DECLARE_RETURN(HACCEL);
 
-  DPRINT("Enter NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d)\n",
+   DPRINT("Enter NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d)\n",
           Entries, EntriesCount);
-  UserEnterExclusive();
-
-  Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
-    UserMode,
-       0,
-       &WindowStation);
-   
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastNtError(STATUS_ACCESS_DENIED);
-    RETURN( FALSE );
-  }
-
-  Accel = ObmCreateObject(&gHandleTable, (PHANDLE)&hAccel, otAccel, sizeof(ACCELERATOR_TABLE));
-   
-  if (Accel == NULL)
-  {
-    ObDereferenceObject(WindowStation);
-    SetLastNtError(STATUS_NO_MEMORY);
-    RETURN( (HACCEL) 0 );
-  }
-
-  Accel->Count = EntriesCount;
-  if (Accel->Count > 0)
-  {
-       Accel->Table = ExAllocatePoolWithTag(PagedPool, EntriesCount * sizeof(ACCEL), TAG_ACCEL);
-       if (Accel->Table == NULL)
-       {
-      ObmDeleteObject(hAccel, otAccel);
-               ObDereferenceObject(WindowStation);
-               SetLastNtError(Status);
-      RETURN( (HACCEL) 0);
-       }
-
-    Status = MmCopyFromCaller(Accel->Table, Entries, EntriesCount * sizeof(ACCEL));
-    if (!NT_SUCCESS(Status))
-    {
-         ExFreePool(Accel->Table);
-     ObmDeleteObject(hAccel, otAccel);
+   UserEnterExclusive();
+
+   Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
+                                           UserMode,
+                                           0,
+                                           &WindowStation);
+
+   if (!NT_SUCCESS(Status))
+   {
+      SetLastNtError(STATUS_ACCESS_DENIED);
+      RETURN( FALSE );
+   }
+
+   Accel = ObmCreateObject(&gHandleTable, (PHANDLE)&hAccel, otAccel, sizeof(ACCELERATOR_TABLE));
+
+   if (Accel == NULL)
+   {
       ObDereferenceObject(WindowStation);
-      SetLastNtError(Status);
-      RETURN((HACCEL) 0);
-    }
-  }
+      SetLastNtError(STATUS_NO_MEMORY);
+      RETURN( (HACCEL) 0 );
+   }
+
+   Accel->Count = EntriesCount;
+   if (Accel->Count > 0)
+   {
+      Accel->Table = ExAllocatePoolWithTag(PagedPool, EntriesCount * sizeof(ACCEL), TAG_ACCEL);
+      if (Accel->Table == NULL)
+      {
+         ObmDeleteObject(hAccel, otAccel);
+         ObDereferenceObject(WindowStation);
+         SetLastNtError(Status);
+         RETURN( (HACCEL) 0);
+      }
+
+      Status = MmCopyFromCaller(Accel->Table, Entries, EntriesCount * sizeof(ACCEL));
+      if (!NT_SUCCESS(Status))
+      {
+         ExFreePool(Accel->Table);
+         ObmDeleteObject(hAccel, otAccel);
+         ObDereferenceObject(WindowStation);
+         SetLastNtError(Status);
+         RETURN((HACCEL) 0);
+      }
+   }
 
-  ObDereferenceObject(WindowStation);
+   ObDereferenceObject(WindowStation);
 
-  /* FIXME: Save HandleTable in a list somewhere so we can clean it up again */
+   /* FIXME: Save HandleTable in a list somewhere so we can clean it up again */
+
+   RETURN(hAccel);
 
-  RETURN(hAccel);
-  
 CLEANUP:
-  DPRINT("Leave NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d) = %x\n",
-      Entries, EntriesCount,_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d) = %x\n",
+          Entries, EntriesCount,_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -225,219 +225,224 @@ CLEANUP:
 BOOLEAN
 STDCALL
 NtUserDestroyAcceleratorTable(
-  HACCEL hAccel)
+   HACCEL hAccel)
 {
-  PWINSTATION_OBJECT WindowStation;
-  PACCELERATOR_TABLE Accel;
-  NTSTATUS Status;
-  DECLARE_RETURN(BOOLEAN);
-
-  /* FIXME: If the handle table is from a call to LoadAcceleratorTable, decrement it's
-     usage count (and return TRUE).
-        FIXME: Destroy only tables created using CreateAcceleratorTable.
-   */
-
-  DPRINT("NtUserDestroyAcceleratorTable(Table %x)\n", hAccel);
-  UserEnterExclusive();
-
-  Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
-    UserMode,
-       0,
-       &WindowStation);
-   
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastNtError(STATUS_ACCESS_DENIED);
-    DPRINT1("E1\n");
-    RETURN( FALSE);
-  }
-
-  if (!(Accel = UserGetAccelObject(hAccel)))
-  {
-    ObDereferenceObject(WindowStation);
-    RETURN( FALSE);
-  }
-
-  ObmDeleteObject(hAccel, otAccel);
-
-  if (Accel->Table != NULL)
-  {
-    ExFreePool(Accel->Table);
-  }
-
-  ObDereferenceObject(WindowStation);
-
-  RETURN( TRUE);
-  
+   PWINSTATION_OBJECT WindowStation;
+   PACCELERATOR_TABLE Accel;
+   NTSTATUS Status;
+   DECLARE_RETURN(BOOLEAN);
+
+   /* FIXME: If the handle table is from a call to LoadAcceleratorTable, decrement it's
+      usage count (and return TRUE).
+   FIXME: Destroy only tables created using CreateAcceleratorTable.
+    */
+
+   DPRINT("NtUserDestroyAcceleratorTable(Table %x)\n", hAccel);
+   UserEnterExclusive();
+
+   Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
+                                           UserMode,
+                                           0,
+                                           &WindowStation);
+
+   if (!NT_SUCCESS(Status))
+   {
+      SetLastNtError(STATUS_ACCESS_DENIED);
+      DPRINT1("E1\n");
+      RETURN( FALSE);
+   }
+
+   if (!(Accel = UserGetAccelObject(hAccel)))
+   {
+      ObDereferenceObject(WindowStation);
+      RETURN( FALSE);
+   }
+
+   ObmDeleteObject(hAccel, otAccel);
+
+   if (Accel->Table != NULL)
+   {
+      ExFreePool(Accel->Table);
+   }
+
+   ObDereferenceObject(WindowStation);
+
+   RETURN( TRUE);
+
 CLEANUP:
-  DPRINT("Leave NtUserDestroyAcceleratorTable(Table %x) = %i\n", hAccel,_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserDestroyAcceleratorTable(Table %x) = %i\n", hAccel,_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
-static 
+static
 BOOLEAN FASTCALL
 co_IntTranslateAccelerator(
-  PWINDOW_OBJECT Window,
-  UINT message,
-  WPARAM wParam,
-  LPARAM lParam,
-  BYTE fVirt,
-  WORD key,
-  WORD cmd)
+   PWINDOW_OBJECT Window,
+   UINT message,
+   WPARAM wParam,
+   LPARAM lParam,
+   BYTE fVirt,
+   WORD key,
+   WORD cmd)
 {
-  UINT mesg = 0;
+   UINT mesg = 0;
 
-  ASSERT_REFS_CO(Window); 
+   ASSERT_REFS_CO(Window);
 
-  DPRINT("IntTranslateAccelerator(hwnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x)\n",
-    Window->hSelf, message, wParam, lParam, fVirt, key, cmd);
+   DPRINT("IntTranslateAccelerator(hwnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x)\n",
+          Window->hSelf, message, wParam, lParam, fVirt, key, cmd);
 
-  if (wParam != key)
-    {
+   if (wParam != key)
+   {
       DPRINT("T0\n");
       return FALSE;
-    }
+   }
 
-  if (message == WM_CHAR)
-    {
+   if (message == WM_CHAR)
+   {
       if (!(fVirt & FALT) && !(fVirt & FVIRTKEY))
-        {
-          DPRINT("found accel for WM_CHAR: ('%c')\n", wParam & 0xff);
-          goto found;
-        }
-    }
-  else
-    {
+      {
+         DPRINT("found accel for WM_CHAR: ('%c')\n", wParam & 0xff);
+         goto found;
+      }
+   }
+   else
+   {
       if ((fVirt & FVIRTKEY) > 0)
-        {
-          INT mask = 0;
-          DPRINT("found accel for virt_key %04x (scan %04x)\n",
-            wParam, 0xff & HIWORD(lParam));
-
-                 DPRINT("NtUserGetKeyState(VK_SHIFT) = 0x%x\n",
-            UserGetKeyState(VK_SHIFT));
-                 DPRINT("NtUserGetKeyState(VK_CONTROL) = 0x%x\n",
-            UserGetKeyState(VK_CONTROL));
-                 DPRINT("NtUserGetKeyState(VK_MENU) = 0x%x\n",
-            UserGetKeyState(VK_MENU));
-
-                 if (UserGetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT;
-          if (UserGetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
-          if (UserGetKeyState(VK_MENU) & 0x8000) mask |= FALT;
-          if (mask == (fVirt & (FSHIFT | FCONTROL | FALT))) goto found;
-          DPRINT("but incorrect SHIFT/CTRL/ALT-state\n");
-        }
+      {
+         INT mask = 0;
+         DPRINT("found accel for virt_key %04x (scan %04x)\n",
+                wParam, 0xff & HIWORD(lParam));
+
+         DPRINT("NtUserGetKeyState(VK_SHIFT) = 0x%x\n",
+                UserGetKeyState(VK_SHIFT));
+         DPRINT("NtUserGetKeyState(VK_CONTROL) = 0x%x\n",
+                UserGetKeyState(VK_CONTROL));
+         DPRINT("NtUserGetKeyState(VK_MENU) = 0x%x\n",
+                UserGetKeyState(VK_MENU));
+
+         if (UserGetKeyState(VK_SHIFT) & 0x8000)
+            mask |= FSHIFT;
+         if (UserGetKeyState(VK_CONTROL) & 0x8000)
+            mask |= FCONTROL;
+         if (UserGetKeyState(VK_MENU) & 0x8000)
+            mask |= FALT;
+         if (mask == (fVirt & (FSHIFT | FCONTROL | FALT)))
+            goto found;
+         DPRINT("but incorrect SHIFT/CTRL/ALT-state\n");
+      }
       else
-        {
-          if (!(lParam & 0x01000000))  /* no special_key */
-            {
-              if ((fVirt & FALT) && (lParam & 0x20000000))
-                {                            /* ^^ ALT pressed */
-                  DPRINT("found accel for Alt-%c\n", wParam & 0xff);
-                  goto found;
-                }
+      {
+         if (!(lParam & 0x01000000))  /* no special_key */
+         {
+            if ((fVirt & FALT) && (lParam & 0x20000000))
+            {                            /* ^^ ALT pressed */
+               DPRINT("found accel for Alt-%c\n", wParam & 0xff);
+               goto found;
             }
-        }
-    }
-
-  DPRINT("IntTranslateAccelerator(hwnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x) = FALSE\n",
-    Window->hSelf, message, wParam, lParam, fVirt, key, cmd);
-
-  return FALSE;
-
- found:
-    if (message == WM_KEYUP || message == WM_SYSKEYUP)
-        mesg = 1;
-    else if (IntGetCaptureWindow())
-        mesg = 2;
-    else if (!IntIsWindowVisible(Window->hSelf)) /* FIXME: WINE IsWindowEnabled == IntIsWindowVisible? */
-        mesg = 3;
-    else
-    {
+         }
+      }
+   }
+
+   DPRINT("IntTranslateAccelerator(hwnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x) = FALSE\n",
+          Window->hSelf, message, wParam, lParam, fVirt, key, cmd);
+
+   return FALSE;
+
+found:
+   if (message == WM_KEYUP || message == WM_SYSKEYUP)
+      mesg = 1;
+   else if (IntGetCaptureWindow())
+      mesg = 2;
+   else if (!IntIsWindowVisible(Window->hSelf)) /* FIXME: WINE IsWindowEnabled == IntIsWindowVisible? */
+      mesg = 3;
+   else
+   {
 #if 0
-        HMENU hMenu, hSubMenu, hSysMenu;
-        UINT uSysStat = (UINT)-1, uStat = (UINT)-1, nPos;
-
-        hMenu = (UserGetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD) ? 0 : GetMenu(hWnd);
-        hSysMenu = get_win_sys_menu(hWnd);
-
-        /* find menu item and ask application to initialize it */
-        /* 1. in the system menu */
-        hSubMenu = hSysMenu;
-        nPos = cmd;
-        if(MENU_FindItem(&hSubMenu, &nPos, MF_BYCOMMAND))
-        {
-                       co_IntSendMessage(hWnd, WM_INITMENU, (WPARAM)hSysMenu, 0L);
-            if(hSubMenu != hSysMenu)
-            {
-                nPos = MENU_FindSubMenu(&hSysMenu, hSubMenu);
-                TRACE_(accel)("hSysMenu = %p, hSubMenu = %p, nPos = %d\n", hSysMenu, hSubMenu, nPos);
-                co_IntSendMessage(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, TRUE));
-            }
-            uSysStat = GetMenuState(GetSubMenu(hSysMenu, 0), cmd, MF_BYCOMMAND);
-        }
-        else /* 2. in the window's menu */
-        {
-            hSubMenu = hMenu;
-            nPos = cmd;
-            if(MENU_FindItem(&hSubMenu, &nPos, MF_BYCOMMAND))
+      HMENU hMenu, hSubMenu, hSysMenu;
+      UINT uSysStat = (UINT)-1, uStat = (UINT)-1, nPos;
+
+      hMenu = (UserGetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD) ? 0 : GetMenu(hWnd);
+      hSysMenu = get_win_sys_menu(hWnd);
+
+      /* find menu item and ask application to initialize it */
+      /* 1. in the system menu */
+      hSubMenu = hSysMenu;
+      nPos = cmd;
+      if(MENU_FindItem(&hSubMenu, &nPos, MF_BYCOMMAND))
+      {
+         co_IntSendMessage(hWnd, WM_INITMENU, (WPARAM)hSysMenu, 0L);
+         if(hSubMenu != hSysMenu)
+         {
+            nPos = MENU_FindSubMenu(&hSysMenu, hSubMenu);
+            TRACE_(accel)("hSysMenu = %p, hSubMenu = %p, nPos = %d\n", hSysMenu, hSubMenu, nPos);
+            co_IntSendMessage(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, TRUE));
+         }
+         uSysStat = GetMenuState(GetSubMenu(hSysMenu, 0), cmd, MF_BYCOMMAND);
+      }
+      else /* 2. in the window's menu */
+      {
+         hSubMenu = hMenu;
+         nPos = cmd;
+         if(MENU_FindItem(&hSubMenu, &nPos, MF_BYCOMMAND))
+         {
+            co_IntSendMessage(hWnd, WM_INITMENU, (WPARAM)hMenu, 0L);
+            if(hSubMenu != hMenu)
             {
-                co_IntSendMessage(hWnd, WM_INITMENU, (WPARAM)hMenu, 0L);
-                if(hSubMenu != hMenu)
-                {
-                    nPos = MENU_FindSubMenu(&hMenu, hSubMenu);
-                    TRACE_(accel)("hMenu = %p, hSubMenu = %p, nPos = %d\n", hMenu, hSubMenu, nPos);
-                    co_IntSendMessage(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, FALSE));
-                }
-                uStat = GetMenuState(hMenu, cmd, MF_BYCOMMAND);
+               nPos = MENU_FindSubMenu(&hMenu, hSubMenu);
+               TRACE_(accel)("hMenu = %p, hSubMenu = %p, nPos = %d\n", hMenu, hSubMenu, nPos);
+               co_IntSendMessage(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, FALSE));
             }
-        }
-
-        if (uSysStat != (UINT)-1)
-        {
-            if (uSysStat & (MF_DISABLED|MF_GRAYED))
-                mesg=4;
+            uStat = GetMenuState(hMenu, cmd, MF_BYCOMMAND);
+         }
+      }
+
+      if (uSysStat != (UINT)-1)
+      {
+         if (uSysStat & (MF_DISABLED|MF_GRAYED))
+            mesg=4;
+         else
+            mesg=WM_SYSCOMMAND;
+      }
+      else
+      {
+         if (uStat != (UINT)-1)
+         {
+            if (IsIconic(hWnd))
+               mesg=5;
             else
-                mesg=WM_SYSCOMMAND;
-        }
-        else
-        {
-            if (uStat != (UINT)-1)
             {
-                if (IsIconic(hWnd))
-                    mesg=5;
-                else
-                {
-                    if (uStat & (MF_DISABLED|MF_GRAYED))
-                        mesg=6;
-                    else
-                        mesg=WM_COMMAND;
-                }
+               if (uStat & (MF_DISABLED|MF_GRAYED))
+                  mesg=6;
+               else
+                  mesg=WM_COMMAND;
             }
-            else
-                       {
-              mesg=WM_COMMAND;
-                       }
-        }
+         }
+         else
+         {
+            mesg=WM_COMMAND;
+         }
+      }
 #else
       DPRINT1("menu search not implemented");
       mesg = WM_COMMAND;
 #endif
-    }
 
-  if (mesg == WM_COMMAND)
-    {
+   }
+
+   if (mesg == WM_COMMAND)
+   {
       DPRINT(", sending WM_COMMAND, wParam=%0x\n", 0x10000 | cmd);
       co_IntSendMessage(Window->hSelf, mesg, 0x10000 | cmd, 0L);
-    }
-  else if (mesg == WM_SYSCOMMAND)
-    {
+   }
+   else if (mesg == WM_SYSCOMMAND)
+   {
       DPRINT(", sending WM_SYSCOMMAND, wParam=%0x\n", cmd);
       co_IntSendMessage(Window->hSelf, mesg, cmd, 0x00010000L);
-    }
-  else
-    {
+   }
+   else
+   {
       /*  some reasons for NOT sending the WM_{SYS}COMMAND message:
        *   #0: unknown (please report!)
        *   #1: for WM_KEYUP,WM_SYSKEYUP
@@ -449,104 +454,107 @@ co_IntTranslateAccelerator(
        */
       DPRINT(", but won't send WM_{SYS}COMMAND, reason is #%d\n", mesg);
       if (mesg == 0)
-           {
-          DPRINT1(" unknown reason - please report!");
-           }
-    }
+      {
+         DPRINT1(" unknown reason - please report!");
+      }
+   }
 
-  DPRINT("IntTranslateAccelerator(hWnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x) = TRUE\n",
-    Window->hSelf, message, wParam, lParam, fVirt, key, cmd);
+   DPRINT("IntTranslateAccelerator(hWnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x) = TRUE\n",
+          Window->hSelf, message, wParam, lParam, fVirt, key, cmd);
 
-  return TRUE;
+   return TRUE;
 }
 
 int
 STDCALL
 NtUserTranslateAccelerator(
-  HWND hWnd,
-  HACCEL hAccel,
-  LPMSG Message)
+   HWND hWnd,
+   HACCEL hAccel,
+   LPMSG Message)
 {
-  PWINSTATION_OBJECT WindowStation = NULL;
-  PWINDOW_OBJECT Window = NULL;
-  PACCELERATOR_TABLE Accel = NULL;
-  NTSTATUS Status;
-  ULONG i;
-  DECLARE_RETURN(int);
-
-  DPRINT("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p)\n",
-    hWnd, hAccel, Message);
-  UserEnterShared();
-
-  if (Message == NULL)
-    {
-         SetLastNtError(STATUS_INVALID_PARAMETER);
+   PWINSTATION_OBJECT WindowStation = NULL;
+   PWINDOW_OBJECT Window = NULL;
+   PACCELERATOR_TABLE Accel = NULL;
+   NTSTATUS Status;
+   ULONG i;
+   DECLARE_RETURN(int);
+
+   DPRINT("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p)\n",
+          hWnd, hAccel, Message);
+   UserEnterShared();
+
+   if (Message == NULL)
+   {
+      SetLastNtError(STATUS_INVALID_PARAMETER);
+      RETURN( 0);
+   }
+
+   if ((Message->message != WM_KEYDOWN) &&
+         (Message->message != WM_SYSKEYDOWN) &&
+         (Message->message != WM_SYSCHAR) &&
+         (Message->message != WM_CHAR))
+   {
+      RETURN( 0);
+   }
+
+   Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
+                                           UserMode,
+                                           0,
+                                           &WindowStation);
+
+   if (!NT_SUCCESS(Status))
+   {
+      SetLastNtError(STATUS_ACCESS_DENIED);
+      RETURN( 0);
+   }
+
+   if (!(Accel = UserGetAccelObject(hAccel)))
+   {
+      RETURN( 0);
+   }
+
+   UserRefObjectCo(Accel);
+
+   if (!(Window = UserGetWindowObject(hWnd)))
+   {
       RETURN( 0);
-    }
-
-  if ((Message->message != WM_KEYDOWN) &&
-         (Message->message != WM_SYSKEYDOWN) &&
-         (Message->message != WM_SYSCHAR) &&
-         (Message->message != WM_CHAR))
-  {
-    RETURN( 0);
-  }
-
-  Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
-    UserMode,
-       0,
-       &WindowStation);
-   
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastNtError(STATUS_ACCESS_DENIED);
-    RETURN( 0);
-  }
-
-  if (!(Accel = UserGetAccelObject(hAccel)))
-  {
-    RETURN( 0);
-  }
-
-  UserRefObjectCo(Accel); 
-
-  if (!(Window = UserGetWindowObject(hWnd)))
-  {
-    RETURN( 0);
-  }
-
-  UserRefObjectCo(Window); 
-  
-
-  /* FIXME: Associate AcceleratorTable with the current thread */
-
-  for (i = 0; i < Accel->Count; i++)
-    {
+   }
+
+   UserRefObjectCo(Window);
+
+
+   /* FIXME: Associate AcceleratorTable with the current thread */
+
+   for (i = 0; i < Accel->Count; i++)
+   {
       if (co_IntTranslateAccelerator(Window, Message->message, Message->wParam, Message->lParam,
-                 Accel->Table[i].fVirt, Accel->Table[i].key,
-                 Accel->Table[i].cmd))
-        {
-          DPRINT("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p) = %i end\n",
-                 hWnd, hAccel, Message, 1);
-          RETURN( 1);
-        }
+                                     Accel->Table[i].fVirt, Accel->Table[i].key,
+                                     Accel->Table[i].cmd))
+      {
+         DPRINT("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p) = %i end\n",
+                hWnd, hAccel, Message, 1);
+         RETURN( 1);
+      }
       if (((Accel->Table[i].fVirt & 0x80) > 0))
-        {
-          break;
-        }
-    }
+      {
+         break;
+      }
+   }
+
+   RETURN( 0);
 
-  RETURN( 0);
-  
 CLEANUP:
-  
-  if (Window) UserDerefObjectCo(Window); 
-  if (Accel) UserDerefObjectCo(Accel); 
 
-  if (WindowStation) ObDereferenceObject(WindowStation);
+   if (Window)
+      UserDerefObjectCo(Window);
+   if (Accel)
+      UserDerefObjectCo(Accel);
+
+   if (WindowStation)
+      ObDereferenceObject(WindowStation);
 
-  DPRINT("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p) = %i end\n",
-    hWnd, hAccel, Message, 0);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p) = %i end\n",
+          hWnd, hAccel, Message, 0);
+   UserLeave();
+   END_CLEANUP;
 }
index 40a602c..4b616c8 100644 (file)
 
 typedef struct _INT_CALLBACK_HEADER
 {
-  /* list entry in the W32THREAD structure */
-  LIST_ENTRY ListEntry;
-} INT_CALLBACK_HEADER, *PINT_CALLBACK_HEADER;
+   /* list entry in the W32THREAD structure */
+   LIST_ENTRY ListEntry;
+}
+INT_CALLBACK_HEADER, *PINT_CALLBACK_HEADER;
 
 PVOID FASTCALL
 IntCbAllocateMemory(ULONG Size)
 {
-  PINT_CALLBACK_HEADER Mem;
-  PW32THREAD W32Thread;
+   PINT_CALLBACK_HEADER Mem;
+   PW32THREAD W32Thread;
 
-  if(!(Mem = ExAllocatePoolWithTag(PagedPool, Size + sizeof(INT_CALLBACK_HEADER),
-                                   TAG_CALLBACK)))
-  {
-    return NULL;
-  }
+   if(!(Mem = ExAllocatePoolWithTag(PagedPool, Size + sizeof(INT_CALLBACK_HEADER),
+                                    TAG_CALLBACK)))
+   {
+      return NULL;
+   }
 
-  W32Thread = PsGetWin32Thread();
-  ASSERT(W32Thread);
+   W32Thread = PsGetWin32Thread();
+   ASSERT(W32Thread);
 
-  /* insert the callback memory into the thread's callback list */
+   /* insert the callback memory into the thread's callback list */
 
-  InsertTailList(&W32Thread->W32CallbackListHead, &Mem->ListEntry);
+   InsertTailList(&W32Thread->W32CallbackListHead, &Mem->ListEntry);
 
-  return (Mem + 1);
+   return (Mem + 1);
 }
 
 VOID FASTCALL
 IntCbFreeMemory(PVOID Data)
 {
-  PINT_CALLBACK_HEADER Mem;
-  PW32THREAD W32Thread;
+   PINT_CALLBACK_HEADER Mem;
+   PW32THREAD W32Thread;
 
-  ASSERT(Data);
+   ASSERT(Data);
 
-  Mem = ((PINT_CALLBACK_HEADER)Data - 1);
+   Mem = ((PINT_CALLBACK_HEADER)Data - 1);
 
-  W32Thread = PsGetWin32Thread();
-  ASSERT(W32Thread);
+   W32Thread = PsGetWin32Thread();
+   ASSERT(W32Thread);
 
-  /* remove the memory block from the thread's callback list */
-  RemoveEntryList(&Mem->ListEntry);
+   /* remove the memory block from the thread's callback list */
+   RemoveEntryList(&Mem->ListEntry);
 
-  /* free memory */
-  ExFreePool(Mem);
+   /* free memory */
+   ExFreePool(Mem);
 }
 
 VOID FASTCALL
 IntCleanupThreadCallbacks(PW32THREAD W32Thread)
 {
-  PLIST_ENTRY CurrentEntry;
-  PINT_CALLBACK_HEADER Mem;
-
-  while (!IsListEmpty(&W32Thread->W32CallbackListHead))
-  {
-    CurrentEntry = RemoveHeadList(&W32Thread->W32CallbackListHead);
-    Mem = CONTAINING_RECORD(CurrentEntry, INT_CALLBACK_HEADER,
-                            ListEntry);
-
-    /* free memory */
-    ExFreePool(Mem);
-  }
+   PLIST_ENTRY CurrentEntry;
+   PINT_CALLBACK_HEADER Mem;
+
+   while (!IsListEmpty(&W32Thread->W32CallbackListHead))
+   {
+      CurrentEntry = RemoveHeadList(&W32Thread->W32CallbackListHead);
+      Mem = CONTAINING_RECORD(CurrentEntry, INT_CALLBACK_HEADER,
+                              ListEntry);
+
+      /* free memory */
+      ExFreePool(Mem);
+   }
 }
 
 /* FUNCTIONS *****************************************************************/
 
 VOID STDCALL
 co_IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback,
-                           HWND hWnd,
-                           UINT Msg,
-                           ULONG_PTR CompletionCallbackContext,
-                           LRESULT Result)
+                              HWND hWnd,
+                              UINT Msg,
+                              ULONG_PTR CompletionCallbackContext,
+                              LRESULT Result)
 {
-  SENDASYNCPROC_CALLBACK_ARGUMENTS Arguments;
-  NTSTATUS Status;
-
-  Arguments.Callback = CompletionCallback;
-  Arguments.Wnd = hWnd;
-  Arguments.Msg = Msg;
-  Arguments.Context = CompletionCallbackContext;
-  Arguments.Result = Result;
-  
-  UserLeaveCo();
-  
-  Status = NtW32Call(USER32_CALLBACK_SENDASYNCPROC,
-                    &Arguments,
-                    sizeof(SENDASYNCPROC_CALLBACK_ARGUMENTS),
-                    NULL,
-                    NULL);
-           
-  UserEnterCo();           
-           
-  if (!NT_SUCCESS(Status))
-    {
+   SENDASYNCPROC_CALLBACK_ARGUMENTS Arguments;
+   NTSTATUS Status;
+
+   Arguments.Callback = CompletionCallback;
+   Arguments.Wnd = hWnd;
+   Arguments.Msg = Msg;
+   Arguments.Context = CompletionCallbackContext;
+   Arguments.Result = Result;
+
+   UserLeaveCo();
+
+   Status = NtW32Call(USER32_CALLBACK_SENDASYNCPROC,
+                      &Arguments,
+                      sizeof(SENDASYNCPROC_CALLBACK_ARGUMENTS),
+                      NULL,
+                      NULL);
+
+   UserEnterCo();
+
+   if (!NT_SUCCESS(Status))
+   {
       return;
-    }
-  return;
+   }
+   return;
 }
 
 LRESULT STDCALL
 co_IntCallWindowProc(WNDPROC Proc,
-                   BOOLEAN IsAnsiProc,
-                  HWND Wnd,
-                  UINT Message,
-                  WPARAM wParam,
-                  LPARAM lParam,
-                   INT lParamBufferSize)
+                     BOOLEAN IsAnsiProc,
+                     HWND Wnd,
+                     UINT Message,
+                     WPARAM wParam,
+                     LPARAM lParam,
+                     INT lParamBufferSize)
 {
-  WINDOWPROC_CALLBACK_ARGUMENTS StackArguments;
-  PWINDOWPROC_CALLBACK_ARGUMENTS Arguments;
-  NTSTATUS Status;
-  PVOID ResultPointer;
-  ULONG ResultLength;
-  ULONG ArgumentLength;
-  LRESULT Result;
-
-  if (0 < lParamBufferSize)
-    {
+   WINDOWPROC_CALLBACK_ARGUMENTS StackArguments;
+   PWINDOWPROC_CALLBACK_ARGUMENTS Arguments;
+   NTSTATUS Status;
+   PVOID ResultPointer;
+   ULONG ResultLength;
+   ULONG ArgumentLength;
+   LRESULT Result;
+
+   if (0 < lParamBufferSize)
+   {
       ArgumentLength = sizeof(WINDOWPROC_CALLBACK_ARGUMENTS) + lParamBufferSize;
       Arguments = IntCbAllocateMemory(ArgumentLength);
       if (NULL == Arguments)
-        {
-          DPRINT1("Unable to allocate buffer for window proc callback\n");
-          return -1;
-        }
+      {
+         DPRINT1("Unable to allocate buffer for window proc callback\n");
+         return -1;
+      }
       RtlMoveMemory((PVOID) ((char *) Arguments + sizeof(WINDOWPROC_CALLBACK_ARGUMENTS)),
                     (PVOID) lParam, lParamBufferSize);
-    }
-  else
-    {
+   }
+   else
+   {
       Arguments = &StackArguments;
       ArgumentLength = sizeof(WINDOWPROC_CALLBACK_ARGUMENTS);
-    }
-  Arguments->Proc = Proc;
-  Arguments->IsAnsiProc = IsAnsiProc;
-  Arguments->Wnd = Wnd;
-  Arguments->Msg = Message;
-  Arguments->wParam = wParam;
-  Arguments->lParam = lParam;
-  Arguments->lParamBufferSize = lParamBufferSize;
-  ResultPointer = Arguments;
-  ResultLength = ArgumentLength;
-
-  UserLeaveCo();
-
-  Status = NtW32Call(USER32_CALLBACK_WINDOWPROC,
-                    Arguments,
-                    ArgumentLength,
-                    &ResultPointer,
-                    &ResultLength);
-
-  UserEnterCo();
-           
-  if (!NT_SUCCESS(Status))
-    {
+   }
+   Arguments->Proc = Proc;
+   Arguments->IsAnsiProc = IsAnsiProc;
+   Arguments->Wnd = Wnd;
+   Arguments->Msg = Message;
+   Arguments->wParam = wParam;
+   Arguments->lParam = lParam;
+   Arguments->lParamBufferSize = lParamBufferSize;
+   ResultPointer = Arguments;
+   ResultLength = ArgumentLength;
+
+   UserLeaveCo();
+
+   Status = NtW32Call(USER32_CALLBACK_WINDOWPROC,
+                      Arguments,
+                      ArgumentLength,
+                      &ResultPointer,
+                      &ResultLength);
+
+   UserEnterCo();
+
+   if (!NT_SUCCESS(Status))
+   {
       if (0 < lParamBufferSize)
-        {
-          IntCbFreeMemory(Arguments);
-        }
+      {
+         IntCbFreeMemory(Arguments);
+      }
       return -1;
-    }
-  Result = Arguments->Result;
+   }
+   Result = Arguments->Result;
 
-  if (0 < lParamBufferSize)
-    {
+   if (0 < lParamBufferSize)
+   {
       RtlMoveMemory((PVOID) lParam,
                     (PVOID) ((char *) Arguments + sizeof(WINDOWPROC_CALLBACK_ARGUMENTS)),
                     lParamBufferSize);
       IntCbFreeMemory(Arguments);
-    }
+   }
 
-  return Result;
+   return Result;
 }
 
 HMENU STDCALL
 co_IntLoadSysMenuTemplate()
 {
-  LRESULT Result;
-  NTSTATUS Status;
-  PVOID ResultPointer;
-  ULONG ResultLength;
-
-  ResultPointer = &Result;
-  ResultLength = sizeof(LRESULT);
-  
-  UserLeaveCo();
-  
-  Status = NtW32Call(USER32_CALLBACK_LOADSYSMENUTEMPLATE,
-                    NULL,
-                    0,
-                    &ResultPointer,
-                    &ResultLength);
-           
-  UserEnterCo();
-  
-  if (!NT_SUCCESS(Status))
-    {
+   LRESULT Result;
+   NTSTATUS Status;
+   PVOID ResultPointer;
+   ULONG ResultLength;
+
+   ResultPointer = &Result;
+   ResultLength = sizeof(LRESULT);
+
+   UserLeaveCo();
+
+   Status = NtW32Call(USER32_CALLBACK_LOADSYSMENUTEMPLATE,
+                      NULL,
+                      0,
+                      &ResultPointer,
+                      &ResultLength);
+
+   UserEnterCo();
+
+   if (!NT_SUCCESS(Status))
+   {
       return(0);
-    }
-  return (HMENU)Result;
+   }
+   return (HMENU)Result;
 }
 
 BOOL STDCALL
 co_IntLoadDefaultCursors(VOID)
 {
-  LRESULT Result;
-  NTSTATUS Status;
-  PVOID ResultPointer;
-  ULONG ResultLength;
-  BOOL DefaultCursor = TRUE;
-
-  ResultPointer = &Result;
-  ResultLength = sizeof(LRESULT);
-  
-  UserLeaveCo();
-  
-  Status = NtW32Call(USER32_CALLBACK_LOADDEFAULTCURSORS,
-                    &DefaultCursor,
-                    sizeof(BOOL),
-                    &ResultPointer,
-                    &ResultLength);
-           
-  UserEnterCo();
-  
-  if (!NT_SUCCESS(Status))
-    {
+   LRESULT Result;
+   NTSTATUS Status;
+   PVOID ResultPointer;
+   ULONG ResultLength;
+   BOOL DefaultCursor = TRUE;
+
+   ResultPointer = &Result;
+   ResultLength = sizeof(LRESULT);
+
+   UserLeaveCo();
+
+   Status = NtW32Call(USER32_CALLBACK_LOADDEFAULTCURSORS,
+                      &DefaultCursor,
+                      sizeof(BOOL),
+                      &ResultPointer,
+                      &ResultLength);
+
+   UserEnterCo();
+
+   if (!NT_SUCCESS(Status))
+   {
       return FALSE;
-    }
-  return TRUE;
+   }
+   return TRUE;
 }
 
 LRESULT STDCALL
 co_IntCallHookProc(INT HookId,
-                INT Code,
-                WPARAM wParam,
-                LPARAM lParam,
-                HOOKPROC Proc,
-                BOOLEAN Ansi,
-                PUNICODE_STRING ModuleName)
+                   INT Code,
+                   WPARAM wParam,
+                   LPARAM lParam,
+                   HOOKPROC Proc,
+                   BOOLEAN Ansi,
+                   PUNICODE_STRING ModuleName)
 {
-  ULONG ArgumentLength;
-  PVOID Argument;
-  LRESULT Result;
-  NTSTATUS Status;
-  PVOID ResultPointer;
-  ULONG ResultLength;
-  PHOOKPROC_CALLBACK_ARGUMENTS Common;
-  CBT_CREATEWNDW *CbtCreateWnd =NULL;
-  PCHAR Extra;
-  PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS CbtCreatewndExtra ;
-  PUNICODE_STRING WindowName = NULL;
-  PUNICODE_STRING ClassName = NULL;
-
-  ArgumentLength = sizeof(HOOKPROC_CALLBACK_ARGUMENTS) - sizeof(WCHAR)
-                   + ModuleName->Length;
-  switch(HookId)
-    {
-    case WH_CBT:
-      switch(Code)
-        {
-        case HCBT_CREATEWND:
-          CbtCreateWnd = (CBT_CREATEWNDW *) lParam;
-          ArgumentLength += sizeof(HOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS);
-          WindowName = (PUNICODE_STRING) (CbtCreateWnd->lpcs->lpszName);
-          ArgumentLength += WindowName->Length + sizeof(WCHAR);
-          ClassName = (PUNICODE_STRING) (CbtCreateWnd->lpcs->lpszClass);
-          if (! IS_ATOM(ClassName->Buffer))
-            {
-              ArgumentLength += ClassName->Length + sizeof(WCHAR);
-            }
-          break;
-        default:
-          DPRINT1("Trying to call unsupported CBT hook %d\n", Code);
-          return 0;
-        }
-      break;
-    case WH_KEYBOARD_LL:
-      ArgumentLength += sizeof(KBDLLHOOKSTRUCT);
-      break;
-    case WH_MOUSE_LL:
-      ArgumentLength += sizeof(MSLLHOOKSTRUCT);
-      break;
-    default:
-      DPRINT1("Trying to call unsupported window hook %d\n", HookId);
-      return 0;
-    }
-
-  Argument = IntCbAllocateMemory(ArgumentLength);
-  if (NULL == Argument)
-    {
+   ULONG ArgumentLength;
+   PVOID Argument;
+   LRESULT Result;
+   NTSTATUS Status;
+   PVOID ResultPointer;
+   ULONG ResultLength;
+   PHOOKPROC_CALLBACK_ARGUMENTS Common;
+   CBT_CREATEWNDW *CbtCreateWnd =NULL;
+   PCHAR Extra;
+   PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS CbtCreatewndExtra ;
+   PUNICODE_STRING WindowName = NULL;
+   PUNICODE_STRING ClassName = NULL;
+
+   ArgumentLength = sizeof(HOOKPROC_CALLBACK_ARGUMENTS) - sizeof(WCHAR)
+                    + ModuleName->Length;
+   switch(HookId)
+   {
+      case WH_CBT:
+         switch(Code)
+         {
+            case HCBT_CREATEWND:
+               CbtCreateWnd = (CBT_CREATEWNDW *) lParam;
+               ArgumentLength += sizeof(HOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS);
+               WindowName = (PUNICODE_STRING) (CbtCreateWnd->lpcs->lpszName);
+               ArgumentLength += WindowName->Length + sizeof(WCHAR);
+               ClassName = (PUNICODE_STRING) (CbtCreateWnd->lpcs->lpszClass);
+               if (! IS_ATOM(ClassName->Buffer))
+               {
+                  ArgumentLength += ClassName->Length + sizeof(WCHAR);
+               }
+               break;
+            default:
+               DPRINT1("Trying to call unsupported CBT hook %d\n", Code);
+               return 0;
+         }
+         break;
+      case WH_KEYBOARD_LL:
+         ArgumentLength += sizeof(KBDLLHOOKSTRUCT);
+         break;
+      case WH_MOUSE_LL:
+         ArgumentLength += sizeof(MSLLHOOKSTRUCT);
+         break;
+      default:
+         DPRINT1("Trying to call unsupported window hook %d\n", HookId);
+         return 0;
+   }
+
+   Argument = IntCbAllocateMemory(ArgumentLength);
+   if (NULL == Argument)
+   {
       DPRINT1("HookProc callback failed: out of memory\n");
       return 0;
-    }
-  Common = (PHOOKPROC_CALLBACK_ARGUMENTS) Argument;
-  Common->HookId = HookId;
-  Common->Code = Code;
-  Common->wParam = wParam;
-  Common->lParam = lParam;
-  Common->Proc = Proc;
-  Common->Ansi = Ansi;
-  Common->ModuleNameLength = ModuleName->Length;
-  memcpy(Common->ModuleName, ModuleName->Buffer, ModuleName->Length);
-  Extra = (PCHAR) Common->ModuleName + Common->ModuleNameLength;
-
-  switch(HookId)
-    {
-    case WH_CBT:
-      switch(Code)
-        {
-        case HCBT_CREATEWND:
-          Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
-          CbtCreatewndExtra = (PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS) Extra;
-          CbtCreatewndExtra->Cs = *(CbtCreateWnd->lpcs);
-          CbtCreatewndExtra->WndInsertAfter = CbtCreateWnd->hwndInsertAfter;
-          Extra = (PCHAR) (CbtCreatewndExtra + 1);
-          RtlCopyMemory(Extra, WindowName->Buffer, WindowName->Length);
-          CbtCreatewndExtra->Cs.lpszName = (LPCWSTR) (Extra - (PCHAR) CbtCreatewndExtra);
-          CbtCreatewndExtra->Cs.lpszClass = ClassName->Buffer;
-          Extra += WindowName->Length;
-          *((WCHAR *) Extra) = L'\0';
-          Extra += sizeof(WCHAR);
-          if (! IS_ATOM(ClassName->Buffer))
-            {
-              RtlCopyMemory(Extra, ClassName->Buffer, ClassName->Length);
-              CbtCreatewndExtra->Cs.lpszClass =
-                (LPCWSTR) MAKELONG(Extra - (PCHAR) CbtCreatewndExtra, 1);
-              Extra += ClassName->Length;
-              *((WCHAR *) Extra) = L'\0';
-            }
-          break;
-        }
-      break;
-    case WH_KEYBOARD_LL:
-      RtlCopyMemory(Extra, (PVOID) lParam, sizeof(KBDLLHOOKSTRUCT));
-      Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
-      break;
-    case WH_MOUSE_LL:
-      RtlCopyMemory(Extra, (PVOID) lParam, sizeof(MSLLHOOKSTRUCT));
-      Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
-      break;
-    }
-
-  ResultPointer = &Result;
-  ResultLength = sizeof(LRESULT);
-
-  UserLeaveCo();
-
-  Status = NtW32Call(USER32_CALLBACK_HOOKPROC,
-                    Argument,
-                    ArgumentLength,
-                    &ResultPointer,
-                    &ResultLength);
-
-  UserEnterCo();
-
-  IntCbFreeMemory(Argument);
-
-  if (!NT_SUCCESS(Status))
-    {
+   }
+   Common = (PHOOKPROC_CALLBACK_ARGUMENTS) Argument;
+   Common->HookId = HookId;
+   Common->Code = Code;
+   Common->wParam = wParam;
+   Common->lParam = lParam;
+   Common->Proc = Proc;
+   Common->Ansi = Ansi;
+   Common->ModuleNameLength = ModuleName->Length;
+   memcpy(Common->ModuleName, ModuleName->Buffer, ModuleName->Length);
+   Extra = (PCHAR) Common->ModuleName + Common->ModuleNameLength;
+
+   switch(HookId)
+   {
+      case WH_CBT:
+         switch(Code)
+         {
+            case HCBT_CREATEWND:
+               Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
+               CbtCreatewndExtra = (PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS) Extra;
+               CbtCreatewndExtra->Cs = *(CbtCreateWnd->lpcs);
+               CbtCreatewndExtra->WndInsertAfter = CbtCreateWnd->hwndInsertAfter;
+               Extra = (PCHAR) (CbtCreatewndExtra + 1);
+               RtlCopyMemory(Extra, WindowName->Buffer, WindowName->Length);
+               CbtCreatewndExtra->Cs.lpszName = (LPCWSTR) (Extra - (PCHAR) CbtCreatewndExtra);
+               CbtCreatewndExtra->Cs.lpszClass = ClassName->Buffer;
+               Extra += WindowName->Length;
+               *((WCHAR *) Extra) = L'\0';
+               Extra += sizeof(WCHAR);
+               if (! IS_ATOM(ClassName->Buffer))
+               {
+                  RtlCopyMemory(Extra, ClassName->Buffer, ClassName->Length);
+                  CbtCreatewndExtra->Cs.lpszClass =
+                     (LPCWSTR) MAKELONG(Extra - (PCHAR) CbtCreatewndExtra, 1);
+                  Extra += ClassName->Length;
+                  *((WCHAR *) Extra) = L'\0';
+               }
+               break;
+         }
+         break;
+      case WH_KEYBOARD_LL:
+         RtlCopyMemory(Extra, (PVOID) lParam, sizeof(KBDLLHOOKSTRUCT));
+         Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
+         break;
+      case WH_MOUSE_LL:
+         RtlCopyMemory(Extra, (PVOID) lParam, sizeof(MSLLHOOKSTRUCT));
+         Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
+         break;
+   }
+
+   ResultPointer = &Result;
+   ResultLength = sizeof(LRESULT);
+
+   UserLeaveCo();
+
+   Status = NtW32Call(USER32_CALLBACK_HOOKPROC,
+                      Argument,
+                      ArgumentLength,
+                      &ResultPointer,
+                      &ResultLength);
+
+   UserEnterCo();
+
+   IntCbFreeMemory(Argument);
+
+   if (!NT_SUCCESS(Status))
+   {
       return 0;
-    }
+   }
 
-  return Result;
+   return Result;
 }
 
 /* EOF */
index 47c5fc5..59e9595 100644 (file)
 BOOL FASTCALL
 co_IntHideCaret(PTHRDCARETINFO CaretInfo)
 {
-  if(CaretInfo->hWnd && CaretInfo->Visible && CaretInfo->Showing)
-  {
-    co_IntSendMessage(CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
-    CaretInfo->Showing = 0;
-    return TRUE;
-  }
-  return FALSE;
+   if(CaretInfo->hWnd && CaretInfo->Visible && CaretInfo->Showing)
+   {
+      co_IntSendMessage(CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
+      CaretInfo->Showing = 0;
+      return TRUE;
+   }
+   return FALSE;
 }
 
 BOOL FASTCALL
 co_IntDestroyCaret(PW32THREAD Win32Thread)
 {
-  PUSER_MESSAGE_QUEUE ThreadQueue;
-  ThreadQueue = (PUSER_MESSAGE_QUEUE)Win32Thread->MessageQueue;
-
-  if(!ThreadQueue || !ThreadQueue->CaretInfo)
-    return FALSE;
-
-  co_IntHideCaret(ThreadQueue->CaretInfo);
-  ThreadQueue->CaretInfo->Bitmap = (HBITMAP)0;
-  ThreadQueue->CaretInfo->hWnd = (HWND)0;
-  ThreadQueue->CaretInfo->Size.cx = ThreadQueue->CaretInfo->Size.cy = 0;
-  ThreadQueue->CaretInfo->Showing = 0;
-  ThreadQueue->CaretInfo->Visible = 0;
-  return TRUE;
+   PUSER_MESSAGE_QUEUE ThreadQueue;
+   ThreadQueue = (PUSER_MESSAGE_QUEUE)Win32Thread->MessageQueue;
+
+   if(!ThreadQueue || !ThreadQueue->CaretInfo)
+      return FALSE;
+
+   co_IntHideCaret(ThreadQueue->CaretInfo);
+   ThreadQueue->CaretInfo->Bitmap = (HBITMAP)0;
+   ThreadQueue->CaretInfo->hWnd = (HWND)0;
+   ThreadQueue->CaretInfo->Size.cx = ThreadQueue->CaretInfo->Size.cy = 0;
+   ThreadQueue->CaretInfo->Showing = 0;
+   ThreadQueue->CaretInfo->Visible = 0;
+   return TRUE;
 }
 
 BOOL FASTCALL
 IntSetCaretBlinkTime(UINT uMSeconds)
 {
-  /* Don't save the new value to the registry! */
-  PWINSTATION_OBJECT WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
+   /* Don't save the new value to the registry! */
+   PWINSTATION_OBJECT WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
 
-  /* windows doesn't do this check */
-  if((uMSeconds < MIN_CARETBLINKRATE) || (uMSeconds > MAX_CARETBLINKRATE))
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    ObDereferenceObject(WinStaObject);
-    return FALSE;
-  }
+   /* windows doesn't do this check */
+   if((uMSeconds < MIN_CARETBLINKRATE) || (uMSeconds > MAX_CARETBLINKRATE))
+   {
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      ObDereferenceObject(WinStaObject);
+      return FALSE;
+   }
 
-  WinStaObject->CaretBlinkRate = uMSeconds;
+   WinStaObject->CaretBlinkRate = uMSeconds;
 
-  return TRUE;
+   return TRUE;
 }
 
 UINT FASTCALL
 IntQueryCaretBlinkRate(VOID)
 {
-  UNICODE_STRING KeyName = RTL_CONSTANT_STRING(CARET_REGKEY);
-  UNICODE_STRING ValueName = RTL_CONSTANT_STRING(CARET_VALUENAME);
-  NTSTATUS Status;
-  HANDLE KeyHandle = NULL;
-  OBJECT_ATTRIBUTES KeyAttributes;
-  PKEY_VALUE_PARTIAL_INFORMATION KeyValuePartialInfo;
-  ULONG Length = 0;
-  ULONG ResLength = 0;
-  ULONG Val = 0;
-
-  InitializeObjectAttributes(&KeyAttributes, &KeyName, OBJ_CASE_INSENSITIVE,
-                             NULL, NULL);
-
-  Status = ZwOpenKey(&KeyHandle, KEY_READ, &KeyAttributes);
-  if(!NT_SUCCESS(Status))
-  {
-    return 0;
-  }
-
-  Status = ZwQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation,
-                           0, 0, &ResLength);
-  if((Status != STATUS_BUFFER_TOO_SMALL))
-  {
-    NtClose(KeyHandle);
-    return 0;
-  }
-
-  ResLength += sizeof(KEY_VALUE_PARTIAL_INFORMATION);
-  KeyValuePartialInfo = ExAllocatePoolWithTag(PagedPool, ResLength, TAG_STRING);
-  Length = ResLength;
-
-  if(!KeyValuePartialInfo)
-  {
-    NtClose(KeyHandle);
-    return 0;
-  }
-
-  Status = ZwQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation,
-                           (PVOID)KeyValuePartialInfo, Length, &ResLength);
-  if(!NT_SUCCESS(Status) || (KeyValuePartialInfo->Type != REG_SZ))
-  {
-    NtClose(KeyHandle);
-    ExFreePool(KeyValuePartialInfo);
-    return 0;
-  }
-
-  ValueName.Length = KeyValuePartialInfo->DataLength;
-  ValueName.MaximumLength = KeyValuePartialInfo->DataLength;
-  ValueName.Buffer = (PWSTR)KeyValuePartialInfo->Data;
-
-  Status = RtlUnicodeStringToInteger(&ValueName, 0, &Val);
-  if(!NT_SUCCESS(Status))
-  {
-    Val = 0;
-  }
-
-  ExFreePool(KeyValuePartialInfo);
-  NtClose(KeyHandle);
-
-  return (UINT)Val;
+   UNICODE_STRING KeyName = RTL_CONSTANT_STRING(CARET_REGKEY);
+   UNICODE_STRING ValueName = RTL_CONSTANT_STRING(CARET_VALUENAME);
+   NTSTATUS Status;
+   HANDLE KeyHandle = NULL;
+   OBJECT_ATTRIBUTES KeyAttributes;
+   PKEY_VALUE_PARTIAL_INFORMATION KeyValuePartialInfo;
+   ULONG Length = 0;
+   ULONG ResLength = 0;
+   ULONG Val = 0;
+
+   InitializeObjectAttributes(&KeyAttributes, &KeyName, OBJ_CASE_INSENSITIVE,
+                              NULL, NULL);
+
+   Status = ZwOpenKey(&KeyHandle, KEY_READ, &KeyAttributes);
+   if(!NT_SUCCESS(Status))
+   {
+      return 0;
+   }
+
+   Status = ZwQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation,
+                            0, 0, &ResLength);
+   if((Status != STATUS_BUFFER_TOO_SMALL))
+   {
+      NtClose(KeyHandle);
+      return 0;
+   }
+
+   ResLength += sizeof(KEY_VALUE_PARTIAL_INFORMATION);
+   KeyValuePartialInfo = ExAllocatePoolWithTag(PagedPool, ResLength, TAG_STRING);
+   Length = ResLength;
+
+   if(!KeyValuePartialInfo)
+   {
+      NtClose(KeyHandle);
+      return 0;
+   }
+
+   Status = ZwQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation,
+                            (PVOID)KeyValuePartialInfo, Length, &ResLength);
+   if(!NT_SUCCESS(Status) || (KeyValuePartialInfo->Type != REG_SZ))
+   {
+      NtClose(KeyHandle);
+      ExFreePool(KeyValuePartialInfo);
+      return 0;
+   }
+
+   ValueName.Length = KeyValuePartialInfo->DataLength;
+   ValueName.MaximumLength = KeyValuePartialInfo->DataLength;
+   ValueName.Buffer = (PWSTR)KeyValuePartialInfo->Data;
+
+   Status = RtlUnicodeStringToInteger(&ValueName, 0, &Val);
+   if(!NT_SUCCESS(Status))
+   {
+      Val = 0;
+   }
+
+   ExFreePool(KeyValuePartialInfo);
+   NtClose(KeyHandle);
+
+   return (UINT)Val;
 }
 
 UINT FASTCALL
 IntGetCaretBlinkTime(VOID)
 {
-  PWINSTATION_OBJECT WinStaObject;
-  UINT Ret;
+   PWINSTATION_OBJECT WinStaObject;
+   UINT Ret;
 
-  WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
+   WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
 
-  Ret = WinStaObject->CaretBlinkRate;
-  if(!Ret)
-  {
-    /* load it from the registry the first call only! */
-    Ret = WinStaObject->CaretBlinkRate = IntQueryCaretBlinkRate();
-  }
+   Ret = WinStaObject->CaretBlinkRate;
+   if(!Ret)
+   {
+      /* load it from the registry the first call only! */
+      Ret = WinStaObject->CaretBlinkRate = IntQueryCaretBlinkRate();
+   }
 
-  /* windows doesn't do this check */
-  if((Ret < MIN_CARETBLINKRATE) || (Ret > MAX_CARETBLINKRATE))
-  {
-    Ret = DEFAULT_CARETBLINKRATE;
-  }
+   /* windows doesn't do this check */
+   if((Ret < MIN_CARETBLINKRATE) || (Ret > MAX_CARETBLINKRATE))
+   {
+      Ret = DEFAULT_CARETBLINKRATE;
+   }
 
-  return Ret;
+   return Ret;
 }
 
 BOOL FASTCALL
 co_IntSetCaretPos(int X, int Y)
 {
-  PUSER_MESSAGE_QUEUE ThreadQueue;
-  ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
+   PUSER_MESSAGE_QUEUE ThreadQueue;
+   ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
 
-  if(ThreadQueue->CaretInfo->hWnd)
-  {
-    if(ThreadQueue->CaretInfo->Pos.x != X || ThreadQueue->CaretInfo->Pos.y != Y)
-    {
-      co_IntHideCaret(ThreadQueue->CaretInfo);
-      ThreadQueue->CaretInfo->Showing = 0;
-      ThreadQueue->CaretInfo->Pos.x = X;
-      ThreadQueue->CaretInfo->Pos.y = Y;
-      co_IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
-      IntSetTimer(ThreadQueue->CaretInfo->hWnd, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE);
-    }
-    return TRUE;
-  }
+   if(ThreadQueue->CaretInfo->hWnd)
+   {
+      if(ThreadQueue->CaretInfo->Pos.x != X || ThreadQueue->CaretInfo->Pos.y != Y)
+      {
+         co_IntHideCaret(ThreadQueue->CaretInfo);
+         ThreadQueue->CaretInfo->Showing = 0;
+         ThreadQueue->CaretInfo->Pos.x = X;
+         ThreadQueue->CaretInfo->Pos.y = Y;
+         co_IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
+         IntSetTimer(ThreadQueue->CaretInfo->hWnd, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE);
+      }
+      return TRUE;
+   }
 
-  return FALSE;
+   return FALSE;
 }
 
 BOOL FASTCALL
 IntSwitchCaretShowing(PVOID Info)
 {
-  PUSER_MESSAGE_QUEUE ThreadQueue;
-  ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
+   PUSER_MESSAGE_QUEUE ThreadQueue;
+   ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
 
-  if(ThreadQueue->CaretInfo->hWnd)
-  {
-    ThreadQueue->CaretInfo->Showing = (ThreadQueue->CaretInfo->Showing ? 0 : 1);
-    MmCopyToCaller(Info, ThreadQueue->CaretInfo, sizeof(THRDCARETINFO));
-    return TRUE;
-  }
+   if(ThreadQueue->CaretInfo->hWnd)
+   {
+      ThreadQueue->CaretInfo->Showing = (ThreadQueue->CaretInfo->Showing ? 0 : 1);
+      MmCopyToCaller(Info, ThreadQueue->CaretInfo, sizeof(THRDCARETINFO));
+      return TRUE;
+   }
 
-  return FALSE;
+   return FALSE;
 }
 
 VOID FASTCALL
 co_IntDrawCaret(HWND hWnd)
 {
-  PUSER_MESSAGE_QUEUE ThreadQueue;
-  ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-
-  if(ThreadQueue->CaretInfo->hWnd && ThreadQueue->CaretInfo->Visible &&
-     ThreadQueue->CaretInfo->Showing)
-  {
-    co_IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
-    ThreadQueue->CaretInfo->Showing = 1;
-  }
+   PUSER_MESSAGE_QUEUE ThreadQueue;
+   ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
+
+   if(ThreadQueue->CaretInfo->hWnd && ThreadQueue->CaretInfo->Visible &&
+         ThreadQueue->CaretInfo->Showing)
+   {
+      co_IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
+      ThreadQueue->CaretInfo->Showing = 1;
+   }
 }
 
 
@@ -216,63 +216,63 @@ co_IntDrawCaret(HWND hWnd)
 BOOL
 STDCALL
 NtUserCreateCaret(
-  HWND hWnd,
-  HBITMAP hBitmap,
-  int nWidth,
-  int nHeight)
+   HWND hWnd,
+   HBITMAP hBitmap,
+   int nWidth,
+   int nHeight)
 {
-  PWINDOW_OBJECT WindowObject;
-  PUSER_MESSAGE_QUEUE ThreadQueue;
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserCreateCaret\n");
-  UserEnterExclusive();
-
-  WindowObject = IntGetWindowObject(hWnd);
-  if(!WindowObject)
-  {
-    SetLastWin32Error(ERROR_INVALID_HANDLE);
-    RETURN(FALSE);
-  }
-
-  if(WindowObject->OwnerThread != PsGetCurrentThread())
-  {
-    IntReleaseWindowObject(WindowObject);
-    SetLastWin32Error(ERROR_ACCESS_DENIED);
-    RETURN(FALSE);
-  }
-
-  ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-
-  if (ThreadQueue->CaretInfo->Visible)
-  {
-    IntKillTimer(hWnd, IDCARETTIMER, TRUE);
-    co_IntHideCaret(ThreadQueue->CaretInfo);
-  }
-
-  ThreadQueue->CaretInfo->hWnd = hWnd;
-  if(hBitmap)
-  {
-    ThreadQueue->CaretInfo->Bitmap = hBitmap;
-    ThreadQueue->CaretInfo->Size.cx = ThreadQueue->CaretInfo->Size.cy = 0;
-  }
-  else
-  {
-    ThreadQueue->CaretInfo->Bitmap = (HBITMAP)0;
-    ThreadQueue->CaretInfo->Size.cx = nWidth;
-    ThreadQueue->CaretInfo->Size.cy = nHeight;
-  }
-  ThreadQueue->CaretInfo->Visible = 0;
-  ThreadQueue->CaretInfo->Showing = 0;
-
-  IntReleaseWindowObject(WindowObject);
-
-  RETURN(TRUE);
+   PWINDOW_OBJECT WindowObject;
+   PUSER_MESSAGE_QUEUE ThreadQueue;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserCreateCaret\n");
+   UserEnterExclusive();
+
+   WindowObject = IntGetWindowObject(hWnd);
+   if(!WindowObject)
+   {
+      SetLastWin32Error(ERROR_INVALID_HANDLE);
+      RETURN(FALSE);
+   }
+
+   if(WindowObject->OwnerThread != PsGetCurrentThread())
+   {
+      IntReleaseWindowObject(WindowObject);
+      SetLastWin32Error(ERROR_ACCESS_DENIED);
+      RETURN(FALSE);
+   }
+
+   ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
+
+   if (ThreadQueue->CaretInfo->Visible)
+   {
+      IntKillTimer(hWnd, IDCARETTIMER, TRUE);
+      co_IntHideCaret(ThreadQueue->CaretInfo);
+   }
+
+   ThreadQueue->CaretInfo->hWnd = hWnd;
+   if(hBitmap)
+   {
+      ThreadQueue->CaretInfo->Bitmap = hBitmap;
+      ThreadQueue->CaretInfo->Size.cx = ThreadQueue->CaretInfo->Size.cy = 0;
+   }
+   else
+   {
+      ThreadQueue->CaretInfo->Bitmap = (HBITMAP)0;
+      ThreadQueue->CaretInfo->Size.cx = nWidth;
+      ThreadQueue->CaretInfo->Size.cy = nHeight;
+   }
+   ThreadQueue->CaretInfo->Visible = 0;
+   ThreadQueue->CaretInfo->Showing = 0;
+
+   IntReleaseWindowObject(WindowObject);
+
+   RETURN(TRUE);
 
 CLEANUP:
-  DPRINT("Leave NtUserCreateCaret, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserCreateCaret, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 UINT
@@ -283,9 +283,9 @@ NtUserGetCaretBlinkTime(VOID)
 
    DPRINT("Enter NtUserGetCaretBlinkTime\n");
    UserEnterExclusive();
-   
+
    RETURN(IntGetCaretBlinkTime());
-   
+
 CLEANUP:
    DPRINT("Leave NtUserGetCaretBlinkTime, ret=%i\n",_ret_);
    UserLeave();
@@ -295,99 +295,99 @@ CLEANUP:
 BOOL
 STDCALL
 NtUserGetCaretPos(
-  LPPOINT lpPoint)
+   LPPOINT lpPoint)
 {
-  PUSER_MESSAGE_QUEUE ThreadQueue;
-  NTSTATUS Status;
-  DECLARE_RETURN(BOOL);
+   PUSER_MESSAGE_QUEUE ThreadQueue;
+   NTSTATUS Status;
+   DECLARE_RETURN(BOOL);
 
-  DPRINT("Enter NtUserGetCaretPos\n");
-  UserEnterShared();
+   DPRINT("Enter NtUserGetCaretPos\n");
+   UserEnterShared();
+
+   ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
 
-  ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
+   Status = MmCopyToCaller(lpPoint, &(ThreadQueue->CaretInfo->Pos), sizeof(POINT));
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      RETURN(FALSE);
+   }
 
-  Status = MmCopyToCaller(lpPoint, &(ThreadQueue->CaretInfo->Pos), sizeof(POINT));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    RETURN(FALSE);
-  }
+   RETURN(TRUE);
 
-  RETURN(TRUE);
-  
 CLEANUP:
-  DPRINT("Leave NtUserGetCaretPos, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetCaretPos, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
 BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT WindowObject)
 {
-  PUSER_MESSAGE_QUEUE ThreadQueue;
-  
-  if(WindowObject->OwnerThread != PsGetCurrentThread())
-  {
-    SetLastWin32Error(ERROR_ACCESS_DENIED);
-    return FALSE;
-  }
-
-  ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-
-  if(ThreadQueue->CaretInfo->hWnd != WindowObject->hSelf)
-  {
-    SetLastWin32Error(ERROR_ACCESS_DENIED);
-    return FALSE;
-  }
-
-  if(ThreadQueue->CaretInfo->Visible)
-  {
-    IntKillTimer(WindowObject->hSelf, IDCARETTIMER, TRUE);
-
-    co_IntHideCaret(ThreadQueue->CaretInfo);
-    ThreadQueue->CaretInfo->Visible = 0;
-    ThreadQueue->CaretInfo->Showing = 0;
-  }
-  
-  return TRUE;
-}   
+   PUSER_MESSAGE_QUEUE ThreadQueue;
+
+   if(WindowObject->OwnerThread != PsGetCurrentThread())
+   {
+      SetLastWin32Error(ERROR_ACCESS_DENIED);
+      return FALSE;
+   }
+
+   ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
+
+   if(ThreadQueue->CaretInfo->hWnd != WindowObject->hSelf)
+   {
+      SetLastWin32Error(ERROR_ACCESS_DENIED);
+      return FALSE;
+   }
+
+   if(ThreadQueue->CaretInfo->Visible)
+   {
+      IntKillTimer(WindowObject->hSelf, IDCARETTIMER, TRUE);
+
+      co_IntHideCaret(ThreadQueue->CaretInfo);
+      ThreadQueue->CaretInfo->Visible = 0;
+      ThreadQueue->CaretInfo->Showing = 0;
+   }
+
+   return TRUE;
+}
 
 
 BOOL
 STDCALL
 NtUserHideCaret(
-  HWND hWnd)
+   HWND hWnd)
 {
-  PWINDOW_OBJECT WindowObject;
-  DECLARE_RETURN(BOOL);
-  BOOL ret;
+   PWINDOW_OBJECT WindowObject;
+   DECLARE_RETURN(BOOL);
+   BOOL ret;
 
-  DPRINT("Enter NtUserHideCaret\n");
-  UserEnterExclusive();
+   DPRINT("Enter NtUserHideCaret\n");
+   UserEnterExclusive();
 
-  WindowObject = IntGetWindowObject(hWnd);
-  if(!WindowObject)
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    RETURN(FALSE);
-  }
+   WindowObject = IntGetWindowObject(hWnd);
+   if(!WindowObject)
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      RETURN(FALSE);
+   }
 
-  ret = co_UserHideCaret(WindowObject);
-  IntReleaseWindowObject(WindowObject);
+   ret = co_UserHideCaret(WindowObject);
+   IntReleaseWindowObject(WindowObject);
 
-  RETURN(ret);
+   RETURN(ret);
 
 CLEANUP:
-  DPRINT("Leave NtUserHideCaret, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserHideCaret, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
 BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT Window)
 {
    PUSER_MESSAGE_QUEUE ThreadQueue;
-   
+
    if(Window->OwnerThread != PsGetCurrentThread())
    {
       SetLastWin32Error(ERROR_ACCESS_DENIED);
@@ -411,7 +411,7 @@ BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT Window)
       }
       IntSetTimer(Window->hSelf, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE);
    }
-   
+
    return TRUE;
 }
 
@@ -419,28 +419,28 @@ BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT Window)
 BOOL
 STDCALL
 NtUserShowCaret(
-  HWND hWnd)
+   HWND hWnd)
 {
-  PWINDOW_OBJECT WindowObject;
-  DECLARE_RETURN(BOOL);
-  BOOL ret;
-
-  DPRINT("Enter NtUserShowCaret\n");
-  UserEnterExclusive();
-
-  WindowObject = IntGetWindowObject(hWnd);
-  if(!WindowObject)
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    RETURN(FALSE);
-  }
-
-  ret = co_UserShowCaret(WindowObject);
-  IntReleaseWindowObject(WindowObject);
-  RETURN(ret);
-  
+   PWINDOW_OBJECT WindowObject;
+   DECLARE_RETURN(BOOL);
+   BOOL ret;
+
+   DPRINT("Enter NtUserShowCaret\n");
+   UserEnterExclusive();
+
+   WindowObject = IntGetWindowObject(hWnd);
+   if(!WindowObject)
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      RETURN(FALSE);
+   }
+
+   ret = co_UserShowCaret(WindowObject);
+   IntReleaseWindowObject(WindowObject);
+   RETURN(ret);
+
 CLEANUP:
-  DPRINT("Leave NtUserShowCaret, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserShowCaret, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
index 3f0bfec..f8d113b 100644 (file)
 NTSTATUS FASTCALL
 InitClassImpl(VOID)
 {
-  return(STATUS_SUCCESS);
+   return(STATUS_SUCCESS);
 }
 
 NTSTATUS FASTCALL
 CleanupClassImpl(VOID)
 {
-  return(STATUS_SUCCESS);
+   return(STATUS_SUCCESS);
 }
 
 BOOL FASTCALL
@@ -102,9 +102,9 @@ ClassReferenceClassByName(
    WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
 
    Status = RtlLookupAtomInAtomTable(
-      WinStaObject->AtomTable,
-      (LPWSTR)ClassName,
-      &ClassAtom);
+               WinStaObject->AtomTable,
+               (LPWSTR)ClassName,
+               &ClassAtom);
 
    if (!NT_SUCCESS(Status))
    {
@@ -144,14 +144,14 @@ NtUserGetClassInfo(
    PWNDCLASS_OBJECT Class;
    RTL_ATOM Atom;
    DECLARE_RETURN(DWORD);
-   
+
    if (IS_ATOM(lpClassName))
       DPRINT("NtUserGetClassInfo - %x (%lx)\n", lpClassName, hInstance);
    else
       DPRINT("NtUserGetClassInfo - %S (%lx)\n", lpClassName, hInstance);
 
    UserEnterExclusive();
-   
+
    if (!ClassReferenceClassByNameOrAtom(&Class, lpClassName, hInstance))
    {
       SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST);
@@ -182,7 +182,7 @@ NtUserGetClassInfo(
    ObmDereferenceObject(Class);
 
    RETURN(Atom);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserGetClassInfo, ret=%i\n",_ret_);
    UserLeave();
@@ -191,7 +191,7 @@ CLEANUP:
 
 ULONG FASTCALL
 IntGetClassName(struct _WINDOW_OBJECT *WindowObject, LPWSTR lpClassName,
-   ULONG nMaxCount)
+                ULONG nMaxCount)
 {
    ULONG Length;
    LPWSTR Name;
@@ -207,10 +207,10 @@ IntGetClassName(struct _WINDOW_OBJECT *WindowObject, LPWSTR lpClassName,
 
    Length = 0;
    Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,
-      WindowObject->Class->Atom, NULL, NULL, NULL, &Length);
+                                    WindowObject->Class->Atom, NULL, NULL, NULL, &Length);
    Name = ExAllocatePoolWithTag(PagedPool, Length + sizeof(UNICODE_NULL), TAG_STRING);
    Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,
-      WindowObject->Class->Atom, NULL, NULL, Name, &Length);
+                                    WindowObject->Class->Atom, NULL, NULL, Name, &Length);
    if (!NT_SUCCESS(Status))
    {
       DPRINT("IntGetClassName: RtlQueryAtomInAtomTable failed\n");
@@ -231,16 +231,16 @@ IntGetClassName(struct _WINDOW_OBJECT *WindowObject, LPWSTR lpClassName,
 
 DWORD STDCALL
 NtUserGetClassName (
-  HWND hWnd,
-  LPWSTR lpClassName,
-  ULONG nMaxCount)
+   HWND hWnd,
+   LPWSTR lpClassName,
+   ULONG nMaxCount)
 {
    PWINDOW_OBJECT WindowObject;
    LONG Length;
    DECLARE_RETURN(DWORD);
-   
+
    UserEnterShared();
-   
+
    WindowObject = IntGetWindowObject(hWnd);
    if (WindowObject == NULL)
    {
@@ -250,7 +250,7 @@ NtUserGetClassName (
    Length = IntGetClassName(WindowObject, lpClassName, nMaxCount);
    IntReleaseWindowObject(WindowObject);
    RETURN(Length);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserGetClassName, ret=%i\n",_ret_);
    UserLeave();
@@ -259,10 +259,10 @@ CLEANUP:
 
 DWORD STDCALL
 NtUserGetWOWClass(DWORD Unknown0,
-                 DWORD Unknown1)
+                  DWORD Unknown1)
 {
-  UNIMPLEMENTED;
-  return(0);
+   UNIMPLEMENTED;
+   return(0);
 }
 
 PWNDCLASS_OBJECT FASTCALL
@@ -273,101 +273,104 @@ IntCreateClass(
    PUNICODE_STRING MenuName,
    RTL_ATOM Atom)
 {
-       PWNDCLASS_OBJECT ClassObject;
-       ULONG  objectSize;
-       BOOL Global;
-
-       Global = (Flags & REGISTERCLASS_SYSTEM) || (lpwcx->style & CS_GLOBALCLASS) ? TRUE : FALSE;
-
-       /* Check for double registration of the class. */
-       if (PsGetWin32Process() != NULL)
-       {
-               if (ClassReferenceClassByAtom(&ClassObject, Atom, lpwcx->hInstance))
-               {
-                       /*
-                        * NOTE: We may also get a global class from
-                         * ClassReferenceClassByAtom. This simple check
-                         * prevents that we fail valid request.
-                         */
-                       if (ClassObject->hInstance == lpwcx->hInstance)
-                       {
-                               SetLastWin32Error(ERROR_CLASS_ALREADY_EXISTS);
-                               ObmDereferenceObject(ClassObject);
-                               return(NULL);
-                       }
-               }
-       }
-
-       objectSize = sizeof(WNDCLASS_OBJECT) + lpwcx->cbClsExtra;
-       ClassObject = ObmCreateObject(&gHandleTable, NULL, otClass, objectSize);
-       if (ClassObject == 0)
-       {
-               SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-               return(NULL);
-       }
-
-       ClassObject->cbSize = lpwcx->cbSize;
-       ClassObject->style = lpwcx->style;
-       ClassObject->cbClsExtra = lpwcx->cbClsExtra;
-       ClassObject->cbWndExtra = lpwcx->cbWndExtra;
-       ClassObject->hInstance = lpwcx->hInstance;
-       ClassObject->hIcon = lpwcx->hIcon;
-       ClassObject->hCursor = lpwcx->hCursor;
-       ClassObject->hbrBackground = lpwcx->hbrBackground;
-       ClassObject->Unicode = !(Flags & REGISTERCLASS_ANSI);
-       ClassObject->Global = Global;
-       ClassObject->hIconSm = lpwcx->hIconSm;
-       ClassObject->Atom = Atom;
-       if (wpExtra == NULL) {
-               if (Flags & REGISTERCLASS_ANSI)
-               {
-                       ClassObject->lpfnWndProcA = lpwcx->lpfnWndProc;
-                       ClassObject->lpfnWndProcW = (WNDPROC)IntAddWndProcHandle(lpwcx->lpfnWndProc,FALSE);
-               }
-               else
-               {
-                       ClassObject->lpfnWndProcW = lpwcx->lpfnWndProc;
-                       ClassObject->lpfnWndProcA = (WNDPROC)IntAddWndProcHandle(lpwcx->lpfnWndProc,TRUE);
-               }
-       } else {
-               if (Flags & REGISTERCLASS_ANSI)
-               {
-                       ClassObject->lpfnWndProcA = lpwcx->lpfnWndProc;
-                       ClassObject->lpfnWndProcW = wpExtra;
-               }
-               else
-               {
-                       ClassObject->lpfnWndProcW = lpwcx->lpfnWndProc;
-                       ClassObject->lpfnWndProcA = wpExtra;
-               }
-       }
-       if (MenuName->Length == 0)
-       {
-               ClassObject->lpszMenuName.Length =
-               ClassObject->lpszMenuName.MaximumLength = 0;
-               ClassObject->lpszMenuName.Buffer = MenuName->Buffer;
-       }
-       else
-       {
-               ClassObject->lpszMenuName.Length =
-               ClassObject->lpszMenuName.MaximumLength = MenuName->MaximumLength;
-               ClassObject->lpszMenuName.Buffer = ExAllocatePoolWithTag(PagedPool, ClassObject->lpszMenuName.MaximumLength, TAG_STRING);
-               RtlCopyUnicodeString(&ClassObject->lpszMenuName, MenuName);
-       }
-       /* Extra class data */
-       if (ClassObject->cbClsExtra != 0)
-       {
-               ClassObject->ExtraData = (PCHAR)(ClassObject + 1);
-               RtlZeroMemory(ClassObject->ExtraData, (ULONG)ClassObject->cbClsExtra);
-       }
-       else
-       {
-               ClassObject->ExtraData = NULL;
-       }
-
-       InitializeListHead(&ClassObject->ClassWindowsListHead);
-
-       return(ClassObject);
+   PWNDCLASS_OBJECT ClassObject;
+   ULONG  objectSize;
+   BOOL Global;
+
+   Global = (Flags & REGISTERCLASS_SYSTEM) || (lpwcx->style & CS_GLOBALCLASS) ? TRUE : FALSE;
+
+   /* Check for double registration of the class. */
+   if (PsGetWin32Process() != NULL)
+   {
+      if (ClassReferenceClassByAtom(&ClassObject, Atom, lpwcx->hInstance))
+      {
+         /*
+          * NOTE: We may also get a global class from
+                               * ClassReferenceClassByAtom. This simple check
+                               * prevents that we fail valid request.
+                               */
+         if (ClassObject->hInstance == lpwcx->hInstance)
+         {
+            SetLastWin32Error(ERROR_CLASS_ALREADY_EXISTS);
+            ObmDereferenceObject(ClassObject);
+            return(NULL);
+         }
+      }
+   }
+
+   objectSize = sizeof(WNDCLASS_OBJECT) + lpwcx->cbClsExtra;
+   ClassObject = ObmCreateObject(&gHandleTable, NULL, otClass, objectSize);
+   if (ClassObject == 0)
+   {
+      SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+      return(NULL);
+   }
+
+   ClassObject->cbSize = lpwcx->cbSize;
+   ClassObject->style = lpwcx->style;
+   ClassObject->cbClsExtra = lpwcx->cbClsExtra;
+   ClassObject->cbWndExtra = lpwcx->cbWndExtra;
+   ClassObject->hInstance = lpwcx->hInstance;
+   ClassObject->hIcon = lpwcx->hIcon;
+   ClassObject->hCursor = lpwcx->hCursor;
+   ClassObject->hbrBackground = lpwcx->hbrBackground;
+   ClassObject->Unicode = !(Flags & REGISTERCLASS_ANSI);
+   ClassObject->Global = Global;
+   ClassObject->hIconSm = lpwcx->hIconSm;
+   ClassObject->Atom = Atom;
+   if (wpExtra == NULL)
+   {
+      if (Flags & REGISTERCLASS_ANSI)
+      {
+         ClassObject->lpfnWndProcA = lpwcx->lpfnWndProc;
+         ClassObject->lpfnWndProcW = (WNDPROC)IntAddWndProcHandle(lpwcx->lpfnWndProc,FALSE);
+      }
+      else
+      {
+         ClassObject->lpfnWndProcW = lpwcx->lpfnWndProc;
+         ClassObject->lpfnWndProcA = (WNDPROC)IntAddWndProcHandle(lpwcx->lpfnWndProc,TRUE);
+      }
+   }
+   else
+   {
+      if (Flags & REGISTERCLASS_ANSI)
+      {
+         ClassObject->lpfnWndProcA = lpwcx->lpfnWndProc;
+         ClassObject->lpfnWndProcW = wpExtra;
+      }
+      else
+      {
+         ClassObject->lpfnWndProcW = lpwcx->lpfnWndProc;
+         ClassObject->lpfnWndProcA = wpExtra;
+      }
+   }
+   if (MenuName->Length == 0)
+   {
+      ClassObject->lpszMenuName.Length =
+         ClassObject->lpszMenuName.MaximumLength = 0;
+      ClassObject->lpszMenuName.Buffer = MenuName->Buffer;
+   }
+   else
+   {
+      ClassObject->lpszMenuName.Length =
+         ClassObject->lpszMenuName.MaximumLength = MenuName->MaximumLength;
+      ClassObject->lpszMenuName.Buffer = ExAllocatePoolWithTag(PagedPool, ClassObject->lpszMenuName.MaximumLength, TAG_STRING);
+      RtlCopyUnicodeString(&ClassObject->lpszMenuName, MenuName);
+   }
+   /* Extra class data */
+   if (ClassObject->cbClsExtra != 0)
+   {
+      ClassObject->ExtraData = (PCHAR)(ClassObject + 1);
+      RtlZeroMemory(ClassObject->ExtraData, (ULONG)ClassObject->cbClsExtra);
+   }
+   else
+   {
+      ClassObject->ExtraData = NULL;
+   }
+
+   InitializeListHead(&ClassObject->ClassWindowsListHead);
+
+   return(ClassObject);
 }
 
 RTL_ATOM STDCALL
@@ -428,279 +431,279 @@ NtUserRegisterClassExWOW(
       RETURN( (RTL_ATOM)0);
    }
 
-  WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
+   WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
 
-  if (ClassName->Length > 0)
-  {
-    DPRINT("NtUserRegisterClassExWOW(%S)\n", ClassName->Buffer);
-    /* FIXME - Safely copy/verify the buffer first!!! */
-    Status = RtlAddAtomToAtomTable(WinStaObject->AtomTable,
-      ClassName->Buffer,
-      &Atom);
-    if (!NT_SUCCESS(Status))
-    {
-      DPRINT1("Failed adding class name (%S) to atom table\n",
-       ClassName->Buffer);
-      SetLastNtError(Status);
+   if (ClassName->Length > 0)
+   {
+      DPRINT("NtUserRegisterClassExWOW(%S)\n", ClassName->Buffer);
+      /* FIXME - Safely copy/verify the buffer first!!! */
+      Status = RtlAddAtomToAtomTable(WinStaObject->AtomTable,
+                                     ClassName->Buffer,
+                                     &Atom);
+      if (!NT_SUCCESS(Status))
+      {
+         DPRINT1("Failed adding class name (%S) to atom table\n",
+                 ClassName->Buffer);
+         SetLastNtError(Status);
+         RETURN((RTL_ATOM)0);
+      }
+   }
+   else
+   {
+      Atom = (RTL_ATOM)(ULONG)ClassName->Buffer;
+   }
+   ClassObject = IntCreateClass(&SafeClass, Flags, wpExtra, MenuName, Atom);
+   if (ClassObject == NULL)
+   {
+      if (ClassName->Length)
+      {
+         RtlDeleteAtomFromAtomTable(WinStaObject->AtomTable, Atom);
+      }
+      DPRINT("Failed creating window class object\n");
       RETURN((RTL_ATOM)0);
-    }
-  }
-  else
-  {
-    Atom = (RTL_ATOM)(ULONG)ClassName->Buffer;
-  }
-  ClassObject = IntCreateClass(&SafeClass, Flags, wpExtra, MenuName, Atom);
-  if (ClassObject == NULL)
-  {
-    if (ClassName->Length)
-    {
-      RtlDeleteAtomFromAtomTable(WinStaObject->AtomTable, Atom);
-    }
-    DPRINT("Failed creating window class object\n");
-    RETURN((RTL_ATOM)0);
-  }
-
-  InsertTailList(&PsGetWin32Process()->ClassListHead, &ClassObject->ListEntry);
-
-  RETURN(Atom);
+   }
+
+   InsertTailList(&PsGetWin32Process()->ClassListHead, &ClassObject->ListEntry);
+
+   RETURN(Atom);
 
 CLEANUP:
-  DPRINT("Leave NtUserRegisterClassExWOW, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserRegisterClassExWOW, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 ULONG FASTCALL
 IntGetClassLong(struct _WINDOW_OBJECT *Window, ULONG Offset, BOOL Ansi)
 {
-  LONG Ret;
+   LONG Ret;
 
-  if ((int)Offset >= 0)
-    {
+   if ((int)Offset >= 0)
+   {
       DPRINT("GetClassLong(%x, %d)\n", Window->hSelf, Offset);
       if ((Offset + sizeof(LONG)) > Window->Class->cbClsExtra)
-       {
-         SetLastWin32Error(ERROR_INVALID_PARAMETER);
-         return 0;
-       }
+      {
+         SetLastWin32Error(ERROR_INVALID_PARAMETER);
+         return 0;
+      }
       Ret = *((LONG *)(Window->Class->ExtraData + Offset));
       DPRINT("Result: %x\n", Ret);
       return Ret;
-    }
-
-  switch (Offset)
-    {
-    case GCL_CBWNDEXTRA:
-      Ret = Window->Class->cbWndExtra;
-      break;
-    case GCL_CBCLSEXTRA:
-      Ret = Window->Class->cbClsExtra;
-      break;
-    case GCL_HBRBACKGROUND:
-      Ret = (ULONG)Window->Class->hbrBackground;
-      break;
-    case GCL_HCURSOR:
-      Ret = (ULONG)Window->Class->hCursor;
-      break;
-    case GCL_HICON:
-      Ret = (ULONG)Window->Class->hIcon;
-      break;
-    case GCL_HICONSM:
-      Ret = (ULONG)Window->Class->hIconSm;
-      break;
-    case GCL_HMODULE:
-      Ret = (ULONG)Window->Class->hInstance;
-      break;
-    case GCL_MENUNAME:
-      Ret = (ULONG)Window->Class->lpszMenuName.Buffer;
-      break;
-    case GCL_STYLE:
-      Ret = Window->Class->style;
-      break;
-    case GCL_WNDPROC:
-         if (Ansi)
-         {
-               Ret = (ULONG)Window->Class->lpfnWndProcA;
-         }
-         else
-         {
-               Ret = (ULONG)Window->Class->lpfnWndProcW;
-         }
-      break;
-    default:
-      Ret = 0;
-      break;
-    }
-  return(Ret);
+   }
+
+   switch (Offset)
+   {
+      case GCL_CBWNDEXTRA:
+         Ret = Window->Class->cbWndExtra;
+         break;
+      case GCL_CBCLSEXTRA:
+         Ret = Window->Class->cbClsExtra;
+         break;
+      case GCL_HBRBACKGROUND:
+         Ret = (ULONG)Window->Class->hbrBackground;
+         break;
+      case GCL_HCURSOR:
+         Ret = (ULONG)Window->Class->hCursor;
+         break;
+      case GCL_HICON:
+         Ret = (ULONG)Window->Class->hIcon;
+         break;
+      case GCL_HICONSM:
+         Ret = (ULONG)Window->Class->hIconSm;
+         break;
+      case GCL_HMODULE:
+         Ret = (ULONG)Window->Class->hInstance;
+         break;
+      case GCL_MENUNAME:
+         Ret = (ULONG)Window->Class->lpszMenuName.Buffer;
+         break;
+      case GCL_STYLE:
+         Ret = Window->Class->style;
+         break;
+      case GCL_WNDPROC:
+         if (Ansi)
+         {
+            Ret = (ULONG)Window->Class->lpfnWndProcA;
+         }
+         else
+         {
+            Ret = (ULONG)Window->Class->lpfnWndProcW;
+         }
+         break;
+      default:
+         Ret = 0;
+         break;
+   }
+   return(Ret);
 }
 
 DWORD STDCALL
 NtUserGetClassLong(HWND hWnd, DWORD Offset, BOOL Ansi)
 {
-  PWINDOW_OBJECT Window;
-  DECLARE_RETURN(DWORD);
-
-  DPRINT("Enter NtUserGetClassLong\n");
-  UserEnterExclusive();
-
-  if (!(Window = UserGetWindowObject(hWnd)))
-  {
-    RETURN(0);
-  }
-  
-  RETURN(IntGetClassLong(Window, Offset, Ansi));
-  
+   PWINDOW_OBJECT Window;
+   DECLARE_RETURN(DWORD);
+
+   DPRINT("Enter NtUserGetClassLong\n");
+   UserEnterExclusive();
+
+   if (!(Window = UserGetWindowObject(hWnd)))
+   {
+      RETURN(0);
+   }
+
+   RETURN(IntGetClassLong(Window, Offset, Ansi));
+
 CLEANUP:
-  DPRINT("Leave NtUserGetClassLong, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetClassLong, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 void FASTCALL
 co_IntSetClassLong(PWINDOW_OBJECT Window, ULONG Offset, LONG dwNewLong, BOOL Ansi)
 {
-  PWINDOW_OBJECT Parent, Owner;
+   PWINDOW_OBJECT Parent, Owner;
 
-  ASSERT_REFS_CO(Window); 
+   ASSERT_REFS_CO(Window);
 
-  if ((int)Offset >= 0)
-    {
+   if ((int)Offset >= 0)
+   {
       DPRINT("SetClassLong(%x, %d, %x)\n", Window->hSelf, Offset, dwNewLong);
       if ((Offset + sizeof(LONG)) > Window->Class->cbClsExtra)
-       {
-         SetLastWin32Error(ERROR_INVALID_PARAMETER);
-         return;
-       }
-      *((LONG *)(Window->Class->ExtraData + Offset)) = dwNewLong;
-      return;
-    }
-
-  switch (Offset)
-    {
-    case GCL_CBWNDEXTRA:
-      Window->Class->cbWndExtra = dwNewLong;
-      break;
-    case GCL_CBCLSEXTRA:
-      Window->Class->cbClsExtra = dwNewLong;
-      break;
-    case GCL_HBRBACKGROUND:
-      Window->Class->hbrBackground = (HBRUSH)dwNewLong;
-      break;
-    case GCL_HCURSOR:
-      Window->Class->hCursor = (HCURSOR)dwNewLong;
-      break;
-    case GCL_HICON:
-      Window->Class->hIcon = (HICON)dwNewLong;
-      Owner = IntGetOwner(Window);
-      Parent = IntGetParent(Window);
-
-      if ((!Owner) && (!Parent))
-        {
-          co_IntShellHookNotify(HSHELL_REDRAW, (LPARAM) Window->hSelf);
-        }
-
-      if (Parent)
-        {
-          IntReleaseWindowObject(Parent);
-        }
-
-      if (Owner)
-        {
-          IntReleaseWindowObject(Owner);
-        }
-
-
-      break;
-    case GCL_HICONSM:
-      Window->Class->hIconSm = (HICON)dwNewLong;
-      break;
-    case GCL_HMODULE:
-      Window->Class->hInstance = (HINSTANCE)dwNewLong;
-      break;
-    case GCL_MENUNAME:
-      if (Window->Class->lpszMenuName.MaximumLength)
-        RtlFreeUnicodeString(&Window->Class->lpszMenuName);
-      if (!IS_INTRESOURCE(dwNewLong))
       {
-        Window->Class->lpszMenuName.Length =
-        Window->Class->lpszMenuName.MaximumLength = ((PUNICODE_STRING)dwNewLong)->MaximumLength;
-        Window->Class->lpszMenuName.Buffer = ExAllocatePoolWithTag(PagedPool, Window->Class->lpszMenuName.MaximumLength, TAG_STRING);
-        RtlCopyUnicodeString(&Window->Class->lpszMenuName, (PUNICODE_STRING)dwNewLong);
+         SetLastWin32Error(ERROR_INVALID_PARAMETER);
+         return;
       }
-      else
-      {
-        Window->Class->lpszMenuName.Length =
-        Window->Class->lpszMenuName.MaximumLength = 0;
-        Window->Class->lpszMenuName.Buffer = (LPWSTR)dwNewLong;
-      }
-      break;
-    case GCL_STYLE:
-      Window->Class->style = dwNewLong;
-      break;
-    case GCL_WNDPROC:
-         if (Ansi)
-         {
-               Window->Class->lpfnWndProcA = (WNDPROC)dwNewLong;
-      Window->Class->lpfnWndProcW = (WNDPROC) IntAddWndProcHandle((WNDPROC)dwNewLong,FALSE);
-               Window->Class->Unicode = FALSE;
-         }
-         else
-         {
-               Window->Class->lpfnWndProcW = (WNDPROC)dwNewLong;
-      Window->Class->lpfnWndProcA = (WNDPROC) IntAddWndProcHandle((WNDPROC)dwNewLong,TRUE);
-               Window->Class->Unicode = TRUE;
-         }
-      break;
-    }
+      *((LONG *)(Window->Class->ExtraData + Offset)) = dwNewLong;
+      return;
+   }
+
+   switch (Offset)
+   {
+      case GCL_CBWNDEXTRA:
+         Window->Class->cbWndExtra = dwNewLong;
+         break;
+      case GCL_CBCLSEXTRA:
+         Window->Class->cbClsExtra = dwNewLong;
+         break;
+      case GCL_HBRBACKGROUND:
+         Window->Class->hbrBackground = (HBRUSH)dwNewLong;
+         break;
+      case GCL_HCURSOR:
+         Window->Class->hCursor = (HCURSOR)dwNewLong;
+         break;
+      case GCL_HICON:
+         Window->Class->hIcon = (HICON)dwNewLong;
+         Owner = IntGetOwner(Window);
+         Parent = IntGetParent(Window);
+
+         if ((!Owner) && (!Parent))
+         {
+            co_IntShellHookNotify(HSHELL_REDRAW, (LPARAM) Window->hSelf);
+         }
+
+         if (Parent)
+         {
+            IntReleaseWindowObject(Parent);
+         }
+
+         if (Owner)
+         {
+            IntReleaseWindowObject(Owner);
+         }
+
+
+         break;
+      case GCL_HICONSM:
+         Window->Class->hIconSm = (HICON)dwNewLong;
+         break;
+      case GCL_HMODULE:
+         Window->Class->hInstance = (HINSTANCE)dwNewLong;
+         break;
+      case GCL_MENUNAME:
+         if (Window->Class->lpszMenuName.MaximumLength)
+            RtlFreeUnicodeString(&Window->Class->lpszMenuName);
+         if (!IS_INTRESOURCE(dwNewLong))
+         {
+            Window->Class->lpszMenuName.Length =
+               Window->Class->lpszMenuName.MaximumLength = ((PUNICODE_STRING)dwNewLong)->MaximumLength;
+            Window->Class->lpszMenuName.Buffer = ExAllocatePoolWithTag(PagedPool, Window->Class->lpszMenuName.MaximumLength, TAG_STRING);
+            RtlCopyUnicodeString(&Window->Class->lpszMenuName, (PUNICODE_STRING)dwNewLong);
+         }
+         else
+         {
+            Window->Class->lpszMenuName.Length =
+               Window->Class->lpszMenuName.MaximumLength = 0;
+            Window->Class->lpszMenuName.Buffer = (LPWSTR)dwNewLong;
+         }
+         break;
+      case GCL_STYLE:
+         Window->Class->style = dwNewLong;
+         break;
+      case GCL_WNDPROC:
+         if (Ansi)
+         {
+            Window->Class->lpfnWndProcA = (WNDPROC)dwNewLong;
+            Window->Class->lpfnWndProcW = (WNDPROC) IntAddWndProcHandle((WNDPROC)dwNewLong,FALSE);
+            Window->Class->Unicode = FALSE;
+         }
+         else
+         {
+            Window->Class->lpfnWndProcW = (WNDPROC)dwNewLong;
+            Window->Class->lpfnWndProcA = (WNDPROC) IntAddWndProcHandle((WNDPROC)dwNewLong,TRUE);
+            Window->Class->Unicode = TRUE;
+         }
+         break;
+   }
 }
 
 DWORD STDCALL
 NtUserSetClassLong(HWND hWnd,
-                  DWORD Offset,
-                  LONG dwNewLong,
-                  BOOL Ansi)
+                   DWORD Offset,
+                   LONG dwNewLong,
+                   BOOL Ansi)
 {
-  PWINDOW_OBJECT Window;
-  LONG Ret;
-  DECLARE_RETURN(DWORD);
-
-  DPRINT("Enter NtUserSetClassLong\n");
-  UserEnterExclusive();
-
-  if (!(Window = UserGetWindowObject(hWnd)))
-  {
-    RETURN(0);
-  }
-  
-  UserRefObjectCo(Window);
-  
-  Ret = IntGetClassLong(Window, Offset, Ansi);
-  co_IntSetClassLong(Window, Offset, dwNewLong, Ansi);
-  
-  UserDerefObjectCo(Window);
-  
-  RETURN(Ret);
-  
+   PWINDOW_OBJECT Window;
+   LONG Ret;
+   DECLARE_RETURN(DWORD);
+
+   DPRINT("Enter NtUserSetClassLong\n");
+   UserEnterExclusive();
+
+   if (!(Window = UserGetWindowObject(hWnd)))
+   {
+      RETURN(0);
+   }
+
+   UserRefObjectCo(Window);
+
+   Ret = IntGetClassLong(Window, Offset, Ansi);
+   co_IntSetClassLong(Window, Offset, dwNewLong, Ansi);
+
+   UserDerefObjectCo(Window);
+
+   RETURN(Ret);
+
 CLEANUP:
-  DPRINT("Leave NtUserSetClassLong, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserSetClassLong, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 DWORD STDCALL
 NtUserSetClassWord(DWORD Unknown0,
-                  DWORD Unknown1,
-                  DWORD Unknown2)
+                   DWORD Unknown1,
+                   DWORD Unknown2)
 {
-  UNIMPLEMENTED;
-  return(0);
+   UNIMPLEMENTED;
+   return(0);
 }
 
 BOOL STDCALL
 NtUserUnregisterClass(
    LPCWSTR ClassNameOrAtom,
-        HINSTANCE hInstance,
-        DWORD Unknown)
+   HINSTANCE hInstance,
+   DWORD Unknown)
 {
    PWNDCLASS_OBJECT Class;
    PWINSTATION_OBJECT WinSta;
@@ -749,7 +752,7 @@ NtUserUnregisterClass(
    ClassDereferenceObject(Class);
 
    RETURN( TRUE);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserUnregisterClass, ret=%i\n",_ret_);
    UserLeave();
index 090efbe..44ad97e 100644 (file)
@@ -47,7 +47,7 @@ IntGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName)
 {
 
    return IntGetAtomName((RTL_ATOM)format, FormatName->Buffer,
-      FormatName->MaximumLength);
+                         FormatName->MaximumLength);
 }
 
 UINT FASTCALL
@@ -57,7 +57,7 @@ IntEnumClipboardFormats(UINT format)
    CHECK_LOCK
 
    if (!hCBData)
-       return FALSE;
+      return FALSE;
    //UNIMPLEMENTED;
    return 1;
 }
@@ -114,12 +114,12 @@ NtUserEmptyClipboard(VOID)
 {
    CHECK_LOCK
 
-//   if (!hCBData)
-//       return FALSE;
+   //   if (!hCBData)
+   //       return FALSE;
 
-//   FIXME!
-//   GlobalUnlock(hCBData);
-//   GlobalFree(hCBData);
+   //   FIXME!
+   //   GlobalUnlock(hCBData);
+   //   GlobalFree(hCBData);
    hCBData = NULL;
    uCBFormat = 0;
    ClipboardWindow = tempClipboardWindow;
@@ -133,90 +133,90 @@ NtUserGetClipboardData(UINT uFormat, DWORD Unknown1)
    CHECK_LOCK
 
    if ((uFormat==1 && uCBFormat==13) || (uFormat==13 && uCBFormat==1))
-       uCBFormat = uFormat;
+      uCBFormat = uFormat;
 
    if (uFormat != uCBFormat)
-       return FALSE;
+      return FALSE;
 
    return hCBData;
 }
 
 INT STDCALL
 NtUserGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName,
-   INT cchMaxCount)
+                             INT cchMaxCount)
 {
-  NTSTATUS Status;
-  PWSTR Buf;
-  UNICODE_STRING SafeFormatName, BufFormatName;
-  ULONG Ret;
-
-  if((cchMaxCount < 1) || !FormatName)
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    return 0;
-  }
-
-  /* copy the FormatName UNICODE_STRING structure */
-  Status = MmCopyFromCaller(&SafeFormatName, FormatName, sizeof(UNICODE_STRING));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return 0;
-  }
-
-  /* Allocate memory for the string */
-  Buf = ExAllocatePoolWithTag(PagedPool, cchMaxCount * sizeof(WCHAR), TAG_STRING);
-  if(!Buf)
-  {
-    SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-    return 0;
-  }
-
-  /* Setup internal unicode string */
-  BufFormatName.Length = 0;
-  BufFormatName.MaximumLength = min(cchMaxCount * sizeof(WCHAR), SafeFormatName.MaximumLength);
-  BufFormatName.Buffer = Buf;
-
-  if(BufFormatName.MaximumLength < sizeof(WCHAR))
-  {
-    ExFreePool(Buf);
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    return 0;
-  }
-
-  if (format >= 0xC000)
-  {
-     Ret = IntGetClipboardFormatName(format, &BufFormatName);
-  }
-  else
-  {
-     SetLastNtError(NO_ERROR);
-     return 0;
-  }
-
-  /* copy the UNICODE_STRING buffer back to the user */
-  Status = MmCopyToCaller(SafeFormatName.Buffer, BufFormatName.Buffer, BufFormatName.MaximumLength);
-  if(!NT_SUCCESS(Status))
-  {
-    ExFreePool(Buf);
-    SetLastNtError(Status);
-    return 0;
-  }
-
-  BufFormatName.MaximumLength = SafeFormatName.MaximumLength;
-  BufFormatName.Buffer = SafeFormatName.Buffer;
-
-  /* update the UNICODE_STRING structure (only the Length member should change) */
-  Status = MmCopyToCaller(FormatName, &BufFormatName, sizeof(UNICODE_STRING));
-  if(!NT_SUCCESS(Status))
-  {
-    ExFreePool(Buf);
-    SetLastNtError(Status);
-    return 0;
-  }
-
-  ExFreePool(Buf);
-  return Ret;
+   NTSTATUS Status;
+   PWSTR Buf;
+   UNICODE_STRING SafeFormatName, BufFormatName;
+   ULONG Ret;
+
+   if((cchMaxCount < 1) || !FormatName)
+   {
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      return 0;
+   }
+
+   /* copy the FormatName UNICODE_STRING structure */
+   Status = MmCopyFromCaller(&SafeFormatName, FormatName, sizeof(UNICODE_STRING));
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      return 0;
+   }
+
+   /* Allocate memory for the string */
+   Buf = ExAllocatePoolWithTag(PagedPool, cchMaxCount * sizeof(WCHAR), TAG_STRING);
+   if(!Buf)
+   {
+      SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+      return 0;
+   }
+
+   /* Setup internal unicode string */
+   BufFormatName.Length = 0;
+   BufFormatName.MaximumLength = min(cchMaxCount * sizeof(WCHAR), SafeFormatName.MaximumLength);
+   BufFormatName.Buffer = Buf;
+
+   if(BufFormatName.MaximumLength < sizeof(WCHAR))
+   {
+      ExFreePool(Buf);
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      return 0;
+   }
+
+   if (format >= 0xC000)
+   {
+      Ret = IntGetClipboardFormatName(format, &BufFormatName);
+   }
+   else
+   {
+      SetLastNtError(NO_ERROR);
+      return 0;
+   }
+
+   /* copy the UNICODE_STRING buffer back to the user */
+   Status = MmCopyToCaller(SafeFormatName.Buffer, BufFormatName.Buffer, BufFormatName.MaximumLength);
+   if(!NT_SUCCESS(Status))
+   {
+      ExFreePool(Buf);
+      SetLastNtError(Status);
+      return 0;
+   }
+
+   BufFormatName.MaximumLength = SafeFormatName.MaximumLength;
+   BufFormatName.Buffer = SafeFormatName.Buffer;
+
+   /* update the UNICODE_STRING structure (only the Length member should change) */
+   Status = MmCopyToCaller(FormatName, &BufFormatName, sizeof(UNICODE_STRING));
+   if(!NT_SUCCESS(Status))
+   {
+      ExFreePool(Buf);
+      SetLastNtError(Status);
+      return 0;
+   }
+
+   ExFreePool(Buf);
+   return Ret;
 }
 
 HWND STDCALL
@@ -251,16 +251,17 @@ NtUserIsClipboardFormatAvailable(UINT format)
 {
    //UNIMPLEMENTED
 
-   if (format != 1 && format != 13) {
+   if (format != 1 && format != 13)
+   {
       DbgPrint("Clipboard Format unavailable (%d)\n", format);
       return FALSE;
    }
 
    if ((format==1 && uCBFormat==13) || (format==13 && uCBFormat==1))
-       uCBFormat = format;
+      uCBFormat = format;
 
    if (format != uCBFormat)
-     return FALSE;
+      return FALSE;
 
    return TRUE;
 }
@@ -269,48 +270,49 @@ NtUserIsClipboardFormatAvailable(UINT format)
 HANDLE STDCALL
 NtUserSetClipboardData(UINT uFormat, HANDLE hMem, DWORD Unknown2)
 {
-//    LPVOID pMem;
-    CHECK_LOCK
+   //    LPVOID pMem;
+   CHECK_LOCK
 
 
-   if (uFormat != 1 && uFormat != 13) {
+   if (uFormat != 1 && uFormat != 13)
+   {
       DbgPrint("Clipboard unsupported format (%d)\n", uFormat);
       return FALSE;
    }
 
-    if (hMem)
-    {
-        uCBFormat = uFormat;
-        hCBData = hMem;
-        //pMem = GlobalLock(hMem);
-        /*
-        switch (uFormat) {
-            default:
-                DbgPrint("Clipboard unsupported format (%d)\n", uFormat);
-                return FALSE;
-            case CF_TEXT:             // 1
-                break;
-            case CF_UNICODETEXT:      // 13
-                break;
-            case CF_BITMAP:           // 2
-                break;
-            case CF_OEMTEXT:          // 7
-                break;
-        } */
-    }
-    else
-    {
-    //the window provides data in the specified format
-    }
-    return hMem;
+   if (hMem)
+   {
+      uCBFormat = uFormat;
+      hCBData = hMem;
+      //pMem = GlobalLock(hMem);
+      /*
+      switch (uFormat) {
+          default:
+              DbgPrint("Clipboard unsupported format (%d)\n", uFormat);
+              return FALSE;
+          case CF_TEXT:             // 1
+              break;
+          case CF_UNICODETEXT:      // 13
+              break;
+          case CF_BITMAP:           // 2
+              break;
+          case CF_OEMTEXT:          // 7
+              break;
+      } */
+   }
+   else
+   {
+      //the window provides data in the specified format
+   }
+   return hMem;
 }
 
 HWND STDCALL
 NtUserSetClipboardViewer(HWND hWndNewViewer)
 {
-    HWND hwndPrev = 0;
-    DbgPrint("NtUserSetClipboardViewer is UNIMPLEMENTED (%p): returning %p\n", hWndNewViewer, hwndPrev);
-    return hwndPrev;
+   HWND hwndPrev = 0;
+   DbgPrint("NtUserSetClipboardViewer is UNIMPLEMENTED (%p): returning %p\n", hWndNewViewer, hwndPrev);
+   return hwndPrev;
 }
 
 /* EOF */
index 9307c21..c58e69e 100644 (file)
 
 static HANDLE WindowsApiPort = NULL;
 PEPROCESS CsrProcess = NULL;
-           
+
 NTSTATUS FASTCALL
 CsrInit(void)
 {
-  NTSTATUS Status;
-  UNICODE_STRING PortName;
-  ULONG ConnectInfoLength;
-
-  RtlInitUnicodeString(&PortName, L"\\Windows\\ApiPort");
-  ConnectInfoLength = 0;
-  Status = ZwConnectPort(&WindowsApiPort,
-                         &PortName,
-                         NULL,
-                         NULL,
-                         NULL,
-                         NULL,
-                         NULL,
-                         &ConnectInfoLength);
-  if (! NT_SUCCESS(Status))
-    {
+   NTSTATUS Status;
+   UNICODE_STRING PortName;
+   ULONG ConnectInfoLength;
+
+   RtlInitUnicodeString(&PortName, L"\\Windows\\ApiPort");
+   ConnectInfoLength = 0;
+   Status = ZwConnectPort(&WindowsApiPort,
+                          &PortName,
+                          NULL,
+                          NULL,
+                          NULL,
+                          NULL,
+                          NULL,
+                          &ConnectInfoLength);
+   if (! NT_SUCCESS(Status))
+   {
       return Status;
-    }
+   }
 
-  CsrProcess = PsGetCurrentProcess();
+   CsrProcess = PsGetCurrentProcess();
 
-  return STATUS_SUCCESS;
+   return STATUS_SUCCESS;
 }
 
 
 NTSTATUS FASTCALL
 co_CsrNotify(PCSR_API_MESSAGE Request)
 {
-  NTSTATUS Status;
-  PEPROCESS OldProcess;
+   NTSTATUS Status;
+   PEPROCESS OldProcess;
 
-  if (NULL == CsrProcess)
-    {
+   if (NULL == CsrProcess)
+   {
       return STATUS_INVALID_PORT_HANDLE;
-    }
+   }
 
-  Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
-  Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
+   Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
+   Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
 
-  /* Switch to the process in which the WindowsApiPort handle is valid */
-  OldProcess = PsGetCurrentProcess();
-  if (CsrProcess != OldProcess)
-    {
+   /* Switch to the process in which the WindowsApiPort handle is valid */
+   OldProcess = PsGetCurrentProcess();
+   if (CsrProcess != OldProcess)
+   {
       KeAttachProcess(&CsrProcess->Pcb);
-    }
-   
-  UserLeaveCo();
-
-  Status = ZwRequestWaitReplyPort(WindowsApiPort,
-                                  &Request->Header,
-                                  &Request->Header);
-                                  
-  UserEnterCo();
-  
-  if (CsrProcess != OldProcess)
-    {
+   }
+
+   UserLeaveCo();
+
+   Status = ZwRequestWaitReplyPort(WindowsApiPort,
+                                   &Request->Header,
+                                   &Request->Header);
+
+   UserEnterCo();
+
+   if (CsrProcess != OldProcess)
+   {
       KeDetachProcess();
-    }
+   }
 
-  if (NT_SUCCESS(Status))
-    {
+   if (NT_SUCCESS(Status))
+   {
       Status = Request->Status;
-    }
+   }
 
-  return Status;
+   return Status;
 }
 
 NTSTATUS
@@ -91,30 +91,30 @@ CsrInsertObject(HANDLE ObjectHandle,
                 ACCESS_MASK DesiredAccess,
                 PHANDLE Handle)
 {
-  NTSTATUS Status;
-  HANDLE CsrProcessHandle;
-  OBJECT_ATTRIBUTES ObjectAttributes;
-  CLIENT_ID Cid;
-  
-  /* Put CSR'S CID */
-  Cid.UniqueProcess = CsrProcess->UniqueProcessId;
-  Cid.UniqueThread = 0;
-  
-  /* Empty Attributes */
-  InitializeObjectAttributes(&ObjectAttributes,
-                             NULL,
-                             0,
-                             NULL,
-                             NULL);
-  
-  /* Get a Handle to Csrss */
-  Status = ZwOpenProcess(&CsrProcessHandle,
-                         PROCESS_DUP_HANDLE,
-                         &ObjectAttributes,
-                         &Cid);
-                         
-  if ((NT_SUCCESS(Status)))
-  {                         
+   NTSTATUS Status;
+   HANDLE CsrProcessHandle;
+   OBJECT_ATTRIBUTES ObjectAttributes;
+   CLIENT_ID Cid;
+
+   /* Put CSR'S CID */
+   Cid.UniqueProcess = CsrProcess->UniqueProcessId;
+   Cid.UniqueThread = 0;
+
+   /* Empty Attributes */
+   InitializeObjectAttributes(&ObjectAttributes,
+                              NULL,
+                              0,
+                              NULL,
+                              NULL);
+
+   /* Get a Handle to Csrss */
+   Status = ZwOpenProcess(&CsrProcessHandle,
+                          PROCESS_DUP_HANDLE,
+                          &ObjectAttributes,
+                          &Cid);
+
+   if ((NT_SUCCESS(Status)))
+   {
       /* Duplicate the Handle */
       Status = ZwDuplicateObject(NtCurrentProcess(),
                                  ObjectHandle,
@@ -123,35 +123,35 @@ CsrInsertObject(HANDLE ObjectHandle,
                                  DesiredAccess,
                                  TRUE,
                                  0);
-  
+
       /* Close our handle to CSRSS */
       ZwClose(CsrProcessHandle);
-  }
+   }
 
-  return Status;
+   return Status;
 }
 
 NTSTATUS FASTCALL
 CsrCloseHandle(HANDLE Handle)
 {
-  NTSTATUS Status;
-  PEPROCESS OldProcess;
+   NTSTATUS Status;
+   PEPROCESS OldProcess;
 
-  /* Switch to the process in which the handle is valid */
-  OldProcess = PsGetCurrentProcess();
-  if (CsrProcess != OldProcess)
-    {
+   /* Switch to the process in which the handle is valid */
+   OldProcess = PsGetCurrentProcess();
+   if (CsrProcess != OldProcess)
+   {
       KeAttachProcess(&CsrProcess->Pcb);
-    }
+   }
 
-  Status = ZwClose(Handle);
+   Status = ZwClose(Handle);
 
-  if (CsrProcess != OldProcess)
-    {
+   if (CsrProcess != OldProcess)
+   {
       KeDetachProcess();
-    }
+   }
 
-  return Status;
+   return Status;
 }
 
 /* EOF */
index 4fdb880..770fbf1 100644 (file)
@@ -50,25 +50,25 @@ static LIST_ENTRY CurIconList;
 BOOL FASTCALL
 IntGetCursorLocation(PWINSTATION_OBJECT WinStaObject, POINT *loc)
 {
-  HDC hDC;
-  PDC dc;
-  GDIDEVICE *GDIDevice;
+   HDC hDC;
+   PDC dc;
+   GDIDEVICE *GDIDevice;
 
 #if 1
-  /* FIXME - get the screen dc from the window station or desktop */
-  if (!(hDC = IntGetScreenDC()))
-    return FALSE;
+   /* FIXME - get the screen dc from the window station or desktop */
+   if (!(hDC = IntGetScreenDC()))
+      return FALSE;
 #endif
 
-  if (!(dc = DC_LockDc(hDC)))
-    return FALSE;
-  GDIDevice = (GDIDEVICE *)dc->GDIDevice;
-  DC_UnlockDc(dc);
+   if (!(dc = DC_LockDc(hDC)))
+      return FALSE;
+   GDIDevice = (GDIDEVICE *)dc->GDIDevice;
+   DC_UnlockDc(dc);
 
-  loc->x = GDIDevice->Pointer.Pos.x;
-  loc->y = GDIDevice->Pointer.Pos.y;
+   loc->x = GDIDevice->Pointer.Pos.x;
+   loc->y = GDIDevice->Pointer.Pos.y;
 
-  return TRUE;
+   return TRUE;
 }
 
 
@@ -83,7 +83,7 @@ PCURICON_OBJECT FASTCALL UserGetCurIconObject(HANDLE hWnd)
       SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
       return NULL;
    }
-   
+
    ASSERT(USER_BODY_TO_HEADER(Window)->RefCount >= 0);
    return Window;
 }
@@ -95,7 +95,7 @@ IntGetCurIconObject(HANDLE Handle)
    if (ci)
    {
       ASSERT(USER_BODY_TO_HEADER(ci)->RefCount >= 0);
-      
+
       USER_BODY_TO_HEADER(ci)->RefCount++;
    }
    return ci;
@@ -104,7 +104,7 @@ IntGetCurIconObject(HANDLE Handle)
 #define COLORCURSORS_ALLOWED FALSE
 HCURSOR FASTCALL
 IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor,
-   BOOL ForceChange)
+             BOOL ForceChange)
 {
    BITMAPOBJ *BitmapObj;
    SURFOBJ *SurfObj;
@@ -134,7 +134,7 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor,
    {
       if(!(Screen = IntGetScreenDC()))
       {
-        return (HCURSOR)0;
+         return (HCURSOR)0;
       }
       /* FIXME use the desktop's HDC instead of using ScreenDeviceContext */
       PDC dc = DC_LockDc(Screen);
@@ -149,7 +149,7 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor,
 
       BitmapObj = BITMAPOBJ_LockBitmap(dcbmp);
       if ( !BitmapObj )
-        return (HCURSOR)0;
+         return (HCURSOR)0;
       SurfObj = &BitmapObj->SurfObj;
       ASSERT(SurfObj);
    }
@@ -192,135 +192,135 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor,
       }
 
       if ((DevInfo->flGraphicsCaps2 & GCAPS2_ALPHACURSOR) &&
-          SurfObj->iBitmapFormat >= BMF_16BPP &&
-          SurfObj->iBitmapFormat <= BMF_32BPP &&
-          NewCursor->Shadow && COLORCURSORS_ALLOWED)
+            SurfObj->iBitmapFormat >= BMF_16BPP &&
+            SurfObj->iBitmapFormat <= BMF_32BPP &&
+            NewCursor->Shadow && COLORCURSORS_ALLOWED)
       {
-        /* FIXME - Create a color pointer, only 32bit bitmap, set alpha bits!
-                   Do not pass a mask bitmap to DrvSetPointerShape()!
-                   Create a XLATEOBJ that describes the colors of the bitmap. */
-        DPRINT1("SetCursor: (Colored) alpha cursors are not supported!\n");
+         /* FIXME - Create a color pointer, only 32bit bitmap, set alpha bits!
+                    Do not pass a mask bitmap to DrvSetPointerShape()!
+                    Create a XLATEOBJ that describes the colors of the bitmap. */
+         DPRINT1("SetCursor: (Colored) alpha cursors are not supported!\n");
       }
       else
       {
-        if(NewCursor->IconInfo.hbmColor
-           && COLORCURSORS_ALLOWED)
-        {
-          /* FIXME - Create a color pointer, create only one 32bit bitmap!
-                     Do not pass a mask bitmap to DrvSetPointerShape()!
-                     Create a XLATEOBJ that describes the colors of the bitmap.
-                     (16bit bitmaps are propably allowed) */
-          DPRINT1("SetCursor: Cursors with colors are not supported!\n");
-        }
-        else
-        {
-          MaskBmpObj = BITMAPOBJ_LockBitmap(NewCursor->IconInfo.hbmMask);
-          if(MaskBmpObj)
-          {
-            RECTL DestRect = {0, 0, MaskBmpObj->SurfObj.sizlBitmap.cx, MaskBmpObj->SurfObj.sizlBitmap.cy};
-            POINTL SourcePoint = {0, 0};
-
-            /*
-             * NOTE: For now we create the cursor in top-down bitmap,
-             * because VMware driver rejects it otherwise. This should
-             * be fixed later.
-             */
-            hMask = EngCreateBitmap(
-              MaskBmpObj->SurfObj.sizlBitmap, abs(MaskBmpObj->SurfObj.lDelta),
-              MaskBmpObj->SurfObj.iBitmapFormat, BMF_TOPDOWN,
-              NULL);
-            if ( !hMask )
+         if(NewCursor->IconInfo.hbmColor
+               && COLORCURSORS_ALLOWED)
+         {
+            /* FIXME - Create a color pointer, create only one 32bit bitmap!
+                       Do not pass a mask bitmap to DrvSetPointerShape()!
+                       Create a XLATEOBJ that describes the colors of the bitmap.
+                       (16bit bitmaps are propably allowed) */
+            DPRINT1("SetCursor: Cursors with colors are not supported!\n");
+         }
+         else
+         {
+            MaskBmpObj = BITMAPOBJ_LockBitmap(NewCursor->IconInfo.hbmMask);
+            if(MaskBmpObj)
             {
-              BITMAPOBJ_UnlockBitmap(MaskBmpObj);
-              BITMAPOBJ_UnlockBitmap(BitmapObj);
-              return (HCURSOR)0;
+               RECTL DestRect = {0, 0, MaskBmpObj->SurfObj.sizlBitmap.cx, MaskBmpObj->SurfObj.sizlBitmap.cy};
+               POINTL SourcePoint = {0, 0};
+
+               /*
+                * NOTE: For now we create the cursor in top-down bitmap,
+                * because VMware driver rejects it otherwise. This should
+                * be fixed later.
+                */
+               hMask = EngCreateBitmap(
+                          MaskBmpObj->SurfObj.sizlBitmap, abs(MaskBmpObj->SurfObj.lDelta),
+                          MaskBmpObj->SurfObj.iBitmapFormat, BMF_TOPDOWN,
+                          NULL);
+               if ( !hMask )
+               {
+                  BITMAPOBJ_UnlockBitmap(MaskBmpObj);
+                  BITMAPOBJ_UnlockBitmap(BitmapObj);
+                  return (HCURSOR)0;
+               }
+               soMask = EngLockSurface((HSURF)hMask);
+               EngCopyBits(soMask, &MaskBmpObj->SurfObj, NULL, NULL,
+                           &DestRect, &SourcePoint);
+               BITMAPOBJ_UnlockBitmap(MaskBmpObj);
             }
-            soMask = EngLockSurface((HSURF)hMask);
-            EngCopyBits(soMask, &MaskBmpObj->SurfObj, NULL, NULL,
-              &DestRect, &SourcePoint);
-            BITMAPOBJ_UnlockBitmap(MaskBmpObj);
-          }
-        }
+         }
       }
       CurInfo->ShowingCursor = CURSOR_SHOWING;
       CurInfo->CurrentCursorObject = NewCursor;
-    }
-    else
-    {
+   }
+   else
+   {
       CurInfo->ShowingCursor = 0;
       CurInfo->CurrentCursorObject = NULL;
-    }
+   }
 
-    if (GDIDEVFUNCS(SurfObj).SetPointerShape)
-    {
+   if (GDIDEVFUNCS(SurfObj).SetPointerShape)
+   {
       GDIDEV(SurfObj)->Pointer.Status =
          GDIDEVFUNCS(SurfObj).SetPointerShape(
-                                                        SurfObj, soMask, soColor, XlateObj,
-                                                        NewCursor->IconInfo.xHotspot,
-                                                        NewCursor->IconInfo.yHotspot,
-                                                        GDIDEV(SurfObj)->Pointer.Pos.x,
-                                                        GDIDEV(SurfObj)->Pointer.Pos.y,
-                                                        &(GDIDEV(SurfObj)->Pointer.Exclude),
-                                                        SPS_CHANGE);
+            SurfObj, soMask, soColor, XlateObj,
+            NewCursor->IconInfo.xHotspot,
+            NewCursor->IconInfo.yHotspot,
+            GDIDEV(SurfObj)->Pointer.Pos.x,
+            GDIDEV(SurfObj)->Pointer.Pos.y,
+            &(GDIDEV(SurfObj)->Pointer.Exclude),
+            SPS_CHANGE);
       DPRINT("SetCursor: DrvSetPointerShape() returned %x\n",
-         GDIDEV(SurfObj)->Pointer.Status);
-    }
-    else
-    {
+             GDIDEV(SurfObj)->Pointer.Status);
+   }
+   else
+   {
       GDIDEV(SurfObj)->Pointer.Status = SPS_DECLINE;
-    }
+   }
 
-    if(GDIDEV(SurfObj)->Pointer.Status == SPS_DECLINE)
-    {
+   if(GDIDEV(SurfObj)->Pointer.Status == SPS_DECLINE)
+   {
       GDIDEV(SurfObj)->Pointer.Status = EngSetPointerShape(
-                         SurfObj, soMask, soColor, XlateObj,
-                         NewCursor->IconInfo.xHotspot,
-                         NewCursor->IconInfo.yHotspot,
-                         GDIDEV(SurfObj)->Pointer.Pos.x,
-                         GDIDEV(SurfObj)->Pointer.Pos.y,
-                         &(GDIDEV(SurfObj)->Pointer.Exclude),
-                         SPS_CHANGE);
+                                           SurfObj, soMask, soColor, XlateObj,
+                                           NewCursor->IconInfo.xHotspot,
+                                           NewCursor->IconInfo.yHotspot,
+                                           GDIDEV(SurfObj)->Pointer.Pos.x,
+                                           GDIDEV(SurfObj)->Pointer.Pos.y,
+                                           &(GDIDEV(SurfObj)->Pointer.Exclude),
+                                           SPS_CHANGE);
       GDIDEV(SurfObj)->Pointer.MovePointer = NULL;
-    }
-    else
-    {
+   }
+   else
+   {
       GDIDEV(SurfObj)->Pointer.MovePointer = GDIDEVFUNCS(SurfObj).MovePointer;
-    }
+   }
 
-    BITMAPOBJ_UnlockBitmap(BitmapObj);
-    if(hMask)
-    {
+   BITMAPOBJ_UnlockBitmap(BitmapObj);
+   if(hMask)
+   {
       EngUnlockSurface(soMask);
       EngDeleteSurface((HSURF)hMask);
-    }
-    if(hColor)
-    {
+   }
+   if(hColor)
+   {
       EngDeleteSurface((HSURF)hColor);
-    }
-    if(XlateObj)
-    {
+   }
+   if(XlateObj)
+   {
       EngDeleteXlate(XlateObj);
-    }
+   }
 
-    if(GDIDEV(SurfObj)->Pointer.Status == SPS_ERROR)
+   if(GDIDEV(SurfObj)->Pointer.Status == SPS_ERROR)
       DPRINT1("SetCursor: DrvSetPointerShape() returned SPS_ERROR\n");
 
-  return Ret;
+   return Ret;
 }
 
 BOOL FASTCALL
 IntSetupCurIconHandles(PWINSTATION_OBJECT WinStaObject)
 {
-  ExInitializePagedLookasideList(&ProcessLookasideList,
-                                NULL,
-                                NULL,
-                                0,
-                                sizeof(CURICON_PROCESS),
-                                0,
-                                128);
-  InitializeListHead(&CurIconList);
-
-  return TRUE;
+   ExInitializePagedLookasideList(&ProcessLookasideList,
+                                  NULL,
+                                  NULL,
+                                  0,
+                                  sizeof(CURICON_PROCESS),
+                                  0,
+                                  128);
+   InitializeListHead(&CurIconList);
+
+   return TRUE;
 }
 
 /*
@@ -335,234 +335,234 @@ IntSetupCurIconHandles(PWINSTATION_OBJECT WinStaObject)
 static BOOLEAN FASTCALL
 ReferenceCurIconByProcess(PCURICON_OBJECT Object)
 {
-  PW32PROCESS Win32Process;
-  PLIST_ENTRY Search;
-  PCURICON_PROCESS Current;
+   PW32PROCESS Win32Process;
+   PLIST_ENTRY Search;
+   PCURICON_PROCESS Current;
 
-  Win32Process = PsGetWin32Process();
+   Win32Process = PsGetWin32Process();
 
-  Search = Object->ProcessList.Flink;
-  while (Search != &Object->ProcessList)
-    {
+   Search = Object->ProcessList.Flink;
+   while (Search != &Object->ProcessList)
+   {
       Current = CONTAINING_RECORD(Search, CURICON_PROCESS, ListEntry);
       if (Current->Process == Win32Process)
-        {
-          /* Already registered for this process */
-          return TRUE;
-        }
+      {
+         /* Already registered for this process */
+         return TRUE;
+      }
       Search = Search->Flink;
-    }
+   }
 
-  /* Not registered yet */
-  Current = ExAllocateFromPagedLookasideList(&ProcessLookasideList);
-  if (NULL == Current)
-    {
+   /* Not registered yet */
+   Current = ExAllocateFromPagedLookasideList(&ProcessLookasideList);
+   if (NULL == Current)
+   {
       return FALSE;
-    }
-  InsertHeadList(&Object->ProcessList, &Current->ListEntry);
-  Current->Process = Win32Process;
+   }
+   InsertHeadList(&Object->ProcessList, &Current->ListEntry);
+   Current->Process = Win32Process;
 
-  return TRUE;
+   return TRUE;
 }
 
 PCURICON_OBJECT FASTCALL
 IntFindExistingCurIconObject(PWINSTATION_OBJECT WinStaObject, HMODULE hModule,
                              HRSRC hRsrc, LONG cx, LONG cy)
 {
-  PLIST_ENTRY CurrentEntry;
-  PCURICON_OBJECT Object;
-
-  CurrentEntry = CurIconList.Flink;
-  while (CurrentEntry != &CurIconList)
-  {
-    Object = CONTAINING_RECORD(CurrentEntry, CURICON_OBJECT, ListEntry);
-    CurrentEntry = CurrentEntry->Flink;
-
-//    if(NT_SUCCESS(ObmReferenceObjectByPointer(Object, otCursorIcon))) //<- huh????
-    ObmReferenceObject(  Object);
-    {
-      if((Object->hModule == hModule) && (Object->hRsrc == hRsrc))
+   PLIST_ENTRY CurrentEntry;
+   PCURICON_OBJECT Object;
+
+   CurrentEntry = CurIconList.Flink;
+   while (CurrentEntry != &CurIconList)
+   {
+      Object = CONTAINING_RECORD(CurrentEntry, CURICON_OBJECT, ListEntry);
+      CurrentEntry = CurrentEntry->Flink;
+
+      //    if(NT_SUCCESS(ObmReferenceObjectByPointer(Object, otCursorIcon))) //<- huh????
+      ObmReferenceObject(  Object);
       {
-        if(cx && ((cx != Object->Size.cx) || (cy != Object->Size.cy)))
-        {
-          ObmDereferenceObject(Object);
-          continue;
-        }
-        if (! ReferenceCurIconByProcess(Object))
-        {
-          return NULL;
-        }
-
-        return Object;
+         if((Object->hModule == hModule) && (Object->hRsrc == hRsrc))
+         {
+            if(cx && ((cx != Object->Size.cx) || (cy != Object->Size.cy)))
+            {
+               ObmDereferenceObject(Object);
+               continue;
+            }
+            if (! ReferenceCurIconByProcess(Object))
+            {
+               return NULL;
+            }
+
+            return Object;
+         }
       }
-    }
-    ObmDereferenceObject(Object);
+      ObmDereferenceObject(Object);
 
-  }
+   }
 
-  return NULL;
+   return NULL;
 }
 
 PCURICON_OBJECT FASTCALL
 IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject)
 {
-  PCURICON_OBJECT Object;
-  HANDLE Handle;
+   PCURICON_OBJECT Object;
+   HANDLE Handle;
 
-  Object = ObmCreateObject(&gHandleTable, &Handle, otCursor, sizeof(CURICON_OBJECT));
+   Object = ObmCreateObject(&gHandleTable, &Handle, otCursor, sizeof(CURICON_OBJECT));
 
-  if(!Object)
-  {
-    SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-    return FALSE;
-  }
+   if(!Object)
+   {
+      SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+      return FALSE;
+   }
 
-  Object->Self = Handle;
-  InitializeListHead(&Object->ProcessList);
+   Object->Self = Handle;
+   InitializeListHead(&Object->ProcessList);
 
-  if (! ReferenceCurIconByProcess(Object))
-  {
-    DPRINT1("Failed to add process\n");
-    ObmDeleteObject(Handle, otCursor);
-    ObmDereferenceObject(Object);
-    return NULL;
-  }
+   if (! ReferenceCurIconByProcess(Object))
+   {
+      DPRINT1("Failed to add process\n");
+      ObmDeleteObject(Handle, otCursor);
+      ObmDereferenceObject(Object);
+      return NULL;
+   }
 
-  InsertHeadList(&CurIconList, &Object->ListEntry);
+   InsertHeadList(&CurIconList, &Object->ListEntry);
 
-  ObmDereferenceObject(Object);
+   ObmDereferenceObject(Object);
 
-  return Object;
+   return Object;
 }
 
 BOOLEAN FASTCALL
 IntDestroyCurIconObject(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT Object, BOOL ProcessCleanup)
 {
-  PSYSTEM_CURSORINFO CurInfo;
-  HBITMAP bmpMask, bmpColor;
-  BOOLEAN Ret;
-  PLIST_ENTRY Search;
-  PCURICON_PROCESS Current = NULL;
-  PW32PROCESS W32Process = PsGetWin32Process();
-
-  /* Private objects can only be destroyed by their own process */
-  if (NULL == Object->hModule)
-    {
-    ASSERT(Object->ProcessList.Flink->Flink == &Object->ProcessList);
-    Current = CONTAINING_RECORD(Object->ProcessList.Flink, CURICON_PROCESS, ListEntry);
-    if (Current->Process != W32Process)
+   PSYSTEM_CURSORINFO CurInfo;
+   HBITMAP bmpMask, bmpColor;
+   BOOLEAN Ret;
+   PLIST_ENTRY Search;
+   PCURICON_PROCESS Current = NULL;
+   PW32PROCESS W32Process = PsGetWin32Process();
+
+   /* Private objects can only be destroyed by their own process */
+   if (NULL == Object->hModule)
+   {
+      ASSERT(Object->ProcessList.Flink->Flink == &Object->ProcessList);
+      Current = CONTAINING_RECORD(Object->ProcessList.Flink, CURICON_PROCESS, ListEntry);
+      if (Current->Process != W32Process)
       {
-        DPRINT1("Trying to destroy private icon/cursor of another process\n");
-        return FALSE;
+         DPRINT1("Trying to destroy private icon/cursor of another process\n");
+         return FALSE;
       }
-    }
-  else if (! ProcessCleanup)
-    {
+   }
+   else if (! ProcessCleanup)
+   {
       DPRINT("Trying to destroy shared icon/cursor\n");
       return FALSE;
-    }
-
-  /* Now find this process in the list of processes referencing this object and
-     remove it from that list */
-  Search = Object->ProcessList.Flink;
-  while (Search != &Object->ProcessList)
-    {
-    Current = CONTAINING_RECORD(Search, CURICON_PROCESS, ListEntry);
-    if (Current->Process == W32Process)
+   }
+
+   /* Now find this process in the list of processes referencing this object and
+      remove it from that list */
+   Search = Object->ProcessList.Flink;
+   while (Search != &Object->ProcessList)
+   {
+      Current = CONTAINING_RECORD(Search, CURICON_PROCESS, ListEntry);
+      if (Current->Process == W32Process)
       {
-      break;
+         break;
       }
-    Search = Search->Flink;
-    }
-  ASSERT(Search != &Object->ProcessList);
-  RemoveEntryList(Search);
-  ExFreeToPagedLookasideList(&ProcessLookasideList, Current);
-
-  /* If there are still processes referencing this object we can't destroy it yet */
-  if (! IsListEmpty(&Object->ProcessList))
-    {
-    return TRUE;
-    }
-
-
-  if (! ProcessCleanup)
-    {
-    RemoveEntryList(&Object->ListEntry);
-    }
-
-  CurInfo = IntGetSysCursorInfo(WinStaObject);
-
-  if (CurInfo->CurrentCursorObject == Object)
-  {
-    /* Hide the cursor if we're destroying the current cursor */
-    IntSetCursor(WinStaObject, NULL, TRUE);
-  }
-
-  bmpMask = Object->IconInfo.hbmMask;
-  bmpColor = Object->IconInfo.hbmColor;
-
-  Ret = ObmDeleteObject(Object->Self, otCursor);
-
-  /* delete bitmaps */
-  if(bmpMask)
-  {
-    GDIOBJ_SetOwnership(bmpMask, PsGetCurrentProcess());
-    NtGdiDeleteObject(bmpMask);
-  }
-  if(bmpColor)
-  {
-    GDIOBJ_SetOwnership(bmpColor, PsGetCurrentProcess());
-    NtGdiDeleteObject(bmpColor);
-  }
-
-  return Ret;
+      Search = Search->Flink;
+   }
+   ASSERT(Search != &Object->ProcessList);
+   RemoveEntryList(Search);
+   ExFreeToPagedLookasideList(&ProcessLookasideList, Current);
+
+   /* If there are still processes referencing this object we can't destroy it yet */
+   if (! IsListEmpty(&Object->ProcessList))
+   {
+      return TRUE;
+   }
+
+
+   if (! ProcessCleanup)
+   {
+      RemoveEntryList(&Object->ListEntry);
+   }
+
+   CurInfo = IntGetSysCursorInfo(WinStaObject);
+
+   if (CurInfo->CurrentCursorObject == Object)
+   {
+      /* Hide the cursor if we're destroying the current cursor */
+      IntSetCursor(WinStaObject, NULL, TRUE);
+   }
+
+   bmpMask = Object->IconInfo.hbmMask;
+   bmpColor = Object->IconInfo.hbmColor;
+
+   Ret = ObmDeleteObject(Object->Self, otCursor);
+
+   /* delete bitmaps */
+   if(bmpMask)
+   {
+      GDIOBJ_SetOwnership(bmpMask, PsGetCurrentProcess());
+      NtGdiDeleteObject(bmpMask);
+   }
+   if(bmpColor)
+   {
+      GDIOBJ_SetOwnership(bmpColor, PsGetCurrentProcess());
+      NtGdiDeleteObject(bmpColor);
+   }
+
+   return Ret;
 }
 
 VOID FASTCALL
 IntCleanupCurIcons(struct _EPROCESS *Process, PW32PROCESS Win32Process)
 {
-  PWINSTATION_OBJECT WinStaObject;
-  PLIST_ENTRY CurrentEntry;
-  PCURICON_OBJECT Object;
-  PLIST_ENTRY ProcessEntry;
-  PCURICON_PROCESS ProcessData;
-
-  WinStaObject = IntGetWinStaObj();
-  if(WinStaObject == NULL)
-  {
-    return;
-  }
+   PWINSTATION_OBJECT WinStaObject;
+   PLIST_ENTRY CurrentEntry;
+   PCURICON_OBJECT Object;
+   PLIST_ENTRY ProcessEntry;
+   PCURICON_PROCESS ProcessData;
+
+   WinStaObject = IntGetWinStaObj();
+   if(WinStaObject == NULL)
+   {
+      return;
+   }
 
-  CurrentEntry = CurIconList.Flink;
-  while (CurrentEntry != &CurIconList)
-  {
-    Object = CONTAINING_RECORD(CurrentEntry, CURICON_OBJECT, ListEntry);
-    CurrentEntry = CurrentEntry->Flink;
+   CurrentEntry = CurIconList.Flink;
+   while (CurrentEntry != &CurIconList)
+   {
+      Object = CONTAINING_RECORD(CurrentEntry, CURICON_OBJECT, ListEntry);
+      CurrentEntry = CurrentEntry->Flink;
 
 
       ObmReferenceObject(Object);
-//    if(NT_SUCCESS(ObmReferenceObjectByPointer(Object, otCursorIcon)))
+      //    if(NT_SUCCESS(ObmReferenceObjectByPointer(Object, otCursorIcon)))
       {
-      ProcessEntry = Object->ProcessList.Flink;
-      while (ProcessEntry != &Object->ProcessList)
-      {
-        ProcessData = CONTAINING_RECORD(ProcessEntry, CURICON_PROCESS, ListEntry);
-        if (Win32Process == ProcessData->Process)
-        {
-          RemoveEntryList(&Object->ListEntry);
-          IntDestroyCurIconObject(WinStaObject, Object, TRUE);
-          break;
-        }
-        ProcessEntry = ProcessEntry->Flink;
-      }
+         ProcessEntry = Object->ProcessList.Flink;
+         while (ProcessEntry != &Object->ProcessList)
+         {
+            ProcessData = CONTAINING_RECORD(ProcessEntry, CURICON_PROCESS, ListEntry);
+            if (Win32Process == ProcessData->Process)
+            {
+               RemoveEntryList(&Object->ListEntry);
+               IntDestroyCurIconObject(WinStaObject, Object, TRUE);
+               break;
+            }
+            ProcessEntry = ProcessEntry->Flink;
+         }
 
-      ObmDereferenceObject(Object);
-    }
+         ObmDereferenceObject(Object);
+      }
 
 
-  }
+   }
 
-  ObDereferenceObject(WinStaObject);
+   ObDereferenceObject(WinStaObject);
 }
 
 /*
@@ -572,76 +572,76 @@ HANDLE
 STDCALL
 NtUserCreateCursorIconHandle(PICONINFO IconInfo, BOOL Indirect)
 {
-  PCURICON_OBJECT CurIconObject;
-  PWINSTATION_OBJECT WinStaObject;
-  PBITMAPOBJ bmp;
-  NTSTATUS Status;
-  HANDLE Ret;
-  DECLARE_RETURN(HANDLE);
-
-  DPRINT("Enter NtUserCreateCursorIconHandle\n");
-  UserEnterExclusive();
-
-  WinStaObject = IntGetWinStaObj();
-  if(WinStaObject == NULL)
-  {
-    RETURN( (HANDLE)0);
-  }
-
-  CurIconObject = IntCreateCurIconHandle(WinStaObject);
-  if(CurIconObject)
-  {
-    Ret = CurIconObject->Self;
-
-    if(IconInfo)
-    {
-      Status = MmCopyFromCaller(&CurIconObject->IconInfo, IconInfo, sizeof(ICONINFO));
-      if(NT_SUCCESS(Status))
-      {
-        if(Indirect)
-        {
-          CurIconObject->IconInfo.hbmMask = BITMAPOBJ_CopyBitmap(CurIconObject->IconInfo.hbmMask);
-          CurIconObject->IconInfo.hbmColor = BITMAPOBJ_CopyBitmap(CurIconObject->IconInfo.hbmColor);
-        }
-        if(CurIconObject->IconInfo.hbmColor &&
-          (bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmColor)))
-        {
-          CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
-          CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy;
-          BITMAPOBJ_UnlockBitmap(bmp);
-          GDIOBJ_SetOwnership(CurIconObject->IconInfo.hbmColor, NULL);
-        }
-        if(CurIconObject->IconInfo.hbmMask &&
-          (bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmMask)))
-        {
-          if (CurIconObject->IconInfo.hbmColor == NULL)
-          {
-            CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
-            CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy / 2;
-          }
-          BITMAPOBJ_UnlockBitmap(bmp);
-          GDIOBJ_SetOwnership(CurIconObject->IconInfo.hbmMask, NULL);
-        }
-      }
-      else
+   PCURICON_OBJECT CurIconObject;
+   PWINSTATION_OBJECT WinStaObject;
+   PBITMAPOBJ bmp;
+   NTSTATUS Status;
+   HANDLE Ret;
+   DECLARE_RETURN(HANDLE);
+
+   DPRINT("Enter NtUserCreateCursorIconHandle\n");
+   UserEnterExclusive();
+
+   WinStaObject = IntGetWinStaObj();
+   if(WinStaObject == NULL)
+   {
+      RETURN( (HANDLE)0);
+   }
+
+   CurIconObject = IntCreateCurIconHandle(WinStaObject);
+   if(CurIconObject)
+   {
+      Ret = CurIconObject->Self;
+
+      if(IconInfo)
       {
-        SetLastNtError(Status);
-        /* FIXME - Don't exit here */
+         Status = MmCopyFromCaller(&CurIconObject->IconInfo, IconInfo, sizeof(ICONINFO));
+         if(NT_SUCCESS(Status))
+         {
+            if(Indirect)
+            {
+               CurIconObject->IconInfo.hbmMask = BITMAPOBJ_CopyBitmap(CurIconObject->IconInfo.hbmMask);
+               CurIconObject->IconInfo.hbmColor = BITMAPOBJ_CopyBitmap(CurIconObject->IconInfo.hbmColor);
+            }
+            if(CurIconObject->IconInfo.hbmColor &&
+                  (bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmColor)))
+            {
+               CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
+               CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy;
+               BITMAPOBJ_UnlockBitmap(bmp);
+               GDIOBJ_SetOwnership(CurIconObject->IconInfo.hbmColor, NULL);
+            }
+            if(CurIconObject->IconInfo.hbmMask &&
+                  (bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmMask)))
+            {
+               if (CurIconObject->IconInfo.hbmColor == NULL)
+               {
+                  CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
+                  CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy / 2;
+               }
+               BITMAPOBJ_UnlockBitmap(bmp);
+               GDIOBJ_SetOwnership(CurIconObject->IconInfo.hbmMask, NULL);
+            }
+         }
+         else
+         {
+            SetLastNtError(Status);
+            /* FIXME - Don't exit here */
+         }
       }
-    }
 
-    ObDereferenceObject(WinStaObject);
-    RETURN( Ret);
-  }
+      ObDereferenceObject(WinStaObject);
+      RETURN( Ret);
+   }
+
+   SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+   ObDereferenceObject(WinStaObject);
+   RETURN( (HANDLE)0);
 
-  SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-  ObDereferenceObject(WinStaObject);
-  RETURN( (HANDLE)0);
-  
 CLEANUP:
-  DPRINT("Leave NtUserCreateCursorIconHandle, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserCreateCursorIconHandle, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 /*
@@ -650,61 +650,61 @@ CLEANUP:
 BOOL
 STDCALL
 NtUserGetCursorIconInfo(
-  HANDLE Handle,
-  PICONINFO IconInfo)
+   HANDLE Handle,
+   PICONINFO IconInfo)
 {
-  ICONINFO ii;
-  PCURICON_OBJECT CurIconObject;
-  PWINSTATION_OBJECT WinStaObject;
-  NTSTATUS Status;
-  BOOL Ret = FALSE;
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserGetCursorIconInfo\n");
-  UserEnterExclusive();
-
-  WinStaObject = IntGetWinStaObj();
-  if(WinStaObject == NULL)
-  {
-    RETURN( FALSE);
-  }
-
-  CurIconObject = IntGetCurIconObject(Handle);
-  if(CurIconObject)
-  {
-    if(IconInfo)
-    {
-      RtlCopyMemory(&ii, &CurIconObject->IconInfo, sizeof(ICONINFO));
-
-      /* Copy bitmaps */
-      ii.hbmMask = BITMAPOBJ_CopyBitmap(ii.hbmMask);
-      ii.hbmColor = BITMAPOBJ_CopyBitmap(ii.hbmColor);
+   ICONINFO ii;
+   PCURICON_OBJECT CurIconObject;
+   PWINSTATION_OBJECT WinStaObject;
+   NTSTATUS Status;
+   BOOL Ret = FALSE;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserGetCursorIconInfo\n");
+   UserEnterExclusive();
+
+   WinStaObject = IntGetWinStaObj();
+   if(WinStaObject == NULL)
+   {
+      RETURN( FALSE);
+   }
 
-      /* Copy fields */
-      Status = MmCopyToCaller(IconInfo, &ii, sizeof(ICONINFO));
-      if(NT_SUCCESS(Status))
-        Ret = TRUE;
+   CurIconObject = IntGetCurIconObject(Handle);
+   if(CurIconObject)
+   {
+      if(IconInfo)
+      {
+         RtlCopyMemory(&ii, &CurIconObject->IconInfo, sizeof(ICONINFO));
+
+         /* Copy bitmaps */
+         ii.hbmMask = BITMAPOBJ_CopyBitmap(ii.hbmMask);
+         ii.hbmColor = BITMAPOBJ_CopyBitmap(ii.hbmColor);
+
+         /* Copy fields */
+         Status = MmCopyToCaller(IconInfo, &ii, sizeof(ICONINFO));
+         if(NT_SUCCESS(Status))
+            Ret = TRUE;
+         else
+            SetLastNtError(Status);
+      }
       else
-        SetLastNtError(Status);
-    }
-    else
-    {
-      SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    }
+      {
+         SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      }
 
-    IntReleaseCurIconObject(CurIconObject);
-    ObDereferenceObject(WinStaObject);
-    RETURN( Ret);
-  }
+      IntReleaseCurIconObject(CurIconObject);
+      ObDereferenceObject(WinStaObject);
+      RETURN( Ret);
+   }
+
+   SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
+   ObDereferenceObject(WinStaObject);
+   RETURN( FALSE);
 
-  SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
-  ObDereferenceObject(WinStaObject);
-  RETURN( FALSE);
-  
 CLEANUP:
-  DPRINT("Leave NtUserGetCursorIconInfo, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetCursorIconInfo, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -714,66 +714,66 @@ CLEANUP:
 BOOL
 STDCALL
 NtUserGetCursorIconSize(
-  HANDLE Handle,
-  BOOL *fIcon,
-  SIZE *Size)
+   HANDLE Handle,
+   BOOL *fIcon,
+   SIZE *Size)
 {
-  PCURICON_OBJECT CurIconObject;
-  PBITMAPOBJ bmp;
-  PWINSTATION_OBJECT WinStaObject;
-  NTSTATUS Status;
-  BOOL Ret = FALSE;
-  SIZE SafeSize;
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserGetCursorIconSize\n");
-  UserEnterExclusive();
-
-  WinStaObject = IntGetWinStaObj();
-  if(WinStaObject == NULL)
-  {
-    RETURN( FALSE);
-  }
-
-  CurIconObject = IntGetCurIconObject(Handle);
-  if(CurIconObject)
-  {
-    /* Copy fields */
-    Status = MmCopyToCaller(fIcon, &CurIconObject->IconInfo.fIcon, sizeof(BOOL));
-    if(!NT_SUCCESS(Status))
-    {
-      SetLastNtError(Status);
-      goto done;
-    }
+   PCURICON_OBJECT CurIconObject;
+   PBITMAPOBJ bmp;
+   PWINSTATION_OBJECT WinStaObject;
+   NTSTATUS Status;
+   BOOL Ret = FALSE;
+   SIZE SafeSize;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserGetCursorIconSize\n");
+   UserEnterExclusive();
+
+   WinStaObject = IntGetWinStaObj();
+   if(WinStaObject == NULL)
+   {
+      RETURN( FALSE);
+   }
+
+   CurIconObject = IntGetCurIconObject(Handle);
+   if(CurIconObject)
+   {
+      /* Copy fields */
+      Status = MmCopyToCaller(fIcon, &CurIconObject->IconInfo.fIcon, sizeof(BOOL));
+      if(!NT_SUCCESS(Status))
+      {
+         SetLastNtError(Status);
+         goto done;
+      }
 
-    bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmColor);
-    if(!bmp)
-      goto done;
+      bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmColor);
+      if(!bmp)
+         goto done;
 
-    SafeSize.cx = bmp->SurfObj.sizlBitmap.cx;
-    SafeSize.cy = bmp->SurfObj.sizlBitmap.cy;
-    Status = MmCopyToCaller(Size, &SafeSize, sizeof(SIZE));
-    if(NT_SUCCESS(Status))
-      Ret = TRUE;
-    else
-      SetLastNtError(Status);
+      SafeSize.cx = bmp->SurfObj.sizlBitmap.cx;
+      SafeSize.cy = bmp->SurfObj.sizlBitmap.cy;
+      Status = MmCopyToCaller(Size, &SafeSize, sizeof(SIZE));
+      if(NT_SUCCESS(Status))
+         Ret = TRUE;
+      else
+         SetLastNtError(Status);
 
-    BITMAPOBJ_UnlockBitmap(bmp);
+      BITMAPOBJ_UnlockBitmap(bmp);
+
+done:
+      IntReleaseCurIconObject(CurIconObject);
+      ObDereferenceObject(WinStaObject);
+      RETURN( Ret);
+   }
 
-    done:
-    IntReleaseCurIconObject(CurIconObject);
-    ObDereferenceObject(WinStaObject);
-    RETURN( Ret);
-  }
+   SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
+   ObDereferenceObject(WinStaObject);
+   RETURN( FALSE);
 
-  SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
-  ObDereferenceObject(WinStaObject);
-  RETURN( FALSE);
-  
 CLEANUP:
-  DPRINT("Leave NtUserGetCursorIconSize, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetCursorIconSize, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -783,14 +783,14 @@ CLEANUP:
 DWORD
 STDCALL
 NtUserGetCursorFrameInfo(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
@@ -800,70 +800,71 @@ NtUserGetCursorFrameInfo(
 BOOL
 STDCALL
 NtUserGetCursorInfo(
-  PCURSORINFO pci)
+   PCURSORINFO pci)
 {
-  CURSORINFO SafeCi;
-  PSYSTEM_CURSORINFO CurInfo;
-  PWINSTATION_OBJECT WinStaObject;
-  NTSTATUS Status;
-  PCURICON_OBJECT CursorObject;
-  DECLARE_RETURN(BOOL);
+   CURSORINFO SafeCi;
+   PSYSTEM_CURSORINFO CurInfo;
+   PWINSTATION_OBJECT WinStaObject;
+   NTSTATUS Status;
+   PCURICON_OBJECT CursorObject;
+   DECLARE_RETURN(BOOL);
 
-  DPRINT("Enter NtUserGetCursorInfo\n");
-  UserEnterExclusive();
+   DPRINT("Enter NtUserGetCursorInfo\n");
+   UserEnterExclusive();
 
 #if 1
-  HDC hDC;
 
-  /* FIXME - get the screen dc from the window station or desktop */
-  if (!(hDC = IntGetScreenDC()))
-  {
-    RETURN( FALSE);
-  }
+   HDC hDC;
+
+   /* FIXME - get the screen dc from the window station or desktop */
+   if (!(hDC = IntGetScreenDC()))
+   {
+      RETURN( FALSE);
+   }
 #endif
 
-  Status = MmCopyFromCaller(&SafeCi.cbSize, pci, sizeof(DWORD));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    RETURN( FALSE);
-  }
-
-  if(SafeCi.cbSize != sizeof(CURSORINFO))
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    RETURN( FALSE);
-  }
-
-  WinStaObject = IntGetWinStaObj();
-  if(WinStaObject == NULL)
-  {
-    RETURN( FALSE);
-  }
-
-  CurInfo = IntGetSysCursorInfo(WinStaObject);
-  CursorObject = (PCURICON_OBJECT)CurInfo->CurrentCursorObject;
-
-  SafeCi.flags = ((CurInfo->ShowingCursor && CursorObject) ? CURSOR_SHOWING : 0);
-  SafeCi.hCursor = (CursorObject ? (HCURSOR)CursorObject->Self : (HCURSOR)0);
-
-  IntGetCursorLocation(WinStaObject, &SafeCi.ptScreenPos);
-
-  Status = MmCopyToCaller(pci, &SafeCi, sizeof(CURSORINFO));
-  if(!NT_SUCCESS(Status))
-  {
-    ObDereferenceObject(WinStaObject);
-    SetLastNtError(Status);
-    RETURN( FALSE);
-  }
-
-  ObDereferenceObject(WinStaObject);
-  RETURN( TRUE);
-  
+   Status = MmCopyFromCaller(&SafeCi.cbSize, pci, sizeof(DWORD));
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      RETURN( FALSE);
+   }
+
+   if(SafeCi.cbSize != sizeof(CURSORINFO))
+   {
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      RETURN( FALSE);
+   }
+
+   WinStaObject = IntGetWinStaObj();
+   if(WinStaObject == NULL)
+   {
+      RETURN( FALSE);
+   }
+
+   CurInfo = IntGetSysCursorInfo(WinStaObject);
+   CursorObject = (PCURICON_OBJECT)CurInfo->CurrentCursorObject;
+
+   SafeCi.flags = ((CurInfo->ShowingCursor && CursorObject) ? CURSOR_SHOWING : 0);
+   SafeCi.hCursor = (CursorObject ? (HCURSOR)CursorObject->Self : (HCURSOR)0);
+
+   IntGetCursorLocation(WinStaObject, &SafeCi.ptScreenPos);
+
+   Status = MmCopyToCaller(pci, &SafeCi, sizeof(CURSORINFO));
+   if(!NT_SUCCESS(Status))
+   {
+      ObDereferenceObject(WinStaObject);
+      SetLastNtError(Status);
+      RETURN( FALSE);
+   }
+
+   ObDereferenceObject(WinStaObject);
+   RETURN( TRUE);
+
 CLEANUP:
-  DPRINT("Leave NtUserGetCursorInfo, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetCursorInfo, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -873,71 +874,71 @@ CLEANUP:
 BOOL
 STDCALL
 NtUserClipCursor(
-  RECT *UnsafeRect)
+   RECT *UnsafeRect)
 {
-  /* FIXME - check if process has WINSTA_WRITEATTRIBUTES */
-
-  PWINSTATION_OBJECT WinStaObject;
-  PSYSTEM_CURSORINFO CurInfo;
-  RECT Rect;
-  PWINDOW_OBJECT DesktopWindow = NULL;
-  POINT MousePos;
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserClipCursor\n");
-  UserEnterExclusive();
-
-  WinStaObject = IntGetWinStaObj();
-  if (WinStaObject == NULL)
-  {
-    RETURN( FALSE);
-  }
-
-  if (NULL != UnsafeRect && ! NT_SUCCESS(MmCopyFromCaller(&Rect, UnsafeRect, sizeof(RECT))))
-  {
-    ObDereferenceObject(WinStaObject);
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    RETURN( FALSE);
-  }
-
-  CurInfo = IntGetSysCursorInfo(WinStaObject);
-  IntGetCursorLocation(WinStaObject, &MousePos);
-
-  if(WinStaObject->ActiveDesktop)
-    DesktopWindow = IntGetWindowObject(WinStaObject->ActiveDesktop->DesktopWindow);
-
-  if((Rect.right > Rect.left) && (Rect.bottom > Rect.top)
-     && DesktopWindow && UnsafeRect != NULL)
-  {
-    MOUSEINPUT mi;
-
-    CurInfo->CursorClipInfo.IsClipped = TRUE;
-    CurInfo->CursorClipInfo.Left = max(Rect.left, DesktopWindow->WindowRect.left);
-    CurInfo->CursorClipInfo.Top = max(Rect.top, DesktopWindow->WindowRect.top);
-    CurInfo->CursorClipInfo.Right = min(Rect.right - 1, DesktopWindow->WindowRect.right - 1);
-    CurInfo->CursorClipInfo.Bottom = min(Rect.bottom - 1, DesktopWindow->WindowRect.bottom - 1);
-    IntReleaseWindowObject(DesktopWindow);
-
-    mi.dx = MousePos.x;
-    mi.dy = MousePos.y;
-    mi.mouseData = 0;
-    mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
-    mi.time = 0;
-    mi.dwExtraInfo = 0;
-    IntMouseInput(&mi);
-
-    RETURN( TRUE);
-  }
-
-  CurInfo->CursorClipInfo.IsClipped = FALSE;
-  ObDereferenceObject(WinStaObject);
-
-  RETURN( TRUE);
-  
+   /* FIXME - check if process has WINSTA_WRITEATTRIBUTES */
+
+   PWINSTATION_OBJECT WinStaObject;
+   PSYSTEM_CURSORINFO CurInfo;
+   RECT Rect;
+   PWINDOW_OBJECT DesktopWindow = NULL;
+   POINT MousePos;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserClipCursor\n");
+   UserEnterExclusive();
+
+   WinStaObject = IntGetWinStaObj();
+   if (WinStaObject == NULL)
+   {
+      RETURN( FALSE);
+   }
+
+   if (NULL != UnsafeRect && ! NT_SUCCESS(MmCopyFromCaller(&Rect, UnsafeRect, sizeof(RECT))))
+   {
+      ObDereferenceObject(WinStaObject);
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      RETURN( FALSE);
+   }
+
+   CurInfo = IntGetSysCursorInfo(WinStaObject);
+   IntGetCursorLocation(WinStaObject, &MousePos);
+
+   if(WinStaObject->ActiveDesktop)
+      DesktopWindow = IntGetWindowObject(WinStaObject->ActiveDesktop->DesktopWindow);
+
+   if((Rect.right > Rect.left) && (Rect.bottom > Rect.top)
+         && DesktopWindow && UnsafeRect != NULL)
+   {
+      MOUSEINPUT mi;
+
+      CurInfo->CursorClipInfo.IsClipped = TRUE;
+      CurInfo->CursorClipInfo.Left = max(Rect.left, DesktopWindow->WindowRect.left);
+      CurInfo->CursorClipInfo.Top = max(Rect.top, DesktopWindow->WindowRect.top);
+      CurInfo->CursorClipInfo.Right = min(Rect.right - 1, DesktopWindow->WindowRect.right - 1);
+      CurInfo->CursorClipInfo.Bottom = min(Rect.bottom - 1, DesktopWindow->WindowRect.bottom - 1);
+      IntReleaseWindowObject(DesktopWindow);
+
+      mi.dx = MousePos.x;
+      mi.dy = MousePos.y;
+      mi.mouseData = 0;
+      mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
+      mi.time = 0;
+      mi.dwExtraInfo = 0;
+      IntMouseInput(&mi);
+
+      RETURN( TRUE);
+   }
+
+   CurInfo->CursorClipInfo.IsClipped = FALSE;
+   ObDereferenceObject(WinStaObject);
+
+   RETURN( TRUE);
+
 CLEANUP:
-  DPRINT("Leave NtUserClipCursor, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserClipCursor, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -947,51 +948,51 @@ CLEANUP:
 BOOL
 STDCALL
 NtUserDestroyCursorIcon(
-  HANDLE Handle,
-  DWORD Unknown)
+   HANDLE Handle,
+   DWORD Unknown)
 {
-  PWINSTATION_OBJECT WinStaObject;
-  PCURICON_OBJECT Object;
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserDestroyCursorIcon\n");
-  UserEnterExclusive();
-
-  WinStaObject = IntGetWinStaObj();
-  if(WinStaObject == NULL)
-  {
-    RETURN( FALSE);
-  }
-
-  if (!(Object = IntGetCurIconObject(Handle)))
-  {
-     ObDereferenceObject(WinStaObject);
-     RETURN(FALSE); 
-  }
-//  Status = ObmReferenceObjectByHandle(gHandleTable, Handle, otCursorIcon, (PVOID*)&Object);
-//  if(!NT_SUCCESS(Status))
-//  {
-//    ObDereferenceObject(WinStaObject);
-//    SetLastNtError(Status);
-//    RETURN( FALSE);
-//  }
-
-  if(IntDestroyCurIconObject(WinStaObject, Object, FALSE))
-  {
-    ObmDereferenceObject(Object);
-    ObDereferenceObject(WinStaObject);
-    RETURN( TRUE);
-  }
-
-  ObmDereferenceObject(Object);
-  ObDereferenceObject(WinStaObject);
-  SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
-  RETURN( FALSE);
-  
+   PWINSTATION_OBJECT WinStaObject;
+   PCURICON_OBJECT Object;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserDestroyCursorIcon\n");
+   UserEnterExclusive();
+
+   WinStaObject = IntGetWinStaObj();
+   if(WinStaObject == NULL)
+   {
+      RETURN( FALSE);
+   }
+
+   if (!(Object = IntGetCurIconObject(Handle)))
+   {
+      ObDereferenceObject(WinStaObject);
+      RETURN(FALSE);
+   }
+   //  Status = ObmReferenceObjectByHandle(gHandleTable, Handle, otCursorIcon, (PVOID*)&Object);
+   //  if(!NT_SUCCESS(Status))
+   //  {
+   //    ObDereferenceObject(WinStaObject);
+   //    SetLastNtError(Status);
+   //    RETURN( FALSE);
+   //  }
+
+   if(IntDestroyCurIconObject(WinStaObject, Object, FALSE))
+   {
+      ObmDereferenceObject(Object);
+      ObDereferenceObject(WinStaObject);
+      RETURN( TRUE);
+   }
+
+   ObmDereferenceObject(Object);
+   ObDereferenceObject(WinStaObject);
+   SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
+   RETURN( FALSE);
+
 CLEANUP:
-  DPRINT("Leave NtUserDestroyCursorIcon, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserDestroyCursorIcon, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -1001,43 +1002,43 @@ CLEANUP:
 HICON
 STDCALL
 NtUserFindExistingCursorIcon(
-  HMODULE hModule,
-  HRSRC hRsrc,
-  LONG cx,
-  LONG cy)
+   HMODULE hModule,
+   HRSRC hRsrc,
+   LONG cx,
+   LONG cy)
 {
-  PCURICON_OBJECT CurIconObject;
-  PWINSTATION_OBJECT WinStaObject;
-  HANDLE Ret = (HANDLE)0;
-  DECLARE_RETURN(HICON);
-
-  DPRINT("Enter NtUserFindExistingCursorIcon\n");
-  UserEnterExclusive();
-
-  WinStaObject = IntGetWinStaObj();
-  if(WinStaObject == NULL)
-  {
-    RETURN( Ret);
-  }
-
-  CurIconObject = IntFindExistingCurIconObject(WinStaObject, hModule, hRsrc, cx, cy);
-  if(CurIconObject)
-  {
-    Ret = CurIconObject->Self;
-
-    IntReleaseCurIconObject(CurIconObject);
-    ObDereferenceObject(WinStaObject);
-    RETURN( Ret);
-  }
-
-  SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
-  ObDereferenceObject(WinStaObject);
-  RETURN( (HANDLE)0);
-  
+   PCURICON_OBJECT CurIconObject;
+   PWINSTATION_OBJECT WinStaObject;
+   HANDLE Ret = (HANDLE)0;
+   DECLARE_RETURN(HICON);
+
+   DPRINT("Enter NtUserFindExistingCursorIcon\n");
+   UserEnterExclusive();
+
+   WinStaObject = IntGetWinStaObj();
+   if(WinStaObject == NULL)
+   {
+      RETURN( Ret);
+   }
+
+   CurIconObject = IntFindExistingCurIconObject(WinStaObject, hModule, hRsrc, cx, cy);
+   if(CurIconObject)
+   {
+      Ret = CurIconObject->Self;
+
+      IntReleaseCurIconObject(CurIconObject);
+      ObDereferenceObject(WinStaObject);
+      RETURN( Ret);
+   }
+
+   SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
+   ObDereferenceObject(WinStaObject);
+   RETURN( (HANDLE)0);
+
 CLEANUP:
-  DPRINT("Leave NtUserFindExistingCursorIcon, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserFindExistingCursorIcon, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -1047,59 +1048,59 @@ CLEANUP:
 BOOL
 STDCALL
 NtUserGetClipCursor(
-  RECT *lpRect)
+   RECT *lpRect)
 {
-  /* FIXME - check if process has WINSTA_READATTRIBUTES */
-  PSYSTEM_CURSORINFO CurInfo;
-  PWINSTATION_OBJECT WinStaObject;
-  RECT Rect;
-  NTSTATUS Status;
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserGetClipCursor\n");
-  UserEnterExclusive();
-
-  if(!lpRect)
-    RETURN( FALSE);
-
-  WinStaObject = IntGetWinStaObj();
-  if (WinStaObject == NULL)
-  {
-    RETURN( FALSE);
-  }
-
-  CurInfo = IntGetSysCursorInfo(WinStaObject);
-  if(CurInfo->CursorClipInfo.IsClipped)
-  {
-    Rect.left = CurInfo->CursorClipInfo.Left;
-    Rect.top = CurInfo->CursorClipInfo.Top;
-    Rect.right = CurInfo->CursorClipInfo.Right;
-    Rect.bottom = CurInfo->CursorClipInfo.Bottom;
-  }
-  else
-  {
-    Rect.left = 0;
-    Rect.top = 0;
-    Rect.right = UserGetSystemMetrics(SM_CXSCREEN);
-    Rect.bottom = UserGetSystemMetrics(SM_CYSCREEN);
-  }
-
-  Status = MmCopyToCaller((PRECT)lpRect, &Rect, sizeof(RECT));
-  if(!NT_SUCCESS(Status))
-  {
-    ObDereferenceObject(WinStaObject);
-    SetLastNtError(Status);
-    RETURN( FALSE);
-  }
-
-  ObDereferenceObject(WinStaObject);
-
-  RETURN( TRUE);
-  
+   /* FIXME - check if process has WINSTA_READATTRIBUTES */
+   PSYSTEM_CURSORINFO CurInfo;
+   PWINSTATION_OBJECT WinStaObject;
+   RECT Rect;
+   NTSTATUS Status;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserGetClipCursor\n");
+   UserEnterExclusive();
+
+   if(!lpRect)
+      RETURN( FALSE);
+
+   WinStaObject = IntGetWinStaObj();
+   if (WinStaObject == NULL)
+   {
+      RETURN( FALSE);
+   }
+
+   CurInfo = IntGetSysCursorInfo(WinStaObject);
+   if(CurInfo->CursorClipInfo.IsClipped)
+   {
+      Rect.left = CurInfo->CursorClipInfo.Left;
+      Rect.top = CurInfo->CursorClipInfo.Top;
+      Rect.right = CurInfo->CursorClipInfo.Right;
+      Rect.bottom = CurInfo->CursorClipInfo.Bottom;
+   }
+   else
+   {
+      Rect.left = 0;
+      Rect.top = 0;
+      Rect.right = UserGetSystemMetrics(SM_CXSCREEN);
+      Rect.bottom = UserGetSystemMetrics(SM_CYSCREEN);
+   }
+
+   Status = MmCopyToCaller((PRECT)lpRect, &Rect, sizeof(RECT));
+   if(!NT_SUCCESS(Status))
+   {
+      ObDereferenceObject(WinStaObject);
+      SetLastNtError(Status);
+      RETURN( FALSE);
+   }
+
+   ObDereferenceObject(WinStaObject);
+
+   RETURN( TRUE);
+
 CLEANUP:
-  DPRINT("Leave NtUserGetClipCursor, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetClipCursor, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -1109,38 +1110,38 @@ CLEANUP:
 HCURSOR
 STDCALL
 NtUserSetCursor(
-  HCURSOR hCursor)
+   HCURSOR hCursor)
 {
-  PCURICON_OBJECT CurIconObject;
-  HICON OldCursor = (HCURSOR)0;
-  PWINSTATION_OBJECT WinStaObject;
-  DECLARE_RETURN(HCURSOR);
-
-  DPRINT("Enter NtUserSetCursor\n");
-  UserEnterExclusive();
-
-  WinStaObject = IntGetWinStaObj();
-  if(WinStaObject == NULL)
-  {
-    RETURN( (HCURSOR)0);
-  }
-
-  CurIconObject = IntGetCurIconObject(hCursor);
-  if(CurIconObject)
-  {
-    OldCursor = IntSetCursor(WinStaObject, CurIconObject, FALSE);
-    IntReleaseCurIconObject(CurIconObject);
-  }
-  else
-    SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
-
-  ObDereferenceObject(WinStaObject);
-  RETURN( OldCursor);
-  
+   PCURICON_OBJECT CurIconObject;
+   HICON OldCursor = (HCURSOR)0;
+   PWINSTATION_OBJECT WinStaObject;
+   DECLARE_RETURN(HCURSOR);
+
+   DPRINT("Enter NtUserSetCursor\n");
+   UserEnterExclusive();
+
+   WinStaObject = IntGetWinStaObj();
+   if(WinStaObject == NULL)
+   {
+      RETURN( (HCURSOR)0);
+   }
+
+   CurIconObject = IntGetCurIconObject(hCursor);
+   if(CurIconObject)
+   {
+      OldCursor = IntSetCursor(WinStaObject, CurIconObject, FALSE);
+      IntReleaseCurIconObject(CurIconObject);
+   }
+   else
+      SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
+
+   ObDereferenceObject(WinStaObject);
+   RETURN( OldCursor);
+
 CLEANUP:
-  DPRINT("Leave NtUserSetCursor, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserSetCursor, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -1150,73 +1151,73 @@ CLEANUP:
 BOOL
 STDCALL
 NtUserSetCursorIconContents(
-  HANDLE Handle,
-  PICONINFO IconInfo)
+   HANDLE Handle,
+   PICONINFO IconInfo)
 {
-  PCURICON_OBJECT CurIconObject;
-  PBITMAPOBJ bmp;
-  PWINSTATION_OBJECT WinStaObject;
-  NTSTATUS Status;
-  BOOL Ret = FALSE;
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserSetCursorIconContents\n");
-  UserEnterExclusive();
-
-  WinStaObject = IntGetWinStaObj();
-  if(WinStaObject == NULL)
-  {
-    RETURN( FALSE);
-  }
-
-  CurIconObject = IntGetCurIconObject(Handle);
-  if(CurIconObject)
-  {
-    /* Copy fields */
-    Status = MmCopyFromCaller(&CurIconObject->IconInfo, IconInfo, sizeof(ICONINFO));
-    if(!NT_SUCCESS(Status))
-    {
-      SetLastNtError(Status);
-      goto done;
-    }
-
-    bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmColor);
-    if(bmp)
-    {
-      CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
-      CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy;
-      BITMAPOBJ_UnlockBitmap(bmp);
-      GDIOBJ_SetOwnership(CurIconObject->IconInfo.hbmColor, NULL);
-    }
-    else
-    {
-      bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmMask);
-      if(!bmp)
-        goto done;
+   PCURICON_OBJECT CurIconObject;
+   PBITMAPOBJ bmp;
+   PWINSTATION_OBJECT WinStaObject;
+   NTSTATUS Status;
+   BOOL Ret = FALSE;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserSetCursorIconContents\n");
+   UserEnterExclusive();
+
+   WinStaObject = IntGetWinStaObj();
+   if(WinStaObject == NULL)
+   {
+      RETURN( FALSE);
+   }
 
-      CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
-      CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy / 2;
+   CurIconObject = IntGetCurIconObject(Handle);
+   if(CurIconObject)
+   {
+      /* Copy fields */
+      Status = MmCopyFromCaller(&CurIconObject->IconInfo, IconInfo, sizeof(ICONINFO));
+      if(!NT_SUCCESS(Status))
+      {
+         SetLastNtError(Status);
+         goto done;
+      }
 
-      BITMAPOBJ_UnlockBitmap(bmp);
-      GDIOBJ_SetOwnership(CurIconObject->IconInfo.hbmMask, NULL);
-    }
+      bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmColor);
+      if(bmp)
+      {
+         CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
+         CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy;
+         BITMAPOBJ_UnlockBitmap(bmp);
+         GDIOBJ_SetOwnership(CurIconObject->IconInfo.hbmColor, NULL);
+      }
+      else
+      {
+         bmp = BITMAPOBJ_LockBitmap(CurIconObject->IconInfo.hbmMask);
+         if(!bmp)
+            goto done;
 
-    Ret = TRUE;
+         CurIconObject->Size.cx = bmp->SurfObj.sizlBitmap.cx;
+         CurIconObject->Size.cy = bmp->SurfObj.sizlBitmap.cy / 2;
 
-    done:
-    IntReleaseCurIconObject(CurIconObject);
-    ObDereferenceObject(WinStaObject);
-    RETURN( Ret);
-  }
+         BITMAPOBJ_UnlockBitmap(bmp);
+         GDIOBJ_SetOwnership(CurIconObject->IconInfo.hbmMask, NULL);
+      }
+
+      Ret = TRUE;
+
+done:
+      IntReleaseCurIconObject(CurIconObject);
+      ObDereferenceObject(WinStaObject);
+      RETURN( Ret);
+   }
+
+   SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
+   ObDereferenceObject(WinStaObject);
+   RETURN( FALSE);
 
-  SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
-  ObDereferenceObject(WinStaObject);
-  RETURN( FALSE);
-  
 CLEANUP:
-  DPRINT("Leave NtUserSetCursorIconContents, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserSetCursorIconContents, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -1226,85 +1227,85 @@ CLEANUP:
 BOOL
 STDCALL
 NtUserSetCursorIconData(
-  HANDLE Handle,
-  PBOOL fIcon,
-  POINT *Hotspot,
-  HMODULE hModule,
-  HRSRC hRsrc,
-  HRSRC hGroupRsrc)
+   HANDLE Handle,
+   PBOOL fIcon,
+   POINT *Hotspot,
+   HMODULE hModule,
+   HRSRC hRsrc,
+   HRSRC hGroupRsrc)
 {
-  PCURICON_OBJECT CurIconObject;
-  PWINSTATION_OBJECT WinStaObject;
-  NTSTATUS Status;
-  POINT SafeHotspot;
-  BOOL Ret = FALSE;
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserSetCursorIconData\n");
-  UserEnterExclusive();
-
-  WinStaObject = IntGetWinStaObj();
-  if(WinStaObject == NULL)
-  {
-    RETURN( FALSE);
-  }
-
-  CurIconObject = IntGetCurIconObject(Handle);
-  if(CurIconObject)
-  {
-    CurIconObject->hModule = hModule;
-    CurIconObject->hRsrc = hRsrc;
-    CurIconObject->hGroupRsrc = hGroupRsrc;
-
-    /* Copy fields */
-    if(fIcon)
-    {
-      Status = MmCopyFromCaller(&CurIconObject->IconInfo.fIcon, fIcon, sizeof(BOOL));
-      if(!NT_SUCCESS(Status))
+   PCURICON_OBJECT CurIconObject;
+   PWINSTATION_OBJECT WinStaObject;
+   NTSTATUS Status;
+   POINT SafeHotspot;
+   BOOL Ret = FALSE;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserSetCursorIconData\n");
+   UserEnterExclusive();
+
+   WinStaObject = IntGetWinStaObj();
+   if(WinStaObject == NULL)
+   {
+      RETURN( FALSE);
+   }
+
+   CurIconObject = IntGetCurIconObject(Handle);
+   if(CurIconObject)
+   {
+      CurIconObject->hModule = hModule;
+      CurIconObject->hRsrc = hRsrc;
+      CurIconObject->hGroupRsrc = hGroupRsrc;
+
+      /* Copy fields */
+      if(fIcon)
       {
-        SetLastNtError(Status);
-        goto done;
+         Status = MmCopyFromCaller(&CurIconObject->IconInfo.fIcon, fIcon, sizeof(BOOL));
+         if(!NT_SUCCESS(Status))
+         {
+            SetLastNtError(Status);
+            goto done;
+         }
       }
-    }
-    else
-    {
-      if(!Hotspot)
-        Ret = TRUE;
-    }
-
-    if(Hotspot)
-    {
-      Status = MmCopyFromCaller(&SafeHotspot, Hotspot, sizeof(POINT));
-      if(NT_SUCCESS(Status))
+      else
       {
-        CurIconObject->IconInfo.xHotspot = SafeHotspot.x;
-        CurIconObject->IconInfo.yHotspot = SafeHotspot.y;
+         if(!Hotspot)
+            Ret = TRUE;
+      }
 
-        Ret = TRUE;
+      if(Hotspot)
+      {
+         Status = MmCopyFromCaller(&SafeHotspot, Hotspot, sizeof(POINT));
+         if(NT_SUCCESS(Status))
+         {
+            CurIconObject->IconInfo.xHotspot = SafeHotspot.x;
+            CurIconObject->IconInfo.yHotspot = SafeHotspot.y;
+
+            Ret = TRUE;
+         }
+         else
+            SetLastNtError(Status);
       }
-      else
-        SetLastNtError(Status);
-    }
 
-    if(!fIcon && !Hotspot)
-    {
-      Ret = TRUE;
-    }
-
-    done:
-    IntReleaseCurIconObject(CurIconObject);
-    ObDereferenceObject(WinStaObject);
-    RETURN( Ret);
-  }
-
-  SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
-  ObDereferenceObject(WinStaObject);
-  RETURN( FALSE);
-  
+      if(!fIcon && !Hotspot)
+      {
+         Ret = TRUE;
+      }
+
+done:
+      IntReleaseCurIconObject(CurIconObject);
+      ObDereferenceObject(WinStaObject);
+      RETURN( Ret);
+   }
+
+   SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
+   ObDereferenceObject(WinStaObject);
+   RETURN( FALSE);
+
 CLEANUP:
-  DPRINT("Leave NtUserSetCursorIconData, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserSetCursorIconData, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -1314,10 +1315,10 @@ CLEANUP:
 BOOL
 STDCALL
 NtUserSetSystemCursor(
-  HCURSOR hcur,
-  DWORD id)
+   HCURSOR hcur,
+   DWORD id)
 {
-  return FALSE;
+   return FALSE;
 }
 
 
@@ -1328,191 +1329,204 @@ NtUserSetSystemCursor(
 BOOL
 STDCALL
 NtUserDrawIconEx(
-  HDC hdc,
-  int xLeft,
-  int yTop,
-  HICON hIcon,
-  int cxWidth,
-  int cyWidth,
-  UINT istepIfAniCur,
-  HBRUSH hbrFlickerFreeDraw,
-  UINT diFlags,
-  DWORD Unknown0,
-  DWORD Unknown1)
+   HDC hdc,
+   int xLeft,
+   int yTop,
+   HICON hIcon,
+   int cxWidth,
+   int cyWidth,
+   UINT istepIfAniCur,
+   HBRUSH hbrFlickerFreeDraw,
+   UINT diFlags,
+   DWORD Unknown0,
+   DWORD Unknown1)
 {
-  PCURICON_OBJECT CurIconObject;
-  PWINSTATION_OBJECT WinStaObject;
-  HBITMAP hbmMask, hbmColor;
-  BITMAP bmpMask, bmpColor;
-  BOOL DoFlickerFree;
-  SIZE IconSize;
-  COLORREF oldFg, oldBg;
-  HDC hdcMem, hdcOff = (HDC)0;
-  HBITMAP hbmOff = (HBITMAP)0;
-  HGDIOBJ hOldOffBrush = 0, hOldOffBmp = 0, hOldMem;
-  BOOL Ret = FALSE;
-  #if CANSTRETCHBLT
-  INT nStretchMode;
-  #endif
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserDrawIconEx\n");
-  UserEnterExclusive();
-
-  WinStaObject = IntGetWinStaObj();
-  if(WinStaObject == NULL)
-  {
-    RETURN( FALSE);
-  }
-
-  CurIconObject = IntGetCurIconObject(hIcon);
-  if(CurIconObject)
-  {
-    hbmMask = CurIconObject->IconInfo.hbmMask;
-    hbmColor = CurIconObject->IconInfo.hbmColor;
-    IntReleaseCurIconObject(CurIconObject);
-
-    if(istepIfAniCur)
-      DPRINT1("NtUserDrawIconEx: istepIfAniCur is not supported!\n");
-
-    if(!hbmMask || !IntGdiGetObject(hbmMask, sizeof(BITMAP), &bmpMask))
-      goto done;
-
-    if(hbmColor && !IntGdiGetObject(hbmColor, sizeof(BITMAP), &bmpColor))
-      goto done;
-
-    if(hbmColor)
-    {
-      IconSize.cx = bmpColor.bmWidth;
-      IconSize.cy = bmpColor.bmHeight;
-    }
-    else
-    {
-      IconSize.cx = bmpMask.bmWidth;
-      IconSize.cy = bmpMask.bmHeight / 2;
-    }
-
-    if(!diFlags)
-      diFlags = DI_NORMAL;
-
-    if(!cxWidth)
-      cxWidth = ((diFlags & DI_DEFAULTSIZE) ? UserGetSystemMetrics(SM_CXICON) : IconSize.cx);
-    if(!cyWidth)
-      cyWidth = ((diFlags & DI_DEFAULTSIZE) ? UserGetSystemMetrics(SM_CYICON) : IconSize.cy);
-
-    DoFlickerFree = (hbrFlickerFreeDraw && (NtGdiGetObjectType(hbrFlickerFreeDraw) == OBJ_BRUSH));
-
-    if(DoFlickerFree)
-    {
-      RECT r;
-      r.right = cxWidth;
-      r.bottom = cyWidth;
-
-      hdcOff = NtGdiCreateCompatableDC(hdc);
-      if(!hdcOff)
-        goto done;
-
-      hbmOff = NtGdiCreateCompatibleBitmap(hdc, cxWidth, cyWidth);
-      if(!hbmOff)
+   PCURICON_OBJECT CurIconObject;
+   PWINSTATION_OBJECT WinStaObject;
+   HBITMAP hbmMask, hbmColor;
+   BITMAP bmpMask, bmpColor;
+   BOOL DoFlickerFree;
+   SIZE IconSize;
+   COLORREF oldFg, oldBg;
+   HDC hdcMem, hdcOff = (HDC)0;
+   HBITMAP hbmOff = (HBITMAP)0;
+   HGDIOBJ hOldOffBrush = 0, hOldOffBmp = 0, hOldMem;
+   BOOL Ret = FALSE;
+#if CANSTRETCHBLT
+
+   INT nStretchMode;
+#endif
+
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserDrawIconEx\n");
+   UserEnterExclusive();
+
+   WinStaObject = IntGetWinStaObj();
+   if(WinStaObject == NULL)
+   {
+      RETURN( FALSE);
+   }
+
+   CurIconObject = IntGetCurIconObject(hIcon);
+   if(CurIconObject)
+   {
+      hbmMask = CurIconObject->IconInfo.hbmMask;
+      hbmColor = CurIconObject->IconInfo.hbmColor;
+      IntReleaseCurIconObject(CurIconObject);
+
+      if(istepIfAniCur)
+         DPRINT1("NtUserDrawIconEx: istepIfAniCur is not supported!\n");
+
+      if(!hbmMask || !IntGdiGetObject(hbmMask, sizeof(BITMAP), &bmpMask))
+         goto done;
+
+      if(hbmColor && !IntGdiGetObject(hbmColor, sizeof(BITMAP), &bmpColor))
+         goto done;
+
+      if(hbmColor)
+      {
+         IconSize.cx = bmpColor.bmWidth;
+         IconSize.cy = bmpColor.bmHeight;
+      }
+      else
+      {
+         IconSize.cx = bmpMask.bmWidth;
+         IconSize.cy = bmpMask.bmHeight / 2;
+      }
+
+      if(!diFlags)
+         diFlags = DI_NORMAL;
+
+      if(!cxWidth)
+         cxWidth = ((diFlags & DI_DEFAULTSIZE) ? UserGetSystemMetrics(SM_CXICON) : IconSize.cx);
+      if(!cyWidth)
+         cyWidth = ((diFlags & DI_DEFAULTSIZE) ? UserGetSystemMetrics(SM_CYICON) : IconSize.cy);
+
+      DoFlickerFree = (hbrFlickerFreeDraw && (NtGdiGetObjectType(hbrFlickerFreeDraw) == OBJ_BRUSH));
+
+      if(DoFlickerFree)
       {
-        NtGdiDeleteDC(hdcOff);
-        goto done;
+         RECT r;
+         r.right = cxWidth;
+         r.bottom = cyWidth;
+
+         hdcOff = NtGdiCreateCompatableDC(hdc);
+         if(!hdcOff)
+            goto done;
+
+         hbmOff = NtGdiCreateCompatibleBitmap(hdc, cxWidth, cyWidth);
+         if(!hbmOff)
+         {
+            NtGdiDeleteDC(hdcOff);
+            goto done;
+         }
+         hOldOffBrush = NtGdiSelectObject(hdcOff, hbrFlickerFreeDraw);
+         hOldOffBmp = NtGdiSelectObject(hdcOff, hbmOff);
+         NtGdiPatBlt(hdcOff, 0, 0, r.right, r.bottom, PATCOPY);
+         NtGdiSelectObject(hdcOff, hbmOff);
       }
-      hOldOffBrush = NtGdiSelectObject(hdcOff, hbrFlickerFreeDraw);
-      hOldOffBmp = NtGdiSelectObject(hdcOff, hbmOff);
-      NtGdiPatBlt(hdcOff, 0, 0, r.right, r.bottom, PATCOPY);
-      NtGdiSelectObject(hdcOff, hbmOff);
-    }
-
-    hdcMem = NtGdiCreateCompatableDC(hdc);
-    if(!hdcMem)
-      goto cleanup;
-
-    if(!DoFlickerFree)
-      hdcOff = hdc;
-
-    #if CANSTRETCHBLT
-    nStretchMode = NtGdiSetStretchBltMode(hdcOff, STRETCH_DELETESCANS);
-    #endif
-    oldFg = NtGdiSetTextColor(hdcOff, RGB(0, 0, 0));
-    oldBg = NtGdiSetBkColor(hdcOff, RGB(255, 255, 255));
-
-    if(diFlags & DI_MASK)
-    {
-      hOldMem = NtGdiSelectObject(hdcMem, hbmMask);
-      #if CANSTRETCHBLT
-      NtGdiStretchBlt(hdcOff, (DoFlickerFree ? 0 : xLeft), (DoFlickerFree ? 0 : yTop),
-                      cxWidth, cyWidth, hdcMem, 0, 0, IconSize.cx, IconSize.cy,
-                      ((diFlags & DI_IMAGE) ? SRCAND : SRCCOPY));
-      #else
-      NtGdiBitBlt(hdcOff, (DoFlickerFree ? 0 : xLeft), (DoFlickerFree ? 0 : yTop),
-                  cxWidth, cyWidth, hdcMem, 0, 0, ((diFlags & DI_IMAGE) ? SRCAND : SRCCOPY));
-      #endif
-      if(!hbmColor && (bmpMask.bmHeight == 2 * bmpMask.bmWidth) && (diFlags & DI_IMAGE))
+
+      hdcMem = NtGdiCreateCompatableDC(hdc);
+      if(!hdcMem)
+         goto cleanup;
+
+      if(!DoFlickerFree)
+         hdcOff = hdc;
+
+#if CANSTRETCHBLT
+
+      nStretchMode = NtGdiSetStretchBltMode(hdcOff, STRETCH_DELETESCANS);
+#endif
+
+      oldFg = NtGdiSetTextColor(hdcOff, RGB(0, 0, 0));
+      oldBg = NtGdiSetBkColor(hdcOff, RGB(255, 255, 255));
+
+      if(diFlags & DI_MASK)
       {
-        #if CANSTRETCHBLT
-        NtGdiStretchBlt(hdcOff, (DoFlickerFree ? 0 : xLeft), (DoFlickerFree ? 0 : yTop),
-                        cxWidth, cyWidth, hdcMem, 0, IconSize.cy, IconSize.cx, IconSize.cy, SRCINVERT);
-        #else
-        NtGdiBitBlt(hdcOff, (DoFlickerFree ? 0 : xLeft), (DoFlickerFree ? 0 : yTop),
-                    cxWidth, cyWidth, hdcMem, 0, IconSize.cy, SRCINVERT);
-        #endif
-        diFlags &= ~DI_IMAGE;
+         hOldMem = NtGdiSelectObject(hdcMem, hbmMask);
+#if CANSTRETCHBLT
+
+         NtGdiStretchBlt(hdcOff, (DoFlickerFree ? 0 : xLeft), (DoFlickerFree ? 0 : yTop),
+                         cxWidth, cyWidth, hdcMem, 0, 0, IconSize.cx, IconSize.cy,
+                         ((diFlags & DI_IMAGE) ? SRCAND : SRCCOPY));
+#else
+
+         NtGdiBitBlt(hdcOff, (DoFlickerFree ? 0 : xLeft), (DoFlickerFree ? 0 : yTop),
+                     cxWidth, cyWidth, hdcMem, 0, 0, ((diFlags & DI_IMAGE) ? SRCAND : SRCCOPY));
+#endif
+
+         if(!hbmColor && (bmpMask.bmHeight == 2 * bmpMask.bmWidth) && (diFlags & DI_IMAGE))
+         {
+#if CANSTRETCHBLT
+            NtGdiStretchBlt(hdcOff, (DoFlickerFree ? 0 : xLeft), (DoFlickerFree ? 0 : yTop),
+                            cxWidth, cyWidth, hdcMem, 0, IconSize.cy, IconSize.cx, IconSize.cy, SRCINVERT);
+#else
+
+            NtGdiBitBlt(hdcOff, (DoFlickerFree ? 0 : xLeft), (DoFlickerFree ? 0 : yTop),
+                        cxWidth, cyWidth, hdcMem, 0, IconSize.cy, SRCINVERT);
+#endif
+
+            diFlags &= ~DI_IMAGE;
+         }
+         NtGdiSelectObject(hdcMem, hOldMem);
       }
-      NtGdiSelectObject(hdcMem, hOldMem);
-    }
-
-    if(diFlags & DI_IMAGE)
-    {
-      hOldMem = NtGdiSelectObject(hdcMem, (hbmColor ? hbmColor : hbmMask));
-      #if CANSTRETCHBLT
-      NtGdiStretchBlt(hdcOff, (DoFlickerFree ? 0 : xLeft), (DoFlickerFree ? 0 : yTop),
-                      cxWidth, cyWidth, hdcMem, 0, (hbmColor ? 0 : IconSize.cy),
-                      IconSize.cx, IconSize.cy, ((diFlags & DI_MASK) ? SRCINVERT : SRCCOPY));
-      #else
-      NtGdiBitBlt(hdcOff, (DoFlickerFree ? 0 : xLeft), (DoFlickerFree ? 0 : yTop),
-                  cxWidth, cyWidth, hdcMem, 0, (hbmColor ? 0 : IconSize.cy),
-                  ((diFlags & DI_MASK) ? SRCINVERT : SRCCOPY));
-      #endif
-      NtGdiSelectObject(hdcMem, hOldMem);
-    }
-
-    if(DoFlickerFree)
-      NtGdiBitBlt(hdc, xLeft, yTop, cxWidth, cyWidth, hdcOff, 0, 0, SRCCOPY);
-
-    NtGdiSetTextColor(hdcOff, oldFg);
-    NtGdiSetBkColor(hdcOff, oldBg);
-    #if CANSTRETCHBLT
-    SetStretchBltMode(hdcOff, nStretchMode);
-    #endif
-
-    Ret = TRUE;
-
-    cleanup:
-    if(DoFlickerFree)
-    {
-
-      NtGdiSelectObject(hdcOff, hOldOffBmp);
-      NtGdiSelectObject(hdcOff, hOldOffBrush);
-      NtGdiDeleteObject(hbmOff);
-      NtGdiDeleteDC(hdcOff);
-    }
-    if(hdcMem)
-      NtGdiDeleteDC(hdcMem);
-
-    done:
-    ObDereferenceObject(WinStaObject);
-
-    RETURN( Ret);
-  }
-
-  SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
-  ObDereferenceObject(WinStaObject);
-  RETURN( FALSE);
-  
+
+      if(diFlags & DI_IMAGE)
+      {
+         hOldMem = NtGdiSelectObject(hdcMem, (hbmColor ? hbmColor : hbmMask));
+#if CANSTRETCHBLT
+
+         NtGdiStretchBlt(hdcOff, (DoFlickerFree ? 0 : xLeft), (DoFlickerFree ? 0 : yTop),
+                         cxWidth, cyWidth, hdcMem, 0, (hbmColor ? 0 : IconSize.cy),
+                         IconSize.cx, IconSize.cy, ((diFlags & DI_MASK) ? SRCINVERT : SRCCOPY));
+#else
+
+         NtGdiBitBlt(hdcOff, (DoFlickerFree ? 0 : xLeft), (DoFlickerFree ? 0 : yTop),
+                     cxWidth, cyWidth, hdcMem, 0, (hbmColor ? 0 : IconSize.cy),
+                     ((diFlags & DI_MASK) ? SRCINVERT : SRCCOPY));
+#endif
+
+         NtGdiSelectObject(hdcMem, hOldMem);
+      }
+
+      if(DoFlickerFree)
+         NtGdiBitBlt(hdc, xLeft, yTop, cxWidth, cyWidth, hdcOff, 0, 0, SRCCOPY);
+
+      NtGdiSetTextColor(hdcOff, oldFg);
+      NtGdiSetBkColor(hdcOff, oldBg);
+#if CANSTRETCHBLT
+
+      SetStretchBltMode(hdcOff, nStretchMode);
+#endif
+
+      Ret = TRUE;
+
+cleanup:
+      if(DoFlickerFree)
+      {
+
+         NtGdiSelectObject(hdcOff, hOldOffBmp);
+         NtGdiSelectObject(hdcOff, hOldOffBrush);
+         NtGdiDeleteObject(hbmOff);
+         NtGdiDeleteDC(hdcOff);
+      }
+      if(hdcMem)
+         NtGdiDeleteDC(hdcMem);
+
+done:
+      ObDereferenceObject(WinStaObject);
+
+      RETURN( Ret);
+   }
+
+   SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
+   ObDereferenceObject(WinStaObject);
+   RETURN( FALSE);
+
 CLEANUP:
-  DPRINT("Leave NtUserDrawIconEx, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserDrawIconEx, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
index e401580..a1b4438 100644 (file)
@@ -46,15 +46,15 @@ BOOL g_PaintDesktopVersion = FALSE;
 /* INITALIZATION FUNCTIONS ****************************************************/
 
 static GENERIC_MAPPING IntDesktopMapping =
-{
-   STANDARD_RIGHTS_READ     | DESKTOP_ENUMERATE       | DESKTOP_READOBJECTS,
-   STANDARD_RIGHTS_WRITE    | DESKTOP_CREATEMENU      | DESKTOP_CREATEWINDOW    | DESKTOP_HOOKCONTROL   |
-                              DESKTOP_JOURNALPLAYBACK | DESKTOP_JOURNALRECORD   | DESKTOP_WRITEOBJECTS,
-   STANDARD_RIGHTS_EXECUTE  | DESKTOP_SWITCHDESKTOP,
-   STANDARD_RIGHTS_REQUIRED | DESKTOP_CREATEMENU      | DESKTOP_CREATEWINDOW    | DESKTOP_ENUMERATE     |
-                              DESKTOP_HOOKCONTROL     | DESKTOP_JOURNALPLAYBACK | DESKTOP_JOURNALRECORD |
-                              DESKTOP_READOBJECTS     | DESKTOP_SWITCHDESKTOP   | DESKTOP_WRITEOBJECTS
-};
+   {
+      STANDARD_RIGHTS_READ     | DESKTOP_ENUMERATE       | DESKTOP_READOBJECTS,
+      STANDARD_RIGHTS_WRITE    | DESKTOP_CREATEMENU      | DESKTOP_CREATEWINDOW    | DESKTOP_HOOKCONTROL   |
+      DESKTOP_JOURNALPLAYBACK | DESKTOP_JOURNALRECORD   | DESKTOP_WRITEOBJECTS,
+      STANDARD_RIGHTS_EXECUTE  | DESKTOP_SWITCHDESKTOP,
+      STANDARD_RIGHTS_REQUIRED | DESKTOP_CREATEMENU      | DESKTOP_CREATEWINDOW    | DESKTOP_ENUMERATE     |
+      DESKTOP_HOOKCONTROL     | DESKTOP_JOURNALPLAYBACK | DESKTOP_JOURNALRECORD |
+      DESKTOP_READOBJECTS     | DESKTOP_SWITCHDESKTOP   | DESKTOP_WRITEOBJECTS
+   };
 
 NTSTATUS FASTCALL
 InitDesktopImpl(VOID)
@@ -62,70 +62,70 @@ InitDesktopImpl(VOID)
    /* Set Desktop Object Attributes */
    ExDesktopObjectType->TypeInfo.DefaultNonPagedPoolCharge = sizeof(DESKTOP_OBJECT);
    ExDesktopObjectType->TypeInfo.GenericMapping = IntDesktopMapping;
-   
-  return STATUS_SUCCESS;
+
+   return STATUS_SUCCESS;
 }
 
 NTSTATUS FASTCALL
 CleanupDesktopImpl(VOID)
 {
-  return STATUS_SUCCESS;
+   return STATUS_SUCCESS;
 }
 
 /* OBJECT CALLBACKS **********************************************************/
 
 NTSTATUS STDCALL
 IntDesktopObjectCreate(PVOID ObjectBody,
-                      PVOID Parent,
-                      PWSTR RemainingPath,
-                      struct _OBJECT_ATTRIBUTES* ObjectAttributes)
+                       PVOID Parent,
+                       PWSTR RemainingPath,
+                       struct _OBJECT_ATTRIBUTES* ObjectAttributes)
 {
-  PDESKTOP_OBJECT Desktop = (PDESKTOP_OBJECT)ObjectBody;
-  UNICODE_STRING UnicodeString;
+   PDESKTOP_OBJECT Desktop = (PDESKTOP_OBJECT)ObjectBody;
+   UNICODE_STRING UnicodeString;
 
-  DPRINT("Creating desktop (0x%X)  Name (%S)\n", Desktop, RemainingPath);
-  if (RemainingPath == NULL)
-       {
-               return STATUS_SUCCESS;
-       }
+   DPRINT("Creating desktop (0x%X)  Name (%S)\n", Desktop, RemainingPath);
+   if (RemainingPath == NULL)
+   {
+      return STATUS_SUCCESS;
+   }
 
-  if (wcschr((RemainingPath + 1), '\\') != NULL)
-       {
-               return STATUS_UNSUCCESSFUL;
-       }
+   if (wcschr((RemainingPath + 1), '\\') != NULL)
+   {
+      return STATUS_UNSUCCESSFUL;
+   }
 
-  RtlInitUnicodeString(&UnicodeString, (RemainingPath + 1));
+   RtlInitUnicodeString(&UnicodeString, (RemainingPath + 1));
 
-  
 
-  KeInitializeSpinLock(&Desktop->Lock);
-  InitializeListHead(&Desktop->ShellHookWindows);
 
-  Desktop->WindowStation = (PWINSTATION_OBJECT)Parent;
+   KeInitializeSpinLock(&Desktop->Lock);
+   InitializeListHead(&Desktop->ShellHookWindows);
 
-  /* Put the desktop on the window station's list of associcated desktops */
-  ExInterlockedInsertTailList(
-    &Desktop->WindowStation->DesktopListHead,
-    &Desktop->ListEntry,
-    &Desktop->WindowStation->Lock);
+   Desktop->WindowStation = (PWINSTATION_OBJECT)Parent;
 
-  return RtlCreateUnicodeString(&Desktop->Name, UnicodeString.Buffer);
+   /* Put the desktop on the window station's list of associcated desktops */
+   ExInterlockedInsertTailList(
+      &Desktop->WindowStation->DesktopListHead,
+      &Desktop->ListEntry,
+      &Desktop->WindowStation->Lock);
+
+   return RtlCreateUnicodeString(&Desktop->Name, UnicodeString.Buffer);
 }
 
 VOID STDCALL
 IntDesktopObjectDelete(PVOID DeletedObject)
 {
-  PDESKTOP_OBJECT Desktop = (PDESKTOP_OBJECT)DeletedObject;
-  KIRQL OldIrql;
+   PDESKTOP_OBJECT Desktop = (PDESKTOP_OBJECT)DeletedObject;
+   KIRQL OldIrql;
 
-  DPRINT("Deleting desktop (0x%X)\n", Desktop);
+   DPRINT("Deleting desktop (0x%X)\n", Desktop);
 
-  /* Remove the desktop from the window station's list of associcated desktops */
-  KeAcquireSpinLock(&Desktop->WindowStation->Lock, &OldIrql);
-  RemoveEntryList(&Desktop->ListEntry);
-  KeReleaseSpinLock(&Desktop->WindowStation->Lock, OldIrql);
+   /* Remove the desktop from the window station's list of associcated desktops */
+   KeAcquireSpinLock(&Desktop->WindowStation->Lock, &OldIrql);
+   RemoveEntryList(&Desktop->ListEntry);
+   KeReleaseSpinLock(&Desktop->WindowStation->Lock, OldIrql);
 
-  RtlFreeUnicodeString(&Desktop->Name);
+   RtlFreeUnicodeString(&Desktop->Name);
 }
 
 /* PRIVATE FUNCTIONS **********************************************************/
@@ -136,171 +136,171 @@ IntParseDesktopPath(PEPROCESS Process,
                     HWINSTA *hWinSta,
                     HDESK *hDesktop)
 {
-  OBJECT_ATTRIBUTES ObjectAttributes;
-  UNICODE_STRING WinSta, Desktop, FullName;
-  BOOL DesktopPresent = FALSE;
-  BOOL WinStaPresent = FALSE;
-  NTSTATUS Status;
-
-  ASSERT(hWinSta);
-
-  *hWinSta = NULL;
-
-  if(hDesktop != NULL)
-  {
-    *hDesktop = NULL;
-  }
-
-  RtlInitUnicodeString(&WinSta, NULL);
-  RtlInitUnicodeString(&Desktop, NULL);
-
-  if(DesktopPath != NULL && DesktopPath->Buffer != NULL && DesktopPath->Length > sizeof(WCHAR))
-  {
-    PWCHAR c = DesktopPath->Buffer;
-    USHORT wl = 0;
-    USHORT l = DesktopPath->Length;
-
-    /*
-     * Parse the desktop path string which can be in the form "WinSta\Desktop"
-     * or just "Desktop". In latter case WinSta0 will be used.
-     */
-
-    while(l > 0)
-    {
-      if(*c == L'\\')
+   OBJECT_ATTRIBUTES ObjectAttributes;
+   UNICODE_STRING WinSta, Desktop, FullName;
+   BOOL DesktopPresent = FALSE;
+   BOOL WinStaPresent = FALSE;
+   NTSTATUS Status;
+
+   ASSERT(hWinSta);
+
+   *hWinSta = NULL;
+
+   if(hDesktop != NULL)
+   {
+      *hDesktop = NULL;
+   }
+
+   RtlInitUnicodeString(&WinSta, NULL);
+   RtlInitUnicodeString(&Desktop, NULL);
+
+   if(DesktopPath != NULL && DesktopPath->Buffer != NULL && DesktopPath->Length > sizeof(WCHAR))
+   {
+      PWCHAR c = DesktopPath->Buffer;
+      USHORT wl = 0;
+      USHORT l = DesktopPath->Length;
+
+      /*
+       * Parse the desktop path string which can be in the form "WinSta\Desktop"
+       * or just "Desktop". In latter case WinSta0 will be used.
+       */
+
+      while(l > 0)
       {
-        wl = (ULONG_PTR)c - (ULONG_PTR)DesktopPath->Buffer;
-        break;
+         if(*c == L'\\')
+         {
+            wl = (ULONG_PTR)c - (ULONG_PTR)DesktopPath->Buffer;
+            break;
+         }
+         l -= sizeof(WCHAR);
+         c++;
       }
-      l -= sizeof(WCHAR);
-      c++;
-    }
-
-    if(wl > 0)
-    {
-      WinSta.Length = wl;
-      WinSta.MaximumLength = wl + sizeof(WCHAR);
-      WinSta.Buffer = DesktopPath->Buffer;
-
-      WinStaPresent = TRUE;
-      c++;
-    }
-
-    Desktop.Length = DesktopPath->Length - wl;
-    if(wl > 0)
-    {
-      Desktop.Length -= sizeof(WCHAR);
-    }
-    if(Desktop.Length > 0)
-    {
-      Desktop.MaximumLength = Desktop.Length + sizeof(WCHAR);
-      Desktop.Buffer = ((wl > 0) ? c : DesktopPath->Buffer);
-      DesktopPresent = TRUE;
-    }
-  }
-
-  if(!WinStaPresent)
-  {
-    /* search the process handle table for (inherited) window station
-       handles, use a more appropriate one than WinSta0 if possible. */
-    Status = ObFindHandleForObject(Process,
-                                   NULL,
-                                   ExWindowStationObjectType,
-                                   NULL,
-                                   (PHANDLE)hWinSta);
-    if(!NT_SUCCESS(Status))
-    {
-      /* we had no luck searching for opened handles, use WinSta0 now */
-      RtlInitUnicodeString(&WinSta, L"WinSta0");
-    }
-  }
-
-  if(!DesktopPresent && hDesktop != NULL)
-  {
-    /* search the process handle table for (inherited) desktop
-       handles, use a more appropriate one than Default if possible. */
-    Status = ObFindHandleForObject(Process,
-                                   NULL,
-                                   ExDesktopObjectType,
-                                   NULL,
-                                   (PHANDLE)hDesktop);
-    if(!NT_SUCCESS(Status))
-    {
-      /* we had no luck searching for opened handles, use Desktop now */
-      RtlInitUnicodeString(&Desktop, L"Default");
-    }
-  }
-
-  if(*hWinSta == NULL)
-  {
-    if(!IntGetFullWindowStationName(&FullName, &WinSta, NULL))
-    {
-      return STATUS_INSUFFICIENT_RESOURCES;
-    }
-
-    /* open the window station */
-    InitializeObjectAttributes(&ObjectAttributes,
-                               &FullName,
-                               OBJ_CASE_INSENSITIVE,
-                               NULL,
-                               NULL);
-
-    Status = ObOpenObjectByName(&ObjectAttributes,
-                                ExWindowStationObjectType,
-                                NULL,
-                                KernelMode,
-                                0,
-                                NULL,
-                                (HANDLE*)hWinSta);
-
-    RtlFreeUnicodeString(&FullName);
-
-    if(!NT_SUCCESS(Status))
-    {
-      SetLastNtError(Status);
-      DPRINT("Failed to reference window station %wZ PID: %d!\n", &WinSta, PsGetCurrentProcessId());
-      return Status;
-    }
-  }
-
-  if(hDesktop != NULL && *hDesktop == NULL)
-  {
-    if(!IntGetFullWindowStationName(&FullName, &WinSta, &Desktop))
-    {
-      NtClose(*hWinSta);
-      *hWinSta = NULL;
-      return STATUS_INSUFFICIENT_RESOURCES;
-    }
-
-    /* open the desktop object */
-    InitializeObjectAttributes(&ObjectAttributes,
-                               &FullName,
-                               OBJ_CASE_INSENSITIVE,
-                               NULL,
-                               NULL);
-
-     Status = ObOpenObjectByName(&ObjectAttributes,
-                                 ExDesktopObjectType,
+
+      if(wl > 0)
+      {
+         WinSta.Length = wl;
+         WinSta.MaximumLength = wl + sizeof(WCHAR);
+         WinSta.Buffer = DesktopPath->Buffer;
+
+         WinStaPresent = TRUE;
+         c++;
+      }
+
+      Desktop.Length = DesktopPath->Length - wl;
+      if(wl > 0)
+      {
+         Desktop.Length -= sizeof(WCHAR);
+      }
+      if(Desktop.Length > 0)
+      {
+         Desktop.MaximumLength = Desktop.Length + sizeof(WCHAR);
+         Desktop.Buffer = ((wl > 0) ? c : DesktopPath->Buffer);
+         DesktopPresent = TRUE;
+      }
+   }
+
+   if(!WinStaPresent)
+   {
+      /* search the process handle table for (inherited) window station
+         handles, use a more appropriate one than WinSta0 if possible. */
+      Status = ObFindHandleForObject(Process,
+                                     NULL,
+                                     ExWindowStationObjectType,
+                                     NULL,
+                                     (PHANDLE)hWinSta);
+      if(!NT_SUCCESS(Status))
+      {
+         /* we had no luck searching for opened handles, use WinSta0 now */
+         RtlInitUnicodeString(&WinSta, L"WinSta0");
+      }
+   }
+
+   if(!DesktopPresent && hDesktop != NULL)
+   {
+      /* search the process handle table for (inherited) desktop
+         handles, use a more appropriate one than Default if possible. */
+      Status = ObFindHandleForObject(Process,
+                                     NULL,
+                                     ExDesktopObjectType,
+                                     NULL,
+                                     (PHANDLE)hDesktop);
+      if(!NT_SUCCESS(Status))
+      {
+         /* we had no luck searching for opened handles, use Desktop now */
+         RtlInitUnicodeString(&Desktop, L"Default");
+      }
+   }
+
+   if(*hWinSta == NULL)
+   {
+      if(!IntGetFullWindowStationName(&FullName, &WinSta, NULL))
+      {
+         return STATUS_INSUFFICIENT_RESOURCES;
+      }
+
+      /* open the window station */
+      InitializeObjectAttributes(&ObjectAttributes,
+                                 &FullName,
+                                 OBJ_CASE_INSENSITIVE,
                                  NULL,
-                                 KernelMode,
-                                 0,
+                                 NULL);
+
+      Status = ObOpenObjectByName(&ObjectAttributes,
+                                  ExWindowStationObjectType,
+                                  NULL,
+                                  KernelMode,
+                                  0,
+                                  NULL,
+                                  (HANDLE*)hWinSta);
+
+      RtlFreeUnicodeString(&FullName);
+
+      if(!NT_SUCCESS(Status))
+      {
+         SetLastNtError(Status);
+         DPRINT("Failed to reference window station %wZ PID: %d!\n", &WinSta, PsGetCurrentProcessId());
+         return Status;
+      }
+   }
+
+   if(hDesktop != NULL && *hDesktop == NULL)
+   {
+      if(!IntGetFullWindowStationName(&FullName, &WinSta, &Desktop))
+      {
+         NtClose(*hWinSta);
+         *hWinSta = NULL;
+         return STATUS_INSUFFICIENT_RESOURCES;
+      }
+
+      /* open the desktop object */
+      InitializeObjectAttributes(&ObjectAttributes,
+                                 &FullName,
+                                 OBJ_CASE_INSENSITIVE,
                                  NULL,
-                                 (HANDLE*)hDesktop);
+                                 NULL);
 
-    RtlFreeUnicodeString(&FullName);
+      Status = ObOpenObjectByName(&ObjectAttributes,
+                                  ExDesktopObjectType,
+                                  NULL,
+                                  KernelMode,
+                                  0,
+                                  NULL,
+                                  (HANDLE*)hDesktop);
 
-    if(!NT_SUCCESS(Status))
-    {
-      *hDesktop = NULL;
-      NtClose(*hWinSta);
-      *hWinSta = NULL;
-      SetLastNtError(Status);
-      DPRINT("Failed to reference desktop %wZ PID: %d!\n", &Desktop, PsGetCurrentProcessId());
-      return Status;
-    }
-  }
+      RtlFreeUnicodeString(&FullName);
+
+      if(!NT_SUCCESS(Status))
+      {
+         *hDesktop = NULL;
+         NtClose(*hWinSta);
+         *hWinSta = NULL;
+         SetLastNtError(Status);
+         DPRINT("Failed to reference desktop %wZ PID: %d!\n", &Desktop, PsGetCurrentProcessId());
+         return Status;
+      }
+   }
 
-  return STATUS_SUCCESS;
+   return STATUS_SUCCESS;
 }
 
 /*
@@ -323,12 +323,12 @@ IntValidateDesktopHandle(
    NTSTATUS Status;
 
    Status = ObReferenceObjectByHandle(
-      Desktop,
-      DesiredAccess,
-      ExDesktopObjectType,
-      AccessMode,
-      (PVOID*)Object,
-      NULL);
+               Desktop,
+               DesiredAccess,
+               ExDesktopObjectType,
+               AccessMode,
+               (PVOID*)Object,
+               NULL);
 
    if (!NT_SUCCESS(Status))
       SetLastNtError(Status);
@@ -339,37 +339,37 @@ IntValidateDesktopHandle(
 VOID FASTCALL
 IntGetDesktopWorkArea(PDESKTOP_OBJECT Desktop, PRECT Rect)
 {
-  PRECT Ret;
-
-  ASSERT(Desktop);
-
-  Ret = &Desktop->WorkArea;
-  if((Ret->right == -1) && ScreenDeviceContext)
-  {
-    PDC dc;
-    BITMAPOBJ *BitmapObj;
-    dc = DC_LockDc(ScreenDeviceContext);
-    /* FIXME - Handle dc == NULL!!!! */
-    BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
-    if(BitmapObj)
-    {
-      Ret->right = BitmapObj->SurfObj.sizlBitmap.cx;
-      Ret->bottom = BitmapObj->SurfObj.sizlBitmap.cy;
-      BITMAPOBJ_UnlockBitmap(BitmapObj);
-    }
-    DC_UnlockDc(dc);
-  }
-
-  if(Rect)
-  {
-    *Rect = *Ret;
-  }
+   PRECT Ret;
+
+   ASSERT(Desktop);
+
+   Ret = &Desktop->WorkArea;
+   if((Ret->right == -1) && ScreenDeviceContext)
+   {
+      PDC dc;
+      BITMAPOBJ *BitmapObj;
+      dc = DC_LockDc(ScreenDeviceContext);
+      /* FIXME - Handle dc == NULL!!!! */
+      BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
+      if(BitmapObj)
+      {
+         Ret->right = BitmapObj->SurfObj.sizlBitmap.cx;
+         Ret->bottom = BitmapObj->SurfObj.sizlBitmap.cy;
+         BITMAPOBJ_UnlockBitmap(BitmapObj);
+      }
+      DC_UnlockDc(dc);
+   }
+
+   if(Rect)
+   {
+      *Rect = *Ret;
+   }
 }
 
 PDESKTOP_OBJECT FASTCALL
 IntGetActiveDesktop(VOID)
 {
-  return InputDesktop;
+   return InputDesktop;
 }
 
 /*
@@ -378,35 +378,35 @@ IntGetActiveDesktop(VOID)
 HDESK FASTCALL
 IntGetDesktopObjectHandle(PDESKTOP_OBJECT DesktopObject)
 {
-  NTSTATUS Status;
-  HDESK Ret;
+   NTSTATUS Status;
+   HDESK Ret;
 
-  ASSERT(DesktopObject);
+   ASSERT(DesktopObject);
 
-  Status = ObFindHandleForObject(PsGetCurrentProcess(),
-                                 DesktopObject,
-                                 ExDesktopObjectType,
-                                 NULL,
-                                 (PHANDLE)&Ret);
-
-  if(!NT_SUCCESS(Status))
-  {
-    Status = ObOpenObjectByPointer(DesktopObject,
-                                   0,
-                                   NULL,
-                                   0,
-                                   ExDesktopObjectType,
-                                   UserMode,
-                                   (PHANDLE)&Ret);
-    if(!NT_SUCCESS(Status))
-    {
-     /* unable to create a handle */
-     DPRINT1("Unable to create a desktop handle\n");
-     return NULL;
-    }
-  }
-
-  return Ret;
+   Status = ObFindHandleForObject(PsGetCurrentProcess(),
+                                  DesktopObject,
+                                  ExDesktopObjectType,
+                                  NULL,
+                                  (PHANDLE)&Ret);
+
+   if(!NT_SUCCESS(Status))
+   {
+      Status = ObOpenObjectByPointer(DesktopObject,
+                                     0,
+                                     NULL,
+                                     0,
+                                     ExDesktopObjectType,
+                                     UserMode,
+                                     (PHANDLE)&Ret);
+      if(!NT_SUCCESS(Status))
+      {
+         /* unable to create a handle */
+         DPRINT1("Unable to create a desktop handle\n");
+         return NULL;
+      }
+   }
+
+   return Ret;
 }
 
 PUSER_MESSAGE_QUEUE FASTCALL
@@ -435,8 +435,8 @@ IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue)
    {
       if(NewQueue->Desktop != NULL)
       {
-        DPRINT("Message Queue already attached to another desktop!\n");
-        return;
+         DPRINT("Message Queue already attached to another desktop!\n");
+         return;
       }
       IntReferenceMessageQueue(NewQueue);
       InterlockedExchange((LONG*)&NewQueue->Desktop, (LONG)pdo);
@@ -457,36 +457,37 @@ HWND FASTCALL IntGetDesktopWindow(VOID)
       DPRINT("No active desktop\n");
       return NULL;
    }
-  return pdo->DesktopWindow;
+   return pdo->DesktopWindow;
 }
 
 PWINDOW_OBJECT FASTCALL UserGetDesktopWindow(VOID)
 {
    PDESKTOP_OBJECT pdo = IntGetActiveDesktop();
    PWINDOW_OBJECT DeskWnd;
-   
+
    if (!pdo)
    {
       DPRINT("No active desktop\n");
       return NULL;
    }
-   
+
    //temp hack
    DeskWnd = IntGetWindowObject(pdo->DesktopWindow);
-   if (DeskWnd) IntReleaseWindowObject(DeskWnd);
+   if (DeskWnd)
+      IntReleaseWindowObject(DeskWnd);
    return DeskWnd;
 }
 
 
 HWND FASTCALL IntGetCurrentThreadDesktopWindow(VOID)
 {
-  PDESKTOP_OBJECT pdo = PsGetWin32Thread()->Desktop;
-  if (NULL == pdo)
-    {
+   PDESKTOP_OBJECT pdo = PsGetWin32Thread()->Desktop;
+   if (NULL == pdo)
+   {
       DPRINT1("Thread doesn't have a desktop\n");
       return NULL;
-    }
-  return pdo->DesktopWindow;
+   }
+   return pdo->DesktopWindow;
 }
 
 BOOL FASTCALL IntDesktopUpdatePerUserSettings(BOOL bEnable)
@@ -530,38 +531,39 @@ BOOL FASTCALL IntDesktopUpdatePerUserSettings(BOOL bEnable)
 NTSTATUS FASTCALL
 co_IntShowDesktop(PDESKTOP_OBJECT Desktop, ULONG Width, ULONG Height)
 {
-  CSR_API_MESSAGE Request;
+   CSR_API_MESSAGE Request;
 
-  Request.Type = MAKE_CSR_API(SHOW_DESKTOP, CSR_GUI);
-  Request.Data.ShowDesktopRequest.DesktopWindow = Desktop->DesktopWindow;
-  Request.Data.ShowDesktopRequest.Width = Width;
-  Request.Data.ShowDesktopRequest.Height = Height;
+   Request.Type = MAKE_CSR_API(SHOW_DESKTOP, CSR_GUI);
+   Request.Data.ShowDesktopRequest.DesktopWindow = Desktop->DesktopWindow;
+   Request.Data.ShowDesktopRequest.Width = Width;
+   Request.Data.ShowDesktopRequest.Height = Height;
 
-  return co_CsrNotify(&Request);
+   return co_CsrNotify(&Request);
 }
 
 NTSTATUS FASTCALL
 IntHideDesktop(PDESKTOP_OBJECT Desktop)
 {
 #if 0
-  CSRSS_API_REQUEST Request;
-  CSRSS_API_REPLY Reply;
+   CSRSS_API_REQUEST Request;
+   CSRSS_API_REPLY Reply;
 
-  Request.Type = CSRSS_HIDE_DESKTOP;
-  Request.Data.HideDesktopRequest.DesktopWindow = Desktop->DesktopWindow;
+   Request.Type = CSRSS_HIDE_DESKTOP;
+   Request.Data.HideDesktopRequest.DesktopWindow = Desktop->DesktopWindow;
 
-  return NotifyCsrss(&Request, &Reply);
+   return NotifyCsrss(&Request, &Reply);
 #else
-  PWINDOW_OBJECT DesktopWindow;
 
-  DesktopWindow = IntGetWindowObject(Desktop->DesktopWindow);
-  if (! DesktopWindow)
-    {
+   PWINDOW_OBJECT DesktopWindow;
+
+   DesktopWindow = IntGetWindowObject(Desktop->DesktopWindow);
+   if (! DesktopWindow)
+   {
       return ERROR_INVALID_WINDOW_HANDLE;
-    }
-  DesktopWindow->Style &= ~WS_VISIBLE;
+   }
+   DesktopWindow->Style &= ~WS_VISIBLE;
 
-  return STATUS_SUCCESS;
+   return STATUS_SUCCESS;
 #endif
 }
 
@@ -572,68 +574,73 @@ IntHideDesktop(PDESKTOP_OBJECT Desktop)
  */
 VOID co_IntShellHookNotify(WPARAM Message, LPARAM lParam)
 {
-  PDESKTOP_OBJECT Desktop = IntGetActiveDesktop();
-  PLIST_ENTRY Entry, Entry2;
-  PSHELL_HOOK_WINDOW Current;
-  KIRQL OldLevel;
+   PDESKTOP_OBJECT Desktop = IntGetActiveDesktop();
+   PLIST_ENTRY Entry, Entry2;
+   PSHELL_HOOK_WINDOW Current;
+   KIRQL OldLevel;
 
-  static UINT MsgType = 0;
+   static UINT MsgType = 0;
 
-  if (!MsgType) {
+   if (!MsgType)
+   {
 
-    /* Too bad, this doesn't work.*/
+      /* Too bad, this doesn't work.*/
 #if 0
-    UNICODE_STRING Str;
-    RtlInitUnicodeString(&Str, L"SHELLHOOK");
-    MsgType = UserRegisterWindowMessage(&Str);
+      UNICODE_STRING Str;
+      RtlInitUnicodeString(&Str, L"SHELLHOOK");
+      MsgType = UserRegisterWindowMessage(&Str);
 #endif
-    MsgType = IntAddAtom(L"SHELLHOOK");
-
-    DPRINT("MsgType = %x\n", MsgType);
-    if (!MsgType)
-      DPRINT1("LastError: %x\n", GetLastNtError());
-  }
-
-  if (!Desktop) {
-    DPRINT1("IntShellHookNotify: No desktop!\n");
-    return;
-  }
-
-  /* We have to do some tricks because the list could change
-   * between calls, and we can't keep the lock during the call
-   */
-
-  KeAcquireSpinLock(&Desktop->Lock, &OldLevel);
-  Entry = Desktop->ShellHookWindows.Flink;
-  while (Entry != &Desktop->ShellHookWindows) {
-    Current = CONTAINING_RECORD(Entry, SHELL_HOOK_WINDOW, ListEntry);
-    KeReleaseSpinLock(&Desktop->Lock, OldLevel);
-
-    DPRINT("Sending notify\n");
-    co_IntPostOrSendMessage(Current->hWnd,
-                         MsgType,
-                         Message,
-                         lParam);
-
-    /* Loop again to find the window we were sending to. If it doesn't
-     * exist anymore, we just stop. This could leave an infinite loop
-     * if a window is removed and readded to the list. That's quite
-     * unlikely though.
-     */
-
-    KeAcquireSpinLock(&Desktop->Lock, &OldLevel);
-    Entry2 = Desktop->ShellHookWindows.Flink;
-    while (Entry2 != Entry &&
-           Entry2 != &Desktop->ShellHookWindows) {
-      Entry2 = Entry2->Flink;
-    }
-
-    if (Entry2 == Entry)
-      Entry = Entry->Flink;
-    else
-      break;
-  }
-  KeReleaseSpinLock(&Desktop->Lock, OldLevel);
+
+      MsgType = IntAddAtom(L"SHELLHOOK");
+
+      DPRINT("MsgType = %x\n", MsgType);
+      if (!MsgType)
+         DPRINT1("LastError: %x\n", GetLastNtError());
+   }
+
+   if (!Desktop)
+   {
+      DPRINT1("IntShellHookNotify: No desktop!\n");
+      return;
+   }
+
+   /* We have to do some tricks because the list could change
+    * between calls, and we can't keep the lock during the call
+    */
+
+   KeAcquireSpinLock(&Desktop->Lock, &OldLevel);
+   Entry = Desktop->ShellHookWindows.Flink;
+   while (Entry != &Desktop->ShellHookWindows)
+   {
+      Current = CONTAINING_RECORD(Entry, SHELL_HOOK_WINDOW, ListEntry);
+      KeReleaseSpinLock(&Desktop->Lock, OldLevel);
+
+      DPRINT("Sending notify\n");
+      co_IntPostOrSendMessage(Current->hWnd,
+                              MsgType,
+                              Message,
+                              lParam);
+
+      /* Loop again to find the window we were sending to. If it doesn't
+       * exist anymore, we just stop. This could leave an infinite loop
+       * if a window is removed and readded to the list. That's quite
+       * unlikely though.
+       */
+
+      KeAcquireSpinLock(&Desktop->Lock, &OldLevel);
+      Entry2 = Desktop->ShellHookWindows.Flink;
+      while (Entry2 != Entry &&
+             Entry2 != &Desktop->ShellHookWindows)
+      {
+         Entry2 = Entry2->Flink;
+      }
+
+      if (Entry2 == Entry)
+         Entry = Entry->Flink;
+      else
+         break;
+   }
+   KeReleaseSpinLock(&Desktop->Lock, OldLevel);
 }
 
 /*
@@ -646,33 +653,33 @@ VOID co_IntShellHookNotify(WPARAM Message, LPARAM lParam)
  */
 BOOL IntRegisterShellHookWindow(HWND hWnd)
 {
-  PDESKTOP_OBJECT Desktop = PsGetWin32Thread()->Desktop;
-  PSHELL_HOOK_WINDOW Entry;
-  KIRQL OldLevel;
+   PDESKTOP_OBJECT Desktop = PsGetWin32Thread()->Desktop;
+   PSHELL_HOOK_WINDOW Entry;
+   KIRQL OldLevel;
 
-  DPRINT("IntRegisterShellHookWindow\n");
+   DPRINT("IntRegisterShellHookWindow\n");
 
-  /* First deregister the window, so we can be sure it's never twice in the
-   * list.
-   */
-  IntDeRegisterShellHookWindow(hWnd);
+   /* First deregister the window, so we can be sure it's never twice in the
+    * list.
+    */
+   IntDeRegisterShellHookWindow(hWnd);
 
-  Entry = ExAllocatePoolWithTag(NonPagedPool,
-                                sizeof(SHELL_HOOK_WINDOW),
-                                TAG_WINSTA);
-  /* We have to walk this structure with while holding a spinlock, so we
-   * need NonPagedPool */
+   Entry = ExAllocatePoolWithTag(NonPagedPool,
+                                 sizeof(SHELL_HOOK_WINDOW),
+                                 TAG_WINSTA);
+   /* We have to walk this structure with while holding a spinlock, so we
+    * need NonPagedPool */
 
-  if (!Entry)
-    return FALSE;
+   if (!Entry)
+      return FALSE;
 
-  Entry->hWnd = hWnd;
+   Entry->hWnd = hWnd;
 
-  KeAcquireSpinLock(&Desktop->Lock, &OldLevel);
-  InsertTailList(&Desktop->ShellHookWindows, &Entry->ListEntry);
-  KeReleaseSpinLock(&Desktop->Lock, OldLevel);
+   KeAcquireSpinLock(&Desktop->Lock, &OldLevel);
+   InsertTailList(&Desktop->ShellHookWindows, &Entry->ListEntry);
+   KeReleaseSpinLock(&Desktop->Lock, OldLevel);
 
-  return TRUE;
+   return TRUE;
 }
 
 /*
@@ -682,28 +689,30 @@ BOOL IntRegisterShellHookWindow(HWND hWnd)
  */
 BOOL IntDeRegisterShellHookWindow(HWND hWnd)
 {
-  PDESKTOP_OBJECT Desktop = PsGetWin32Thread()->Desktop;
-  PLIST_ENTRY Entry;
-  PSHELL_HOOK_WINDOW Current;
-  KIRQL OldLevel;
-
-  KeAcquireSpinLock(&Desktop->Lock, &OldLevel);
-
-  Entry = Desktop->ShellHookWindows.Flink;
-  while (Entry != &Desktop->ShellHookWindows) {
-    Current = CONTAINING_RECORD(Entry, SHELL_HOOK_WINDOW, ListEntry);
-    if (Current->hWnd == hWnd) {
-      RemoveEntryList(Entry);
-      KeReleaseSpinLock(&Desktop->Lock, OldLevel);
-      ExFreePool(Entry);
-      return TRUE;
-    }
-    Entry = Entry->Flink;
-  }
+   PDESKTOP_OBJECT Desktop = PsGetWin32Thread()->Desktop;
+   PLIST_ENTRY Entry;
+   PSHELL_HOOK_WINDOW Current;
+   KIRQL OldLevel;
 
-  KeReleaseSpinLock(&Desktop->Lock, OldLevel);
+   KeAcquireSpinLock(&Desktop->Lock, &OldLevel);
 
-  return FALSE;
+   Entry = Desktop->ShellHookWindows.Flink;
+   while (Entry != &Desktop->ShellHookWindows)
+   {
+      Current = CONTAINING_RECORD(Entry, SHELL_HOOK_WINDOW, ListEntry);
+      if (Current->hWnd == hWnd)
+      {
+         RemoveEntryList(Entry);
+         KeReleaseSpinLock(&Desktop->Lock, OldLevel);
+         ExFreePool(Entry);
+         return TRUE;
+      }
+      Entry = Entry->Flink;
+   }
+
+   KeReleaseSpinLock(&Desktop->Lock, OldLevel);
+
+   return FALSE;
 }
 
 /*
@@ -746,154 +755,154 @@ NtUserCreateDesktop(
    LPSECURITY_ATTRIBUTES lpSecurity,
    HWINSTA hWindowStation)
 {
-  OBJECT_ATTRIBUTES ObjectAttributes;
-  PWINSTATION_OBJECT WinStaObject;
-  PDESKTOP_OBJECT DesktopObject;
-  UNICODE_STRING DesktopName;
-  NTSTATUS Status;
-  HDESK Desktop;
-  CSR_API_MESSAGE Request;
-  DECLARE_RETURN(HDESK);
-
-  DPRINT("Enter CreateDesktop: %wZ\n", lpszDesktopName);
-  UserEnterExclusive();
-
-  Status = IntValidateWindowStationHandle(
-    hWindowStation,
-    KernelMode,
-    0, /* FIXME - WINSTA_CREATEDESKTOP */
-    &WinStaObject);
-
-  if (! NT_SUCCESS(Status))
-    {
+   OBJECT_ATTRIBUTES ObjectAttributes;
+   PWINSTATION_OBJECT WinStaObject;
+   PDESKTOP_OBJECT DesktopObject;
+   UNICODE_STRING DesktopName;
+   NTSTATUS Status;
+   HDESK Desktop;
+   CSR_API_MESSAGE Request;
+   DECLARE_RETURN(HDESK);
+
+   DPRINT("Enter CreateDesktop: %wZ\n", lpszDesktopName);
+   UserEnterExclusive();
+
+   Status = IntValidateWindowStationHandle(
+               hWindowStation,
+               KernelMode,
+               0, /* FIXME - WINSTA_CREATEDESKTOP */
+               &WinStaObject);
+
+   if (! NT_SUCCESS(Status))
+   {
       DPRINT1("Failed validation of window station handle (0x%X), cannot create desktop %wZ\n",
-        hWindowStation, lpszDesktopName);
+              hWindowStation, lpszDesktopName);
       SetLastNtError(Status);
       RETURN( NULL);
-    }
+   }
 
-  if (! IntGetFullWindowStationName(&DesktopName, &WinStaObject->Name,
-          lpszDesktopName))
-    {
+   if (! IntGetFullWindowStationName(&DesktopName, &WinStaObject->Name,
+                                     lpszDesktopName))
+   {
       SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
       ObDereferenceObject(WinStaObject);
       RETURN( NULL);
-    }
-
-  ObDereferenceObject(WinStaObject);
-
-  /*
-   * Try to open already existing desktop
-   */
-
-  DPRINT1("Trying to open desktop (%wZ)\n", &DesktopName);
-
-  /* Initialize ObjectAttributes for the desktop object */
-  InitializeObjectAttributes(
-    &ObjectAttributes,
-    &DesktopName,
-    0,
-    NULL,
-    NULL);
-
-  Status = ObOpenObjectByName(
-    &ObjectAttributes,
-    ExDesktopObjectType,
-    NULL,
-    KernelMode,
-    dwDesiredAccess,
-    NULL,
-    (HANDLE*)&Desktop);
-
-  if (NT_SUCCESS(Status))
-    {
+   }
+
+   ObDereferenceObject(WinStaObject);
+
+   /*
+    * Try to open already existing desktop
+    */
+
+   DPRINT1("Trying to open desktop (%wZ)\n", &DesktopName);
+
+   /* Initialize ObjectAttributes for the desktop object */
+   InitializeObjectAttributes(
+      &ObjectAttributes,
+      &DesktopName,
+      0,
+      NULL,
+      NULL);
+
+   Status = ObOpenObjectByName(
+               &ObjectAttributes,
+               ExDesktopObjectType,
+               NULL,
+               KernelMode,
+               dwDesiredAccess,
+               NULL,
+               (HANDLE*)&Desktop);
+
+   if (NT_SUCCESS(Status))
+   {
       DPRINT("Successfully opened desktop (%wZ)\n", &DesktopName);
       ExFreePool(DesktopName.Buffer);
       RETURN( Desktop);
-    }
-
-  /*
-   * No existing desktop found, try to create new one
-   */
-
-  Status = ObCreateObject(
-    KernelMode,
-    ExDesktopObjectType,
-    &ObjectAttributes,
-    ExGetPreviousMode(),
-    NULL,
-    sizeof(DESKTOP_OBJECT),
-    0,
-    0,
-    (PVOID*)&DesktopObject);
-
-  if (! NT_SUCCESS(Status))
-    {
+   }
+
+   /*
+    * No existing desktop found, try to create new one
+    */
+
+   Status = ObCreateObject(
+               KernelMode,
+               ExDesktopObjectType,
+               &ObjectAttributes,
+               ExGetPreviousMode(),
+               NULL,
+               sizeof(DESKTOP_OBJECT),
+               0,
+               0,
+               (PVOID*)&DesktopObject);
+
+   if (! NT_SUCCESS(Status))
+   {
       DPRINT1("Failed creating desktop (%wZ)\n", &DesktopName);
       ExFreePool(DesktopName.Buffer);
       SetLastNtError(STATUS_UNSUCCESSFUL);
       RETURN( NULL);
-    }
-
-  // init desktop area
-  DesktopObject->WorkArea.left = 0;
-  DesktopObject->WorkArea.top = 0;
-  DesktopObject->WorkArea.right = -1;
-  DesktopObject->WorkArea.bottom = -1;
-  IntGetDesktopWorkArea(DesktopObject, NULL);
-
-  /* Initialize some local (to win32k) desktop state. */
-  DesktopObject->ActiveMessageQueue = NULL;
-
-  Status = ObInsertObject(
-    (PVOID)DesktopObject,
-    NULL,
-    STANDARD_RIGHTS_REQUIRED,
-    0,
-    NULL,
-    (HANDLE*)&Desktop);
-
-  ObDereferenceObject(DesktopObject);
-  ExFreePool(DesktopName.Buffer);
-
-  if (! NT_SUCCESS(Status))
-    {
+   }
+
+   // init desktop area
+   DesktopObject->WorkArea.left = 0;
+   DesktopObject->WorkArea.top = 0;
+   DesktopObject->WorkArea.right = -1;
+   DesktopObject->WorkArea.bottom = -1;
+   IntGetDesktopWorkArea(DesktopObject, NULL);
+
+   /* Initialize some local (to win32k) desktop state. */
+   DesktopObject->ActiveMessageQueue = NULL;
+
+   Status = ObInsertObject(
+               (PVOID)DesktopObject,
+               NULL,
+               STANDARD_RIGHTS_REQUIRED,
+               0,
+               NULL,
+               (HANDLE*)&Desktop);
+
+   ObDereferenceObject(DesktopObject);
+   ExFreePool(DesktopName.Buffer);
+
+   if (! NT_SUCCESS(Status))
+   {
       DPRINT1("Failed to create desktop handle\n");
       SetLastNtError(Status);
       RETURN( NULL);
-    }
-
-  /*
-   * Create a handle for CSRSS and notify CSRSS
-   */
-  Request.Type = MAKE_CSR_API(CREATE_DESKTOP, CSR_GUI);
-  Status = CsrInsertObject(Desktop,
-                           GENERIC_ALL,
-                           (HANDLE*)&Request.Data.CreateDesktopRequest.DesktopHandle);
-  if (! NT_SUCCESS(Status))
-  {
-    DPRINT1("Failed to create desktop handle for CSRSS\n");
-    ZwClose(Desktop);
-    SetLastNtError(Status);
-    RETURN( NULL);
-  }
-
-  Status = co_CsrNotify(&Request);
-  if (! NT_SUCCESS(Status))
-    {
+   }
+
+   /*
+    * Create a handle for CSRSS and notify CSRSS
+    */
+   Request.Type = MAKE_CSR_API(CREATE_DESKTOP, CSR_GUI);
+   Status = CsrInsertObject(Desktop,
+                            GENERIC_ALL,
+                            (HANDLE*)&Request.Data.CreateDesktopRequest.DesktopHandle);
+   if (! NT_SUCCESS(Status))
+   {
+      DPRINT1("Failed to create desktop handle for CSRSS\n");
+      ZwClose(Desktop);
+      SetLastNtError(Status);
+      RETURN( NULL);
+   }
+
+   Status = co_CsrNotify(&Request);
+   if (! NT_SUCCESS(Status))
+   {
       CsrCloseHandle(Request.Data.CreateDesktopRequest.DesktopHandle);
       DPRINT1("Failed to notify CSRSS about new desktop\n");
       ZwClose(Desktop);
       SetLastNtError(Status);
       RETURN( NULL);
-    }
+   }
+
+   RETURN( Desktop);
 
-  RETURN( Desktop);
-  
 CLEANUP:
-  DPRINT("Leave NtUserCreateDesktop, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserCreateDesktop, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 /*
@@ -930,20 +939,20 @@ NtUserOpenDesktop(
    NTSTATUS Status;
    HDESK Desktop;
    DECLARE_RETURN(HDESK);
-   
+
    DPRINT("Enter NtUserOpenDesktop: %wZ\n", lpszDesktopName);
    UserEnterExclusive();
-   
+
    /*
     * Validate the window station handle and compose the fully
     * qualified desktop name
     */
 
    Status = IntValidateWindowStationHandle(
-      PsGetCurrentProcess()->Win32WindowStation,
-      KernelMode,
-      0,
-      &WinStaObject);
+               PsGetCurrentProcess()->Win32WindowStation,
+               KernelMode,
+               0,
+               &WinStaObject);
 
    if (!NT_SUCCESS(Status))
    {
@@ -954,7 +963,7 @@ NtUserOpenDesktop(
    }
 
    if (!IntGetFullWindowStationName(&DesktopName, &WinStaObject->Name,
-       lpszDesktopName))
+                                    lpszDesktopName))
    {
       SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
       ObDereferenceObject(WinStaObject);
@@ -974,13 +983,13 @@ NtUserOpenDesktop(
       NULL);
 
    Status = ObOpenObjectByName(
-      &ObjectAttributes,
-      ExDesktopObjectType,
-      NULL,
-      UserMode,
-      dwDesiredAccess,
-      NULL,
-      (HANDLE*)&Desktop);
+               &ObjectAttributes,
+               ExDesktopObjectType,
+               NULL,
+               UserMode,
+               dwDesiredAccess,
+               NULL,
+               (HANDLE*)&Desktop);
 
    if (!NT_SUCCESS(Status))
    {
@@ -993,7 +1002,7 @@ NtUserOpenDesktop(
    ExFreePool(DesktopName.Buffer);
 
    RETURN( Desktop);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserOpenDesktop, ret=%i\n",_ret_);
    UserLeave();
@@ -1037,10 +1046,10 @@ NtUserOpenInputDesktop(
    /* Get a pointer to the desktop object */
 
    Status = IntValidateDesktopHandle(
-      InputDesktopHandle,
-      UserMode,
-      0,
-      &Object);
+               InputDesktopHandle,
+               UserMode,
+               0,
+               &Object);
 
    if (!NT_SUCCESS(Status))
    {
@@ -1051,13 +1060,13 @@ NtUserOpenInputDesktop(
    /* Create a new handle to the object */
 
    Status = ObOpenObjectByPointer(
-      Object,
-      0,
-      NULL,
-      dwDesiredAccess,
-      ExDesktopObjectType,
-      UserMode,
-      (HANDLE*)&Desktop);
+               Object,
+               0,
+               NULL,
+               dwDesiredAccess,
+               ExDesktopObjectType,
+               UserMode,
+               (HANDLE*)&Desktop);
 
    ObDereferenceObject(Object);
 
@@ -1098,14 +1107,14 @@ NtUserCloseDesktop(HDESK hDesktop)
 {
    PDESKTOP_OBJECT Object;
    NTSTATUS Status;
-   
+
    DPRINT("About to close desktop handle (0x%X)\n", hDesktop);
 
    Status = IntValidateDesktopHandle(
-      hDesktop,
-      UserMode,
-      0,
-      &Object);
+               hDesktop,
+               UserMode,
+               0,
+               &Object);
 
    if (!NT_SUCCESS(Status))
    {
@@ -1130,25 +1139,25 @@ NtUserCloseDesktop(HDESK hDesktop)
 
 static int GetSystemVersionString(LPWSTR buffer)
 {
-  RTL_OSVERSIONINFOEXW versionInfo;
-  int len;
+   RTL_OSVERSIONINFOEXW versionInfo;
+   int len;
 
-  versionInfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
+   versionInfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
 
-  if (!NT_SUCCESS(RtlGetVersion((PRTL_OSVERSIONINFOW)&versionInfo)))
-       return 0;
+   if (!NT_SUCCESS(RtlGetVersion((PRTL_OSVERSIONINFOW)&versionInfo)))
+      return 0;
 
-  if (versionInfo.dwMajorVersion <= 4)
-         len = swprintf(buffer,
-                         L"ReactOS Version %d.%d %s Build %d",
-                         versionInfo.dwMajorVersion, versionInfo.dwMinorVersion,
-                         versionInfo.szCSDVersion, versionInfo.dwBuildNumber&0xFFFF);
-  else
-         len = swprintf(buffer,
-                         L"ReactOS %s (Build %d)",
-                         versionInfo.szCSDVersion, versionInfo.dwBuildNumber&0xFFFF);
+   if (versionInfo.dwMajorVersion <= 4)
+      len = swprintf(buffer,
+                     L"ReactOS Version %d.%d %s Build %d",
+                     versionInfo.dwMajorVersion, versionInfo.dwMinorVersion,
+                     versionInfo.szCSDVersion, versionInfo.dwBuildNumber&0xFFFF);
+   else
+      len = swprintf(buffer,
+                     L"ReactOS %s (Build %d)",
+                     versionInfo.szCSDVersion, versionInfo.dwBuildNumber&0xFFFF);
 
-  return len;
+   return len;
 }
 
 /*
@@ -1169,110 +1178,114 @@ static int GetSystemVersionString(LPWSTR buffer)
 BOOL STDCALL
 NtUserPaintDesktop(HDC hDC)
 {
-  RECT Rect;
-  HBRUSH DesktopBrush, PreviousBrush;
-  HWND hWndDesktop;
-  BOOL doPatBlt = TRUE;
-  PWINDOW_OBJECT WndDesktop;
-  int len;
-
-  PWINSTATION_OBJECT WinSta = PsGetWin32Thread()->Desktop->WindowStation;
-
-  IntGdiGetClipBox(hDC, &Rect);
-
-  hWndDesktop = IntGetDesktopWindow();
-  if (!(WndDesktop = IntGetWindowObject(hWndDesktop)))
-     return FALSE;
-     
-  DesktopBrush = (HBRUSH)IntGetClassLong(WndDesktop, GCL_HBRBACKGROUND, FALSE); //fixme: verify retval
-
-  //temp hack
-  IntReleaseWindowObject(WndDesktop);
-  
-  
-  /*
-   * Paint desktop background
-   */
-
-  if(WinSta->hbmWallpaper != NULL)
-  {
-    PWINDOW_OBJECT DeskWin;
-
-    if((DeskWin = IntGetWindowObject(hWndDesktop)))
-    {
-      SIZE sz;
-      int x, y;
-      HDC hWallpaperDC;
-
-      sz.cx = DeskWin->WindowRect.right - DeskWin->WindowRect.left;
-      sz.cy = DeskWin->WindowRect.bottom - DeskWin->WindowRect.top;
-      IntReleaseWindowObject(DeskWin);
-
-      x = (sz.cx / 2) - (WinSta->cxWallpaper / 2);
-      y = (sz.cy / 2) - (WinSta->cyWallpaper / 2);
-
-      hWallpaperDC = NtGdiCreateCompatableDC(hDC);
-      if(hWallpaperDC != NULL)
+   RECT Rect;
+   HBRUSH DesktopBrush, PreviousBrush;
+   HWND hWndDesktop;
+   BOOL doPatBlt = TRUE;
+   PWINDOW_OBJECT WndDesktop;
+   int len;
+
+   PWINSTATION_OBJECT WinSta = PsGetWin32Thread()->Desktop->WindowStation;
+
+   IntGdiGetClipBox(hDC, &Rect);
+
+   hWndDesktop = IntGetDesktopWindow();
+   if (!(WndDesktop = IntGetWindowObject(hWndDesktop)))
+      return FALSE;
+
+   DesktopBrush = (HBRUSH)IntGetClassLong(WndDesktop, GCL_HBRBACKGROUND, FALSE); //fixme: verify retval
+
+   //temp hack
+   IntReleaseWindowObject(WndDesktop);
+
+
+   /*
+    * Paint desktop background
+    */
+
+   if(WinSta->hbmWallpaper != NULL)
+   {
+      PWINDOW_OBJECT DeskWin;
+
+      if((DeskWin = IntGetWindowObject(hWndDesktop)))
+      {
+         SIZE sz;
+         int x, y;
+         HDC hWallpaperDC;
+
+         sz.cx = DeskWin->WindowRect.right - DeskWin->WindowRect.left;
+         sz.cy = DeskWin->WindowRect.bottom - DeskWin->WindowRect.top;
+         IntReleaseWindowObject(DeskWin);
+
+         x = (sz.cx / 2) - (WinSta->cxWallpaper / 2);
+         y = (sz.cy / 2) - (WinSta->cyWallpaper / 2);
+
+         hWallpaperDC = NtGdiCreateCompatableDC(hDC);
+         if(hWallpaperDC != NULL)
+         {
+            HBITMAP hOldBitmap;
+
+            if(x > 0 || y > 0)
+            {
+               /* FIXME - clip out the bitmap */
+               PreviousBrush = NtGdiSelectObject(hDC, DesktopBrush);
+               NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right, Rect.bottom, PATCOPY);
+               NtGdiSelectObject(hDC, PreviousBrush);
+            }
+            else
+               doPatBlt = FALSE;
+
+            hOldBitmap = NtGdiSelectObject(hWallpaperDC, WinSta->hbmWallpaper);
+            NtGdiBitBlt(hDC, x, y, WinSta->cxWallpaper, WinSta->cyWallpaper, hWallpaperDC, 0, 0, SRCCOPY);
+            NtGdiSelectObject(hWallpaperDC, hOldBitmap);
+
+            NtGdiDeleteDC(hWallpaperDC);
+         }
+      }
+   }
+
+   if (doPatBlt)
+   {
+      PreviousBrush = NtGdiSelectObject(hDC, DesktopBrush);
+      NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right, Rect.bottom, PATCOPY);
+      NtGdiSelectObject(hDC, PreviousBrush);
+   }
+
+   /*
+    * Display system version on the desktop background
+    */
+
+   if (g_PaintDesktopVersion)
+   {
+      static WCHAR s_wszVersion[256] = {0};
+      RECT rect;
+
+      if (*s_wszVersion)
+         len = wcslen(s_wszVersion);
+      else
+         len = GetSystemVersionString(s_wszVersion);
+
+      if (len)
       {
-        HBITMAP hOldBitmap;
-
-        if(x > 0 || y > 0)
-        {
-          /* FIXME - clip out the bitmap */
-          PreviousBrush = NtGdiSelectObject(hDC, DesktopBrush);
-          NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right, Rect.bottom, PATCOPY);
-          NtGdiSelectObject(hDC, PreviousBrush);
-        }
-               else
-                 doPatBlt = FALSE;
-
-        hOldBitmap = NtGdiSelectObject(hWallpaperDC, WinSta->hbmWallpaper);
-        NtGdiBitBlt(hDC, x, y, WinSta->cxWallpaper, WinSta->cyWallpaper, hWallpaperDC, 0, 0, SRCCOPY);
-        NtGdiSelectObject(hWallpaperDC, hOldBitmap);
-
-        NtGdiDeleteDC(hWallpaperDC);
+         if (!UserSystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0))
+         {
+            rect.right = UserGetSystemMetrics(SM_CXSCREEN);
+            rect.bottom = UserGetSystemMetrics(SM_CYSCREEN);
+         }
+
+         COLORREF color_old = NtGdiSetTextColor(hDC, RGB(255,255,255));
+         UINT align_old = NtGdiSetTextAlign(hDC, TA_RIGHT);
+         int mode_old = NtGdiSetBkMode(hDC, TRANSPARENT);
+
+         NtGdiTextOut(hDC, rect.right-16, rect.bottom-48, s_wszVersion, len);
+
+         NtGdiSetBkMode(hDC, mode_old);
+         NtGdiSetTextAlign(hDC, align_old);
+         NtGdiSetTextColor(hDC, color_old);
       }
-    }
-  }
-
-  if (doPatBlt) {
-       PreviousBrush = NtGdiSelectObject(hDC, DesktopBrush);
-       NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right, Rect.bottom, PATCOPY);
-       NtGdiSelectObject(hDC, PreviousBrush);
-  }
-
-  /*
-   * Display system version on the desktop background
-   */
-
-  if (g_PaintDesktopVersion) {
-       static WCHAR s_wszVersion[256] = {0};
-       RECT rect;
-
-       if (*s_wszVersion)
-         len = wcslen(s_wszVersion);
-       else
-         len = GetSystemVersionString(s_wszVersion);
-
-       if (len) {
-     if (!UserSystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0)) {
-               rect.right = UserGetSystemMetrics(SM_CXSCREEN);
-      rect.bottom = UserGetSystemMetrics(SM_CYSCREEN);
-         }
-
-         COLORREF color_old = NtGdiSetTextColor(hDC, RGB(255,255,255));
-         UINT align_old = NtGdiSetTextAlign(hDC, TA_RIGHT);
-         int mode_old = NtGdiSetBkMode(hDC, TRANSPARENT);
-
-         NtGdiTextOut(hDC, rect.right-16, rect.bottom-48, s_wszVersion, len);
-
-         NtGdiSetBkMode(hDC, mode_old);
-         NtGdiSetTextAlign(hDC, align_old);
-         NtGdiSetTextColor(hDC, color_old);
-       }
-  }
-
-  return TRUE;
+   }
+
+   return TRUE;
 }
 
 
@@ -1301,10 +1314,10 @@ NtUserSwitchDesktop(HDESK hDesktop)
    DPRINT("About to switch desktop (0x%X)\n", hDesktop);
 
    Status = IntValidateDesktopHandle(
-      hDesktop,
-      UserMode,
-      0,
-      &DesktopObject);
+               hDesktop,
+               UserMode,
+               0,
+               &DesktopObject);
 
    if (!NT_SUCCESS(Status))
    {
@@ -1317,7 +1330,7 @@ NtUserSwitchDesktop(HDESK hDesktop)
     * is the logon application itself
     */
    if((DesktopObject->WindowStation->Flags & WSS_LOCKED) &&
-      LogonProcess != NULL && LogonProcess != PsGetWin32Process())
+         LogonProcess != NULL && LogonProcess != PsGetWin32Process())
    {
       ObDereferenceObject(DesktopObject);
       DPRINT1("Switching desktop 0x%x denied because the work station is locked!\n", hDesktop);
@@ -1366,71 +1379,71 @@ NtUserResolveDesktopForWOW(DWORD Unknown0)
 HDESK STDCALL
 NtUserGetThreadDesktop(DWORD dwThreadId, DWORD Unknown1)
 {
-  NTSTATUS Status;
-  PETHREAD Thread;
-  PDESKTOP_OBJECT DesktopObject;
-  HDESK Ret, hThreadDesktop;
-  OBJECT_HANDLE_INFORMATION HandleInformation;
-
-  if(!dwThreadId)
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    return 0;
-  }
-
-  Status = PsLookupThreadByThreadId((HANDLE)dwThreadId, &Thread);
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    return 0;
-  }
-
-  if(Thread->ThreadsProcess == PsGetCurrentProcess())
-  {
-    /* just return the handle, we queried the desktop handle of a thread running
-       in the same context */
-    Ret = Thread->Tcb.Win32Thread->hDesktop;
-    ObDereferenceObject(Thread);
-    return Ret;
-  }
-
-  /* get the desktop handle and the desktop of the thread */
-  if(!(hThreadDesktop = Thread->Tcb.Win32Thread->hDesktop) ||
-     !(DesktopObject = Thread->Tcb.Win32Thread->Desktop))
-  {
-    ObDereferenceObject(Thread);
-    DPRINT1("Desktop information of thread 0x%x broken!?\n", dwThreadId);
-    return NULL;
-  }
-
-  /* we could just use DesktopObject instead of looking up the handle, but latter
-     may be a bit safer (e.g. when the desktop is being destroyed */
-  /* switch into the context of the thread we're trying to get the desktop from,
-     so we can use the handle */
-  KeAttachProcess(&Thread->ThreadsProcess->Pcb);
-  Status = ObReferenceObjectByHandle(hThreadDesktop,
-                                     GENERIC_ALL,
-                                    ExDesktopObjectType,
-                                    UserMode,
-                                    (PVOID*)&DesktopObject,
-                                    &HandleInformation);
-  KeDetachProcess();
-
-  /* the handle couldn't be found, there's nothing to get... */
-  if(!NT_SUCCESS(Status))
-  {
-    ObDereferenceObject(Thread);
-    return NULL;
-  }
-
-  /* lookup our handle table if we can find a handle to the desktop object,
-     if not, create one */
-  Ret = IntGetDesktopObjectHandle(DesktopObject);
-
-  /* all done, we got a valid handle to the desktop */
-  ObDereferenceObject(DesktopObject);
-  ObDereferenceObject(Thread);
-  return Ret;
+   NTSTATUS Status;
+   PETHREAD Thread;
+   PDESKTOP_OBJECT DesktopObject;
+   HDESK Ret, hThreadDesktop;
+   OBJECT_HANDLE_INFORMATION HandleInformation;
+
+   if(!dwThreadId)
+   {
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      return 0;
+   }
+
+   Status = PsLookupThreadByThreadId((HANDLE)dwThreadId, &Thread);
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      return 0;
+   }
+
+   if(Thread->ThreadsProcess == PsGetCurrentProcess())
+   {
+      /* just return the handle, we queried the desktop handle of a thread running
+         in the same context */
+      Ret = Thread->Tcb.Win32Thread->hDesktop;
+      ObDereferenceObject(Thread);
+      return Ret;
+   }
+
+   /* get the desktop handle and the desktop of the thread */
+   if(!(hThreadDesktop = Thread->Tcb.Win32Thread->hDesktop) ||
+         !(DesktopObject = Thread->Tcb.Win32Thread->Desktop))
+   {
+      ObDereferenceObject(Thread);
+      DPRINT1("Desktop information of thread 0x%x broken!?\n", dwThreadId);
+      return NULL;
+   }
+
+   /* we could just use DesktopObject instead of looking up the handle, but latter
+      may be a bit safer (e.g. when the desktop is being destroyed */
+   /* switch into the context of the thread we're trying to get the desktop from,
+      so we can use the handle */
+   KeAttachProcess(&Thread->ThreadsProcess->Pcb);
+   Status = ObReferenceObjectByHandle(hThreadDesktop,
+                                      GENERIC_ALL,
+                                      ExDesktopObjectType,
+                                      UserMode,
+                                      (PVOID*)&DesktopObject,
+                                      &HandleInformation);
+   KeDetachProcess();
+
+   /* the handle couldn't be found, there's nothing to get... */
+   if(!NT_SUCCESS(Status))
+   {
+      ObDereferenceObject(Thread);
+      return NULL;
+   }
+
+   /* lookup our handle table if we can find a handle to the desktop object,
+      if not, create one */
+   Ret = IntGetDesktopObjectHandle(DesktopObject);
+
+   /* all done, we got a valid handle to the desktop */
+   ObDereferenceObject(DesktopObject);
+   ObDereferenceObject(Thread);
+   return Ret;
 }
 
 /*
@@ -1449,10 +1462,10 @@ NtUserSetThreadDesktop(HDESK hDesktop)
 
    /* Validate the new desktop. */
    Status = IntValidateDesktopHandle(
-      hDesktop,
-      UserMode,
-      0,
-      &DesktopObject);
+               hDesktop,
+               UserMode,
+               0,
+               &DesktopObject);
 
    if (!NT_SUCCESS(Status))
    {
index 09b8c09..3a06c6b 100644 (file)
@@ -53,8 +53,8 @@ co_IntSendDeactivateMessages(HWND hWndPrev, HWND hWnd)
    {
       co_IntPostOrSendMessage(hWndPrev, WM_NCACTIVATE, FALSE, 0);
       co_IntPostOrSendMessage(hWndPrev, WM_ACTIVATE,
-         MAKEWPARAM(WA_INACTIVE, UserGetWindowLong(hWndPrev, GWL_STYLE, FALSE) & WS_MINIMIZE),
-         (LPARAM)hWnd);
+                              MAKEWPARAM(WA_INACTIVE, UserGetWindowLong(hWndPrev, GWL_STYLE, FALSE) & WS_MINIMIZE),
+                              (LPARAM)hWnd);
    }
 }
 
@@ -69,24 +69,24 @@ co_IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate)
       if (co_IntPostOrSendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0))
       {
          co_IntPostOrSendMessage(HWND_BROADCAST, WM_PALETTEISCHANGING,
-            (WPARAM)hWnd, 0);
+                                 (WPARAM)hWnd, 0);
       }
 
       if (UserGetWindow(hWnd, GW_HWNDPREV) != NULL)
          co_WinPosSetWindowPos(Window, HWND_TOP, 0, 0, 0, 0,
-            SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSENDCHANGING);
+                               SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSENDCHANGING);
+
 
-      
       Owner = IntGetOwner(Window);
-      if (!Owner) 
+      if (!Owner)
       {
          Parent = IntGetParent(Window);
          if (!Parent)
             co_IntShellHookNotify(HSHELL_WINDOWACTIVATED, (LPARAM) hWnd);
          else
             IntReleaseWindowObject(Parent);
-      } 
-      else 
+      }
+      else
       {
          IntReleaseWindowObject(Owner);
       }
@@ -98,9 +98,9 @@ co_IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate)
       co_IntPostOrSendMessage(hWnd, WM_NCACTIVATE, (WPARAM)(hWnd == UserGetForegroundWindow()), 0);
       /* FIXME: WA_CLICKACTIVE */
       co_IntPostOrSendMessage(hWnd, WM_ACTIVATE,
-         MAKEWPARAM(MouseActivate ? WA_CLICKACTIVE : WA_ACTIVE,
-                    UserGetWindowLong(hWnd, GWL_STYLE, FALSE) & WS_MINIMIZE),
-         (LPARAM)hWndPrev);
+                              MAKEWPARAM(MouseActivate ? WA_CLICKACTIVE : WA_ACTIVE,
+                                         UserGetWindowLong(hWnd, GWL_STYLE, FALSE) & WS_MINIMIZE),
+                              (LPARAM)hWndPrev);
    }
 }
 
@@ -125,25 +125,25 @@ co_IntSendSetFocusMessages(HWND hWndPrev, HWND hWnd)
 HWND FASTCALL
 IntFindChildWindowToOwner(PWINDOW_OBJECT Root, PWINDOW_OBJECT Owner)
 {
-  HWND Ret;
-  PWINDOW_OBJECT Child, OwnerWnd;
-
-  for(Child = Root->FirstChild; Child; Child = Child->NextSibling)
-  {
-    OwnerWnd = IntGetWindowObject(Child->hOwner);
-    if(!OwnerWnd)
-      continue;
-
-    if(OwnerWnd == Owner)
-    {
-      Ret = Child->hSelf;
+   HWND Ret;
+   PWINDOW_OBJECT Child, OwnerWnd;
+
+   for(Child = Root->FirstChild; Child; Child = Child->NextSibling)
+   {
+      OwnerWnd = IntGetWindowObject(Child->hOwner);
+      if(!OwnerWnd)
+         continue;
+
+      if(OwnerWnd == Owner)
+      {
+         Ret = Child->hSelf;
+         IntReleaseWindowObject(OwnerWnd);
+         return Ret;
+      }
       IntReleaseWindowObject(OwnerWnd);
-      return Ret;
-    }
-    IntReleaseWindowObject(OwnerWnd);
-  }
+   }
 
-  return NULL;
+   return NULL;
 }
 
 STATIC BOOL FASTCALL
@@ -218,61 +218,61 @@ BOOL FASTCALL
 co_IntSetForegroundWindow(PWINDOW_OBJECT Window)
 {
    ASSERT_REFS_CO(Window);
-   
+
    return co_IntSetForegroundAndFocusWindow(Window, Window, FALSE);
 }
 
 BOOL FASTCALL
 co_IntMouseActivateWindow(PWINDOW_OBJECT Window)
 {
-  HWND Top;
-  PWINDOW_OBJECT TopWindow;
-
-  ASSERT_REFS_CO(Window);
-
-  if(Window->Style & WS_DISABLED)
-  {
-    BOOL Ret;
-    PWINDOW_OBJECT TopWnd;
-    PWINDOW_OBJECT DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
-    if(DesktopWindow)
-    {
-      Top = IntFindChildWindowToOwner(DesktopWindow, Window);
-      if((TopWnd = IntGetWindowObject(Top)))
+   HWND Top;
+   PWINDOW_OBJECT TopWindow;
+
+   ASSERT_REFS_CO(Window);
+
+   if(Window->Style & WS_DISABLED)
+   {
+      BOOL Ret;
+      PWINDOW_OBJECT TopWnd;
+      PWINDOW_OBJECT DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
+      if(DesktopWindow)
       {
-        Ret = co_IntMouseActivateWindow(TopWnd);
-        IntReleaseWindowObject(TopWnd);
-        IntReleaseWindowObject(DesktopWindow);
-        return Ret;
+         Top = IntFindChildWindowToOwner(DesktopWindow, Window);
+         if((TopWnd = IntGetWindowObject(Top)))
+         {
+            Ret = co_IntMouseActivateWindow(TopWnd);
+            IntReleaseWindowObject(TopWnd);
+            IntReleaseWindowObject(DesktopWindow);
+            return Ret;
+         }
+         IntReleaseWindowObject(DesktopWindow);
       }
-      IntReleaseWindowObject(DesktopWindow);
-    }
-    return FALSE;
-  }
-
-  Top = UserGetAncestor(Window->hSelf, GA_ROOT);
-  if (Top != Window->hSelf)
-    {
+      return FALSE;
+   }
+
+   Top = UserGetAncestor(Window->hSelf, GA_ROOT);
+   if (Top != Window->hSelf)
+   {
       TopWindow = IntGetWindowObject(Top);
       if (TopWindow == NULL)
-        {
-          SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-          return FALSE;
-        }
-    }
-  else
-    {
+      {
+         SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+         return FALSE;
+      }
+   }
+   else
+   {
       TopWindow = Window;
-    }
+   }
 
-  /* TMN: Check return valud from this function? */
-  co_IntSetForegroundAndFocusWindow(TopWindow, Window, TRUE);
+   /* TMN: Check return valud from this function? */
+   co_IntSetForegroundAndFocusWindow(TopWindow, Window, TRUE);
 
-  if (Top != Window->hSelf)
-    {
+   if (Top != Window->hSelf)
+   {
       IntReleaseWindowObject(TopWindow);
-    }
-  return TRUE;
+   }
+   return TRUE;
 }
 
 HWND FASTCALL
@@ -282,7 +282,8 @@ co_IntSetActiveWindow(PWINDOW_OBJECT Window OPTIONAL)
    HWND hWndPrev;
    HWND hWnd = 0;
 
-   if (Window) ASSERT_REFS_CO(Window);
+   if (Window)
+      ASSERT_REFS_CO(Window);
 
    ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
    ASSERT(ThreadQueue != 0);
@@ -290,7 +291,7 @@ co_IntSetActiveWindow(PWINDOW_OBJECT Window OPTIONAL)
    if (Window != 0)
    {
       if (!(Window->Style & WS_VISIBLE) ||
-          (Window->Style & (WS_POPUP | WS_CHILD)) == WS_CHILD)
+            (Window->Style & (WS_POPUP | WS_CHILD)) == WS_CHILD)
       {
          return ThreadQueue ? 0 : ThreadQueue->ActiveWindow;
       }
@@ -310,8 +311,8 @@ co_IntSetActiveWindow(PWINDOW_OBJECT Window OPTIONAL)
    co_IntSendDeactivateMessages(hWndPrev, hWnd);
    co_IntSendActivateMessages(hWndPrev, hWnd, FALSE);
 
-/* FIXME */
-/*   return IntIsWindow(hWndPrev) ? hWndPrev : 0;*/
+   /* FIXME */
+   /*   return IntIsWindow(hWndPrev) ? hWndPrev : 0;*/
    return hWndPrev;
 }
 
@@ -346,7 +347,7 @@ HWND FASTCALL
 UserGetForegroundWindow(VOID)
 {
    PUSER_MESSAGE_QUEUE ForegroundQueue;
-   
+
    ForegroundQueue = IntGetFocusMessageQueue();
    return( ForegroundQueue != NULL ? ForegroundQueue->ActiveWindow : 0);
 }
@@ -359,12 +360,12 @@ HWND STDCALL
 NtUserGetForegroundWindow(VOID)
 {
    DECLARE_RETURN(HWND);
-   
+
    DPRINT("Enter NtUserGetForegroundWindow\n");
    UserEnterExclusive();
-   
+
    RETURN( UserGetForegroundWindow());
-   
+
 CLEANUP:
    DPRINT("Leave NtUserGetForegroundWindow, ret=%i\n",_ret_);
    UserLeave();
@@ -387,12 +388,12 @@ HWND STDCALL
 NtUserGetActiveWindow(VOID)
 {
    DECLARE_RETURN(HWND);
-   
+
    DPRINT("Enter NtUserGetActiveWindow\n");
    UserEnterShared();
-   
+
    RETURN( UserGetActiveWindow());
-   
+
 CLEANUP:
    DPRINT("Leave NtUserGetActiveWindow, ret=%i\n",_ret_);
    UserLeave();
@@ -438,7 +439,7 @@ NtUserSetActiveWindow(HWND hWnd)
    {
       RETURN( co_IntSetActiveWindow(0));
    }
-   
+
 CLEANUP:
    DPRINT("Leave NtUserSetActiveWindow, ret=%i\n",_ret_);
    UserLeave();
@@ -455,11 +456,11 @@ NtUserGetCapture(VOID)
 
    DPRINT("Enter NtUserGetCapture\n");
    UserEnterShared();
-   
+
    PUSER_MESSAGE_QUEUE ThreadQueue;
    ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
    RETURN( ThreadQueue ? ThreadQueue->CaptureWindow : 0);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserGetCapture, ret=%i\n",_ret_);
    UserLeave();
@@ -481,7 +482,7 @@ NtUserSetCapture(HWND hWnd)
    UserEnterExclusive();
 
    ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-   
+
    if((Window = UserGetWindowObject(hWnd)))
    {
       if(Window->MessageQueue != ThreadQueue)
@@ -489,21 +490,21 @@ NtUserSetCapture(HWND hWnd)
          RETURN(NULL);
       }
    }
-   
+
    hWndPrev = MsqSetStateWindow(ThreadQueue, MSQ_STATE_CAPTURE, hWnd);
 
    /* also remove other windows if not capturing anymore */
    if(hWnd == NULL)
    {
-     MsqSetStateWindow(ThreadQueue, MSQ_STATE_MENUOWNER, NULL);
-     MsqSetStateWindow(ThreadQueue, MSQ_STATE_MOVESIZE, NULL);
+      MsqSetStateWindow(ThreadQueue, MSQ_STATE_MENUOWNER, NULL);
+      MsqSetStateWindow(ThreadQueue, MSQ_STATE_MOVESIZE, NULL);
    }
 
    co_IntPostOrSendMessage(hWndPrev, WM_CAPTURECHANGED, 0, (LPARAM)hWnd);
    ThreadQueue->CaptureWindow = hWnd;
 
    RETURN( hWndPrev);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserSetCapture, ret=%i\n",_ret_);
    UserLeave();
@@ -570,7 +571,7 @@ NtUserSetFocus(HWND hWnd)
    UserEnterExclusive();
 
    RETURN(UserSetFocus(hWnd));
-   
+
 CLEANUP:
    DPRINT("Leave NtUserSetFocus, ret=%i\n",_ret_);
    UserLeave();
index a071e71..c80b822 100644 (file)
@@ -48,9 +48,9 @@ static FAST_MUTEX GuiSwitchLock;
 static BOOL FASTCALL
 co_AddGuiApp(PW32PROCESS W32Data)
 {
-  W32Data->Flags |= W32PF_CREATEDWINORDC;
-  if (InterlockedIncrement(&NrGuiAppsRunning) == 1)
-    {
+   W32Data->Flags |= W32PF_CREATEDWINORDC;
+   if (InterlockedIncrement(&NrGuiAppsRunning) == 1)
+   {
       BOOL Initialized;
 
       ExAcquireFastMutex(&GuiSwitchLock);
@@ -58,89 +58,89 @@ co_AddGuiApp(PW32PROCESS W32Data)
       ExReleaseFastMutex(&GuiSwitchLock);
 
       if (!Initialized)
-        {
-          W32Data->Flags &= ~W32PF_CREATEDWINORDC;
-          InterlockedDecrement(&NrGuiAppsRunning);
-          return FALSE;
-        }
-    }
-  return TRUE;
+      {
+         W32Data->Flags &= ~W32PF_CREATEDWINORDC;
+         InterlockedDecrement(&NrGuiAppsRunning);
+         return FALSE;
+      }
+   }
+   return TRUE;
 }
 
 static void FASTCALL
 RemoveGuiApp(PW32PROCESS W32Data)
 {
-  W32Data->Flags &= ~W32PF_CREATEDWINORDC;
-  if (InterlockedDecrement(&NrGuiAppsRunning) == 0)
-    {
+   W32Data->Flags &= ~W32PF_CREATEDWINORDC;
+   if (InterlockedDecrement(&NrGuiAppsRunning) == 0)
+   {
       ExAcquireFastMutex(&GuiSwitchLock);
       IntEndDesktopGraphics();
       ExReleaseFastMutex(&GuiSwitchLock);
-    }
+   }
 }
 
 BOOL FASTCALL
 co_IntGraphicsCheck(BOOL Create)
 {
-  PW32PROCESS W32Data;
+   PW32PROCESS W32Data;
 
-  W32Data = PsGetWin32Process();
-  if (Create)
-    {
+   W32Data = PsGetWin32Process();
+   if (Create)
+   {
       if (! (W32Data->Flags & W32PF_CREATEDWINORDC) && ! (W32Data->Flags & W32PF_MANUALGUICHECK))
-        {
-          return co_AddGuiApp(W32Data);
-        }
-    }
-  else
-    {
+      {
+         return co_AddGuiApp(W32Data);
+      }
+   }
+   else
+   {
       if ((W32Data->Flags & W32PF_CREATEDWINORDC) && ! (W32Data->Flags & W32PF_MANUALGUICHECK))
-        {
-          RemoveGuiApp(W32Data);
-        }
-    }
+      {
+         RemoveGuiApp(W32Data);
+      }
+   }
 
-  return TRUE;
+   return TRUE;
 }
 
 VOID STDCALL
 NtUserManualGuiCheck(LONG Check)
 {
-  PW32PROCESS W32Data;
-  
-  DPRINT("Enter NtUserManualGuiCheck\n");
-  UserEnterExclusive();
-
-  W32Data = PsGetWin32Process();
-  if (0 == Check)
-    {
+   PW32PROCESS W32Data;
+
+   DPRINT("Enter NtUserManualGuiCheck\n");
+   UserEnterExclusive();
+
+   W32Data = PsGetWin32Process();
+   if (0 == Check)
+   {
       W32Data->Flags |= W32PF_MANUALGUICHECK;
-    }
-  else if (0 < Check)
-    {
+   }
+   else if (0 < Check)
+   {
       if (! (W32Data->Flags & W32PF_CREATEDWINORDC))
-        {
-          co_AddGuiApp(W32Data);
-        }
-    }
-  else
-    {
+      {
+         co_AddGuiApp(W32Data);
+      }
+   }
+   else
+   {
       if (W32Data->Flags & W32PF_CREATEDWINORDC)
-        {
-          RemoveGuiApp(W32Data);
-        }
-    }
-
-  DPRINT("Leave NtUserManualGuiCheck\n");    
-  UserLeave();
-    
+      {
+         RemoveGuiApp(W32Data);
+      }
+   }
+
+   DPRINT("Leave NtUserManualGuiCheck\n");
+   UserLeave();
+
 }
 
 NTSTATUS FASTCALL
 InitGuiCheckImpl (VOID)
 {
-  ExInitializeFastMutex(&GuiSwitchLock);
-  return STATUS_SUCCESS;
+   ExInitializeFastMutex(&GuiSwitchLock);
+   return STATUS_SUCCESS;
 }
 
 /* EOF */
index 9cca7b4..79b8185 100644 (file)
@@ -42,37 +42,37 @@ STATIC PHOOKTABLE GlobalHooks;
 STATIC FASTCALL PHOOKTABLE
 IntAllocHookTable(void)
 {
-  PHOOKTABLE Table;
-  UINT i;
+   PHOOKTABLE Table;
+   UINT i;
 
-  Table = ExAllocatePoolWithTag(PagedPool, sizeof(HOOKTABLE), TAG_HOOK);
-  if (NULL != Table)
-    {
+   Table = ExAllocatePoolWithTag(PagedPool, sizeof(HOOKTABLE), TAG_HOOK);
+   if (NULL != Table)
+   {
       for (i = 0; i < NB_HOOKS; i++)
-        {
-          InitializeListHead(&Table->Hooks[i]);
-          Table->Counts[i] = 0;
-        }
-    }
+      {
+         InitializeListHead(&Table->Hooks[i]);
+         Table->Counts[i] = 0;
+      }
+   }
 
-  return Table;
+   return Table;
 }
 
 
 PHOOK FASTCALL IntGetHookObject(HHOOK hWnd)
 {
-   
+
    PHOOK Window = (PHOOK)UserGetObject(&gHandleTable, hWnd, otHook);
    if (!Window)
    {
       SetLastWin32Error(ERROR_INVALID_HOOK_HANDLE);
       return NULL;
    }
-   
+
    ASSERT(USER_BODY_TO_HEADER(Window)->RefCount >= 0);
-   
+
    USER_BODY_TO_HEADER(Window)->RefCount++;
-   
+
    return Window;
 }
 
@@ -82,669 +82,670 @@ PHOOK FASTCALL IntGetHookObject(HHOOK hWnd)
 STATIC FASTCALL PHOOK
 IntAddHook(PETHREAD Thread, int HookId, BOOLEAN Global, PWINSTATION_OBJECT WinStaObj)
 {
-  PHOOK Hook;
-  PHOOKTABLE Table = Global ? GlobalHooks : MsqGetHooks(Thread->Tcb.Win32Thread->MessageQueue);
-  HANDLE Handle;
+   PHOOK Hook;
+   PHOOKTABLE Table = Global ? GlobalHooks : MsqGetHooks(Thread->Tcb.Win32Thread->MessageQueue);
+   HANDLE Handle;
 
-  if (NULL == Table)
-    {
+   if (NULL == Table)
+   {
       Table = IntAllocHookTable();
       if (NULL == Table)
-        {
-          return NULL;
-        }
+      {
+         return NULL;
+      }
       if (Global)
-        {
-          GlobalHooks = Table;
-        }
+      {
+         GlobalHooks = Table;
+      }
       else
-        {
-          MsqSetHooks(Thread->Tcb.Win32Thread->MessageQueue, Table);
-        }
-    }
-
-  Hook = ObmCreateObject(&gHandleTable, &Handle, otHook, sizeof(HOOK));
-  if (NULL == Hook)
-    {
+      {
+         MsqSetHooks(Thread->Tcb.Win32Thread->MessageQueue, Table);
+      }
+   }
+
+   Hook = ObmCreateObject(&gHandleTable, &Handle, otHook, sizeof(HOOK));
+   if (NULL == Hook)
+   {
       return NULL;
-    }
+   }
 
-  Hook->Self = Handle;
-  Hook->Thread = Thread;
-  Hook->HookId = HookId;
-  RtlInitUnicodeString(&Hook->ModuleName, NULL);
+   Hook->Self = Handle;
+   Hook->Thread = Thread;
+   Hook->HookId = HookId;
+   RtlInitUnicodeString(&Hook->ModuleName, NULL);
 
-  InsertHeadList(&Table->Hooks[HOOKID_TO_INDEX(HookId)], &Hook->Chain);
+   InsertHeadList(&Table->Hooks[HOOKID_TO_INDEX(HookId)], &Hook->Chain);
 
-  return Hook;
+   return Hook;
 }
 
 /* get the hook table that a given hook belongs to */
 STATIC PHOOKTABLE FASTCALL
 IntGetTable(PHOOK Hook)
 {
-  if (NULL == Hook->Thread || WH_KEYBOARD_LL == Hook->HookId ||
-      WH_MOUSE_LL == Hook->HookId)
-    {
+   if (NULL == Hook->Thread || WH_KEYBOARD_LL == Hook->HookId ||
+         WH_MOUSE_LL == Hook->HookId)
+   {
       return GlobalHooks;
-    }
+   }
 
-  return MsqGetHooks(Hook->Thread->Tcb.Win32Thread->MessageQueue);
+   return MsqGetHooks(Hook->Thread->Tcb.Win32Thread->MessageQueue);
 }
 
 /* get the first hook in the chain */
 STATIC PHOOK FASTCALL
 IntGetFirstHook(PHOOKTABLE Table, int HookId)
 {
-  PLIST_ENTRY Elem = Table->Hooks[HOOKID_TO_INDEX(HookId)].Flink;
-  return Elem == &Table->Hooks[HOOKID_TO_INDEX(HookId)]
-         ? NULL : CONTAINING_RECORD(Elem, HOOK, Chain);
+   PLIST_ENTRY Elem = Table->Hooks[HOOKID_TO_INDEX(HookId)].Flink;
+   return Elem == &Table->Hooks[HOOKID_TO_INDEX(HookId)]
+          ? NULL : CONTAINING_RECORD(Elem, HOOK, Chain);
 }
 
 /* find the first non-deleted hook in the chain */
 STATIC PHOOK FASTCALL
 IntGetFirstValidHook(PHOOKTABLE Table, int HookId)
 {
-  PHOOK Hook;
-  PLIST_ENTRY Elem;
+   PHOOK Hook;
+   PLIST_ENTRY Elem;
 
-  Hook = IntGetFirstHook(Table, HookId);
-  while (NULL != Hook && NULL == Hook->Proc)
-    {
+   Hook = IntGetFirstHook(Table, HookId);
+   while (NULL != Hook && NULL == Hook->Proc)
+   {
       Elem = Hook->Chain.Flink;
       Hook = (Elem == &Table->Hooks[HOOKID_TO_INDEX(HookId)]
               ? NULL : CONTAINING_RECORD(Elem, HOOK, Chain));
-    }
+   }
 
-  return Hook;
+   return Hook;
 }
 
 /* find the next hook in the chain, skipping the deleted ones */
 STATIC PHOOK FASTCALL
 IntGetNextHook(PHOOK Hook)
 {
-  PHOOKTABLE Table = IntGetTable(Hook);
-  int HookId = Hook->HookId;
-  PLIST_ENTRY Elem;
+   PHOOKTABLE Table = IntGetTable(Hook);
+   int HookId = Hook->HookId;
+   PLIST_ENTRY Elem;
 
-  Elem = Hook->Chain.Flink;
-  while (Elem != &Table->Hooks[HOOKID_TO_INDEX(HookId)])
-    {
+   Elem = Hook->Chain.Flink;
+   while (Elem != &Table->Hooks[HOOKID_TO_INDEX(HookId)])
+   {
       Hook = CONTAINING_RECORD(Elem, HOOK, Chain);
       if (NULL != Hook->Proc)
-        {
-          return Hook;
-        }
-    }
+      {
+         return Hook;
+      }
+   }
 
-  if (NULL != GlobalHooks && Table != GlobalHooks)  /* now search through the global table */
-    {
+   if (NULL != GlobalHooks && Table != GlobalHooks)  /* now search through the global table */
+   {
       return IntGetFirstValidHook(GlobalHooks, HookId);
-    }
+   }
 
-  return NULL;
+   return NULL;
 }
 
 /* free a hook, removing it from its chain */
 STATIC VOID FASTCALL
 IntFreeHook(PHOOKTABLE Table, PHOOK Hook, PWINSTATION_OBJECT WinStaObj)
 {
-  RemoveEntryList(&Hook->Chain);
-  RtlFreeUnicodeString(&Hook->ModuleName);
+   RemoveEntryList(&Hook->Chain);
+   RtlFreeUnicodeString(&Hook->ModuleName);
 
-  /* Dereference thread if required */
-  if (Hook->Flags & HOOK_THREAD_REFERENCED)
-    {
+   /* Dereference thread if required */
+   if (Hook->Flags & HOOK_THREAD_REFERENCED)
+   {
       ObDereferenceObject(Hook->Thread);
-    }
+   }
 
-  /* Close handle */
-  ObmDeleteObject(Hook->Self, otHook);
+   /* Close handle */
+   ObmDeleteObject(Hook->Self, otHook);
 }
 
 /* remove a hook, freeing it if the chain is not in use */
 STATIC FASTCALL VOID
 IntRemoveHook(PHOOK Hook, PWINSTATION_OBJECT WinStaObj, BOOL TableAlreadyLocked)
 {
-  PHOOKTABLE Table = IntGetTable(Hook);
+   PHOOKTABLE Table = IntGetTable(Hook);
 
-  ASSERT(NULL != Table);
-  if (NULL == Table)
-    {
+   ASSERT(NULL != Table);
+   if (NULL == Table)
+   {
       return;
-    }
+   }
 
-  if (0 != Table->Counts[HOOKID_TO_INDEX(Hook->HookId)])
-    {
+   if (0 != Table->Counts[HOOKID_TO_INDEX(Hook->HookId)])
+   {
       Hook->Proc = NULL; /* chain is in use, just mark it and return */
-    }
-  else
-    {
+   }
+   else
+   {
       IntFreeHook(Table, Hook, WinStaObj);
-    }
+   }
 }
 
 /* release a hook chain, removing deleted hooks if the use count drops to 0 */
 STATIC VOID FASTCALL
 IntReleaseHookChain(PHOOKTABLE Table, int HookId, PWINSTATION_OBJECT WinStaObj)
 {
-  PLIST_ENTRY Elem;
-  PHOOK HookObj;
+   PLIST_ENTRY Elem;
+   PHOOK HookObj;
 
-  if (NULL == Table)
-    {
+   if (NULL == Table)
+   {
       return;
-    }
+   }
 
-  /* use count shouldn't already be 0 */
-  ASSERT(0 != Table->Counts[HOOKID_TO_INDEX(HookId)]);
-  if (0 == Table->Counts[HOOKID_TO_INDEX(HookId)])
-    {
+   /* use count shouldn't already be 0 */
+   ASSERT(0 != Table->Counts[HOOKID_TO_INDEX(HookId)]);
+   if (0 == Table->Counts[HOOKID_TO_INDEX(HookId)])
+   {
       return;
-    }
-  if (0 == --Table->Counts[HOOKID_TO_INDEX(HookId)])
-    {
+   }
+   if (0 == --Table->Counts[HOOKID_TO_INDEX(HookId)])
+   {
       Elem = Table->Hooks[HOOKID_TO_INDEX(HookId)].Flink;
       while (Elem != &Table->Hooks[HOOKID_TO_INDEX(HookId)])
-        {
-          HookObj = CONTAINING_RECORD(Elem, HOOK, Chain);
-          Elem = Elem->Flink;
-          if (NULL == HookObj->Proc)
-            {
-              IntFreeHook(Table, HookObj, WinStaObj);
-            }
-        }
-    }
+      {
+         HookObj = CONTAINING_RECORD(Elem, HOOK, Chain);
+         Elem = Elem->Flink;
+         if (NULL == HookObj->Proc)
+         {
+            IntFreeHook(Table, HookObj, WinStaObj);
+         }
+      }
+   }
 }
 
 static LRESULT FASTCALL
 IntCallLowLevelHook(INT HookId, INT Code, WPARAM wParam, LPARAM lParam, PHOOK Hook)
 {
-  NTSTATUS Status;
-  ULONG_PTR uResult;
+   NTSTATUS Status;
+   ULONG_PTR uResult;
 
-  /* FIXME should get timeout from
-   * HKEY_CURRENT_USER\Control Panel\Desktop\LowLevelHooksTimeout */
-  Status = co_MsqSendMessage(Hook->Thread->Tcb.Win32Thread->MessageQueue, (HWND) Code, HookId,
-                          wParam, lParam, 5000, TRUE, TRUE, &uResult);
+   /* FIXME should get timeout from
+    * HKEY_CURRENT_USER\Control Panel\Desktop\LowLevelHooksTimeout */
+   Status = co_MsqSendMessage(Hook->Thread->Tcb.Win32Thread->MessageQueue, (HWND) Code, HookId,
+                              wParam, lParam, 5000, TRUE, TRUE, &uResult);
 
-  return NT_SUCCESS(Status) ? uResult : 0;
+   return NT_SUCCESS(Status) ? uResult : 0;
 }
 
 LRESULT FASTCALL
 co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
 {
-  PHOOK Hook;
-  PW32THREAD Win32Thread;
-  PHOOKTABLE Table;
-  LRESULT Result;
-  PWINSTATION_OBJECT WinStaObj;
-  NTSTATUS Status;
-
-  ASSERT(WH_MINHOOK <= HookId && HookId <= WH_MAXHOOK);
-
-  Win32Thread = PsGetWin32Thread();
-  if (NULL == Win32Thread)
-    {
+   PHOOK Hook;
+   PW32THREAD Win32Thread;
+   PHOOKTABLE Table;
+   LRESULT Result;
+   PWINSTATION_OBJECT WinStaObj;
+   NTSTATUS Status;
+
+   ASSERT(WH_MINHOOK <= HookId && HookId <= WH_MAXHOOK);
+
+   Win32Thread = PsGetWin32Thread();
+   if (NULL == Win32Thread)
+   {
       Table = NULL;
-    }
-  else
-    {
+   }
+   else
+   {
       Table = MsqGetHooks(Win32Thread->MessageQueue);
-    }
+   }
 
-  if (NULL == Table || ! (Hook = IntGetFirstValidHook(Table, HookId)))
-    {
+   if (NULL == Table || ! (Hook = IntGetFirstValidHook(Table, HookId)))
+   {
       /* try global table */
       Table = GlobalHooks;
       if (NULL == Table || ! (Hook = IntGetFirstValidHook(Table, HookId)))
-        {
-          return 0;  /* no hook set */
-        }
-    }
-
-  if (Hook->Thread != PsGetCurrentThread()
-      && (WH_KEYBOARD_LL == HookId || WH_MOUSE_LL == HookId))
-    {
+      {
+         return 0;  /* no hook set */
+      }
+   }
+
+   if (Hook->Thread != PsGetCurrentThread()
+         && (WH_KEYBOARD_LL == HookId || WH_MOUSE_LL == HookId))
+   {
       DPRINT("Calling hook in owning thread\n");
       return IntCallLowLevelHook(HookId, Code, wParam, lParam, Hook);
-    }
+   }
 
-  if (Hook->Thread != PsGetCurrentThread())
-    {
+   if (Hook->Thread != PsGetCurrentThread())
+   {
       DPRINT1("Calling hooks in other threads not implemented yet");
       return 0;
-    }
+   }
 
-  Table->Counts[HOOKID_TO_INDEX(HookId)]++;
-  if (Table != GlobalHooks && GlobalHooks != NULL)
-    {
+   Table->Counts[HOOKID_TO_INDEX(HookId)]++;
+   if (Table != GlobalHooks && GlobalHooks != NULL)
+   {
       GlobalHooks->Counts[HOOKID_TO_INDEX(HookId)]++;
-    }
+   }
 
-  Result = co_IntCallHookProc(HookId, Code, wParam, lParam, Hook->Proc,
-                           Hook->Ansi, &Hook->ModuleName);
+   Result = co_IntCallHookProc(HookId, Code, wParam, lParam, Hook->Proc,
+                               Hook->Ansi, &Hook->ModuleName);
 
-  Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
-                                         KernelMode,
-                                         0,
-                                         &WinStaObj);
+   Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
+                                           KernelMode,
+                                           0,
+                                           &WinStaObj);
 
-  if (! NT_SUCCESS(Status))
-    {
+   if (! NT_SUCCESS(Status))
+   {
       DPRINT1("Invalid window station????\n");
-    }
-  else
-    {
+   }
+   else
+   {
       IntReleaseHookChain(MsqGetHooks(PsGetWin32Thread()->MessageQueue), HookId, WinStaObj);
       IntReleaseHookChain(GlobalHooks, HookId, WinStaObj);
       ObDereferenceObject(WinStaObj);
-    }
+   }
 
-  return Result;
+   return Result;
 }
 
 VOID FASTCALL
 HOOK_DestroyThreadHooks(PETHREAD Thread)
 {
-  int HookId;
-  PLIST_ENTRY Elem;
-  PHOOK HookObj;
-  PWINSTATION_OBJECT WinStaObj;
-  NTSTATUS Status;
-
-  if (NULL != GlobalHooks)
-    {
+   int HookId;
+   PLIST_ENTRY Elem;
+   PHOOK HookObj;
+   PWINSTATION_OBJECT WinStaObj;
+   NTSTATUS Status;
+
+   if (NULL != GlobalHooks)
+   {
       Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
                                               KernelMode,
                                               0,
                                               &WinStaObj);
 
       if (! NT_SUCCESS(Status))
-        {
-          DPRINT1("Invalid window station????\n");
-          return;
-        }
+      {
+         DPRINT1("Invalid window station????\n");
+         return;
+      }
 
       for (HookId = WH_MINHOOK; HookId <= WH_MAXHOOK; HookId++)
-        {
-          /* only low-level keyboard/mouse global hooks can be owned by a thread */
-          switch(HookId)
-            {
+      {
+         /* only low-level keyboard/mouse global hooks can be owned by a thread */
+         switch(HookId)
+         {
             case WH_KEYBOARD_LL:
             case WH_MOUSE_LL:
-              Elem = GlobalHooks->Hooks[HOOKID_TO_INDEX(HookId)].Flink;
-              while (Elem != &GlobalHooks->Hooks[HOOKID_TO_INDEX(HookId)])
-                {
+               Elem = GlobalHooks->Hooks[HOOKID_TO_INDEX(HookId)].Flink;
+               while (Elem != &GlobalHooks->Hooks[HOOKID_TO_INDEX(HookId)])
+               {
                   HookObj = CONTAINING_RECORD(Elem, HOOK, Chain);
                   Elem = Elem->Flink;
                   if (HookObj->Thread == Thread)
-                    {
-                      IntRemoveHook(HookObj, WinStaObj, TRUE);
-                    }
-                }
-              break;
-            }
-        }
+                  {
+                     IntRemoveHook(HookObj, WinStaObj, TRUE);
+                  }
+               }
+               break;
+         }
+      }
 
       ObDereferenceObject(WinStaObj);
-    }
+   }
 }
 
 LRESULT
 STDCALL
 NtUserCallNextHookEx(
-  HHOOK Hook,
-  int Code,
-  WPARAM wParam,
-  LPARAM lParam)
+   HHOOK Hook,
+   int Code,
+   WPARAM wParam,
+   LPARAM lParam)
 {
-  PHOOK HookObj, NextObj;
-  PWINSTATION_OBJECT WinStaObj;
-  NTSTATUS Status;
-  DECLARE_RETURN(LRESULT);
+   PHOOK HookObj, NextObj;
+   PWINSTATION_OBJECT WinStaObj;
+   NTSTATUS Status;
+   DECLARE_RETURN(LRESULT);
 
-  DPRINT("Enter NtUserCallNextHookEx\n");
-  UserEnterExclusive();
+   DPRINT("Enter NtUserCallNextHookEx\n");
+   UserEnterExclusive();
 
-  Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
-                                         KernelMode,
-                                         0,
-                                         &WinStaObj);
+   Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
+                                           KernelMode,
+                                           0,
+                                           &WinStaObj);
 
-  if (! NT_SUCCESS(Status))
-    {
+   if (! NT_SUCCESS(Status))
+   {
       SetLastNtError(Status);
       RETURN( FALSE);
-    }
-
-  //Status = ObmReferenceObjectByHandle(gHandleTable, Hook,
-        //                             otHookProc, (PVOID *) &HookObj);
-  ObDereferenceObject(WinStaObj);
-  
-//  if (! NT_SUCCESS(Status))
-//    {
-//      DPRINT1("Invalid handle passed to NtUserCallNextHookEx\n");
-//      SetLastNtError(Status);
-//      RETURN( 0);
-//    }
-
-  if (!(HookObj = IntGetHookObject(Hook)))
-  {
-     RETURN(0);
-  }
-    
-  ASSERT(Hook == HookObj->Self);
-
-  if (NULL != HookObj->Thread && (HookObj->Thread != PsGetCurrentThread()))
-    {
+   }
+
+   //Status = ObmReferenceObjectByHandle(gHandleTable, Hook,
+   //                             otHookProc, (PVOID *) &HookObj);
+   ObDereferenceObject(WinStaObj);
+
+   //  if (! NT_SUCCESS(Status))
+   //    {
+   //      DPRINT1("Invalid handle passed to NtUserCallNextHookEx\n");
+   //      SetLastNtError(Status);
+   //      RETURN( 0);
+   //    }
+
+   if (!(HookObj = IntGetHookObject(Hook)))
+   {
+      RETURN(0);
+   }
+
+   ASSERT(Hook == HookObj->Self);
+
+   if (NULL != HookObj->Thread && (HookObj->Thread != PsGetCurrentThread()))
+   {
       DPRINT1("Thread mismatch\n");
       ObmDereferenceObject(HookObj);
       SetLastWin32Error(ERROR_INVALID_HANDLE);
       RETURN( 0);
-    }
+   }
 
-  NextObj = IntGetNextHook(HookObj);
-  ObmDereferenceObject(HookObj);
-  if (NULL != NextObj)
-    {
+   NextObj = IntGetNextHook(HookObj);
+   ObmDereferenceObject(HookObj);
+   if (NULL != NextObj)
+   {
       DPRINT1("Calling next hook not implemented\n");
       UNIMPLEMENTED
       SetLastWin32Error(ERROR_NOT_SUPPORTED);
       RETURN( 0);
-    }
+   }
+
+   RETURN( 0);
 
-  RETURN( 0);
-  
 CLEANUP:
-  DPRINT("Leave NtUserCallNextHookEx, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserCallNextHookEx, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 DWORD
 STDCALL
 NtUserSetWindowsHookAW(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 HHOOK
 STDCALL
 NtUserSetWindowsHookEx(
-  HINSTANCE Mod,
-  PUNICODE_STRING UnsafeModuleName,
-  DWORD ThreadId,
-  int HookId,
-  HOOKPROC HookProc,
-  BOOL Ansi)
+   HINSTANCE Mod,
+   PUNICODE_STRING UnsafeModuleName,
+   DWORD ThreadId,
+   int HookId,
+   HOOKPROC HookProc,
+   BOOL Ansi)
 {
-  PWINSTATION_OBJECT WinStaObj;
-  BOOLEAN Global;
-  PETHREAD Thread;
-  PHOOK Hook;
-  UNICODE_STRING ModuleName;
-  NTSTATUS Status;
-  HHOOK Handle;
-  DECLARE_RETURN(HHOOK);
-
-  DPRINT("Enter NtUserSetWindowsHookEx\n");
-  UserEnterExclusive();
-
-  if (HookId < WH_MINHOOK || WH_MAXHOOK < HookId || NULL == HookProc)
-    {
+   PWINSTATION_OBJECT WinStaObj;
+   BOOLEAN Global;
+   PETHREAD Thread;
+   PHOOK Hook;
+   UNICODE_STRING ModuleName;
+   NTSTATUS Status;
+   HHOOK Handle;
+   DECLARE_RETURN(HHOOK);
+
+   DPRINT("Enter NtUserSetWindowsHookEx\n");
+   UserEnterExclusive();
+
+   if (HookId < WH_MINHOOK || WH_MAXHOOK < HookId || NULL == HookProc)
+   {
       SetLastWin32Error(ERROR_INVALID_PARAMETER);
       RETURN( NULL);
-    }
+   }
 
-  if (ThreadId)  /* thread-local hook */
-    {
+   if (ThreadId)  /* thread-local hook */
+   {
       if (HookId == WH_JOURNALRECORD ||
-          HookId == WH_JOURNALPLAYBACK ||
-          HookId == WH_KEYBOARD_LL ||
-          HookId == WH_MOUSE_LL ||
-          HookId == WH_SYSMSGFILTER)
-        {
-          /* these can only be global */
-          SetLastWin32Error(ERROR_INVALID_PARAMETER);
-          RETURN( NULL);
-        }
+            HookId == WH_JOURNALPLAYBACK ||
+            HookId == WH_KEYBOARD_LL ||
+            HookId == WH_MOUSE_LL ||
+            HookId == WH_SYSMSGFILTER)
+      {
+         /* these can only be global */
+         SetLastWin32Error(ERROR_INVALID_PARAMETER);
+         RETURN( NULL);
+      }
       Mod = NULL;
       Global = FALSE;
       if (! NT_SUCCESS(PsLookupThreadByThreadId((HANDLE) ThreadId, &Thread)))
-        {
-          DPRINT1("Invalid thread id 0x%x\n", ThreadId);
-          SetLastWin32Error(ERROR_INVALID_PARAMETER);
-          RETURN( NULL);
-        }
+      {
+         DPRINT1("Invalid thread id 0x%x\n", ThreadId);
+         SetLastWin32Error(ERROR_INVALID_PARAMETER);
+         RETURN( NULL);
+      }
       if (Thread->ThreadsProcess != PsGetCurrentProcess())
-        {
-          ObDereferenceObject(Thread);
-          DPRINT1("Can't specify thread belonging to another process\n");
-          SetLastWin32Error(ERROR_INVALID_PARAMETER);
-          RETURN( NULL);
-        }
-    }
-  else  /* system-global hook */
-    {
+      {
+         ObDereferenceObject(Thread);
+         DPRINT1("Can't specify thread belonging to another process\n");
+         SetLastWin32Error(ERROR_INVALID_PARAMETER);
+         RETURN( NULL);
+      }
+   }
+   else  /* system-global hook */
+   {
       if (HookId == WH_KEYBOARD_LL || HookId == WH_MOUSE_LL)
-        {
-          Mod = NULL;
-          Thread = PsGetCurrentThread();
-          Status = ObReferenceObjectByPointer(Thread,
-                                             THREAD_ALL_ACCESS,
-                                             PsThreadType,
-                                             KernelMode);
-
-          if (! NT_SUCCESS(Status))
-            {
-              SetLastNtError(Status);
-              RETURN( (HANDLE) NULL);
-            }
-        }
+      {
+         Mod = NULL;
+         Thread = PsGetCurrentThread();
+         Status = ObReferenceObjectByPointer(Thread,
+                                             THREAD_ALL_ACCESS,
+                                             PsThreadType,
+                                             KernelMode);
+
+         if (! NT_SUCCESS(Status))
+         {
+            SetLastNtError(Status);
+            RETURN( (HANDLE) NULL);
+         }
+      }
       else if (NULL ==  Mod)
-        {
-          SetLastWin32Error(ERROR_INVALID_PARAMETER);
-          RETURN( NULL);
-        }
+      {
+         SetLastWin32Error(ERROR_INVALID_PARAMETER);
+         RETURN( NULL);
+      }
       else
-        {
-          Thread = NULL;
-        }
+      {
+         Thread = NULL;
+      }
       Global = TRUE;
-    }
+   }
 
-  /* We only (partially) support local WH_CBT hooks and
-   * WH_KEYBOARD_LL/WH_MOUSE_LL hooks for now */
-  if ((WH_CBT != HookId || Global)
-      && WH_KEYBOARD_LL != HookId && WH_MOUSE_LL != HookId)
-    {
+   /* We only (partially) support local WH_CBT hooks and
+    * WH_KEYBOARD_LL/WH_MOUSE_LL hooks for now */
+   if ((WH_CBT != HookId || Global)
+         && WH_KEYBOARD_LL != HookId && WH_MOUSE_LL != HookId)
+   {
 #if 0 /* Removed to get winEmbed working again */
       UNIMPLEMENTED
 #else
       DPRINT1("Not implemented: HookId %d Global %s\n", HookId, Global ? "TRUE" : "FALSE");
 #endif
+
       if (NULL != Thread)
-        {
-          ObDereferenceObject(Thread);
-        }
+      {
+         ObDereferenceObject(Thread);
+      }
       SetLastWin32Error(ERROR_NOT_SUPPORTED);
       RETURN( NULL);
-    }
+   }
 
-  Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
-                                         KernelMode,
-                                         0,
-                                         &WinStaObj);
+   Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
+                                           KernelMode,
+                                           0,
+                                           &WinStaObj);
 
-  if (! NT_SUCCESS(Status))
-    {
+   if (! NT_SUCCESS(Status))
+   {
       if (NULL != Thread)
-        {
-          ObDereferenceObject(Thread);
-        }
+      {
+         ObDereferenceObject(Thread);
+      }
       SetLastNtError(Status);
       RETURN( (HANDLE) NULL);
-    }
+   }
 
-  Hook = IntAddHook(Thread, HookId, Global, WinStaObj);
-  if (NULL == Hook)
-    {
+   Hook = IntAddHook(Thread, HookId, Global, WinStaObj);
+   if (NULL == Hook)
+   {
       if (NULL != Thread)
-        {
-          ObDereferenceObject(Thread);
-        }
+      {
+         ObDereferenceObject(Thread);
+      }
       ObDereferenceObject(WinStaObj);
       RETURN( NULL);
-    }
+   }
 
-  if (NULL != Thread)
-    {
-    Hook->Flags |= HOOK_THREAD_REFERENCED;
-    }
+   if (NULL != Thread)
+   {
+      Hook->Flags |= HOOK_THREAD_REFERENCED;
+   }
 
-  if (NULL != Mod)
-    {
+   if (NULL != Mod)
+   {
       Status = MmCopyFromCaller(&ModuleName, UnsafeModuleName, sizeof(UNICODE_STRING));
       if (! NT_SUCCESS(Status))
-        {
-          ObmDereferenceObject(Hook);
-          IntRemoveHook(Hook, WinStaObj, FALSE);
-          if (NULL != Thread)
-            {
-              ObDereferenceObject(Thread);
-            }
-          ObDereferenceObject(WinStaObj);
-          SetLastNtError(Status);
-          RETURN( NULL);
-        }
+      {
+         ObmDereferenceObject(Hook);
+         IntRemoveHook(Hook, WinStaObj, FALSE);
+         if (NULL != Thread)
+         {
+            ObDereferenceObject(Thread);
+         }
+         ObDereferenceObject(WinStaObj);
+         SetLastNtError(Status);
+         RETURN( NULL);
+      }
       Hook->ModuleName.Buffer = ExAllocatePoolWithTag(PagedPool,
-                                                      ModuleName.MaximumLength,
-                                                      TAG_HOOK);
+                                ModuleName.MaximumLength,
+                                TAG_HOOK);
       if (NULL == Hook->ModuleName.Buffer)
-        {
-          ObmDereferenceObject(Hook);
-          IntRemoveHook(Hook, WinStaObj, FALSE);
-          if (NULL != Thread)
-            {
-              ObDereferenceObject(Thread);
-            }
-          ObDereferenceObject(WinStaObj);
-          SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-          RETURN( NULL);
-        }
+      {
+         ObmDereferenceObject(Hook);
+         IntRemoveHook(Hook, WinStaObj, FALSE);
+         if (NULL != Thread)
+         {
+            ObDereferenceObject(Thread);
+         }
+         ObDereferenceObject(WinStaObj);
+         SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+         RETURN( NULL);
+      }
       Hook->ModuleName.MaximumLength = ModuleName.MaximumLength;
       Status = MmCopyFromCaller(Hook->ModuleName.Buffer,
-                               ModuleName.Buffer,
-                               ModuleName.MaximumLength);
+                                ModuleName.Buffer,
+                                ModuleName.MaximumLength);
       if (! NT_SUCCESS(Status))
-        {
-          ObmDereferenceObject(Hook);
-          IntRemoveHook(Hook, WinStaObj, FALSE);
-          if (NULL != Thread)
-            {
-              ObDereferenceObject(Thread);
-            }
-          ObDereferenceObject(WinStaObj);
-          SetLastNtError(Status);
-          RETURN( NULL);
-        }
+      {
+         ObmDereferenceObject(Hook);
+         IntRemoveHook(Hook, WinStaObj, FALSE);
+         if (NULL != Thread)
+         {
+            ObDereferenceObject(Thread);
+         }
+         ObDereferenceObject(WinStaObj);
+         SetLastNtError(Status);
+         RETURN( NULL);
+      }
       Hook->ModuleName.Length = ModuleName.Length;
-    }
+   }
+
+   Hook->Proc = HookProc;
+   Hook->Ansi = Ansi;
+   Handle = Hook->Self;
 
-  Hook->Proc = HookProc;
-  Hook->Ansi = Ansi;
-  Handle = Hook->Self;
+   ObmDereferenceObject(Hook);
+   ObDereferenceObject(WinStaObj);
 
-  ObmDereferenceObject(Hook);
-  ObDereferenceObject(WinStaObj);
+   RETURN( Handle);
 
-  RETURN( Handle);
-  
 CLEANUP:
-  DPRINT("Leave NtUserSetWindowsHookEx, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserSetWindowsHookEx, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 DWORD
 STDCALL
 NtUserSetWinEventHook(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5,
-  DWORD Unknown6,
-  DWORD Unknown7)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3,
+   DWORD Unknown4,
+   DWORD Unknown5,
+   DWORD Unknown6,
+   DWORD Unknown7)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 BOOL
 STDCALL
 NtUserUnhookWindowsHookEx(
-  HHOOK Hook)
+   HHOOK Hook)
 {
-  PWINSTATION_OBJECT WinStaObj;
-  PHOOK HookObj;
- NTSTATUS Status;
-  DECLARE_RETURN(BOOL);
+   PWINSTATION_OBJECT WinStaObj;
+   PHOOK HookObj;
  NTSTATUS Status;
+   DECLARE_RETURN(BOOL);
 
-  DPRINT("Enter NtUserUnhookWindowsHookEx\n");
-  UserEnterExclusive();
+   DPRINT("Enter NtUserUnhookWindowsHookEx\n");
+   UserEnterExclusive();
 
-  Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
-                                         KernelMode,
-                                         0,
-                                         &WinStaObj);
+   Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
+                                           KernelMode,
+                                           0,
+                                           &WinStaObj);
 
-  if (! NT_SUCCESS(Status))
-    {
+   if (! NT_SUCCESS(Status))
+   {
       SetLastNtError(Status);
       RETURN( FALSE);
-    }
+   }
 
-//  Status = ObmReferenceObjectByHandle(gHandleTable, Hook,
-//                                      otHookProc, (PVOID *) &HookObj);
-  if (!(HookObj = IntGetHookObject(Hook)))
-    {
+   //  Status = ObmReferenceObjectByHandle(gHandleTable, Hook,
+   //                                      otHookProc, (PVOID *) &HookObj);
+   if (!(HookObj = IntGetHookObject(Hook)))
+   {
       DPRINT1("Invalid handle passed to NtUserUnhookWindowsHookEx\n");
       ObDereferenceObject(WinStaObj);
-//      SetLastNtError(Status);
+      //      SetLastNtError(Status);
       RETURN( FALSE);
-    }
-  ASSERT(Hook == HookObj->Self);
+   }
+   ASSERT(Hook == HookObj->Self);
+
+   IntRemoveHook(HookObj, WinStaObj, FALSE);
 
-  IntRemoveHook(HookObj, WinStaObj, FALSE);
+   ObmDereferenceObject(HookObj);
+   ObDereferenceObject(WinStaObj);
 
-  ObmDereferenceObject(HookObj);
-  ObDereferenceObject(WinStaObj);
+   RETURN( TRUE);
 
-  RETURN( TRUE);
-  
 CLEANUP:
-  DPRINT("Leave NtUserUnhookWindowsHookEx, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserUnhookWindowsHookEx, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 DWORD
 STDCALL
 NtUserUnhookWinEvent(
-  DWORD Unknown0)
+   DWORD Unknown0)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 /* EOF */
index 60c3ce6..6da6f21 100644 (file)
 NTSTATUS FASTCALL
 InitHotKeys(PWINSTATION_OBJECT WinStaObject)
 {
-  InitializeListHead(&WinStaObject->HotKeyListHead);
-  ExInitializeFastMutex(&WinStaObject->HotKeyListLock);
+   InitializeListHead(&WinStaObject->HotKeyListHead);
+   ExInitializeFastMutex(&WinStaObject->HotKeyListLock);
 
-  return STATUS_SUCCESS;
+   return STATUS_SUCCESS;
 }
 
 
@@ -52,289 +52,289 @@ NTSTATUS FASTCALL
 CleanupHotKeys(PWINSTATION_OBJECT WinStaObject)
 {
 
-  return STATUS_SUCCESS;
+   return STATUS_SUCCESS;
 }
 
 
 BOOL
 GetHotKey (PWINSTATION_OBJECT WinStaObject,
-       UINT fsModifiers,
-          UINT vk,
-          struct _ETHREAD **Thread,
-          HWND *hWnd,
-          int *id)
+           UINT fsModifiers,
+           UINT vk,
+           struct _ETHREAD **Thread,
+           HWND *hWnd,
+           int *id)
 {
-  PLIST_ENTRY Entry;
-  PHOT_KEY_ITEM HotKeyItem;
+   PLIST_ENTRY Entry;
+   PHOT_KEY_ITEM HotKeyItem;
 
-  if(!WinStaObject)
-  {
-    return FALSE;
-  }
+   if(!WinStaObject)
+   {
+      return FALSE;
+   }
 
-  IntLockHotKeys(WinStaObject);
+   IntLockHotKeys(WinStaObject);
 
-  Entry = WinStaObject->HotKeyListHead.Flink;
-  while (Entry != &WinStaObject->HotKeyListHead)
-    {
+   Entry = WinStaObject->HotKeyListHead.Flink;
+   while (Entry != &WinStaObject->HotKeyListHead)
+   {
       HotKeyItem = (PHOT_KEY_ITEM) CONTAINING_RECORD(Entry,
-                                                    HOT_KEY_ITEM,
-                                                    ListEntry);
+                   HOT_KEY_ITEM,
+                   ListEntry);
       if (HotKeyItem->fsModifiers == fsModifiers &&
-         HotKeyItem->vk == vk)
-       {
-         if (Thread != NULL)
-           *Thread = HotKeyItem->Thread;
+            HotKeyItem->vk == vk)
+      {
+         if (Thread != NULL)
+            *Thread = HotKeyItem->Thread;
 
-         if (hWnd != NULL)
-           *hWnd = HotKeyItem->hWnd;
+         if (hWnd != NULL)
+            *hWnd = HotKeyItem->hWnd;
 
-         if (id != NULL)
-           *id = HotKeyItem->id;
+         if (id != NULL)
+            *id = HotKeyItem->id;
 
-         IntUnLockHotKeys(WinStaObject);
+         IntUnLockHotKeys(WinStaObject);
 
-         return TRUE;
-       }
+         return TRUE;
+      }
 
       Entry = Entry->Flink;
-    }
+   }
 
-  IntUnLockHotKeys(WinStaObject);
+   IntUnLockHotKeys(WinStaObject);
 
-  return FALSE;
+   return FALSE;
 }
 
 
 VOID
 UnregisterWindowHotKeys(PWINDOW_OBJECT Window)
 {
-  PLIST_ENTRY Entry;
-  PHOT_KEY_ITEM HotKeyItem;
-  PWINSTATION_OBJECT WinStaObject = NULL;
+   PLIST_ENTRY Entry;
+   PHOT_KEY_ITEM HotKeyItem;
+   PWINSTATION_OBJECT WinStaObject = NULL;
 
-  if(Window->OwnerThread && Window->OwnerThread->ThreadsProcess)
-    WinStaObject = Window->OwnerThread->Tcb.Win32Thread->Desktop->WindowStation;
+   if(Window->OwnerThread && Window->OwnerThread->ThreadsProcess)
+      WinStaObject = Window->OwnerThread->Tcb.Win32Thread->Desktop->WindowStation;
 
-  if(!WinStaObject)
-    return;
+   if(!WinStaObject)
+      return;
 
-  IntLockHotKeys(WinStaObject);
+   IntLockHotKeys(WinStaObject);
 
-  Entry = WinStaObject->HotKeyListHead.Flink;
-  while (Entry != &WinStaObject->HotKeyListHead)
-    {
+   Entry = WinStaObject->HotKeyListHead.Flink;
+   while (Entry != &WinStaObject->HotKeyListHead)
+   {
       HotKeyItem = (PHOT_KEY_ITEM) CONTAINING_RECORD (Entry,
-                                                     HOT_KEY_ITEM,
-                                                     ListEntry);
+                   HOT_KEY_ITEM,
+                   ListEntry);
       Entry = Entry->Flink;
       if (HotKeyItem->hWnd == Window->hSelf)
-       {
-         RemoveEntryList (&HotKeyItem->ListEntry);
-         ExFreePool (HotKeyItem);
-       }
-    }
+      {
+         RemoveEntryList (&HotKeyItem->ListEntry);
+         ExFreePool (HotKeyItem);
+      }
+   }
 
-  IntUnLockHotKeys(WinStaObject);
+   IntUnLockHotKeys(WinStaObject);
 }
 
 
 VOID
 UnregisterThreadHotKeys(struct _ETHREAD *Thread)
 {
-  PLIST_ENTRY Entry;
-  PHOT_KEY_ITEM HotKeyItem;
-  PWINSTATION_OBJECT WinStaObject = NULL;
+   PLIST_ENTRY Entry;
+   PHOT_KEY_ITEM HotKeyItem;
+   PWINSTATION_OBJECT WinStaObject = NULL;
 
-  if(Thread->Tcb.Win32Thread && Thread->Tcb.Win32Thread->Desktop)
-    WinStaObject = Thread->Tcb.Win32Thread->Desktop->WindowStation;
+   if(Thread->Tcb.Win32Thread && Thread->Tcb.Win32Thread->Desktop)
+      WinStaObject = Thread->Tcb.Win32Thread->Desktop->WindowStation;
 
-  if(!WinStaObject)
-    return;
+   if(!WinStaObject)
+      return;
 
-  IntLockHotKeys(WinStaObject);
+   IntLockHotKeys(WinStaObject);
 
-  Entry = WinStaObject->HotKeyListHead.Flink;
-  while (Entry != &WinStaObject->HotKeyListHead)
-    {
+   Entry = WinStaObject->HotKeyListHead.Flink;
+   while (Entry != &WinStaObject->HotKeyListHead)
+   {
       HotKeyItem = (PHOT_KEY_ITEM) CONTAINING_RECORD (Entry,
-                                                     HOT_KEY_ITEM,
-                                                     ListEntry);
+                   HOT_KEY_ITEM,
+                   ListEntry);
       Entry = Entry->Flink;
       if (HotKeyItem->Thread == Thread)
-       {
-         RemoveEntryList (&HotKeyItem->ListEntry);
-         ExFreePool (HotKeyItem);
-       }
-    }
+      {
+         RemoveEntryList (&HotKeyItem->ListEntry);
+         ExFreePool (HotKeyItem);
+      }
+   }
 
-  IntUnLockHotKeys(WinStaObject);
+   IntUnLockHotKeys(WinStaObject);
 }
 
 
 static BOOL
 IsHotKey (PWINSTATION_OBJECT WinStaObject,
-      UINT fsModifiers,
-         UINT vk)
+          UINT fsModifiers,
+          UINT vk)
 {
-  PLIST_ENTRY Entry;
-  PHOT_KEY_ITEM HotKeyItem;
+   PLIST_ENTRY Entry;
+   PHOT_KEY_ITEM HotKeyItem;
 
-  Entry = WinStaObject->HotKeyListHead.Flink;
-  while (Entry != &WinStaObject->HotKeyListHead)
-    {
+   Entry = WinStaObject->HotKeyListHead.Flink;
+   while (Entry != &WinStaObject->HotKeyListHead)
+   {
       HotKeyItem = (PHOT_KEY_ITEM) CONTAINING_RECORD (Entry,
-                                                     HOT_KEY_ITEM,
-                                                     ListEntry);
+                   HOT_KEY_ITEM,
+                   ListEntry);
       if (HotKeyItem->fsModifiers == fsModifiers &&
-         HotKeyItem->vk == vk)
-       {
-         return TRUE;
-       }
+            HotKeyItem->vk == vk)
+      {
+         return TRUE;
+      }
 
       Entry = Entry->Flink;
-    }
+   }
 
-  return FALSE;
+   return FALSE;
 }
 
 
 BOOL STDCALL
 NtUserRegisterHotKey(HWND hWnd,
-                    int id,
-                    UINT fsModifiers,
-                    UINT vk)
+                     int id,
+                     UINT fsModifiers,
+                     UINT vk)
 {
-  PHOT_KEY_ITEM HotKeyItem;
-  PWINDOW_OBJECT Window;
-  PWINSTATION_OBJECT WinStaObject = NULL;
-  PETHREAD HotKeyThread;
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserRegisterHotKey\n");
-  UserEnterExclusive();
-
-  if (hWnd == NULL)
-  {
-    HotKeyThread = PsGetCurrentThread();
-  }
-  else
-  {
-    Window = IntGetWindowObject(hWnd);
-    if(!Window)
-    {
-      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+   PHOT_KEY_ITEM HotKeyItem;
+   PWINDOW_OBJECT Window;
+   PWINSTATION_OBJECT WinStaObject = NULL;
+   PETHREAD HotKeyThread;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserRegisterHotKey\n");
+   UserEnterExclusive();
+
+   if (hWnd == NULL)
+   {
+      HotKeyThread = PsGetCurrentThread();
+   }
+   else
+   {
+      Window = IntGetWindowObject(hWnd);
+      if(!Window)
+      {
+         SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+         RETURN( FALSE);
+      }
+      HotKeyThread = Window->OwnerThread;
+      IntReleaseWindowObject(Window);
+   }
+
+
+   if(HotKeyThread->ThreadsProcess && HotKeyThread->ThreadsProcess->Win32Process)
+      WinStaObject = HotKeyThread->Tcb.Win32Thread->Desktop->WindowStation;
+
+   if(!WinStaObject)
+   {
       RETURN( FALSE);
-    }
-    HotKeyThread = Window->OwnerThread;
-    IntReleaseWindowObject(Window);
-  }
-
-
-  if(HotKeyThread->ThreadsProcess && HotKeyThread->ThreadsProcess->Win32Process)
-    WinStaObject = HotKeyThread->Tcb.Win32Thread->Desktop->WindowStation;
-
-  if(!WinStaObject)
-  {
-    RETURN( FALSE);
-  }
+   }
 
-  IntLockHotKeys(WinStaObject);
+   IntLockHotKeys(WinStaObject);
 
-  /* Check for existing hotkey */
-  if (IsHotKey (WinStaObject, fsModifiers, vk))
-  {
-    IntUnLockHotKeys(WinStaObject);
-    RETURN( FALSE);
-  }
+   /* Check for existing hotkey */
+   if (IsHotKey (WinStaObject, fsModifiers, vk))
+   {
+      IntUnLockHotKeys(WinStaObject);
+      RETURN( FALSE);
+   }
 
-  HotKeyItem = ExAllocatePoolWithTag (PagedPool, sizeof(HOT_KEY_ITEM), TAG_HOTKEY);
-  if (HotKeyItem == NULL)
-    {
+   HotKeyItem = ExAllocatePoolWithTag (PagedPool, sizeof(HOT_KEY_ITEM), TAG_HOTKEY);
+   if (HotKeyItem == NULL)
+   {
       IntUnLockHotKeys(WinStaObject);
       RETURN( FALSE);
-    }
+   }
 
-  HotKeyItem->Thread = HotKeyThread;
-  HotKeyItem->hWnd = hWnd;
-  HotKeyItem->id = id;
-  HotKeyItem->fsModifiers = fsModifiers;
-  HotKeyItem->vk = vk;
+   HotKeyItem->Thread = HotKeyThread;
+   HotKeyItem->hWnd = hWnd;
+   HotKeyItem->id = id;
+   HotKeyItem->fsModifiers = fsModifiers;
+   HotKeyItem->vk = vk;
 
-  InsertHeadList (&WinStaObject->HotKeyListHead,
-                 &HotKeyItem->ListEntry);
+   InsertHeadList (&WinStaObject->HotKeyListHead,
+                   &HotKeyItem->ListEntry);
 
-  IntUnLockHotKeys(WinStaObject);
+   IntUnLockHotKeys(WinStaObject);
+
+   RETURN( TRUE);
 
-  RETURN( TRUE);
-  
 CLEANUP:
-  DPRINT("Leave NtUserRegisterHotKey, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;  
+   DPRINT("Leave NtUserRegisterHotKey, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
 BOOL STDCALL
 NtUserUnregisterHotKey(HWND hWnd,
-                      int id)
+                       int id)
 {
-  PLIST_ENTRY Entry;
-  PHOT_KEY_ITEM HotKeyItem;
-  PWINDOW_OBJECT Window;
-  PWINSTATION_OBJECT WinStaObject = NULL;
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserUnregisterHotKey\n");
-  UserEnterExclusive();
-
-  Window = IntGetWindowObject(hWnd);
-  if(!Window)
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    RETURN( FALSE);
-  }
-
-  if(Window->OwnerThread->ThreadsProcess && Window->OwnerThread->ThreadsProcess->Win32Process)
-    WinStaObject = Window->OwnerThread->Tcb.Win32Thread->Desktop->WindowStation;
-
-  if(!WinStaObject)
-  {
-    IntReleaseWindowObject(Window);
-    RETURN( FALSE);
-  }
-
-  IntLockHotKeys(WinStaObject);
-
-  Entry = WinStaObject->HotKeyListHead.Flink;
-  while (Entry != &WinStaObject->HotKeyListHead)
-    {
+   PLIST_ENTRY Entry;
+   PHOT_KEY_ITEM HotKeyItem;
+   PWINDOW_OBJECT Window;
+   PWINSTATION_OBJECT WinStaObject = NULL;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserUnregisterHotKey\n");
+   UserEnterExclusive();
+
+   Window = IntGetWindowObject(hWnd);
+   if(!Window)
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      RETURN( FALSE);
+   }
+
+   if(Window->OwnerThread->ThreadsProcess && Window->OwnerThread->ThreadsProcess->Win32Process)
+      WinStaObject = Window->OwnerThread->Tcb.Win32Thread->Desktop->WindowStation;
+
+   if(!WinStaObject)
+   {
+      IntReleaseWindowObject(Window);
+      RETURN( FALSE);
+   }
+
+   IntLockHotKeys(WinStaObject);
+
+   Entry = WinStaObject->HotKeyListHead.Flink;
+   while (Entry != &WinStaObject->HotKeyListHead)
+   {
       HotKeyItem = (PHOT_KEY_ITEM) CONTAINING_RECORD (Entry,
-                                                     HOT_KEY_ITEM,
-                                                     ListEntry);
+                   HOT_KEY_ITEM,
+                   ListEntry);
       if (HotKeyItem->hWnd == hWnd &&
-         HotKeyItem->id == id)
-       {
-         RemoveEntryList (&HotKeyItem->ListEntry);
-         ExFreePool (HotKeyItem);
-         IntUnLockHotKeys(WinStaObject);
+            HotKeyItem->id == id)
+      {
+         RemoveEntryList (&HotKeyItem->ListEntry);
+         ExFreePool (HotKeyItem);
+         IntUnLockHotKeys(WinStaObject);
 
-         IntReleaseWindowObject(Window);
-     RETURN( TRUE);
-       }
+         IntReleaseWindowObject(Window);
+         RETURN( TRUE);
+      }
 
       Entry = Entry->Flink;
-    }
+   }
+
+   IntUnLockHotKeys(WinStaObject);
 
-  IntUnLockHotKeys(WinStaObject);
+   IntReleaseWindowObject(Window);
+   RETURN( FALSE);
 
-  IntReleaseWindowObject(Window);
-  RETURN( FALSE);
-  
 CLEANUP:
-  DPRINT("Leave NtUserUnregisterHotKey, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;  
+   DPRINT("Leave NtUserUnregisterHotKey, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 /* EOF */
index 57025ec..57a8f77 100644 (file)
@@ -67,164 +67,164 @@ PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue = 0;
 VOID FASTCALL
 ProcessMouseInputData(PMOUSE_INPUT_DATA Data, ULONG InputCount)
 {
-  PMOUSE_INPUT_DATA mid;
-  MOUSEINPUT mi;
-  ULONG i;
-
-  ClearMouseInput(mi);
-  mi.time = 0;
-  mi.dwExtraInfo = 0;
-  for(i = 0; i < InputCount; i++)
-  {
-    mid = (Data + i);
-    mi.dx += mid->LastX;
-    mi.dy += mid->LastY;
-
-    if(mid->ButtonFlags)
-    {
-      if(mid->ButtonFlags & MOUSE_LEFT_BUTTON_DOWN)
-      {
-        mi.dwFlags |= MOUSEEVENTF_LEFTDOWN;
-        SendMouseEvent(mi);
-      }
-      if(mid->ButtonFlags & MOUSE_LEFT_BUTTON_UP)
-      {
-        mi.dwFlags |= MOUSEEVENTF_LEFTUP;
-        SendMouseEvent(mi);
-      }
-      if(mid->ButtonFlags & MOUSE_MIDDLE_BUTTON_DOWN)
-      {
-        mi.dwFlags |= MOUSEEVENTF_MIDDLEDOWN;
-        SendMouseEvent(mi);
-      }
-      if(mid->ButtonFlags & MOUSE_MIDDLE_BUTTON_UP)
-      {
-        mi.dwFlags |= MOUSEEVENTF_MIDDLEUP;
-        SendMouseEvent(mi);
-      }
-      if(mid->ButtonFlags & MOUSE_RIGHT_BUTTON_DOWN)
-      {
-        mi.dwFlags |= MOUSEEVENTF_RIGHTDOWN;
-        SendMouseEvent(mi);
-      }
-      if(mid->ButtonFlags & MOUSE_RIGHT_BUTTON_UP)
-      {
-        mi.dwFlags |= MOUSEEVENTF_RIGHTUP;
-        SendMouseEvent(mi);
-      }
-      if(mid->ButtonFlags & MOUSE_BUTTON_4_DOWN)
-      {
-        mi.mouseData |= XBUTTON1;
-        mi.dwFlags |= MOUSEEVENTF_XDOWN;
-        SendMouseEvent(mi);
-      }
-      if(mid->ButtonFlags & MOUSE_BUTTON_4_UP)
-      {
-        mi.mouseData |= XBUTTON1;
-        mi.dwFlags |= MOUSEEVENTF_XUP;
-        SendMouseEvent(mi);
-      }
-      if(mid->ButtonFlags & MOUSE_BUTTON_5_DOWN)
-      {
-        mi.mouseData |= XBUTTON2;
-        mi.dwFlags |= MOUSEEVENTF_XDOWN;
-        SendMouseEvent(mi);
-      }
-      if(mid->ButtonFlags & MOUSE_BUTTON_5_UP)
-      {
-        mi.mouseData |= XBUTTON2;
-        mi.dwFlags |= MOUSEEVENTF_XUP;
-        SendMouseEvent(mi);
-      }
-      if(mid->ButtonFlags & MOUSE_WHEEL)
+   PMOUSE_INPUT_DATA mid;
+   MOUSEINPUT mi;
+   ULONG i;
+
+   ClearMouseInput(mi);
+   mi.time = 0;
+   mi.dwExtraInfo = 0;
+   for(i = 0; i < InputCount; i++)
+   {
+      mid = (Data + i);
+      mi.dx += mid->LastX;
+      mi.dy += mid->LastY;
+
+      if(mid->ButtonFlags)
       {
-        mi.mouseData = mid->ButtonData;
-        mi.dwFlags |= MOUSEEVENTF_WHEEL;
-        SendMouseEvent(mi);
+         if(mid->ButtonFlags & MOUSE_LEFT_BUTTON_DOWN)
+         {
+            mi.dwFlags |= MOUSEEVENTF_LEFTDOWN;
+            SendMouseEvent(mi);
+         }
+         if(mid->ButtonFlags & MOUSE_LEFT_BUTTON_UP)
+         {
+            mi.dwFlags |= MOUSEEVENTF_LEFTUP;
+            SendMouseEvent(mi);
+         }
+         if(mid->ButtonFlags & MOUSE_MIDDLE_BUTTON_DOWN)
+         {
+            mi.dwFlags |= MOUSEEVENTF_MIDDLEDOWN;
+            SendMouseEvent(mi);
+         }
+         if(mid->ButtonFlags & MOUSE_MIDDLE_BUTTON_UP)
+         {
+            mi.dwFlags |= MOUSEEVENTF_MIDDLEUP;
+            SendMouseEvent(mi);
+         }
+         if(mid->ButtonFlags & MOUSE_RIGHT_BUTTON_DOWN)
+         {
+            mi.dwFlags |= MOUSEEVENTF_RIGHTDOWN;
+            SendMouseEvent(mi);
+         }
+         if(mid->ButtonFlags & MOUSE_RIGHT_BUTTON_UP)
+         {
+            mi.dwFlags |= MOUSEEVENTF_RIGHTUP;
+            SendMouseEvent(mi);
+         }
+         if(mid->ButtonFlags & MOUSE_BUTTON_4_DOWN)
+         {
+            mi.mouseData |= XBUTTON1;
+            mi.dwFlags |= MOUSEEVENTF_XDOWN;
+            SendMouseEvent(mi);
+         }
+         if(mid->ButtonFlags & MOUSE_BUTTON_4_UP)
+         {
+            mi.mouseData |= XBUTTON1;
+            mi.dwFlags |= MOUSEEVENTF_XUP;
+            SendMouseEvent(mi);
+         }
+         if(mid->ButtonFlags & MOUSE_BUTTON_5_DOWN)
+         {
+            mi.mouseData |= XBUTTON2;
+            mi.dwFlags |= MOUSEEVENTF_XDOWN;
+            SendMouseEvent(mi);
+         }
+         if(mid->ButtonFlags & MOUSE_BUTTON_5_UP)
+         {
+            mi.mouseData |= XBUTTON2;
+            mi.dwFlags |= MOUSEEVENTF_XUP;
+            SendMouseEvent(mi);
+         }
+         if(mid->ButtonFlags & MOUSE_WHEEL)
+         {
+            mi.mouseData = mid->ButtonData;
+            mi.dwFlags |= MOUSEEVENTF_WHEEL;
+            SendMouseEvent(mi);
+         }
       }
-    }
-  }
+   }
 
-  SendMouseEvent(mi);
+   SendMouseEvent(mi);
 }
 
 VOID STDCALL
 MouseThreadMain(PVOID StartContext)
 {
-  UNICODE_STRING MouseDeviceName = RTL_CONSTANT_STRING(L"\\??\\Mouse");
-  OBJECT_ATTRIBUTES MouseObjectAttributes;
-  IO_STATUS_BLOCK Iosb;
-  NTSTATUS Status;
-
-  InitializeObjectAttributes(&MouseObjectAttributes,
-                             &MouseDeviceName,
-                             0,
+   UNICODE_STRING MouseDeviceName = RTL_CONSTANT_STRING(L"\\??\\Mouse");
+   OBJECT_ATTRIBUTES MouseObjectAttributes;
+   IO_STATUS_BLOCK Iosb;
+   NTSTATUS Status;
+
+   InitializeObjectAttributes(&MouseObjectAttributes,
+                              &MouseDeviceName,
+                              0,
+                              NULL,
+                              NULL);
+   Status = NtOpenFile(&MouseDeviceHandle,
+                       FILE_ALL_ACCESS,
+                       &MouseObjectAttributes,
+                       &Iosb,
+                       0,
+                       FILE_SYNCHRONOUS_IO_ALERT);
+   if(!NT_SUCCESS(Status))
+   {
+      DPRINT1("Win32K: Failed to open mouse.\n");
+      return; //(Status);
+   }
+
+   for(;;)
+   {
+      /*
+       * Wait to start input.
+       */
+      DPRINT("Mouse Input Thread Waiting for start event\n");
+      Status = KeWaitForSingleObject(&InputThreadsStart,
+                                     0,
+                                     KernelMode,
+                                     TRUE,
+                                     NULL);
+      DPRINT("Mouse Input Thread Starting...\n");
+
+      /*
+       * Receive and process mouse input.
+       */
+      while(InputThreadsRunning)
+      {
+         MOUSE_INPUT_DATA MouseInput;
+         Status = NtReadFile(MouseDeviceHandle,
+                             NULL,
+                             NULL,
+                             NULL,
+                             &Iosb,
+                             &MouseInput,
+                             sizeof(MOUSE_INPUT_DATA),
                              NULL,
                              NULL);
-  Status = NtOpenFile(&MouseDeviceHandle,
-                      FILE_ALL_ACCESS,
-                      &MouseObjectAttributes,
-                      &Iosb,
-                      0,
-                      FILE_SYNCHRONOUS_IO_ALERT);
-  if(!NT_SUCCESS(Status))
-  {
-    DPRINT1("Win32K: Failed to open mouse.\n");
-    return; //(Status);
-  }
-
-  for(;;)
-  {
-    /*
-     * Wait to start input.
-     */
-    DPRINT("Mouse Input Thread Waiting for start event\n");
-    Status = KeWaitForSingleObject(&InputThreadsStart,
-                                   0,
-                                   KernelMode,
-                                   TRUE,
-                                   NULL);
-    DPRINT("Mouse Input Thread Starting...\n");
-
-    /*
-     * Receive and process mouse input.
-     */
-    while(InputThreadsRunning)
-    {
-      MOUSE_INPUT_DATA MouseInput;
-      Status = NtReadFile(MouseDeviceHandle,
-                          NULL,
-                          NULL,
-                          NULL,
-                          &Iosb,
-                          &MouseInput,
-                          sizeof(MOUSE_INPUT_DATA),
-                          NULL,
-                          NULL);
-      if(Status == STATUS_ALERTED && !InputThreadsRunning)
-      {
-        break;
-      }
-      if(Status == STATUS_PENDING)
-      {
-        NtWaitForSingleObject(MouseDeviceHandle, FALSE, NULL);
-        Status = Iosb.Status;
+         if(Status == STATUS_ALERTED && !InputThreadsRunning)
+         {
+            break;
+         }
+         if(Status == STATUS_PENDING)
+         {
+            NtWaitForSingleObject(MouseDeviceHandle, FALSE, NULL);
+            Status = Iosb.Status;
+         }
+         if(!NT_SUCCESS(Status))
+         {
+            DPRINT1("Win32K: Failed to read from mouse.\n");
+            return; //(Status);
+         }
+         DPRINT("MouseEvent\n");
+
+         UserEnterExclusive();
+
+         ProcessMouseInputData(&MouseInput, Iosb.Information / sizeof(MOUSE_INPUT_DATA));
+
+         UserLeave();
       }
-      if(!NT_SUCCESS(Status))
-      {
-        DPRINT1("Win32K: Failed to read from mouse.\n");
-        return; //(Status);
-      }
-      DPRINT("MouseEvent\n");
-
-      UserEnterExclusive();
-
-      ProcessMouseInputData(&MouseInput, Iosb.Information / sizeof(MOUSE_INPUT_DATA));
-      
-      UserLeave();
-    }
-    DPRINT("Mouse Input Thread Stopped...\n");
-  }
+      DPRINT("Mouse Input Thread Stopped...\n");
+   }
 }
 
 /* Returns a value that indicates if the key is a modifier key, and
@@ -233,45 +233,45 @@ MouseThreadMain(PVOID StartContext)
 STATIC UINT STDCALL
 IntKeyboardGetModifiers(KEYBOARD_INPUT_DATA *InputData)
 {
-  if (InputData->Flags & KEY_E1)
+   if (InputData->Flags & KEY_E1)
       return 0;
 
-  if (!(InputData->Flags & KEY_E0))
-    {
+   if (!(InputData->Flags & KEY_E0))
+   {
       switch (InputData->MakeCode)
-        {
-          case 0x2a: /* left shift */
-          case 0x36: /* right shift */
-              return MOD_SHIFT;
-
-          case 0x1d: /* left control */
-              return MOD_CONTROL;
-
-          case 0x38: /* left alt */
-              return MOD_ALT;
-
-          default:
-              return 0;
-        }
-    }
-  else
-    {
+      {
+         case 0x2a: /* left shift */
+         case 0x36: /* right shift */
+            return MOD_SHIFT;
+
+         case 0x1d: /* left control */
+            return MOD_CONTROL;
+
+         case 0x38: /* left alt */
+            return MOD_ALT;
+
+         default:
+            return 0;
+      }
+   }
+   else
+   {
       switch (InputData->MakeCode)
-        {
-          case 0x1d: /* right control */
-              return MOD_CONTROL;
+      {
+         case 0x1d: /* right control */
+            return MOD_CONTROL;
 
-          case 0x38: /* right alt */
-              return MOD_ALT;
+         case 0x38: /* right alt */
+            return MOD_ALT;
 
-          case 0x5b: /* left gui (windows) */
-          case 0x5c: /* right gui (windows) */
-              return MOD_WIN;
+         case 0x5b: /* left gui (windows) */
+         case 0x5c: /* right gui (windows) */
+            return MOD_WIN;
 
-          default:
-              return 0;
-        }
-    }
+         default:
+            return 0;
+      }
+   }
 }
 
 /* Asks the keyboard driver to send a small table that shows which
@@ -279,922 +279,937 @@ IntKeyboardGetModifiers(KEYBOARD_INPUT_DATA *InputData)
  */
 STATIC NTSTATUS STDCALL
 IntKeyboardGetIndicatorTrans(HANDLE KeyboardDeviceHandle,
-                            PKEYBOARD_INDICATOR_TRANSLATION *IndicatorTrans)
+                             PKEYBOARD_INDICATOR_TRANSLATION *IndicatorTrans)
 {
-  NTSTATUS Status;
-  DWORD Size = 0;
-  IO_STATUS_BLOCK Block;
-  PKEYBOARD_INDICATOR_TRANSLATION Ret;
+   NTSTATUS Status;
+   DWORD Size = 0;
+   IO_STATUS_BLOCK Block;
+   PKEYBOARD_INDICATOR_TRANSLATION Ret;
 
-  Size = sizeof(KEYBOARD_INDICATOR_TRANSLATION);
+   Size = sizeof(KEYBOARD_INDICATOR_TRANSLATION);
 
-  Ret = ExAllocatePoolWithTag(PagedPool,
-                             Size,
-                             TAG_KEYBOARD);
+   Ret = ExAllocatePoolWithTag(PagedPool,
+                               Size,
+                               TAG_KEYBOARD);
 
-  while (Ret)
-    {
+   while (Ret)
+   {
       Status = NtDeviceIoControlFile(KeyboardDeviceHandle,
-                                    NULL,
-                                    NULL,
-                                    NULL,
-                                    &Block,
-                                    IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION,
-                                    NULL, 0,
-                                    Ret, Size);
+                                     NULL,
+                                     NULL,
+                                     NULL,
+                                     &Block,
+                                     IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION,
+                                     NULL, 0,
+                                     Ret, Size);
 
       if (Status != STATUS_BUFFER_TOO_SMALL)
-       break;
+         break;
 
       ExFreePool(Ret);
 
       Size += sizeof(KEYBOARD_INDICATOR_TRANSLATION);
 
       Ret = ExAllocatePoolWithTag(PagedPool,
-                                 Size,
-                                 TAG_KEYBOARD);
-    }
+                                  Size,
+                                  TAG_KEYBOARD);
+   }
 
-  if (!Ret)
-    return STATUS_INSUFFICIENT_RESOURCES;
+   if (!Ret)
+      return STATUS_INSUFFICIENT_RESOURCES;
 
-  if (Status != STATUS_SUCCESS)
-    {
+   if (Status != STATUS_SUCCESS)
+   {
       ExFreePool(Ret);
       return Status;
-    }
+   }
 
-  *IndicatorTrans = Ret;
-  return Status;
+   *IndicatorTrans = Ret;
+   return Status;
 }
 
 /* Sends the keyboard commands to turn on/off the lights.
  */
 STATIC NTSTATUS STDCALL
 IntKeyboardUpdateLeds(HANDLE KeyboardDeviceHandle,
-                     PKEYBOARD_INPUT_DATA KeyInput,
-                     PKEYBOARD_INDICATOR_TRANSLATION IndicatorTrans)
+                      PKEYBOARD_INPUT_DATA KeyInput,
+                      PKEYBOARD_INDICATOR_TRANSLATION IndicatorTrans)
 {
-  NTSTATUS Status;
-  UINT Count;
-  static KEYBOARD_INDICATOR_PARAMETERS Indicators;
-  IO_STATUS_BLOCK Block;
+   NTSTATUS Status;
+   UINT Count;
+   static KEYBOARD_INDICATOR_PARAMETERS Indicators;
+   IO_STATUS_BLOCK Block;
 
-  if (!IndicatorTrans)
-    return STATUS_NOT_SUPPORTED;
+   if (!IndicatorTrans)
+      return STATUS_NOT_SUPPORTED;
 
-  if (KeyInput->Flags & (KEY_E0 | KEY_E1 | KEY_BREAK))
-    return STATUS_SUCCESS;
+   if (KeyInput->Flags & (KEY_E0 | KEY_E1 | KEY_BREAK))
+      return STATUS_SUCCESS;
 
-  for (Count = 0; Count < IndicatorTrans->NumberOfIndicatorKeys; Count++)
-    {
+   for (Count = 0; Count < IndicatorTrans->NumberOfIndicatorKeys; Count++)
+   {
       if (KeyInput->MakeCode == IndicatorTrans->IndicatorList[Count].MakeCode)
-       {
-         Indicators.LedFlags ^=
-                       IndicatorTrans->IndicatorList[Count].IndicatorFlags;
-
-         /* Update the lights on the hardware */
-
-         Status = NtDeviceIoControlFile(KeyboardDeviceHandle,
-                                        NULL,
-                                        NULL,
-                                        NULL,
-                                        &Block,
-                                        IOCTL_KEYBOARD_SET_INDICATORS,
-                                        &Indicators, sizeof(Indicators),
-                                        NULL, 0);
-
-         return Status;
-       }
-    }
-
-  return STATUS_SUCCESS;
+      {
+         Indicators.LedFlags ^=
+            IndicatorTrans->IndicatorList[Count].IndicatorFlags;
+
+         /* Update the lights on the hardware */
+
+         Status = NtDeviceIoControlFile(KeyboardDeviceHandle,
+                                        NULL,
+                                        NULL,
+                                        NULL,
+                                        &Block,
+                                        IOCTL_KEYBOARD_SET_INDICATORS,
+                                        &Indicators, sizeof(Indicators),
+                                        NULL, 0);
+
+         return Status;
+      }
+   }
+
+   return STATUS_SUCCESS;
 }
 
 STATIC VOID STDCALL
 IntKeyboardSendWinKeyMsg()
 {
-  PWINDOW_OBJECT Window;
-  MSG Mesg;
+   PWINDOW_OBJECT Window;
+   MSG Mesg;
 
-  if (!(Window = IntGetWindowObject(InputWindowStation->ShellWindow)))
-    {
+   if (!(Window = IntGetWindowObject(InputWindowStation->ShellWindow)))
+   {
       DPRINT1("Couldn't find window to send Windows key message!\n");
       return;
-    }
+   }
 
-  Mesg.hwnd = InputWindowStation->ShellWindow;
-  Mesg.message = WM_SYSCOMMAND;
-  Mesg.wParam = SC_TASKLIST;
-  Mesg.lParam = 0;
+   Mesg.hwnd = InputWindowStation->ShellWindow;
+   Mesg.message = WM_SYSCOMMAND;
+   Mesg.wParam = SC_TASKLIST;
+   Mesg.lParam = 0;
 
-  /* The QS_HOTKEY is just a guess */
-  MsqPostMessage(Window->MessageQueue, &Mesg, FALSE, QS_HOTKEY);
+   /* The QS_HOTKEY is just a guess */
+   MsqPostMessage(Window->MessageQueue, &Mesg, FALSE, QS_HOTKEY);
 
-  ObmDereferenceObject(Window);
+   ObmDereferenceObject(Window);
 }
 
 STATIC VOID STDCALL
 co_IntKeyboardSendAltKeyMsg()
 {
-  co_MsqPostKeyboardMessage(WM_SYSCOMMAND,SC_KEYMENU,0);
+   co_MsqPostKeyboardMessage(WM_SYSCOMMAND,SC_KEYMENU,0);
 }
 
 STATIC VOID STDCALL
 KeyboardThreadMain(PVOID StartContext)
 {
-  UNICODE_STRING KeyboardDeviceName = RTL_CONSTANT_STRING(L"\\??\\Keyboard");
-  OBJECT_ATTRIBUTES KeyboardObjectAttributes;
-  IO_STATUS_BLOCK Iosb;
-  NTSTATUS Status;
-  MSG msg;
-  PUSER_MESSAGE_QUEUE FocusQueue;
-  struct _ETHREAD *FocusThread;
-  extern NTSTATUS Win32kInitWin32Thread(PETHREAD Thread);
-
-
-  PKEYBOARD_INDICATOR_TRANSLATION IndicatorTrans = NULL;
-  UINT ModifierState = 0;
-  USHORT LastMakeCode = 0;
-  USHORT LastFlags = 0;
-  UINT RepeatCount = 0;
-
-  InitializeObjectAttributes(&KeyboardObjectAttributes,
-                            &KeyboardDeviceName,
-                            0,
-                            NULL,
-                            NULL);
-  Status = NtOpenFile(&KeyboardDeviceHandle,
-                     FILE_ALL_ACCESS,
-                     &KeyboardObjectAttributes,
-                     &Iosb,
-                     0,
-                     FILE_SYNCHRONOUS_IO_ALERT);
-  if (!NT_SUCCESS(Status))
-    {
+   UNICODE_STRING KeyboardDeviceName = RTL_CONSTANT_STRING(L"\\??\\Keyboard");
+   OBJECT_ATTRIBUTES KeyboardObjectAttributes;
+   IO_STATUS_BLOCK Iosb;
+   NTSTATUS Status;
+   MSG msg;
+   PUSER_MESSAGE_QUEUE FocusQueue;
+   struct _ETHREAD *FocusThread;
+   extern NTSTATUS Win32kInitWin32Thread(PETHREAD Thread);
+
+
+   PKEYBOARD_INDICATOR_TRANSLATION IndicatorTrans = NULL;
+   UINT ModifierState = 0;
+   USHORT LastMakeCode = 0;
+   USHORT LastFlags = 0;
+   UINT RepeatCount = 0;
+
+   InitializeObjectAttributes(&KeyboardObjectAttributes,
+                              &KeyboardDeviceName,
+                              0,
+                              NULL,
+                              NULL);
+   Status = NtOpenFile(&KeyboardDeviceHandle,
+                       FILE_ALL_ACCESS,
+                       &KeyboardObjectAttributes,
+                       &Iosb,
+                       0,
+                       FILE_SYNCHRONOUS_IO_ALERT);
+   if (!NT_SUCCESS(Status))
+   {
       DPRINT1("Win32K: Failed to open keyboard.\n");
       return; //(Status);
-    }
-
-  /* Not sure if converting this thread to a win32 thread is such
-     a great idea. Since we're posting keyboard messages to the focus
-     window message queue, we'll be (indirectly) doing sendmessage
-     stuff from this thread (for WH_KEYBOARD_LL processing), which
-     means we need our own message queue. If keyboard messages were
-     instead queued to the system message queue, the thread removing
-     the message from the system message queue would be responsible
-     for WH_KEYBOARD_LL processing and we wouldn't need this thread
-     to be a win32 thread. */
-  Status = Win32kInitWin32Thread(PsGetCurrentThread());
-  if (!NT_SUCCESS(Status))
-    {
+   }
+
+   /* Not sure if converting this thread to a win32 thread is such
+      a great idea. Since we're posting keyboard messages to the focus
+      window message queue, we'll be (indirectly) doing sendmessage
+      stuff from this thread (for WH_KEYBOARD_LL processing), which
+      means we need our own message queue. If keyboard messages were
+      instead queued to the system message queue, the thread removing
+      the message from the system message queue would be responsible
+      for WH_KEYBOARD_LL processing and we wouldn't need this thread
+      to be a win32 thread. */
+   Status = Win32kInitWin32Thread(PsGetCurrentThread());
+   if (!NT_SUCCESS(Status))
+   {
       DPRINT1("Win32K: Failed making keyboard thread a win32 thread.\n");
       return; //(Status);
-    }
+   }
 
-  IntKeyboardGetIndicatorTrans(KeyboardDeviceHandle,
-                              &IndicatorTrans);
+   IntKeyboardGetIndicatorTrans(KeyboardDeviceHandle,
+                                &IndicatorTrans);
 
-  for (;;)
-    {
+   for (;;)
+   {
       /*
        * Wait to start input.
        */
       DPRINT( "Keyboard Input Thread Waiting for start event\n" );
       Status = KeWaitForSingleObject(&InputThreadsStart,
-                                    0,
-                                    KernelMode,
-                                    TRUE,
-                                    NULL);
+                                     0,
+                                     KernelMode,
+                                     TRUE,
+                                     NULL);
       DPRINT( "Keyboard Input Thread Starting...\n" );
 
       /*
        * Receive and process keyboard input.
        */
       while (InputThreadsRunning)
-       {
-         BOOLEAN NumKeys = 1;
-         KEYBOARD_INPUT_DATA KeyInput;
-         KEYBOARD_INPUT_DATA NextKeyInput;
-         LPARAM lParam = 0;
-         UINT fsModifiers, fsNextModifiers;
-         struct _ETHREAD *Thread;
-         HWND hWnd;
-         int id;
-
-         Status = NtReadFile (KeyboardDeviceHandle,
-                              NULL,
-                              NULL,
-                              NULL,
-                              &Iosb,
-                              &KeyInput,
-                              sizeof(KEYBOARD_INPUT_DATA),
-                              NULL,
-                              NULL);
-         DPRINT("KeyRaw: %s %04x\n",
-                (KeyInput.Flags & KEY_BREAK) ? "up" : "down",
-                KeyInput.MakeCode );
-
-         if (Status == STATUS_ALERTED && !InputThreadsRunning)
-           break;
-
-         if (!NT_SUCCESS(Status))
-           {
-             DPRINT1("Win32K: Failed to read from keyboard.\n");
-             return; //(Status);
-           }
-
-         /* Update modifier state */
-         fsModifiers = IntKeyboardGetModifiers(&KeyInput);
-
-         if (fsModifiers)
-           {
-             if (KeyInput.Flags & KEY_BREAK)
-               {
-                 ModifierState &= ~fsModifiers;
-               }
-             else
-               {
-                 ModifierState |= fsModifiers;
-
-                 if (ModifierState == fsModifiers &&
-                     (fsModifiers == MOD_ALT || fsModifiers == MOD_WIN))
-                   {
-                     /* First send out special notifications
-                      * (For alt, the message that turns on accelerator
-                      * display, not sure what for win. Both TODO though.)
-                      */
-
-                     /* Read the next key before sending this one */
-                     do
-                       {
-                         Status = NtReadFile (KeyboardDeviceHandle,
-                                              NULL,
-                                              NULL,
-                                              NULL,
-                                              &Iosb,
-                                              &NextKeyInput,
-                                              sizeof(KEYBOARD_INPUT_DATA),
-                                              NULL,
-                                              NULL);
-                         DPRINT("KeyRaw: %s %04x\n",
-                                (NextKeyInput.Flags & KEY_BREAK) ? "up":"down",
-                                NextKeyInput.MakeCode );
-
-                         if (Status == STATUS_ALERTED && !InputThreadsRunning)
-                           goto KeyboardEscape;
-
-                       } while ((!(NextKeyInput.Flags & KEY_BREAK)) &&
-                                NextKeyInput.MakeCode == KeyInput.MakeCode);
-                     /* ^ Ignore repeats, they'll be KEY_MAKE and the same
-                      *   code. I'm not caring about the counting, not sure
-                      *   if that matters. I think not.
-                      */
-
-                     /* If the ModifierState is now empty again, send a
-                      * special notification and eat both keypresses
-                      */
-
-                     fsNextModifiers = IntKeyboardGetModifiers(&NextKeyInput);
-
-                     if (fsNextModifiers)
-                       ModifierState ^= fsNextModifiers;
-
-                     if (ModifierState == 0)
-                       {
-                         if (fsModifiers == MOD_WIN)
-                           IntKeyboardSendWinKeyMsg();
-                         else if (fsModifiers == MOD_ALT)
-                           co_IntKeyboardSendAltKeyMsg();
-                         continue;
-                       }
-
-                     NumKeys = 2;
-                   }
-               }
-           }
-
-         for (;NumKeys;memcpy(&KeyInput, &NextKeyInput, sizeof(KeyInput)),
-                       NumKeys--)
-           {
-             lParam = 0;
-
-             IntKeyboardUpdateLeds(KeyboardDeviceHandle,
-                                   &KeyInput,
-                                   IndicatorTrans);
-
-         /* While we are working, we set up lParam. The format is:
-          *  0-15: The number of times this key has autorepeated
-          * 16-23: The keyboard scancode
-          *    24: Set if it's and extended key (I assume KEY_E0 | KEY_E1)
-          *        Note that E1 is only used for PAUSE (E1-1D-45) and
-          *        E0-45 happens not to be anything.
-          *    29: Alt is pressed ('Context code')
-          *    30: Previous state, if the key was down before this message
-          *        This is a cheap way to ignore autorepeat keys
-          *    31: 1 if the key is being pressed
-          */
-
-         /* If it's a KEY_MAKE (which is 0, so test using !KEY_BREAK)
-          * and it's the same key as the last one, increase the repeat
-          * count.
-          */
-
-             if (!(KeyInput.Flags & KEY_BREAK))
-               {
-                 if (((KeyInput.Flags & (KEY_E0 | KEY_E1)) == LastFlags) &&
-                     (KeyInput.MakeCode == LastMakeCode))
-                   {
-                     RepeatCount++;
-                     lParam |= (1 << 30);
-                   }
-                 else
-                   {
-                     RepeatCount = 0;
-                     LastFlags = KeyInput.Flags & (KEY_E0 | KEY_E1);
-                     LastMakeCode = KeyInput.MakeCode;
-                   }
-               }
-             else
-               {
-                 LastFlags = 0;
-                 LastMakeCode = 0; /* Should never match */
-                 lParam |= (1 << 30) | (1 << 31);
-               }
-
-             lParam |= RepeatCount;
-
-             lParam |= (KeyInput.MakeCode & 0xff) << 16;
-
-             if (KeyInput.Flags & KEY_E0)
-                 lParam |= (1 << 24);
-
-             if (ModifierState & MOD_ALT)
-               {
-                 lParam |= (1 << 29);
-
-                 if (!(KeyInput.Flags & KEY_BREAK))
-                   msg.message = WM_SYSKEYDOWN;
-                 else
-                   msg.message = WM_SYSKEYUP;
-               }
-             else
-               {
-                 if (!(KeyInput.Flags & KEY_BREAK))
-                   msg.message = WM_KEYDOWN;
-                 else
-                   msg.message = WM_KEYUP;
-               }
-
-             /* Find the target thread whose locale is in effect */
-             if (!IntGetScreenDC())
-               FocusQueue = W32kGetPrimitiveMessageQueue();
-             else
-               FocusQueue = IntGetFocusMessageQueue();
-
-             /* This might cause us to lose hot keys, which are important
-              * (ctrl-alt-del secure attention sequence). Not sure if it
-              * can happen though.
-              */
-             if (!FocusQueue) continue;
-
-             msg.lParam = lParam;
-             msg.hwnd = FocusQueue->FocusWindow;
-
-             FocusThread = FocusQueue->Thread;
-
-             if (!(FocusThread && FocusThread->Tcb.Win32Thread &&
-                   FocusThread->Tcb.Win32Thread->KeyboardLayout))
-               continue;
-
-             /* This function uses lParam to fill wParam according to the
-              * keyboard layout in use.
-              */
-             W32kKeyProcessMessage(&msg,
-                                   FocusThread->Tcb.Win32Thread->KeyboardLayout,
-                                   KeyInput.Flags & KEY_E0 ? 0xE0 :
-                                   (KeyInput.Flags & KEY_E1 ? 0xE1 : 0));
-
-             if (GetHotKey(InputWindowStation,
-                           ModifierState,
-                           msg.wParam,
-                           &Thread,
-                           &hWnd,
-                           &id))
-               {
-                 if (!(KeyInput.Flags & KEY_BREAK))
-                   {
-                     DPRINT("Hot key pressed (hWnd %lx, id %d)\n", hWnd, id);
-                     MsqPostHotKeyMessage (Thread,
-                                           hWnd,
-                                           (WPARAM)id,
-                                           MAKELPARAM((WORD)ModifierState,
-                                                      (WORD)msg.wParam));
-                   }
-                 continue;     /* Eat key up motion too */
-               }
-
-             /*
-              * Post a keyboard message.
-              */
-             co_MsqPostKeyboardMessage(msg.message,msg.wParam,msg.lParam);
-           }
-       }
+      {
+         BOOLEAN NumKeys = 1;
+         KEYBOARD_INPUT_DATA KeyInput;
+         KEYBOARD_INPUT_DATA NextKeyInput;
+         LPARAM lParam = 0;
+         UINT fsModifiers, fsNextModifiers;
+         struct _ETHREAD *Thread;
+         HWND hWnd;
+         int id;
+
+         Status = NtReadFile (KeyboardDeviceHandle,
+                              NULL,
+                              NULL,
+                              NULL,
+                              &Iosb,
+                              &KeyInput,
+                              sizeof(KEYBOARD_INPUT_DATA),
+                              NULL,
+                              NULL);
+         DPRINT("KeyRaw: %s %04x\n",
+                (KeyInput.Flags & KEY_BREAK) ? "up" : "down",
+                KeyInput.MakeCode );
+
+         if (Status == STATUS_ALERTED && !InputThreadsRunning)
+            break;
+
+         if (!NT_SUCCESS(Status))
+         {
+            DPRINT1("Win32K: Failed to read from keyboard.\n");
+            return; //(Status);
+         }
+
+         /* Update modifier state */
+         fsModifiers = IntKeyboardGetModifiers(&KeyInput);
+
+         if (fsModifiers)
+         {
+            if (KeyInput.Flags & KEY_BREAK)
+            {
+               ModifierState &= ~fsModifiers;
+            }
+            else
+            {
+               ModifierState |= fsModifiers;
+
+               if (ModifierState == fsModifiers &&
+                     (fsModifiers == MOD_ALT || fsModifiers == MOD_WIN))
+               {
+                  /* First send out special notifications
+                   * (For alt, the message that turns on accelerator
+                   * display, not sure what for win. Both TODO though.)
+                   */
+
+                  /* Read the next key before sending this one */
+                  do
+                  {
+                     Status = NtReadFile (KeyboardDeviceHandle,
+                                          NULL,
+                                          NULL,
+                                          NULL,
+                                          &Iosb,
+                                          &NextKeyInput,
+                                          sizeof(KEYBOARD_INPUT_DATA),
+                                          NULL,
+                                          NULL);
+                     DPRINT("KeyRaw: %s %04x\n",
+                            (NextKeyInput.Flags & KEY_BREAK) ? "up":"down",
+                            NextKeyInput.MakeCode );
+
+                     if (Status == STATUS_ALERTED && !InputThreadsRunning)
+                        goto KeyboardEscape;
+
+                  }
+                  while ((!(NextKeyInput.Flags & KEY_BREAK)) &&
+                         NextKeyInput.MakeCode == KeyInput.MakeCode);
+                  /* ^ Ignore repeats, they'll be KEY_MAKE and the same
+                   *   code. I'm not caring about the counting, not sure
+                   *   if that matters. I think not.
+                   */
+
+                  /* If the ModifierState is now empty again, send a
+                   * special notification and eat both keypresses
+                   */
+
+                  fsNextModifiers = IntKeyboardGetModifiers(&NextKeyInput);
+
+                  if (fsNextModifiers)
+                     ModifierState ^= fsNextModifiers;
+
+                  if (ModifierState == 0)
+                  {
+                     if (fsModifiers == MOD_WIN)
+                        IntKeyboardSendWinKeyMsg();
+                     else if (fsModifiers == MOD_ALT)
+                        co_IntKeyboardSendAltKeyMsg();
+                     continue;
+                  }
+
+                  NumKeys = 2;
+               }
+            }
+         }
+
+         for (;NumKeys;memcpy(&KeyInput, &NextKeyInput, sizeof(KeyInput)),
+               NumKeys--)
+         {
+            lParam = 0;
+
+            IntKeyboardUpdateLeds(KeyboardDeviceHandle,
+                                  &KeyInput,
+                                  IndicatorTrans);
+
+            /* While we are working, we set up lParam. The format is:
+             *  0-15: The number of times this key has autorepeated
+             * 16-23: The keyboard scancode
+             *    24: Set if it's and extended key (I assume KEY_E0 | KEY_E1)
+             *        Note that E1 is only used for PAUSE (E1-1D-45) and
+             *        E0-45 happens not to be anything.
+             *    29: Alt is pressed ('Context code')
+             *    30: Previous state, if the key was down before this message
+             *        This is a cheap way to ignore autorepeat keys
+             *    31: 1 if the key is being pressed
+             */
+
+            /* If it's a KEY_MAKE (which is 0, so test using !KEY_BREAK)
+             * and it's the same key as the last one, increase the repeat
+             * count.
+             */
+
+            if (!(KeyInput.Flags & KEY_BREAK))
+            {
+               if (((KeyInput.Flags & (KEY_E0 | KEY_E1)) == LastFlags) &&
+                     (KeyInput.MakeCode == LastMakeCode))
+               {
+                  RepeatCount++;
+                  lParam |= (1 << 30);
+               }
+               else
+               {
+                  RepeatCount = 0;
+                  LastFlags = KeyInput.Flags & (KEY_E0 | KEY_E1);
+                  LastMakeCode = KeyInput.MakeCode;
+               }
+            }
+            else
+            {
+               LastFlags = 0;
+               LastMakeCode = 0; /* Should never match */
+               lParam |= (1 << 30) | (1 << 31);
+            }
+
+            lParam |= RepeatCount;
+
+            lParam |= (KeyInput.MakeCode & 0xff) << 16;
+
+            if (KeyInput.Flags & KEY_E0)
+               lParam |= (1 << 24);
+
+            if (ModifierState & MOD_ALT)
+            {
+               lParam |= (1 << 29);
+
+               if (!(KeyInput.Flags & KEY_BREAK))
+                  msg.message = WM_SYSKEYDOWN;
+               else
+                  msg.message = WM_SYSKEYUP;
+            }
+            else
+            {
+               if (!(KeyInput.Flags & KEY_BREAK))
+                  msg.message = WM_KEYDOWN;
+               else
+                  msg.message = WM_KEYUP;
+            }
+
+            /* Find the target thread whose locale is in effect */
+            if (!IntGetScreenDC())
+               FocusQueue = W32kGetPrimitiveMessageQueue();
+            else
+               FocusQueue = IntGetFocusMessageQueue();
+
+            /* This might cause us to lose hot keys, which are important
+             * (ctrl-alt-del secure attention sequence). Not sure if it
+             * can happen though.
+             */
+            if (!FocusQueue)
+               continue;
+
+            msg.lParam = lParam;
+            msg.hwnd = FocusQueue->FocusWindow;
+
+            FocusThread = FocusQueue->Thread;
+
+            if (!(FocusThread && FocusThread->Tcb.Win32Thread &&
+                  FocusThread->Tcb.Win32Thread->KeyboardLayout))
+               continue;
+
+            /* This function uses lParam to fill wParam according to the
+             * keyboard layout in use.
+             */
+            W32kKeyProcessMessage(&msg,
+                                  FocusThread->Tcb.Win32Thread->KeyboardLayout,
+                                  KeyInput.Flags & KEY_E0 ? 0xE0 :
+                                  (KeyInput.Flags & KEY_E1 ? 0xE1 : 0));
+
+            if (GetHotKey(InputWindowStation,
+                          ModifierState,
+                          msg.wParam,
+                          &Thread,
+                          &hWnd,
+                          &id))
+            {
+               if (!(KeyInput.Flags & KEY_BREAK))
+               {
+                  DPRINT("Hot key pressed (hWnd %lx, id %d)\n", hWnd, id);
+                  MsqPostHotKeyMessage (Thread,
+                                        hWnd,
+                                        (WPARAM)id,
+                                        MAKELPARAM((WORD)ModifierState,
+                                                   (WORD)msg.wParam));
+               }
+               continue; /* Eat key up motion too */
+            }
+
+            /*
+             * Post a keyboard message.
+             */
+            co_MsqPostKeyboardMessage(msg.message,msg.wParam,msg.lParam);
+         }
+      }
 
 KeyboardEscape:
       DPRINT( "KeyboardInput Thread Stopped...\n" );
-    }
+   }
 }
 
 
 NTSTATUS FASTCALL
 UserAcquireOrReleaseInputOwnership(BOOLEAN Release)
 {
-  if (Release && InputThreadsRunning && !pmPrimitiveMessageQueue)
-    {
+   if (Release && InputThreadsRunning && !pmPrimitiveMessageQueue)
+   {
       DPRINT( "Releasing input: PM = %08x\n", pmPrimitiveMessageQueue );
       KeClearEvent(&InputThreadsStart);
       InputThreadsRunning = FALSE;
 
       NtAlertThread(KeyboardThreadHandle);
-    }
-  else if (!Release && !InputThreadsRunning)
-    {
+   }
+   else if (!Release && !InputThreadsRunning)
+   {
       InputThreadsRunning = TRUE;
       KeSetEvent(&InputThreadsStart, IO_NO_INCREMENT, FALSE);
-    }
+   }
 
-  return(STATUS_SUCCESS);
+   return(STATUS_SUCCESS);
 }
 
 
 NTSTATUS STDCALL
 NtUserAcquireOrReleaseInputOwnership(BOOLEAN Release)
 {
-  DECLARE_RETURN(NTSTATUS);  
+   DECLARE_RETURN(NTSTATUS);
+
+   DPRINT("Enter NtUserAcquireOrReleaseInputOwnership\n");
+   UserEnterExclusive();
+
+   RETURN(UserAcquireOrReleaseInputOwnership(Release));
 
-  DPRINT("Enter NtUserAcquireOrReleaseInputOwnership\n");
-  UserEnterExclusive();
-  
-  RETURN(UserAcquireOrReleaseInputOwnership(Release));
-  
 CLEANUP:
-  DPRINT("Leave NtUserAcquireOrReleaseInputOwnership, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserAcquireOrReleaseInputOwnership, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
 NTSTATUS FASTCALL
 InitInputImpl(VOID)
 {
-  NTSTATUS Status;
-
-  KeInitializeEvent(&InputThreadsStart, NotificationEvent, FALSE);
-
-  Status = PsCreateSystemThread(&KeyboardThreadHandle,
-                               THREAD_ALL_ACCESS,
-                               NULL,
-                               NULL,
-                               &KeyboardThreadId,
-                               KeyboardThreadMain,
-                               NULL);
-  if (!NT_SUCCESS(Status))
-  {
-    DPRINT1("Win32K: Failed to create keyboard thread.\n");
-  }
-
-  /* Initialize the default keyboard layout */
-  (VOID)W32kGetDefaultKeyLayout();
-
-
-  Status = PsCreateSystemThread(&MouseThreadHandle,
-                               THREAD_ALL_ACCESS,
-                               NULL,
-                               NULL,
-                               &MouseThreadId,
-                               MouseThreadMain,
-                               NULL);
-  if (!NT_SUCCESS(Status))
-  {
-    DPRINT1("Win32K: Failed to create mouse thread.\n");
-  }
-
-  return STATUS_SUCCESS;
+   NTSTATUS Status;
+
+   KeInitializeEvent(&InputThreadsStart, NotificationEvent, FALSE);
+
+   Status = PsCreateSystemThread(&KeyboardThreadHandle,
+                                 THREAD_ALL_ACCESS,
+                                 NULL,
+                                 NULL,
+                                 &KeyboardThreadId,
+                                 KeyboardThreadMain,
+                                 NULL);
+   if (!NT_SUCCESS(Status))
+   {
+      DPRINT1("Win32K: Failed to create keyboard thread.\n");
+   }
+
+   /* Initialize the default keyboard layout */
+   (VOID)W32kGetDefaultKeyLayout();
+
+
+   Status = PsCreateSystemThread(&MouseThreadHandle,
+                                 THREAD_ALL_ACCESS,
+                                 NULL,
+                                 NULL,
+                                 &MouseThreadId,
+                                 MouseThreadMain,
+                                 NULL);
+   if (!NT_SUCCESS(Status))
+   {
+      DPRINT1("Win32K: Failed to create mouse thread.\n");
+   }
+
+   return STATUS_SUCCESS;
 }
 
 NTSTATUS FASTCALL
 CleanupInputImp(VOID)
 {
-  return(STATUS_SUCCESS);
+   return(STATUS_SUCCESS);
 }
 
 BOOL
 STDCALL
 NtUserDragDetect(
-  HWND hWnd,
-  LONG x,
-  LONG y)
+   HWND hWnd,
+   LONG x,
+   LONG y)
 {
-  UNIMPLEMENTED
-  return 0;
+   UNIMPLEMENTED
+   return 0;
 }
 
 BOOL FASTCALL
 IntBlockInput(PW32THREAD W32Thread, BOOL BlockIt)
 {
-  PW32THREAD OldBlock;
-  ASSERT(W32Thread);
-
-  if(!W32Thread->Desktop || (W32Thread->IsExiting && BlockIt))
-  {
-    /*
-     * fail blocking if exiting the thread
-     */
-
-    return FALSE;
-  }
-
-  /*
-   * FIXME - check access rights of the window station
-   *         e.g. services running in the service window station cannot block input
-   */
-  if(!ThreadHasInputAccess(W32Thread) ||
-     !IntIsActiveDesktop(W32Thread->Desktop))
-  {
-    SetLastWin32Error(ERROR_ACCESS_DENIED);
-    return FALSE;
-  }
-
-  ASSERT(W32Thread->Desktop);
-  OldBlock = W32Thread->Desktop->BlockInputThread;
-  if(OldBlock)
-  {
-    if(OldBlock != W32Thread)
-    {
+   PW32THREAD OldBlock;
+   ASSERT(W32Thread);
+
+   if(!W32Thread->Desktop || (W32Thread->IsExiting && BlockIt))
+   {
+      /*
+       * fail blocking if exiting the thread
+       */
+
+      return FALSE;
+   }
+
+   /*
+    * FIXME - check access rights of the window station
+    *         e.g. services running in the service window station cannot block input
+    */
+   if(!ThreadHasInputAccess(W32Thread) ||
+         !IntIsActiveDesktop(W32Thread->Desktop))
+   {
       SetLastWin32Error(ERROR_ACCESS_DENIED);
       return FALSE;
-    }
-    W32Thread->Desktop->BlockInputThread = (BlockIt ? W32Thread : NULL);
-    return OldBlock == NULL;
-  }
+   }
+
+   ASSERT(W32Thread->Desktop);
+   OldBlock = W32Thread->Desktop->BlockInputThread;
+   if(OldBlock)
+   {
+      if(OldBlock != W32Thread)
+      {
+         SetLastWin32Error(ERROR_ACCESS_DENIED);
+         return FALSE;
+      }
+      W32Thread->Desktop->BlockInputThread = (BlockIt ? W32Thread : NULL);
+      return OldBlock == NULL;
+   }
 
-  W32Thread->Desktop->BlockInputThread = (BlockIt ? W32Thread : NULL);
-  return OldBlock == NULL;
+   W32Thread->Desktop->BlockInputThread = (BlockIt ? W32Thread : NULL);
+   return OldBlock == NULL;
 }
 
 BOOL
 STDCALL
 NtUserBlockInput(
-  BOOL BlockIt)
+   BOOL BlockIt)
 {
-  DECLARE_RETURN(BOOLEAN);  
+   DECLARE_RETURN(BOOLEAN);
+
+   DPRINT("Enter NtUserBlockInput\n");
+   UserEnterExclusive();
+
+   RETURN( IntBlockInput(PsGetWin32Thread(), BlockIt));
 
-  DPRINT("Enter NtUserBlockInput\n");
-  UserEnterExclusive();
-   
-  RETURN( IntBlockInput(PsGetWin32Thread(), BlockIt));
-  
 CLEANUP:
-  DPRINT("Leave NtUserBlockInput, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserBlockInput, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 BOOL FASTCALL
 IntSwapMouseButton(PWINSTATION_OBJECT WinStaObject, BOOL Swap)
 {
-  PSYSTEM_CURSORINFO CurInfo;
-  BOOL res;
+   PSYSTEM_CURSORINFO CurInfo;
+   BOOL res;
 
-  CurInfo = IntGetSysCursorInfo(WinStaObject);
-  res = CurInfo->SwapButtons;
-  CurInfo->SwapButtons = Swap;
-  return res;
+   CurInfo = IntGetSysCursorInfo(WinStaObject);
+   res = CurInfo->SwapButtons;
+   CurInfo->SwapButtons = Swap;
+   return res;
 }
 
 BOOL FASTCALL
 IntMouseInput(MOUSEINPUT *mi)
 {
-  const UINT SwapBtnMsg[2][2] = {{WM_LBUTTONDOWN, WM_RBUTTONDOWN},
-                                 {WM_LBUTTONUP, WM_RBUTTONUP}};
-  const WPARAM SwapBtn[2] = {MK_LBUTTON, MK_RBUTTON};
-  POINT MousePos, OrgPos;
-  PSYSTEM_CURSORINFO CurInfo;
-  PWINSTATION_OBJECT WinSta;
-  BOOL DoMove, SwapButtons;
-  MSG Msg;
-  HBITMAP hBitmap;
-  BITMAPOBJ *BitmapObj;
-  SURFOBJ *SurfObj;
-  PDC dc;
-  PWINDOW_OBJECT DesktopWindow;
+   const UINT SwapBtnMsg[2][2] =
+      {
+         {
+            WM_LBUTTONDOWN, WM_RBUTTONDOWN
+         },
+         {WM_LBUTTONUP, WM_RBUTTONUP}
+      };
+   const WPARAM SwapBtn[2] =
+      {
+         MK_LBUTTON, MK_RBUTTON
+      };
+   POINT MousePos, OrgPos;
+   PSYSTEM_CURSORINFO CurInfo;
+   PWINSTATION_OBJECT WinSta;
+   BOOL DoMove, SwapButtons;
+   MSG Msg;
+   HBITMAP hBitmap;
+   BITMAPOBJ *BitmapObj;
+   SURFOBJ *SurfObj;
+   PDC dc;
+   PWINDOW_OBJECT DesktopWindow;
 
 #if 1
-  HDC hDC;
 
-  /* FIXME - get the screen dc from the window station or desktop */
-  if(!(hDC = IntGetScreenDC()))
-  {
-    return FALSE;
-  }
+   HDC hDC;
+
+   /* FIXME - get the screen dc from the window station or desktop */
+   if(!(hDC = IntGetScreenDC()))
+   {
+      return FALSE;
+   }
 #endif
 
-  ASSERT(mi);
+   ASSERT(mi);
 #if 0
-  WinSta = PsGetWin32Process()->WindowStation;
+
+   WinSta = PsGetWin32Process()->WindowStation;
 #else
-  /* FIXME - ugly hack but as long as we're using this dumb callback from the
-             mouse class driver, we can't access the window station from the calling
-             process */
-  WinSta = InputWindowStation;
+   /* FIXME - ugly hack but as long as we're using this dumb callback from the
+   mouse class driver, we can't access the window station from the calling
+   process */
+   WinSta = InputWindowStation;
 #endif
-  ASSERT(WinSta);
-
-  CurInfo = IntGetSysCursorInfo(WinSta);
-
-  if(!mi->time)
-  {
-    LARGE_INTEGER LargeTickCount;
-    KeQueryTickCount(&LargeTickCount);
-    mi->time = LargeTickCount.u.LowPart;
-  }
-
-  SwapButtons = CurInfo->SwapButtons;
-  DoMove = FALSE;
-
-  IntGetCursorLocation(WinSta, &MousePos);
-  OrgPos.x = MousePos.x;
-  OrgPos.y = MousePos.y;
-
-  if(mi->dwFlags & MOUSEEVENTF_MOVE)
-  {
-    if(mi->dwFlags & MOUSEEVENTF_ABSOLUTE)
-    {
-      MousePos.x = mi->dx;
-      MousePos.y = mi->dy;
-    }
-    else
-    {
-      MousePos.x += mi->dx;
-      MousePos.y += mi->dy;
-    }
-
-    DesktopWindow = IntGetWindowObject(WinSta->ActiveDesktop->DesktopWindow);
-    
-    if (DesktopWindow)
-    {
-      if(MousePos.x >= DesktopWindow->ClientRect.right)
-        MousePos.x = DesktopWindow->ClientRect.right - 1;
-      if(MousePos.y >= DesktopWindow->ClientRect.bottom)
-        MousePos.y = DesktopWindow->ClientRect.bottom - 1;
-      ObmDereferenceObject(DesktopWindow);
-    }
-
-    if(MousePos.x < 0)
-      MousePos.x = 0;
-    if(MousePos.y < 0)
-      MousePos.y = 0;
-
-    if(CurInfo->CursorClipInfo.IsClipped)
-    {
-      /* The mouse cursor needs to be clipped */
-
-      if(MousePos.x >= (LONG)CurInfo->CursorClipInfo.Right)
-        MousePos.x = (LONG)CurInfo->CursorClipInfo.Right;
-      if(MousePos.x < (LONG)CurInfo->CursorClipInfo.Left)
-        MousePos.x = (LONG)CurInfo->CursorClipInfo.Left;
-      if(MousePos.y >= (LONG)CurInfo->CursorClipInfo.Bottom)
-        MousePos.y = (LONG)CurInfo->CursorClipInfo.Bottom;
-      if(MousePos.y < (LONG)CurInfo->CursorClipInfo.Top)
-        MousePos.y = (LONG)CurInfo->CursorClipInfo.Top;
-    }
-
-    DoMove = (MousePos.x != OrgPos.x || MousePos.y != OrgPos.y);
-  }
-
-  if (DoMove)
-  {
-    dc = DC_LockDc(hDC);
-    if (dc)
-    {
-      hBitmap = dc->w.hBitmap;
-      DC_UnlockDc(dc);
-
-      BitmapObj = BITMAPOBJ_LockBitmap(hBitmap);
-      if (BitmapObj)
+
+   ASSERT(WinSta);
+
+   CurInfo = IntGetSysCursorInfo(WinSta);
+
+   if(!mi->time)
+   {
+      LARGE_INTEGER LargeTickCount;
+      KeQueryTickCount(&LargeTickCount);
+      mi->time = LargeTickCount.u.LowPart;
+   }
+
+   SwapButtons = CurInfo->SwapButtons;
+   DoMove = FALSE;
+
+   IntGetCursorLocation(WinSta, &MousePos);
+   OrgPos.x = MousePos.x;
+   OrgPos.y = MousePos.y;
+
+   if(mi->dwFlags & MOUSEEVENTF_MOVE)
+   {
+      if(mi->dwFlags & MOUSEEVENTF_ABSOLUTE)
+      {
+         MousePos.x = mi->dx;
+         MousePos.y = mi->dy;
+      }
+      else
+      {
+         MousePos.x += mi->dx;
+         MousePos.y += mi->dy;
+      }
+
+      DesktopWindow = IntGetWindowObject(WinSta->ActiveDesktop->DesktopWindow);
+
+      if (DesktopWindow)
+      {
+         if(MousePos.x >= DesktopWindow->ClientRect.right)
+            MousePos.x = DesktopWindow->ClientRect.right - 1;
+         if(MousePos.y >= DesktopWindow->ClientRect.bottom)
+            MousePos.y = DesktopWindow->ClientRect.bottom - 1;
+         ObmDereferenceObject(DesktopWindow);
+      }
+
+      if(MousePos.x < 0)
+         MousePos.x = 0;
+      if(MousePos.y < 0)
+         MousePos.y = 0;
+
+      if(CurInfo->CursorClipInfo.IsClipped)
       {
-        SurfObj = &BitmapObj->SurfObj;
+         /* The mouse cursor needs to be clipped */
+
+         if(MousePos.x >= (LONG)CurInfo->CursorClipInfo.Right)
+            MousePos.x = (LONG)CurInfo->CursorClipInfo.Right;
+         if(MousePos.x < (LONG)CurInfo->CursorClipInfo.Left)
+            MousePos.x = (LONG)CurInfo->CursorClipInfo.Left;
+         if(MousePos.y >= (LONG)CurInfo->CursorClipInfo.Bottom)
+            MousePos.y = (LONG)CurInfo->CursorClipInfo.Bottom;
+         if(MousePos.y < (LONG)CurInfo->CursorClipInfo.Top)
+            MousePos.y = (LONG)CurInfo->CursorClipInfo.Top;
+      }
 
-        IntEngMovePointer(SurfObj, MousePos.x, MousePos.y, &(GDIDEV(SurfObj)->Pointer.Exclude));
-        /* Only now, update the info in the GDIDEVICE, so EngMovePointer can
-        * use the old values to move the pointer image */
-       GDIDEV(SurfObj)->Pointer.Pos.x = MousePos.x;
-       GDIDEV(SurfObj)->Pointer.Pos.y = MousePos.y;
+      DoMove = (MousePos.x != OrgPos.x || MousePos.y != OrgPos.y);
+   }
 
-        BITMAPOBJ_UnlockBitmap(BitmapObj);
+   if (DoMove)
+   {
+      dc = DC_LockDc(hDC);
+      if (dc)
+      {
+         hBitmap = dc->w.hBitmap;
+         DC_UnlockDc(dc);
+
+         BitmapObj = BITMAPOBJ_LockBitmap(hBitmap);
+         if (BitmapObj)
+         {
+            SurfObj = &BitmapObj->SurfObj;
+
+            IntEngMovePointer(SurfObj, MousePos.x, MousePos.y, &(GDIDEV(SurfObj)->Pointer.Exclude));
+            /* Only now, update the info in the GDIDEVICE, so EngMovePointer can
+            * use the old values to move the pointer image */
+            GDIDEV(SurfObj)->Pointer.Pos.x = MousePos.x;
+            GDIDEV(SurfObj)->Pointer.Pos.y = MousePos.y;
+
+            BITMAPOBJ_UnlockBitmap(BitmapObj);
+         }
       }
-    }
-  }
-
-  /*
-   * Insert the messages into the system queue
-   */
-
-  Msg.wParam = CurInfo->ButtonsDown;
-  Msg.lParam = MAKELPARAM(MousePos.x, MousePos.y);
-  Msg.pt = MousePos;
-  if(DoMove)
-  {
-    Msg.message = WM_MOUSEMOVE;
-    MsqInsertSystemMessage(&Msg);
-  }
-
-  Msg.message = 0;
-  if(mi->dwFlags & MOUSEEVENTF_LEFTDOWN)
-  {
-    QueueKeyStateTable[VK_LBUTTON] |= 0xc0;
-    Msg.message = SwapBtnMsg[0][SwapButtons];
-    CurInfo->ButtonsDown |= SwapBtn[SwapButtons];
-    MsqInsertSystemMessage(&Msg);
-  }
-  else if(mi->dwFlags & MOUSEEVENTF_LEFTUP)
-  {
-    QueueKeyStateTable[VK_LBUTTON] &= ~0x80;
-    Msg.message = SwapBtnMsg[1][SwapButtons];
-    CurInfo->ButtonsDown &= ~SwapBtn[SwapButtons];
-    MsqInsertSystemMessage(&Msg);
-  }
-  if(mi->dwFlags & MOUSEEVENTF_MIDDLEDOWN)
-  {
-    QueueKeyStateTable[VK_MBUTTON] |= 0xc0;
-    Msg.message = WM_MBUTTONDOWN;
-    CurInfo->ButtonsDown |= MK_MBUTTON;
-    MsqInsertSystemMessage(&Msg);
-  }
-  else if(mi->dwFlags & MOUSEEVENTF_MIDDLEUP)
-  {
-    QueueKeyStateTable[VK_MBUTTON] &= ~0x80;
-    Msg.message = WM_MBUTTONUP;
-    CurInfo->ButtonsDown &= ~MK_MBUTTON;
-    MsqInsertSystemMessage(&Msg);
-  }
-  if(mi->dwFlags & MOUSEEVENTF_RIGHTDOWN)
-  {
-    QueueKeyStateTable[VK_RBUTTON] |= 0xc0;
-    Msg.message = SwapBtnMsg[0][!SwapButtons];
-    CurInfo->ButtonsDown |= SwapBtn[!SwapButtons];
-    MsqInsertSystemMessage(&Msg);
-  }
-  else if(mi->dwFlags & MOUSEEVENTF_RIGHTUP)
-  {
-    QueueKeyStateTable[VK_RBUTTON] &= ~0x80;
-    Msg.message = SwapBtnMsg[1][!SwapButtons];
-    CurInfo->ButtonsDown &= ~SwapBtn[!SwapButtons];
-    MsqInsertSystemMessage(&Msg);
-  }
-
-  if((mi->dwFlags & (MOUSEEVENTF_XDOWN | MOUSEEVENTF_XUP)) &&
-     (mi->dwFlags & MOUSEEVENTF_WHEEL))
-  {
-    /* fail because both types of events use the mouseData field */
-    return FALSE;
-  }
-
-  if(mi->dwFlags & MOUSEEVENTF_XDOWN)
-  {
-    Msg.message = WM_XBUTTONDOWN;
-    if(mi->mouseData & XBUTTON1)
-    {
-      QueueKeyStateTable[VK_XBUTTON1] |= 0xc0;
-      Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON1);
-      CurInfo->ButtonsDown |= XBUTTON1;
+   }
+
+   /*
+    * Insert the messages into the system queue
+    */
+
+   Msg.wParam = CurInfo->ButtonsDown;
+   Msg.lParam = MAKELPARAM(MousePos.x, MousePos.y);
+   Msg.pt = MousePos;
+   if(DoMove)
+   {
+      Msg.message = WM_MOUSEMOVE;
+      MsqInsertSystemMessage(&Msg);
+   }
+
+   Msg.message = 0;
+   if(mi->dwFlags & MOUSEEVENTF_LEFTDOWN)
+   {
+      QueueKeyStateTable[VK_LBUTTON] |= 0xc0;
+      Msg.message = SwapBtnMsg[0][SwapButtons];
+      CurInfo->ButtonsDown |= SwapBtn[SwapButtons];
       MsqInsertSystemMessage(&Msg);
-    }
-    if(mi->mouseData & XBUTTON2)
-    {
-      QueueKeyStateTable[VK_XBUTTON2] |= 0xc0;
-      Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON2);
-      CurInfo->ButtonsDown |= XBUTTON2;
+   }
+   else if(mi->dwFlags & MOUSEEVENTF_LEFTUP)
+   {
+      QueueKeyStateTable[VK_LBUTTON] &= ~0x80;
+      Msg.message = SwapBtnMsg[1][SwapButtons];
+      CurInfo->ButtonsDown &= ~SwapBtn[SwapButtons];
       MsqInsertSystemMessage(&Msg);
-    }
-  }
-  else if(mi->dwFlags & MOUSEEVENTF_XUP)
-  {
-    Msg.message = WM_XBUTTONUP;
-    if(mi->mouseData & XBUTTON1)
-    {
-      QueueKeyStateTable[VK_XBUTTON1] &= ~0x80;
-      Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON1);
-      CurInfo->ButtonsDown &= ~XBUTTON1;
+   }
+   if(mi->dwFlags & MOUSEEVENTF_MIDDLEDOWN)
+   {
+      QueueKeyStateTable[VK_MBUTTON] |= 0xc0;
+      Msg.message = WM_MBUTTONDOWN;
+      CurInfo->ButtonsDown |= MK_MBUTTON;
       MsqInsertSystemMessage(&Msg);
-    }
-    if(mi->mouseData & XBUTTON2)
-    {
-      QueueKeyStateTable[VK_XBUTTON2] &= ~0x80;
-      Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON2);
-      CurInfo->ButtonsDown &= ~XBUTTON2;
+   }
+   else if(mi->dwFlags & MOUSEEVENTF_MIDDLEUP)
+   {
+      QueueKeyStateTable[VK_MBUTTON] &= ~0x80;
+      Msg.message = WM_MBUTTONUP;
+      CurInfo->ButtonsDown &= ~MK_MBUTTON;
+      MsqInsertSystemMessage(&Msg);
+   }
+   if(mi->dwFlags & MOUSEEVENTF_RIGHTDOWN)
+   {
+      QueueKeyStateTable[VK_RBUTTON] |= 0xc0;
+      Msg.message = SwapBtnMsg[0][!SwapButtons];
+      CurInfo->ButtonsDown |= SwapBtn[!SwapButtons];
+      MsqInsertSystemMessage(&Msg);
+   }
+   else if(mi->dwFlags & MOUSEEVENTF_RIGHTUP)
+   {
+      QueueKeyStateTable[VK_RBUTTON] &= ~0x80;
+      Msg.message = SwapBtnMsg[1][!SwapButtons];
+      CurInfo->ButtonsDown &= ~SwapBtn[!SwapButtons];
+      MsqInsertSystemMessage(&Msg);
+   }
+
+   if((mi->dwFlags & (MOUSEEVENTF_XDOWN | MOUSEEVENTF_XUP)) &&
+         (mi->dwFlags & MOUSEEVENTF_WHEEL))
+   {
+      /* fail because both types of events use the mouseData field */
+      return FALSE;
+   }
+
+   if(mi->dwFlags & MOUSEEVENTF_XDOWN)
+   {
+      Msg.message = WM_XBUTTONDOWN;
+      if(mi->mouseData & XBUTTON1)
+      {
+         QueueKeyStateTable[VK_XBUTTON1] |= 0xc0;
+         Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON1);
+         CurInfo->ButtonsDown |= XBUTTON1;
+         MsqInsertSystemMessage(&Msg);
+      }
+      if(mi->mouseData & XBUTTON2)
+      {
+         QueueKeyStateTable[VK_XBUTTON2] |= 0xc0;
+         Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON2);
+         CurInfo->ButtonsDown |= XBUTTON2;
+         MsqInsertSystemMessage(&Msg);
+      }
+   }
+   else if(mi->dwFlags & MOUSEEVENTF_XUP)
+   {
+      Msg.message = WM_XBUTTONUP;
+      if(mi->mouseData & XBUTTON1)
+      {
+         QueueKeyStateTable[VK_XBUTTON1] &= ~0x80;
+         Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON1);
+         CurInfo->ButtonsDown &= ~XBUTTON1;
+         MsqInsertSystemMessage(&Msg);
+      }
+      if(mi->mouseData & XBUTTON2)
+      {
+         QueueKeyStateTable[VK_XBUTTON2] &= ~0x80;
+         Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON2);
+         CurInfo->ButtonsDown &= ~XBUTTON2;
+         MsqInsertSystemMessage(&Msg);
+      }
+   }
+   if(mi->dwFlags & MOUSEEVENTF_WHEEL)
+   {
+      Msg.message = WM_MOUSEWHEEL;
+      Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, mi->mouseData);
       MsqInsertSystemMessage(&Msg);
-    }
-  }
-  if(mi->dwFlags & MOUSEEVENTF_WHEEL)
-  {
-    Msg.message = WM_MOUSEWHEEL;
-    Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, mi->mouseData);
-    MsqInsertSystemMessage(&Msg);
-  }
-
-  return TRUE;
+   }
+
+   return TRUE;
 }
 
 BOOL FASTCALL
 IntKeyboardInput(KEYBDINPUT *ki)
 {
-  return FALSE;
+   return FALSE;
 }
 
 UINT
 STDCALL
 NtUserSendInput(
-  UINT nInputs,
-  LPINPUT pInput,
-  INT cbSize)
+   UINT nInputs,
+   LPINPUT pInput,
+   INT cbSize)
 {
-  PW32THREAD W32Thread;
-  UINT cnt;
-  DECLARE_RETURN(UINT);  
-
-  DPRINT("Enter NtUserSendInput\n");
-  UserEnterExclusive();
-
-  W32Thread = PsGetWin32Thread();
-  ASSERT(W32Thread);
-
-  if(!W32Thread->Desktop)
-  {
-    RETURN( 0);
-  }
-
-  if(!nInputs || !pInput || (cbSize != sizeof(INPUT)))
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    RETURN( 0);
-  }
-
-  /*
-   * FIXME - check access rights of the window station
-   *         e.g. services running in the service window station cannot block input
-   */
-  if(!ThreadHasInputAccess(W32Thread) ||
-     !IntIsActiveDesktop(W32Thread->Desktop))
-  {
-    SetLastWin32Error(ERROR_ACCESS_DENIED);
-    RETURN( 0);
-  }
-
-  cnt = 0;
-  while(nInputs--)
-  {
-    INPUT SafeInput;
-    NTSTATUS Status;
-
-    Status = MmCopyFromCaller(&SafeInput, pInput++, sizeof(INPUT));
-    if(!NT_SUCCESS(Status))
-    {
-      SetLastNtError(Status);
-      RETURN( cnt);
-    }
-
-    switch(SafeInput.type)
-    {
-      case INPUT_MOUSE:
-        if(IntMouseInput(&SafeInput.mi))
-        {
-          cnt++;
-        }
-        break;
-      case INPUT_KEYBOARD:
-        if(IntKeyboardInput(&SafeInput.ki))
-        {
-          cnt++;
-        }
-        break;
-      case INPUT_HARDWARE:
-        break;
+   PW32THREAD W32Thread;
+   UINT cnt;
+   DECLARE_RETURN(UINT);
+
+   DPRINT("Enter NtUserSendInput\n");
+   UserEnterExclusive();
+
+   W32Thread = PsGetWin32Thread();
+   ASSERT(W32Thread);
+
+   if(!W32Thread->Desktop)
+   {
+      RETURN( 0);
+   }
+
+   if(!nInputs || !pInput || (cbSize != sizeof(INPUT)))
+   {
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      RETURN( 0);
+   }
+
+   /*
+    * FIXME - check access rights of the window station
+    *         e.g. services running in the service window station cannot block input
+    */
+   if(!ThreadHasInputAccess(W32Thread) ||
+         !IntIsActiveDesktop(W32Thread->Desktop))
+   {
+      SetLastWin32Error(ERROR_ACCESS_DENIED);
+      RETURN( 0);
+   }
+
+   cnt = 0;
+   while(nInputs--)
+   {
+      INPUT SafeInput;
+      NTSTATUS Status;
+
+      Status = MmCopyFromCaller(&SafeInput, pInput++, sizeof(INPUT));
+      if(!NT_SUCCESS(Status))
+      {
+         SetLastNtError(Status);
+         RETURN( cnt);
+      }
+
+      switch(SafeInput.type)
+      {
+         case INPUT_MOUSE:
+            if(IntMouseInput(&SafeInput.mi))
+            {
+               cnt++;
+            }
+            break;
+         case INPUT_KEYBOARD:
+            if(IntKeyboardInput(&SafeInput.ki))
+            {
+               cnt++;
+            }
+            break;
+         case INPUT_HARDWARE:
+            break;
 #ifndef NDEBUG
-      default:
-        DPRINT1("SendInput(): Invalid input type: 0x%x\n", SafeInput.type);
-        break;
+
+         default:
+            DPRINT1("SendInput(): Invalid input type: 0x%x\n", SafeInput.type);
+            break;
 #endif
-    }
-  }
 
-  RETURN( cnt);
+      }
+   }
+
+   RETURN( cnt);
 
 CLEANUP:
-  DPRINT("Leave NtUserSendInput, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserSendInput, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 /* EOF */
index 6307ad9..6c8f916 100644 (file)
@@ -63,304 +63,337 @@ BYTE QueueKeyStateTable[256];
 /* FUNCTIONS *****************************************************************/
 
 /* Initialization -- Right now, just zero the key state and init the lock */
-NTSTATUS FASTCALL InitKeyboardImpl(VOID) {
-  ExInitializeFastMutex(&QueueStateLock);
-  RtlZeroMemory(&QueueKeyStateTable,0x100);
-  return STATUS_SUCCESS;
+NTSTATUS FASTCALL InitKeyboardImpl(VOID)
+{
+   ExInitializeFastMutex(&QueueStateLock);
+   RtlZeroMemory(&QueueKeyStateTable,0x100);
+   return STATUS_SUCCESS;
 }
 
 /*** Statics used by TranslateMessage ***/
 
 /*** Shift state code was out of hand, sorry. --- arty */
 
-static UINT DontDistinguishShifts( UINT ret ) {
-    if( ret == VK_LSHIFT || ret == VK_RSHIFT ) ret = VK_LSHIFT;
-    if( ret == VK_LCONTROL || ret == VK_RCONTROL ) ret = VK_LCONTROL;
-    if( ret == VK_LMENU || ret == VK_RMENU ) ret = VK_LMENU;
-    return ret;
+static UINT DontDistinguishShifts( UINT ret )
+{
+   if( ret == VK_LSHIFT || ret == VK_RSHIFT )
+      ret = VK_LSHIFT;
+   if( ret == VK_LCONTROL || ret == VK_RCONTROL )
+      ret = VK_LCONTROL;
+   if( ret == VK_LMENU || ret == VK_RMENU )
+      ret = VK_LMENU;
+   return ret;
 }
 
-static VOID STDCALL SetKeyState(DWORD key, DWORD vk, DWORD ext, BOOL down) {
-  ASSERT(vk <= 0xff);
-
-  /* Special handling for toggles like numpad and caps lock */
-  if (vk == VK_CAPITAL || vk == VK_NUMLOCK) {
-    if (down) QueueKeyStateTable[vk] ^= KS_LOCK_BIT;
-  }
-
-  if (ext && vk == VK_LSHIFT)
-    vk = VK_RSHIFT;
-  if (ext && vk == VK_LCONTROL)
-    vk = VK_RCONTROL;
-  if (ext && vk == VK_LMENU)
-    vk = VK_RMENU;
-
-  if (down)
-    QueueKeyStateTable[vk] |= KS_DOWN_BIT;
-  else
-    QueueKeyStateTable[vk] &= ~KS_DOWN_MASK;
-
-  if (vk == VK_LSHIFT || vk == VK_RSHIFT) {
-    if ((QueueKeyStateTable[VK_LSHIFT] & KS_DOWN_BIT) ||
-        (QueueKeyStateTable[VK_RSHIFT] & KS_DOWN_BIT)) {
-      QueueKeyStateTable[VK_SHIFT] |= KS_DOWN_BIT;
-    } else {
-      QueueKeyStateTable[VK_SHIFT] &= ~KS_DOWN_MASK;
-    }
-  }
-
-  if (vk == VK_LCONTROL || vk == VK_RCONTROL) {
-    if ((QueueKeyStateTable[VK_LCONTROL] & KS_DOWN_BIT) ||
-        (QueueKeyStateTable[VK_RCONTROL] & KS_DOWN_BIT)) {
-      QueueKeyStateTable[VK_CONTROL] |= KS_DOWN_BIT;
-    } else {
-      QueueKeyStateTable[VK_CONTROL] &= ~KS_DOWN_MASK;
-    }
-  }
-
-  if (vk == VK_LMENU || vk == VK_RMENU) {
-    if ((QueueKeyStateTable[VK_LMENU] & KS_DOWN_BIT) ||
-        (QueueKeyStateTable[VK_RMENU] & KS_DOWN_BIT)) {
-      QueueKeyStateTable[VK_MENU] |= KS_DOWN_BIT;
-    } else {
-      QueueKeyStateTable[VK_MENU] &= ~KS_DOWN_MASK;
-    }
-  }
-}
+static VOID STDCALL SetKeyState(DWORD key, DWORD vk, DWORD ext, BOOL down)
+{
+   ASSERT(vk <= 0xff);
+
+   /* Special handling for toggles like numpad and caps lock */
+   if (vk == VK_CAPITAL || vk == VK_NUMLOCK)
+   {
+      if (down)
+         QueueKeyStateTable[vk] ^= KS_LOCK_BIT;
+   }
+
+   if (ext && vk == VK_LSHIFT)
+      vk = VK_RSHIFT;
+   if (ext && vk == VK_LCONTROL)
+      vk = VK_RCONTROL;
+   if (ext && vk == VK_LMENU)
+      vk = VK_RMENU;
+
+   if (down)
+      QueueKeyStateTable[vk] |= KS_DOWN_BIT;
+   else
+      QueueKeyStateTable[vk] &= ~KS_DOWN_MASK;
+
+   if (vk == VK_LSHIFT || vk == VK_RSHIFT)
+   {
+      if ((QueueKeyStateTable[VK_LSHIFT] & KS_DOWN_BIT) ||
+            (QueueKeyStateTable[VK_RSHIFT] & KS_DOWN_BIT))
+      {
+         QueueKeyStateTable[VK_SHIFT] |= KS_DOWN_BIT;
+      }
+      else
+      {
+         QueueKeyStateTable[VK_SHIFT] &= ~KS_DOWN_MASK;
+      }
+   }
 
-VOID DumpKeyState( PBYTE KeyState ) {
-  int i;
+   if (vk == VK_LCONTROL || vk == VK_RCONTROL)
+   {
+      if ((QueueKeyStateTable[VK_LCONTROL] & KS_DOWN_BIT) ||
+            (QueueKeyStateTable[VK_RCONTROL] & KS_DOWN_BIT))
+      {
+         QueueKeyStateTable[VK_CONTROL] |= KS_DOWN_BIT;
+      }
+      else
+      {
+         QueueKeyStateTable[VK_CONTROL] &= ~KS_DOWN_MASK;
+      }
+   }
 
-  DbgPrint( "KeyState { " );
-  for( i = 0; i < 0x100; i++ ) {
-    if( KeyState[i] ) DbgPrint( "%02x(%02x) ", i, KeyState[i] );
-  }
-  DbgPrint( "};\n" );
+   if (vk == VK_LMENU || vk == VK_RMENU)
+   {
+      if ((QueueKeyStateTable[VK_LMENU] & KS_DOWN_BIT) ||
+            (QueueKeyStateTable[VK_RMENU] & KS_DOWN_BIT))
+      {
+         QueueKeyStateTable[VK_MENU] |= KS_DOWN_BIT;
+      }
+      else
+      {
+         QueueKeyStateTable[VK_MENU] &= ~KS_DOWN_MASK;
+      }
+   }
+}
+
+VOID DumpKeyState( PBYTE KeyState )
+{
+   int i;
+
+   DbgPrint( "KeyState { " );
+   for( i = 0; i < 0x100; i++ )
+   {
+      if( KeyState[i] )
+         DbgPrint( "%02x(%02x) ", i, KeyState[i] );
+   }
+   DbgPrint( "};\n" );
 }
 
 static BYTE KeysSet( PKBDTABLES pkKT, PBYTE KeyState,
-                    int FakeModLeft, int FakeModRight ) {
-  if( !KeyState || !pkKT ) return 0;
+                     int FakeModLeft, int FakeModRight )
+{
+   if( !KeyState || !pkKT )
+      return 0;
 
-  /* Search special codes first */
-  if( FakeModLeft && KeyState[FakeModLeft] )
+   /* Search special codes first */
+   if( FakeModLeft && KeyState[FakeModLeft] )
       return KeyState[FakeModLeft];
-  else if( FakeModRight && KeyState[FakeModRight] )
+   else if( FakeModRight && KeyState[FakeModRight] )
       return KeyState[FakeModRight];
 
-  return 0;
+   return 0;
 }
 
 /* Search the keyboard layout modifiers table for the shift bit.  I don't
  * want to count on the shift bit not moving, because it can be specified
  * in the layout */
 
-static DWORD FASTCALL GetShiftBit( PKBDTABLES pkKT, DWORD Vk ) {
-  int i;
+static DWORD FASTCALL GetShiftBit( PKBDTABLES pkKT, DWORD Vk )
+{
+   int i;
 
-  for( i = 0; pkKT->pCharModifiers->pVkToBit[i].Vk; i++ )
-    if( pkKT->pCharModifiers->pVkToBit[i].Vk == Vk )
-      return pkKT->pCharModifiers->pVkToBit[i].ModBits;
+   for( i = 0; pkKT->pCharModifiers->pVkToBit[i].Vk; i++ )
+      if( pkKT->pCharModifiers->pVkToBit[i].Vk == Vk )
+         return pkKT->pCharModifiers->pVkToBit[i].ModBits;
 
-  return 0;
+   return 0;
 }
 
-static DWORD ModBits( PKBDTABLES pkKT, PBYTE KeyState ) {
-  DWORD ModBits = 0;
+static DWORD ModBits( PKBDTABLES pkKT, PBYTE KeyState )
+{
+   DWORD ModBits = 0;
 
-  if( !KeyState ) return 0;
+   if( !KeyState )
+      return 0;
 
-  /* DumpKeyState( KeyState ); */
+   /* DumpKeyState( KeyState ); */
 
-  if (KeysSet( pkKT, KeyState, VK_LSHIFT, VK_RSHIFT ) &
-      KS_DOWN_BIT)
+   if (KeysSet( pkKT, KeyState, VK_LSHIFT, VK_RSHIFT ) &
+         KS_DOWN_BIT)
       ModBits |= GetShiftBit( pkKT, VK_SHIFT );
 
-  if (KeysSet( pkKT, KeyState, VK_LCONTROL, VK_RCONTROL ) &
-      KS_DOWN_BIT )
+   if (KeysSet( pkKT, KeyState, VK_LCONTROL, VK_RCONTROL ) &
+         KS_DOWN_BIT )
       ModBits |= GetShiftBit( pkKT, VK_CONTROL );
 
-  if (KeysSet( pkKT, KeyState, VK_LMENU, VK_RMENU ) &
-      KS_DOWN_BIT )
+   if (KeysSet( pkKT, KeyState, VK_LMENU, VK_RMENU ) &
+         KS_DOWN_BIT )
       ModBits |= GetShiftBit( pkKT, VK_MENU );
 
-  /* Handle Alt+Gr */
-  if (KeysSet( pkKT, KeyState, VK_RMENU, 0 ) &
-      KS_DOWN_BIT )
+   /* Handle Alt+Gr */
+   if (KeysSet( pkKT, KeyState, VK_RMENU, 0 ) &
+         KS_DOWN_BIT )
       ModBits |= GetShiftBit( pkKT, VK_CONTROL );
 
-      /* Deal with VK_CAPITAL */
-  if (KeysSet( pkKT, KeyState, VK_CAPITAL, 0 ) & KS_LOCK_BIT)
-    {
+   /* Deal with VK_CAPITAL */
+   if (KeysSet( pkKT, KeyState, VK_CAPITAL, 0 ) & KS_LOCK_BIT)
+   {
       ModBits |= CAPITAL_BIT;
-    }
+   }
 
-  /* Deal with VK_NUMLOCK */
-  if (KeysSet( pkKT, KeyState, VK_NUMLOCK, 0 ) & KS_LOCK_BIT)
-    {
+   /* Deal with VK_NUMLOCK */
+   if (KeysSet( pkKT, KeyState, VK_NUMLOCK, 0 ) & KS_LOCK_BIT)
+   {
       ModBits |= NUMLOCK_BIT;
-    }
+   }
 
-  DPRINT( "Current Mod Bits: %x\n", ModBits );
+   DPRINT( "Current Mod Bits: %x\n", ModBits );
 
-  return ModBits;
+   return ModBits;
 }
 
 static BOOL TryToTranslateChar(WORD wVirtKey,
-                              DWORD ModBits,
-                              PBOOL pbDead,
-                              PBOOL pbLigature,
-                              PWCHAR pwcTranslatedChar,
-                              PKBDTABLES keyLayout )
+                               DWORD ModBits,
+                               PBOOL pbDead,
+                               PBOOL pbLigature,
+                               PWCHAR pwcTranslatedChar,
+                               PKBDTABLES keyLayout )
 {
-  PVK_TO_WCHAR_TABLE vtwTbl;
-  PVK_TO_WCHARS10 vkPtr;
-  size_t size_this_entry;
-  int nMod;
-  DWORD CapsMod = 0, CapsState = 0;
+   PVK_TO_WCHAR_TABLE vtwTbl;
+   PVK_TO_WCHARS10 vkPtr;
+   size_t size_this_entry;
+   int nMod;
+   DWORD CapsMod = 0, CapsState = 0;
 
-  CapsState = ModBits & ~MOD_BITS_MASK;
-  ModBits = ModBits & MOD_BITS_MASK;
+   CapsState = ModBits & ~MOD_BITS_MASK;
+   ModBits = ModBits & MOD_BITS_MASK;
 
-  DPRINT ( "TryToTranslate: %04x %x\n", wVirtKey, ModBits );
+   DPRINT ( "TryToTranslate: %04x %x\n", wVirtKey, ModBits );
 
-  if (ModBits > keyLayout->pCharModifiers->wMaxModBits)
-    {
+   if (ModBits > keyLayout->pCharModifiers->wMaxModBits)
+   {
       return FALSE;
-    }
-  for (nMod = 0; keyLayout->pVkToWcharTable[nMod].nModifications; nMod++)
-    {
+   }
+   for (nMod = 0; keyLayout->pVkToWcharTable[nMod].nModifications; nMod++)
+   {
       vtwTbl = &keyLayout->pVkToWcharTable[nMod];
       size_this_entry = vtwTbl->cbSize;
       vkPtr = (PVK_TO_WCHARS10)((BYTE *)vtwTbl->pVkToWchars);
       while(vkPtr->VirtualKey)
-        {
-          if( wVirtKey == (vkPtr->VirtualKey & 0xff) )
-           {
-              CapsMod = keyLayout->pCharModifiers->ModNumber
-                  [ModBits ^
-                   ((CapsState & CAPITAL_BIT) ? vkPtr->Attributes : 0)];
-
-             if( CapsMod > keyLayout->pVkToWcharTable[nMod].nModifications ) {
-                 DWORD MaxBit = 1;
-                 while( MaxBit <
-                        keyLayout->pVkToWcharTable[nMod].nModifications )
-                     MaxBit <<= 1;
-
-                 CapsMod &= MaxBit - 1; /* Guarantee that CapsMod lies
-                                           in bounds. */
-             }
-
-             *pbDead = vkPtr->wch[CapsMod] == WCH_DEAD;
-             *pbLigature = vkPtr->wch[CapsMod] == WCH_LGTR;
-             *pwcTranslatedChar = vkPtr->wch[CapsMod];
-
-             DPRINT("%d %04x: CapsMod %08x CapsState %08x Char %04x\n",
-                      nMod, wVirtKey,
-                      CapsMod, CapsState, *pwcTranslatedChar);
-
-             if( *pbDead )
-               {
-                  vkPtr = (PVK_TO_WCHARS10)(((BYTE *)vkPtr) + size_this_entry);
-                 if( vkPtr->VirtualKey != 0xff )
-                   {
-                     DPRINT( "Found dead key with no trailer in the table.\n" );
-                     DPRINT( "VK: %04x, ADDR: %08x\n", wVirtKey, (int)vkPtr );
-                     return FALSE;
-                   }
-                 *pwcTranslatedChar = vkPtr->wch[CapsMod];
-               }
-               return TRUE;
-           }
-          vkPtr = (PVK_TO_WCHARS10)(((BYTE *)vkPtr) + size_this_entry);
-       }
-    }
-  return FALSE;
+      {
+         if( wVirtKey == (vkPtr->VirtualKey & 0xff) )
+         {
+            CapsMod = keyLayout->pCharModifiers->ModNumber
+                      [ModBits ^
+                       ((CapsState & CAPITAL_BIT) ? vkPtr->Attributes : 0)];
+
+            if( CapsMod > keyLayout->pVkToWcharTable[nMod].nModifications )
+            {
+               DWORD MaxBit = 1;
+               while( MaxBit <
+                      keyLayout->pVkToWcharTable[nMod].nModifications )
+                  MaxBit <<= 1;
+
+               CapsMod &= MaxBit - 1; /* Guarantee that CapsMod lies
+                        in bounds. */
+            }
+
+            *pbDead = vkPtr->wch[CapsMod] == WCH_DEAD;
+            *pbLigature = vkPtr->wch[CapsMod] == WCH_LGTR;
+            *pwcTranslatedChar = vkPtr->wch[CapsMod];
+
+            DPRINT("%d %04x: CapsMod %08x CapsState %08x Char %04x\n",
+                   nMod, wVirtKey,
+                   CapsMod, CapsState, *pwcTranslatedChar);
+
+            if( *pbDead )
+            {
+               vkPtr = (PVK_TO_WCHARS10)(((BYTE *)vkPtr) + size_this_entry);
+               if( vkPtr->VirtualKey != 0xff )
+               {
+                  DPRINT( "Found dead key with no trailer in the table.\n" );
+                  DPRINT( "VK: %04x, ADDR: %08x\n", wVirtKey, (int)vkPtr );
+                  return FALSE;
+               }
+               *pwcTranslatedChar = vkPtr->wch[CapsMod];
+            }
+            return TRUE;
+         }
+         vkPtr = (PVK_TO_WCHARS10)(((BYTE *)vkPtr) + size_this_entry);
+      }
+   }
+   return FALSE;
 }
 
 static
 int STDCALL
 ToUnicodeInner(UINT wVirtKey,
-              UINT wScanCode,
-              PBYTE lpKeyState,
-              LPWSTR pwszBuff,
-              int cchBuff,
-              UINT wFlags,
-              PKBDTABLES pkKT)
+               UINT wScanCode,
+               PBYTE lpKeyState,
+               LPWSTR pwszBuff,
+               int cchBuff,
+               UINT wFlags,
+               PKBDTABLES pkKT)
 {
-  WCHAR wcTranslatedChar;
-  BOOL bDead;
-  BOOL bLigature;
-
-  if( !pkKT ) return 0;
-
-  if( TryToTranslateChar( wVirtKey,
-                         ModBits( pkKT, lpKeyState ),
-                         &bDead,
-                         &bLigature,
-                         &wcTranslatedChar,
-                         pkKT ) )
-    {
+   WCHAR wcTranslatedChar;
+   BOOL bDead;
+   BOOL bLigature;
+
+   if( !pkKT )
+      return 0;
+
+   if( TryToTranslateChar( wVirtKey,
+                           ModBits( pkKT, lpKeyState ),
+                           &bDead,
+                           &bLigature,
+                           &wcTranslatedChar,
+                           pkKT ) )
+   {
       if( bLigature )
-        {
-         DPRINT("Not handling ligature (yet)\n" );
-         return 0;
-        }
+      {
+         DPRINT("Not handling ligature (yet)\n" );
+         return 0;
+      }
 
-      if( cchBuff > 0 ) pwszBuff[0] = wcTranslatedChar;
+      if( cchBuff > 0 )
+         pwszBuff[0] = wcTranslatedChar;
 
       return bDead ? -1 : 1;
-    }
+   }
 
-  return 0;
+   return 0;
 }
 
 
 DWORD FASTCALL UserGetKeyState(DWORD key)
 {
-  DWORD ret = 0;
-
-  IntLockQueueState;
-  if( key < 0x100 ) {
-    ret = ((DWORD)(QueueKeyStateTable[key] & KS_DOWN_BIT) << 8 ) |
-      (QueueKeyStateTable[key] & KS_LOCK_BIT);
-  }
-  IntUnLockQueueState;
-  return ret;
+   DWORD ret = 0;
+
+   IntLockQueueState;
+   if( key < 0x100 )
+   {
+      ret = ((DWORD)(QueueKeyStateTable[key] & KS_DOWN_BIT) << 8 ) |
+            (QueueKeyStateTable[key] & KS_LOCK_BIT);
+   }
+   IntUnLockQueueState;
+   return ret;
 }
 
 
 DWORD
 STDCALL
 NtUserGetKeyState(
-  DWORD key)
+   DWORD key)
 {
-  DECLARE_RETURN(DWORD);  
+   DECLARE_RETURN(DWORD);
+
+   DPRINT("Enter NtUserGetKeyState\n");
+   UserEnterExclusive();
+
+   RETURN(UserGetKeyState(key));
 
-  DPRINT("Enter NtUserGetKeyState\n");
-  UserEnterExclusive();
-  
-  RETURN(UserGetKeyState(key));
-  
 CLEANUP:
-  DPRINT("Leave NtUserGetKeyState, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetKeyState, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
 
 DWORD FASTCALL UserGetAsyncKeyState(DWORD key)
 {
-  DWORD ret = 0;
-
-  IntLockQueueState;
-  if( key < 0x100 ) {
-    ret = ((DWORD)(QueueKeyStateTable[key] & KS_DOWN_BIT) << 8 ) |
-      (QueueKeyStateTable[key] & KS_LOCK_BIT);
-  }
-  IntUnLockQueueState;
-  return ret;
+   DWORD ret = 0;
+
+   IntLockQueueState;
+   if( key < 0x100 )
+   {
+      ret = ((DWORD)(QueueKeyStateTable[key] & KS_DOWN_BIT) << 8 ) |
+            (QueueKeyStateTable[key] & KS_LOCK_BIT);
+   }
+   IntUnLockQueueState;
+   return ret;
 }
 
 
@@ -368,66 +401,68 @@ DWORD FASTCALL UserGetAsyncKeyState(DWORD key)
 DWORD
 STDCALL
 NtUserGetAsyncKeyState(
-  DWORD key)
+   DWORD key)
 {
-  DECLARE_RETURN(DWORD);  
+   DECLARE_RETURN(DWORD);
+
+   DPRINT("Enter NtUserGetAsyncKeyState\n");
+   UserEnterExclusive();
+
+   RETURN(UserGetAsyncKeyState(key));
 
-  DPRINT("Enter NtUserGetAsyncKeyState\n");
-  UserEnterExclusive();
-  
-  RETURN(UserGetAsyncKeyState(key));
-  
 CLEANUP:
-  DPRINT("Leave NtUserGetAsyncKeyState, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetAsyncKeyState, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
 
 int STDCALL ToUnicodeEx( UINT wVirtKey,
-                        UINT wScanCode,
-                        PBYTE lpKeyState,
-                        LPWSTR pwszBuff,
-                        int cchBuff,
-                        UINT wFlags,
-                        HKL dwhkl ) {
-  int ToUnicodeResult = 0;
-
-  if (0 == (lpKeyState[wVirtKey] & KS_DOWN_BIT))
-    {
+                         UINT wScanCode,
+                         PBYTE lpKeyState,
+                         LPWSTR pwszBuff,
+                         int cchBuff,
+                         UINT wFlags,
+                         HKL dwhkl )
+{
+   int ToUnicodeResult = 0;
+
+   if (0 == (lpKeyState[wVirtKey] & KS_DOWN_BIT))
+   {
       ToUnicodeResult = 0;
-    }
-  else
-    {
+   }
+   else
+   {
       IntLockQueueState;
       ToUnicodeResult = ToUnicodeInner( wVirtKey,
-                                       wScanCode,
-                                       lpKeyState,
-                                       pwszBuff,
-                                       cchBuff,
-                                       wFlags,
-                                       PsGetWin32Thread() ?
-                                       PsGetWin32Thread()->KeyboardLayout : 0 );
+                                        wScanCode,
+                                        lpKeyState,
+                                        pwszBuff,
+                                        cchBuff,
+                                        wFlags,
+                                        PsGetWin32Thread() ?
+                                        PsGetWin32Thread()->KeyboardLayout : 0 );
       IntUnLockQueueState;
-    }
+   }
 
-  return ToUnicodeResult;
+   return ToUnicodeResult;
 }
 
 int STDCALL ToUnicode( UINT wVirtKey,
-                      UINT wScanCode,
-                      PBYTE lpKeyState,
-                      LPWSTR pwszBuff,
-                      int cchBuff,
-                      UINT wFlags ) {
-  return ToUnicodeEx( wVirtKey,
-                     wScanCode,
-                     QueueKeyStateTable,
-                     pwszBuff,
-                     cchBuff,
-                     wFlags,
-                     0 );
+                       UINT wScanCode,
+                       PBYTE lpKeyState,
+                       LPWSTR pwszBuff,
+                       int cchBuff,
+                       UINT wFlags )
+{
+   return ToUnicodeEx( wVirtKey,
+                       wScanCode,
+                       QueueKeyStateTable,
+                       pwszBuff,
+                       cchBuff,
+                       wFlags,
+                       0 );
 }
 
 /*
@@ -442,29 +477,32 @@ int STDCALL ToUnicode( UINT wVirtKey,
  */
 
 NTSTATUS NTAPI AppendUnicodeString(PUNICODE_STRING ResultFirst,
-                                  PUNICODE_STRING Second,
-                                  BOOL Deallocate) {
-    NTSTATUS Status;
-    PWSTR new_string =
-       ExAllocatePoolWithTag(PagedPool,
-                             (ResultFirst->Length + Second->Length + sizeof(WCHAR)),
-                             TAG_STRING);
-    if( !new_string ) {
-       return STATUS_NO_MEMORY;
-    }
-    memcpy( new_string, ResultFirst->Buffer,
-           ResultFirst->Length );
-    memcpy( new_string + ResultFirst->Length / sizeof(WCHAR),
-           Second->Buffer,
-           Second->Length );
-    if( Deallocate ) RtlFreeUnicodeString(ResultFirst);
-    ResultFirst->Length += Second->Length;
-    ResultFirst->MaximumLength = ResultFirst->Length;
-    new_string[ResultFirst->Length / sizeof(WCHAR)] = 0;
-    Status = RtlCreateUnicodeString(ResultFirst,new_string) ?
-       STATUS_SUCCESS : STATUS_NO_MEMORY;
-    ExFreePool(new_string);
-    return Status;
+                                   PUNICODE_STRING Second,
+                                   BOOL Deallocate)
+{
+   NTSTATUS Status;
+   PWSTR new_string =
+      ExAllocatePoolWithTag(PagedPool,
+                            (ResultFirst->Length + Second->Length + sizeof(WCHAR)),
+                            TAG_STRING);
+   if( !new_string )
+   {
+      return STATUS_NO_MEMORY;
+   }
+   memcpy( new_string, ResultFirst->Buffer,
+           ResultFirst->Length );
+   memcpy( new_string + ResultFirst->Length / sizeof(WCHAR),
+           Second->Buffer,
+           Second->Length );
+   if( Deallocate )
+      RtlFreeUnicodeString(ResultFirst);
+   ResultFirst->Length += Second->Length;
+   ResultFirst->MaximumLength = ResultFirst->Length;
+   new_string[ResultFirst->Length / sizeof(WCHAR)] = 0;
+   Status = RtlCreateUnicodeString(ResultFirst,new_string) ?
+            STATUS_SUCCESS : STATUS_NO_MEMORY;
+   ExFreePool(new_string);
+   return Status;
 }
 
 /*
@@ -478,253 +516,267 @@ NTSTATUS NTAPI AppendUnicodeString(PUNICODE_STRING ResultFirst,
  */
 
 static NTSTATUS NTAPI ReadRegistryValue( PUNICODE_STRING KeyName,
-                                        PUNICODE_STRING ValueName,
-                                        PUNICODE_STRING ReturnedValue ) {
-    NTSTATUS Status;
-    HANDLE KeyHandle;
-    OBJECT_ATTRIBUTES KeyAttributes;
-    PKEY_VALUE_PARTIAL_INFORMATION KeyValuePartialInfo;
-    ULONG Length = 0;
-    ULONG ResLength = 0;
-    UNICODE_STRING Temp;
-
-    InitializeObjectAttributes(&KeyAttributes, KeyName, OBJ_CASE_INSENSITIVE,
-                              NULL, NULL);
-    Status = ZwOpenKey(&KeyHandle, KEY_ALL_ACCESS, &KeyAttributes);
-    if( !NT_SUCCESS(Status) ) {
-       return Status;
-    }
-
-    Status = ZwQueryValueKey(KeyHandle, ValueName, KeyValuePartialInformation,
-                            0,
-                            0,
-                            &ResLength);
-
-    if( Status != STATUS_BUFFER_TOO_SMALL ) {
-       NtClose(KeyHandle);
-       return Status;
-    }
-
-    ResLength += sizeof( *KeyValuePartialInfo );
-    KeyValuePartialInfo =
-       ExAllocatePoolWithTag(PagedPool, ResLength, TAG_STRING);
-    Length = ResLength;
-
-    if( !KeyValuePartialInfo ) {
-       NtClose(KeyHandle);
-       return STATUS_NO_MEMORY;
-    }
-
-    Status = ZwQueryValueKey(KeyHandle, ValueName, KeyValuePartialInformation,
-                            (PVOID)KeyValuePartialInfo,
-                            Length,
-                            &ResLength);
-
-    if( !NT_SUCCESS(Status) ) {
-       NtClose(KeyHandle);
-       ExFreePool(KeyValuePartialInfo);
-       return Status;
-    }
-
-    Temp.Length = Temp.MaximumLength = KeyValuePartialInfo->DataLength;
-    Temp.Buffer = (PWCHAR)KeyValuePartialInfo->Data;
-
-    /* At this point, KeyValuePartialInfo->Data contains the key data */
-    RtlInitUnicodeString(ReturnedValue,L"");
-    AppendUnicodeString(ReturnedValue,&Temp,FALSE);
-
-    ExFreePool(KeyValuePartialInfo);
-    NtClose(KeyHandle);
-
-    return Status;
+      PUNICODE_STRING ValueName,
+      PUNICODE_STRING ReturnedValue )
+{
+   NTSTATUS Status;
+   HANDLE KeyHandle;
+   OBJECT_ATTRIBUTES KeyAttributes;
+   PKEY_VALUE_PARTIAL_INFORMATION KeyValuePartialInfo;
+   ULONG Length = 0;
+   ULONG ResLength = 0;
+   UNICODE_STRING Temp;
+
+   InitializeObjectAttributes(&KeyAttributes, KeyName, OBJ_CASE_INSENSITIVE,
+                              NULL, NULL);
+   Status = ZwOpenKey(&KeyHandle, KEY_ALL_ACCESS, &KeyAttributes);
+   if( !NT_SUCCESS(Status) )
+   {
+      return Status;
+   }
+
+   Status = ZwQueryValueKey(KeyHandle, ValueName, KeyValuePartialInformation,
+                            0,
+                            0,
+                            &ResLength);
+
+   if( Status != STATUS_BUFFER_TOO_SMALL )
+   {
+      NtClose(KeyHandle);
+      return Status;
+   }
+
+   ResLength += sizeof( *KeyValuePartialInfo );
+   KeyValuePartialInfo =
+      ExAllocatePoolWithTag(PagedPool, ResLength, TAG_STRING);
+   Length = ResLength;
+
+   if( !KeyValuePartialInfo )
+   {
+      NtClose(KeyHandle);
+      return STATUS_NO_MEMORY;
+   }
+
+   Status = ZwQueryValueKey(KeyHandle, ValueName, KeyValuePartialInformation,
+                            (PVOID)KeyValuePartialInfo,
+                            Length,
+                            &ResLength);
+
+   if( !NT_SUCCESS(Status) )
+   {
+      NtClose(KeyHandle);
+      ExFreePool(KeyValuePartialInfo);
+      return Status;
+   }
+
+   Temp.Length = Temp.MaximumLength = KeyValuePartialInfo->DataLength;
+   Temp.Buffer = (PWCHAR)KeyValuePartialInfo->Data;
+
+   /* At this point, KeyValuePartialInfo->Data contains the key data */
+   RtlInitUnicodeString(ReturnedValue,L"");
+   AppendUnicodeString(ReturnedValue,&Temp,FALSE);
+
+   ExFreePool(KeyValuePartialInfo);
+   NtClose(KeyHandle);
+
+   return Status;
 }
 
 typedef PVOID (*KbdLayerDescriptor)(VOID);
 NTSTATUS STDCALL LdrGetProcedureAddress(PVOID module,
-                                       PANSI_STRING import_name,
-                                       DWORD flags,
-                                       PVOID *func_addr);
+                                        PANSI_STRING import_name,
+                                        DWORD flags,
+                                        PVOID *func_addr);
 
 void InitKbdLayout( PVOID *pkKeyboardLayout )
 {
-  WCHAR LocaleBuffer[16];
-  UNICODE_STRING LayoutKeyName;
-  UNICODE_STRING LayoutValueName;
-  UNICODE_STRING DefaultLocale;
-  UNICODE_STRING LayoutFile;
-  UNICODE_STRING FullLayoutPath;
-  LCID LocaleId;
-  PWCHAR KeyboardLayoutWSTR;
-  HMODULE kbModule = 0;
-  NTSTATUS Status;
-  ANSI_STRING kbdProcedureName;
-  KbdLayerDescriptor layerDescGetFn;
-
-  #define XX_STATUS(x) if (!NT_SUCCESS(Status = (x))) continue;
-
-  do {
-    Status = ZwQueryDefaultLocale(FALSE, &LocaleId);
-    if (!NT_SUCCESS(Status))
-    {
-      DPRINT1("Could not get default locale (%08lx).\n", Status);
-    }
-    else
-    {
-      DPRINT("DefaultLocale = %lx\n", LocaleId);
-      swprintf(LocaleBuffer, L"%08lx", LocaleId);
-      DPRINT("DefaultLocale = %S\n", LocaleBuffer);
-      RtlInitUnicodeString(&DefaultLocale, LocaleBuffer);
-
-      RtlInitUnicodeString(&LayoutKeyName,
-                          L"\\REGISTRY\\Machine\\SYSTEM\\CurrentControlSet"
-                          L"\\Control\\KeyboardLayouts\\");
-
-      AppendUnicodeString(&LayoutKeyName,&DefaultLocale,FALSE);
-
-      RtlInitUnicodeString(&LayoutValueName,L"Layout File");
-
-      Status = ReadRegistryValue(&LayoutKeyName,&LayoutValueName,&LayoutFile);
-      RtlInitUnicodeString(&FullLayoutPath,SYSTEMROOT_DIR);
-
-      if( !NT_SUCCESS(Status) ) {
-       DPRINT1("Got default locale but not layout file. (%08lx)\n",
-                Status);
-      } else {
-       DPRINT("Read registry and got %wZ\n", &LayoutFile);
-
-       RtlFreeUnicodeString(&LayoutKeyName);
-
-       AppendUnicodeString(&FullLayoutPath,&LayoutFile,FALSE);
-
-       DPRINT("Loading Keyboard DLL %wZ\n", &FullLayoutPath);
-
-       RtlFreeUnicodeString(&LayoutFile);
-
-       KeyboardLayoutWSTR =
-         ExAllocatePoolWithTag(PagedPool,
-                               FullLayoutPath.Length + sizeof(WCHAR),
-                               TAG_STRING);
-
-       if( !KeyboardLayoutWSTR ) {
-         DPRINT1("Couldn't allocate a string for the keyboard layout name.\n");
-         RtlFreeUnicodeString(&FullLayoutPath);
-         return;
-       }
-       memcpy(KeyboardLayoutWSTR,FullLayoutPath.Buffer,
-              FullLayoutPath.Length + sizeof(WCHAR));
-       KeyboardLayoutWSTR[FullLayoutPath.Length / sizeof(WCHAR)] = 0;
-
-       kbModule = EngLoadImage(KeyboardLayoutWSTR);
-       DPRINT( "Load Keyboard Layout: %S\n", KeyboardLayoutWSTR );
-
-        if( !kbModule )
-         DPRINT1( "Load Keyboard Layout: No %wZ\n", &FullLayoutPath );
-
-       RtlFreeUnicodeString(&FullLayoutPath);
+   WCHAR LocaleBuffer[16];
+   UNICODE_STRING LayoutKeyName;
+   UNICODE_STRING LayoutValueName;
+   UNICODE_STRING DefaultLocale;
+   UNICODE_STRING LayoutFile;
+   UNICODE_STRING FullLayoutPath;
+   LCID LocaleId;
+   PWCHAR KeyboardLayoutWSTR;
+   HMODULE kbModule = 0;
+   NTSTATUS Status;
+   ANSI_STRING kbdProcedureName;
+   KbdLayerDescriptor layerDescGetFn;
+
+#define XX_STATUS(x) if (!NT_SUCCESS(Status = (x))) continue;
+
+   do
+   {
+      Status = ZwQueryDefaultLocale(FALSE, &LocaleId);
+      if (!NT_SUCCESS(Status))
+      {
+         DPRINT1("Could not get default locale (%08lx).\n", Status);
       }
-    }
+      else
+      {
+         DPRINT("DefaultLocale = %lx\n", LocaleId);
+         swprintf(LocaleBuffer, L"%08lx", LocaleId);
+         DPRINT("DefaultLocale = %S\n", LocaleBuffer);
+         RtlInitUnicodeString(&DefaultLocale, LocaleBuffer);
+
+         RtlInitUnicodeString(&LayoutKeyName,
+                              L"\\REGISTRY\\Machine\\SYSTEM\\CurrentControlSet"
+                              L"\\Control\\KeyboardLayouts\\");
+
+         AppendUnicodeString(&LayoutKeyName,&DefaultLocale,FALSE);
 
-    if( !kbModule )
-    {
-      DPRINT1("Trying to load US Keyboard Layout\n");
-      kbModule = EngLoadImage(L"\\SystemRoot\\system32\\kbdus.dll");
+         RtlInitUnicodeString(&LayoutValueName,L"Layout File");
 
-      if (!kbModule)
+         Status = ReadRegistryValue(&LayoutKeyName,&LayoutValueName,&LayoutFile);
+         RtlInitUnicodeString(&FullLayoutPath,SYSTEMROOT_DIR);
+
+         if( !NT_SUCCESS(Status) )
+         {
+            DPRINT1("Got default locale but not layout file. (%08lx)\n",
+                    Status);
+         }
+         else
+         {
+            DPRINT("Read registry and got %wZ\n", &LayoutFile);
+
+            RtlFreeUnicodeString(&LayoutKeyName);
+
+            AppendUnicodeString(&FullLayoutPath,&LayoutFile,FALSE);
+
+            DPRINT("Loading Keyboard DLL %wZ\n", &FullLayoutPath);
+
+            RtlFreeUnicodeString(&LayoutFile);
+
+            KeyboardLayoutWSTR =
+               ExAllocatePoolWithTag(PagedPool,
+                                     FullLayoutPath.Length + sizeof(WCHAR),
+                                     TAG_STRING);
+
+            if( !KeyboardLayoutWSTR )
+            {
+               DPRINT1("Couldn't allocate a string for the keyboard layout name.\n");
+               RtlFreeUnicodeString(&FullLayoutPath);
+               return;
+            }
+            memcpy(KeyboardLayoutWSTR,FullLayoutPath.Buffer,
+                   FullLayoutPath.Length + sizeof(WCHAR));
+            KeyboardLayoutWSTR[FullLayoutPath.Length / sizeof(WCHAR)] = 0;
+
+            kbModule = EngLoadImage(KeyboardLayoutWSTR);
+            DPRINT( "Load Keyboard Layout: %S\n", KeyboardLayoutWSTR );
+
+            if( !kbModule )
+               DPRINT1( "Load Keyboard Layout: No %wZ\n", &FullLayoutPath );
+
+            RtlFreeUnicodeString(&FullLayoutPath);
+         }
+      }
+
+      if( !kbModule )
       {
-        DPRINT1("Failed to load any Keyboard Layout\n");
-        return;
-           }
-    }
+         DPRINT1("Trying to load US Keyboard Layout\n");
+         kbModule = EngLoadImage(L"\\SystemRoot\\system32\\kbdus.dll");
+
+         if (!kbModule)
+         {
+            DPRINT1("Failed to load any Keyboard Layout\n");
+            return;
+         }
+      }
 
-    RtlInitAnsiString( &kbdProcedureName, "KbdLayerDescriptor" );
+      RtlInitAnsiString( &kbdProcedureName, "KbdLayerDescriptor" );
 
-    LdrGetProcedureAddress((PVOID)kbModule,
-                          &kbdProcedureName,
-                          0,
-                          (PVOID*)&layerDescGetFn);
+      LdrGetProcedureAddress((PVOID)kbModule,
+                             &kbdProcedureName,
+                             0,
+                             (PVOID*)&layerDescGetFn);
 
-    if( layerDescGetFn ) {
-      *pkKeyboardLayout = layerDescGetFn();
-    }
-  } while (FALSE);
+      if( layerDescGetFn )
+      {
+         *pkKeyboardLayout = layerDescGetFn();
+      }
+   }
+   while (FALSE);
 
-  if( !*pkKeyboardLayout ) {
-    DPRINT1("Failed to load the keyboard layout.\n");
-  }
+   if( !*pkKeyboardLayout )
+   {
+      DPRINT1("Failed to load the keyboard layout.\n");
+   }
 
 #undef XX_STATUS
 }
 
-PKBDTABLES W32kGetDefaultKeyLayout() {
-  PKBDTABLES pkKeyboardLayout = 0;
-  InitKbdLayout( (PVOID) &pkKeyboardLayout );
-  return pkKeyboardLayout;
+PKBDTABLES W32kGetDefaultKeyLayout()
+{
+   PKBDTABLES pkKeyboardLayout = 0;
+   InitKbdLayout( (PVOID) &pkKeyboardLayout );
+   return pkKeyboardLayout;
 }
 
 BOOL FASTCALL
 IntTranslateKbdMessage(LPMSG lpMsg,
                        HKL dwhkl)
 {
-  static INT dead_char = 0;
-  LONG UState = 0;
-  WCHAR wp[2] = { 0 };
-  MSG NewMsg = { 0 };
-  PKBDTABLES keyLayout;
-  BOOL Result = FALSE;
-  DWORD ScanCode = 0;
+   static INT dead_char = 0;
+   LONG UState = 0;
+   WCHAR wp[2] = { 0 };
+   MSG NewMsg = { 0 };
+   PKBDTABLES keyLayout;
+   BOOL Result = FALSE;
+   DWORD ScanCode = 0;
 
 
-  keyLayout = PsGetWin32Thread()->KeyboardLayout;
-  if( !keyLayout )
-    return FALSE;
+   keyLayout = PsGetWin32Thread()->KeyboardLayout;
+   if( !keyLayout )
+      return FALSE;
 
-  if (lpMsg->message != WM_KEYDOWN && lpMsg->message != WM_SYSKEYDOWN)
-    return FALSE;
+   if (lpMsg->message != WM_KEYDOWN && lpMsg->message != WM_SYSKEYDOWN)
+      return FALSE;
 
-  ScanCode = (lpMsg->lParam >> 16) & 0xff;
+   ScanCode = (lpMsg->lParam >> 16) & 0xff;
 
-  IntLockQueueState;
+   IntLockQueueState;
 
-  /* All messages have to contain the cursor point. */
-  IntGetCursorLocation(PsGetWin32Thread()->Desktop->WindowStation,
-                       &NewMsg.pt);
+   /* All messages have to contain the cursor point. */
+   IntGetCursorLocation(PsGetWin32Thread()->Desktop->WindowStation,
+                        &NewMsg.pt);
 
-  UState = ToUnicodeInner(lpMsg->wParam, HIWORD(lpMsg->lParam) & 0xff,
-                         QueueKeyStateTable, wp, 2, 0,
-                         keyLayout );
+   UState = ToUnicodeInner(lpMsg->wParam, HIWORD(lpMsg->lParam) & 0xff,
+                           QueueKeyStateTable, wp, 2, 0,
+                           keyLayout );
 
-  if (UState == 1)
-    {
+   if (UState == 1)
+   {
       NewMsg.message = (lpMsg->message == WM_KEYDOWN) ? WM_CHAR : WM_SYSCHAR;
       if (dead_char)
-        {
-         ULONG i;
-         WCHAR first, second;
-         DPRINT("PREVIOUS DEAD CHAR: %c\n", dead_char);
-
-         for( i = 0; keyLayout->pDeadKey[i].dwBoth; i++ )
-           {
-             first = keyLayout->pDeadKey[i].dwBoth >> 16;
-             second = keyLayout->pDeadKey[i].dwBoth;
-             if (first == dead_char && second == wp[0])
-               {
-                 wp[0] = keyLayout->pDeadKey[i].wchComposed;
-                 dead_char = 0;
-                 break;
-               }
-           }
-
-         DPRINT("FINAL CHAR: %c\n", wp[0]);
-       }
+      {
+         ULONG i;
+         WCHAR first, second;
+         DPRINT("PREVIOUS DEAD CHAR: %c\n", dead_char);
+
+         for( i = 0; keyLayout->pDeadKey[i].dwBoth; i++ )
+         {
+            first = keyLayout->pDeadKey[i].dwBoth >> 16;
+            second = keyLayout->pDeadKey[i].dwBoth;
+            if (first == dead_char && second == wp[0])
+            {
+               wp[0] = keyLayout->pDeadKey[i].wchComposed;
+               dead_char = 0;
+               break;
+            }
+         }
+
+         DPRINT("FINAL CHAR: %c\n", wp[0]);
+      }
 
       if (dead_char)
-       {
-         NewMsg.hwnd = lpMsg->hwnd;
-         NewMsg.wParam = dead_char;
-         NewMsg.lParam = lpMsg->lParam;
-         dead_char = 0;
-         MsqPostMessage(PsGetWin32Thread()->MessageQueue, &NewMsg, FALSE, QS_KEY);
-       }
+      {
+         NewMsg.hwnd = lpMsg->hwnd;
+         NewMsg.wParam = dead_char;
+         NewMsg.lParam = lpMsg->lParam;
+         dead_char = 0;
+         MsqPostMessage(PsGetWin32Thread()->MessageQueue, &NewMsg, FALSE, QS_KEY);
+      }
 
       NewMsg.hwnd = lpMsg->hwnd;
       NewMsg.wParam = wp[0];
@@ -732,89 +784,106 @@ IntTranslateKbdMessage(LPMSG lpMsg,
       DPRINT( "CHAR='%c' %04x %08x\n", wp[0], wp[0], lpMsg->lParam );
       MsqPostMessage(PsGetWin32Thread()->MessageQueue, &NewMsg, FALSE, QS_KEY);
       Result = TRUE;
-    }
-  else if (UState == -1)
-    {
+   }
+   else if (UState == -1)
+   {
       NewMsg.message =
-       (lpMsg->message == WM_KEYDOWN) ? WM_DEADCHAR : WM_SYSDEADCHAR;
+         (lpMsg->message == WM_KEYDOWN) ? WM_DEADCHAR : WM_SYSDEADCHAR;
       NewMsg.hwnd = lpMsg->hwnd;
       NewMsg.wParam = wp[0];
       NewMsg.lParam = lpMsg->lParam;
       dead_char = wp[0];
       MsqPostMessage(PsGetWin32Thread()->MessageQueue, &NewMsg, FALSE, QS_KEY);
       Result = TRUE;
-    }
+   }
 
-  IntUnLockQueueState;
-  return Result;
+   IntUnLockQueueState;
+   return Result;
 }
 
 DWORD
 STDCALL
 NtUserGetKeyboardState(
-  LPBYTE lpKeyState)
+   LPBYTE lpKeyState)
 {
-  BOOL Result = TRUE;
-
-  IntLockQueueState;
-  if (lpKeyState) {
-       if(!NT_SUCCESS(MmCopyToCaller(lpKeyState, QueueKeyStateTable, 256)))
-         Result = FALSE;
-  }
-  IntUnLockQueueState;
-  return Result;
+   BOOL Result = TRUE;
+
+   IntLockQueueState;
+   if (lpKeyState)
+   {
+      if(!NT_SUCCESS(MmCopyToCaller(lpKeyState, QueueKeyStateTable, 256)))
+         Result = FALSE;
+   }
+   IntUnLockQueueState;
+   return Result;
 }
 
 DWORD
 STDCALL
 NtUserSetKeyboardState(
-  LPBYTE lpKeyState)
+   LPBYTE lpKeyState)
 {
-  BOOL Result = TRUE;
+   BOOL Result = TRUE;
 
- IntLockQueueState;
-  if (lpKeyState) {
-    if(! NT_SUCCESS(MmCopyFromCaller(QueueKeyStateTable, lpKeyState, 256)))
-      Result = FALSE;
-  }
-  IntUnLockQueueState;
+   IntLockQueueState;
+   if (lpKeyState)
+   {
+      if(! NT_SUCCESS(MmCopyFromCaller(QueueKeyStateTable, lpKeyState, 256)))
+         Result = FALSE;
+   }
+   IntUnLockQueueState;
 
-  return Result;
+   return Result;
 }
 
-static UINT VkToScan( UINT Code, BOOL ExtCode, PKBDTABLES pkKT ) {
-  int i;
+static UINT VkToScan( UINT Code, BOOL ExtCode, PKBDTABLES pkKT )
+{
+   int i;
 
-  for( i = 0; i < pkKT->bMaxVSCtoVK; i++ ) {
-    if( pkKT->pusVSCtoVK[i] == Code ) { return i; }
-  }
+   for( i = 0; i < pkKT->bMaxVSCtoVK; i++ )
+   {
+      if( pkKT->pusVSCtoVK[i] == Code )
+      {
+         return i;
+      }
+   }
 
-  return 0;
+   return 0;
 }
 
-UINT ScanToVk( UINT Code, BOOL ExtKey, PKBDTABLES pkKT ) {
-  if( !pkKT ) {
-    DPRINT("ScanToVk: No layout\n");
-    return 0;
-  }
-
-  if( ExtKey ) {
-    int i;
-
-    for( i = 0; pkKT->pVSCtoVK_E0[i].Vsc; i++ ) {
-      if( pkKT->pVSCtoVK_E0[i].Vsc == Code )
-       return pkKT->pVSCtoVK_E0[i].Vk & 0xff;
-    }
-    for( i = 0; pkKT->pVSCtoVK_E1[i].Vsc; i++ ) {
-      if( pkKT->pVSCtoVK_E1[i].Vsc == Code )
-       return pkKT->pVSCtoVK_E1[i].Vk & 0xff;
-    }
-
-    return 0;
-  } else {
-    if( Code >= pkKT->bMaxVSCtoVK ) { return 0; }
-    return pkKT->pusVSCtoVK[Code] & 0xff;
-  }
+UINT ScanToVk( UINT Code, BOOL ExtKey, PKBDTABLES pkKT )
+{
+   if( !pkKT )
+   {
+      DPRINT("ScanToVk: No layout\n");
+      return 0;
+   }
+
+   if( ExtKey )
+   {
+      int i;
+
+      for( i = 0; pkKT->pVSCtoVK_E0[i].Vsc; i++ )
+      {
+         if( pkKT->pVSCtoVK_E0[i].Vsc == Code )
+            return pkKT->pVSCtoVK_E0[i].Vk & 0xff;
+      }
+      for( i = 0; pkKT->pVSCtoVK_E1[i].Vsc; i++ )
+      {
+         if( pkKT->pVSCtoVK_E1[i].Vsc == Code )
+            return pkKT->pVSCtoVK_E1[i].Vk & 0xff;
+      }
+
+      return 0;
+   }
+   else
+   {
+      if( Code >= pkKT->bMaxVSCtoVK )
+      {
+         return 0;
+      }
+      return pkKT->pusVSCtoVK[Code] & 0xff;
+   }
 }
 
 /*
@@ -836,165 +905,188 @@ UINT ScanToVk( UINT Code, BOOL ExtKey, PKBDTABLES pkKT ) {
  * @implemented
  */
 
-static UINT IntMapVirtualKeyEx( UINT Code, UINT Type, PKBDTABLES keyLayout ) {
-  UINT ret = 0;
-
-  switch( Type ) {
-  case 0:
-    if( Code == VK_RSHIFT ) Code = VK_LSHIFT;
-    if( Code == VK_RMENU ) Code = VK_LMENU;
-    if( Code == VK_RCONTROL ) Code = VK_LCONTROL;
-    ret = VkToScan( Code, FALSE, keyLayout );
-    break;
-
-  case 1:
-    ret =
-      DontDistinguishShifts
-      (IntMapVirtualKeyEx( Code, 3, keyLayout ) );
-    break;
-
-  case 2: {
-    WCHAR wp[2];
-
-    ret = VkToScan( Code, FALSE, keyLayout );
-    ToUnicodeInner( Code, ret, 0, wp, 2, 0, keyLayout );
-    ret = wp[0];
-  } break;
-
-  case 3:
-
-    ret = ScanToVk( Code, FALSE, keyLayout );
-    break;
-  }
-
-  return ret;
+static UINT IntMapVirtualKeyEx( UINT Code, UINT Type, PKBDTABLES keyLayout )
+{
+   UINT ret = 0;
+
+   switch( Type )
+   {
+      case 0:
+         if( Code == VK_RSHIFT )
+            Code = VK_LSHIFT;
+         if( Code == VK_RMENU )
+            Code = VK_LMENU;
+         if( Code == VK_RCONTROL )
+            Code = VK_LCONTROL;
+         ret = VkToScan( Code, FALSE, keyLayout );
+         break;
+
+      case 1:
+         ret =
+            DontDistinguishShifts
+            (IntMapVirtualKeyEx( Code, 3, keyLayout ) );
+         break;
+
+      case 2:
+         {
+            WCHAR wp[2];
+
+            ret = VkToScan( Code, FALSE, keyLayout );
+            ToUnicodeInner( Code, ret, 0, wp, 2, 0, keyLayout );
+            ret = wp[0];
+         }
+         break;
+
+      case 3:
+
+         ret = ScanToVk( Code, FALSE, keyLayout );
+         break;
+   }
+
+   return ret;
 }
 
 UINT
 STDCALL
-NtUserMapVirtualKeyEx( UINT Code, UINT Type, DWORD keyboardId, HKL dwhkl ) {
-  PKBDTABLES keyLayout = PsGetWin32Thread() ?
-    PsGetWin32Thread()->KeyboardLayout : 0;
+NtUserMapVirtualKeyEx( UINT Code, UINT Type, DWORD keyboardId, HKL dwhkl )
+{
+   PKBDTABLES keyLayout = PsGetWin32Thread() ?
+                          PsGetWin32Thread()->KeyboardLayout : 0;
 
-  if( !keyLayout ) return 0;
+   if( !keyLayout )
+      return 0;
 
-  return IntMapVirtualKeyEx( Code, Type, keyLayout );
+   return IntMapVirtualKeyEx( Code, Type, keyLayout );
 }
 
 
 int
 STDCALL
 NtUserToUnicodeEx(
-                 UINT wVirtKey,
-                 UINT wScanCode,
-                 PBYTE lpKeyState,
-                 LPWSTR pwszBuff,
-                 int cchBuff,
-                 UINT wFlags,
-                 HKL dwhkl ) {
-  BYTE KeyStateBuf[0x100];
-  PWCHAR OutPwszBuff = 0;
-  int ret = 0;
-
-
-  if( !NT_SUCCESS(MmCopyFromCaller(KeyStateBuf,
-                                  lpKeyState,
-                                  sizeof(KeyStateBuf))) ) {
-    DPRINT1( "Couldn't copy key state from caller.\n" );
-    return 0;
-  }
-  OutPwszBuff = ExAllocatePoolWithTag(NonPagedPool,sizeof(WCHAR) * cchBuff, TAG_STRING);
-  if( !OutPwszBuff ) {
-    DPRINT1( "ExAllocatePool(%d) failed\n", sizeof(WCHAR) * cchBuff);
-    return 0;
-  }
-  RtlZeroMemory( OutPwszBuff, sizeof( WCHAR ) * cchBuff );
-
-  ret = ToUnicodeEx( wVirtKey,
-                    wScanCode,
-                    KeyStateBuf,
-                    OutPwszBuff,
-                    cchBuff,
-                    wFlags,
-                    dwhkl );
-
-  MmCopyToCaller(pwszBuff,OutPwszBuff,sizeof(WCHAR)*cchBuff);
-  ExFreePool(OutPwszBuff);
-
-  return ret;
+   UINT wVirtKey,
+   UINT wScanCode,
+   PBYTE lpKeyState,
+   LPWSTR pwszBuff,
+   int cchBuff,
+   UINT wFlags,
+   HKL dwhkl )
+{
+   BYTE KeyStateBuf[0x100];
+   PWCHAR OutPwszBuff = 0;
+   int ret = 0;
+
+
+   if( !NT_SUCCESS(MmCopyFromCaller(KeyStateBuf,
+                                    lpKeyState,
+                                    sizeof(KeyStateBuf))) )
+   {
+      DPRINT1( "Couldn't copy key state from caller.\n" );
+      return 0;
+   }
+   OutPwszBuff = ExAllocatePoolWithTag(NonPagedPool,sizeof(WCHAR) * cchBuff, TAG_STRING);
+   if( !OutPwszBuff )
+   {
+      DPRINT1( "ExAllocatePool(%d) failed\n", sizeof(WCHAR) * cchBuff);
+      return 0;
+   }
+   RtlZeroMemory( OutPwszBuff, sizeof( WCHAR ) * cchBuff );
+
+   ret = ToUnicodeEx( wVirtKey,
+                      wScanCode,
+                      KeyStateBuf,
+                      OutPwszBuff,
+                      cchBuff,
+                      wFlags,
+                      dwhkl );
+
+   MmCopyToCaller(pwszBuff,OutPwszBuff,sizeof(WCHAR)*cchBuff);
+   ExFreePool(OutPwszBuff);
+
+   return ret;
 }
 
-static int W32kSimpleToupper( int ch ) {
-  if( ch >= 'a' && ch <= 'z' ) ch = ch - 'a' + 'A';
-  return ch;
+static int W32kSimpleToupper( int ch )
+{
+   if( ch >= 'a' && ch <= 'z' )
+      ch = ch - 'a' + 'A';
+   return ch;
 }
 
 DWORD
 STDCALL
-NtUserGetKeyNameText( LONG lParam, LPWSTR lpString, int nSize ) {
-  int i;
-  DWORD ret = 0;
-  UINT CareVk = 0;
-  UINT VkCode = 0;
-  UINT ScanCode = (lParam >> 16) & 0xff;
-  BOOL ExtKey = lParam & (1<<24) ? TRUE : FALSE;
-  PKBDTABLES keyLayout =
-    PsGetWin32Thread() ?
-    PsGetWin32Thread()->KeyboardLayout : 0;
-
-  if( !keyLayout || nSize < 1 ) return 0;
-
-  if( lParam & (1<<25) ) {
-    CareVk = VkCode = ScanToVk( ScanCode, ExtKey, keyLayout );
-    if( VkCode == VK_LSHIFT || VkCode == VK_RSHIFT )
-      VkCode = VK_LSHIFT;
-    if( VkCode == VK_LCONTROL || VkCode == VK_RCONTROL )
-      VkCode = VK_LCONTROL;
-    if( VkCode == VK_LMENU || VkCode == VK_RMENU )
-      VkCode = VK_LMENU;
-  } else {
-    VkCode = ScanToVk( ScanCode, ExtKey, keyLayout );
-  }
-
-  VSC_LPWSTR *KeyNames = 0;
-
-  if( CareVk != VkCode )
-    ScanCode = VkToScan( VkCode, ExtKey, keyLayout );
-
-  if( ExtKey )
-    KeyNames = keyLayout->pKeyNamesExt;
-  else
-    KeyNames = keyLayout->pKeyNames;
-
-  for( i = 0; KeyNames[i].pwsz; i++ ) {
-    if( KeyNames[i].vsc == ScanCode ) {
-      UINT StrLen = wcslen(KeyNames[i].pwsz);
-      UINT StrMax = StrLen > (nSize - 1) ? (nSize - 1) : StrLen;
-      WCHAR null_wc = 0;
-      if( NT_SUCCESS( MmCopyToCaller( lpString,
-                                     KeyNames[i].pwsz,
-                                     StrMax * sizeof(WCHAR) ) ) &&
-         NT_SUCCESS( MmCopyToCaller( lpString + StrMax,
-                                     &null_wc,
-                                     sizeof( WCHAR ) ) ) ) {
-       ret = StrMax;
-       break;
+NtUserGetKeyNameText( LONG lParam, LPWSTR lpString, int nSize )
+{
+   int i;
+   DWORD ret = 0;
+   UINT CareVk = 0;
+   UINT VkCode = 0;
+   UINT ScanCode = (lParam >> 16) & 0xff;
+   BOOL ExtKey = lParam & (1<<24) ? TRUE : FALSE;
+   PKBDTABLES keyLayout =
+      PsGetWin32Thread() ?
+      PsGetWin32Thread()->KeyboardLayout : 0;
+
+   if( !keyLayout || nSize < 1 )
+      return 0;
+
+   if( lParam & (1<<25) )
+   {
+      CareVk = VkCode = ScanToVk( ScanCode, ExtKey, keyLayout );
+      if( VkCode == VK_LSHIFT || VkCode == VK_RSHIFT )
+         VkCode = VK_LSHIFT;
+      if( VkCode == VK_LCONTROL || VkCode == VK_RCONTROL )
+         VkCode = VK_LCONTROL;
+      if( VkCode == VK_LMENU || VkCode == VK_RMENU )
+         VkCode = VK_LMENU;
+   }
+   else
+   {
+      VkCode = ScanToVk( ScanCode, ExtKey, keyLayout );
+   }
+
+   VSC_LPWSTR *KeyNames = 0;
+
+   if( CareVk != VkCode )
+      ScanCode = VkToScan( VkCode, ExtKey, keyLayout );
+
+   if( ExtKey )
+      KeyNames = keyLayout->pKeyNamesExt;
+   else
+      KeyNames = keyLayout->pKeyNames;
+
+   for( i = 0; KeyNames[i].pwsz; i++ )
+   {
+      if( KeyNames[i].vsc == ScanCode )
+      {
+         UINT StrLen = wcslen(KeyNames[i].pwsz);
+         UINT StrMax = StrLen > (nSize - 1) ? (nSize - 1) : StrLen;
+         WCHAR null_wc = 0;
+         if( NT_SUCCESS( MmCopyToCaller( lpString,
+                                         KeyNames[i].pwsz,
+                                         StrMax * sizeof(WCHAR) ) ) &&
+               NT_SUCCESS( MmCopyToCaller( lpString + StrMax,
+                                           &null_wc,
+                                           sizeof( WCHAR ) ) ) )
+         {
+            ret = StrMax;
+            break;
+         }
       }
-    }
-  }
+   }
 
-  if( ret == 0 ) {
-    WCHAR UCName[2];
+   if( ret == 0 )
+   {
+      WCHAR UCName[2];
 
-    UCName[0] = W32kSimpleToupper(IntMapVirtualKeyEx( VkCode, 2, keyLayout ));
-    UCName[1] = 0;
-    ret = 1;
+      UCName[0] = W32kSimpleToupper(IntMapVirtualKeyEx( VkCode, 2, keyLayout ));
+      UCName[1] = 0;
+      ret = 1;
 
-    if( !NT_SUCCESS(MmCopyToCaller( lpString, UCName, 2 * sizeof(WCHAR) )) )
-      return 0;
-  }
+      if( !NT_SUCCESS(MmCopyToCaller( lpString, UCName, 2 * sizeof(WCHAR) )) )
+         return 0;
+   }
 
-  return ret;
+   return ret;
 }
 
 /*
@@ -1007,212 +1099,216 @@ W32kKeyProcessMessage(LPMSG Msg,
                       PKBDTABLES KeyboardLayout,
                       BYTE Prefix)
 {
-  DWORD ScanCode = 0, ModifierBits = 0;
-  DWORD i = 0;
-  DWORD BaseMapping = 0;
-  DWORD RawVk = 0;
-  static WORD NumpadConversion[][2] =
-    { { VK_DELETE, VK_DECIMAL },
-      { VK_INSERT, VK_NUMPAD0 },
-      { VK_END,    VK_NUMPAD1 },
-      { VK_DOWN,   VK_NUMPAD2 },
-      { VK_NEXT,   VK_NUMPAD3 },
-      { VK_LEFT,   VK_NUMPAD4 },
-      { VK_CLEAR,  VK_NUMPAD5 },
-      { VK_RIGHT,  VK_NUMPAD6 },
-      { VK_HOME,   VK_NUMPAD7 },
-      { VK_UP,     VK_NUMPAD8 },
-      { VK_PRIOR,  VK_NUMPAD9 },
-      { 0,0 } };
-  PVSC_VK VscVkTable = NULL;
-
-  if( !KeyboardLayout || !Msg ||
-      (Msg->message != WM_KEYDOWN && Msg->message != WM_SYSKEYDOWN &&
-       Msg->message != WM_KEYUP   && Msg->message != WM_SYSKEYUP) )
-    {
+   DWORD ScanCode = 0, ModifierBits = 0;
+   DWORD i = 0;
+   DWORD BaseMapping = 0;
+   DWORD RawVk = 0;
+   static WORD NumpadConversion[][2] =
+      { { VK_DELETE, VK_DECIMAL },
+        { VK_INSERT, VK_NUMPAD0 },
+        { VK_END,    VK_NUMPAD1 },
+        { VK_DOWN,   VK_NUMPAD2 },
+        { VK_NEXT,   VK_NUMPAD3 },
+        { VK_LEFT,   VK_NUMPAD4 },
+        { VK_CLEAR,  VK_NUMPAD5 },
+        { VK_RIGHT,  VK_NUMPAD6 },
+        { VK_HOME,   VK_NUMPAD7 },
+        { VK_UP,     VK_NUMPAD8 },
+        { VK_PRIOR,  VK_NUMPAD9 },
+        { 0,0 } };
+   PVSC_VK VscVkTable = NULL;
+
+   if( !KeyboardLayout || !Msg ||
+         (Msg->message != WM_KEYDOWN && Msg->message != WM_SYSKEYDOWN &&
+          Msg->message != WM_KEYUP   && Msg->message != WM_SYSKEYUP) )
+   {
       return;
-    }
-
-  IntLockQueueState;
-
-  /* arty -- handle numpad -- On real windows, the actual key produced
-   * by the messaging layer is different based on the state of numlock. */
-  ModifierBits = ModBits(KeyboardLayout,QueueKeyStateTable);
-
-  /* Get the raw scan code, so we can look up whether the key is a numpad
-   * key
-   *
-   * Shift and the LP_EXT_BIT cancel. */
-  ScanCode = (Msg->lParam >> 16) & 0xff;
-  BaseMapping = Msg->wParam =
-    IntMapVirtualKeyEx( ScanCode, 1, KeyboardLayout );
-  if( Prefix == 0 )
-    {
+   }
+
+   IntLockQueueState;
+
+   /* arty -- handle numpad -- On real windows, the actual key produced
+    * by the messaging layer is different based on the state of numlock. */
+   ModifierBits = ModBits(KeyboardLayout,QueueKeyStateTable);
+
+   /* Get the raw scan code, so we can look up whether the key is a numpad
+    * key
+    *
+    * Shift and the LP_EXT_BIT cancel. */
+   ScanCode = (Msg->lParam >> 16) & 0xff;
+   BaseMapping = Msg->wParam =
+                    IntMapVirtualKeyEx( ScanCode, 1, KeyboardLayout );
+   if( Prefix == 0 )
+   {
       if( ScanCode >= KeyboardLayout->bMaxVSCtoVK )
-        RawVk = 0xff;
+         RawVk = 0xff;
       else
-        RawVk = KeyboardLayout->pusVSCtoVK[ScanCode];
-    }
-  else
-    {
+         RawVk = KeyboardLayout->pusVSCtoVK[ScanCode];
+   }
+   else
+   {
       if( Prefix == 0xE0 )
-        {
-          /* ignore shift codes */
-          if( ScanCode == 0x2A || ScanCode == 0x36 )
-            {
-              IntUnLockQueueState;
-              return;
-            }
-          VscVkTable = KeyboardLayout->pVSCtoVK_E0;
-        }
+      {
+         /* ignore shift codes */
+         if( ScanCode == 0x2A || ScanCode == 0x36 )
+         {
+            IntUnLockQueueState;
+            return;
+         }
+         VscVkTable = KeyboardLayout->pVSCtoVK_E0;
+      }
       else if( Prefix == 0xE1 )
-        {
-          VscVkTable = KeyboardLayout->pVSCtoVK_E1;
-        }
+      {
+         VscVkTable = KeyboardLayout->pVSCtoVK_E1;
+      }
 
       RawVk = 0xff;
       while (VscVkTable->Vsc)
-        {
-          if( VscVkTable->Vsc == ScanCode )
-            {
-              RawVk = VscVkTable->Vk;
-            }
-          VscVkTable++;
-        }
-    }
-
-  if ((ModifierBits & NUMLOCK_BIT) &&
-      !(ModifierBits & GetShiftBit(KeyboardLayout, VK_SHIFT)) &&
-      (RawVk & KNUMP) &&
-      !(Msg->lParam & LP_EXT_BIT))
-    {
+      {
+         if( VscVkTable->Vsc == ScanCode )
+         {
+            RawVk = VscVkTable->Vk;
+         }
+         VscVkTable++;
+      }
+   }
+
+   if ((ModifierBits & NUMLOCK_BIT) &&
+         !(ModifierBits & GetShiftBit(KeyboardLayout, VK_SHIFT)) &&
+         (RawVk & KNUMP) &&
+         !(Msg->lParam & LP_EXT_BIT))
+   {
       /* The key in question is a numpad key.  Search for a translation. */
       for (i = 0; NumpadConversion[i][0]; i++)
-       {
-           if ((BaseMapping & 0xff) == NumpadConversion[i][0]) /* RawVk? */
-           {
-             Msg->wParam = NumpadConversion[i][1];
-             break;
-           }
-       }
-    }
-
-  DPRINT("Key: [%04x -> %04x]\n", BaseMapping, Msg->wParam);
-
-  /* Now that we have the VK, we can set the keymap appropriately
-   * This is a better place for this code, as it's guaranteed to be
-   * run, unlike translate message. */
-  if (Msg->message == WM_KEYDOWN || Msg->message == WM_SYSKEYDOWN)
-    {
+      {
+         if ((BaseMapping & 0xff) == NumpadConversion[i][0]) /* RawVk? */
+         {
+            Msg->wParam = NumpadConversion[i][1];
+            break;
+         }
+      }
+   }
+
+   DPRINT("Key: [%04x -> %04x]\n", BaseMapping, Msg->wParam);
+
+   /* Now that we have the VK, we can set the keymap appropriately
+    * This is a better place for this code, as it's guaranteed to be
+    * run, unlike translate message. */
+   if (Msg->message == WM_KEYDOWN || Msg->message == WM_SYSKEYDOWN)
+   {
       SetKeyState( ScanCode, Msg->wParam, Msg->lParam & LP_EXT_BIT,
-                  TRUE ); /* Strike key */
-    }
-  else if (Msg->message == WM_KEYUP || Msg->message == WM_SYSKEYUP)
-    {
+                   TRUE ); /* Strike key */
+   }
+   else if (Msg->message == WM_KEYUP || Msg->message == WM_SYSKEYUP)
+   {
       SetKeyState( ScanCode, Msg->wParam, Msg->lParam & LP_EXT_BIT,
-                  FALSE ); /* Release key */
-    }
-
-  /* We need to unset SYSKEYDOWN if the ALT key is an ALT+Gr */
-  if( QueueKeyStateTable[VK_RMENU] & KS_DOWN_BIT ) {
-      if( Msg->message == WM_SYSKEYDOWN ) Msg->message = WM_KEYDOWN;
-      else Msg->message = WM_KEYUP;
-  }
+                   FALSE ); /* Release key */
+   }
+
+   /* We need to unset SYSKEYDOWN if the ALT key is an ALT+Gr */
+   if( QueueKeyStateTable[VK_RMENU] & KS_DOWN_BIT )
+   {
+      if( Msg->message == WM_SYSKEYDOWN )
+         Msg->message = WM_KEYDOWN;
+      else
+         Msg->message = WM_KEYUP;
+   }
 
-  IntUnLockQueueState;
+   IntUnLockQueueState;
 }
 
 DWORD
 STDCALL
 NtUserGetKeyboardLayoutList(
-  DWORD Items,
-  DWORD pHklBuff)
+   DWORD Items,
+   DWORD pHklBuff)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserGetKeyboardLayoutName(
-  DWORD lpszName)
+   DWORD lpszName)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
 
 HKL FASTCALL
 UserGetKeyboardLayout(
-  DWORD dwThreadId)
+   DWORD dwThreadId)
 {
-  NTSTATUS Status;
-  PETHREAD Thread;
-  PW32THREAD W32Thread;
-  PKBDTABLES layout;
-
-  if (!dwThreadId)
-     W32Thread = PsGetWin32Thread();
-  else 
-  {
-     Status = PsLookupThreadByThreadId((HANDLE)dwThreadId, &Thread);//fixme: deref thread
-     if(!NT_SUCCESS(Status))
-       {
+   NTSTATUS Status;
+   PETHREAD Thread;
+   PW32THREAD W32Thread;
+   PKBDTABLES layout;
+
+   if (!dwThreadId)
+      W32Thread = PsGetWin32Thread();
+   else
+   {
+      Status = PsLookupThreadByThreadId((HANDLE)dwThreadId, &Thread);//fixme: deref thread
+      if(!NT_SUCCESS(Status))
+      {
          SetLastWin32Error(ERROR_INVALID_PARAMETER);
          return 0;
-       }
-     W32Thread = Thread->Tcb.Win32Thread;
-  }
-  layout = W32Thread->KeyboardLayout;
-  if(!layout) return 0;
-  return (HKL)layout;
+      }
+      W32Thread = Thread->Tcb.Win32Thread;
+   }
+   layout = W32Thread->KeyboardLayout;
+   if(!layout)
+      return 0;
+   return (HKL)layout;
 }
 
 
 HKL
 STDCALL
 NtUserGetKeyboardLayout(
-  DWORD dwThreadId)
+   DWORD dwThreadId)
 {
    DECLARE_RETURN(HKL);
-   
+
    UserEnterShared();
    DPRINT("Enter NtUserGetKeyboardLayout\n");
-   
+
    RETURN( UserGetKeyboardLayout(dwThreadId));
-   
+
 CLEANUP:
    DPRINT("Leave NtUserGetKeyboardLayout, ret=%i\n",_ret_);
    UserLeave();
    END_CLEANUP;
 }
-    
-  
+
+
 DWORD FASTCALL
 UserGetKeyboardType(
-  DWORD TypeFlag)
+   DWORD TypeFlag)
 {
-  switch(TypeFlag)
-  {
-    case 0:        /* Keyboard type */
-      return 4;    /* AT-101 */
-    case 1:        /* Keyboard Subtype */
-      return 0;    /* There are no defined subtypes */
-    case 2:        /* Number of F-keys */
-      return 12;   /* We're doing an 101 for now, so return 12 F-keys */
-    default:
-    DPRINT1("Unknown type!\n");
-      return 0;    /* The book says 0 here, so 0 */
-  }
-}  
-  
+   switch(TypeFlag)
+   {
+      case 0:        /* Keyboard type */
+         return 4;    /* AT-101 */
+      case 1:        /* Keyboard Subtype */
+         return 0;    /* There are no defined subtypes */
+      case 2:        /* Number of F-keys */
+         return 12;   /* We're doing an 101 for now, so return 12 F-keys */
+      default:
+         DPRINT1("Unknown type!\n");
+         return 0;    /* The book says 0 here, so 0 */
+   }
+}
+
 DWORD
 STDCALL
 NtUserGetKeyboardType(
-  DWORD TypeFlag)
+   DWORD TypeFlag)
 {
    return UserGetKeyboardType(TypeFlag);
 }
@@ -1225,49 +1321,50 @@ NtUserGetKeyboardType(
 DWORD
 STDCALL
 NtUserVkKeyScanEx(
-  DWORD wChar,
-  DWORD KeyboardLayout,
-  DWORD Unknown2)
+   DWORD wChar,
+   DWORD KeyboardLayout,
+   DWORD Unknown2)
 {
-  PKBDTABLES KeyLayout;
-  PVK_TO_WCHAR_TABLE vtwTbl;
-  PVK_TO_WCHARS10 vkPtr;
-  size_t size_this_entry;
-  int nMod;
-  DWORD CapsMod = 0, CapsState = 0;
-
-  if(!KeyboardLayout) return -1;
-  KeyLayout = (PKBDTABLES) KeyboardLayout;
-  
-  for (nMod = 0; KeyLayout->pVkToWcharTable[nMod].nModifications; nMod++)
-  {
-    vtwTbl = &KeyLayout->pVkToWcharTable[nMod];
-    size_this_entry = vtwTbl->cbSize;
-    vkPtr = (PVK_TO_WCHARS10)((BYTE *)vtwTbl->pVkToWchars);
-
-    while(vkPtr->VirtualKey)
-    {
-     /*
-        0x01 Shift key
-        0x02 Ctrl key
-        0x04 Alt key
-        Should have only 8 valid possibilities. Including zero.
-      */
-      for(CapsState = 0; CapsState < vtwTbl->nModifications; CapsState++)
+   PKBDTABLES KeyLayout;
+   PVK_TO_WCHAR_TABLE vtwTbl;
+   PVK_TO_WCHARS10 vkPtr;
+   size_t size_this_entry;
+   int nMod;
+   DWORD CapsMod = 0, CapsState = 0;
+
+   if(!KeyboardLayout)
+      return -1;
+   KeyLayout = (PKBDTABLES) KeyboardLayout;
+
+   for (nMod = 0; KeyLayout->pVkToWcharTable[nMod].nModifications; nMod++)
+   {
+      vtwTbl = &KeyLayout->pVkToWcharTable[nMod];
+      size_this_entry = vtwTbl->cbSize;
+      vkPtr = (PVK_TO_WCHARS10)((BYTE *)vtwTbl->pVkToWchars);
+
+      while(vkPtr->VirtualKey)
       {
-        if(vkPtr->wch[CapsState] == wChar)
-        {
-          CapsMod = KeyLayout->pCharModifiers->ModNumber[CapsState];
-          DPRINT("nMod %d wC %04x: CapsMod %08x CapsState %08x MaxModBits %08x\n",
-                 nMod, wChar, CapsMod, CapsState, KeyLayout->pCharModifiers->wMaxModBits);
-          return ((CapsMod << 8)|(vkPtr->VirtualKey & 0xff));
-        }
+         /*
+            0x01 Shift key
+            0x02 Ctrl key
+            0x04 Alt key
+            Should have only 8 valid possibilities. Including zero.
+          */
+         for(CapsState = 0; CapsState < vtwTbl->nModifications; CapsState++)
+         {
+            if(vkPtr->wch[CapsState] == wChar)
+            {
+               CapsMod = KeyLayout->pCharModifiers->ModNumber[CapsState];
+               DPRINT("nMod %d wC %04x: CapsMod %08x CapsState %08x MaxModBits %08x\n",
+                      nMod, wChar, CapsMod, CapsState, KeyLayout->pCharModifiers->wMaxModBits);
+               return ((CapsMod << 8)|(vkPtr->VirtualKey & 0xff));
+            }
+         }
+         vkPtr = (PVK_TO_WCHARS10)(((BYTE *)vkPtr) + size_this_entry);
       }
-      vkPtr = (PVK_TO_WCHARS10)(((BYTE *)vkPtr) + size_this_entry);
-    }
-  }
-  return -1;
+   }
+   return -1;
 }
 
-    
+
 /* EOF */
index 069f6da..883c14d 100644 (file)
 static
 BOOL FASTCALL
 UserMenuItemInfo(
- PMENU_OBJECT Menu,
- UINT Item,
- BOOL ByPosition,
- PROSMENUITEMINFO UnsafeItemInfo,
- BOOL SetOrGet);
  PMENU_OBJECT Menu,
  UINT Item,
  BOOL ByPosition,
  PROSMENUITEMINFO UnsafeItemInfo,
  BOOL SetOrGet);
 
 static
 BOOL FASTCALL
 UserMenuInfo(
- PMENU_OBJECT Menu,
- PROSMENUINFO UnsafeMenuInfo,
- BOOL SetOrGet);
  PMENU_OBJECT Menu,
  PROSMENUINFO UnsafeMenuInfo,
  BOOL SetOrGet);
+
 /* INTERNAL ******************************************************************/
 
 /* maximum number of menu items a menu can contain */
@@ -104,13 +104,13 @@ UserMenuInfo(
 NTSTATUS FASTCALL
 InitMenuImpl(VOID)
 {
-  return(STATUS_SUCCESS);
+   return(STATUS_SUCCESS);
 }
 
 NTSTATUS FASTCALL
 CleanupMenuImpl(VOID)
 {
-  return(STATUS_SUCCESS);
+   return(STATUS_SUCCESS);
 }
 
 PMENU_OBJECT FASTCALL UserGetMenuObject(HMENU hMenu)
@@ -121,7 +121,7 @@ PMENU_OBJECT FASTCALL UserGetMenuObject(HMENU hMenu)
       SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
       return NULL;
    }
-   
+
    ASSERT(USER_BODY_TO_HEADER(Menu)->RefCount >= 0);
    return Menu;
 }
@@ -131,36 +131,52 @@ PMENU_OBJECT FASTCALL UserGetMenuObject(HMENU hMenu)
 void FASTCALL
 DumpMenuItemList(PMENU_ITEM MenuItem)
 {
-  UINT cnt = 0;
-  while(MenuItem)
-  {
-    if(MenuItem->Text.Length)
-      DbgPrint(" %d. %wZ\n", ++cnt, &MenuItem->Text);
-    else
-      DbgPrint(" %d. NO TEXT dwTypeData==%d\n", ++cnt, (DWORD)MenuItem->Text.Buffer);
-    DbgPrint("   fType=");
-    if(MFT_BITMAP & MenuItem->fType) DbgPrint("MFT_BITMAP ");
-    if(MFT_MENUBARBREAK & MenuItem->fType) DbgPrint("MFT_MENUBARBREAK ");
-    if(MFT_MENUBREAK & MenuItem->fType) DbgPrint("MFT_MENUBREAK ");
-    if(MFT_OWNERDRAW & MenuItem->fType) DbgPrint("MFT_OWNERDRAW ");
-    if(MFT_RADIOCHECK & MenuItem->fType) DbgPrint("MFT_RADIOCHECK ");
-    if(MFT_RIGHTJUSTIFY & MenuItem->fType) DbgPrint("MFT_RIGHTJUSTIFY ");
-    if(MFT_SEPARATOR & MenuItem->fType) DbgPrint("MFT_SEPARATOR ");
-    if(MFT_STRING & MenuItem->fType) DbgPrint("MFT_STRING ");
-    DbgPrint("\n   fState=");
-    if(MFS_DISABLED & MenuItem->fState) DbgPrint("MFS_DISABLED ");
-    else DbgPrint("MFS_ENABLED ");
-    if(MFS_CHECKED & MenuItem->fState) DbgPrint("MFS_CHECKED ");
-    else DbgPrint("MFS_UNCHECKED ");
-    if(MFS_HILITE & MenuItem->fState) DbgPrint("MFS_HILITE ");
-    else DbgPrint("MFS_UNHILITE ");
-    if(MFS_DEFAULT & MenuItem->fState) DbgPrint("MFS_DEFAULT ");
-    if(MFS_GRAYED & MenuItem->fState) DbgPrint("MFS_GRAYED ");
-    DbgPrint("\n   wId=%d\n", MenuItem->wID);
-    MenuItem = MenuItem->Next;
-  }
-  DbgPrint("Entries: %d\n", cnt);
-  return;
+   UINT cnt = 0;
+   while(MenuItem)
+   {
+      if(MenuItem->Text.Length)
+         DbgPrint(" %d. %wZ\n", ++cnt, &MenuItem->Text);
+      else
+         DbgPrint(" %d. NO TEXT dwTypeData==%d\n", ++cnt, (DWORD)MenuItem->Text.Buffer);
+      DbgPrint("   fType=");
+      if(MFT_BITMAP & MenuItem->fType)
+         DbgPrint("MFT_BITMAP ");
+      if(MFT_MENUBARBREAK & MenuItem->fType)
+         DbgPrint("MFT_MENUBARBREAK ");
+      if(MFT_MENUBREAK & MenuItem->fType)
+         DbgPrint("MFT_MENUBREAK ");
+      if(MFT_OWNERDRAW & MenuItem->fType)
+         DbgPrint("MFT_OWNERDRAW ");
+      if(MFT_RADIOCHECK & MenuItem->fType)
+         DbgPrint("MFT_RADIOCHECK ");
+      if(MFT_RIGHTJUSTIFY & MenuItem->fType)
+         DbgPrint("MFT_RIGHTJUSTIFY ");
+      if(MFT_SEPARATOR & MenuItem->fType)
+         DbgPrint("MFT_SEPARATOR ");
+      if(MFT_STRING & MenuItem->fType)
+         DbgPrint("MFT_STRING ");
+      DbgPrint("\n   fState=");
+      if(MFS_DISABLED & MenuItem->fState)
+         DbgPrint("MFS_DISABLED ");
+      else
+         DbgPrint("MFS_ENABLED ");
+      if(MFS_CHECKED & MenuItem->fState)
+         DbgPrint("MFS_CHECKED ");
+      else
+         DbgPrint("MFS_UNCHECKED ");
+      if(MFS_HILITE & MenuItem->fState)
+         DbgPrint("MFS_HILITE ");
+      else
+         DbgPrint("MFS_UNHILITE ");
+      if(MFS_DEFAULT & MenuItem->fState)
+         DbgPrint("MFS_DEFAULT ");
+      if(MFS_GRAYED & MenuItem->fState)
+         DbgPrint("MFS_GRAYED ");
+      DbgPrint("\n   wId=%d\n", MenuItem->wID);
+      MenuItem = MenuItem->Next;
+   }
+   DbgPrint("Entries: %d\n", cnt);
+   return;
 }
 #endif
 
@@ -171,7 +187,7 @@ IntGetMenuObject(HMENU hMenu)
    if (Menu)
    {
       ASSERT(USER_BODY_TO_HEADER(Menu)->RefCount >= 0);
-      
+
       USER_BODY_TO_HEADER(Menu)->RefCount++;
    }
    return Menu;
@@ -179,333 +195,333 @@ IntGetMenuObject(HMENU hMenu)
 
 BOOL FASTCALL
 IntFreeMenuItem(PMENU_OBJECT Menu, PMENU_ITEM MenuItem,
-    BOOL RemoveFromList, BOOL bRecurse)
+                BOOL RemoveFromList, BOOL bRecurse)
 {
-  FreeMenuText(MenuItem);
-  if(RemoveFromList)
-  {
-    /* FIXME - Remove from List */
-    Menu->MenuInfo.MenuItemCount--;
-  }
-  if(bRecurse && MenuItem->hSubMenu)
-  {
-    PMENU_OBJECT SubMenu;
-    SubMenu = IntGetMenuObject(MenuItem->hSubMenu );
-    if(SubMenu)
-    {
-      IntDestroyMenuObject(SubMenu, bRecurse, TRUE);
-      IntReleaseMenuObject(SubMenu);
-    }
-  }
-
-  /* Free memory */
-  ExFreePool(MenuItem);
-
-  return TRUE;
+   FreeMenuText(MenuItem);
+   if(RemoveFromList)
+   {
+      /* FIXME - Remove from List */
+      Menu->MenuInfo.MenuItemCount--;
+   }
+   if(bRecurse && MenuItem->hSubMenu)
+   {
+      PMENU_OBJECT SubMenu;
+      SubMenu = IntGetMenuObject(MenuItem->hSubMenu );
+      if(SubMenu)
+      {
+         IntDestroyMenuObject(SubMenu, bRecurse, TRUE);
+         IntReleaseMenuObject(SubMenu);
+      }
+   }
+
+   /* Free memory */
+   ExFreePool(MenuItem);
+
+   return TRUE;
 }
 
 BOOL FASTCALL
 IntRemoveMenuItem(PMENU_OBJECT Menu, UINT uPosition, UINT uFlags,
-                   BOOL bRecurse)
+                  BOOL bRecurse)
 {
-  PMENU_ITEM PrevMenuItem, MenuItem;
-  if(IntGetMenuItemByFlag(Menu, uPosition, uFlags, &MenuItem,
+   PMENU_ITEM PrevMenuItem, MenuItem;
+   if(IntGetMenuItemByFlag(Menu, uPosition, uFlags, &MenuItem,
                            &PrevMenuItem) > -1)
-  {
-    if(MenuItem)
-    {
-      if(PrevMenuItem)
-        PrevMenuItem->Next = MenuItem->Next;
-      else
+   {
+      if(MenuItem)
       {
-        Menu->MenuItemList = MenuItem->Next;
+         if(PrevMenuItem)
+            PrevMenuItem->Next = MenuItem->Next;
+         else
+         {
+            Menu->MenuItemList = MenuItem->Next;
+         }
+         return IntFreeMenuItem(Menu, MenuItem, TRUE, bRecurse);
       }
-      return IntFreeMenuItem(Menu, MenuItem, TRUE, bRecurse);
-    }
-  }
-  return FALSE;
+   }
+   return FALSE;
 }
 
 UINT FASTCALL
 IntDeleteMenuItems(PMENU_OBJECT Menu, BOOL bRecurse)
 {
-  UINT res = 0;
-  PMENU_ITEM NextItem;
-  PMENU_ITEM CurItem = Menu->MenuItemList;
-  while(CurItem)
-  {
-    NextItem = CurItem->Next;
-    IntFreeMenuItem(Menu, CurItem, FALSE, bRecurse);
-    CurItem = NextItem;
-    res++;
-  }
-  Menu->MenuInfo.MenuItemCount = 0;
-  Menu->MenuItemList = NULL;
-  return res;
+   UINT res = 0;
+   PMENU_ITEM NextItem;
+   PMENU_ITEM CurItem = Menu->MenuItemList;
+   while(CurItem)
+   {
+      NextItem = CurItem->Next;
+      IntFreeMenuItem(Menu, CurItem, FALSE, bRecurse);
+      CurItem = NextItem;
+      res++;
+   }
+   Menu->MenuInfo.MenuItemCount = 0;
+   Menu->MenuItemList = NULL;
+   return res;
 }
 
 BOOL FASTCALL
 IntDestroyMenuObject(PMENU_OBJECT Menu,
                      BOOL bRecurse, BOOL RemoveFromProcess)
 {
-  if(Menu)
-  {
-    PWINSTATION_OBJECT WindowStation;
-    NTSTATUS Status;
-
-    /* remove all menu items */
-    IntDeleteMenuItems(Menu, bRecurse); /* do not destroy submenus */
-
-    if(RemoveFromProcess)
-    {
-      RemoveEntryList(&Menu->ListEntry);
-    }
-
-    Status = ObReferenceObjectByHandle(Menu->Process->Win32WindowStation,
-                                       0,
-                                       ExWindowStationObjectType,
-                                       KernelMode,
-                                       (PVOID*)&WindowStation,
-                                       NULL);
-    if(NT_SUCCESS(Status))
-    {
-      ObmDeleteObject(Menu->MenuInfo.Self, otMenu);
-      ObDereferenceObject(WindowStation);
-      return TRUE;
-    }
-  }
-  return FALSE;
+   if(Menu)
+   {
+      PWINSTATION_OBJECT WindowStation;
+      NTSTATUS Status;
+
+      /* remove all menu items */
+      IntDeleteMenuItems(Menu, bRecurse); /* do not destroy submenus */
+
+      if(RemoveFromProcess)
+      {
+         RemoveEntryList(&Menu->ListEntry);
+      }
+
+      Status = ObReferenceObjectByHandle(Menu->Process->Win32WindowStation,
+                                         0,
+                                         ExWindowStationObjectType,
+                                         KernelMode,
+                                         (PVOID*)&WindowStation,
+                                         NULL);
+      if(NT_SUCCESS(Status))
+      {
+         ObmDeleteObject(Menu->MenuInfo.Self, otMenu);
+         ObDereferenceObject(WindowStation);
+         return TRUE;
+      }
+   }
+   return FALSE;
 }
 
 PMENU_OBJECT FASTCALL
 IntCreateMenu(PHANDLE Handle, BOOL IsMenuBar)
 {
-  PMENU_OBJECT Menu;
-
-  Menu = (PMENU_OBJECT)ObmCreateObject(
-      &gHandleTable, Handle,
-      otMenu, sizeof(MENU_OBJECT));
-
-  if(!Menu)
-  {
-    *Handle = 0;
-    return NULL;
-  }
-
-  Menu->Process = PsGetCurrentProcess();
-  Menu->RtoL = FALSE; /* default */
-  Menu->MenuInfo.cbSize = sizeof(MENUINFO); /* not used */
-  Menu->MenuInfo.fMask = 0; /* not used */
-  Menu->MenuInfo.dwStyle = 0; /* FIXME */
-  Menu->MenuInfo.cyMax = 0; /* default */
-  Menu->MenuInfo.hbrBack =
-     NtGdiCreateSolidBrush(RGB(192, 192, 192)); /* FIXME: default background color */
-  Menu->MenuInfo.dwContextHelpID = 0; /* default */
-  Menu->MenuInfo.dwMenuData = 0; /* default */
-  Menu->MenuInfo.Self = *Handle;
-  Menu->MenuInfo.FocusedItem = NO_SELECTED_ITEM;
-  Menu->MenuInfo.Flags = (IsMenuBar ? 0 : MF_POPUP);
-  Menu->MenuInfo.Wnd = NULL;
-  Menu->MenuInfo.WndOwner = NULL;
-  Menu->MenuInfo.Height = 0;
-  Menu->MenuInfo.Width = 0;
-  Menu->MenuInfo.TimeToHide = FALSE;
-
-  Menu->MenuInfo.MenuItemCount = 0;
-  Menu->MenuItemList = NULL;
-
-  /* Insert menu item into process menu handle list */
-  InsertTailList(&PsGetWin32Process()->MenuListHead, &Menu->ListEntry);
-
-  return Menu;
+   PMENU_OBJECT Menu;
+
+   Menu = (PMENU_OBJECT)ObmCreateObject(
+             &gHandleTable, Handle,
+             otMenu, sizeof(MENU_OBJECT));
+
+   if(!Menu)
+   {
+      *Handle = 0;
+      return NULL;
+   }
+
+   Menu->Process = PsGetCurrentProcess();
+   Menu->RtoL = FALSE; /* default */
+   Menu->MenuInfo.cbSize = sizeof(MENUINFO); /* not used */
+   Menu->MenuInfo.fMask = 0; /* not used */
+   Menu->MenuInfo.dwStyle = 0; /* FIXME */
+   Menu->MenuInfo.cyMax = 0; /* default */
+   Menu->MenuInfo.hbrBack =
+      NtGdiCreateSolidBrush(RGB(192, 192, 192)); /* FIXME: default background color */
+   Menu->MenuInfo.dwContextHelpID = 0; /* default */
+   Menu->MenuInfo.dwMenuData = 0; /* default */
+   Menu->MenuInfo.Self = *Handle;
+   Menu->MenuInfo.FocusedItem = NO_SELECTED_ITEM;
+   Menu->MenuInfo.Flags = (IsMenuBar ? 0 : MF_POPUP);
+   Menu->MenuInfo.Wnd = NULL;
+   Menu->MenuInfo.WndOwner = NULL;
+   Menu->MenuInfo.Height = 0;
+   Menu->MenuInfo.Width = 0;
+   Menu->MenuInfo.TimeToHide = FALSE;
+
+   Menu->MenuInfo.MenuItemCount = 0;
+   Menu->MenuItemList = NULL;
+
+   /* Insert menu item into process menu handle list */
+   InsertTailList(&PsGetWin32Process()->MenuListHead, &Menu->ListEntry);
+
+   return Menu;
 }
 
 BOOL FASTCALL
 IntCloneMenuItems(PMENU_OBJECT Destination, PMENU_OBJECT Source)
 {
-  PMENU_ITEM MenuItem, NewMenuItem = NULL;
-  PMENU_ITEM Old = NULL;
-
-  if(!Source->MenuInfo.MenuItemCount)
-    return FALSE;
-
-  MenuItem = Source->MenuItemList;
-  while(MenuItem)
-  {
-    Old = NewMenuItem;
-    if(NewMenuItem)
-      NewMenuItem->Next = MenuItem;
-    NewMenuItem = ExAllocatePoolWithTag(PagedPool, sizeof(MENU_ITEM), TAG_MENUITEM);
-    if(!NewMenuItem)
-      break;
-    NewMenuItem->fType = MenuItem->fType;
-    NewMenuItem->fState = MenuItem->fState;
-    NewMenuItem->wID = MenuItem->wID;
-    NewMenuItem->hSubMenu = MenuItem->hSubMenu;
-    NewMenuItem->hbmpChecked = MenuItem->hbmpChecked;
-    NewMenuItem->hbmpUnchecked = MenuItem->hbmpUnchecked;
-    NewMenuItem->dwItemData = MenuItem->dwItemData;
-    if((MENU_ITEM_TYPE(NewMenuItem->fType) == MF_STRING))
-    {
-      if(MenuItem->Text.Length)
+   PMENU_ITEM MenuItem, NewMenuItem = NULL;
+   PMENU_ITEM Old = NULL;
+
+   if(!Source->MenuInfo.MenuItemCount)
+      return FALSE;
+
+   MenuItem = Source->MenuItemList;
+   while(MenuItem)
+   {
+      Old = NewMenuItem;
+      if(NewMenuItem)
+         NewMenuItem->Next = MenuItem;
+      NewMenuItem = ExAllocatePoolWithTag(PagedPool, sizeof(MENU_ITEM), TAG_MENUITEM);
+      if(!NewMenuItem)
+         break;
+      NewMenuItem->fType = MenuItem->fType;
+      NewMenuItem->fState = MenuItem->fState;
+      NewMenuItem->wID = MenuItem->wID;
+      NewMenuItem->hSubMenu = MenuItem->hSubMenu;
+      NewMenuItem->hbmpChecked = MenuItem->hbmpChecked;
+      NewMenuItem->hbmpUnchecked = MenuItem->hbmpUnchecked;
+      NewMenuItem->dwItemData = MenuItem->dwItemData;
+      if((MENU_ITEM_TYPE(NewMenuItem->fType) == MF_STRING))
       {
-        NewMenuItem->Text.Length = 0;
-        NewMenuItem->Text.MaximumLength = MenuItem->Text.MaximumLength;
-        NewMenuItem->Text.Buffer = (PWSTR)ExAllocatePoolWithTag(PagedPool, MenuItem->Text.MaximumLength, TAG_STRING);
-        if(!NewMenuItem->Text.Buffer)
-        {
-          ExFreePool(NewMenuItem);
-          break;
-        }
-        RtlCopyUnicodeString(&NewMenuItem->Text, &MenuItem->Text);
+         if(MenuItem->Text.Length)
+         {
+            NewMenuItem->Text.Length = 0;
+            NewMenuItem->Text.MaximumLength = MenuItem->Text.MaximumLength;
+            NewMenuItem->Text.Buffer = (PWSTR)ExAllocatePoolWithTag(PagedPool, MenuItem->Text.MaximumLength, TAG_STRING);
+            if(!NewMenuItem->Text.Buffer)
+            {
+               ExFreePool(NewMenuItem);
+               break;
+            }
+            RtlCopyUnicodeString(&NewMenuItem->Text, &MenuItem->Text);
+         }
+         else
+         {
+            NewMenuItem->Text.Buffer = MenuItem->Text.Buffer;
+         }
       }
       else
       {
-        NewMenuItem->Text.Buffer = MenuItem->Text.Buffer;
+         NewMenuItem->Text.Buffer = MenuItem->Text.Buffer;
       }
-    }
-    else
-    {
-      NewMenuItem->Text.Buffer = MenuItem->Text.Buffer;
-    }
-    NewMenuItem->hbmpItem = MenuItem->hbmpItem;
-
-    NewMenuItem->Next = NULL;
-    if(Old)
-      Old->Next = NewMenuItem;
-    else
-      Destination->MenuItemList = NewMenuItem;
-    Destination->MenuInfo.MenuItemCount++;
-    MenuItem = MenuItem->Next;
-  }
-
-  return TRUE;
+      NewMenuItem->hbmpItem = MenuItem->hbmpItem;
+
+      NewMenuItem->Next = NULL;
+      if(Old)
+         Old->Next = NewMenuItem;
+      else
+         Destination->MenuItemList = NewMenuItem;
+      Destination->MenuInfo.MenuItemCount++;
+      MenuItem = MenuItem->Next;
+   }
+
+   return TRUE;
 }
 
 PMENU_OBJECT FASTCALL
 IntCloneMenu(PMENU_OBJECT Source)
 {
-  HANDLE hMenu;
-  PMENU_OBJECT Menu;
-
-  if(!Source)
-    return NULL;
-
-  Menu = (PMENU_OBJECT)ObmCreateObject(
-    &gHandleTable, &hMenu,
-    otMenu, sizeof(MENU_OBJECT));
-  
-  if(!Menu)
-    return NULL;
-
-  Menu->Process = PsGetCurrentProcess();
-  Menu->RtoL = Source->RtoL;
-  Menu->MenuInfo.cbSize = sizeof(MENUINFO); /* not used */
-  Menu->MenuInfo.fMask = Source->MenuInfo.fMask;
-  Menu->MenuInfo.dwStyle = Source->MenuInfo.dwStyle;
-  Menu->MenuInfo.cyMax = Source->MenuInfo.cyMax;
-  Menu->MenuInfo.hbrBack = Source->MenuInfo.hbrBack;
-  Menu->MenuInfo.dwContextHelpID = Source->MenuInfo.dwContextHelpID;
-  Menu->MenuInfo.dwMenuData = Source->MenuInfo.dwMenuData;
-  Menu->MenuInfo.Self = hMenu;
-  Menu->MenuInfo.FocusedItem = NO_SELECTED_ITEM;
-  Menu->MenuInfo.Wnd = NULL;
-  Menu->MenuInfo.WndOwner = NULL;
-  Menu->MenuInfo.Height = 0;
-  Menu->MenuInfo.Width = 0;
-  Menu->MenuInfo.TimeToHide = FALSE;
-
-  Menu->MenuInfo.MenuItemCount = 0;
-  Menu->MenuItemList = NULL;
-
-  /* Insert menu item into process menu handle list */
-  InsertTailList(&PsGetWin32Process()->MenuListHead, &Menu->ListEntry);
-
-  IntCloneMenuItems(Menu, Source);
-
-  return Menu;
+   HANDLE hMenu;
+   PMENU_OBJECT Menu;
+
+   if(!Source)
+      return NULL;
+
+   Menu = (PMENU_OBJECT)ObmCreateObject(
+             &gHandleTable, &hMenu,
+             otMenu, sizeof(MENU_OBJECT));
+
+   if(!Menu)
+      return NULL;
+
+   Menu->Process = PsGetCurrentProcess();
+   Menu->RtoL = Source->RtoL;
+   Menu->MenuInfo.cbSize = sizeof(MENUINFO); /* not used */
+   Menu->MenuInfo.fMask = Source->MenuInfo.fMask;
+   Menu->MenuInfo.dwStyle = Source->MenuInfo.dwStyle;
+   Menu->MenuInfo.cyMax = Source->MenuInfo.cyMax;
+   Menu->MenuInfo.hbrBack = Source->MenuInfo.hbrBack;
+   Menu->MenuInfo.dwContextHelpID = Source->MenuInfo.dwContextHelpID;
+   Menu->MenuInfo.dwMenuData = Source->MenuInfo.dwMenuData;
+   Menu->MenuInfo.Self = hMenu;
+   Menu->MenuInfo.FocusedItem = NO_SELECTED_ITEM;
+   Menu->MenuInfo.Wnd = NULL;
+   Menu->MenuInfo.WndOwner = NULL;
+   Menu->MenuInfo.Height = 0;
+   Menu->MenuInfo.Width = 0;
+   Menu->MenuInfo.TimeToHide = FALSE;
+
+   Menu->MenuInfo.MenuItemCount = 0;
+   Menu->MenuItemList = NULL;
+
+   /* Insert menu item into process menu handle list */
+   InsertTailList(&PsGetWin32Process()->MenuListHead, &Menu->ListEntry);
+
+   IntCloneMenuItems(Menu, Source);
+
+   return Menu;
 }
 
 BOOL FASTCALL
 IntSetMenuFlagRtoL(PMENU_OBJECT Menu)
 {
-  Menu->RtoL = TRUE;
-  return TRUE;
+   Menu->RtoL = TRUE;
+   return TRUE;
 }
 
 BOOL FASTCALL
 IntSetMenuContextHelpId(PMENU_OBJECT Menu, DWORD dwContextHelpId)
 {
-  Menu->MenuInfo.dwContextHelpID = dwContextHelpId;
-  return TRUE;
+   Menu->MenuInfo.dwContextHelpID = dwContextHelpId;
+   return TRUE;
 }
 
 BOOL FASTCALL
 IntGetMenuInfo(PMENU_OBJECT Menu, PROSMENUINFO lpmi)
 {
-  if(lpmi->fMask & MIM_BACKGROUND)
-    lpmi->hbrBack = Menu->MenuInfo.hbrBack;
-  if(lpmi->fMask & MIM_HELPID)
-    lpmi->dwContextHelpID = Menu->MenuInfo.dwContextHelpID;
-  if(lpmi->fMask & MIM_MAXHEIGHT)
-    lpmi->cyMax = Menu->MenuInfo.cyMax;
-  if(lpmi->fMask & MIM_MENUDATA)
-    lpmi->dwMenuData = Menu->MenuInfo.dwMenuData;
-  if(lpmi->fMask & MIM_STYLE)
-    lpmi->dwStyle = Menu->MenuInfo.dwStyle;
-  if (sizeof(MENUINFO) < lpmi->cbSize)
-    {
+   if(lpmi->fMask & MIM_BACKGROUND)
+      lpmi->hbrBack = Menu->MenuInfo.hbrBack;
+   if(lpmi->fMask & MIM_HELPID)
+      lpmi->dwContextHelpID = Menu->MenuInfo.dwContextHelpID;
+   if(lpmi->fMask & MIM_MAXHEIGHT)
+      lpmi->cyMax = Menu->MenuInfo.cyMax;
+   if(lpmi->fMask & MIM_MENUDATA)
+      lpmi->dwMenuData = Menu->MenuInfo.dwMenuData;
+   if(lpmi->fMask & MIM_STYLE)
+      lpmi->dwStyle = Menu->MenuInfo.dwStyle;
+   if (sizeof(MENUINFO) < lpmi->cbSize)
+   {
       RtlCopyMemory((char *) lpmi + sizeof(MENUINFO),
                     (char *) &Menu->MenuInfo + sizeof(MENUINFO),
                     lpmi->cbSize - sizeof(MENUINFO));
-    }
+   }
 
-  return TRUE;
+   return TRUE;
 }
 
 
 BOOL FASTCALL
 IntIsMenu(HMENU hMenu)
 {
-  PMENU_OBJECT Menu;
-
-  if((Menu = IntGetMenuObject(hMenu)))
-  {
-    IntReleaseMenuObject(Menu);
-    return TRUE;
-  }
-  return FALSE;
+   PMENU_OBJECT Menu;
+
+   if((Menu = IntGetMenuObject(hMenu)))
+   {
+      IntReleaseMenuObject(Menu);
+      return TRUE;
+   }
+   return FALSE;
 }
 
 
 BOOL FASTCALL
 IntSetMenuInfo(PMENU_OBJECT Menu, PROSMENUINFO lpmi)
 {
-  if(lpmi->fMask & MIM_BACKGROUND)
-    Menu->MenuInfo.hbrBack = lpmi->hbrBack;
-  if(lpmi->fMask & MIM_HELPID)
-    Menu->MenuInfo.dwContextHelpID = lpmi->dwContextHelpID;
-  if(lpmi->fMask & MIM_MAXHEIGHT)
-    Menu->MenuInfo.cyMax = lpmi->cyMax;
-  if(lpmi->fMask & MIM_MENUDATA)
-    Menu->MenuInfo.dwMenuData = lpmi->dwMenuData;
-  if(lpmi->fMask & MIM_STYLE)
-    Menu->MenuInfo.dwStyle = lpmi->dwStyle;
-  if(lpmi->fMask & MIM_APPLYTOSUBMENUS)
-    {
-    /* FIXME */
-    }
-  if (sizeof(MENUINFO) < lpmi->cbSize)
-    {
+   if(lpmi->fMask & MIM_BACKGROUND)
+      Menu->MenuInfo.hbrBack = lpmi->hbrBack;
+   if(lpmi->fMask & MIM_HELPID)
+      Menu->MenuInfo.dwContextHelpID = lpmi->dwContextHelpID;
+   if(lpmi->fMask & MIM_MAXHEIGHT)
+      Menu->MenuInfo.cyMax = lpmi->cyMax;
+   if(lpmi->fMask & MIM_MENUDATA)
+      Menu->MenuInfo.dwMenuData = lpmi->dwMenuData;
+   if(lpmi->fMask & MIM_STYLE)
+      Menu->MenuInfo.dwStyle = lpmi->dwStyle;
+   if(lpmi->fMask & MIM_APPLYTOSUBMENUS)
+   {
+      /* FIXME */
+   }
+   if (sizeof(MENUINFO) < lpmi->cbSize)
+   {
       Menu->MenuInfo.FocusedItem = lpmi->FocusedItem;
       Menu->MenuInfo.Height = lpmi->Height;
       Menu->MenuInfo.Width = lpmi->Width;
       Menu->MenuInfo.Wnd = lpmi->Wnd;
       Menu->MenuInfo.WndOwner = lpmi->WndOwner;
       Menu->MenuInfo.TimeToHide = lpmi->TimeToHide;
-    }
+   }
 
-  return TRUE;
+   return TRUE;
 }
 
 
@@ -513,437 +529,443 @@ int FASTCALL
 IntGetMenuItemByFlag(PMENU_OBJECT Menu, UINT uSearchBy, UINT fFlag,
                      PMENU_ITEM *MenuItem, PMENU_ITEM *PrevMenuItem)
 {
-  PMENU_ITEM PrevItem = NULL;
-  PMENU_ITEM CurItem = Menu->MenuItemList;
-  int p;
-  int ret;
-
-  if(MF_BYPOSITION & fFlag)
-  {
-    p = uSearchBy;
-    while(CurItem && (p > 0))
-    {
-      PrevItem = CurItem;
-      CurItem = CurItem->Next;
-      p--;
-    }
-    if(CurItem)
-    {
-      if(MenuItem) *MenuItem = CurItem;
-      if(PrevMenuItem) *PrevMenuItem = PrevItem;
-    }
-    else
-    {
-      if(MenuItem) *MenuItem = NULL;
-      if(PrevMenuItem) *PrevMenuItem = NULL; /* ? */
-      return -1;
-    }
-
-    return uSearchBy - p;
-  }
-  else
-  {
-    p = 0;
-    while(CurItem)
-    {
-      if(CurItem->wID == uSearchBy)
+   PMENU_ITEM PrevItem = NULL;
+   PMENU_ITEM CurItem = Menu->MenuItemList;
+   int p;
+   int ret;
+
+   if(MF_BYPOSITION & fFlag)
+   {
+      p = uSearchBy;
+      while(CurItem && (p > 0))
+      {
+         PrevItem = CurItem;
+         CurItem = CurItem->Next;
+         p--;
+      }
+      if(CurItem)
       {
-        if(MenuItem) *MenuItem = CurItem;
-        if(PrevMenuItem) *PrevMenuItem = PrevItem;
-        return p;
+         if(MenuItem)
+            *MenuItem = CurItem;
+         if(PrevMenuItem)
+            *PrevMenuItem = PrevItem;
       }
-      else if (0 != (CurItem->fType & MF_POPUP))
+      else
       {
-        Menu = UserGetMenuObject(CurItem->hSubMenu);
-        if (NULL != Menu)
-        {
-          ret = IntGetMenuItemByFlag(Menu, uSearchBy, fFlag,
-                                     MenuItem, PrevMenuItem);
-          if (-1 != ret)
-          {
-            return ret;
-          }
-        }
+         if(MenuItem)
+            *MenuItem = NULL;
+         if(PrevMenuItem)
+            *PrevMenuItem = NULL; /* ? */
+         return -1;
       }
-      PrevItem = CurItem;
-      CurItem = CurItem->Next;
-      p++;
-    }
-  }
-  return -1;
+
+      return uSearchBy - p;
+   }
+   else
+   {
+      p = 0;
+      while(CurItem)
+      {
+         if(CurItem->wID == uSearchBy)
+         {
+            if(MenuItem)
+               *MenuItem = CurItem;
+            if(PrevMenuItem)
+               *PrevMenuItem = PrevItem;
+            return p;
+         }
+         else if (0 != (CurItem->fType & MF_POPUP))
+         {
+            Menu = UserGetMenuObject(CurItem->hSubMenu);
+            if (NULL != Menu)
+            {
+               ret = IntGetMenuItemByFlag(Menu, uSearchBy, fFlag,
+                                          MenuItem, PrevMenuItem);
+               if (-1 != ret)
+               {
+                  return ret;
+               }
+            }
+         }
+         PrevItem = CurItem;
+         CurItem = CurItem->Next;
+         p++;
+      }
+   }
+   return -1;
 }
 
 
 int FASTCALL
 IntInsertMenuItemToList(PMENU_OBJECT Menu, PMENU_ITEM MenuItem, int pos)
 {
-  PMENU_ITEM CurItem;
-  PMENU_ITEM LastItem = NULL;
-  UINT npos = 0;
-
-  CurItem = Menu->MenuItemList;
-  if(pos <= -1)
-  {
-    while(CurItem)
-    {
-      LastItem = CurItem;
-      CurItem = CurItem->Next;
-      npos++;
-    }
-  }
-  else
-  {
-    while(CurItem && (pos > 0))
-    {
-      LastItem = CurItem;
-      CurItem = CurItem->Next;
-      pos--;
-      npos++;
-    }
-  }
-
-  if(CurItem)
-  {
-    if(LastItem)
-    {
-      /* insert the item before CurItem */
-      MenuItem->Next = LastItem->Next;
-      LastItem->Next = MenuItem;
-    }
-    else
-    {
-      /* insert at the beginning */
-      Menu->MenuItemList = MenuItem;
-      MenuItem->Next = CurItem;
-    }
-  }
-  else
-  {
-    if(LastItem)
-    {
-      /* append item */
-      LastItem->Next = MenuItem;
-      MenuItem->Next = NULL;
-    }
-    else
-    {
-      /* insert first item */
-      Menu->MenuItemList = MenuItem;
-      MenuItem->Next = NULL;
-    }
-  }
-  Menu->MenuInfo.MenuItemCount++;
-
-  return npos;
+   PMENU_ITEM CurItem;
+   PMENU_ITEM LastItem = NULL;
+   UINT npos = 0;
+
+   CurItem = Menu->MenuItemList;
+   if(pos <= -1)
+   {
+      while(CurItem)
+      {
+         LastItem = CurItem;
+         CurItem = CurItem->Next;
+         npos++;
+      }
+   }
+   else
+   {
+      while(CurItem && (pos > 0))
+      {
+         LastItem = CurItem;
+         CurItem = CurItem->Next;
+         pos--;
+         npos++;
+      }
+   }
+
+   if(CurItem)
+   {
+      if(LastItem)
+      {
+         /* insert the item before CurItem */
+         MenuItem->Next = LastItem->Next;
+         LastItem->Next = MenuItem;
+      }
+      else
+      {
+         /* insert at the beginning */
+         Menu->MenuItemList = MenuItem;
+         MenuItem->Next = CurItem;
+      }
+   }
+   else
+   {
+      if(LastItem)
+      {
+         /* append item */
+         LastItem->Next = MenuItem;
+         MenuItem->Next = NULL;
+      }
+      else
+      {
+         /* insert first item */
+         Menu->MenuItemList = MenuItem;
+         MenuItem->Next = NULL;
+      }
+   }
+   Menu->MenuInfo.MenuItemCount++;
+
+   return npos;
 }
 
 BOOL FASTCALL
 IntGetMenuItemInfo(PMENU_OBJECT Menu, /* UNUSED PARAM!! */
-   PMENU_ITEM MenuItem, PROSMENUITEMINFO lpmii)
+                   PMENU_ITEM MenuItem, PROSMENUITEMINFO lpmii)
 {
-  NTSTATUS Status;
+   NTSTATUS Status;
 
-  if(lpmii->fMask & MIIM_BITMAP)
-    {
+   if(lpmii->fMask & MIIM_BITMAP)
+   {
       lpmii->hbmpItem = MenuItem->hbmpItem;
-    }
-  if(lpmii->fMask & MIIM_CHECKMARKS)
-    {
+   }
+   if(lpmii->fMask & MIIM_CHECKMARKS)
+   {
       lpmii->hbmpChecked = MenuItem->hbmpChecked;
       lpmii->hbmpUnchecked = MenuItem->hbmpUnchecked;
-    }
-  if(lpmii->fMask & MIIM_DATA)
-    {
+   }
+   if(lpmii->fMask & MIIM_DATA)
+   {
       lpmii->dwItemData = MenuItem->dwItemData;
-    }
-  if(lpmii->fMask & (MIIM_FTYPE | MIIM_TYPE))
-    {
+   }
+   if(lpmii->fMask & (MIIM_FTYPE | MIIM_TYPE))
+   {
       lpmii->fType = MenuItem->fType;
-    }
-  if(lpmii->fMask & MIIM_ID)
-    {
+   }
+   if(lpmii->fMask & MIIM_ID)
+   {
       lpmii->wID = MenuItem->wID;
-    }
-  if(lpmii->fMask & MIIM_STATE)
-    {
+   }
+   if(lpmii->fMask & MIIM_STATE)
+   {
       lpmii->fState = MenuItem->fState;
-    }
-  if(lpmii->fMask & MIIM_SUBMENU)
-    {
+   }
+   if(lpmii->fMask & MIIM_SUBMENU)
+   {
       lpmii->hSubMenu = MenuItem->hSubMenu;
-    }
-  if (lpmii->fMask & (MIIM_STRING | MIIM_TYPE))
-    {
+   }
+   if (lpmii->fMask & (MIIM_STRING | MIIM_TYPE))
+   {
       if (lpmii->dwTypeData == NULL)
-        {
-          lpmii->cch = MenuItem->Text.Length / sizeof(WCHAR);
-        }
+      {
+         lpmii->cch = MenuItem->Text.Length / sizeof(WCHAR);
+      }
       else
-        {
-          Status = MmCopyToCaller(lpmii->dwTypeData, MenuItem->Text.Buffer,
-                                  min(lpmii->cch * sizeof(WCHAR),
-                                      MenuItem->Text.MaximumLength));
-          if (! NT_SUCCESS(Status))
-            {
-              SetLastNtError(Status);
-              return FALSE;
-            }
-        }
-    }
+      {
+         Status = MmCopyToCaller(lpmii->dwTypeData, MenuItem->Text.Buffer,
+                                 min(lpmii->cch * sizeof(WCHAR),
+                                     MenuItem->Text.MaximumLength));
+         if (! NT_SUCCESS(Status))
+         {
+            SetLastNtError(Status);
+            return FALSE;
+         }
+      }
+   }
 
-  if (sizeof(ROSMENUITEMINFO) == lpmii->cbSize)
-    {
+   if (sizeof(ROSMENUITEMINFO) == lpmii->cbSize)
+   {
       lpmii->Rect = MenuItem->Rect;
       lpmii->XTab = MenuItem->XTab;
-    }
+   }
 
-  return TRUE;
+   return TRUE;
 }
 
 BOOL FASTCALL
 IntSetMenuItemInfo(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem, PROSMENUITEMINFO lpmii)
 {
-  PMENU_OBJECT SubMenuObject;
-
-  if(!MenuItem || !MenuObject || !lpmii)
-  {
-    return FALSE;
-  }
-
-  MenuItem->fType = lpmii->fType;
-
-  if(lpmii->fMask & MIIM_BITMAP)
-  {
-    MenuItem->hbmpItem = lpmii->hbmpItem;
-  }
-  if(lpmii->fMask & MIIM_CHECKMARKS)
-  {
-    MenuItem->hbmpChecked = lpmii->hbmpChecked;
-    MenuItem->hbmpUnchecked = lpmii->hbmpUnchecked;
-  }
-  if(lpmii->fMask & MIIM_DATA)
-  {
-    MenuItem->dwItemData = lpmii->dwItemData;
-  }
-  if(lpmii->fMask & (MIIM_FTYPE | MIIM_TYPE))
-  {
-    /*
-     * Delete the menu item type when changing type from
-     * MF_STRING.
-     */
-    if (MenuItem->fType != lpmii->fType &&
-        MENU_ITEM_TYPE(MenuItem->fType) == MF_STRING)
-    {
-      FreeMenuText(MenuItem);
-      RtlInitUnicodeString(&MenuItem->Text, NULL);
-    }
-    MenuItem->fType = lpmii->fType;
-  }
-  if(lpmii->fMask & MIIM_ID)
-  {
-    MenuItem->wID = lpmii->wID;
-  }
-  if(lpmii->fMask & MIIM_STATE)
-  {
-    /* remove MFS_DEFAULT flag from all other menu items if this item
-       has the MFS_DEFAULT state */
-    if(lpmii->fState & MFS_DEFAULT)
-      UserSetMenuDefaultItem(MenuObject, -1, 0);
-    /* update the menu item state flags */
-    UpdateMenuItemState(MenuItem->fState, lpmii->fState);
-  }
-
-  if(lpmii->fMask & MIIM_SUBMENU)
-  {
-    MenuItem->hSubMenu = lpmii->hSubMenu;
-    /* Make sure the submenu is marked as a popup menu */
-    if (MenuItem->hSubMenu)
-    {
-      SubMenuObject = IntGetMenuObject(MenuItem->hSubMenu);
-      if (SubMenuObject != NULL)
+   PMENU_OBJECT SubMenuObject;
+
+   if(!MenuItem || !MenuObject || !lpmii)
+   {
+      return FALSE;
+   }
+
+   MenuItem->fType = lpmii->fType;
+
+   if(lpmii->fMask & MIIM_BITMAP)
+   {
+      MenuItem->hbmpItem = lpmii->hbmpItem;
+   }
+   if(lpmii->fMask & MIIM_CHECKMARKS)
+   {
+      MenuItem->hbmpChecked = lpmii->hbmpChecked;
+      MenuItem->hbmpUnchecked = lpmii->hbmpUnchecked;
+   }
+   if(lpmii->fMask & MIIM_DATA)
+   {
+      MenuItem->dwItemData = lpmii->dwItemData;
+   }
+   if(lpmii->fMask & (MIIM_FTYPE | MIIM_TYPE))
+   {
+      /*
+       * Delete the menu item type when changing type from
+       * MF_STRING.
+       */
+      if (MenuItem->fType != lpmii->fType &&
+            MENU_ITEM_TYPE(MenuItem->fType) == MF_STRING)
       {
-        SubMenuObject->MenuInfo.Flags |= MF_POPUP;
-        MenuItem->fType |= MF_POPUP;
-        IntReleaseMenuObject(SubMenuObject);
+         FreeMenuText(MenuItem);
+         RtlInitUnicodeString(&MenuItem->Text, NULL);
+      }
+      MenuItem->fType = lpmii->fType;
+   }
+   if(lpmii->fMask & MIIM_ID)
+   {
+      MenuItem->wID = lpmii->wID;
+   }
+   if(lpmii->fMask & MIIM_STATE)
+   {
+      /* remove MFS_DEFAULT flag from all other menu items if this item
+         has the MFS_DEFAULT state */
+      if(lpmii->fState & MFS_DEFAULT)
+         UserSetMenuDefaultItem(MenuObject, -1, 0);
+      /* update the menu item state flags */
+      UpdateMenuItemState(MenuItem->fState, lpmii->fState);
+   }
+
+   if(lpmii->fMask & MIIM_SUBMENU)
+   {
+      MenuItem->hSubMenu = lpmii->hSubMenu;
+      /* Make sure the submenu is marked as a popup menu */
+      if (MenuItem->hSubMenu)
+      {
+         SubMenuObject = IntGetMenuObject(MenuItem->hSubMenu);
+         if (SubMenuObject != NULL)
+         {
+            SubMenuObject->MenuInfo.Flags |= MF_POPUP;
+            MenuItem->fType |= MF_POPUP;
+            IntReleaseMenuObject(SubMenuObject);
+         }
+         else
+         {
+            MenuItem->fType &= ~MF_POPUP;
+         }
       }
       else
       {
-        MenuItem->fType &= ~MF_POPUP;
+         MenuItem->fType &= ~MF_POPUP;
       }
-    }
-    else
-    {
-      MenuItem->fType &= ~MF_POPUP;
-    }
-  }
-  if ((lpmii->fMask & (MIIM_TYPE | MIIM_STRING)) &&
-      (MENU_ITEM_TYPE(lpmii->fType) == MF_STRING))
-  {
-    FreeMenuText(MenuItem);
-
-    if(lpmii->dwTypeData && lpmii->cch)
-    {
-      UNICODE_STRING Source;
-
-      Source.Length =
-      Source.MaximumLength = lpmii->cch * sizeof(WCHAR);
-      Source.Buffer = lpmii->dwTypeData;
-
-      MenuItem->Text.Buffer = (PWSTR)ExAllocatePoolWithTag(
-        PagedPool, Source.Length + sizeof(WCHAR), TAG_STRING);
-      if(MenuItem->Text.Buffer != NULL)
+   }
+   if ((lpmii->fMask & (MIIM_TYPE | MIIM_STRING)) &&
+         (MENU_ITEM_TYPE(lpmii->fType) == MF_STRING))
+   {
+      FreeMenuText(MenuItem);
+
+      if(lpmii->dwTypeData && lpmii->cch)
       {
-        MenuItem->Text.Length = 0;
-        MenuItem->Text.MaximumLength = Source.Length + sizeof(WCHAR);
-        RtlCopyUnicodeString(&MenuItem->Text, &Source);
-        MenuItem->Text.Buffer[MenuItem->Text.Length / sizeof(WCHAR)] = 0;
+         UNICODE_STRING Source;
+
+         Source.Length =
+            Source.MaximumLength = lpmii->cch * sizeof(WCHAR);
+         Source.Buffer = lpmii->dwTypeData;
+
+         MenuItem->Text.Buffer = (PWSTR)ExAllocatePoolWithTag(
+                                    PagedPool, Source.Length + sizeof(WCHAR), TAG_STRING);
+         if(MenuItem->Text.Buffer != NULL)
+         {
+            MenuItem->Text.Length = 0;
+            MenuItem->Text.MaximumLength = Source.Length + sizeof(WCHAR);
+            RtlCopyUnicodeString(&MenuItem->Text, &Source);
+            MenuItem->Text.Buffer[MenuItem->Text.Length / sizeof(WCHAR)] = 0;
+         }
+         else
+         {
+            RtlInitUnicodeString(&MenuItem->Text, NULL);
+         }
       }
       else
       {
-        RtlInitUnicodeString(&MenuItem->Text, NULL);
+         MenuItem->fType |= MF_SEPARATOR;
+         RtlInitUnicodeString(&MenuItem->Text, NULL);
       }
-    }
-    else
-    {
-      MenuItem->fType |= MF_SEPARATOR;
-      RtlInitUnicodeString(&MenuItem->Text, NULL);
-    }
-  }
-
-  if (sizeof(ROSMENUITEMINFO) == lpmii->cbSize)
-    {
+   }
+
+   if (sizeof(ROSMENUITEMINFO) == lpmii->cbSize)
+   {
       MenuItem->Rect = lpmii->Rect;
       MenuItem->XTab = lpmii->XTab;
-    }
+   }
 
-  return TRUE;
+   return TRUE;
 }
 
 BOOL FASTCALL
 IntInsertMenuItem(PMENU_OBJECT MenuObject, UINT uItem, BOOL fByPosition,
                   PROSMENUITEMINFO ItemInfo)
 {
-  int pos = (int)uItem;
-  PMENU_ITEM MenuItem;
+   int pos = (int)uItem;
+   PMENU_ITEM MenuItem;
 
-  if (MAX_MENU_ITEMS <= MenuObject->MenuInfo.MenuItemCount)
-    {
+   if (MAX_MENU_ITEMS <= MenuObject->MenuInfo.MenuItemCount)
+   {
       SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
       return FALSE;
-    }
+   }
 
-  if (fByPosition)
-    {
+   if (fByPosition)
+   {
       /* calculate position */
       if(MenuObject->MenuInfo.MenuItemCount < pos)
-        {
-          pos = MenuObject->MenuInfo.MenuItemCount;
-        }
-    }
-  else
-    {
+      {
+         pos = MenuObject->MenuInfo.MenuItemCount;
+      }
+   }
+   else
+   {
       pos = IntGetMenuItemByFlag(MenuObject, uItem, MF_BYCOMMAND, NULL, NULL);
-    }
-  if (pos < -1)
-    {
+   }
+   if (pos < -1)
+   {
       pos = -1;
-    }
+   }
 
-  MenuItem = ExAllocatePoolWithTag(PagedPool, sizeof(MENU_ITEM), TAG_MENUITEM);
-  if (NULL == MenuItem)
-    {
+   MenuItem = ExAllocatePoolWithTag(PagedPool, sizeof(MENU_ITEM), TAG_MENUITEM);
+   if (NULL == MenuItem)
+   {
       SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
       return FALSE;
-    }
-
-  MenuItem->fType = MFT_STRING;
-  MenuItem->fState = MFS_ENABLED | MFS_UNCHECKED;
-  MenuItem->wID = 0;
-  MenuItem->hSubMenu = (HMENU)0;
-  MenuItem->hbmpChecked = (HBITMAP)0;
-  MenuItem->hbmpUnchecked = (HBITMAP)0;
-  MenuItem->dwItemData = 0;
-  RtlInitUnicodeString(&MenuItem->Text, NULL);
-  MenuItem->hbmpItem = (HBITMAP)0;
-
-  if (! IntSetMenuItemInfo(MenuObject, MenuItem, ItemInfo))
-    {
+   }
+
+   MenuItem->fType = MFT_STRING;
+   MenuItem->fState = MFS_ENABLED | MFS_UNCHECKED;
+   MenuItem->wID = 0;
+   MenuItem->hSubMenu = (HMENU)0;
+   MenuItem->hbmpChecked = (HBITMAP)0;
+   MenuItem->hbmpUnchecked = (HBITMAP)0;
+   MenuItem->dwItemData = 0;
+   RtlInitUnicodeString(&MenuItem->Text, NULL);
+   MenuItem->hbmpItem = (HBITMAP)0;
+
+   if (! IntSetMenuItemInfo(MenuObject, MenuItem, ItemInfo))
+   {
       ExFreePool(MenuItem);
       return FALSE;
-    }
+   }
 
-  /* Force size recalculation! */
-  MenuObject->MenuInfo.Height = 0;
+   /* Force size recalculation! */
+   MenuObject->MenuInfo.Height = 0;
 
-  pos = IntInsertMenuItemToList(MenuObject, MenuItem, pos);
+   pos = IntInsertMenuItemToList(MenuObject, MenuItem, pos);
 
-  return pos >= 0;
+   return pos >= 0;
 }
 
 UINT FASTCALL
 IntEnableMenuItem(PMENU_OBJECT MenuObject, UINT uIDEnableItem, UINT uEnable)
 {
-  PMENU_ITEM MenuItem;
-  UINT res = IntGetMenuItemByFlag(MenuObject, uIDEnableItem, uEnable, &MenuItem, NULL);
-  if(!MenuItem || (res == (UINT)-1))
-  {
-    return (UINT)-1;
-  }
-
-  res = MenuItem->fState & (MF_GRAYED | MF_DISABLED);
-
-  if(uEnable & MF_DISABLED)
-  {
-    if(!(MenuItem->fState & MF_DISABLED))
-        MenuItem->fState |= MF_DISABLED;
-    if(uEnable & MF_GRAYED)
-    {
-      if(!(MenuItem->fState & MF_GRAYED))
-          MenuItem->fState |= MF_GRAYED;
-    }
-  }
-  else
-  {
-    if(uEnable & MF_GRAYED)
-    {
-      if(!(MenuItem->fState & MF_GRAYED))
-          MenuItem->fState |= MF_GRAYED;
+   PMENU_ITEM MenuItem;
+   UINT res = IntGetMenuItemByFlag(MenuObject, uIDEnableItem, uEnable, &MenuItem, NULL);
+   if(!MenuItem || (res == (UINT)-1))
+   {
+      return (UINT)-1;
+   }
+
+   res = MenuItem->fState & (MF_GRAYED | MF_DISABLED);
+
+   if(uEnable & MF_DISABLED)
+   {
       if(!(MenuItem->fState & MF_DISABLED))
-          MenuItem->fState |= MF_DISABLED;
-    }
-    else
-    {
-      if(MenuItem->fState & MF_DISABLED)
-          MenuItem->fState ^= MF_DISABLED;
-      if(MenuItem->fState & MF_GRAYED)
-          MenuItem->fState ^= MF_GRAYED;
-    }
-  }
-
-  return res;
+         MenuItem->fState |= MF_DISABLED;
+      if(uEnable & MF_GRAYED)
+      {
+         if(!(MenuItem->fState & MF_GRAYED))
+            MenuItem->fState |= MF_GRAYED;
+      }
+   }
+   else
+   {
+      if(uEnable & MF_GRAYED)
+      {
+         if(!(MenuItem->fState & MF_GRAYED))
+            MenuItem->fState |= MF_GRAYED;
+         if(!(MenuItem->fState & MF_DISABLED))
+            MenuItem->fState |= MF_DISABLED;
+      }
+      else
+      {
+         if(MenuItem->fState & MF_DISABLED)
+            MenuItem->fState ^= MF_DISABLED;
+         if(MenuItem->fState & MF_GRAYED)
+            MenuItem->fState ^= MF_GRAYED;
+      }
+   }
+
+   return res;
 }
 
 
 DWORD FASTCALL
 IntBuildMenuItemList(PMENU_OBJECT MenuObject, PVOID Buffer, ULONG nMax)
 {
-  DWORD res = 0;
-  UINT sz;
-  ROSMENUITEMINFO mii;
-  PVOID Buf;
-  PMENU_ITEM CurItem = MenuObject->MenuItemList;
-  PWCHAR StrOut;
-  NTSTATUS Status;
-  WCHAR NulByte;
-
-  if (0 != nMax)
-    {
+   DWORD res = 0;
+   UINT sz;
+   ROSMENUITEMINFO mii;
+   PVOID Buf;
+   PMENU_ITEM CurItem = MenuObject->MenuItemList;
+   PWCHAR StrOut;
+   NTSTATUS Status;
+   WCHAR NulByte;
+
+   if (0 != nMax)
+   {
       if (nMax < MenuObject->MenuInfo.MenuItemCount * sizeof(ROSMENUITEMINFO))
-        {
-          return 0;
-        }
+      {
+         return 0;
+      }
       StrOut = (PWCHAR)((char *) Buffer + MenuObject->MenuInfo.MenuItemCount
-                                          * sizeof(ROSMENUITEMINFO));
+                        * sizeof(ROSMENUITEMINFO));
       nMax -= MenuObject->MenuInfo.MenuItemCount * sizeof(ROSMENUITEMINFO);
       sz = sizeof(ROSMENUITEMINFO);
       Buf = Buffer;
@@ -952,293 +974,293 @@ IntBuildMenuItemList(PMENU_OBJECT MenuObject, PVOID Buffer, ULONG nMax)
       NulByte = L'\0';
 
       while (NULL != CurItem)
-        {
-          mii.cch = CurItem->Text.Length / sizeof(WCHAR);
-          mii.dwItemData = CurItem->dwItemData;
-          if (0 != CurItem->Text.Length)
-            {
-              mii.dwTypeData = StrOut;
-            }
-          else
-            {
-              mii.dwTypeData = NULL;
-            }
-          mii.fState = CurItem->fState;
-          mii.fType = CurItem->fType;
-          mii.hbmpChecked = CurItem->hbmpChecked;
-          mii.hbmpItem = CurItem->hbmpItem;
-          mii.hbmpUnchecked = CurItem->hbmpUnchecked;
-          mii.hSubMenu = CurItem->hSubMenu;
-          mii.Rect = CurItem->Rect;
-          mii.XTab = CurItem->XTab;
-
-          Status = MmCopyToCaller(Buf, &mii, sizeof(ROSMENUITEMINFO));
-          if (! NT_SUCCESS(Status))
-            {
-              SetLastNtError(Status);
-              return 0;
-            }
-          Buf = (PVOID)((ULONG_PTR)Buf + sizeof(ROSMENUITEMINFO));
-
-          if (0 != CurItem->Text.Length
-              && (nMax >= CurItem->Text.Length + sizeof(WCHAR)))
+      {
+         mii.cch = CurItem->Text.Length / sizeof(WCHAR);
+         mii.dwItemData = CurItem->dwItemData;
+         if (0 != CurItem->Text.Length)
+         {
+            mii.dwTypeData = StrOut;
+         }
+         else
+         {
+            mii.dwTypeData = NULL;
+         }
+         mii.fState = CurItem->fState;
+         mii.fType = CurItem->fType;
+         mii.hbmpChecked = CurItem->hbmpChecked;
+         mii.hbmpItem = CurItem->hbmpItem;
+         mii.hbmpUnchecked = CurItem->hbmpUnchecked;
+         mii.hSubMenu = CurItem->hSubMenu;
+         mii.Rect = CurItem->Rect;
+         mii.XTab = CurItem->XTab;
+
+         Status = MmCopyToCaller(Buf, &mii, sizeof(ROSMENUITEMINFO));
+         if (! NT_SUCCESS(Status))
+         {
+            SetLastNtError(Status);
+            return 0;
+         }
+         Buf = (PVOID)((ULONG_PTR)Buf + sizeof(ROSMENUITEMINFO));
+
+         if (0 != CurItem->Text.Length
+               && (nMax >= CurItem->Text.Length + sizeof(WCHAR)))
+         {
+            /* copy string */
+            Status = MmCopyToCaller(StrOut, CurItem->Text.Buffer,
+                                    CurItem->Text.Length);
+            if (! NT_SUCCESS(Status))
             {
-              /* copy string */
-              Status = MmCopyToCaller(StrOut, CurItem->Text.Buffer,
-                                      CurItem->Text.Length);
-              if (! NT_SUCCESS(Status))
-                {
-                  SetLastNtError(Status);
-                  return 0;
-                }
-              StrOut += CurItem->Text.Length / sizeof(WCHAR);
-              Status = MmCopyToCaller(StrOut, &NulByte, sizeof(WCHAR));
-              if (! NT_SUCCESS(Status))
-                {
-                  SetLastNtError(Status);
-                  return 0;
-                }
-              StrOut++;
-              nMax -= CurItem->Text.Length + sizeof(WCHAR);
+               SetLastNtError(Status);
+               return 0;
             }
-          else if (0 != CurItem->Text.Length)
+            StrOut += CurItem->Text.Length / sizeof(WCHAR);
+            Status = MmCopyToCaller(StrOut, &NulByte, sizeof(WCHAR));
+            if (! NT_SUCCESS(Status))
             {
-              break;
+               SetLastNtError(Status);
+               return 0;
             }
-
-          CurItem = CurItem->Next;
-          res++;
-        }
-    }
-  else
-    {
+            StrOut++;
+            nMax -= CurItem->Text.Length + sizeof(WCHAR);
+         }
+         else if (0 != CurItem->Text.Length)
+         {
+            break;
+         }
+
+         CurItem = CurItem->Next;
+         res++;
+      }
+   }
+   else
+   {
       while (NULL != CurItem)
-        {
-          res += sizeof(ROSMENUITEMINFO) + CurItem->Text.Length + sizeof(WCHAR);
-          CurItem = CurItem->Next;
-        }
-    }
+      {
+         res += sizeof(ROSMENUITEMINFO) + CurItem->Text.Length + sizeof(WCHAR);
+         CurItem = CurItem->Next;
+      }
+   }
 
-  return res;
+   return res;
 }
 
 
 DWORD FASTCALL
 IntCheckMenuItem(PMENU_OBJECT MenuObject, UINT uIDCheckItem, UINT uCheck)
 {
-  PMENU_ITEM MenuItem;
-  int res = -1;
-
-  if((IntGetMenuItemByFlag(MenuObject, uIDCheckItem, uCheck, &MenuItem, NULL) < 0) || !MenuItem)
-  {
-    return -1;
-  }
-
-  res = (DWORD)(MenuItem->fState & MF_CHECKED);
-  if(uCheck & MF_CHECKED)
-  {
-    if(!(MenuItem->fState & MF_CHECKED))
-        MenuItem->fState |= MF_CHECKED;
-  }
-  else
-  {
-    if(MenuItem->fState & MF_CHECKED)
-        MenuItem->fState ^= MF_CHECKED;
-  }
-
-  return (DWORD)res;
+   PMENU_ITEM MenuItem;
+   int res = -1;
+
+   if((IntGetMenuItemByFlag(MenuObject, uIDCheckItem, uCheck, &MenuItem, NULL) < 0) || !MenuItem)
+   {
+      return -1;
+   }
+
+   res = (DWORD)(MenuItem->fState & MF_CHECKED);
+   if(uCheck & MF_CHECKED)
+   {
+      if(!(MenuItem->fState & MF_CHECKED))
+         MenuItem->fState |= MF_CHECKED;
+   }
+   else
+   {
+      if(MenuItem->fState & MF_CHECKED)
+         MenuItem->fState ^= MF_CHECKED;
+   }
+
+   return (DWORD)res;
 }
 
 BOOL FASTCALL
 IntHiliteMenuItem(PWINDOW_OBJECT WindowObject, PMENU_OBJECT MenuObject,
-  UINT uItemHilite, UINT uHilite)
+                  UINT uItemHilite, UINT uHilite)
 {
-  PMENU_ITEM MenuItem;
-  BOOL res = IntGetMenuItemByFlag(MenuObject, uItemHilite, uHilite, &MenuItem, NULL);
-  if(!MenuItem || !res)
-  {
-    return FALSE;
-  }
-
-  if(uHilite & MF_HILITE)
-  {
-    if(!(MenuItem->fState & MF_HILITE))
-        MenuItem->fState |= MF_HILITE;
-  }
-  else
-  {
-    if(MenuItem->fState & MF_HILITE)
-        MenuItem->fState ^= MF_HILITE;
-  }
-
-  /* FIXME - update the window's menu */
-
-  return TRUE;
+   PMENU_ITEM MenuItem;
+   BOOL res = IntGetMenuItemByFlag(MenuObject, uItemHilite, uHilite, &MenuItem, NULL);
+   if(!MenuItem || !res)
+   {
+      return FALSE;
+   }
+
+   if(uHilite & MF_HILITE)
+   {
+      if(!(MenuItem->fState & MF_HILITE))
+         MenuItem->fState |= MF_HILITE;
+   }
+   else
+   {
+      if(MenuItem->fState & MF_HILITE)
+         MenuItem->fState ^= MF_HILITE;
+   }
+
+   /* FIXME - update the window's menu */
+
+   return TRUE;
 }
 
 BOOL FASTCALL
 UserSetMenuDefaultItem(PMENU_OBJECT MenuObject, UINT uItem, UINT fByPos)
 {
-  BOOL ret = FALSE;
-  PMENU_ITEM MenuItem = MenuObject->MenuItemList;
+   BOOL ret = FALSE;
+   PMENU_ITEM MenuItem = MenuObject->MenuItemList;
 
-  if(uItem == (UINT)-1)
-  {
-    while(MenuItem)
-    {
-      if(MenuItem->fState & MFS_DEFAULT)
-        MenuItem->fState ^= MFS_DEFAULT;
-      MenuItem = MenuItem->Next;
-    }
-    return TRUE;
-  }
-
-  if(fByPos)
-  {
-    UINT pos = 0;
-    while(MenuItem)
-    {
-      if(pos == uItem)
-      {
-        if(!(MenuItem->fState & MFS_DEFAULT))
-          MenuItem->fState |= MFS_DEFAULT;
-        ret = TRUE;
-      }
-      else
+   if(uItem == (UINT)-1)
+   {
+      while(MenuItem)
       {
-        if(MenuItem->fState & MFS_DEFAULT)
-          MenuItem->fState ^= MFS_DEFAULT;
+         if(MenuItem->fState & MFS_DEFAULT)
+            MenuItem->fState ^= MFS_DEFAULT;
+         MenuItem = MenuItem->Next;
       }
-      pos++;
-      MenuItem = MenuItem->Next;
-    }
-  }
-  else
-  {
-    while(MenuItem)
-    {
-      if(!ret && (MenuItem->wID == uItem))
+      return TRUE;
+   }
+
+   if(fByPos)
+   {
+      UINT pos = 0;
+      while(MenuItem)
       {
-        if(!(MenuItem->fState & MFS_DEFAULT))
-          MenuItem->fState |= MFS_DEFAULT;
-        ret = TRUE;
+         if(pos == uItem)
+         {
+            if(!(MenuItem->fState & MFS_DEFAULT))
+               MenuItem->fState |= MFS_DEFAULT;
+            ret = TRUE;
+         }
+         else
+         {
+            if(MenuItem->fState & MFS_DEFAULT)
+               MenuItem->fState ^= MFS_DEFAULT;
+         }
+         pos++;
+         MenuItem = MenuItem->Next;
       }
-      else
+   }
+   else
+   {
+      while(MenuItem)
       {
-        if(MenuItem->fState & MFS_DEFAULT)
-          MenuItem->fState ^= MFS_DEFAULT;
+         if(!ret && (MenuItem->wID == uItem))
+         {
+            if(!(MenuItem->fState & MFS_DEFAULT))
+               MenuItem->fState |= MFS_DEFAULT;
+            ret = TRUE;
+         }
+         else
+         {
+            if(MenuItem->fState & MFS_DEFAULT)
+               MenuItem->fState ^= MFS_DEFAULT;
+         }
+         MenuItem = MenuItem->Next;
       }
-      MenuItem = MenuItem->Next;
-    }
-  }
-  return ret;
+   }
+   return ret;
 }
 
 
 UINT FASTCALL
 IntGetMenuDefaultItem(PMENU_OBJECT MenuObject, UINT fByPos, UINT gmdiFlags,
-  DWORD *gismc)
+                      DWORD *gismc)
 {
-  UINT x = 0;
-  UINT res = -1;
-  UINT sres;
-  PMENU_OBJECT SubMenuObject;
-  PMENU_ITEM MenuItem = MenuObject->MenuItemList;
-
-  while(MenuItem)
-  {
-    if(MenuItem->fState & MFS_DEFAULT)
-    {
-
-      if(!(gmdiFlags & GMDI_USEDISABLED) && (MenuItem->fState & MFS_DISABLED))
-        break;
-
-      if(fByPos & MF_BYPOSITION)
-        res = x;
-      else
-        res = MenuItem->wID;
+   UINT x = 0;
+   UINT res = -1;
+   UINT sres;
+   PMENU_OBJECT SubMenuObject;
+   PMENU_ITEM MenuItem = MenuObject->MenuItemList;
 
-      if((*gismc < MAX_GOINTOSUBMENU) && (gmdiFlags & GMDI_GOINTOPOPUPS) &&
-         MenuItem->hSubMenu)
+   while(MenuItem)
+   {
+      if(MenuItem->fState & MFS_DEFAULT)
       {
 
-        SubMenuObject = IntGetMenuObject(MenuItem->hSubMenu);
-        if(!SubMenuObject || (SubMenuObject == MenuObject))
-          break;
+         if(!(gmdiFlags & GMDI_USEDISABLED) && (MenuItem->fState & MFS_DISABLED))
+            break;
 
-        (*gismc)++;
-        sres = IntGetMenuDefaultItem(SubMenuObject, fByPos, gmdiFlags, gismc);
-        (*gismc)--;
+         if(fByPos & MF_BYPOSITION)
+            res = x;
+         else
+            res = MenuItem->wID;
 
-        IntReleaseMenuObject(SubMenuObject);
+         if((*gismc < MAX_GOINTOSUBMENU) && (gmdiFlags & GMDI_GOINTOPOPUPS) &&
+               MenuItem->hSubMenu)
+         {
 
-        if(sres > (UINT)-1)
-          res = sres;
-      }
+            SubMenuObject = IntGetMenuObject(MenuItem->hSubMenu);
+            if(!SubMenuObject || (SubMenuObject == MenuObject))
+               break;
+
+            (*gismc)++;
+            sres = IntGetMenuDefaultItem(SubMenuObject, fByPos, gmdiFlags, gismc);
+            (*gismc)--;
 
-      break;
-    }
+            IntReleaseMenuObject(SubMenuObject);
 
-    MenuItem = MenuItem->Next;
-    x++;
-  }
+            if(sres > (UINT)-1)
+               res = sres;
+         }
 
-  return res;
+         break;
+      }
+
+      MenuItem = MenuItem->Next;
+      x++;
+   }
+
+   return res;
 }
 
 VOID FASTCALL
 co_IntInitTracking(PWINDOW_OBJECT Window, PMENU_OBJECT Menu, BOOL Popup,
-                UINT Flags)
+                   UINT Flags)
 {
-  /* FIXME - hide caret */
+   /* FIXME - hide caret */
 
-  if(!(Flags & TPM_NONOTIFY))
-    co_IntSendMessage(Window->hSelf, WM_SETCURSOR, (WPARAM)Window->hSelf, HTCAPTION);
+   if(!(Flags & TPM_NONOTIFY))
+      co_IntSendMessage(Window->hSelf, WM_SETCURSOR, (WPARAM)Window->hSelf, HTCAPTION);
 
-  /* FIXME - send WM_SETCURSOR message */
+   /* FIXME - send WM_SETCURSOR message */
 
-  if(!(Flags & TPM_NONOTIFY))
-    co_IntSendMessage(Window->hSelf, WM_INITMENU, (WPARAM)Menu->MenuInfo.Self, 0);
+   if(!(Flags & TPM_NONOTIFY))
+      co_IntSendMessage(Window->hSelf, WM_INITMENU, (WPARAM)Menu->MenuInfo.Self, 0);
 }
 
 VOID FASTCALL
 co_IntExitTracking(PWINDOW_OBJECT Window, PMENU_OBJECT Menu, BOOL Popup,
-                UINT Flags)
+                   UINT Flags)
 {
-  if(!(Flags & TPM_NONOTIFY))
-    co_IntSendMessage(Window->hSelf, WM_EXITMENULOOP, 0 /* FIXME */, 0);
+   if(!(Flags & TPM_NONOTIFY))
+      co_IntSendMessage(Window->hSelf, WM_EXITMENULOOP, 0 /* FIXME */, 0);
 
-  /* FIXME - Show caret again */
+   /* FIXME - Show caret again */
 }
 
 INT FASTCALL
 IntTrackMenu(PMENU_OBJECT Menu, PWINDOW_OBJECT Window, INT x, INT y,
              RECT lprect)
 {
-  return 0;
+   return 0;
 }
 
 BOOL FASTCALL
 co_IntTrackPopupMenu(PMENU_OBJECT Menu, PWINDOW_OBJECT Window,
-                  UINT Flags, POINT *Pos, UINT MenuPos, RECT *ExcludeRect)
+                     UINT Flags, POINT *Pos, UINT MenuPos, RECT *ExcludeRect)
 {
-  co_IntInitTracking(Window, Menu, TRUE, Flags);
+   co_IntInitTracking(Window, Menu, TRUE, Flags);
 
-  co_IntExitTracking(Window, Menu, TRUE, Flags);
-  return FALSE;
+   co_IntExitTracking(Window, Menu, TRUE, Flags);
+   return FALSE;
 }
 
 BOOL FASTCALL
 IntSetMenuItemRect(PMENU_OBJECT Menu, UINT Item, BOOL fByPos, RECT *rcRect)
 {
-  PMENU_ITEM mi;
-  if(IntGetMenuItemByFlag(Menu, Item, (fByPos ? MF_BYPOSITION : MF_BYCOMMAND),
-                          &mi, NULL) > -1)
-  {
-    mi->Rect = *rcRect;
-    return TRUE;
-  }
-  return FALSE;
+   PMENU_ITEM mi;
+   if(IntGetMenuItemByFlag(Menu, Item, (fByPos ? MF_BYPOSITION : MF_BYCOMMAND),
+                           &mi, NULL) > -1)
+   {
+      mi->Rect = *rcRect;
+      return TRUE;
+   }
+   return FALSE;
 }
 
 
@@ -1248,30 +1270,30 @@ IntSetMenuItemRect(PMENU_OBJECT Menu, UINT Item, BOOL fByPos, RECT *rcRect)
 BOOL FASTCALL
 IntCleanupMenus(struct _EPROCESS *Process, PW32PROCESS Win32Process)
 {
-  PEPROCESS CurrentProcess;
-  PLIST_ENTRY LastHead = NULL;
-  PMENU_OBJECT MenuObject;
-
-  CurrentProcess = PsGetCurrentProcess();
-  if (CurrentProcess != Process)
-  {
-    KeAttachProcess(&Process->Pcb);
-  }
-
-  while (Win32Process->MenuListHead.Flink != &(Win32Process->MenuListHead) &&
-         Win32Process->MenuListHead.Flink != LastHead)
-  {
-    LastHead = Win32Process->MenuListHead.Flink;
-    MenuObject = CONTAINING_RECORD(Win32Process->MenuListHead.Flink, MENU_OBJECT, ListEntry);
-
-    IntDestroyMenuObject(MenuObject, FALSE, TRUE);
-  }
-
-  if (CurrentProcess != Process)
-  {
-    KeDetachProcess();
-  }
-  return TRUE;
+   PEPROCESS CurrentProcess;
+   PLIST_ENTRY LastHead = NULL;
+   PMENU_OBJECT MenuObject;
+
+   CurrentProcess = PsGetCurrentProcess();
+   if (CurrentProcess != Process)
+   {
+      KeAttachProcess(&Process->Pcb);
+   }
+
+   while (Win32Process->MenuListHead.Flink != &(Win32Process->MenuListHead) &&
+          Win32Process->MenuListHead.Flink != LastHead)
+   {
+      LastHead = Win32Process->MenuListHead.Flink;
+      MenuObject = CONTAINING_RECORD(Win32Process->MenuListHead.Flink, MENU_OBJECT, ListEntry);
+
+      IntDestroyMenuObject(MenuObject, FALSE, TRUE);
+   }
+
+   if (CurrentProcess != Process)
+   {
+      KeDetachProcess();
+   }
+   return TRUE;
 }
 
 /* FUNCTIONS *****************************************************************/
@@ -1283,42 +1305,42 @@ IntCleanupMenus(struct _EPROCESS *Process, PW32PROCESS Win32Process)
 DWORD
 STDCALL
 NtUserBuildMenuItemList(
- HMENU hMenu,
- VOID* Buffer,
- ULONG nBufSize,
- DWORD Reserved)
  HMENU hMenu,
  VOID* Buffer,
  ULONG nBufSize,
  DWORD Reserved)
 {
-  DWORD res = -1;
-  PMENU_OBJECT MenuObject;
-  DECLARE_RETURN(DWORD);  
-  
-  DPRINT("Enter NtUserBuildMenuItemList\n");
-  UserEnterExclusive();
-  
-  MenuObject = IntGetMenuObject(hMenu);
-  if(!MenuObject)
-  {
-    SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
-    RETURN( (DWORD)-1);
-  }
-
-  if(Buffer)
-  {
-    res = IntBuildMenuItemList(MenuObject, Buffer, nBufSize);
-  }
-  else
-  {
-    res = MenuObject->MenuInfo.MenuItemCount;
-  }
-
-  IntReleaseMenuObject(MenuObject);
-
-  RETURN( res);
-  
+   DWORD res = -1;
+   PMENU_OBJECT MenuObject;
+   DECLARE_RETURN(DWORD);
+
+   DPRINT("Enter NtUserBuildMenuItemList\n");
+   UserEnterExclusive();
+
+   MenuObject = IntGetMenuObject(hMenu);
+   if(!MenuObject)
+   {
+      SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
+      RETURN( (DWORD)-1);
+   }
+
+   if(Buffer)
+   {
+      res = IntBuildMenuItemList(MenuObject, Buffer, nBufSize);
+   }
+   else
+   {
+      res = MenuObject->MenuInfo.MenuItemCount;
+   }
+
+   IntReleaseMenuObject(MenuObject);
+
+   RETURN( res);
+
 CLEANUP:
-  DPRINT("Leave NtUserBuildMenuItemList, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;  
+   DPRINT("Leave NtUserBuildMenuItemList, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -1327,58 +1349,58 @@ CLEANUP:
  */
 DWORD STDCALL
 NtUserCheckMenuItem(
-  HMENU hmenu,
-  UINT uIDCheckItem,
-  UINT uCheck)
+   HMENU hmenu,
+   UINT uIDCheckItem,
+   UINT uCheck)
 {
-  DWORD res = 0;
-  PMENU_OBJECT MenuObject;
-  DECLARE_RETURN(DWORD); 
-  
-  DPRINT("Enter NtUserCheckMenuItem\n");
-  UserEnterExclusive();
-  
-  MenuObject = IntGetMenuObject(hmenu);
-  if(!MenuObject)
-  {
-    SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
-    RETURN( (DWORD)-1);
-  }
-
-  res = IntCheckMenuItem(MenuObject, uIDCheckItem, uCheck);
-
-  IntReleaseMenuObject(MenuObject);
-  RETURN( res);
-  
+   DWORD res = 0;
+   PMENU_OBJECT MenuObject;
+   DECLARE_RETURN(DWORD);
+
+   DPRINT("Enter NtUserCheckMenuItem\n");
+   UserEnterExclusive();
+
+   MenuObject = IntGetMenuObject(hmenu);
+   if(!MenuObject)
+   {
+      SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
+      RETURN( (DWORD)-1);
+   }
+
+   res = IntCheckMenuItem(MenuObject, uIDCheckItem, uCheck);
+
+   IntReleaseMenuObject(MenuObject);
+   RETURN( res);
+
 CLEANUP:
-  DPRINT("Leave NtUserCheckMenuItem, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;  
+   DPRINT("Leave NtUserCheckMenuItem, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
 HMENU FASTCALL UserCreateMenu(BOOL PopupMenu)
 {
-  PWINSTATION_OBJECT WinStaObject;
-  HANDLE Handle;
-
-  NTSTATUS Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
-                                      KernelMode,
-                                      0,
-                                      &WinStaObject);
-
-  if (!NT_SUCCESS(Status))
-  {
-    DPRINT("Validation of window station handle (0x%X) failed\n",
-      PsGetCurrentProcess()->Win32WindowStation);
-    SetLastNtError(Status);
-    return (HMENU)0;
-  }
-
-  IntCreateMenu(&Handle, !PopupMenu);
-
-  ObDereferenceObject(WinStaObject);
-  return (HMENU)Handle;
+   PWINSTATION_OBJECT WinStaObject;
+   HANDLE Handle;
+
+   NTSTATUS Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
+                     KernelMode,
+                     0,
+                     &WinStaObject);
+
+   if (!NT_SUCCESS(Status))
+   {
+      DPRINT("Validation of window station handle (0x%X) failed\n",
+             PsGetCurrentProcess()->Win32WindowStation);
+      SetLastNtError(Status);
+      return (HMENU)0;
+   }
+
+   IntCreateMenu(&Handle, !PopupMenu);
+
+   ObDereferenceObject(WinStaObject);
+   return (HMENU)Handle;
 }
 
 
@@ -1386,17 +1408,17 @@ HMENU FASTCALL UserCreateMenu(BOOL PopupMenu)
 HMENU STDCALL
 NtUserCreateMenu(BOOL PopupMenu)
 {
-  DECLARE_RETURN(HMENU);  
-  
-  DPRINT("Enter NtUserCreateMenu\n");
-  UserEnterExclusive();
-  
-  RETURN(UserCreateMenu(PopupMenu));
-   
+   DECLARE_RETURN(HMENU);
+
+   DPRINT("Enter NtUserCreateMenu\n");
+   UserEnterExclusive();
+
+   RETURN(UserCreateMenu(PopupMenu));
+
 CLEANUP:
-  DPRINT("Leave NtUserCreateMenu, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserCreateMenu, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -1406,33 +1428,33 @@ CLEANUP:
  */
 BOOL STDCALL
 NtUserDeleteMenu(
-  HMENU hMenu,
-  UINT uPosition,
-  UINT uFlags)
+   HMENU hMenu,
+   UINT uPosition,
+   UINT uFlags)
 {
-  BOOL res;
-  PMENU_OBJECT MenuObject;
-  DECLARE_RETURN(BOOL);  
-
-  DPRINT("Enter NtUserDeleteMenu\n");
-  UserEnterExclusive();
-  
-  MenuObject = IntGetMenuObject(hMenu);
-  if(!MenuObject)
-  {
-    SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
-    RETURN( FALSE);
-  }
-
-  res = IntRemoveMenuItem(MenuObject, uPosition, uFlags, TRUE);
-  IntReleaseMenuObject(MenuObject);
-
-  RETURN( res);
-  
+   BOOL res;
+   PMENU_OBJECT MenuObject;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserDeleteMenu\n");
+   UserEnterExclusive();
+
+   MenuObject = IntGetMenuObject(hMenu);
+   if(!MenuObject)
+   {
+      SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
+      RETURN( FALSE);
+   }
+
+   res = IntRemoveMenuItem(MenuObject, uPosition, uFlags, TRUE);
+   IntReleaseMenuObject(MenuObject);
+
+   RETURN( res);
+
 CLEANUP:
-  DPRINT("Leave NtUserDeleteMenu, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserDeleteMenu, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -1442,25 +1464,25 @@ CLEANUP:
  */
 BOOL FASTCALL UserDestroyMenu(HMENU hMenu)
 {
-  BOOL Ret;
-
-  PMENU_OBJECT MenuObject = IntGetMenuObject(hMenu);
-  if(!MenuObject)
-  {
-    SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
-    return FALSE;
-  }
-  if(MenuObject->Process != PsGetCurrentProcess())
-  {
-    IntReleaseMenuObject(MenuObject);
-    SetLastWin32Error(ERROR_ACCESS_DENIED);
-    return FALSE;
-  }
-
-  Ret = IntDestroyMenuObject(MenuObject, FALSE, TRUE);
-
-  IntReleaseMenuObject(MenuObject);
-  return Ret;
+   BOOL Ret;
+
+   PMENU_OBJECT MenuObject = IntGetMenuObject(hMenu);
+   if(!MenuObject)
+   {
+      SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
+      return FALSE;
+   }
+   if(MenuObject->Process != PsGetCurrentProcess())
+   {
+      IntReleaseMenuObject(MenuObject);
+      SetLastWin32Error(ERROR_ACCESS_DENIED);
+      return FALSE;
+   }
+
+   Ret = IntDestroyMenuObject(MenuObject, FALSE, TRUE);
+
+   IntReleaseMenuObject(MenuObject);
+   return Ret;
 }
 
 /*
@@ -1468,36 +1490,36 @@ BOOL FASTCALL UserDestroyMenu(HMENU hMenu)
  */
 BOOL STDCALL
 NtUserDestroyMenu(
-  HMENU hMenu)
+   HMENU hMenu)
 {
-  BOOL Ret;
-  DECLARE_RETURN(BOOL);  
-
-  DPRINT("Enter NtUserDestroyMenu\n");
-  UserEnterExclusive();
-
-  PMENU_OBJECT MenuObject = IntGetMenuObject(hMenu);
-  if(!MenuObject)
-  {
-    SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
-    RETURN( FALSE);
-  }
-  if(MenuObject->Process != PsGetCurrentProcess())
-  {
-    IntReleaseMenuObject(MenuObject);
-    SetLastWin32Error(ERROR_ACCESS_DENIED);
-    RETURN( FALSE);
-  }
-
-  Ret = IntDestroyMenuObject(MenuObject, FALSE, TRUE);
-
-  IntReleaseMenuObject(MenuObject);
-  RETURN( Ret);
-  
+   BOOL Ret;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserDestroyMenu\n");
+   UserEnterExclusive();
+
+   PMENU_OBJECT MenuObject = IntGetMenuObject(hMenu);
+   if(!MenuObject)
+   {
+      SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
+      RETURN( FALSE);
+   }
+   if(MenuObject->Process != PsGetCurrentProcess())
+   {
+      IntReleaseMenuObject(MenuObject);
+      SetLastWin32Error(ERROR_ACCESS_DENIED);
+      RETURN( FALSE);
+   }
+
+   Ret = IntDestroyMenuObject(MenuObject, FALSE, TRUE);
+
+   IntReleaseMenuObject(MenuObject);
+   RETURN( Ret);
+
 CLEANUP:
-  DPRINT("Leave NtUserDestroyMenu, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserDestroyMenu, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -1506,34 +1528,34 @@ CLEANUP:
  */
 UINT STDCALL
 NtUserEnableMenuItem(
-  HMENU hMenu,
-  UINT uIDEnableItem,
-  UINT uEnable)
+   HMENU hMenu,
+   UINT uIDEnableItem,
+   UINT uEnable)
 {
-  UINT res = (UINT)-1;
-  PMENU_OBJECT MenuObject;
-  DECLARE_RETURN(UINT);  
-
-  DPRINT("Enter NtUserEnableMenuItem\n");
-  UserEnterExclusive();
-  
-  MenuObject = IntGetMenuObject(hMenu);
-  if(!MenuObject)
-  {
-    SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
-    RETURN( res);
-  }
-
-  res = IntEnableMenuItem(MenuObject, uIDEnableItem, uEnable);
-
-  IntReleaseMenuObject(MenuObject);
-
-  RETURN( res);
-  
+   UINT res = (UINT)-1;
+   PMENU_OBJECT MenuObject;
+   DECLARE_RETURN(UINT);
+
+   DPRINT("Enter NtUserEnableMenuItem\n");
+   UserEnterExclusive();
+
+   MenuObject = IntGetMenuObject(hMenu);
+   if(!MenuObject)
+   {
+      SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
+      RETURN( res);
+   }
+
+   res = IntEnableMenuItem(MenuObject, uIDEnableItem, uEnable);
+
+   IntReleaseMenuObject(MenuObject);
+
+   RETURN( res);
+
 CLEANUP:
-  DPRINT("Leave NtUserEnableMenuItem, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserEnableMenuItem, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -1542,51 +1564,51 @@ CLEANUP:
  */
 DWORD STDCALL
 NtUserInsertMenuItem(
-  HMENU hMenu,
-  UINT uItem,
-  BOOL fByPosition,
-  LPCMENUITEMINFOW UnsafeItemInfo)
+   HMENU hMenu,
+   UINT uItem,
+   BOOL fByPosition,
+   LPCMENUITEMINFOW UnsafeItemInfo)
 {
-  DWORD Res = 0;
-  PMENU_OBJECT MenuObject;
-  NTSTATUS Status;
-  ROSMENUITEMINFO ItemInfo;
-  DECLARE_RETURN(DWORD);  
-
-  DPRINT("Enter NtUserInsertMenuItem\n");
-  UserEnterExclusive();
-
-  MenuObject = IntGetMenuObject(hMenu);
-  if(!MenuObject)
-    {
+   DWORD Res = 0;
+   PMENU_OBJECT MenuObject;
+   NTSTATUS Status;
+   ROSMENUITEMINFO ItemInfo;
+   DECLARE_RETURN(DWORD);
+
+   DPRINT("Enter NtUserInsertMenuItem\n");
+   UserEnterExclusive();
+
+   MenuObject = IntGetMenuObject(hMenu);
+   if(!MenuObject)
+   {
       SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
       RETURN( 0);
-    }
+   }
 
-  Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, sizeof(MENUITEMINFOW));
-  if (! NT_SUCCESS(Status))
-    {
+   Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, sizeof(MENUITEMINFOW));
+   if (! NT_SUCCESS(Status))
+   {
       IntReleaseMenuObject(MenuObject);
       SetLastNtError(Status);
       RETURN( FALSE);
-    }
-  if (ItemInfo.cbSize != sizeof(MENUITEMINFOW))
-    {
+   }
+   if (ItemInfo.cbSize != sizeof(MENUITEMINFOW))
+   {
       IntReleaseMenuObject(MenuObject);
       SetLastWin32Error(ERROR_INVALID_PARAMETER);
       RETURN( FALSE);
-    }
+   }
 
-  Res = IntInsertMenuItem(MenuObject, uItem, fByPosition, &ItemInfo);
+   Res = IntInsertMenuItem(MenuObject, uItem, fByPosition, &ItemInfo);
 
-  IntReleaseMenuObject(MenuObject);
+   IntReleaseMenuObject(MenuObject);
+
+   RETURN( Res);
 
-  RETURN( Res);
-  
 CLEANUP:
-  DPRINT("Leave NtUserInsertMenuItem, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserInsertMenuItem, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -1596,9 +1618,9 @@ CLEANUP:
 BOOL STDCALL
 NtUserEndMenu(VOID)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
@@ -1607,28 +1629,28 @@ NtUserEndMenu(VOID)
  */
 UINT STDCALL
 NtUserGetMenuDefaultItem(
-  HMENU hMenu,
-  UINT fByPos,
-  UINT gmdiFlags)
+   HMENU hMenu,
+   UINT fByPos,
+   UINT gmdiFlags)
 {
-  PMENU_OBJECT Menu;
-  DWORD gismc = 0;
-  DECLARE_RETURN(UINT);  
+   PMENU_OBJECT Menu;
+   DWORD gismc = 0;
+   DECLARE_RETURN(UINT);
 
-  DPRINT("Enter NtUserGetMenuDefaultItem\n");
-  UserEnterExclusive();
+   DPRINT("Enter NtUserGetMenuDefaultItem\n");
+   UserEnterExclusive();
+
+   if(!(Menu = UserGetMenuObject(hMenu)))
+   {
+      RETURN(-1);
+   }
 
-  if(!(Menu = UserGetMenuObject(hMenu)))
-  {
-    RETURN(-1);
-  }
+   RETURN( IntGetMenuDefaultItem(Menu, fByPos, gmdiFlags, &gismc));
 
-  RETURN( IntGetMenuDefaultItem(Menu, fByPos, gmdiFlags, &gismc));
-  
 CLEANUP:
-  DPRINT("Leave NtUserGetMenuDefaultItem, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetMenuDefaultItem, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -1637,14 +1659,14 @@ CLEANUP:
  */
 BOOL STDCALL
 NtUserGetMenuBarInfo(
-  HWND hwnd,
-  LONG idObject,
-  LONG idItem,
-  PMENUBARINFO pmbi)
+   HWND hwnd,
+   LONG idObject,
+   LONG idItem,
+   PMENUBARINFO pmbi)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
@@ -1653,12 +1675,12 @@ NtUserGetMenuBarInfo(
  */
 UINT STDCALL
 NtUserGetMenuIndex(
-  HMENU hMenu,
-  UINT wID)
+   HMENU hMenu,
+   UINT wID)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
@@ -1667,75 +1689,78 @@ NtUserGetMenuIndex(
  */
 BOOL STDCALL
 NtUserGetMenuItemRect(
-  HWND hWnd,
-  HMENU hMenu,
-  UINT uItem,
-  LPRECT lprcItem)
+   HWND hWnd,
+   HMENU hMenu,
+   UINT uItem,
+   LPRECT lprcItem)
 {
-     ROSMENUINFO mi;
-     ROSMENUITEMINFO mii;
-     HWND referenceHwnd;
-     LPPOINT lpPoints;
-     LPRECT lpRect = NULL;
-     POINT FromOffset;
-     LONG XMove, YMove;
-     ULONG i;
-     NTSTATUS Status;
-     PMENU_OBJECT Menu;
-     PWINDOW_OBJECT ReferenceWnd;
-     DECLARE_RETURN(BOOL);  
-
-     DPRINT("Enter NtUserGetMenuItemRect\n");
-     UserEnterShared();
+   ROSMENUINFO mi;
+   ROSMENUITEMINFO mii;
+   HWND referenceHwnd;
+   LPPOINT lpPoints;
+   LPRECT lpRect = NULL;
+   POINT FromOffset;
+   LONG XMove, YMove;
+   ULONG i;
+   NTSTATUS Status;
+   PMENU_OBJECT Menu;
+   PWINDOW_OBJECT ReferenceWnd;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserGetMenuItemRect\n");
+   UserEnterShared();
 
    if (!(Menu = UserGetMenuObject(hMenu)))
    {
       RETURN(FALSE);
    }
-          
-     if(!UserMenuItemInfo(Menu, uItem, MF_BYPOSITION, &mii, FALSE))
+
+   if(!UserMenuItemInfo(Menu, uItem, MF_BYPOSITION, &mii, FALSE))
       RETURN( FALSE);
-       
-     referenceHwnd = hWnd;
-
-     if(!hWnd)
-     {
-   if(!UserMenuInfo(Menu, &mi, FALSE)) RETURN( FALSE);
-    if(mi.Wnd == 0) RETURN( FALSE);
-        referenceHwnd = mi.Wnd;
-     }
-
-     if (lprcItem == NULL) RETURN( FALSE);
-     *lpRect = mii.Rect;
-     lpPoints = (LPPOINT)lpRect;
-      
-    ReferenceWnd = UserGetWindowObject(referenceHwnd);
-    if (!ReferenceWnd || !UserGetClientOrigin(ReferenceWnd, &FromOffset))
-    {
-       RETURN( FALSE);
-    }
-
-    XMove = FromOffset.x;
-    YMove = FromOffset.y;
-
-    for (i = 0; i < 2; i++)
-      {
-        lpPoints[i].x += XMove;
-        lpPoints[i].y += YMove;
-      }
-      
-    Status = MmCopyToCaller(lprcItem, lpPoints, sizeof(POINT));
-    if (! NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        RETURN( FALSE);
-      }                                                              
-    RETURN( TRUE);
-    
+
+   referenceHwnd = hWnd;
+
+   if(!hWnd)
+   {
+      if(!UserMenuInfo(Menu, &mi, FALSE))
+         RETURN( FALSE);
+      if(mi.Wnd == 0)
+         RETURN( FALSE);
+      referenceHwnd = mi.Wnd;
+   }
+
+   if (lprcItem == NULL)
+      RETURN( FALSE);
+   *lpRect = mii.Rect;
+   lpPoints = (LPPOINT)lpRect;
+
+   ReferenceWnd = UserGetWindowObject(referenceHwnd);
+   if (!ReferenceWnd || !UserGetClientOrigin(ReferenceWnd, &FromOffset))
+   {
+      RETURN( FALSE);
+   }
+
+   XMove = FromOffset.x;
+   YMove = FromOffset.y;
+
+   for (i = 0; i < 2; i++)
+   {
+      lpPoints[i].x += XMove;
+      lpPoints[i].y += YMove;
+   }
+
+   Status = MmCopyToCaller(lprcItem, lpPoints, sizeof(POINT));
+   if (! NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      RETURN( FALSE);
+   }
+   RETURN( TRUE);
+
 CLEANUP:
-  DPRINT("Leave NtUserGetMenuItemRect, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetMenuItemRect, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -1744,98 +1769,98 @@ CLEANUP:
  */
 BOOL STDCALL
 NtUserHiliteMenuItem(
-  HWND hwnd,
-  HMENU hmenu,
-  UINT uItemHilite,
-  UINT uHilite)
+   HWND hwnd,
+   HMENU hmenu,
+   UINT uItemHilite,
+   UINT uHilite)
 {
-  BOOL res = FALSE;
-  PMENU_OBJECT MenuObject;
-  PWINDOW_OBJECT WindowObject;
-  DECLARE_RETURN(BOOLEAN);  
-
-  DPRINT("Enter NtUserHiliteMenuItem\n");
-  UserEnterExclusive();
-  
-  WindowObject = IntGetWindowObject(hwnd);
-  if(!WindowObject)
-  {
-    SetLastWin32Error(ERROR_INVALID_HANDLE);
-    RETURN( res);
-  }
-  MenuObject = IntGetMenuObject(hmenu);
-  if(!MenuObject)
-  {
-    IntReleaseWindowObject(WindowObject);
-    SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
-    RETURN( res);
-  }
-  if(WindowObject->IDMenu == (UINT)hmenu)
-  {
-    res = IntHiliteMenuItem(WindowObject, MenuObject, uItemHilite, uHilite);
-  }
-  IntReleaseMenuObject(MenuObject);
-  IntReleaseWindowObject(WindowObject);
-  RETURN( res);
-  
+   BOOL res = FALSE;
+   PMENU_OBJECT MenuObject;
+   PWINDOW_OBJECT WindowObject;
+   DECLARE_RETURN(BOOLEAN);
+
+   DPRINT("Enter NtUserHiliteMenuItem\n");
+   UserEnterExclusive();
+
+   WindowObject = IntGetWindowObject(hwnd);
+   if(!WindowObject)
+   {
+      SetLastWin32Error(ERROR_INVALID_HANDLE);
+      RETURN( res);
+   }
+   MenuObject = IntGetMenuObject(hmenu);
+   if(!MenuObject)
+   {
+      IntReleaseWindowObject(WindowObject);
+      SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
+      RETURN( res);
+   }
+   if(WindowObject->IDMenu == (UINT)hmenu)
+   {
+      res = IntHiliteMenuItem(WindowObject, MenuObject, uItemHilite, uHilite);
+   }
+   IntReleaseMenuObject(MenuObject);
+   IntReleaseWindowObject(WindowObject);
+   RETURN( res);
+
 CLEANUP:
-  DPRINT("Leave NtUserHiliteMenuItem, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserHiliteMenuItem, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
 static
 BOOL FASTCALL
 UserMenuInfo(
- PMENU_OBJECT Menu,
- PROSMENUINFO UnsafeMenuInfo,
- BOOL SetOrGet)
  PMENU_OBJECT Menu,
  PROSMENUINFO UnsafeMenuInfo,
  BOOL SetOrGet)
 {
-  BOOL Res;
-  DWORD Size;
-  NTSTATUS Status;
-  ROSMENUINFO MenuInfo;
-
-  Status = MmCopyFromCaller(&Size, &UnsafeMenuInfo->cbSize, sizeof(DWORD));
-  if (! NT_SUCCESS(Status))
-    {
+   BOOL Res;
+   DWORD Size;
+   NTSTATUS Status;
+   ROSMENUINFO MenuInfo;
+
+   Status = MmCopyFromCaller(&Size, &UnsafeMenuInfo->cbSize, sizeof(DWORD));
+   if (! NT_SUCCESS(Status))
+   {
       SetLastNtError(Status);
       return( FALSE);
-    }
-  if(Size < sizeof(MENUINFO) || sizeof(ROSMENUINFO) < Size)
-    {
+   }
+   if(Size < sizeof(MENUINFO) || sizeof(ROSMENUINFO) < Size)
+   {
       SetLastWin32Error(ERROR_INVALID_PARAMETER);
       return( FALSE);
-    }
-  Status = MmCopyFromCaller(&MenuInfo, UnsafeMenuInfo, Size);
-  if (! NT_SUCCESS(Status))
-    {
+   }
+   Status = MmCopyFromCaller(&MenuInfo, UnsafeMenuInfo, Size);
+   if (! NT_SUCCESS(Status))
+   {
       SetLastNtError(Status);
       return( FALSE);
-    }
+   }
 
-  if(SetOrGet)
-    {
+   if(SetOrGet)
+   {
       /* Set MenuInfo */
       Res = IntSetMenuInfo(Menu, &MenuInfo);
-    }
-  else
-    {
+   }
+   else
+   {
       /* Get MenuInfo */
       Res = IntGetMenuInfo(Menu, &MenuInfo);
       if (Res)
-        {
-          Status = MmCopyToCaller(UnsafeMenuInfo, &MenuInfo, Size);
-          if (! NT_SUCCESS(Status))
-            {
-              SetLastNtError(Status);
-              return( FALSE);
-            }
-        }
-    }
+      {
+         Status = MmCopyToCaller(UnsafeMenuInfo, &MenuInfo, Size);
+         if (! NT_SUCCESS(Status))
+         {
+            SetLastNtError(Status);
+            return( FALSE);
+         }
+      }
+   }
 
-  return( Res);
+   return( Res);
 }
 
 
@@ -1848,27 +1873,27 @@ UserMenuInfo(
 BOOL
 STDCALL
 NtUserMenuInfo(
- HMENU hMenu,
- PROSMENUINFO UnsafeMenuInfo,
- BOOL SetOrGet)
  HMENU hMenu,
  PROSMENUINFO UnsafeMenuInfo,
  BOOL SetOrGet)
 {
-  PMENU_OBJECT Menu; 
-  DECLARE_RETURN(BOOL);  
+   PMENU_OBJECT Menu;
+   DECLARE_RETURN(BOOL);
 
-  DPRINT("Enter NtUserMenuInfo\n");
-  UserEnterShared();
+   DPRINT("Enter NtUserMenuInfo\n");
+   UserEnterShared();
 
-  if (!(Menu = UserGetMenuObject(hMenu)))
-  {
-     RETURN(FALSE);
-  }
+   if (!(Menu = UserGetMenuObject(hMenu)))
+   {
+      RETURN(FALSE);
+   }
+
+   RETURN(UserMenuInfo(Menu, UnsafeMenuInfo, SetOrGet));
 
-  RETURN(UserMenuInfo(Menu, UnsafeMenuInfo, SetOrGet));
-  
 CLEANUP:
-  DPRINT("Leave NtUserMenuInfo, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserMenuInfo, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -1878,49 +1903,49 @@ CLEANUP:
  */
 int STDCALL
 NtUserMenuItemFromPoint(
-  HWND hWnd,
-  HMENU hMenu,
-  DWORD X,
-  DWORD Y)
+   HWND hWnd,
+   HMENU hMenu,
+   DWORD X,
+   DWORD Y)
 {
-  PMENU_OBJECT Menu;
-  PWINDOW_OBJECT Window = NULL;
-  PMENU_ITEM mi;
-  int i;
-  DECLARE_RETURN(int);  
+   PMENU_OBJECT Menu;
+   PWINDOW_OBJECT Window = NULL;
+   PMENU_ITEM mi;
+   int i;
+   DECLARE_RETURN(int);
 
-  DPRINT("Enter NtUserMenuItemFromPoint\n");
-  UserEnterExclusive();
+   DPRINT("Enter NtUserMenuItemFromPoint\n");
+   UserEnterExclusive();
 
-  if (!(Menu = UserGetMenuObject(hMenu)))
-    {
+   if (!(Menu = UserGetMenuObject(hMenu)))
+   {
       RETURN( -1);
-    }
+   }
 
-  if (!(Window = UserGetWindowObject(Menu->MenuInfo.Wnd)))
-    {
+   if (!(Window = UserGetWindowObject(Menu->MenuInfo.Wnd)))
+   {
       RETURN( -1);
-    }
-    
-  X -= Window->WindowRect.left;
-  Y -= Window->WindowRect.top;
-
-  mi = Menu->MenuItemList;
-  for (i = 0; NULL != mi; i++)
-    {
+   }
+
+   X -= Window->WindowRect.left;
+   Y -= Window->WindowRect.top;
+
+   mi = Menu->MenuItemList;
+   for (i = 0; NULL != mi; i++)
+   {
       if (InRect(mi->Rect, X, Y))
-        {
-          break;
-        }
+      {
+         break;
+      }
       mi = mi->Next;
-    }
+   }
+
+   RETURN( (mi ? i : NO_SELECTED_ITEM));
 
-  RETURN( (mi ? i : NO_SELECTED_ITEM));
-  
 CLEANUP:
-  DPRINT("Leave NtUserMenuItemFromPoint, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserMenuItemFromPoint, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -1928,73 +1953,73 @@ CLEANUP:
 static
 BOOL FASTCALL
 UserMenuItemInfo(
- PMENU_OBJECT Menu,
- UINT Item,
- BOOL ByPosition,
- PROSMENUITEMINFO UnsafeItemInfo,
- BOOL SetOrGet)
  PMENU_OBJECT Menu,
  UINT Item,
  BOOL ByPosition,
  PROSMENUITEMINFO UnsafeItemInfo,
  BOOL SetOrGet)
 {
-  PMENU_ITEM MenuItem;
-  ROSMENUITEMINFO ItemInfo;
-  NTSTATUS Status;
-  UINT Size;
-  BOOL Ret;
-
-  Status = MmCopyFromCaller(&Size, &UnsafeItemInfo->cbSize, sizeof(UINT));
-  if (! NT_SUCCESS(Status))
-    {
+   PMENU_ITEM MenuItem;
+   ROSMENUITEMINFO ItemInfo;
+   NTSTATUS Status;
+   UINT Size;
+   BOOL Ret;
+
+   Status = MmCopyFromCaller(&Size, &UnsafeItemInfo->cbSize, sizeof(UINT));
+   if (! NT_SUCCESS(Status))
+   {
       SetLastNtError(Status);
       return( FALSE);
-    }
-  if (sizeof(MENUITEMINFOW) != Size
-      && sizeof(MENUITEMINFOW) - sizeof(HBITMAP) != Size
-      && sizeof(ROSMENUITEMINFO) != Size)
-    {
+   }
+   if (sizeof(MENUITEMINFOW) != Size
+         && sizeof(MENUITEMINFOW) - sizeof(HBITMAP) != Size
+         && sizeof(ROSMENUITEMINFO) != Size)
+   {
       SetLastWin32Error(ERROR_INVALID_PARAMETER);
       return( FALSE);
-    }
-  Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, Size);
-  if (! NT_SUCCESS(Status))
-    {
+   }
+   Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, Size);
+   if (! NT_SUCCESS(Status))
+   {
       SetLastNtError(Status);
       return( FALSE);
-    }
-  /* If this is a pre-0x0500 _WIN32_WINNT MENUITEMINFOW, you can't
-     set/get hbmpItem */
-  if (sizeof(MENUITEMINFOW) - sizeof(HBITMAP) == Size
-      && 0 != (ItemInfo.fMask & MIIM_BITMAP))
-    {
+   }
+   /* If this is a pre-0x0500 _WIN32_WINNT MENUITEMINFOW, you can't
+      set/get hbmpItem */
+   if (sizeof(MENUITEMINFOW) - sizeof(HBITMAP) == Size
+         && 0 != (ItemInfo.fMask & MIIM_BITMAP))
+   {
       SetLastWin32Error(ERROR_INVALID_PARAMETER);
       return( FALSE);
-    }
+   }
 
-  if (IntGetMenuItemByFlag(Menu, Item,
-                           (ByPosition ? MF_BYPOSITION : MF_BYCOMMAND),
-                           &MenuItem, NULL) < 0)
-    {
+   if (IntGetMenuItemByFlag(Menu, Item,
+                            (ByPosition ? MF_BYPOSITION : MF_BYCOMMAND),
+                            &MenuItem, NULL) < 0)
+   {
       SetLastWin32Error(ERROR_INVALID_PARAMETER);
       return( FALSE);
-    }
+   }
 
-  if (SetOrGet)
-    {
+   if (SetOrGet)
+   {
       Ret = IntSetMenuItemInfo(Menu, MenuItem, &ItemInfo);
-    }
-  else
-    {
+   }
+   else
+   {
       Ret = IntGetMenuItemInfo(Menu, MenuItem, &ItemInfo);
       if (Ret)
-        {
-          Status = MmCopyToCaller(UnsafeItemInfo, &ItemInfo, Size);
-          if (! NT_SUCCESS(Status))
-            {
-              SetLastNtError(Status);
-              return( FALSE);
-            }
-        }
-    }
+      {
+         Status = MmCopyToCaller(UnsafeItemInfo, &ItemInfo, Size);
+         if (! NT_SUCCESS(Status))
+         {
+            SetLastNtError(Status);
+            return( FALSE);
+         }
+      }
+   }
 
-  return( Ret);
+   return( Ret);
 }
 
 
@@ -2005,30 +2030,30 @@ UserMenuItemInfo(
 BOOL
 STDCALL
 NtUserMenuItemInfo(
- HMENU hMenu,
- UINT Item,
- BOOL ByPosition,
- PROSMENUITEMINFO UnsafeItemInfo,
- BOOL SetOrGet)
  HMENU hMenu,
  UINT Item,
  BOOL ByPosition,
  PROSMENUITEMINFO UnsafeItemInfo,
  BOOL SetOrGet)
 {
-  PMENU_OBJECT Menu;
-  DECLARE_RETURN(BOOL);  
-
-  DPRINT("Enter NtUserMenuItemInfo\n");
-  UserEnterExclusive();
-  
-  if (!(Menu = UserGetMenuObject(hMenu)))
-  {
-     RETURN(FALSE);
-  }
-
-  RETURN( UserMenuItemInfo(Menu, Item, ByPosition, UnsafeItemInfo, SetOrGet));
-  
+   PMENU_OBJECT Menu;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserMenuItemInfo\n");
+   UserEnterExclusive();
+
+   if (!(Menu = UserGetMenuObject(hMenu)))
+   {
+      RETURN(FALSE);
+   }
+
+   RETURN( UserMenuItemInfo(Menu, Item, ByPosition, UnsafeItemInfo, SetOrGet));
+
 CLEANUP:
-  DPRINT("Leave NtUserMenuItemInfo, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
-  
+   DPRINT("Leave NtUserMenuItemInfo, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
+
 }
 
 
@@ -2037,28 +2062,28 @@ CLEANUP:
  */
 BOOL STDCALL
 NtUserRemoveMenu(
-  HMENU hMenu,
-  UINT uPosition,
-  UINT uFlags)
+   HMENU hMenu,
+   UINT uPosition,
+   UINT uFlags)
 {
-  PMENU_OBJECT Menu;
-  DECLARE_RETURN(BOOL);  
-
-  DPRINT("Enter NtUserRemoveMenu\n");
-  UserEnterExclusive();
-  
-  if(!(Menu = UserGetMenuObject(hMenu)))
-  {
-    RETURN( FALSE);
-  }
-
-  RETURN(IntRemoveMenuItem(Menu, uPosition, uFlags, FALSE));
-  
+   PMENU_OBJECT Menu;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserRemoveMenu\n");
+   UserEnterExclusive();
+
+   if(!(Menu = UserGetMenuObject(hMenu)))
+   {
+      RETURN( FALSE);
+   }
+
+   RETURN(IntRemoveMenuItem(Menu, uPosition, uFlags, FALSE));
+
 CLEANUP:
-  DPRINT("Leave NtUserRemoveMenu, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
-  
+   DPRINT("Leave NtUserRemoveMenu, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
+
 }
 
 
@@ -2067,26 +2092,26 @@ CLEANUP:
  */
 BOOL STDCALL
 NtUserSetMenuContextHelpId(
-  HMENU hMenu,
-  DWORD dwContextHelpId)
+   HMENU hMenu,
+   DWORD dwContextHelpId)
 {
-  PMENU_OBJECT Menu;
-  DECLARE_RETURN(BOOL);  
-
-  DPRINT("Enter NtUserSetMenuContextHelpId\n");
-  UserEnterExclusive();
-  
-  if(!(Menu = UserGetMenuObject(hMenu)))
-  {
-    RETURN( FALSE);
-  }
-
-  RETURN(IntSetMenuContextHelpId(Menu, dwContextHelpId));
-  
+   PMENU_OBJECT Menu;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserSetMenuContextHelpId\n");
+   UserEnterExclusive();
+
+   if(!(Menu = UserGetMenuObject(hMenu)))
+   {
+      RETURN( FALSE);
+   }
+
+   RETURN(IntSetMenuContextHelpId(Menu, dwContextHelpId));
+
 CLEANUP:
-  DPRINT("Leave NtUserSetMenuContextHelpId, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserSetMenuContextHelpId, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -2096,27 +2121,27 @@ CLEANUP:
  */
 BOOL STDCALL
 NtUserSetMenuDefaultItem(
-  HMENU hMenu,
-  UINT uItem,
-  UINT fByPos)
+   HMENU hMenu,
+   UINT uItem,
+   UINT fByPos)
 {
-  PMENU_OBJECT Menu;
-  DECLARE_RETURN(BOOL);  
+   PMENU_OBJECT Menu;
+   DECLARE_RETURN(BOOL);
 
-  DPRINT("Enter NtUserSetMenuDefaultItem\n");
-  UserEnterExclusive();
+   DPRINT("Enter NtUserSetMenuDefaultItem\n");
+   UserEnterExclusive();
+
+   if(!(Menu = UserGetMenuObject(hMenu)))
+   {
+      RETURN( FALSE);
+   }
 
-  if(!(Menu = UserGetMenuObject(hMenu)))
-  {
-    RETURN( FALSE);
-  }
+   RETURN( UserSetMenuDefaultItem(Menu, uItem, fByPos));
 
-  RETURN( UserSetMenuDefaultItem(Menu, uItem, fByPos));
-  
 CLEANUP:
-  DPRINT("Leave NtUserSetMenuDefaultItem, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserSetMenuDefaultItem, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -2125,25 +2150,25 @@ CLEANUP:
  */
 BOOL STDCALL
 NtUserSetMenuFlagRtoL(
-  HMENU hMenu)
+   HMENU hMenu)
 {
-  PMENU_OBJECT Menu;
-  DECLARE_RETURN(BOOL);  
+   PMENU_OBJECT Menu;
+   DECLARE_RETURN(BOOL);
 
-  DPRINT("Enter NtUserSetMenuFlagRtoL\n");
-  UserEnterExclusive();
-  
-  if(!(Menu = UserGetMenuObject(hMenu)))
-  {
-    RETURN( FALSE);
-  }
+   DPRINT("Enter NtUserSetMenuFlagRtoL\n");
+   UserEnterExclusive();
 
-  RETURN(IntSetMenuFlagRtoL(Menu));
+   if(!(Menu = UserGetMenuObject(hMenu)))
+   {
+      RETURN( FALSE);
+   }
+
+   RETURN(IntSetMenuFlagRtoL(Menu));
 
 CLEANUP:
-  DPRINT("Leave NtUserSetMenuFlagRtoL, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserSetMenuFlagRtoL, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -2152,12 +2177,12 @@ CLEANUP:
  */
 DWORD STDCALL
 NtUserThunkedMenuInfo(
-  HMENU hMenu,
-  LPCMENUINFO lpcmi)
+   HMENU hMenu,
+   LPCMENUINFO lpcmi)
 {
-  UNIMPLEMENTED
-  /* This function seems just to call SetMenuInfo() */
-  return 0;
+   UNIMPLEMENTED
+   /* This function seems just to call SetMenuInfo() */
+   return 0;
 }
 
 
@@ -2166,36 +2191,36 @@ NtUserThunkedMenuInfo(
  */
 DWORD STDCALL
 NtUserThunkedMenuItemInfo(
-  HMENU hMenu,
-  UINT uItem,
-  BOOL fByPosition,
-  BOOL bInsert,
-  LPMENUITEMINFOW lpmii,
-  PUNICODE_STRING lpszCaption)
+   HMENU hMenu,
+   UINT uItem,
+   BOOL fByPosition,
+   BOOL bInsert,
+   LPMENUITEMINFOW lpmii,
+   PUNICODE_STRING lpszCaption)
 {
-  UNIMPLEMENTED
-  /* lpszCaption may be NULL, check for it and call RtlInitUnicodeString()
-     if bInsert == TRUE call NtUserInsertMenuItem() else NtUserSetMenuItemInfo()
-  */
-  return 0;
+   UNIMPLEMENTED
+   /* lpszCaption may be NULL, check for it and call RtlInitUnicodeString()
+      if bInsert == TRUE call NtUserInsertMenuItem() else NtUserSetMenuItemInfo()
+   */
+   return 0;
 }
 
 
 /*
  * @implemented
  */
- /* NOTE: unused function */
+/* NOTE: unused function */
 BOOL STDCALL
 NtUserTrackPopupMenuEx(
-  HMENU hMenu,
-  UINT fuFlags,
-  int x,
-  int y,
-  HWND hWnd,
-  LPTPMPARAMS lptpm)
+   HMENU hMenu,
+   UINT fuFlags,
+   int x,
+   int y,
+   HWND hWnd,
+   LPTPMPARAMS lptpm)
 {
    UNIMPLEMENTED
-   
+
    return FALSE;
 }
 
index 88fbc36..7f77023 100644 (file)
 
 typedef struct
 {
-  UINT uFlags;
-  UINT uTimeout;
-  ULONG_PTR Result;
-} DOSENDMESSAGE, *PDOSENDMESSAGE;
+   UINT uFlags;
+   UINT uTimeout;
+   ULONG_PTR Result;
+}
+DOSENDMESSAGE, *PDOSENDMESSAGE;
 
 /* FUNCTIONS *****************************************************************/
 
 NTSTATUS FASTCALL
 IntInitMessageImpl(VOID)
 {
-  return STATUS_SUCCESS;
+   return STATUS_SUCCESS;
 }
 
 NTSTATUS FASTCALL
 IntCleanupMessageImpl(VOID)
 {
-  return STATUS_SUCCESS;
+   return STATUS_SUCCESS;
 }
 
 #define MMS_SIZE_WPARAM      -1
@@ -63,166 +64,167 @@ IntCleanupMessageImpl(VOID)
 #define MMS_FLAG_WRITE       0x02
 #define MMS_FLAG_READWRITE   (MMS_FLAG_READ | MMS_FLAG_WRITE)
 typedef struct tagMSGMEMORY
-  {
-    UINT Message;
-    UINT Size;
-    INT Flags;
-  } MSGMEMORY, *PMSGMEMORY;
+{
+   UINT Message;
+   UINT Size;
+   INT Flags;
+}
+MSGMEMORY, *PMSGMEMORY;
 
 static MSGMEMORY MsgMemory[] =
-  {
-    { WM_CREATE, MMS_SIZE_SPECIAL, MMS_FLAG_READWRITE },
-    { WM_DDE_ACK, sizeof(KMDDELPARAM), MMS_FLAG_READ },
-    { WM_DDE_EXECUTE, MMS_SIZE_WPARAM, MMS_FLAG_READ },
-    { WM_GETMINMAXINFO, sizeof(MINMAXINFO), MMS_FLAG_READWRITE },
-    { WM_GETTEXT, MMS_SIZE_WPARAMWCHAR, MMS_FLAG_WRITE },
-    { WM_NCCALCSIZE, MMS_SIZE_SPECIAL, MMS_FLAG_READWRITE },
-    { WM_NCCREATE, MMS_SIZE_SPECIAL, MMS_FLAG_READWRITE },
-    { WM_SETTEXT, MMS_SIZE_LPARAMSZ, MMS_FLAG_READ },
-    { WM_STYLECHANGED, sizeof(STYLESTRUCT), MMS_FLAG_READ },
-    { WM_STYLECHANGING, sizeof(STYLESTRUCT), MMS_FLAG_READWRITE },
-    { WM_COPYDATA, MMS_SIZE_SPECIAL, MMS_FLAG_READ },
-    { WM_WINDOWPOSCHANGED, sizeof(WINDOWPOS), MMS_FLAG_READ },
-    { WM_WINDOWPOSCHANGING, sizeof(WINDOWPOS), MMS_FLAG_READWRITE },
-  };
+   {
+      { WM_CREATE, MMS_SIZE_SPECIAL, MMS_FLAG_READWRITE },
+      { WM_DDE_ACK, sizeof(KMDDELPARAM), MMS_FLAG_READ },
+      { WM_DDE_EXECUTE, MMS_SIZE_WPARAM, MMS_FLAG_READ },
+      { WM_GETMINMAXINFO, sizeof(MINMAXINFO), MMS_FLAG_READWRITE },
+      { WM_GETTEXT, MMS_SIZE_WPARAMWCHAR, MMS_FLAG_WRITE },
+      { WM_NCCALCSIZE, MMS_SIZE_SPECIAL, MMS_FLAG_READWRITE },
+      { WM_NCCREATE, MMS_SIZE_SPECIAL, MMS_FLAG_READWRITE },
+      { WM_SETTEXT, MMS_SIZE_LPARAMSZ, MMS_FLAG_READ },
+      { WM_STYLECHANGED, sizeof(STYLESTRUCT), MMS_FLAG_READ },
+      { WM_STYLECHANGING, sizeof(STYLESTRUCT), MMS_FLAG_READWRITE },
+      { WM_COPYDATA, MMS_SIZE_SPECIAL, MMS_FLAG_READ },
+      { WM_WINDOWPOSCHANGED, sizeof(WINDOWPOS), MMS_FLAG_READ },
+      { WM_WINDOWPOSCHANGING, sizeof(WINDOWPOS), MMS_FLAG_READWRITE },
+   };
 
 static PMSGMEMORY FASTCALL
 FindMsgMemory(UINT Msg)
-  {
-  PMSGMEMORY MsgMemoryEntry;
-
-  /* See if this message type is present in the table */
-  for (MsgMemoryEntry = MsgMemory;
-       MsgMemoryEntry < MsgMemory + sizeof(MsgMemory) / sizeof(MSGMEMORY);
-       MsgMemoryEntry++)
-    {
+{
+   PMSGMEMORY MsgMemoryEntry;
+
+   /* See if this message type is present in the table */
+   for (MsgMemoryEntry = MsgMemory;
+         MsgMemoryEntry < MsgMemory + sizeof(MsgMemory) / sizeof(MSGMEMORY);
+         MsgMemoryEntry++)
+   {
       if (Msg == MsgMemoryEntry->Message)
-        {
-          return MsgMemoryEntry;
-        }
-    }
+      {
+         return MsgMemoryEntry;
+      }
+   }
 
-  return NULL;
+   return NULL;
 }
 
 static UINT FASTCALL
 MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam)
 {
-  CREATESTRUCTW *Cs;
-  PUNICODE_STRING WindowName;
-  PUNICODE_STRING ClassName;
-  UINT Size;
-
-  _SEH_TRY {
-  if (MMS_SIZE_WPARAM == MsgMemoryEntry->Size)
-    {
+   CREATESTRUCTW *Cs;
+   PUNICODE_STRING WindowName;
+   PUNICODE_STRING ClassName;
+   UINT Size;
+
+   _SEH_TRY {
+      if (MMS_SIZE_WPARAM == MsgMemoryEntry->Size)
+   {
       return (UINT) wParam;
-    }
-  else if (MMS_SIZE_WPARAMWCHAR == MsgMemoryEntry->Size)
-    {
+      }
+      else if (MMS_SIZE_WPARAMWCHAR == MsgMemoryEntry->Size)
+   {
       return (UINT) (wParam * sizeof(WCHAR));
-    }
-  else if (MMS_SIZE_LPARAMSZ == MsgMemoryEntry->Size)
-    {
+      }
+      else if (MMS_SIZE_LPARAMSZ == MsgMemoryEntry->Size)
+   {
       return (UINT) ((wcslen((PWSTR) lParam) + 1) * sizeof(WCHAR));
-    }
-  else if (MMS_SIZE_SPECIAL == MsgMemoryEntry->Size)
-    {
+      }
+      else if (MMS_SIZE_SPECIAL == MsgMemoryEntry->Size)
+   {
       switch(MsgMemoryEntry->Message)
-        {
-        case WM_CREATE:
-        case WM_NCCREATE:
-          Cs = (CREATESTRUCTW *) lParam;
-          WindowName = (PUNICODE_STRING) Cs->lpszName;
-          ClassName = (PUNICODE_STRING) Cs->lpszClass;
-          Size = sizeof(CREATESTRUCTW) + WindowName->Length + sizeof(WCHAR);
-          if (IS_ATOM(ClassName->Buffer))
-            {
-              Size += sizeof(WCHAR) + sizeof(ATOM);
-            }
-          else
-            {
-              Size += sizeof(WCHAR) + ClassName->Length + sizeof(WCHAR);
-            }
-          return Size;
-          break;
-
-        case WM_NCCALCSIZE:
-          return wParam ? sizeof(NCCALCSIZE_PARAMS) + sizeof(WINDOWPOS) : sizeof(RECT);
-          break;
-
-        case WM_COPYDATA:
-          return sizeof(COPYDATASTRUCT) + ((PCOPYDATASTRUCT)lParam)->cbData;
-
-        default:
-          assert(FALSE);
-          return 0;
-          break;
-        }
-    }
-  else
-    {
-      return MsgMemoryEntry->Size;
-    }
-    } _SEH_HANDLE {
-
-        DPRINT1("Exception caught in MsgMemorySize()! Status: 0x%x\n", _SEH_GetExceptionCode());
-    } _SEH_END;
-    return 0;
+         {
+            case WM_CREATE:
+            case WM_NCCREATE:
+               Cs = (CREATESTRUCTW *) lParam;
+               WindowName = (PUNICODE_STRING) Cs->lpszName;
+               ClassName = (PUNICODE_STRING) Cs->lpszClass;
+               Size = sizeof(CREATESTRUCTW) + WindowName->Length + sizeof(WCHAR);
+               if (IS_ATOM(ClassName->Buffer))
+               {
+                  Size += sizeof(WCHAR) + sizeof(ATOM);
+               }
+               else
+               {
+                  Size += sizeof(WCHAR) + ClassName->Length + sizeof(WCHAR);
+               }
+               return Size;
+               break;
+
+            case WM_NCCALCSIZE:
+               return wParam ? sizeof(NCCALCSIZE_PARAMS) + sizeof(WINDOWPOS) : sizeof(RECT);
+               break;
+
+            case WM_COPYDATA:
+               return sizeof(COPYDATASTRUCT) + ((PCOPYDATASTRUCT)lParam)->cbData;
+
+            default:
+               assert(FALSE);
+               return 0;
+               break;
+         }
+      }
+      else
+      {
+         return MsgMemoryEntry->Size;
+      }
+   } _SEH_HANDLE {
+
+      DPRINT1("Exception caught in MsgMemorySize()! Status: 0x%x\n", _SEH_GetExceptionCode());
+   } _SEH_END;
+   return 0;
 }
 
 static FASTCALL NTSTATUS
 PackParam(LPARAM *lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam)
 {
-  NCCALCSIZE_PARAMS *UnpackedNcCalcsize;
-  NCCALCSIZE_PARAMS *PackedNcCalcsize;
-  CREATESTRUCTW *UnpackedCs;
-  CREATESTRUCTW *PackedCs;
-  PUNICODE_STRING WindowName;
-  PUNICODE_STRING ClassName;
-  UINT Size;
-  PCHAR CsData;
-
-  *lParamPacked = lParam;
-  if (WM_NCCALCSIZE == Msg && wParam)
-    {
+   NCCALCSIZE_PARAMS *UnpackedNcCalcsize;
+   NCCALCSIZE_PARAMS *PackedNcCalcsize;
+   CREATESTRUCTW *UnpackedCs;
+   CREATESTRUCTW *PackedCs;
+   PUNICODE_STRING WindowName;
+   PUNICODE_STRING ClassName;
+   UINT Size;
+   PCHAR CsData;
+
+   *lParamPacked = lParam;
+   if (WM_NCCALCSIZE == Msg && wParam)
+   {
       UnpackedNcCalcsize = (NCCALCSIZE_PARAMS *) lParam;
       if (UnpackedNcCalcsize->lppos != (PWINDOWPOS) (UnpackedNcCalcsize + 1))
-        {
-          PackedNcCalcsize = ExAllocatePoolWithTag(PagedPool,
-                                                   sizeof(NCCALCSIZE_PARAMS) + sizeof(WINDOWPOS),
-                                                   TAG_MSG);
-          if (NULL == PackedNcCalcsize)
-            {
-              DPRINT1("Not enough memory to pack lParam\n");
-              return STATUS_NO_MEMORY;
-            }
-          RtlCopyMemory(PackedNcCalcsize, UnpackedNcCalcsize, sizeof(NCCALCSIZE_PARAMS));
-          PackedNcCalcsize->lppos = (PWINDOWPOS) (PackedNcCalcsize + 1);
-          RtlCopyMemory(PackedNcCalcsize->lppos, UnpackedNcCalcsize->lppos, sizeof(WINDOWPOS));
-          *lParamPacked = (LPARAM) PackedNcCalcsize;
-        }
-    }
-  else if (WM_CREATE == Msg || WM_NCCREATE == Msg)
-    {
+      {
+         PackedNcCalcsize = ExAllocatePoolWithTag(PagedPool,
+                            sizeof(NCCALCSIZE_PARAMS) + sizeof(WINDOWPOS),
+                            TAG_MSG);
+         if (NULL == PackedNcCalcsize)
+         {
+            DPRINT1("Not enough memory to pack lParam\n");
+            return STATUS_NO_MEMORY;
+         }
+         RtlCopyMemory(PackedNcCalcsize, UnpackedNcCalcsize, sizeof(NCCALCSIZE_PARAMS));
+         PackedNcCalcsize->lppos = (PWINDOWPOS) (PackedNcCalcsize + 1);
+         RtlCopyMemory(PackedNcCalcsize->lppos, UnpackedNcCalcsize->lppos, sizeof(WINDOWPOS));
+         *lParamPacked = (LPARAM) PackedNcCalcsize;
+      }
+   }
+   else if (WM_CREATE == Msg || WM_NCCREATE == Msg)
+   {
       UnpackedCs = (CREATESTRUCTW *) lParam;
       WindowName = (PUNICODE_STRING) UnpackedCs->lpszName;
       ClassName = (PUNICODE_STRING) UnpackedCs->lpszClass;
       Size = sizeof(CREATESTRUCTW) + WindowName->Length + sizeof(WCHAR);
       if (IS_ATOM(ClassName->Buffer))
-        {
-          Size += sizeof(WCHAR) + sizeof(ATOM);
-        }
+      {
+         Size += sizeof(WCHAR) + sizeof(ATOM);
+      }
       else
-        {
-          Size += sizeof(WCHAR) + ClassName->Length + sizeof(WCHAR);
-        }
+      {
+         Size += sizeof(WCHAR) + ClassName->Length + sizeof(WCHAR);
+      }
       PackedCs = ExAllocatePoolWithTag(PagedPool, Size, TAG_MSG);
       if (NULL == PackedCs)
-        {
-          DPRINT1("Not enough memory to pack lParam\n");
-          return STATUS_NO_MEMORY;
-        }
+      {
+         DPRINT1("Not enough memory to pack lParam\n");
+         return STATUS_NO_MEMORY;
+      }
       RtlCopyMemory(PackedCs, UnpackedCs, sizeof(CREATESTRUCTW));
       CsData = (PCHAR) (PackedCs + 1);
       PackedCs->lpszName = (LPCWSTR) (CsData - (PCHAR) PackedCs);
@@ -232,42 +234,42 @@ PackParam(LPARAM *lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam)
       CsData += sizeof(WCHAR);
       PackedCs->lpszClass = (LPCWSTR) (CsData - (PCHAR) PackedCs);
       if (IS_ATOM(ClassName->Buffer))
-        {
-          *((WCHAR *) CsData) = L'A';
-          CsData += sizeof(WCHAR);
-          *((ATOM *) CsData) = (ATOM)(DWORD_PTR) ClassName->Buffer;
-          CsData += sizeof(ATOM);
-        }
+      {
+         *((WCHAR *) CsData) = L'A';
+         CsData += sizeof(WCHAR);
+         *((ATOM *) CsData) = (ATOM)(DWORD_PTR) ClassName->Buffer;
+         CsData += sizeof(ATOM);
+      }
       else
-        {
-          *((WCHAR *) CsData) = L'S';
-          CsData += sizeof(WCHAR);
-          RtlCopyMemory(CsData, ClassName->Buffer, ClassName->Length);
-          CsData += ClassName->Length;
-          *((WCHAR *) CsData) = L'\0';
-          CsData += sizeof(WCHAR);
-        }
+      {
+         *((WCHAR *) CsData) = L'S';
+         CsData += sizeof(WCHAR);
+         RtlCopyMemory(CsData, ClassName->Buffer, ClassName->Length);
+         CsData += ClassName->Length;
+         *((WCHAR *) CsData) = L'\0';
+         CsData += sizeof(WCHAR);
+      }
       ASSERT(CsData == (PCHAR) PackedCs + Size);
       *lParamPacked = (LPARAM) PackedCs;
-    }
+   }
 
-  return STATUS_SUCCESS;
+   return STATUS_SUCCESS;
 }
 
 static FASTCALL NTSTATUS
 UnpackParam(LPARAM lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam)
 {
-  NCCALCSIZE_PARAMS *UnpackedParams;
-  NCCALCSIZE_PARAMS *PackedParams;
-  PWINDOWPOS UnpackedWindowPos;
+   NCCALCSIZE_PARAMS *UnpackedParams;
+   NCCALCSIZE_PARAMS *PackedParams;
+   PWINDOWPOS UnpackedWindowPos;
 
-  if (lParamPacked == lParam)
-    {
+   if (lParamPacked == lParam)
+   {
       return STATUS_SUCCESS;
-    }
+   }
 
-  if (WM_NCCALCSIZE == Msg && wParam)
-    {
+   if (WM_NCCALCSIZE == Msg && wParam)
+   {
       PackedParams = (NCCALCSIZE_PARAMS *) lParamPacked;
       UnpackedParams = (NCCALCSIZE_PARAMS *) lParam;
       UnpackedWindowPos = UnpackedParams->lppos;
@@ -277,61 +279,62 @@ UnpackParam(LPARAM lParamPacked, UINT Msg, WPARAM wParam, LPARAM lParam)
       ExFreePool((PVOID) lParamPacked);
 
       return STATUS_SUCCESS;
-    }
-  else if (WM_CREATE == Msg || WM_NCCREATE == Msg)
-    {
+   }
+   else if (WM_CREATE == Msg || WM_NCCREATE == Msg)
+   {
       ExFreePool((PVOID) lParamPacked);
 
       return STATUS_SUCCESS;
-    }
+   }
 
-  ASSERT(FALSE);
+   ASSERT(FALSE);
 
-  return STATUS_INVALID_PARAMETER;
+   return STATUS_INVALID_PARAMETER;
 }
 
 BOOL
 STDCALL
 NtUserCallMsgFilter(
-  LPMSG msg,
-  INT code)
+   LPMSG msg,
+   INT code)
 {
-    DECLARE_RETURN(BOOL);
-
-    DPRINT("Enter NtUserCallMsgFilter\n");
-    UserEnterExclusive();
-  
-    if (co_HOOK_CallHooks( WH_SYSMSGFILTER, code, 0, (LPARAM)msg)) RETURN( TRUE); 
-        RETURN( co_HOOK_CallHooks( WH_MSGFILTER, code, 0, (LPARAM)msg));
-        
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserCallMsgFilter\n");
+   UserEnterExclusive();
+
+   if (co_HOOK_CallHooks( WH_SYSMSGFILTER, code, 0, (LPARAM)msg))
+      RETURN( TRUE);
+   RETURN( co_HOOK_CallHooks( WH_MSGFILTER, code, 0, (LPARAM)msg));
+
 CLEANUP:
-    DPRINT("Leave NtUserCallMsgFilter. ret=%i\n", _ret_);
-    UserLeave();
-    END_CLEANUP;
+   DPRINT("Leave NtUserCallMsgFilter. ret=%i\n", _ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 LRESULT STDCALL
 NtUserDispatchMessage(PNTUSERDISPATCHMESSAGEINFO UnsafeMsgInfo)
 {
-  NTSTATUS Status;
-  NTUSERDISPATCHMESSAGEINFO MsgInfo;
-  PWINDOW_OBJECT WindowObject;
-  LRESULT Result = TRUE;
-  DECLARE_RETURN(LRESULT);
-
-  DPRINT("Enter NtUserDispatchMessage\n");
-  UserEnterExclusive();
-
-  Status = MmCopyFromCaller(&MsgInfo, UnsafeMsgInfo, sizeof(NTUSERDISPATCHMESSAGEINFO));
-  if (! NT_SUCCESS(Status))
-    {
+   NTSTATUS Status;
+   NTUSERDISPATCHMESSAGEINFO MsgInfo;
+   PWINDOW_OBJECT WindowObject;
+   LRESULT Result = TRUE;
+   DECLARE_RETURN(LRESULT);
+
+   DPRINT("Enter NtUserDispatchMessage\n");
+   UserEnterExclusive();
+
+   Status = MmCopyFromCaller(&MsgInfo, UnsafeMsgInfo, sizeof(NTUSERDISPATCHMESSAGEINFO));
+   if (! NT_SUCCESS(Status))
+   {
       SetLastNtError(Status);
       RETURN( 0);
-    }
+   }
 
-  /* Process timer messages. */
-  if (WM_TIMER == MsgInfo.Msg.message && 0 != MsgInfo.Msg.lParam)
-    {
+   /* Process timer messages. */
+   if (WM_TIMER == MsgInfo.Msg.message && 0 != MsgInfo.Msg.lParam)
+   {
       LARGE_INTEGER LargeTickCount;
       /* FIXME: Call hooks. */
 
@@ -341,305 +344,305 @@ NtUserDispatchMessage(PNTUSERDISPATCHMESSAGEINFO UnsafeMsgInfo)
       KeQueryTickCount(&LargeTickCount);
       MsgInfo.Proc = (WNDPROC) MsgInfo.Msg.lParam;
       MsgInfo.Msg.lParam = (LPARAM)LargeTickCount.u.LowPart;
-    }
-  else if (NULL == MsgInfo.Msg.hwnd)
-    {
+   }
+   else if (NULL == MsgInfo.Msg.hwnd)
+   {
       MsgInfo.HandledByKernel = TRUE;
       Result = 0;
-    }
-  else
-    {
+   }
+   else
+   {
       /* Get the window object. */
       WindowObject = IntGetWindowObject(MsgInfo.Msg.hwnd);
       if (NULL == WindowObject)
-        {
-          SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-          MsgInfo.HandledByKernel = TRUE;
-          Result = 0;
-        }
+      {
+         SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+         MsgInfo.HandledByKernel = TRUE;
+         Result = 0;
+      }
       else
-        {
-          if (WindowObject->OwnerThread != PsGetCurrentThread())
+      {
+         if (WindowObject->OwnerThread != PsGetCurrentThread())
+         {
+            IntReleaseWindowObject(WindowObject);
+            DPRINT1("Window doesn't belong to the calling thread!\n");
+            MsgInfo.HandledByKernel = TRUE;
+            Result = 0;
+         }
+         else
+         {
+            /* FIXME: Call hook procedures. */
+
+            MsgInfo.HandledByKernel = FALSE;
+            Result = 0;
+            if (0xFFFF0000 != ((DWORD) WindowObject->WndProcW & 0xFFFF0000))
             {
-              IntReleaseWindowObject(WindowObject);
-              DPRINT1("Window doesn't belong to the calling thread!\n");
-              MsgInfo.HandledByKernel = TRUE;
-              Result = 0;
+               if (0xFFFF0000 != ((DWORD) WindowObject->WndProcA & 0xFFFF0000))
+               {
+                  /* Both Unicode and Ansi winprocs are real, use whatever
+                     usermode prefers */
+                  MsgInfo.Proc = (MsgInfo.Ansi ? WindowObject->WndProcA
+                                  : WindowObject->WndProcW);
+               }
+               else
+               {
+                  /* Real Unicode winproc */
+                  MsgInfo.Ansi = FALSE;
+                  MsgInfo.Proc = WindowObject->WndProcW;
+               }
             }
-          else
+            else
             {
-              /* FIXME: Call hook procedures. */
-
-              MsgInfo.HandledByKernel = FALSE;
-              Result = 0;
-              if (0xFFFF0000 != ((DWORD) WindowObject->WndProcW & 0xFFFF0000))
-                {
-                  if (0xFFFF0000 != ((DWORD) WindowObject->WndProcA & 0xFFFF0000))
-                    {
-                      /* Both Unicode and Ansi winprocs are real, use whatever
-                         usermode prefers */
-                      MsgInfo.Proc = (MsgInfo.Ansi ? WindowObject->WndProcA
-                                      : WindowObject->WndProcW);
-                    }
-                  else
-                    {
-                      /* Real Unicode winproc */
-                      MsgInfo.Ansi = FALSE;
-                      MsgInfo.Proc = WindowObject->WndProcW;
-                    }
-                }
-              else
-                {
-                  /* Must have real Ansi winproc */
-                  MsgInfo.Ansi = TRUE;
-                  MsgInfo.Proc = WindowObject->WndProcA;
-                }
+               /* Must have real Ansi winproc */
+               MsgInfo.Ansi = TRUE;
+               MsgInfo.Proc = WindowObject->WndProcA;
             }
-          IntReleaseWindowObject(WindowObject);
-        }
-    }
-  Status = MmCopyToCaller(UnsafeMsgInfo, &MsgInfo, sizeof(NTUSERDISPATCHMESSAGEINFO));
-  if (! NT_SUCCESS(Status))
-    {
+         }
+         IntReleaseWindowObject(WindowObject);
+      }
+   }
+   Status = MmCopyToCaller(UnsafeMsgInfo, &MsgInfo, sizeof(NTUSERDISPATCHMESSAGEINFO));
+   if (! NT_SUCCESS(Status))
+   {
       SetLastNtError(Status);
       RETURN( 0);
-    }
+   }
+
+   RETURN( Result);
 
-  RETURN( Result);
-  
 CLEANUP:
-  DPRINT("Leave NtUserDispatchMessage. ret=%i\n", _ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserDispatchMessage. ret=%i\n", _ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
 BOOL STDCALL
 NtUserTranslateMessage(LPMSG lpMsg,
-                      HKL dwhkl)
+                       HKL dwhkl)
 {
-  NTSTATUS Status;
-  MSG SafeMsg;
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserTranslateMessage\n");
-  UserEnterExclusive();
-
-  Status = MmCopyFromCaller(&SafeMsg, lpMsg, sizeof(MSG));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    RETURN( FALSE);
-  }
-
-  RETURN( IntTranslateKbdMessage(&SafeMsg, dwhkl));
-  
+   NTSTATUS Status;
+   MSG SafeMsg;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserTranslateMessage\n");
+   UserEnterExclusive();
+
+   Status = MmCopyFromCaller(&SafeMsg, lpMsg, sizeof(MSG));
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      RETURN( FALSE);
+   }
+
+   RETURN( IntTranslateKbdMessage(&SafeMsg, dwhkl));
+
 CLEANUP:
-  DPRINT("Leave NtUserTranslateMessage: ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserTranslateMessage: ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
 VOID FASTCALL
 co_IntSendHitTestMessages(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg)
 {
-  if(!Msg->hwnd || ThreadQueue->CaptureWindow)
-  {
-    return;
-  }
-
-  switch(Msg->message)
-  {
-    case WM_MOUSEMOVE:
-    {
-      co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message));
-      break;
-    }
-    case WM_NCMOUSEMOVE:
-    {
-      co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(Msg->wParam, Msg->message));
-      break;
-    }
-    case WM_LBUTTONDOWN:
-    case WM_MBUTTONDOWN:
-    case WM_RBUTTONDOWN:
-    case WM_XBUTTONDOWN:
-    case WM_LBUTTONDBLCLK:
-    case WM_MBUTTONDBLCLK:
-    case WM_RBUTTONDBLCLK:
-    case WM_XBUTTONDBLCLK:
-    {
-      WPARAM wParam;
-      PSYSTEM_CURSORINFO CurInfo;
-
-      if(!IntGetWindowStationObject(InputWindowStation))
-      {
-        break;
-      }
-      CurInfo = IntGetSysCursorInfo(InputWindowStation);
-      wParam = (WPARAM)(CurInfo->ButtonsDown);
-      ObDereferenceObject(InputWindowStation);
-
-      co_IntSendMessage(Msg->hwnd, WM_MOUSEMOVE, wParam, Msg->lParam);
-      co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message));
-      break;
-    }
-    case WM_NCLBUTTONDOWN:
-    case WM_NCMBUTTONDOWN:
-    case WM_NCRBUTTONDOWN:
-    case WM_NCXBUTTONDOWN:
-    case WM_NCLBUTTONDBLCLK:
-    case WM_NCMBUTTONDBLCLK:
-    case WM_NCRBUTTONDBLCLK:
-    case WM_NCXBUTTONDBLCLK:
-    {
-      co_IntSendMessage(Msg->hwnd, WM_NCMOUSEMOVE, (WPARAM)Msg->wParam, Msg->lParam);
-      co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(Msg->wParam, Msg->message));
-      break;
-    }
-  }
+   if(!Msg->hwnd || ThreadQueue->CaptureWindow)
+   {
+      return;
+   }
+
+   switch(Msg->message)
+   {
+      case WM_MOUSEMOVE:
+         {
+            co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message));
+            break;
+         }
+      case WM_NCMOUSEMOVE:
+         {
+            co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(Msg->wParam, Msg->message));
+            break;
+         }
+      case WM_LBUTTONDOWN:
+      case WM_MBUTTONDOWN:
+      case WM_RBUTTONDOWN:
+      case WM_XBUTTONDOWN:
+      case WM_LBUTTONDBLCLK:
+      case WM_MBUTTONDBLCLK:
+      case WM_RBUTTONDBLCLK:
+      case WM_XBUTTONDBLCLK:
+         {
+            WPARAM wParam;
+            PSYSTEM_CURSORINFO CurInfo;
+
+            if(!IntGetWindowStationObject(InputWindowStation))
+            {
+               break;
+            }
+            CurInfo = IntGetSysCursorInfo(InputWindowStation);
+            wParam = (WPARAM)(CurInfo->ButtonsDown);
+            ObDereferenceObject(InputWindowStation);
+
+            co_IntSendMessage(Msg->hwnd, WM_MOUSEMOVE, wParam, Msg->lParam);
+            co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message));
+            break;
+         }
+      case WM_NCLBUTTONDOWN:
+      case WM_NCMBUTTONDOWN:
+      case WM_NCRBUTTONDOWN:
+      case WM_NCXBUTTONDOWN:
+      case WM_NCLBUTTONDBLCLK:
+      case WM_NCMBUTTONDBLCLK:
+      case WM_NCRBUTTONDBLCLK:
+      case WM_NCXBUTTONDBLCLK:
+         {
+            co_IntSendMessage(Msg->hwnd, WM_NCMOUSEMOVE, (WPARAM)Msg->wParam, Msg->lParam);
+            co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(Msg->wParam, Msg->message));
+            break;
+         }
+   }
 }
 
 BOOL FASTCALL
 co_IntActivateWindowMouse(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, PWINDOW_OBJECT MsgWindow,
-                       USHORT *HitTest)
+                          USHORT *HitTest)
 {
-  ULONG Result;
-  PWINDOW_OBJECT Parent;
-
-  if(*HitTest == (USHORT)HTTRANSPARENT)
-  {
-    /* eat the message, search again! */
-    return TRUE;
-  }
-
-  Parent = IntGetParent(MsgWindow);
-  /* fixme: abort if no parent ? */ 
-  Result = co_IntSendMessage(MsgWindow->hSelf, 
-      WM_MOUSEACTIVATE, 
-      (WPARAM) (Parent ? Parent->hSelf : NULL), 
-      (LPARAM)MAKELONG(*HitTest, Msg->message)
-      );
-      
-  switch (Result)
-  {
-    case MA_NOACTIVATEANDEAT:
-      return TRUE;
-    case MA_NOACTIVATE:
-      break;
-    case MA_ACTIVATEANDEAT:
-      co_IntMouseActivateWindow(MsgWindow);
+   ULONG Result;
+   PWINDOW_OBJECT Parent;
+
+   if(*HitTest == (USHORT)HTTRANSPARENT)
+   {
+      /* eat the message, search again! */
       return TRUE;
-    default:
-      /* MA_ACTIVATE */
-      co_IntMouseActivateWindow(MsgWindow);
-      break;
-  }
+   }
 
-  return FALSE;
+   Parent = IntGetParent(MsgWindow);
+   /* fixme: abort if no parent ? */
+   Result = co_IntSendMessage(MsgWindow->hSelf,
+                              WM_MOUSEACTIVATE,
+                              (WPARAM) (Parent ? Parent->hSelf : NULL),
+                              (LPARAM)MAKELONG(*HitTest, Msg->message)
+                             );
+
+   switch (Result)
+   {
+      case MA_NOACTIVATEANDEAT:
+         return TRUE;
+      case MA_NOACTIVATE:
+         break;
+      case MA_ACTIVATEANDEAT:
+         co_IntMouseActivateWindow(MsgWindow);
+         return TRUE;
+      default:
+         /* MA_ACTIVATE */
+         co_IntMouseActivateWindow(MsgWindow);
+         break;
+   }
+
+   return FALSE;
 }
 
 BOOL FASTCALL
 co_IntTranslateMouseMessage(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, USHORT *HitTest, BOOL Remove)
 {
-  PWINDOW_OBJECT Window;
-
-  if(!(Window = IntGetWindowObject(Msg->hwnd)))
-  {
-    /* let's just eat the message?! */
-    return TRUE;
-  }
-
-  if(ThreadQueue == Window->MessageQueue &&
-     ThreadQueue->CaptureWindow != Window->hSelf)
-  {
-    /* only send WM_NCHITTEST messages if we're not capturing the window! */
-    *HitTest = co_IntSendMessage(Window->hSelf, WM_NCHITTEST, 0,
-                              MAKELONG(Msg->pt.x, Msg->pt.y));
-
-    if(*HitTest == (USHORT)HTTRANSPARENT)
-    {
-      PWINDOW_OBJECT DesktopWindow;
-      HWND hDesktop = IntGetDesktopWindow();
+   PWINDOW_OBJECT Window;
+
+   if(!(Window = IntGetWindowObject(Msg->hwnd)))
+   {
+      /* let's just eat the message?! */
+      return TRUE;
+   }
 
-      if((DesktopWindow = IntGetWindowObject(hDesktop)))
+   if(ThreadQueue == Window->MessageQueue &&
+         ThreadQueue->CaptureWindow != Window->hSelf)
+   {
+      /* only send WM_NCHITTEST messages if we're not capturing the window! */
+      *HitTest = co_IntSendMessage(Window->hSelf, WM_NCHITTEST, 0,
+                                   MAKELONG(Msg->pt.x, Msg->pt.y));
+
+      if(*HitTest == (USHORT)HTTRANSPARENT)
       {
-        PWINDOW_OBJECT Wnd;
-
-        co_WinPosWindowFromPoint(DesktopWindow, Window->MessageQueue, &Msg->pt, &Wnd);
-        if(Wnd)
-        {
-          if(Wnd != Window)
-          {
-            /* post the message to the other window */
-            Msg->hwnd = Wnd->hSelf;
-            if(!(Wnd->Status & WINDOWSTATUS_DESTROYING))
+         PWINDOW_OBJECT DesktopWindow;
+         HWND hDesktop = IntGetDesktopWindow();
+
+         if((DesktopWindow = IntGetWindowObject(hDesktop)))
+         {
+            PWINDOW_OBJECT Wnd;
+
+            co_WinPosWindowFromPoint(DesktopWindow, Window->MessageQueue, &Msg->pt, &Wnd);
+            if(Wnd)
             {
-              MsqPostMessage(Wnd->MessageQueue, Msg, FALSE,
-                             Msg->message == WM_MOUSEMOVE ? QS_MOUSEMOVE :
-                             QS_MOUSEBUTTON);
+               if(Wnd != Window)
+               {
+                  /* post the message to the other window */
+                  Msg->hwnd = Wnd->hSelf;
+                  if(!(Wnd->Status & WINDOWSTATUS_DESTROYING))
+                  {
+                     MsqPostMessage(Wnd->MessageQueue, Msg, FALSE,
+                                    Msg->message == WM_MOUSEMOVE ? QS_MOUSEMOVE :
+                                    QS_MOUSEBUTTON);
+                  }
+
+                  /* eat the message */
+                  IntReleaseWindowObject(Wnd);
+                  IntReleaseWindowObject(Window);
+                  IntReleaseWindowObject(DesktopWindow);
+                  return TRUE;
+               }
+               IntReleaseWindowObject(Wnd);
             }
 
-            /* eat the message */
-            IntReleaseWindowObject(Wnd);
-            IntReleaseWindowObject(Window);
             IntReleaseWindowObject(DesktopWindow);
-            return TRUE;
-          }
-         IntReleaseWindowObject(Wnd);
-        }
+         }
+      }
+   }
+   else
+   {
+      *HitTest = HTCLIENT;
+   }
 
-        IntReleaseWindowObject(DesktopWindow);
+   if(IS_BTN_MESSAGE(Msg->message, DOWN))
+   {
+      /* generate double click messages, if necessary */
+      if ((((*HitTest) != HTCLIENT) ||
+            (IntGetClassLong(Window, GCL_STYLE, FALSE) & CS_DBLCLKS)) &&
+            MsqIsDblClk(Msg, Remove))
+      {
+         Msg->message += WM_LBUTTONDBLCLK - WM_LBUTTONDOWN;
       }
-    }
-  }
-  else
-  {
-    *HitTest = HTCLIENT;
-  }
-
-  if(IS_BTN_MESSAGE(Msg->message, DOWN))
-  {
-    /* generate double click messages, if necessary */
-    if ((((*HitTest) != HTCLIENT) ||
-        (IntGetClassLong(Window, GCL_STYLE, FALSE) & CS_DBLCLKS)) &&
-        MsqIsDblClk(Msg, Remove))
-    {
-      Msg->message += WM_LBUTTONDBLCLK - WM_LBUTTONDOWN;
-    }
-  }
-
-  if(Msg->message != WM_MOUSEWHEEL)
-  {
-
-    if ((*HitTest) != HTCLIENT)
-    {
-      Msg->message += WM_NCMOUSEMOVE - WM_MOUSEMOVE;
-      if((Msg->message == WM_NCRBUTTONUP) &&
-         (((*HitTest) == HTCAPTION) || ((*HitTest) == HTSYSMENU)))
+   }
+
+   if(Msg->message != WM_MOUSEWHEEL)
+   {
+
+      if ((*HitTest) != HTCLIENT)
       {
-        Msg->message = WM_CONTEXTMENU;
-        Msg->wParam = (WPARAM)Window->hSelf;
+         Msg->message += WM_NCMOUSEMOVE - WM_MOUSEMOVE;
+         if((Msg->message == WM_NCRBUTTONUP) &&
+               (((*HitTest) == HTCAPTION) || ((*HitTest) == HTSYSMENU)))
+         {
+            Msg->message = WM_CONTEXTMENU;
+            Msg->wParam = (WPARAM)Window->hSelf;
+         }
+         else
+         {
+            Msg->wParam = *HitTest;
+         }
+         Msg->lParam = MAKELONG(Msg->pt.x, Msg->pt.y);
       }
-      else
+      else if(ThreadQueue->MoveSize == NULL &&
+              ThreadQueue->MenuOwner == NULL)
       {
-        Msg->wParam = *HitTest;
+         /* NOTE: Msg->pt should remain in screen coordinates. -- FiN */
+         Msg->lParam = MAKELONG(
+                          Msg->pt.x - (WORD)Window->ClientRect.left,
+                          Msg->pt.y - (WORD)Window->ClientRect.top);
       }
-      Msg->lParam = MAKELONG(Msg->pt.x, Msg->pt.y);
-    }
-    else if(ThreadQueue->MoveSize == NULL &&
-            ThreadQueue->MenuOwner == NULL)
-    {
-      /* NOTE: Msg->pt should remain in screen coordinates. -- FiN */
-      Msg->lParam = MAKELONG(
-        Msg->pt.x - (WORD)Window->ClientRect.left,
-        Msg->pt.y - (WORD)Window->ClientRect.top);
-    }
-  }
-
-  IntReleaseWindowObject(Window);
-  return FALSE;
+   }
+
+   IntReleaseWindowObject(Window);
+   return FALSE;
 }
 
 
@@ -648,169 +651,171 @@ co_IntTranslateMouseMessage(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, USHORT *
  */
 BOOL FASTCALL
 co_IntPeekMessage(PUSER_MESSAGE Msg,
-                HWND Wnd,
-                UINT MsgFilterMin,
-                UINT MsgFilterMax,
-                UINT RemoveMsg)
+                  HWND Wnd,
+                  UINT MsgFilterMin,
+                  UINT MsgFilterMax,
+                  UINT RemoveMsg)
 {
-  LARGE_INTEGER LargeTickCount;
-  PUSER_MESSAGE_QUEUE ThreadQueue;
-  PUSER_MESSAGE Message;
-  BOOL Present, RemoveMessages;
-
-  /* The queues and order in which they are checked are documented in the MSDN
-     article on GetMessage() */
-
-  ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-
-  /* Inspect RemoveMsg flags */
-  /* FIXME: The only flag we process is PM_REMOVE - processing of others must still be implemented */
-  RemoveMessages = RemoveMsg & PM_REMOVE;
-
-  CheckMessages:
-
-  Present = FALSE;
-
-  KeQueryTickCount(&LargeTickCount);
-  ThreadQueue->LastMsgRead = LargeTickCount.u.LowPart;
-
-  /* Dispatch sent messages here. */
-  while (co_MsqDispatchOneSentMessage(ThreadQueue));
-
-  /* Now look for a quit message. */
-
-  if (ThreadQueue->QuitPosted)
-  {
-    /* According to the PSDK, WM_QUIT messages are always returned, regardless
-       of the filter specified */
-    Msg->Msg.hwnd = NULL;
-    Msg->Msg.message = WM_QUIT;
-    Msg->Msg.wParam = ThreadQueue->QuitExitCode;
-    Msg->Msg.lParam = 0;
-    Msg->FreeLParam = FALSE;
-    if (RemoveMessages)
-    {
-      ThreadQueue->QuitPosted = FALSE;
-    }
-    return TRUE;
-  }
-
-  /* Now check for normal messages. */
-  Present = co_MsqFindMessage(ThreadQueue,
-                           FALSE,
-                           RemoveMessages,
-                           Wnd,
-                           MsgFilterMin,
-                           MsgFilterMax,
-                           &Message);
-  if (Present)
-  {
-    RtlCopyMemory(Msg, Message, sizeof(USER_MESSAGE));
-    if (RemoveMessages)
-    {
-      MsqDestroyMessage(Message);
-    }
-    goto MessageFound;
-  }
-
-  /* Check for hardware events. */
-  Present = co_MsqFindMessage(ThreadQueue,
-                           TRUE,
-                           RemoveMessages,
-                           Wnd,
-                           MsgFilterMin,
-                           MsgFilterMax,
-                           &Message);
-  if (Present)
-  {
-    RtlCopyMemory(Msg, Message, sizeof(USER_MESSAGE));
-    if (RemoveMessages)
-    {
-      MsqDestroyMessage(Message);
-    }
-    goto MessageFound;
-  }
-
-  /* Check for sent messages again. */
-  while (co_MsqDispatchOneSentMessage(ThreadQueue));
-
-  /* Check for paint messages. */
-  if (IntGetPaintMessage(Wnd, MsgFilterMin, MsgFilterMax, PsGetWin32Thread(), &Msg->Msg, RemoveMessages))
-  {
-    Msg->FreeLParam = FALSE;
-    return TRUE;
-  }
-
-  /* Check for WM_(SYS)TIMER messages */
-  Present = MsqGetTimerMessage(ThreadQueue, Wnd, MsgFilterMin, MsgFilterMax,
-                               &Msg->Msg, RemoveMessages);
-  if (Present)
-  {
-    Msg->FreeLParam = FALSE;
-    goto MessageFound;
-  }
-
-  if(Present)
-  {
-    MessageFound:
-
-    if(RemoveMessages)
-    {
-      PWINDOW_OBJECT MsgWindow = NULL;
-
-      if(Msg->Msg.hwnd && (MsgWindow = IntGetWindowObject(Msg->Msg.hwnd)) &&
-         Msg->Msg.message >= WM_MOUSEFIRST && Msg->Msg.message <= WM_MOUSELAST)
+   LARGE_INTEGER LargeTickCount;
+   PUSER_MESSAGE_QUEUE ThreadQueue;
+   PUSER_MESSAGE Message;
+   BOOL Present, RemoveMessages;
+
+   /* The queues and order in which they are checked are documented in the MSDN
+      article on GetMessage() */
+
+   ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
+
+   /* Inspect RemoveMsg flags */
+   /* FIXME: The only flag we process is PM_REMOVE - processing of others must still be implemented */
+   RemoveMessages = RemoveMsg & PM_REMOVE;
+
+CheckMessages:
+
+   Present = FALSE;
+
+   KeQueryTickCount(&LargeTickCount);
+   ThreadQueue->LastMsgRead = LargeTickCount.u.LowPart;
+
+   /* Dispatch sent messages here. */
+   while (co_MsqDispatchOneSentMessage(ThreadQueue))
+      ;
+
+   /* Now look for a quit message. */
+
+   if (ThreadQueue->QuitPosted)
+   {
+      /* According to the PSDK, WM_QUIT messages are always returned, regardless
+         of the filter specified */
+      Msg->Msg.hwnd = NULL;
+      Msg->Msg.message = WM_QUIT;
+      Msg->Msg.wParam = ThreadQueue->QuitExitCode;
+      Msg->Msg.lParam = 0;
+      Msg->FreeLParam = FALSE;
+      if (RemoveMessages)
       {
-        USHORT HitTest;
-
-        if(co_IntTranslateMouseMessage(ThreadQueue, &Msg->Msg, &HitTest, TRUE))
-          /* FIXME - check message filter again, if the message doesn't match anymore,
-                     search again */
-        {
-          IntReleaseWindowObject(MsgWindow);
-          /* eat the message, search again */
-          goto CheckMessages;
-        }
-        if(ThreadQueue->CaptureWindow == NULL)
-        {
-          co_IntSendHitTestMessages(ThreadQueue, &Msg->Msg);
-          if((Msg->Msg.message != WM_MOUSEMOVE && Msg->Msg.message != WM_NCMOUSEMOVE) &&
-             IS_BTN_MESSAGE(Msg->Msg.message, DOWN) &&
-             co_IntActivateWindowMouse(ThreadQueue, &Msg->Msg, MsgWindow, &HitTest))
-          {
-            IntReleaseWindowObject(MsgWindow);
-            /* eat the message, search again */
-            goto CheckMessages;
-          }
-        }
+         ThreadQueue->QuitPosted = FALSE;
       }
-      else
+      return TRUE;
+   }
+
+   /* Now check for normal messages. */
+   Present = co_MsqFindMessage(ThreadQueue,
+                               FALSE,
+                               RemoveMessages,
+                               Wnd,
+                               MsgFilterMin,
+                               MsgFilterMax,
+                               &Message);
+   if (Present)
+   {
+      RtlCopyMemory(Msg, Message, sizeof(USER_MESSAGE));
+      if (RemoveMessages)
       {
-        co_IntSendHitTestMessages(ThreadQueue, &Msg->Msg);
+         MsqDestroyMessage(Message);
       }
+      goto MessageFound;
+   }
 
-      if(MsgWindow)
+   /* Check for hardware events. */
+   Present = co_MsqFindMessage(ThreadQueue,
+                               TRUE,
+                               RemoveMessages,
+                               Wnd,
+                               MsgFilterMin,
+                               MsgFilterMax,
+                               &Message);
+   if (Present)
+   {
+      RtlCopyMemory(Msg, Message, sizeof(USER_MESSAGE));
+      if (RemoveMessages)
       {
-        IntReleaseWindowObject(MsgWindow);
+         MsqDestroyMessage(Message);
       }
+      goto MessageFound;
+   }
+
+   /* Check for sent messages again. */
+   while (co_MsqDispatchOneSentMessage(ThreadQueue))
+      ;
 
+   /* Check for paint messages. */
+   if (IntGetPaintMessage(Wnd, MsgFilterMin, MsgFilterMax, PsGetWin32Thread(), &Msg->Msg, RemoveMessages))
+   {
+      Msg->FreeLParam = FALSE;
       return TRUE;
-    }
-
-    USHORT HitTest;
-    if((Msg->Msg.hwnd && Msg->Msg.message >= WM_MOUSEFIRST && Msg->Msg.message <= WM_MOUSELAST) &&
-       co_IntTranslateMouseMessage(ThreadQueue, &Msg->Msg, &HitTest, FALSE))
-      /* FIXME - check message filter again, if the message doesn't match anymore,
-                 search again */
-    {
-      /* eat the message, search again */
-      goto CheckMessages;
-    }
-
-    return TRUE;
-  }
-
-  return Present;
+   }
+
+   /* Check for WM_(SYS)TIMER messages */
+   Present = MsqGetTimerMessage(ThreadQueue, Wnd, MsgFilterMin, MsgFilterMax,
+                                &Msg->Msg, RemoveMessages);
+   if (Present)
+   {
+      Msg->FreeLParam = FALSE;
+      goto MessageFound;
+   }
+
+   if(Present)
+   {
+MessageFound:
+
+      if(RemoveMessages)
+      {
+         PWINDOW_OBJECT MsgWindow = NULL;
+
+         if(Msg->Msg.hwnd && (MsgWindow = IntGetWindowObject(Msg->Msg.hwnd)) &&
+               Msg->Msg.message >= WM_MOUSEFIRST && Msg->Msg.message <= WM_MOUSELAST)
+         {
+            USHORT HitTest;
+
+            if(co_IntTranslateMouseMessage(ThreadQueue, &Msg->Msg, &HitTest, TRUE))
+               /* FIXME - check message filter again, if the message doesn't match anymore,
+                          search again */
+            {
+               IntReleaseWindowObject(MsgWindow);
+               /* eat the message, search again */
+               goto CheckMessages;
+            }
+            if(ThreadQueue->CaptureWindow == NULL)
+            {
+               co_IntSendHitTestMessages(ThreadQueue, &Msg->Msg);
+               if((Msg->Msg.message != WM_MOUSEMOVE && Msg->Msg.message != WM_NCMOUSEMOVE) &&
+                     IS_BTN_MESSAGE(Msg->Msg.message, DOWN) &&
+                     co_IntActivateWindowMouse(ThreadQueue, &Msg->Msg, MsgWindow, &HitTest))
+               {
+                  IntReleaseWindowObject(MsgWindow);
+                  /* eat the message, search again */
+                  goto CheckMessages;
+               }
+            }
+         }
+         else
+         {
+            co_IntSendHitTestMessages(ThreadQueue, &Msg->Msg);
+         }
+
+         if(MsgWindow)
+         {
+            IntReleaseWindowObject(MsgWindow);
+         }
+
+         return TRUE;
+      }
+
+      USHORT HitTest;
+      if((Msg->Msg.hwnd && Msg->Msg.message >= WM_MOUSEFIRST && Msg->Msg.message <= WM_MOUSELAST) &&
+            co_IntTranslateMouseMessage(ThreadQueue, &Msg->Msg, &HitTest, FALSE))
+         /* FIXME - check message filter again, if the message doesn't match anymore,
+                    search again */
+      {
+         /* eat the message, search again */
+         goto CheckMessages;
+      }
+
+      return TRUE;
+   }
+
+   return Present;
 }
 
 BOOL STDCALL
@@ -820,129 +825,129 @@ NtUserPeekMessage(PNTUSERGETMESSAGEINFO UnsafeInfo,
                   UINT MsgFilterMax,
                   UINT RemoveMsg)
 {
-  NTSTATUS Status;
-  BOOL Present;
-  NTUSERGETMESSAGEINFO Info;
-  PWINDOW_OBJECT Window;
-  PMSGMEMORY MsgMemoryEntry;
-  PVOID UserMem;
-  UINT Size;
-  USER_MESSAGE Msg;
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserPeekMessage\n");
-  UserEnterExclusive();
-
-  /* Validate input */
-  if (NULL != Wnd)
-    {
+   NTSTATUS Status;
+   BOOL Present;
+   NTUSERGETMESSAGEINFO Info;
+   PWINDOW_OBJECT Window;
+   PMSGMEMORY MsgMemoryEntry;
+   PVOID UserMem;
+   UINT Size;
+   USER_MESSAGE Msg;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserPeekMessage\n");
+   UserEnterExclusive();
+
+   /* Validate input */
+   if (NULL != Wnd)
+   {
       Window = IntGetWindowObject(Wnd);
       if (NULL == Window)
-        {
-          Wnd = NULL;
-        }
+      {
+         Wnd = NULL;
+      }
       else
-        {
-          IntReleaseWindowObject(Window);
-        }
-    }
+      {
+         IntReleaseWindowObject(Window);
+      }
+   }
 
-  if (MsgFilterMax < MsgFilterMin)
-    {
+   if (MsgFilterMax < MsgFilterMin)
+   {
       MsgFilterMin = 0;
       MsgFilterMax = 0;
-    }
+   }
 
-  Present = co_IntPeekMessage(&Msg, Wnd, MsgFilterMin, MsgFilterMax, RemoveMsg);
-  if (Present)
-    {
+   Present = co_IntPeekMessage(&Msg, Wnd, MsgFilterMin, MsgFilterMax, RemoveMsg);
+   if (Present)
+   {
       Info.Msg = Msg.Msg;
       /* See if this message type is present in the table */
       MsgMemoryEntry = FindMsgMemory(Info.Msg.message);
       if (NULL == MsgMemoryEntry)
-        {
-          /* Not present, no copying needed */
-          Info.LParamSize = 0;
-        }
+      {
+         /* Not present, no copying needed */
+         Info.LParamSize = 0;
+      }
       else
-        {
-          /* Determine required size */
-          Size = MsgMemorySize(MsgMemoryEntry, Info.Msg.wParam,
-                               Info.Msg.lParam);
-          /* Allocate required amount of user-mode memory */
-          Info.LParamSize = Size;
-          UserMem = NULL;
-          Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &UserMem, 0,
-                                           &Info.LParamSize, MEM_COMMIT, PAGE_READWRITE);
-          if (! NT_SUCCESS(Status))
-            {
-              SetLastNtError(Status);
-              RETURN( (BOOL) -1);
-            }
-          /* Transfer lParam data to user-mode mem */
-          Status = MmCopyToCaller(UserMem, (PVOID) Info.Msg.lParam, Size);
-          if (! NT_SUCCESS(Status))
-            {
-              ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID *) &UserMem,
-                                  &Info.LParamSize, MEM_DECOMMIT);
-              SetLastNtError(Status);
-              RETURN( (BOOL) -1);
-            }
-          Info.Msg.lParam = (LPARAM) UserMem;
-        }
+      {
+         /* Determine required size */
+         Size = MsgMemorySize(MsgMemoryEntry, Info.Msg.wParam,
+                              Info.Msg.lParam);
+         /* Allocate required amount of user-mode memory */
+         Info.LParamSize = Size;
+         UserMem = NULL;
+         Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &UserMem, 0,
+                                          &Info.LParamSize, MEM_COMMIT, PAGE_READWRITE);
+         if (! NT_SUCCESS(Status))
+         {
+            SetLastNtError(Status);
+            RETURN( (BOOL) -1);
+         }
+         /* Transfer lParam data to user-mode mem */
+         Status = MmCopyToCaller(UserMem, (PVOID) Info.Msg.lParam, Size);
+         if (! NT_SUCCESS(Status))
+         {
+            ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID *) &UserMem,
+                                &Info.LParamSize, MEM_DECOMMIT);
+            SetLastNtError(Status);
+            RETURN( (BOOL) -1);
+         }
+         Info.Msg.lParam = (LPARAM) UserMem;
+      }
       if (RemoveMsg && Msg.FreeLParam && 0 != Msg.Msg.lParam)
-        {
-          ExFreePool((void *) Msg.Msg.lParam);
-        }
+      {
+         ExFreePool((void *) Msg.Msg.lParam);
+      }
       Status = MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERGETMESSAGEINFO));
       if (! NT_SUCCESS(Status))
-        {
-          SetLastNtError(Status);
-          RETURN( (BOOL) -1);
-        }
-    }
-
-  RETURN( Present);
-  
+      {
+         SetLastNtError(Status);
+         RETURN( (BOOL) -1);
+      }
+   }
+
+   RETURN( Present);
+
 CLEANUP:
-  DPRINT("Leave NtUserPeekMessage, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserPeekMessage, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 static BOOL FASTCALL
 co_IntWaitMessage(HWND Wnd,
-               UINT MsgFilterMin,
-               UINT MsgFilterMax)
+                  UINT MsgFilterMin,
+                  UINT MsgFilterMax)
 {
-  PUSER_MESSAGE_QUEUE ThreadQueue;
-  NTSTATUS Status;
-  USER_MESSAGE Msg;
+   PUSER_MESSAGE_QUEUE ThreadQueue;
+   NTSTATUS Status;
+   USER_MESSAGE Msg;
 
-  ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
+   ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
 
-  do
-    {
+   do
+   {
       if (co_IntPeekMessage(&Msg, Wnd, MsgFilterMin, MsgFilterMax, PM_NOREMOVE))
-       {
-         return TRUE;
-       }
+      {
+         return TRUE;
+      }
 
       /* Nothing found. Wait for new messages. */
       Status = co_MsqWaitForNewMessages(ThreadQueue, Wnd, MsgFilterMin, MsgFilterMax);
-    }
-  while ((STATUS_WAIT_0 <= Status && Status <= STATUS_WAIT_63) || STATUS_TIMEOUT == Status);
+   }
+   while ((STATUS_WAIT_0 <= Status && Status <= STATUS_WAIT_63) || STATUS_TIMEOUT == Status);
 
-  SetLastNtError(Status);
+   SetLastNtError(Status);
 
-  return FALSE;
+   return FALSE;
 }
 
 BOOL STDCALL
 NtUserGetMessage(PNTUSERGETMESSAGEINFO UnsafeInfo,
-                HWND Wnd,
-                UINT MsgFilterMin,
-                UINT MsgFilterMax)
+                 HWND Wnd,
+                 UINT MsgFilterMin,
+                 UINT MsgFilterMax)
 /*
  * FUNCTION: Get a message from the calling thread's message queue.
  * ARGUMENTS:
@@ -954,228 +959,228 @@ NtUserGetMessage(PNTUSERGETMESSAGEINFO UnsafeInfo,
  *                     retrieved.
  */
 {
-  BOOL GotMessage;
-  NTUSERGETMESSAGEINFO Info;
-  NTSTATUS Status;
-  PWINDOW_OBJECT Window;
-  PMSGMEMORY MsgMemoryEntry;
-  PVOID UserMem;
-  UINT Size;
-  USER_MESSAGE Msg;
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserGetMessage\n");
-  UserEnterExclusive();
-
-  /* Validate input */
-  if (NULL != Wnd)
-    {
+   BOOL GotMessage;
+   NTUSERGETMESSAGEINFO Info;
+   NTSTATUS Status;
+   PWINDOW_OBJECT Window;
+   PMSGMEMORY MsgMemoryEntry;
+   PVOID UserMem;
+   UINT Size;
+   USER_MESSAGE Msg;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserGetMessage\n");
+   UserEnterExclusive();
+
+   /* Validate input */
+   if (NULL != Wnd)
+   {
       Window = IntGetWindowObject(Wnd);
       if(!Window)
-        Wnd = NULL;
+         Wnd = NULL;
       else
-        IntReleaseWindowObject(Window);
-    }
-  if (MsgFilterMax < MsgFilterMin)
-    {
+         IntReleaseWindowObject(Window);
+   }
+   if (MsgFilterMax < MsgFilterMin)
+   {
       MsgFilterMin = 0;
       MsgFilterMax = 0;
-    }
+   }
 
-  do
-    {
+   do
+   {
       GotMessage = co_IntPeekMessage(&Msg, Wnd, MsgFilterMin, MsgFilterMax, PM_REMOVE);
       if (GotMessage)
-       {
-          Info.Msg = Msg.Msg;
-          /* See if this message type is present in the table */
-          MsgMemoryEntry = FindMsgMemory(Info.Msg.message);
-          if (NULL == MsgMemoryEntry)
-            {
-              /* Not present, no copying needed */
-              Info.LParamSize = 0;
-            }
-          else
+      {
+         Info.Msg = Msg.Msg;
+         /* See if this message type is present in the table */
+         MsgMemoryEntry = FindMsgMemory(Info.Msg.message);
+         if (NULL == MsgMemoryEntry)
+         {
+            /* Not present, no copying needed */
+            Info.LParamSize = 0;
+         }
+         else
+         {
+            /* Determine required size */
+            Size = MsgMemorySize(MsgMemoryEntry, Info.Msg.wParam,
+                                 Info.Msg.lParam);
+            /* Allocate required amount of user-mode memory */
+            Info.LParamSize = Size;
+            UserMem = NULL;
+            Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &UserMem, 0,
+                                             &Info.LParamSize, MEM_COMMIT, PAGE_READWRITE);
+
+            if (! NT_SUCCESS(Status))
             {
-              /* Determine required size */
-              Size = MsgMemorySize(MsgMemoryEntry, Info.Msg.wParam,
-                                   Info.Msg.lParam);
-              /* Allocate required amount of user-mode memory */
-              Info.LParamSize = Size;
-              UserMem = NULL;
-              Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &UserMem, 0,
-                                               &Info.LParamSize, MEM_COMMIT, PAGE_READWRITE);
-
-              if (! NT_SUCCESS(Status))
-                {
-                  SetLastNtError(Status);
-                  RETURN( (BOOL) -1);
-                }
-              /* Transfer lParam data to user-mode mem */
-              Status = MmCopyToCaller(UserMem, (PVOID) Info.Msg.lParam, Size);
-              if (! NT_SUCCESS(Status))
-                {
-                  ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID *) &UserMem,
-                                      &Info.LParamSize, MEM_DECOMMIT);
-                  SetLastNtError(Status);
-                  RETURN( (BOOL) -1);
-                }
-              Info.Msg.lParam = (LPARAM) UserMem;
+               SetLastNtError(Status);
+               RETURN( (BOOL) -1);
             }
-          if (Msg.FreeLParam && 0 != Msg.Msg.lParam)
+            /* Transfer lParam data to user-mode mem */
+            Status = MmCopyToCaller(UserMem, (PVOID) Info.Msg.lParam, Size);
+            if (! NT_SUCCESS(Status))
             {
-              ExFreePool((void *) Msg.Msg.lParam);
+               ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID *) &UserMem,
+                                   &Info.LParamSize, MEM_DECOMMIT);
+               SetLastNtError(Status);
+               RETURN( (BOOL) -1);
             }
-         Status = MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERGETMESSAGEINFO));
-         if (! NT_SUCCESS(Status))
-           {
-             SetLastNtError(Status);
-         RETURN( (BOOL) -1);
-           }
-       }
+            Info.Msg.lParam = (LPARAM) UserMem;
+         }
+         if (Msg.FreeLParam && 0 != Msg.Msg.lParam)
+         {
+            ExFreePool((void *) Msg.Msg.lParam);
+         }
+         Status = MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERGETMESSAGEINFO));
+         if (! NT_SUCCESS(Status))
+         {
+            SetLastNtError(Status);
+            RETURN( (BOOL) -1);
+         }
+      }
       else if (! co_IntWaitMessage(Wnd, MsgFilterMin, MsgFilterMax))
-        {
-          RETURN( (BOOL) -1);
-       }
-    }
-  while (! GotMessage);
-
-  RETURN( WM_QUIT != Info.Msg.message);
-  
+      {
+         RETURN( (BOOL) -1);
+      }
+   }
+   while (! GotMessage);
+
+   RETURN( WM_QUIT != Info.Msg.message);
+
 CLEANUP:
-  DPRINT("Leave NtUserGetMessage\n");
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetMessage\n");
+   UserLeave();
+   END_CLEANUP;
 }
 
 DWORD
 STDCALL
 NtUserMessageCall(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5,
-  DWORD Unknown6)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3,
+   DWORD Unknown4,
+   DWORD Unknown5,
+   DWORD Unknown6)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 static NTSTATUS FASTCALL
 CopyMsgToKernelMem(MSG *KernelModeMsg, MSG *UserModeMsg, PMSGMEMORY MsgMemoryEntry)
 {
-  NTSTATUS Status;
+   NTSTATUS Status;
 
-  PVOID KernelMem;
-  UINT Size;
+   PVOID KernelMem;
+   UINT Size;
 
-  *KernelModeMsg = *UserModeMsg;
+   *KernelModeMsg = *UserModeMsg;
 
-  /* See if this message type is present in the table */
-  if (NULL == MsgMemoryEntry)
-    {
+   /* See if this message type is present in the table */
+   if (NULL == MsgMemoryEntry)
+   {
       /* Not present, no copying needed */
       return STATUS_SUCCESS;
-    }
+   }
 
-  /* Determine required size */
-  Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, UserModeMsg->lParam);
+   /* Determine required size */
+   Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, UserModeMsg->lParam);
 
-  if (0 != Size)
-    {
+   if (0 != Size)
+   {
       /* Allocate kernel mem */
       KernelMem = ExAllocatePoolWithTag(PagedPool, Size, TAG_MSG);
       if (NULL == KernelMem)
-        {
-          DPRINT1("Not enough memory to copy message to kernel mem\n");
-          return STATUS_NO_MEMORY;
-        }
+      {
+         DPRINT1("Not enough memory to copy message to kernel mem\n");
+         return STATUS_NO_MEMORY;
+      }
       KernelModeMsg->lParam = (LPARAM) KernelMem;
 
       /* Copy data if required */
       if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_READ))
-        {
-          Status = MmCopyFromCaller(KernelMem, (PVOID) UserModeMsg->lParam, Size);
-          if (! NT_SUCCESS(Status))
-            {
-              DPRINT1("Failed to copy message to kernel: invalid usermode buffer\n");
-              ExFreePool(KernelMem);
-              return Status;
-            }
-        }
+      {
+         Status = MmCopyFromCaller(KernelMem, (PVOID) UserModeMsg->lParam, Size);
+         if (! NT_SUCCESS(Status))
+         {
+            DPRINT1("Failed to copy message to kernel: invalid usermode buffer\n");
+            ExFreePool(KernelMem);
+            return Status;
+         }
+      }
       else
-        {
-          /* Make sure we don't pass any secrets to usermode */
-          RtlZeroMemory(KernelMem, Size);
-        }
-    }
-  else
-    {
+      {
+         /* Make sure we don't pass any secrets to usermode */
+         RtlZeroMemory(KernelMem, Size);
+      }
+   }
+   else
+   {
       KernelModeMsg->lParam = 0;
-    }
+   }
 
-  return STATUS_SUCCESS;
+   return STATUS_SUCCESS;
 }
 
 static NTSTATUS FASTCALL
 CopyMsgToUserMem(MSG *UserModeMsg, MSG *KernelModeMsg)
 {
-  NTSTATUS Status;
-  PMSGMEMORY MsgMemoryEntry;
-  UINT Size;
-
-  /* See if this message type is present in the table */
-  MsgMemoryEntry = FindMsgMemory(UserModeMsg->message);
-  if (NULL == MsgMemoryEntry)
-    {
+   NTSTATUS Status;
+   PMSGMEMORY MsgMemoryEntry;
+   UINT Size;
+
+   /* See if this message type is present in the table */
+   MsgMemoryEntry = FindMsgMemory(UserModeMsg->message);
+   if (NULL == MsgMemoryEntry)
+   {
       /* Not present, no copying needed */
       return STATUS_SUCCESS;
-    }
+   }
 
-  /* Determine required size */
-  Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, UserModeMsg->lParam);
+   /* Determine required size */
+   Size = MsgMemorySize(MsgMemoryEntry, UserModeMsg->wParam, UserModeMsg->lParam);
 
-  if (0 != Size)
-    {
+   if (0 != Size)
+   {
       /* Copy data if required */
       if (0 != (MsgMemoryEntry->Flags & MMS_FLAG_WRITE))
-        {
-          Status = MmCopyToCaller((PVOID) UserModeMsg->lParam, (PVOID) KernelModeMsg->lParam, Size);
-          if (! NT_SUCCESS(Status))
-            {
-              DPRINT1("Failed to copy message from kernel: invalid usermode buffer\n");
-              ExFreePool((PVOID) KernelModeMsg->lParam);
-              return Status;
-            }
-        }
+      {
+         Status = MmCopyToCaller((PVOID) UserModeMsg->lParam, (PVOID) KernelModeMsg->lParam, Size);
+         if (! NT_SUCCESS(Status))
+         {
+            DPRINT1("Failed to copy message from kernel: invalid usermode buffer\n");
+            ExFreePool((PVOID) KernelModeMsg->lParam);
+            return Status;
+         }
+      }
 
       ExFreePool((PVOID) KernelModeMsg->lParam);
-    }
+   }
 
-  return STATUS_SUCCESS;
+   return STATUS_SUCCESS;
 }
 
 BOOL FASTCALL
 UserPostMessage(HWND Wnd,
-                 UINT Msg,
-                 WPARAM wParam,
-                 LPARAM lParam)
+                UINT Msg,
+                WPARAM wParam,
+                LPARAM lParam)
 {
-  PWINDOW_OBJECT Window;
-  MSG UserModeMsg, KernelModeMsg;
-  LARGE_INTEGER LargeTickCount;
-  NTSTATUS Status;
-  PMSGMEMORY MsgMemoryEntry;
-
-  if (WM_QUIT == Msg)
-    {
+   PWINDOW_OBJECT Window;
+   MSG UserModeMsg, KernelModeMsg;
+   LARGE_INTEGER LargeTickCount;
+   NTSTATUS Status;
+   PMSGMEMORY MsgMemoryEntry;
+
+   if (WM_QUIT == Msg)
+   {
       MsqPostQuitMessage(PsGetWin32Thread()->MessageQueue, wParam);
-    }
-  else if (Wnd == HWND_BROADCAST)
-    {
+   }
+   else if (Wnd == HWND_BROADCAST)
+   {
       HWND *List;
       PWINDOW_OBJECT DesktopWindow;
       ULONG i;
@@ -1184,26 +1189,26 @@ UserPostMessage(HWND Wnd,
       List = IntWinListChildren(DesktopWindow);
       IntReleaseWindowObject(DesktopWindow);
       if (List != NULL)
-        {
-          for (i = 0; List[i]; i++)
+      {
+         for (i = 0; List[i]; i++)
             UserPostMessage(List[i], Msg, wParam, lParam);
-          ExFreePool(List);
-        }
-    }
-  else
-    {
+         ExFreePool(List);
+      }
+   }
+   else
+   {
       Window = IntGetWindowObject(Wnd);
       if (NULL == Window)
-        {
-          SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-          return FALSE;
-        }
+      {
+         SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+         return FALSE;
+      }
       if(Window->Status & WINDOWSTATUS_DESTROYING)
       {
-        IntReleaseWindowObject(Window);
-        DPRINT1("Attempted to post message to window 0x%x that is being destroyed!\n", Wnd);
-        /* FIXME - last error code? */
-        return FALSE;
+         IntReleaseWindowObject(Window);
+         DPRINT1("Attempted to post message to window 0x%x that is being destroyed!\n", Wnd);
+         /* FIXME - last error code? */
+         return FALSE;
       }
 
       UserModeMsg.hwnd = Wnd;
@@ -1213,10 +1218,10 @@ UserPostMessage(HWND Wnd,
       MsgMemoryEntry = FindMsgMemory(UserModeMsg.message);
       Status = CopyMsgToKernelMem(&KernelModeMsg, &UserModeMsg, MsgMemoryEntry);
       if (! NT_SUCCESS(Status))
-        {
-          SetLastWin32Error(ERROR_INVALID_PARAMETER);
-          return FALSE;
-        }
+      {
+         SetLastWin32Error(ERROR_INVALID_PARAMETER);
+         return FALSE;
+      }
       IntGetCursorLocation(PsGetWin32Thread()->Desktop->WindowStation,
                            &KernelModeMsg.pt);
       KeQueryTickCount(&LargeTickCount);
@@ -1225,17 +1230,17 @@ UserPostMessage(HWND Wnd,
                      NULL != MsgMemoryEntry && 0 != KernelModeMsg.lParam,
                      QS_POSTMESSAGE);
       IntReleaseWindowObject(Window);
-    }
+   }
 
-  return TRUE;
+   return TRUE;
 }
 
 
 BOOL STDCALL
 NtUserPostMessage(HWND hWnd,
-        UINT Msg,
-        WPARAM wParam,
-        LPARAM lParam)
+                  UINT Msg,
+                  WPARAM wParam,
+                  LPARAM lParam)
 {
    DECLARE_RETURN(BOOL);
 
@@ -1254,233 +1259,236 @@ CLEANUP:
 
 BOOL STDCALL
 NtUserPostThreadMessage(DWORD idThread,
-                       UINT Msg,
-                       WPARAM wParam,
-                       LPARAM lParam)
+                        UINT Msg,
+                        WPARAM wParam,
+                        LPARAM lParam)
 {
-  MSG UserModeMsg, KernelModeMsg;
-  PETHREAD peThread;
-  PW32THREAD pThread;
-  NTSTATUS Status;
-  PMSGMEMORY MsgMemoryEntry;
-  DECLARE_RETURN(BOOL);
+   MSG UserModeMsg, KernelModeMsg;
+   PETHREAD peThread;
+   PW32THREAD pThread;
+   NTSTATUS Status;
+   PMSGMEMORY MsgMemoryEntry;
+   DECLARE_RETURN(BOOL);
 
-  DPRINT("Enter NtUserPostThreadMessage\n");
-  UserEnterExclusive();
+   DPRINT("Enter NtUserPostThreadMessage\n");
+   UserEnterExclusive();
 
-  Status = PsLookupThreadByThreadId((HANDLE)idThread,&peThread);
+   Status = PsLookupThreadByThreadId((HANDLE)idThread,&peThread);
 
-  if( Status == STATUS_SUCCESS ) {
-    pThread = peThread->Tcb.Win32Thread;
-    if( !pThread || !pThread->MessageQueue )
+   if( Status == STATUS_SUCCESS )
+   {
+      pThread = peThread->Tcb.Win32Thread;
+      if( !pThread || !pThread->MessageQueue )
       {
-       ObDereferenceObject( peThread );
-   RETURN( FALSE);
+         ObDereferenceObject( peThread );
+         RETURN( FALSE);
       }
 
-    UserModeMsg.hwnd = NULL;
-    UserModeMsg.message = Msg;
-    UserModeMsg.wParam = wParam;
-    UserModeMsg.lParam = lParam;
-    MsgMemoryEntry = FindMsgMemory(UserModeMsg.message);
-    Status = CopyMsgToKernelMem(&KernelModeMsg, &UserModeMsg, MsgMemoryEntry);
-    if (! NT_SUCCESS(Status))
+      UserModeMsg.hwnd = NULL;
+      UserModeMsg.message = Msg;
+      UserModeMsg.wParam = wParam;
+      UserModeMsg.lParam = lParam;
+      MsgMemoryEntry = FindMsgMemory(UserModeMsg.message);
+      Status = CopyMsgToKernelMem(&KernelModeMsg, &UserModeMsg, MsgMemoryEntry);
+      if (! NT_SUCCESS(Status))
       {
-        ObDereferenceObject( peThread );
-       SetLastWin32Error(ERROR_INVALID_PARAMETER);
-        RETURN( FALSE);
+         ObDereferenceObject( peThread );
+         SetLastWin32Error(ERROR_INVALID_PARAMETER);
+         RETURN( FALSE);
       }
-    MsqPostMessage(pThread->MessageQueue, &KernelModeMsg,
-                   NULL != MsgMemoryEntry && 0 != KernelModeMsg.lParam,
-                   QS_POSTMESSAGE);
-    ObDereferenceObject( peThread );
-    RETURN( TRUE);
-  } else {
-    SetLastNtError( Status );
-    RETURN( FALSE);
-  }
-  
+      MsqPostMessage(pThread->MessageQueue, &KernelModeMsg,
+                     NULL != MsgMemoryEntry && 0 != KernelModeMsg.lParam,
+                     QS_POSTMESSAGE);
+      ObDereferenceObject( peThread );
+      RETURN( TRUE);
+   }
+   else
+   {
+      SetLastNtError( Status );
+      RETURN( FALSE);
+   }
+
 CLEANUP:
-  DPRINT("Leave NtUserPostThreadMessage, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserPostThreadMessage, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 DWORD STDCALL
 NtUserQuerySendMessage(DWORD Unknown0)
 {
-  UNIMPLEMENTED;
+   UNIMPLEMENTED;
 
-  return 0;
+   return 0;
 }
 
 LRESULT FASTCALL
 co_IntSendMessage(HWND hWnd,
-               UINT Msg,
-               WPARAM wParam,
-               LPARAM lParam)
+                  UINT Msg,
+                  WPARAM wParam,
+                  LPARAM lParam)
 {
-  ULONG_PTR Result = 0;
-  if(co_IntSendMessageTimeout(hWnd, Msg, wParam, lParam, SMTO_NORMAL, 0, &Result))
-  {
-    return (LRESULT)Result;
-  }
-  return 0;
+   ULONG_PTR Result = 0;
+   if(co_IntSendMessageTimeout(hWnd, Msg, wParam, lParam, SMTO_NORMAL, 0, &Result))
+   {
+      return (LRESULT)Result;
+   }
+   return 0;
 }
 
 static LRESULT FASTCALL
 co_IntSendMessageTimeoutSingle(HWND hWnd,
-                            UINT Msg,
-                            WPARAM wParam,
-                            LPARAM lParam,
-                            UINT uFlags,
-                            UINT uTimeout,
-                            ULONG_PTR *uResult)
+                               UINT Msg,
+                               WPARAM wParam,
+                               LPARAM lParam,
+                               UINT uFlags,
+                               UINT uTimeout,
+                               ULONG_PTR *uResult)
 {
-  ULONG_PTR Result;
-  NTSTATUS Status;
-  PWINDOW_OBJECT Window;
-  PMSGMEMORY MsgMemoryEntry;
-  INT lParamBufferSize;
-  LPARAM lParamPacked;
-  PW32THREAD Win32Thread;
-
-  /* FIXME: Call hooks. */
-  Window = IntGetWindowObject(hWnd);
-  if (!Window)
-    {
+   ULONG_PTR Result;
+   NTSTATUS Status;
+   PWINDOW_OBJECT Window;
+   PMSGMEMORY MsgMemoryEntry;
+   INT lParamBufferSize;
+   LPARAM lParamPacked;
+   PW32THREAD Win32Thread;
+
+   /* FIXME: Call hooks. */
+   Window = IntGetWindowObject(hWnd);
+   if (!Window)
+   {
       SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
       return FALSE;
-    }
+   }
 
-  Win32Thread = PsGetWin32Thread();
+   Win32Thread = PsGetWin32Thread();
 
-  if (NULL != Win32Thread &&
-      Window->MessageQueue == Win32Thread->MessageQueue)
-    {
+   if (NULL != Win32Thread &&
+         Window->MessageQueue == Win32Thread->MessageQueue)
+   {
       if (Win32Thread->IsExiting)
-        {
-          /* Never send messages to exiting threads */
-          IntReleaseWindowObject(Window);
-          return FALSE;
-        }
+      {
+         /* Never send messages to exiting threads */
+         IntReleaseWindowObject(Window);
+         return FALSE;
+      }
 
       /* See if this message type is present in the table */
       MsgMemoryEntry = FindMsgMemory(Msg);
       if (NULL == MsgMemoryEntry)
-        {
-          lParamBufferSize = -1;
-        }
+      {
+         lParamBufferSize = -1;
+      }
       else
-        {
-          lParamBufferSize = MsgMemorySize(MsgMemoryEntry, wParam, lParam);
-        }
+      {
+         lParamBufferSize = MsgMemorySize(MsgMemoryEntry, wParam, lParam);
+      }
 
       if (! NT_SUCCESS(PackParam(&lParamPacked, Msg, wParam, lParam)))
-        {
-          IntReleaseWindowObject(Window);
-          DPRINT1("Failed to pack message parameters\n");
-          return FALSE;
-        }
+      {
+         IntReleaseWindowObject(Window);
+         DPRINT1("Failed to pack message parameters\n");
+         return FALSE;
+      }
       if (0xFFFF0000 != ((DWORD) Window->WndProcW & 0xFFFF0000))
-        {
-          Result = (ULONG_PTR)co_IntCallWindowProc(Window->WndProcW, FALSE, hWnd, Msg, wParam,
-                                                lParamPacked,lParamBufferSize);
-        }
+      {
+         Result = (ULONG_PTR)co_IntCallWindowProc(Window->WndProcW, FALSE, hWnd, Msg, wParam,
+                  lParamPacked,lParamBufferSize);
+      }
       else
-        {
-          Result = (ULONG_PTR)co_IntCallWindowProc(Window->WndProcA, TRUE, hWnd, Msg, wParam,
-                                                lParamPacked,lParamBufferSize);
-        }
+      {
+         Result = (ULONG_PTR)co_IntCallWindowProc(Window->WndProcA, TRUE, hWnd, Msg, wParam,
+                  lParamPacked,lParamBufferSize);
+      }
 
       if(uResult)
       {
-        *uResult = Result;
+         *uResult = Result;
       }
 
       if (! NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam)))
-        {
-          IntReleaseWindowObject(Window);
-          DPRINT1("Failed to unpack message parameters\n");
-          return TRUE;
-        }
+      {
+         IntReleaseWindowObject(Window);
+         DPRINT1("Failed to unpack message parameters\n");
+         return TRUE;
+      }
 
       IntReleaseWindowObject(Window);
       return TRUE;
-    }
-
-  if(uFlags & SMTO_ABORTIFHUNG && MsqIsHung(Window->MessageQueue))
-  {
-    IntReleaseWindowObject(Window);
-    /* FIXME - Set a LastError? */
-    return FALSE;
-  }
-
-  if(Window->Status & WINDOWSTATUS_DESTROYING)
-  {
-    IntReleaseWindowObject(Window);
-    /* FIXME - last error? */
-    DPRINT1("Attempted to send message to window 0x%x that is being destroyed!\n", hWnd);
-    return FALSE;
-  }
-
-  Status = co_MsqSendMessage(Window->MessageQueue, hWnd, Msg, wParam, lParam,
-                          uTimeout, (uFlags & SMTO_BLOCK), FALSE, uResult);
-  IntReleaseWindowObject(Window);
-  if (STATUS_TIMEOUT == Status)
-    {
+   }
+
+   if(uFlags & SMTO_ABORTIFHUNG && MsqIsHung(Window->MessageQueue))
+   {
+      IntReleaseWindowObject(Window);
+      /* FIXME - Set a LastError? */
+      return FALSE;
+   }
+
+   if(Window->Status & WINDOWSTATUS_DESTROYING)
+   {
+      IntReleaseWindowObject(Window);
+      /* FIXME - last error? */
+      DPRINT1("Attempted to send message to window 0x%x that is being destroyed!\n", hWnd);
+      return FALSE;
+   }
+
+   Status = co_MsqSendMessage(Window->MessageQueue, hWnd, Msg, wParam, lParam,
+                              uTimeout, (uFlags & SMTO_BLOCK), FALSE, uResult);
+   IntReleaseWindowObject(Window);
+   if (STATUS_TIMEOUT == Status)
+   {
       /* MSDN says GetLastError() should return 0 after timeout */
       SetLastWin32Error(0);
       return FALSE;
-    }
-  else if (! NT_SUCCESS(Status))
-    {
+   }
+   else if (! NT_SUCCESS(Status))
+   {
       SetLastNtError(Status);
       return FALSE;
-    }
+   }
 
-  return TRUE;
+   return TRUE;
 }
 
 LRESULT FASTCALL
 co_IntSendMessageTimeout(HWND hWnd,
-                      UINT Msg,
-                      WPARAM wParam,
-                      LPARAM lParam,
-                      UINT uFlags,
-                      UINT uTimeout,
-                      ULONG_PTR *uResult)
+                         UINT Msg,
+                         WPARAM wParam,
+                         LPARAM lParam,
+                         UINT uFlags,
+                         UINT uTimeout,
+                         ULONG_PTR *uResult)
 {
-  PWINDOW_OBJECT DesktopWindow;
-  HWND *Children;
-  HWND *Child;
+   PWINDOW_OBJECT DesktopWindow;
+   HWND *Children;
+   HWND *Child;
 
-  if (HWND_BROADCAST != hWnd)
-    {
+   if (HWND_BROADCAST != hWnd)
+   {
       return co_IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, uFlags, uTimeout, uResult);
-    }
+   }
 
-  DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
-  if (NULL == DesktopWindow)
-    {
+   DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
+   if (NULL == DesktopWindow)
+   {
       SetLastWin32Error(ERROR_INTERNAL_ERROR);
       return 0;
-    }
-  Children = IntWinListChildren(DesktopWindow);
-  IntReleaseWindowObject(DesktopWindow);
-  if (NULL == Children)
-    {
+   }
+   Children = IntWinListChildren(DesktopWindow);
+   IntReleaseWindowObject(DesktopWindow);
+   if (NULL == Children)
+   {
       return 0;
-    }
+   }
 
-  for (Child = Children; NULL != *Child; Child++)
-    {
+   for (Child = Children; NULL != *Child; Child++)
+   {
       co_IntSendMessageTimeoutSingle(*Child, Msg, wParam, lParam, uFlags, uTimeout, uResult);
-    }
+   }
 
-  ExFreePool(Children);
+   ExFreePool(Children);
 
-  return (LRESULT) TRUE;
+   return (LRESULT) TRUE;
 }
 
 
@@ -1489,117 +1497,117 @@ co_IntSendMessageTimeout(HWND hWnd,
    messages! */
 LRESULT FASTCALL
 co_IntPostOrSendMessage(HWND hWnd,
-                     UINT Msg,
-                     WPARAM wParam,
-                     LPARAM lParam)
+                        UINT Msg,
+                        WPARAM wParam,
+                        LPARAM lParam)
 {
-  ULONG_PTR Result;
-  PWINDOW_OBJECT Window;
-
-  if(hWnd == HWND_BROADCAST)
-  {
-    return 0;
-  }
-
-  Window = IntGetWindowObject(hWnd);
-  if(!Window)
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return 0;
-  }
-
-  if(Window->MessageQueue != PsGetWin32Thread()->MessageQueue)
-  {
-    Result = UserPostMessage(hWnd, Msg, wParam, lParam);
-  }
-  else
-  {
-    if(!co_IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, SMTO_NORMAL, 0, &Result))
-    {
-      Result = 0;
-    }
-  }
+   ULONG_PTR Result;
+   PWINDOW_OBJECT Window;
 
-  IntReleaseWindowObject(Window);
+   if(hWnd == HWND_BROADCAST)
+   {
+      return 0;
+   }
+
+   Window = IntGetWindowObject(hWnd);
+   if(!Window)
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      return 0;
+   }
 
-  return (LRESULT)Result;
+   if(Window->MessageQueue != PsGetWin32Thread()->MessageQueue)
+   {
+      Result = UserPostMessage(hWnd, Msg, wParam, lParam);
+   }
+   else
+   {
+      if(!co_IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, SMTO_NORMAL, 0, &Result))
+      {
+         Result = 0;
+      }
+   }
+
+   IntReleaseWindowObject(Window);
+
+   return (LRESULT)Result;
 }
 
 LRESULT FASTCALL
 co_IntDoSendMessage(HWND Wnd,
-                UINT Msg,
-                WPARAM wParam,
-                LPARAM lParam,
-                PDOSENDMESSAGE dsm,
-                PNTUSERSENDMESSAGEINFO UnsafeInfo)
+                    UINT Msg,
+                    WPARAM wParam,
+                    LPARAM lParam,
+                    PDOSENDMESSAGE dsm,
+                    PNTUSERSENDMESSAGEINFO UnsafeInfo)
 {
-  LRESULT Result = TRUE;
-  NTSTATUS Status;
-  PWINDOW_OBJECT Window;
-  NTUSERSENDMESSAGEINFO Info;
-  MSG UserModeMsg;
-  MSG KernelModeMsg;
-  PMSGMEMORY MsgMemoryEntry;
-
-  RtlZeroMemory(&Info, sizeof(NTUSERSENDMESSAGEINFO));
-
-  /* FIXME: Call hooks. */
-  if (HWND_BROADCAST != Wnd)
-    {
+   LRESULT Result = TRUE;
+   NTSTATUS Status;
+   PWINDOW_OBJECT Window;
+   NTUSERSENDMESSAGEINFO Info;
+   MSG UserModeMsg;
+   MSG KernelModeMsg;
+   PMSGMEMORY MsgMemoryEntry;
+
+   RtlZeroMemory(&Info, sizeof(NTUSERSENDMESSAGEINFO));
+
+   /* FIXME: Call hooks. */
+   if (HWND_BROADCAST != Wnd)
+   {
       Window = IntGetWindowObject(Wnd);
       if (NULL == Window)
-        {
-          /* Tell usermode to not touch this one */
-          Info.HandledByKernel = TRUE;
-          MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERSENDMESSAGEINFO));
-          SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-          return 0;
-        }
-    }
-
-  /* FIXME: Check for an exiting window. */
-
-  /* See if the current thread can handle the message */
-  if (HWND_BROADCAST != Wnd && NULL != PsGetWin32Thread() &&
-      Window->MessageQueue == PsGetWin32Thread()->MessageQueue)
-    {
+      {
+         /* Tell usermode to not touch this one */
+         Info.HandledByKernel = TRUE;
+         MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERSENDMESSAGEINFO));
+         SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+         return 0;
+      }
+   }
+
+   /* FIXME: Check for an exiting window. */
+
+   /* See if the current thread can handle the message */
+   if (HWND_BROADCAST != Wnd && NULL != PsGetWin32Thread() &&
+         Window->MessageQueue == PsGetWin32Thread()->MessageQueue)
+   {
       /* Gather the information usermode needs to call the window proc directly */
       Info.HandledByKernel = FALSE;
       if (0xFFFF0000 != ((DWORD) Window->WndProcW & 0xFFFF0000))
-        {
-          if (0xFFFF0000 != ((DWORD) Window->WndProcA & 0xFFFF0000))
-            {
-              /* Both Unicode and Ansi winprocs are real, see what usermode prefers */
-              Status = MmCopyFromCaller(&(Info.Ansi), &(UnsafeInfo->Ansi),
-                                        sizeof(BOOL));
-              if (! NT_SUCCESS(Status))
-                {
-                  Info.Ansi = ! Window->Unicode;
-                }
-              Info.Proc = (Info.Ansi ? Window->WndProcA : Window->WndProcW);
-            }
-          else
+      {
+         if (0xFFFF0000 != ((DWORD) Window->WndProcA & 0xFFFF0000))
+         {
+            /* Both Unicode and Ansi winprocs are real, see what usermode prefers */
+            Status = MmCopyFromCaller(&(Info.Ansi), &(UnsafeInfo->Ansi),
+                                      sizeof(BOOL));
+            if (! NT_SUCCESS(Status))
             {
-              /* Real Unicode winproc */
-              Info.Ansi = FALSE;
-              Info.Proc = Window->WndProcW;
+               Info.Ansi = ! Window->Unicode;
             }
-        }
+            Info.Proc = (Info.Ansi ? Window->WndProcA : Window->WndProcW);
+         }
+         else
+         {
+            /* Real Unicode winproc */
+            Info.Ansi = FALSE;
+            Info.Proc = Window->WndProcW;
+         }
+      }
       else
-        {
-          /* Must have real Ansi winproc */
-          Info.Ansi = TRUE;
-          Info.Proc = Window->WndProcA;
-        }
+      {
+         /* Must have real Ansi winproc */
+         Info.Ansi = TRUE;
+         Info.Proc = Window->WndProcA;
+      }
       IntReleaseWindowObject(Window);
-    }
-  else
-    {
+   }
+   else
+   {
       /* Must be handled by other thread */
       if (HWND_BROADCAST != Wnd)
-        {
-          IntReleaseWindowObject(Window);
-        }
+      {
+         IntReleaseWindowObject(Window);
+      }
       Info.HandledByKernel = TRUE;
       UserModeMsg.hwnd = Wnd;
       UserModeMsg.message = Msg;
@@ -1608,84 +1616,84 @@ co_IntDoSendMessage(HWND Wnd,
       MsgMemoryEntry = FindMsgMemory(UserModeMsg.message);
       Status = CopyMsgToKernelMem(&KernelModeMsg, &UserModeMsg, MsgMemoryEntry);
       if (! NT_SUCCESS(Status))
-        {
-          MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERSENDMESSAGEINFO));
-          SetLastWin32Error(ERROR_INVALID_PARAMETER);
-          return (dsm ? 0 : -1);
-        }
+      {
+         MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERSENDMESSAGEINFO));
+         SetLastWin32Error(ERROR_INVALID_PARAMETER);
+         return (dsm ? 0 : -1);
+      }
       if(!dsm)
       {
-        Result = co_IntSendMessage(KernelModeMsg.hwnd, KernelModeMsg.message,
-                                KernelModeMsg.wParam, KernelModeMsg.lParam);
+         Result = co_IntSendMessage(KernelModeMsg.hwnd, KernelModeMsg.message,
+                                    KernelModeMsg.wParam, KernelModeMsg.lParam);
       }
       else
       {
-        Result = co_IntSendMessageTimeout(KernelModeMsg.hwnd, KernelModeMsg.message,
-                                       KernelModeMsg.wParam, KernelModeMsg.lParam,
-                                       dsm->uFlags, dsm->uTimeout, &dsm->Result);
+         Result = co_IntSendMessageTimeout(KernelModeMsg.hwnd, KernelModeMsg.message,
+                                           KernelModeMsg.wParam, KernelModeMsg.lParam,
+                                           dsm->uFlags, dsm->uTimeout, &dsm->Result);
       }
       Status = CopyMsgToUserMem(&UserModeMsg, &KernelModeMsg);
       if (! NT_SUCCESS(Status))
-        {
-          MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERSENDMESSAGEINFO));
-          SetLastWin32Error(ERROR_INVALID_PARAMETER);
-          return(dsm ? 0 : -1);
-        }
-    }
-
-  Status = MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERSENDMESSAGEINFO));
-  if (! NT_SUCCESS(Status))
-    {
+      {
+         MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERSENDMESSAGEINFO));
+         SetLastWin32Error(ERROR_INVALID_PARAMETER);
+         return(dsm ? 0 : -1);
+      }
+   }
+
+   Status = MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERSENDMESSAGEINFO));
+   if (! NT_SUCCESS(Status))
+   {
       SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    }
+   }
 
-  return (LRESULT)Result;
+   return (LRESULT)Result;
 }
 
 LRESULT STDCALL
 NtUserSendMessageTimeout(HWND hWnd,
-                        UINT Msg,
-                        WPARAM wParam,
-                        LPARAM lParam,
-                        UINT uFlags,
-                        UINT uTimeout,
-                        ULONG_PTR *uResult,
-                        PNTUSERSENDMESSAGEINFO UnsafeInfo)
+                         UINT Msg,
+                         WPARAM wParam,
+                         LPARAM lParam,
+                         UINT uFlags,
+                         UINT uTimeout,
+                         ULONG_PTR *uResult,
+                         PNTUSERSENDMESSAGEINFO UnsafeInfo)
 {
-  DOSENDMESSAGE dsm;
-  LRESULT Result;
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserSendMessageTimeout\n");
-  UserEnterExclusive();
-
-  dsm.uFlags = uFlags;
-  dsm.uTimeout = uTimeout;
-  Result = co_IntDoSendMessage(hWnd, Msg, wParam, lParam, &dsm, UnsafeInfo);
-  if(uResult != NULL && Result != 0)
-  {
-    NTSTATUS Status;
-
-    Status = MmCopyToCaller(uResult, &dsm.Result, sizeof(ULONG_PTR));
-    if(!NT_SUCCESS(Status))
-    {
-      SetLastWin32Error(ERROR_INVALID_PARAMETER);
-      RETURN( FALSE);
-    }
-  }
-  RETURN( Result);
-  
+   DOSENDMESSAGE dsm;
+   LRESULT Result;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserSendMessageTimeout\n");
+   UserEnterExclusive();
+
+   dsm.uFlags = uFlags;
+   dsm.uTimeout = uTimeout;
+   Result = co_IntDoSendMessage(hWnd, Msg, wParam, lParam, &dsm, UnsafeInfo);
+   if(uResult != NULL && Result != 0)
+   {
+      NTSTATUS Status;
+
+      Status = MmCopyToCaller(uResult, &dsm.Result, sizeof(ULONG_PTR));
+      if(!NT_SUCCESS(Status))
+      {
+         SetLastWin32Error(ERROR_INVALID_PARAMETER);
+         RETURN( FALSE);
+      }
+   }
+   RETURN( Result);
+
 CLEANUP:
-  DPRINT("Leave NtUserSendMessageTimeout, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserSendMessageTimeout, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 LRESULT STDCALL
 NtUserSendMessage(HWND Wnd,
-                 UINT Msg,
-                 WPARAM wParam,
-                 LPARAM lParam,
+                  UINT Msg,
+                  WPARAM wParam,
+                  LPARAM lParam,
                   PNTUSERSENDMESSAGEINFO UnsafeInfo)
 {
    DECLARE_RETURN(BOOL);
@@ -1698,31 +1706,31 @@ NtUserSendMessage(HWND Wnd,
 CLEANUP:
    DPRINT("Leave NtUserSendMessage, ret=%i\n",_ret_);
    UserLeave();
-   END_CLEANUP;   
+   END_CLEANUP;
 }
 
 BOOL STDCALL
 NtUserSendMessageCallback(HWND hWnd,
-                         UINT Msg,
-                         WPARAM wParam,
-                         LPARAM lParam,
-                         SENDASYNCPROC lpCallBack,
-                         ULONG_PTR dwData)
+                          UINT Msg,
+                          WPARAM wParam,
+                          LPARAM lParam,
+                          SENDASYNCPROC lpCallBack,
+                          ULONG_PTR dwData)
 {
-  UNIMPLEMENTED;
+   UNIMPLEMENTED;
 
-  return 0;
+   return 0;
 }
 
 BOOL STDCALL
 NtUserSendNotifyMessage(HWND hWnd,
-                       UINT Msg,
-                       WPARAM wParam,
-                       LPARAM lParam)
+                        UINT Msg,
+                        WPARAM wParam,
+                        LPARAM lParam)
 {
-  UNIMPLEMENTED;
+   UNIMPLEMENTED;
 
-  return 0;
+   return 0;
 }
 
 BOOL STDCALL
@@ -1734,7 +1742,7 @@ NtUserWaitMessage(VOID)
    UserEnterExclusive();
 
    RETURN(co_IntWaitMessage(NULL, 0, 0));
-  
+
 CLEANUP:
    DPRINT("Leave NtUserWaitMessage, ret=%i\n",_ret_);
    UserLeave();
@@ -1760,29 +1768,29 @@ NtUserGetQueueStatus(BOOL ClearChanges)
    }
 
    RETURN( Result);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserGetQueueStatus, ret=%i\n",_ret_);
    UserLeave();
-   END_CLEANUP;   
+   END_CLEANUP;
 }
 
 BOOL STDCALL
 IntInitMessagePumpHook()
 {
-       PsGetCurrentThread()->Tcb.Win32Thread->MessagePumpHookValue++;
-       return TRUE;
+   PsGetCurrentThread()->Tcb.Win32Thread->MessagePumpHookValue++;
+   return TRUE;
 }
 
 BOOL STDCALL
 IntUninitMessagePumpHook()
 {
-       if (PsGetCurrentThread()->Tcb.Win32Thread->MessagePumpHookValue <= 0)
-       {
-               return FALSE;
-       }
-       PsGetCurrentThread()->Tcb.Win32Thread->MessagePumpHookValue--;
-       return TRUE;
+   if (PsGetCurrentThread()->Tcb.Win32Thread->MessagePumpHookValue <= 0)
+   {
+      return FALSE;
+   }
+   PsGetCurrentThread()->Tcb.Win32Thread->MessagePumpHookValue--;
+   return TRUE;
 }
 
 /* EOF */
index 1c620cc..4e6c3b6 100644 (file)
 ULONG FASTCALL
 UserGetSystemMetrics(ULONG Index)
 {
-  NTSTATUS Status;
-  PWINSTATION_OBJECT WinStaObject;
-  ULONG Width, Height, Result;
-
-  Result = 0;
-  switch (Index)
-    {
-    case SM_ARRANGE:
-      return(8);
-    case SM_CLEANBOOT:
-      return(0);
-    case SM_CMOUSEBUTTONS:
-      return(2);
-    case SM_CXBORDER:
-    case SM_CYBORDER:
-      return(1);
-    case SM_CXCURSOR:
-    case SM_CYCURSOR:
-      return(32);
-    case SM_CXDLGFRAME:
-    case SM_CYDLGFRAME:
-      return(3);
-    case SM_CXDOUBLECLK:
-    case SM_CYDOUBLECLK:
-    case SM_SWAPBUTTON:
-    {
-      PSYSTEM_CURSORINFO CurInfo;
-      Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
-                                              KernelMode,
-                                              0,
-                                              &WinStaObject);
-      if (!NT_SUCCESS(Status))
-        return 0xFFFFFFFF;
-
-      CurInfo = IntGetSysCursorInfo(WinStaObject);
-      switch(Index)
-      {
-        case SM_CXDOUBLECLK:
-          Result = CurInfo->DblClickWidth;
-          break;
-        case SM_CYDOUBLECLK:
-          Result = CurInfo->DblClickWidth;
-          break;
-        case SM_SWAPBUTTON:
-          Result = (UINT)CurInfo->SwapButtons;
-          break;
-      }
-
-      ObDereferenceObject(WinStaObject);
-      return Result;
-    }
-
-    case SM_CXDRAG:
-    case SM_CYDRAG:
-      return(2);
-    case SM_CXEDGE:
-    case SM_CYEDGE:
-      return(2);
-    case SM_CXFRAME:
-    case SM_CYFRAME:
-      return(4);
-    case SM_CXFULLSCREEN:
-      /* FIXME: shouldn't we take borders etc into account??? */
-      return UserGetSystemMetrics(SM_CXSCREEN);
-    case SM_CYFULLSCREEN:
-      return UserGetSystemMetrics(SM_CYSCREEN);
-    case SM_CXHSCROLL:
-    case SM_CYHSCROLL:
-      return(16);
-    case SM_CYVTHUMB:
-    case SM_CXHTHUMB:
-      return(16);
-    case SM_CXICON:
-    case SM_CYICON:
-      return(32);
-    case SM_CXICONSPACING:
-    case SM_CYICONSPACING:
-      return(64);
-    case SM_CXMAXIMIZED:
-      return(UserGetSystemMetrics(SM_CXSCREEN) + 8); /* This seems to be 8
-                                                          pixels greater than
-                                                          the screen width */
-    case SM_CYMAXIMIZED:
-      return(UserGetSystemMetrics(SM_CYSCREEN) - 20); /* This seems to be 20
-                                                           pixels less than
-                                                           the screen height,
-                                                           taskbar maybe? */
-    case SM_CXMAXTRACK:
-      return(UserGetSystemMetrics(SM_CYSCREEN) + 12);
-    case SM_CYMAXTRACK:
-      return(UserGetSystemMetrics(SM_CYSCREEN) + 12);
-    case SM_CXMENUCHECK:
-    case SM_CYMENUCHECK:
-      return(13);
-    case SM_CXMENUSIZE:
-    case SM_CYMENUSIZE:
-      return(18);
-    case SM_CXMIN:
-      return(112);
-    case SM_CYMIN:
-      return(27);
-    case SM_CXMINIMIZED:
-      return(160);
-    case SM_CYMINIMIZED:
-      return(24);
-    case SM_CXMINSPACING:
-      return(160);
-    case SM_CYMINSPACING:
-      return(24);
-    case SM_CXMINTRACK:
-      return(112);
-    case SM_CYMINTRACK:
-      return(27);
-    case SM_CXSCREEN:
-    case SM_CYSCREEN:
-    {
-      HDC ScreenDCHandle;
-      PDC ScreenDC;
-
-      Width = 640;
-      Height = 480;
-      ScreenDCHandle = IntGdiCreateDC(NULL, NULL, NULL, NULL, TRUE);
-      if (NULL != ScreenDCHandle)
-      {
-       ScreenDC = DC_LockDc(ScreenDCHandle);
-       if (NULL != ScreenDC)
-       {
-         Width = ScreenDC->GDIInfo->ulHorzRes;
-         Height = ScreenDC->GDIInfo->ulVertRes;
-         DC_UnlockDc(ScreenDC);
-       }
-       NtGdiDeleteDC(ScreenDCHandle);
-      }
-      return SM_CXSCREEN == Index ? Width : Height;
-    }
-    case SM_CXSIZE:
-    case SM_CYSIZE:
-      return(18);
-    case SM_CXSMICON:
-    case SM_CYSMICON:
-      return(16);
-    case SM_CXSMSIZE:
-      return(12);
-    case SM_CYSMSIZE:
-      return(14);
-    case SM_CXVSCROLL:
-    case SM_CYVSCROLL:
-      return(16);
-    case SM_CYCAPTION:
-      return(19);
-    case SM_CYKANJIWINDOW:
-      return 0;
-    case SM_CYMENU:
-      return(19);
-    case SM_CYSMCAPTION:
-      return(15);
-    case SM_DBCSENABLED:
-    case SM_DEBUG:
-    case SM_MENUDROPALIGNMENT:
-    case SM_MIDEASTENABLED:
-      return(0);
-    case SM_MOUSEPRESENT:
-      return(1);
-    case SM_NETWORK:
-      return(3);
-    case SM_PENWINDOWS:
-    case SM_SECURE:
-    case SM_SHOWSOUNDS:
-    case SM_SLOWMACHINE:
-      return(0);
-    case SM_CMONITORS:
-      return(1);
-
-    default:
-      return(0xFFFFFFFF);
-    }
+   NTSTATUS Status;
+   PWINSTATION_OBJECT WinStaObject;
+   ULONG Width, Height, Result;
+
+   Result = 0;
+   switch (Index)
+   {
+      case SM_ARRANGE:
+         return(8);
+      case SM_CLEANBOOT:
+         return(0);
+      case SM_CMOUSEBUTTONS:
+         return(2);
+      case SM_CXBORDER:
+      case SM_CYBORDER:
+         return(1);
+      case SM_CXCURSOR:
+      case SM_CYCURSOR:
+         return(32);
+      case SM_CXDLGFRAME:
+      case SM_CYDLGFRAME:
+         return(3);
+      case SM_CXDOUBLECLK:
+      case SM_CYDOUBLECLK:
+      case SM_SWAPBUTTON:
+         {
+            PSYSTEM_CURSORINFO CurInfo;
+            Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
+                                                    KernelMode,
+                                                    0,
+                                                    &WinStaObject);
+            if (!NT_SUCCESS(Status))
+               return 0xFFFFFFFF;
+
+            CurInfo = IntGetSysCursorInfo(WinStaObject);
+            switch(Index)
+            {
+               case SM_CXDOUBLECLK:
+                  Result = CurInfo->DblClickWidth;
+                  break;
+               case SM_CYDOUBLECLK:
+                  Result = CurInfo->DblClickWidth;
+                  break;
+               case SM_SWAPBUTTON:
+                  Result = (UINT)CurInfo->SwapButtons;
+                  break;
+            }
+
+            ObDereferenceObject(WinStaObject);
+            return Result;
+         }
+
+      case SM_CXDRAG:
+      case SM_CYDRAG:
+         return(2);
+      case SM_CXEDGE:
+      case SM_CYEDGE:
+         return(2);
+      case SM_CXFRAME:
+      case SM_CYFRAME:
+         return(4);
+      case SM_CXFULLSCREEN:
+         /* FIXME: shouldn't we take borders etc into account??? */
+         return UserGetSystemMetrics(SM_CXSCREEN);
+      case SM_CYFULLSCREEN:
+         return UserGetSystemMetrics(SM_CYSCREEN);
+      case SM_CXHSCROLL:
+      case SM_CYHSCROLL:
+         return(16);
+      case SM_CYVTHUMB:
+      case SM_CXHTHUMB:
+         return(16);
+      case SM_CXICON:
+      case SM_CYICON:
+         return(32);
+      case SM_CXICONSPACING:
+      case SM_CYICONSPACING:
+         return(64);
+      case SM_CXMAXIMIZED:
+         return(UserGetSystemMetrics(SM_CXSCREEN) + 8); /* This seems to be 8
+                                                                   pixels greater than
+                                                                   the screen width */
+      case SM_CYMAXIMIZED:
+         return(UserGetSystemMetrics(SM_CYSCREEN) - 20); /* This seems to be 20
+                                                                    pixels less than
+                                                                    the screen height,
+                                                                    taskbar maybe? */
+      case SM_CXMAXTRACK:
+         return(UserGetSystemMetrics(SM_CYSCREEN) + 12);
+      case SM_CYMAXTRACK:
+         return(UserGetSystemMetrics(SM_CYSCREEN) + 12);
+      case SM_CXMENUCHECK:
+      case SM_CYMENUCHECK:
+         return(13);
+      case SM_CXMENUSIZE:
+      case SM_CYMENUSIZE:
+         return(18);
+      case SM_CXMIN:
+         return(112);
+      case SM_CYMIN:
+         return(27);
+      case SM_CXMINIMIZED:
+         return(160);
+      case SM_CYMINIMIZED:
+         return(24);
+      case SM_CXMINSPACING:
+         return(160);
+      case SM_CYMINSPACING:
+         return(24);
+      case SM_CXMINTRACK:
+         return(112);
+      case SM_CYMINTRACK:
+         return(27);
+      case SM_CXSCREEN:
+      case SM_CYSCREEN:
+         {
+            HDC ScreenDCHandle;
+            PDC ScreenDC;
+
+            Width = 640;
+            Height = 480;
+            ScreenDCHandle = IntGdiCreateDC(NULL, NULL, NULL, NULL, TRUE);
+            if (NULL != ScreenDCHandle)
+            {
+               ScreenDC = DC_LockDc(ScreenDCHandle);
+               if (NULL != ScreenDC)
+               {
+                  Width = ScreenDC->GDIInfo->ulHorzRes;
+                  Height = ScreenDC->GDIInfo->ulVertRes;
+                  DC_UnlockDc(ScreenDC);
+               }
+               NtGdiDeleteDC(ScreenDCHandle);
+            }
+            return SM_CXSCREEN == Index ? Width : Height;
+         }
+      case SM_CXSIZE:
+      case SM_CYSIZE:
+         return(18);
+      case SM_CXSMICON:
+      case SM_CYSMICON:
+         return(16);
+      case SM_CXSMSIZE:
+         return(12);
+      case SM_CYSMSIZE:
+         return(14);
+      case SM_CXVSCROLL:
+      case SM_CYVSCROLL:
+         return(16);
+      case SM_CYCAPTION:
+         return(19);
+      case SM_CYKANJIWINDOW:
+         return 0;
+      case SM_CYMENU:
+         return(19);
+      case SM_CYSMCAPTION:
+         return(15);
+      case SM_DBCSENABLED:
+      case SM_DEBUG:
+      case SM_MENUDROPALIGNMENT:
+      case SM_MIDEASTENABLED:
+         return(0);
+      case SM_MOUSEPRESENT:
+         return(1);
+      case SM_NETWORK:
+         return(3);
+      case SM_PENWINDOWS:
+      case SM_SECURE:
+      case SM_SHOWSOUNDS:
+      case SM_SLOWMACHINE:
+         return(0);
+      case SM_CMONITORS:
+         return(1);
+
+      default:
+         return(0xFFFFFFFF);
+   }
 }
 
 
@@ -224,16 +224,16 @@ UserGetSystemMetrics(ULONG Index)
 ULONG STDCALL
 NtUserGetSystemMetrics(ULONG Index)
 {
-  DECLARE_RETURN(ULONG);  
+   DECLARE_RETURN(ULONG);
 
-  DPRINT("Enter NtUserGetSystemMetrics\n");
-  UserEnterExclusive();
+   DPRINT("Enter NtUserGetSystemMetrics\n");
+   UserEnterExclusive();
 
-  RETURN(UserGetSystemMetrics(Index));
+   RETURN(UserGetSystemMetrics(Index));
 
 CLEANUP:
-  DPRINT("Leave NtUserGetSystemMetrics, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetSystemMetrics, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 /* EOF */
index 6339d71..8f423d0 100644 (file)
@@ -19,85 +19,89 @@ PW32PROCESS LogonProcess = NULL;
 
 VOID W32kRegisterPrimitiveMessageQueue(VOID)
 {
-  extern PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue;
-  if( !pmPrimitiveMessageQueue ) {
-    PW32THREAD pThread;
-    pThread = PsGetWin32Thread();
-    if( pThread && pThread->MessageQueue ) {
-      pmPrimitiveMessageQueue = pThread->MessageQueue;
-      IntReferenceMessageQueue(pmPrimitiveMessageQueue);
-      DPRINT( "Installed primitive input queue.\n" );
-    }
-  } else {
-    DPRINT1( "Alert! Someone is trying to steal the primitive queue.\n" );
-  }
+   extern PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue;
+   if( !pmPrimitiveMessageQueue )
+   {
+      PW32THREAD pThread;
+      pThread = PsGetWin32Thread();
+      if( pThread && pThread->MessageQueue )
+      {
+         pmPrimitiveMessageQueue = pThread->MessageQueue;
+         IntReferenceMessageQueue(pmPrimitiveMessageQueue);
+         DPRINT( "Installed primitive input queue.\n" );
+      }
+   }
+   else
+   {
+      DPRINT1( "Alert! Someone is trying to steal the primitive queue.\n" );
+   }
 }
 
 VOID W32kUnregisterPrimitiveMessageQueue(VOID)
 {
-  extern PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue;
-  IntDereferenceMessageQueue(pmPrimitiveMessageQueue);
-  pmPrimitiveMessageQueue = NULL;
+   extern PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue;
+   IntDereferenceMessageQueue(pmPrimitiveMessageQueue);
+   pmPrimitiveMessageQueue = NULL;
 }
 
 PUSER_MESSAGE_QUEUE W32kGetPrimitiveMessageQueue()
 {
-  extern PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue;
-  return pmPrimitiveMessageQueue;
+   extern PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue;
+   return pmPrimitiveMessageQueue;
 }
 
 BOOL FASTCALL
 co_IntRegisterLogonProcess(HANDLE ProcessId, BOOL Register)
 {
-  PEPROCESS Process;
-  NTSTATUS Status;
-  CSR_API_MESSAGE Request;
-
-  Status = PsLookupProcessByProcessId(ProcessId,
-                                     &Process);
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastWin32Error(RtlNtStatusToDosError(Status));
-    return FALSE;
-  }
-
-  if (Register)
-  {
-    /* Register the logon process */
-    if (LogonProcess != NULL)
-    {
-      ObDereferenceObject(Process);
-      return FALSE;
-    }
-
-    LogonProcess = (PW32PROCESS)Process->Win32Process;
-  }
-  else
-  {
-    /* Deregister the logon process */
-    if (LogonProcess != (PW32PROCESS)Process->Win32Process)
-    {
-      ObDereferenceObject(Process);
+   PEPROCESS Process;
+   NTSTATUS Status;
+   CSR_API_MESSAGE Request;
+
+   Status = PsLookupProcessByProcessId(ProcessId,
+                                       &Process);
+   if (!NT_SUCCESS(Status))
+   {
+      SetLastWin32Error(RtlNtStatusToDosError(Status));
       return FALSE;
-    }
+   }
+
+   if (Register)
+   {
+      /* Register the logon process */
+      if (LogonProcess != NULL)
+      {
+         ObDereferenceObject(Process);
+         return FALSE;
+      }
 
-    LogonProcess = NULL;
-  }
+      LogonProcess = (PW32PROCESS)Process->Win32Process;
+   }
+   else
+   {
+      /* Deregister the logon process */
+      if (LogonProcess != (PW32PROCESS)Process->Win32Process)
+      {
+         ObDereferenceObject(Process);
+         return FALSE;
+      }
 
-  ObDereferenceObject(Process);
+      LogonProcess = NULL;
+   }
 
-  Request.Type = MAKE_CSR_API(REGISTER_LOGON_PROCESS, CSR_GUI);
-  Request.Data.RegisterLogonProcessRequest.ProcessId = ProcessId;
-  Request.Data.RegisterLogonProcessRequest.Register = Register;
+   ObDereferenceObject(Process);
 
-  Status = co_CsrNotify(&Request);
-  if (! NT_SUCCESS(Status))
-  {
-    DPRINT1("Failed to register logon process with CSRSS\n");
-    return FALSE;
-  }
+   Request.Type = MAKE_CSR_API(REGISTER_LOGON_PROCESS, CSR_GUI);
+   Request.Data.RegisterLogonProcessRequest.ProcessId = ProcessId;
+   Request.Data.RegisterLogonProcessRequest.Register = Register;
 
-  return TRUE;
+   Status = co_CsrNotify(&Request);
+   if (! NT_SUCCESS(Status))
+   {
+      DPRINT1("Failed to register logon process with CSRSS\n");
+      return FALSE;
+   }
+
+   return TRUE;
 }
 
 /*
@@ -107,57 +111,57 @@ DWORD
 STDCALL
 NtUserCallNoParam(DWORD Routine)
 {
-  DWORD Result = 0;
-  DECLARE_RETURN(DWORD);
-  
-  DPRINT("Enter NtUserCallNoParam\n");
-  UserEnterExclusive();
-
-  switch(Routine)
-  {
-    case NOPARAM_ROUTINE_REGISTER_PRIMITIVE:
-      W32kRegisterPrimitiveMessageQueue();
-      Result = (DWORD)TRUE;
-      break;
-
-    case NOPARAM_ROUTINE_DESTROY_CARET:
-      Result = (DWORD)co_IntDestroyCaret(PsGetCurrentThread()->Tcb.Win32Thread);
-      break;
-
-    case NOPARAM_ROUTINE_INIT_MESSAGE_PUMP:
-      Result = (DWORD)IntInitMessagePumpHook();
-      break;
-
-    case NOPARAM_ROUTINE_UNINIT_MESSAGE_PUMP:
-      Result = (DWORD)IntUninitMessagePumpHook();
-      break;
-
-    case NOPARAM_ROUTINE_GETMESSAGEEXTRAINFO:
-      Result = (DWORD)MsqGetMessageExtraInfo();
-      break;
-
-    case NOPARAM_ROUTINE_ANYPOPUP:
-      Result = (DWORD)IntAnyPopup();
-      break;
-
-    case NOPARAM_ROUTINE_CSRSS_INITIALIZED:
-      Result = (DWORD)CsrInit();
-      break;
-
-    case NOPARAM_ROUTINE_MSQCLEARWAKEMASK:
-      RETURN( (DWORD)IntMsqClearWakeMask());
-
-    default:
-      DPRINT1("Calling invalid routine number 0x%x in NtUserCallNoParam\n", Routine);
-      SetLastWin32Error(ERROR_INVALID_PARAMETER);
-      break;
-  }
-  RETURN(Result);
-  
+   DWORD Result = 0;
+   DECLARE_RETURN(DWORD);
+
+   DPRINT("Enter NtUserCallNoParam\n");
+   UserEnterExclusive();
+
+   switch(Routine)
+   {
+      case NOPARAM_ROUTINE_REGISTER_PRIMITIVE:
+         W32kRegisterPrimitiveMessageQueue();
+         Result = (DWORD)TRUE;
+         break;
+
+      case NOPARAM_ROUTINE_DESTROY_CARET:
+         Result = (DWORD)co_IntDestroyCaret(PsGetCurrentThread()->Tcb.Win32Thread);
+         break;
+
+      case NOPARAM_ROUTINE_INIT_MESSAGE_PUMP:
+         Result = (DWORD)IntInitMessagePumpHook();
+         break;
+
+      case NOPARAM_ROUTINE_UNINIT_MESSAGE_PUMP:
+         Result = (DWORD)IntUninitMessagePumpHook();
+         break;
+
+      case NOPARAM_ROUTINE_GETMESSAGEEXTRAINFO:
+         Result = (DWORD)MsqGetMessageExtraInfo();
+         break;
+
+      case NOPARAM_ROUTINE_ANYPOPUP:
+         Result = (DWORD)IntAnyPopup();
+         break;
+
+      case NOPARAM_ROUTINE_CSRSS_INITIALIZED:
+         Result = (DWORD)CsrInit();
+         break;
+
+      case NOPARAM_ROUTINE_MSQCLEARWAKEMASK:
+         RETURN( (DWORD)IntMsqClearWakeMask());
+
+      default:
+         DPRINT1("Calling invalid routine number 0x%x in NtUserCallNoParam\n", Routine);
+         SetLastWin32Error(ERROR_INVALID_PARAMETER);
+         break;
+   }
+   RETURN(Result);
+
 CLEANUP:
-  DPRINT("Leave NtUserCallNoParam, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserCallNoParam, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 /*
@@ -166,211 +170,211 @@ CLEANUP:
 DWORD
 STDCALL
 NtUserCallOneParam(
-  DWORD Param,
-  DWORD Routine)
+   DWORD Param,
+   DWORD Routine)
 {
-  DECLARE_RETURN(DWORD);  
-
-  DPRINT("Enter NtUserCallOneParam\n");
-  UserEnterExclusive();
-   
-  switch(Routine)
-  {
-    case ONEPARAM_ROUTINE_GETMENU:
-    {
-      PWINDOW_OBJECT WindowObject;
-      DWORD Result;
-
-      WindowObject = IntGetWindowObject((HWND)Param);
-      if(!WindowObject)
-      {
-        SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-        RETURN( FALSE);
-      }
+   DECLARE_RETURN(DWORD);
 
-      Result = (DWORD)WindowObject->IDMenu;
+   DPRINT("Enter NtUserCallOneParam\n");
+   UserEnterExclusive();
 
-      IntReleaseWindowObject(WindowObject);
-      RETURN( Result);
-    }
+   switch(Routine)
+   {
+      case ONEPARAM_ROUTINE_GETMENU:
+         {
+            PWINDOW_OBJECT WindowObject;
+            DWORD Result;
 
-    case ONEPARAM_ROUTINE_ISWINDOWUNICODE:
-    {
-      PWINDOW_OBJECT WindowObject;
-      DWORD Result;
+            WindowObject = IntGetWindowObject((HWND)Param);
+            if(!WindowObject)
+            {
+               SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+               RETURN( FALSE);
+            }
 
-      WindowObject = IntGetWindowObject((HWND)Param);
-      if(!WindowObject)
-      {
-        SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-        RETURN( FALSE);
-      }
-      Result = WindowObject->Unicode;
-      IntReleaseWindowObject(WindowObject);
-      RETURN( Result);
-    }
+            Result = (DWORD)WindowObject->IDMenu;
 
-    case ONEPARAM_ROUTINE_WINDOWFROMDC:
-      RETURN( (DWORD)IntWindowFromDC((HDC)Param));
+            IntReleaseWindowObject(WindowObject);
+            RETURN( Result);
+         }
 
-    case ONEPARAM_ROUTINE_GETWNDCONTEXTHLPID:
-    {
-      PWINDOW_OBJECT WindowObject;
-      DWORD Result;
+      case ONEPARAM_ROUTINE_ISWINDOWUNICODE:
+         {
+            PWINDOW_OBJECT WindowObject;
+            DWORD Result;
 
-      WindowObject = IntGetWindowObject((HWND)Param);
-      if(!WindowObject)
-      {
-        SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-        RETURN( FALSE);
-      }
+            WindowObject = IntGetWindowObject((HWND)Param);
+            if(!WindowObject)
+            {
+               SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+               RETURN( FALSE);
+            }
+            Result = WindowObject->Unicode;
+            IntReleaseWindowObject(WindowObject);
+            RETURN( Result);
+         }
 
-      Result = WindowObject->ContextHelpId;
+      case ONEPARAM_ROUTINE_WINDOWFROMDC:
+         RETURN( (DWORD)IntWindowFromDC((HDC)Param));
 
-      IntReleaseWindowObject(WindowObject);
-      RETURN( Result);
-    }
+      case ONEPARAM_ROUTINE_GETWNDCONTEXTHLPID:
+         {
+            PWINDOW_OBJECT WindowObject;
+            DWORD Result;
 
-    case ONEPARAM_ROUTINE_SWAPMOUSEBUTTON:
-    {
-      PWINSTATION_OBJECT WinStaObject;
-      NTSTATUS Status;
-      DWORD Result;
+            WindowObject = IntGetWindowObject((HWND)Param);
+            if(!WindowObject)
+            {
+               SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+               RETURN( FALSE);
+            }
 
-      Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
-                                              KernelMode,
-                                              0,
-                                              &WinStaObject);
-      if (!NT_SUCCESS(Status))
-        RETURN( (DWORD)FALSE);
+            Result = WindowObject->ContextHelpId;
 
-      /* FIXME
-      Result = (DWORD)IntSwapMouseButton(WinStaObject, (BOOL)Param); */
-      Result = 0;
+            IntReleaseWindowObject(WindowObject);
+            RETURN( Result);
+         }
 
-      ObDereferenceObject(WinStaObject);
-      RETURN( Result);
-    }
+      case ONEPARAM_ROUTINE_SWAPMOUSEBUTTON:
+         {
+            PWINSTATION_OBJECT WinStaObject;
+            NTSTATUS Status;
+            DWORD Result;
 
-    case ONEPARAM_ROUTINE_SWITCHCARETSHOWING:
-      RETURN( (DWORD)IntSwitchCaretShowing((PVOID)Param));
+            Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
+                                                    KernelMode,
+                                                    0,
+                                                    &WinStaObject);
+            if (!NT_SUCCESS(Status))
+               RETURN( (DWORD)FALSE);
 
-    case ONEPARAM_ROUTINE_SETCARETBLINKTIME:
-      RETURN( (DWORD)IntSetCaretBlinkTime((UINT)Param));
+            /* FIXME
+            Result = (DWORD)IntSwapMouseButton(WinStaObject, (BOOL)Param); */
+            Result = 0;
 
-    case ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS:
-      RETURN( (DWORD)IntEnumClipboardFormats((UINT)Param));
+            ObDereferenceObject(WinStaObject);
+            RETURN( Result);
+         }
 
-    case ONEPARAM_ROUTINE_GETWINDOWINSTANCE:
-    {
-      PWINDOW_OBJECT WindowObject;
-      DWORD Result;
+      case ONEPARAM_ROUTINE_SWITCHCARETSHOWING:
+         RETURN( (DWORD)IntSwitchCaretShowing((PVOID)Param));
 
-      if(!(WindowObject = IntGetWindowObject((HWND)Param)))
-      {
-        SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-        RETURN( FALSE);
-      }
+      case ONEPARAM_ROUTINE_SETCARETBLINKTIME:
+         RETURN( (DWORD)IntSetCaretBlinkTime((UINT)Param));
 
-      Result = (DWORD)WindowObject->Instance;
-      IntReleaseWindowObject(WindowObject);
-      RETURN( Result);
-    }
-
-    case ONEPARAM_ROUTINE_SETMESSAGEEXTRAINFO:
-      RETURN( (DWORD)MsqSetMessageExtraInfo((LPARAM)Param));
-
-    case ONEPARAM_ROUTINE_GETCURSORPOSITION:
-    {
-      PWINSTATION_OBJECT WinStaObject;
-      NTSTATUS Status;
-      POINT Pos;
-
-      if(!Param)
-        RETURN( (DWORD)FALSE);
-      Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
-                                              KernelMode,
-                                              0,
-                                              &WinStaObject);
-      if (!NT_SUCCESS(Status))
-        RETURN( (DWORD)FALSE);
-
-      /* FIXME - check if process has WINSTA_READATTRIBUTES */
-      IntGetCursorLocation(WinStaObject, &Pos);
-
-      Status = MmCopyToCaller((PPOINT)Param, &Pos, sizeof(POINT));
-      if(!NT_SUCCESS(Status))
-      {
-        ObDereferenceObject(WinStaObject);
-        SetLastNtError(Status);
-        RETURN( FALSE);
-      }
+      case ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS:
+         RETURN( (DWORD)IntEnumClipboardFormats((UINT)Param));
+
+      case ONEPARAM_ROUTINE_GETWINDOWINSTANCE:
+         {
+            PWINDOW_OBJECT WindowObject;
+            DWORD Result;
+
+            if(!(WindowObject = IntGetWindowObject((HWND)Param)))
+            {
+               SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+               RETURN( FALSE);
+            }
 
-      ObDereferenceObject(WinStaObject);
+            Result = (DWORD)WindowObject->Instance;
+            IntReleaseWindowObject(WindowObject);
+            RETURN( Result);
+         }
+
+      case ONEPARAM_ROUTINE_SETMESSAGEEXTRAINFO:
+         RETURN( (DWORD)MsqSetMessageExtraInfo((LPARAM)Param));
+
+      case ONEPARAM_ROUTINE_GETCURSORPOSITION:
+         {
+            PWINSTATION_OBJECT WinStaObject;
+            NTSTATUS Status;
+            POINT Pos;
+
+            if(!Param)
+               RETURN( (DWORD)FALSE);
+            Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
+                                                    KernelMode,
+                                                    0,
+                                                    &WinStaObject);
+            if (!NT_SUCCESS(Status))
+               RETURN( (DWORD)FALSE);
+
+            /* FIXME - check if process has WINSTA_READATTRIBUTES */
+            IntGetCursorLocation(WinStaObject, &Pos);
+
+            Status = MmCopyToCaller((PPOINT)Param, &Pos, sizeof(POINT));
+            if(!NT_SUCCESS(Status))
+            {
+               ObDereferenceObject(WinStaObject);
+               SetLastNtError(Status);
+               RETURN( FALSE);
+            }
 
-      RETURN( (DWORD)TRUE);
-    }
+            ObDereferenceObject(WinStaObject);
 
-    case ONEPARAM_ROUTINE_ISWINDOWINDESTROY:
-    {
-      PWINDOW_OBJECT WindowObject;
-      DWORD Result;
+            RETURN( (DWORD)TRUE);
+         }
 
-      WindowObject = IntGetWindowObject((HWND)Param);
-      if(!WindowObject)
-      {
-        SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-        RETURN( FALSE);
-      }
+      case ONEPARAM_ROUTINE_ISWINDOWINDESTROY:
+         {
+            PWINDOW_OBJECT WindowObject;
+            DWORD Result;
 
-      Result = (DWORD)IntIsWindowInDestroy(WindowObject);
+            WindowObject = IntGetWindowObject((HWND)Param);
+            if(!WindowObject)
+            {
+               SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+               RETURN( FALSE);
+            }
 
-      IntReleaseWindowObject(WindowObject);
-      RETURN( Result);
-    }
+            Result = (DWORD)IntIsWindowInDestroy(WindowObject);
 
-    case ONEPARAM_ROUTINE_ENABLEPROCWNDGHSTING:
-    {
-      BOOL Enable;
-      PW32PROCESS Process = PsGetWin32Process();
+            IntReleaseWindowObject(WindowObject);
+            RETURN( Result);
+         }
 
-      if(Process != NULL)
-      {
-        Enable = (BOOL)(Param != 0);
-
-        if(Enable)
-        {
-          Process->Flags &= ~W32PF_NOWINDOWGHOSTING;
-        }
-        else
-        {
-          Process->Flags |= W32PF_NOWINDOWGHOSTING;
-        }
-
-        RETURN( TRUE);
-      }
+      case ONEPARAM_ROUTINE_ENABLEPROCWNDGHSTING:
+         {
+            BOOL Enable;
+            PW32PROCESS Process = PsGetWin32Process();
+
+            if(Process != NULL)
+            {
+               Enable = (BOOL)(Param != 0);
+
+               if(Enable)
+               {
+                  Process->Flags &= ~W32PF_NOWINDOWGHOSTING;
+               }
+               else
+               {
+                  Process->Flags |= W32PF_NOWINDOWGHOSTING;
+               }
+
+               RETURN( TRUE);
+            }
+
+            RETURN( FALSE);
+         }
+
+      case ONEPARAM_ROUTINE_MSQSETWAKEMASK:
+         RETURN( (DWORD)IntMsqSetWakeMask(Param));
+
+      case ONEPARAM_ROUTINE_GETKEYBOARDTYPE:
+         RETURN( UserGetKeyboardType(Param));
+
+      case ONEPARAM_ROUTINE_GETKEYBOARDLAYOUT:
+         RETURN( (DWORD)UserGetKeyboardLayout(Param));
+   }
+   DPRINT1("Calling invalid routine number 0x%x in NtUserCallOneParam(), Param=0x%x\n",
+           Routine, Param);
+   SetLastWin32Error(ERROR_INVALID_PARAMETER);
+   RETURN( 0);
 
-      RETURN( FALSE);
-    }
-
-    case ONEPARAM_ROUTINE_MSQSETWAKEMASK:
-      RETURN( (DWORD)IntMsqSetWakeMask(Param));
-
-    case ONEPARAM_ROUTINE_GETKEYBOARDTYPE:
-      RETURN( UserGetKeyboardType(Param));
-      
-    case ONEPARAM_ROUTINE_GETKEYBOARDLAYOUT:
-      RETURN( (DWORD)UserGetKeyboardLayout(Param));
-  }
-  DPRINT1("Calling invalid routine number 0x%x in NtUserCallOneParam(), Param=0x%x\n",
-          Routine, Param);
-  SetLastWin32Error(ERROR_INVALID_PARAMETER);
-  RETURN( 0);
-  
 CLEANUP:
-  DPRINT("Leave NtUserCallOneParam, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserCallOneParam, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -380,317 +384,320 @@ CLEANUP:
 DWORD
 STDCALL
 NtUserCallTwoParam(
-  DWORD Param1,
-  DWORD Param2,
-  DWORD Routine)
+   DWORD Param1,
+   DWORD Param2,
+   DWORD Routine)
 {
-  NTSTATUS Status;
-  PWINDOW_OBJECT WindowObject;
-  DECLARE_RETURN(DWORD);  
-
-  DPRINT("Enter NtUserCallTwoParam\n");
-  UserEnterExclusive();
-
-  switch(Routine)
-  {
-    case TWOPARAM_ROUTINE_SETDCPENCOLOR:
-    {
-      RETURN( (DWORD)IntSetDCColor((HDC)Param1, OBJ_PEN, (COLORREF)Param2));
-    }
-    case TWOPARAM_ROUTINE_SETDCBRUSHCOLOR:
-    {
-      RETURN( (DWORD)IntSetDCColor((HDC)Param1, OBJ_BRUSH, (COLORREF)Param2));
-    }
-    case TWOPARAM_ROUTINE_GETDCCOLOR:
-    {
-      RETURN( (DWORD)IntGetDCColor((HDC)Param1, (ULONG)Param2));
-    }
-    case TWOPARAM_ROUTINE_GETWINDOWRGNBOX:
-    {
-      DWORD Ret;
-      RECT rcRect;
-      Ret = (DWORD)IntGetWindowRgnBox((HWND)Param1, &rcRect);
-      Status = MmCopyToCaller((PVOID)Param2, &rcRect, sizeof(RECT));
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        RETURN( ERROR);
-      }
-      RETURN( Ret);
-    }
-    case TWOPARAM_ROUTINE_GETWINDOWRGN:
-    {
-      RETURN( (DWORD)IntGetWindowRgn((HWND)Param1, (HRGN)Param2));
-    }
-    case TWOPARAM_ROUTINE_SETMENUBARHEIGHT:
-    {
-      DWORD Ret;
-      PMENU_OBJECT MenuObject = IntGetMenuObject((HMENU)Param1);
-      if(!MenuObject)
-        RETURN( 0);
-
-      if(Param2 > 0)
-      {
-        Ret = (MenuObject->MenuInfo.Height == (int)Param2);
-        MenuObject->MenuInfo.Height = (int)Param2;
-      }
-      else
-        Ret = (DWORD)MenuObject->MenuInfo.Height;
-      IntReleaseMenuObject(MenuObject);
-      RETURN( Ret);
-    }
-    case TWOPARAM_ROUTINE_SETMENUITEMRECT:
-    {
-      BOOL Ret;
-      SETMENUITEMRECT smir;
-      PMENU_OBJECT MenuObject = IntGetMenuObject((HMENU)Param1);
-      if(!MenuObject)
-        RETURN( 0);
-
-      if(!NT_SUCCESS(MmCopyFromCaller(&smir, (PVOID)Param2, sizeof(SETMENUITEMRECT))))
-      {
-        IntReleaseMenuObject(MenuObject);
-        RETURN( 0);
-      }
-
-      Ret = IntSetMenuItemRect(MenuObject, smir.uItem, smir.fByPosition, &smir.rcRect);
-
-      IntReleaseMenuObject(MenuObject);
-      RETURN( (DWORD)Ret);
-    }
-
-    case TWOPARAM_ROUTINE_SETGUITHRDHANDLE:
-    {
-      PUSER_MESSAGE_QUEUE MsgQueue = PsGetCurrentThread()->Tcb.Win32Thread->MessageQueue;
+   NTSTATUS Status;
+   PWINDOW_OBJECT WindowObject;
+   DECLARE_RETURN(DWORD);
 
-      ASSERT(MsgQueue);
-      RETURN( (DWORD)MsqSetStateWindow(MsgQueue, (ULONG)Param1, (HWND)Param2));
-    }
+   DPRINT("Enter NtUserCallTwoParam\n");
+   UserEnterExclusive();
 
-    case TWOPARAM_ROUTINE_ENABLEWINDOW:
-         UNIMPLEMENTED
-      RETURN( 0);
+   switch(Routine)
+   {
+      case TWOPARAM_ROUTINE_SETDCPENCOLOR:
+         {
+            RETURN( (DWORD)IntSetDCColor((HDC)Param1, OBJ_PEN, (COLORREF)Param2));
+         }
+      case TWOPARAM_ROUTINE_SETDCBRUSHCOLOR:
+         {
+            RETURN( (DWORD)IntSetDCColor((HDC)Param1, OBJ_BRUSH, (COLORREF)Param2));
+         }
+      case TWOPARAM_ROUTINE_GETDCCOLOR:
+         {
+            RETURN( (DWORD)IntGetDCColor((HDC)Param1, (ULONG)Param2));
+         }
+      case TWOPARAM_ROUTINE_GETWINDOWRGNBOX:
+         {
+            DWORD Ret;
+            RECT rcRect;
+            Ret = (DWORD)IntGetWindowRgnBox((HWND)Param1, &rcRect);
+            Status = MmCopyToCaller((PVOID)Param2, &rcRect, sizeof(RECT));
+            if(!NT_SUCCESS(Status))
+            {
+               SetLastNtError(Status);
+               RETURN( ERROR);
+            }
+            RETURN( Ret);
+         }
+      case TWOPARAM_ROUTINE_GETWINDOWRGN:
+         {
+            RETURN( (DWORD)IntGetWindowRgn((HWND)Param1, (HRGN)Param2));
+         }
+      case TWOPARAM_ROUTINE_SETMENUBARHEIGHT:
+         {
+            DWORD Ret;
+            PMENU_OBJECT MenuObject = IntGetMenuObject((HMENU)Param1);
+            if(!MenuObject)
+               RETURN( 0);
+
+            if(Param2 > 0)
+            {
+               Ret = (MenuObject->MenuInfo.Height == (int)Param2);
+               MenuObject->MenuInfo.Height = (int)Param2;
+            }
+            else
+               Ret = (DWORD)MenuObject->MenuInfo.Height;
+            IntReleaseMenuObject(MenuObject);
+            RETURN( Ret);
+         }
+      case TWOPARAM_ROUTINE_SETMENUITEMRECT:
+         {
+            BOOL Ret;
+            SETMENUITEMRECT smir;
+            PMENU_OBJECT MenuObject = IntGetMenuObject((HMENU)Param1);
+            if(!MenuObject)
+               RETURN( 0);
+
+            if(!NT_SUCCESS(MmCopyFromCaller(&smir, (PVOID)Param2, sizeof(SETMENUITEMRECT))))
+            {
+               IntReleaseMenuObject(MenuObject);
+               RETURN( 0);
+            }
 
-    case TWOPARAM_ROUTINE_UNKNOWN:
-         UNIMPLEMENTED
-     RETURN( 0);
+            Ret = IntSetMenuItemRect(MenuObject, smir.uItem, smir.fByPosition, &smir.rcRect);
 
-    case TWOPARAM_ROUTINE_SHOWOWNEDPOPUPS:
-     RETURN( (DWORD)IntShowOwnedPopups((HWND) Param1, (BOOL) Param2));
+            IntReleaseMenuObject(MenuObject);
+            RETURN( (DWORD)Ret);
+         }
 
-    case TWOPARAM_ROUTINE_ROS_SHOWWINDOW:
-    {
-#define WIN_NEEDS_SHOW_OWNEDPOPUP (0x00000040)
-          PWINDOW_OBJECT Window = IntGetWindowObject((HWND)Param1);
-         DPRINT1("ROS_SHOWWINDOW\n");
-          if (Window == 0)
-           {
-                 SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-                 RETURN( FALSE);
-           }
-          if (Param2)
-           {
-               if (!(Window->Flags & WIN_NEEDS_SHOW_OWNEDPOPUP))
-                {
-                    IntReleaseWindowObject(Window);
-                    RETURN( TRUE);
-                }
-                Window->Flags &= ~WIN_NEEDS_SHOW_OWNEDPOPUP;
-           }
-          else Window->Flags |= WIN_NEEDS_SHOW_OWNEDPOPUP;
-          DPRINT1("ROS_SHOWWINDOW ---> 0x%x\n",Window->Flags);
-          IntReleaseWindowObject(Window);
-          RETURN( TRUE);
-    }
-    case TWOPARAM_ROUTINE_SWITCHTOTHISWINDOW:
-         UNIMPLEMENTED
-     RETURN( 0);
-
-    case TWOPARAM_ROUTINE_VALIDATERGN:
-    {
-      PWINDOW_OBJECT Window = UserGetWindowObject((HWND) Param1);
-      BOOL ret;
-      
-      if (!Window) RETURN(FALSE);
-      
-      UserRefObjectCo(Window);
-      ret = co_UserValidateRgn(Window, (HRGN) Param2);
-      UserDerefObjectCo(Window);
-      
-      RETURN((DWORD) ret);
-    }
-    
-    case TWOPARAM_ROUTINE_SETWNDCONTEXTHLPID:
-      WindowObject = IntGetWindowObject((HWND)Param1);
-      if(!WindowObject)
-      {
-        SetLastWin32Error(ERROR_INVALID_HANDLE);
-        RETURN( (DWORD)FALSE);
-      }
+      case TWOPARAM_ROUTINE_SETGUITHRDHANDLE:
+         {
+            PUSER_MESSAGE_QUEUE MsgQueue = PsGetCurrentThread()->Tcb.Win32Thread->MessageQueue;
 
-      WindowObject->ContextHelpId = Param2;
+            ASSERT(MsgQueue);
+            RETURN( (DWORD)MsqSetStateWindow(MsgQueue, (ULONG)Param1, (HWND)Param2));
+         }
 
-      IntReleaseWindowObject(WindowObject);
-      RETURN( (DWORD)TRUE);
+      case TWOPARAM_ROUTINE_ENABLEWINDOW:
+         UNIMPLEMENTED
+         RETURN( 0);
 
-    case TWOPARAM_ROUTINE_SETCARETPOS:
-      RETURN( (DWORD)co_IntSetCaretPos((int)Param1, (int)Param2));
+      case TWOPARAM_ROUTINE_UNKNOWN:
+         UNIMPLEMENTED
+         RETURN( 0);
 
-    case TWOPARAM_ROUTINE_GETWINDOWINFO:
-    {
-      WINDOWINFO wi;
-      DWORD Ret;
+      case TWOPARAM_ROUTINE_SHOWOWNEDPOPUPS:
+         RETURN( (DWORD)IntShowOwnedPopups((HWND) Param1, (BOOL) Param2));
 
-      if(!(WindowObject = IntGetWindowObject((HWND)Param1)))
-      {
-        SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-        RETURN( FALSE);
-      }
+      case TWOPARAM_ROUTINE_ROS_SHOWWINDOW:
+         {
+#define WIN_NEEDS_SHOW_OWNEDPOPUP (0x00000040)
+            PWINDOW_OBJECT Window = IntGetWindowObject((HWND)Param1);
+            DPRINT1("ROS_SHOWWINDOW\n");
+            if (Window == 0)
+            {
+               SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+               RETURN( FALSE);
+            }
+            if (Param2)
+            {
+               if (!(Window->Flags & WIN_NEEDS_SHOW_OWNEDPOPUP))
+               {
+                  IntReleaseWindowObject(Window);
+                  RETURN( TRUE);
+               }
+               Window->Flags &= ~WIN_NEEDS_SHOW_OWNEDPOPUP;
+            }
+            else
+               Window->Flags |= WIN_NEEDS_SHOW_OWNEDPOPUP;
+            DPRINT1("ROS_SHOWWINDOW ---> 0x%x\n",Window->Flags);
+            IntReleaseWindowObject(Window);
+            RETURN( TRUE);
+         }
+      case TWOPARAM_ROUTINE_SWITCHTOTHISWINDOW:
+         UNIMPLEMENTED
+         RETURN( 0);
+
+      case TWOPARAM_ROUTINE_VALIDATERGN:
+         {
+            PWINDOW_OBJECT Window = UserGetWindowObject((HWND) Param1);
+            BOOL ret;
+
+            if (!Window)
+               RETURN(FALSE);
+
+            UserRefObjectCo(Window);
+            ret = co_UserValidateRgn(Window, (HRGN) Param2);
+            UserDerefObjectCo(Window);
+
+            RETURN((DWORD) ret);
+         }
+
+      case TWOPARAM_ROUTINE_SETWNDCONTEXTHLPID:
+         WindowObject = IntGetWindowObject((HWND)Param1);
+         if(!WindowObject)
+         {
+            SetLastWin32Error(ERROR_INVALID_HANDLE);
+            RETURN( (DWORD)FALSE);
+         }
+
+         WindowObject->ContextHelpId = Param2;
+
+         IntReleaseWindowObject(WindowObject);
+         RETURN( (DWORD)TRUE);
+
+      case TWOPARAM_ROUTINE_SETCARETPOS:
+         RETURN( (DWORD)co_IntSetCaretPos((int)Param1, (int)Param2));
+
+      case TWOPARAM_ROUTINE_GETWINDOWINFO:
+         {
+            WINDOWINFO wi;
+            DWORD Ret;
+
+            if(!(WindowObject = IntGetWindowObject((HWND)Param1)))
+            {
+               SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+               RETURN( FALSE);
+            }
 
 #if 0
-      /*
-       * According to WINE, Windows' doesn't check the cbSize field
-       */
+            /*
+             * According to WINE, Windows' doesn't check the cbSize field
+             */
 
-      Status = MmCopyFromCaller(&wi.cbSize, (PVOID)Param2, sizeof(wi.cbSize));
-      if(!NT_SUCCESS(Status))
-      {
-        IntReleaseWindowObject(WindowObject);
-        SetLastNtError(Status);
-        RETURN( FALSE);
-      }
+            Status = MmCopyFromCaller(&wi.cbSize, (PVOID)Param2, sizeof(wi.cbSize));
+            if(!NT_SUCCESS(Status))
+            {
+               IntReleaseWindowObject(WindowObject);
+               SetLastNtError(Status);
+               RETURN( FALSE);
+            }
 
-      if(wi.cbSize != sizeof(WINDOWINFO))
-      {
-        IntReleaseWindowObject(WindowObject);
-        SetLastWin32Error(ERROR_INVALID_PARAMETER);
-        RETURN( FALSE);
-      }
+            if(wi.cbSize != sizeof(WINDOWINFO))
+            {
+               IntReleaseWindowObject(WindowObject);
+               SetLastWin32Error(ERROR_INVALID_PARAMETER);
+               RETURN( FALSE);
+            }
 #endif
 
-      if((Ret = (DWORD)IntGetWindowInfo(WindowObject, &wi)))
-      {
-        Status = MmCopyToCaller((PVOID)Param2, &wi, sizeof(WINDOWINFO));
-        if(!NT_SUCCESS(Status))
-        {
-          IntReleaseWindowObject(WindowObject);
-          SetLastNtError(Status);
-          RETURN( FALSE);
-        }
-      }
+            if((Ret = (DWORD)IntGetWindowInfo(WindowObject, &wi)))
+            {
+               Status = MmCopyToCaller((PVOID)Param2, &wi, sizeof(WINDOWINFO));
+               if(!NT_SUCCESS(Status))
+               {
+                  IntReleaseWindowObject(WindowObject);
+                  SetLastNtError(Status);
+                  RETURN( FALSE);
+               }
+            }
 
-      IntReleaseWindowObject(WindowObject);
-      RETURN( Ret);
-    }
+            IntReleaseWindowObject(WindowObject);
+            RETURN( Ret);
+         }
 
-    case TWOPARAM_ROUTINE_REGISTERLOGONPROC:
-      RETURN( (DWORD)co_IntRegisterLogonProcess((HANDLE)Param1, (BOOL)Param2));
+      case TWOPARAM_ROUTINE_REGISTERLOGONPROC:
+         RETURN( (DWORD)co_IntRegisterLogonProcess((HANDLE)Param1, (BOOL)Param2));
 
-    case TWOPARAM_ROUTINE_SETSYSCOLORS:
-    {
-      DWORD Ret = 0;
-      PVOID Buffer;
-      struct
-      {
-        INT *Elements;
-        COLORREF *Colors;
-      } ChangeSysColors;
+      case TWOPARAM_ROUTINE_SETSYSCOLORS:
+         {
+            DWORD Ret = 0;
+            PVOID Buffer;
+            struct
+            {
+               INT *Elements;
+               COLORREF *Colors;
+            }
+            ChangeSysColors;
 
-      /* FIXME - we should make use of SEH here... */
+            /* FIXME - we should make use of SEH here... */
 
-      Status = MmCopyFromCaller(&ChangeSysColors, (PVOID)Param1, sizeof(ChangeSysColors));
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        RETURN( 0);
-      }
+            Status = MmCopyFromCaller(&ChangeSysColors, (PVOID)Param1, sizeof(ChangeSysColors));
+            if(!NT_SUCCESS(Status))
+            {
+               SetLastNtError(Status);
+               RETURN( 0);
+            }
 
-      Buffer = ExAllocatePool(PagedPool, (Param2 * sizeof(INT)) + (Param2 * sizeof(COLORREF)));
-      if(Buffer != NULL)
-      {
-        INT *Elements = (INT*)Buffer;
-        COLORREF *Colors = (COLORREF*)Buffer + Param2;
-
-        Status = MmCopyFromCaller(Elements, ChangeSysColors.Elements, Param2 * sizeof(INT));
-        if(NT_SUCCESS(Status))
-        {
-          Status = MmCopyFromCaller(Colors, ChangeSysColors.Colors, Param2 * sizeof(COLORREF));
-          if(NT_SUCCESS(Status))
-          {
-            Ret = (DWORD)IntSetSysColors((UINT)Param2, Elements, Colors);
-          }
-          else
-            SetLastNtError(Status);
-        }
-        else
-          SetLastNtError(Status);
-
-        ExFreePool(Buffer);
-      }
+            Buffer = ExAllocatePool(PagedPool, (Param2 * sizeof(INT)) + (Param2 * sizeof(COLORREF)));
+            if(Buffer != NULL)
+            {
+               INT *Elements = (INT*)Buffer;
+               COLORREF *Colors = (COLORREF*)Buffer + Param2;
+
+               Status = MmCopyFromCaller(Elements, ChangeSysColors.Elements, Param2 * sizeof(INT));
+               if(NT_SUCCESS(Status))
+               {
+                  Status = MmCopyFromCaller(Colors, ChangeSysColors.Colors, Param2 * sizeof(COLORREF));
+                  if(NT_SUCCESS(Status))
+                  {
+                     Ret = (DWORD)IntSetSysColors((UINT)Param2, Elements, Colors);
+                  }
+                  else
+                     SetLastNtError(Status);
+               }
+               else
+                  SetLastNtError(Status);
+
+               ExFreePool(Buffer);
+            }
 
 
-      RETURN( Ret);
-    }
+            RETURN( Ret);
+         }
 
-    case TWOPARAM_ROUTINE_GETSYSCOLORBRUSHES:
-    case TWOPARAM_ROUTINE_GETSYSCOLORPENS:
-    case TWOPARAM_ROUTINE_GETSYSCOLORS:
-    {
-      DWORD Ret = 0;
-      union
-      {
-        PVOID Pointer;
-        HBRUSH *Brushes;
-        HPEN *Pens;
-        COLORREF *Colors;
-      } Buffer;
+      case TWOPARAM_ROUTINE_GETSYSCOLORBRUSHES:
+      case TWOPARAM_ROUTINE_GETSYSCOLORPENS:
+      case TWOPARAM_ROUTINE_GETSYSCOLORS:
+         {
+            DWORD Ret = 0;
+            union
+            {
+               PVOID Pointer;
+               HBRUSH *Brushes;
+               HPEN *Pens;
+               COLORREF *Colors;
+            } Buffer;
 
-      /* FIXME - we should make use of SEH here... */
+            /* FIXME - we should make use of SEH here... */
+
+            Buffer.Pointer = ExAllocatePool(PagedPool, Param2 * sizeof(HANDLE));
+            if(Buffer.Pointer != NULL)
+            {
+               switch(Routine)
+               {
+                  case TWOPARAM_ROUTINE_GETSYSCOLORBRUSHES:
+                     Ret = (DWORD)IntGetSysColorBrushes(Buffer.Brushes, (UINT)Param2);
+                     break;
+                  case TWOPARAM_ROUTINE_GETSYSCOLORPENS:
+                     Ret = (DWORD)IntGetSysColorPens(Buffer.Pens, (UINT)Param2);
+                     break;
+                  case TWOPARAM_ROUTINE_GETSYSCOLORS:
+                     Ret = (DWORD)IntGetSysColors(Buffer.Colors, (UINT)Param2);
+                     break;
+                  default:
+                     Ret = 0;
+                     break;
+               }
+
+               if(Ret > 0)
+               {
+                  Status = MmCopyToCaller((PVOID)Param1, Buffer.Pointer, Param2 * sizeof(HANDLE));
+                  if(!NT_SUCCESS(Status))
+                  {
+                     SetLastNtError(Status);
+                     Ret = 0;
+                  }
+               }
+
+               ExFreePool(Buffer.Pointer);
+            }
+            RETURN( Ret);
+         }
+
+   }
+   DPRINT1("Calling invalid routine number 0x%x in NtUserCallTwoParam(), Param1=0x%x Parm2=0x%x\n",
+           Routine, Param1, Param2);
+   SetLastWin32Error(ERROR_INVALID_PARAMETER);
+   RETURN( 0);
 
-      Buffer.Pointer = ExAllocatePool(PagedPool, Param2 * sizeof(HANDLE));
-      if(Buffer.Pointer != NULL)
-      {
-        switch(Routine)
-        {
-          case TWOPARAM_ROUTINE_GETSYSCOLORBRUSHES:
-            Ret = (DWORD)IntGetSysColorBrushes(Buffer.Brushes, (UINT)Param2);
-            break;
-          case TWOPARAM_ROUTINE_GETSYSCOLORPENS:
-            Ret = (DWORD)IntGetSysColorPens(Buffer.Pens, (UINT)Param2);
-            break;
-          case TWOPARAM_ROUTINE_GETSYSCOLORS:
-            Ret = (DWORD)IntGetSysColors(Buffer.Colors, (UINT)Param2);
-            break;
-          default:
-            Ret = 0;
-            break;
-        }
-
-        if(Ret > 0)
-        {
-          Status = MmCopyToCaller((PVOID)Param1, Buffer.Pointer, Param2 * sizeof(HANDLE));
-          if(!NT_SUCCESS(Status))
-          {
-            SetLastNtError(Status);
-            Ret = 0;
-          }
-        }
-
-        ExFreePool(Buffer.Pointer);
-      }
-      RETURN( Ret);
-    }
-
-  }
-  DPRINT1("Calling invalid routine number 0x%x in NtUserCallTwoParam(), Param1=0x%x Parm2=0x%x\n",
-          Routine, Param1, Param2);
-  SetLastWin32Error(ERROR_INVALID_PARAMETER);
-  RETURN( 0);
-  
 CLEANUP:
-  DPRINT("Leave NtUserCallTwoParam, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserCallTwoParam, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -700,12 +707,12 @@ CLEANUP:
 BOOL
 STDCALL
 NtUserCallHwndLock(
-  HWND hWnd,
-  DWORD Routine)
+   HWND hWnd,
+   DWORD Routine)
 {
    BOOL Ret = 0;
    PWINDOW_OBJECT Window;
-   DECLARE_RETURN(BOOLEAN);  
+   DECLARE_RETURN(BOOLEAN);
 
    DPRINT("Enter NtUserCallHwndLock\n");
    UserEnterExclusive();
@@ -725,21 +732,23 @@ NtUserCallHwndLock(
          break;
 
       case HWNDLOCK_ROUTINE_DRAWMENUBAR:
-           {
-              PMENU_OBJECT MenuObject;
-              DPRINT("HWNDLOCK_ROUTINE_DRAWMENUBAR\n");
-              Ret = FALSE;
-              if (!((Window->Style & (WS_CHILD | WS_POPUP)) != WS_CHILD)) break;
-              MenuObject = IntGetMenuObject((HMENU) Window->IDMenu);
-              if(MenuObject == NULL) break;
-              MenuObject->MenuInfo.WndOwner = hWnd;
-              MenuObject->MenuInfo.Height = 0;
-              IntReleaseMenuObject(MenuObject);
-              co_WinPosSetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
-                           SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
-              Ret = TRUE;
-              break;
-            }
+         {
+            PMENU_OBJECT MenuObject;
+            DPRINT("HWNDLOCK_ROUTINE_DRAWMENUBAR\n");
+            Ret = FALSE;
+            if (!((Window->Style & (WS_CHILD | WS_POPUP)) != WS_CHILD))
+               break;
+            MenuObject = IntGetMenuObject((HMENU) Window->IDMenu);
+            if(MenuObject == NULL)
+               break;
+            MenuObject->MenuInfo.WndOwner = hWnd;
+            MenuObject->MenuInfo.Height = 0;
+            IntReleaseMenuObject(MenuObject);
+            co_WinPosSetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
+                                  SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
+            Ret = TRUE;
+            break;
+         }
 
       case HWNDLOCK_ROUTINE_REDRAWFRAME:
          /* FIXME */
@@ -757,11 +766,11 @@ NtUserCallHwndLock(
    IntReleaseWindowObject(Window);
 
    RETURN( Ret);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserCallHwndLock, ret=%i\n",_ret_);
    UserLeave();
-   END_CLEANUP;   
+   END_CLEANUP;
 }
 
 /*
@@ -770,13 +779,13 @@ CLEANUP:
 HWND
 STDCALL
 NtUserCallHwndOpt(
-  HWND Param,
-  DWORD Routine)
+   HWND Param,
+   DWORD Routine)
 {
    switch (Routine)
    {
       case HWNDOPT_ROUTINE_SETPROGMANWINDOW:
-         /* 
+         /*
           * FIXME 
           * Nothing too hard...validate the hWnd and save it in the Desktop Info
           */
@@ -784,7 +793,7 @@ NtUserCallHwndOpt(
          break;
 
       case HWNDOPT_ROUTINE_SETTASKMANWINDOW:
-         /* 
+         /*
           * FIXME 
           * Nothing too hard...validate the hWnd and save it in the Desktop Info
           */
@@ -800,24 +809,24 @@ NtUserCallHwndOpt(
  */
 DWORD STDCALL
 NtUserGetThreadState(
-  DWORD Routine)
+   DWORD Routine)
 {
-   DECLARE_RETURN(DWORD);  
+   DECLARE_RETURN(DWORD);
 
    DPRINT("Enter NtUserGetThreadState\n");
    UserEnterShared();
-   
+
    switch (Routine)
    {
       case 0:
          RETURN( (DWORD)IntGetThreadFocusWindow());
    }
    RETURN( 0);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserGetThreadState, ret=%i\n",_ret_);
    UserLeave();
-   END_CLEANUP;   
+   END_CLEANUP;
 }
 
 VOID FASTCALL
@@ -826,10 +835,10 @@ IntGetFontMetricSetting(LPWSTR lpValueName, PLOGFONTW font)
    RTL_QUERY_REGISTRY_TABLE QueryTable[2];
    NTSTATUS Status;
    static LOGFONTW DefaultFont = {
-      11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
-      0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
-      L"Bitstream Vera Sans"
-   };
+                                    11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
+                                    0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
+                                    L"Bitstream Vera Sans"
+                                 };
 
    RtlZeroMemory(&QueryTable, sizeof(QueryTable));
 
@@ -838,11 +847,11 @@ IntGetFontMetricSetting(LPWSTR lpValueName, PLOGFONTW font)
    QueryTable[0].EntryContext = font;
 
    Status = RtlQueryRegistryValues(
-      RTL_REGISTRY_USER,
-      L"Control Panel\\Desktop\\WindowMetrics",
-      QueryTable,
-      NULL,
-      NULL);
+               RTL_REGISTRY_USER,
+               L"Control Panel\\Desktop\\WindowMetrics",
+               QueryTable,
+               NULL,
+               NULL);
 
    if (!NT_SUCCESS(Status))
    {
@@ -852,244 +861,244 @@ IntGetFontMetricSetting(LPWSTR lpValueName, PLOGFONTW font)
 
 ULONG FASTCALL
 IntSystemParametersInfo(
-  UINT uiAction,
-  UINT uiParam,
-  PVOID pvParam,
-  UINT fWinIni)
+   UINT uiAction,
+   UINT uiParam,
+   PVOID pvParam,
+   UINT fWinIni)
 {
-  PWINSTATION_OBJECT WinStaObject;
-  NTSTATUS Status;
-
-  static BOOL bInitialized = FALSE;
-  static LOGFONTW IconFont;
-  static NONCLIENTMETRICSW pMetrics;
-  static BOOL GradientCaptions = TRUE;
-  static UINT FocusBorderHeight = 1;
-  static UINT FocusBorderWidth = 1;
-
-  if (!bInitialized)
-  {
-    RtlZeroMemory(&IconFont, sizeof(LOGFONTW));
-    RtlZeroMemory(&pMetrics, sizeof(NONCLIENTMETRICSW));
-
-    IntGetFontMetricSetting(L"CaptionFont", &pMetrics.lfCaptionFont);
-    IntGetFontMetricSetting(L"SmCaptionFont", &pMetrics.lfSmCaptionFont);
-    IntGetFontMetricSetting(L"MenuFont", &pMetrics.lfMenuFont);
-    IntGetFontMetricSetting(L"StatusFont", &pMetrics.lfStatusFont);
-    IntGetFontMetricSetting(L"MessageFont", &pMetrics.lfMessageFont);
-    IntGetFontMetricSetting(L"IconFont", &IconFont);
-
-    pMetrics.iBorderWidth = 1;
-    pMetrics.iScrollWidth = UserGetSystemMetrics(SM_CXVSCROLL);
-    pMetrics.iScrollHeight = UserGetSystemMetrics(SM_CYHSCROLL);
-    pMetrics.iCaptionWidth = UserGetSystemMetrics(SM_CXSIZE);
-    pMetrics.iCaptionHeight = UserGetSystemMetrics(SM_CYSIZE);
-    pMetrics.iSmCaptionWidth = UserGetSystemMetrics(SM_CXSMSIZE);
-    pMetrics.iSmCaptionHeight = UserGetSystemMetrics(SM_CYSMSIZE);
-    pMetrics.iMenuWidth = UserGetSystemMetrics(SM_CXMENUSIZE);
-    pMetrics.iMenuHeight = UserGetSystemMetrics(SM_CYMENUSIZE);
-    pMetrics.cbSize = sizeof(NONCLIENTMETRICSW);
-
-    bInitialized = TRUE;
-  }
-
-  switch(uiAction)
-  {
-    case SPI_SETDOUBLECLKWIDTH:
-    case SPI_SETDOUBLECLKHEIGHT:
-    case SPI_SETDOUBLECLICKTIME:
-    case SPI_SETDESKWALLPAPER:
-    case SPI_GETDESKWALLPAPER:
-    {
-      PSYSTEM_CURSORINFO CurInfo;
-
-      Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
-                                              KernelMode,
-                                              0,
-                                              &WinStaObject);
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        return (DWORD)FALSE;
-      }
+   PWINSTATION_OBJECT WinStaObject;
+   NTSTATUS Status;
 
-      switch(uiAction)
-      {
-        case SPI_SETDOUBLECLKWIDTH:
-          CurInfo = IntGetSysCursorInfo(WinStaObject);
-          /* FIXME limit the maximum value? */
-          CurInfo->DblClickWidth = uiParam;
-          break;
-        case SPI_SETDOUBLECLKHEIGHT:
-          CurInfo = IntGetSysCursorInfo(WinStaObject);
-          /* FIXME limit the maximum value? */
-          CurInfo->DblClickHeight = uiParam;
-          break;
-        case SPI_SETDOUBLECLICKTIME:
-          CurInfo = IntGetSysCursorInfo(WinStaObject);
-          /* FIXME limit the maximum time to 1000 ms? */
-          CurInfo->DblClickSpeed = uiParam;
-          break;
-        case SPI_SETDESKWALLPAPER:
-        {
-          /* This function expects different parameters than the user mode version!
-
-             We let the user mode code load the bitmap, it passed the handle to
-             the bitmap. We'll change it's ownership to system and replace it with
-             the current wallpaper bitmap */
-          HBITMAP hOldBitmap, hNewBitmap;
-          ASSERT(pvParam);
-
-          hNewBitmap = *(HBITMAP*)pvParam;
-          if(hNewBitmap != NULL)
-          {
-            BITMAPOBJ *bmp;
-            /* try to get the size of the wallpaper */
-            if(!(bmp = BITMAPOBJ_LockBitmap(hNewBitmap)))
+   static BOOL bInitialized = FALSE;
+   static LOGFONTW IconFont;
+   static NONCLIENTMETRICSW pMetrics;
+   static BOOL GradientCaptions = TRUE;
+   static UINT FocusBorderHeight = 1;
+   static UINT FocusBorderWidth = 1;
+
+   if (!bInitialized)
+   {
+      RtlZeroMemory(&IconFont, sizeof(LOGFONTW));
+      RtlZeroMemory(&pMetrics, sizeof(NONCLIENTMETRICSW));
+
+      IntGetFontMetricSetting(L"CaptionFont", &pMetrics.lfCaptionFont);
+      IntGetFontMetricSetting(L"SmCaptionFont", &pMetrics.lfSmCaptionFont);
+      IntGetFontMetricSetting(L"MenuFont", &pMetrics.lfMenuFont);
+      IntGetFontMetricSetting(L"StatusFont", &pMetrics.lfStatusFont);
+      IntGetFontMetricSetting(L"MessageFont", &pMetrics.lfMessageFont);
+      IntGetFontMetricSetting(L"IconFont", &IconFont);
+
+      pMetrics.iBorderWidth = 1;
+      pMetrics.iScrollWidth = UserGetSystemMetrics(SM_CXVSCROLL);
+      pMetrics.iScrollHeight = UserGetSystemMetrics(SM_CYHSCROLL);
+      pMetrics.iCaptionWidth = UserGetSystemMetrics(SM_CXSIZE);
+      pMetrics.iCaptionHeight = UserGetSystemMetrics(SM_CYSIZE);
+      pMetrics.iSmCaptionWidth = UserGetSystemMetrics(SM_CXSMSIZE);
+      pMetrics.iSmCaptionHeight = UserGetSystemMetrics(SM_CYSMSIZE);
+      pMetrics.iMenuWidth = UserGetSystemMetrics(SM_CXMENUSIZE);
+      pMetrics.iMenuHeight = UserGetSystemMetrics(SM_CYMENUSIZE);
+      pMetrics.cbSize = sizeof(NONCLIENTMETRICSW);
+
+      bInitialized = TRUE;
+   }
+
+   switch(uiAction)
+   {
+      case SPI_SETDOUBLECLKWIDTH:
+      case SPI_SETDOUBLECLKHEIGHT:
+      case SPI_SETDOUBLECLICKTIME:
+      case SPI_SETDESKWALLPAPER:
+      case SPI_GETDESKWALLPAPER:
+         {
+            PSYSTEM_CURSORINFO CurInfo;
+
+            Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
+                                                    KernelMode,
+                                                    0,
+                                                    &WinStaObject);
+            if(!NT_SUCCESS(Status))
             {
-              ObDereferenceObject(WinStaObject);
-              return FALSE;
+               SetLastNtError(Status);
+               return (DWORD)FALSE;
             }
-            WinStaObject->cxWallpaper = bmp->SurfObj.sizlBitmap.cx;
-            WinStaObject->cyWallpaper = bmp->SurfObj.sizlBitmap.cy;
-
-            BITMAPOBJ_UnlockBitmap(bmp);
-
-            /* change the bitmap's ownership */
-            GDIOBJ_SetOwnership(hNewBitmap, NULL);
-          }
-          hOldBitmap = (HBITMAP)InterlockedExchange((LONG*)&WinStaObject->hbmWallpaper, (LONG)hNewBitmap);
-          if(hOldBitmap != NULL)
-          {
-            /* delete the old wallpaper */
-            NtGdiDeleteObject(hOldBitmap);
-          }
-          break;
-        }
-        case SPI_GETDESKWALLPAPER:
-          /* This function expects different parameters than the user mode version!
-
-             We basically return the current wallpaper handle - if any. The user
-             mode version should load the string from the registry and return it
-             without calling this function */
-          ASSERT(pvParam);
-          *(HBITMAP*)pvParam = (HBITMAP)WinStaObject->hbmWallpaper;
-          break;
-      }
 
-      /* FIXME save the value to the registry */
+            switch(uiAction)
+            {
+               case SPI_SETDOUBLECLKWIDTH:
+                  CurInfo = IntGetSysCursorInfo(WinStaObject);
+                  /* FIXME limit the maximum value? */
+                  CurInfo->DblClickWidth = uiParam;
+                  break;
+               case SPI_SETDOUBLECLKHEIGHT:
+                  CurInfo = IntGetSysCursorInfo(WinStaObject);
+                  /* FIXME limit the maximum value? */
+                  CurInfo->DblClickHeight = uiParam;
+                  break;
+               case SPI_SETDOUBLECLICKTIME:
+                  CurInfo = IntGetSysCursorInfo(WinStaObject);
+                  /* FIXME limit the maximum time to 1000 ms? */
+                  CurInfo->DblClickSpeed = uiParam;
+                  break;
+               case SPI_SETDESKWALLPAPER:
+                  {
+                     /* This function expects different parameters than the user mode version!
+
+                        We let the user mode code load the bitmap, it passed the handle to
+                        the bitmap. We'll change it's ownership to system and replace it with
+                        the current wallpaper bitmap */
+                     HBITMAP hOldBitmap, hNewBitmap;
+                     ASSERT(pvParam);
+
+                     hNewBitmap = *(HBITMAP*)pvParam;
+                     if(hNewBitmap != NULL)
+                     {
+                        BITMAPOBJ *bmp;
+                        /* try to get the size of the wallpaper */
+                        if(!(bmp = BITMAPOBJ_LockBitmap(hNewBitmap)))
+                        {
+                           ObDereferenceObject(WinStaObject);
+                           return FALSE;
+                        }
+                        WinStaObject->cxWallpaper = bmp->SurfObj.sizlBitmap.cx;
+                        WinStaObject->cyWallpaper = bmp->SurfObj.sizlBitmap.cy;
+
+                        BITMAPOBJ_UnlockBitmap(bmp);
+
+                        /* change the bitmap's ownership */
+                        GDIOBJ_SetOwnership(hNewBitmap, NULL);
+                     }
+                     hOldBitmap = (HBITMAP)InterlockedExchange((LONG*)&WinStaObject->hbmWallpaper, (LONG)hNewBitmap);
+                     if(hOldBitmap != NULL)
+                     {
+                        /* delete the old wallpaper */
+                        NtGdiDeleteObject(hOldBitmap);
+                     }
+                     break;
+                  }
+               case SPI_GETDESKWALLPAPER:
+                  /* This function expects different parameters than the user mode version!
+
+                     We basically return the current wallpaper handle - if any. The user
+                     mode version should load the string from the registry and return it
+                     without calling this function */
+                  ASSERT(pvParam);
+                  *(HBITMAP*)pvParam = (HBITMAP)WinStaObject->hbmWallpaper;
+                  break;
+            }
 
-      ObDereferenceObject(WinStaObject);
-      return TRUE;
-    }
-    case SPI_SETWORKAREA:
-    {
-      RECT *rc;
-      PDESKTOP_OBJECT Desktop = PsGetWin32Thread()->Desktop;
+            /* FIXME save the value to the registry */
 
-      if(!Desktop)
-      {
-        /* FIXME - Set last error */
-        return FALSE;
-      }
+            ObDereferenceObject(WinStaObject);
+            return TRUE;
+         }
+      case SPI_SETWORKAREA:
+         {
+            RECT *rc;
+            PDESKTOP_OBJECT Desktop = PsGetWin32Thread()->Desktop;
+
+            if(!Desktop)
+            {
+               /* FIXME - Set last error */
+               return FALSE;
+            }
 
-      ASSERT(pvParam);
-      rc = (RECT*)pvParam;
-      Desktop->WorkArea = *rc;
+            ASSERT(pvParam);
+            rc = (RECT*)pvParam;
+            Desktop->WorkArea = *rc;
 
-      return TRUE;
-    }
-    case SPI_GETWORKAREA:
-    {
-      PDESKTOP_OBJECT Desktop = PsGetWin32Thread()->Desktop;
+            return TRUE;
+         }
+      case SPI_GETWORKAREA:
+         {
+            PDESKTOP_OBJECT Desktop = PsGetWin32Thread()->Desktop;
 
-      if(!Desktop)
-      {
-        /* FIXME - Set last error */
-        return FALSE;
-      }
+            if(!Desktop)
+            {
+               /* FIXME - Set last error */
+               return FALSE;
+            }
 
-      ASSERT(pvParam);
-      IntGetDesktopWorkArea(Desktop, (PRECT)pvParam);
-
-      return TRUE;
-    }
-    case SPI_SETGRADIENTCAPTIONS:
-    {
-      GradientCaptions = (pvParam != NULL);
-      /* FIXME - should be checked if the color depth is higher than 8bpp? */
-      return TRUE;
-    }
-    case SPI_GETGRADIENTCAPTIONS:
-    {
-      HDC hDC;
-      BOOL Ret = GradientCaptions;
-
-      hDC = IntGetScreenDC();
-      if(hDC)
-      {
-        Ret = (NtGdiGetDeviceCaps(hDC, BITSPIXEL) > 8) && Ret;
+            ASSERT(pvParam);
+            IntGetDesktopWorkArea(Desktop, (PRECT)pvParam);
+
+            return TRUE;
+         }
+      case SPI_SETGRADIENTCAPTIONS:
+         {
+            GradientCaptions = (pvParam != NULL);
+            /* FIXME - should be checked if the color depth is higher than 8bpp? */
+            return TRUE;
+         }
+      case SPI_GETGRADIENTCAPTIONS:
+         {
+            HDC hDC;
+            BOOL Ret = GradientCaptions;
+
+            hDC = IntGetScreenDC();
+            if(hDC)
+            {
+               Ret = (NtGdiGetDeviceCaps(hDC, BITSPIXEL) > 8) && Ret;
 
-        ASSERT(pvParam);
-        *((PBOOL)pvParam) = Ret;
-        return TRUE;
-      }
-      return FALSE;
-    }
-    case SPI_SETFONTSMOOTHING:
-    {
-      IntEnableFontRendering(uiParam != 0);
-      return TRUE;
-    }
-    case SPI_GETFONTSMOOTHING:
-    {
-      ASSERT(pvParam);
-      *((BOOL*)pvParam) = IntIsFontRenderingEnabled();
-      return TRUE;
-    }
-    case SPI_GETICONTITLELOGFONT:
-    {
-      ASSERT(pvParam);
-      *((LOGFONTW*)pvParam) = IconFont;
-      return TRUE;
-    }
-    case SPI_GETNONCLIENTMETRICS:
-    {
-      ASSERT(pvParam);
-      *((NONCLIENTMETRICSW*)pvParam) = pMetrics;
-      return TRUE;
-    }
-    case SPI_GETFOCUSBORDERHEIGHT:
-    {
-      ASSERT(pvParam);
-      *((UINT*)pvParam) = FocusBorderHeight;
-      return TRUE;
-    }
-    case SPI_GETFOCUSBORDERWIDTH:
-    {
-      ASSERT(pvParam);
-      *((UINT*)pvParam) = FocusBorderWidth;
-      return TRUE;
-    }
-    case SPI_SETFOCUSBORDERHEIGHT:
-    {
-      FocusBorderHeight = (UINT)pvParam;
-      return TRUE;
-    }
-    case SPI_SETFOCUSBORDERWIDTH:
-    {
-      FocusBorderWidth = (UINT)pvParam;
-      return TRUE;
-    }
-
-    default:
-    {
-      DPRINT1("SystemParametersInfo: Unsupported Action 0x%x (uiParam: 0x%x, pvParam: 0x%x, fWinIni: 0x%x)\n",
-              uiAction, uiParam, pvParam, fWinIni);
-      return FALSE;
-    }
-  }
-  return FALSE;
+               ASSERT(pvParam);
+               *((PBOOL)pvParam) = Ret;
+               return TRUE;
+            }
+            return FALSE;
+         }
+      case SPI_SETFONTSMOOTHING:
+         {
+            IntEnableFontRendering(uiParam != 0);
+            return TRUE;
+         }
+      case SPI_GETFONTSMOOTHING:
+         {
+            ASSERT(pvParam);
+            *((BOOL*)pvParam) = IntIsFontRenderingEnabled();
+            return TRUE;
+         }
+      case SPI_GETICONTITLELOGFONT:
+         {
+            ASSERT(pvParam);
+            *((LOGFONTW*)pvParam) = IconFont;
+            return TRUE;
+         }
+      case SPI_GETNONCLIENTMETRICS:
+         {
+            ASSERT(pvParam);
+            *((NONCLIENTMETRICSW*)pvParam) = pMetrics;
+            return TRUE;
+         }
+      case SPI_GETFOCUSBORDERHEIGHT:
+         {
+            ASSERT(pvParam);
+            *((UINT*)pvParam) = FocusBorderHeight;
+            return TRUE;
+         }
+      case SPI_GETFOCUSBORDERWIDTH:
+         {
+            ASSERT(pvParam);
+            *((UINT*)pvParam) = FocusBorderWidth;
+            return TRUE;
+         }
+      case SPI_SETFOCUSBORDERHEIGHT:
+         {
+            FocusBorderHeight = (UINT)pvParam;
+            return TRUE;
+         }
+      case SPI_SETFOCUSBORDERWIDTH:
+         {
+            FocusBorderWidth = (UINT)pvParam;
+            return TRUE;
+         }
+
+      default:
+         {
+            DPRINT1("SystemParametersInfo: Unsupported Action 0x%x (uiParam: 0x%x, pvParam: 0x%x, fWinIni: 0x%x)\n",
+                    uiAction, uiParam, pvParam, fWinIni);
+            return FALSE;
+         }
+   }
+   return FALSE;
 }
 
 /*
@@ -1097,152 +1106,152 @@ IntSystemParametersInfo(
  */
 BOOL FASTCALL
 UserSystemParametersInfo(
-  UINT uiAction,
-  UINT uiParam,
-  PVOID pvParam,
-  UINT fWinIni)
+   UINT uiAction,
+   UINT uiParam,
+   PVOID pvParam,
+   UINT fWinIni)
 {
-  NTSTATUS Status;
-
-  switch(uiAction)
-  {
-    case SPI_SETDOUBLECLKWIDTH:
-    case SPI_SETDOUBLECLKHEIGHT:
-    case SPI_SETDOUBLECLICKTIME:
-    case SPI_SETGRADIENTCAPTIONS:
-    case SPI_SETFONTSMOOTHING:
-    case SPI_SETFOCUSBORDERHEIGHT:
-    case SPI_SETFOCUSBORDERWIDTH:
-    {
-      return (DWORD)IntSystemParametersInfo(uiAction, uiParam, pvParam, fWinIni);
-    }
-    case SPI_SETWORKAREA:
-    {
-      RECT rc;
-      Status = MmCopyFromCaller(&rc, (PRECT)pvParam, sizeof(RECT));
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        return( FALSE);
-      }
-      return( (DWORD)IntSystemParametersInfo(uiAction, uiParam, &rc, fWinIni));
-    }
-    case SPI_GETWORKAREA:
-    {
-      RECT rc;
+   NTSTATUS Status;
 
-      if(!IntSystemParametersInfo(uiAction, uiParam, &rc, fWinIni))
-      {
-        return( FALSE);
-      }
+   switch(uiAction)
+   {
+      case SPI_SETDOUBLECLKWIDTH:
+      case SPI_SETDOUBLECLKHEIGHT:
+      case SPI_SETDOUBLECLICKTIME:
+      case SPI_SETGRADIENTCAPTIONS:
+      case SPI_SETFONTSMOOTHING:
+      case SPI_SETFOCUSBORDERHEIGHT:
+      case SPI_SETFOCUSBORDERWIDTH:
+         {
+            return (DWORD)IntSystemParametersInfo(uiAction, uiParam, pvParam, fWinIni);
+         }
+      case SPI_SETWORKAREA:
+         {
+            RECT rc;
+            Status = MmCopyFromCaller(&rc, (PRECT)pvParam, sizeof(RECT));
+            if(!NT_SUCCESS(Status))
+            {
+               SetLastNtError(Status);
+               return( FALSE);
+            }
+            return( (DWORD)IntSystemParametersInfo(uiAction, uiParam, &rc, fWinIni));
+         }
+      case SPI_GETWORKAREA:
+         {
+            RECT rc;
 
-      Status = MmCopyToCaller((PRECT)pvParam, &rc, sizeof(RECT));
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        return( FALSE);
-      }
-      return( TRUE);
-    }
-    case SPI_GETFONTSMOOTHING:
-    case SPI_GETGRADIENTCAPTIONS:
-    case SPI_GETFOCUSBORDERHEIGHT:
-    case SPI_GETFOCUSBORDERWIDTH:
-    {
-      BOOL Ret;
-
-      if(!IntSystemParametersInfo(uiAction, uiParam, &Ret, fWinIni))
-      {
-        return( FALSE);
-      }
+            if(!IntSystemParametersInfo(uiAction, uiParam, &rc, fWinIni))
+            {
+               return( FALSE);
+            }
 
-      Status = MmCopyToCaller(pvParam, &Ret, sizeof(BOOL));
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        return( FALSE);
-      }
-      return( TRUE);
-    }
-    case SPI_SETDESKWALLPAPER:
-    {
-      /* !!! As opposed to the user mode version this version accepts a handle
-             to the bitmap! */
-      HBITMAP hbmWallpaper;
-
-      Status = MmCopyFromCaller(&hbmWallpaper, pvParam, sizeof(HBITMAP));
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        return( FALSE);
-      }
-      return( IntSystemParametersInfo(SPI_SETDESKWALLPAPER, 0, &hbmWallpaper, fWinIni));
-    }
-    case SPI_GETDESKWALLPAPER:
-    {
-      /* !!! As opposed to the user mode version this version returns a handle
-             to the bitmap! */
-      HBITMAP hbmWallpaper;
-      BOOL Ret;
-
-      Ret = IntSystemParametersInfo(SPI_GETDESKWALLPAPER, 0, &hbmWallpaper, fWinIni);
-
-      Status = MmCopyToCaller(pvParam, &hbmWallpaper, sizeof(HBITMAP));
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        return( FALSE);
-      }
-      return( Ret);
-    }
-    case SPI_GETICONTITLELOGFONT:
-    {
-      LOGFONTW IconFont;
+            Status = MmCopyToCaller((PRECT)pvParam, &rc, sizeof(RECT));
+            if(!NT_SUCCESS(Status))
+            {
+               SetLastNtError(Status);
+               return( FALSE);
+            }
+            return( TRUE);
+         }
+      case SPI_GETFONTSMOOTHING:
+      case SPI_GETGRADIENTCAPTIONS:
+      case SPI_GETFOCUSBORDERHEIGHT:
+      case SPI_GETFOCUSBORDERWIDTH:
+         {
+            BOOL Ret;
+
+            if(!IntSystemParametersInfo(uiAction, uiParam, &Ret, fWinIni))
+            {
+               return( FALSE);
+            }
 
-      if(!IntSystemParametersInfo(uiAction, uiParam, &IconFont, fWinIni))
-      {
-        return( FALSE);
-      }
+            Status = MmCopyToCaller(pvParam, &Ret, sizeof(BOOL));
+            if(!NT_SUCCESS(Status))
+            {
+               SetLastNtError(Status);
+               return( FALSE);
+            }
+            return( TRUE);
+         }
+      case SPI_SETDESKWALLPAPER:
+         {
+            /* !!! As opposed to the user mode version this version accepts a handle
+                   to the bitmap! */
+            HBITMAP hbmWallpaper;
+
+            Status = MmCopyFromCaller(&hbmWallpaper, pvParam, sizeof(HBITMAP));
+            if(!NT_SUCCESS(Status))
+            {
+               SetLastNtError(Status);
+               return( FALSE);
+            }
+            return( IntSystemParametersInfo(SPI_SETDESKWALLPAPER, 0, &hbmWallpaper, fWinIni));
+         }
+      case SPI_GETDESKWALLPAPER:
+         {
+            /* !!! As opposed to the user mode version this version returns a handle
+                   to the bitmap! */
+            HBITMAP hbmWallpaper;
+            BOOL Ret;
+
+            Ret = IntSystemParametersInfo(SPI_GETDESKWALLPAPER, 0, &hbmWallpaper, fWinIni);
+
+            Status = MmCopyToCaller(pvParam, &hbmWallpaper, sizeof(HBITMAP));
+            if(!NT_SUCCESS(Status))
+            {
+               SetLastNtError(Status);
+               return( FALSE);
+            }
+            return( Ret);
+         }
+      case SPI_GETICONTITLELOGFONT:
+         {
+            LOGFONTW IconFont;
 
-      Status = MmCopyToCaller(pvParam, &IconFont, sizeof(LOGFONTW));
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        return( FALSE);
-      }
-      return( TRUE);
-    }
-    case SPI_GETNONCLIENTMETRICS:
-    {
-      NONCLIENTMETRICSW metrics;
+            if(!IntSystemParametersInfo(uiAction, uiParam, &IconFont, fWinIni))
+            {
+               return( FALSE);
+            }
 
-      Status = MmCopyFromCaller(&metrics.cbSize, pvParam, sizeof(UINT));
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        return( FALSE);
-      }
-      if(metrics.cbSize != sizeof(NONCLIENTMETRICSW))
-      {
-        SetLastWin32Error(ERROR_INVALID_PARAMETER);
-        return( FALSE);
-      }
+            Status = MmCopyToCaller(pvParam, &IconFont, sizeof(LOGFONTW));
+            if(!NT_SUCCESS(Status))
+            {
+               SetLastNtError(Status);
+               return( FALSE);
+            }
+            return( TRUE);
+         }
+      case SPI_GETNONCLIENTMETRICS:
+         {
+            NONCLIENTMETRICSW metrics;
+
+            Status = MmCopyFromCaller(&metrics.cbSize, pvParam, sizeof(UINT));
+            if(!NT_SUCCESS(Status))
+            {
+               SetLastNtError(Status);
+               return( FALSE);
+            }
+            if(metrics.cbSize != sizeof(NONCLIENTMETRICSW))
+            {
+               SetLastWin32Error(ERROR_INVALID_PARAMETER);
+               return( FALSE);
+            }
 
-      if(!IntSystemParametersInfo(uiAction, uiParam, &metrics, fWinIni))
-      {
-        return( FALSE);
-      }
+            if(!IntSystemParametersInfo(uiAction, uiParam, &metrics, fWinIni))
+            {
+               return( FALSE);
+            }
 
-      Status = MmCopyToCaller(pvParam, &metrics.cbSize, sizeof(NONCLIENTMETRICSW));
-      if(!NT_SUCCESS(Status))
-      {
-        SetLastNtError(Status);
-        return( FALSE);
-      }
-      return( TRUE);
-    }
-  }
-  return( FALSE);
+            Status = MmCopyToCaller(pvParam, &metrics.cbSize, sizeof(NONCLIENTMETRICSW));
+            if(!NT_SUCCESS(Status))
+            {
+               SetLastNtError(Status);
+               return( FALSE);
+            }
+            return( TRUE);
+         }
+   }
+   return( FALSE);
 }
 
 
@@ -1254,22 +1263,22 @@ UserSystemParametersInfo(
 BOOL
 STDCALL
 NtUserSystemParametersInfo(
-  UINT uiAction,
-  UINT uiParam,
-  PVOID pvParam,
-  UINT fWinIni)
+   UINT uiAction,
+   UINT uiParam,
+   PVOID pvParam,
+   UINT fWinIni)
 {
-  DECLARE_RETURN(BOOLEAN);  
+   DECLARE_RETURN(BOOLEAN);
+
+   DPRINT("Enter NtUserSystemParametersInfo\n");
+   UserEnterExclusive();
 
-  DPRINT("Enter NtUserSystemParametersInfo\n");
-  UserEnterExclusive();
+   RETURN( UserSystemParametersInfo(uiAction, uiParam, pvParam, fWinIni));
 
-  RETURN( UserSystemParametersInfo(uiAction, uiParam, pvParam, fWinIni));
-  
 CLEANUP:
-  DPRINT("Leave NtUserSystemParametersInfo, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserSystemParametersInfo, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -1278,328 +1287,328 @@ UINT
 STDCALL
 NtUserGetDoubleClickTime(VOID)
 {
-  UINT Result;
-  NTSTATUS Status;
-  PWINSTATION_OBJECT WinStaObject;
-  PSYSTEM_CURSORINFO CurInfo;
-  DECLARE_RETURN(UINT);  
-
-  DPRINT("Enter NtUserGetDoubleClickTime\n");
-  UserEnterShared();
-
-  Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
-                                          KernelMode,
-                                          0,
-                                          &WinStaObject);
-  if (!NT_SUCCESS(Status))
-    RETURN( (DWORD)FALSE);
-
-  CurInfo = IntGetSysCursorInfo(WinStaObject);
-  Result = CurInfo->DblClickSpeed;
-
-  ObDereferenceObject(WinStaObject);
-  RETURN( Result);
-  
+   UINT Result;
+   NTSTATUS Status;
+   PWINSTATION_OBJECT WinStaObject;
+   PSYSTEM_CURSORINFO CurInfo;
+   DECLARE_RETURN(UINT);
+
+   DPRINT("Enter NtUserGetDoubleClickTime\n");
+   UserEnterShared();
+
+   Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
+                                           KernelMode,
+                                           0,
+                                           &WinStaObject);
+   if (!NT_SUCCESS(Status))
+      RETURN( (DWORD)FALSE);
+
+   CurInfo = IntGetSysCursorInfo(WinStaObject);
+   Result = CurInfo->DblClickSpeed;
+
+   ObDereferenceObject(WinStaObject);
+   RETURN( Result);
+
 CLEANUP:
-  DPRINT("Leave NtUserGetDoubleClickTime, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;  
+   DPRINT("Leave NtUserGetDoubleClickTime, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 BOOL
 STDCALL
 NtUserGetGUIThreadInfo(
-  DWORD idThread, /* if NULL use foreground thread */
-  LPGUITHREADINFO lpgui)
+   DWORD idThread, /* if NULL use foreground thread */
+   LPGUITHREADINFO lpgui)
 {
-  NTSTATUS Status;
-  PTHRDCARETINFO CaretInfo;
-  GUITHREADINFO SafeGui;
-  PDESKTOP_OBJECT Desktop;
-  PUSER_MESSAGE_QUEUE MsgQueue;
-  PETHREAD Thread = NULL;
-  DECLARE_RETURN(BOOLEAN);  
-
-  DPRINT("Enter NtUserGetGUIThreadInfo\n");
-  UserEnterShared();
-
-  Status = MmCopyFromCaller(&SafeGui, lpgui, sizeof(DWORD));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    RETURN( FALSE);
-  }
-
-  if(SafeGui.cbSize != sizeof(GUITHREADINFO))
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    RETURN( FALSE);
-  }
-
-  if(idThread)
-  {
-    Status = PsLookupThreadByThreadId((HANDLE)idThread, &Thread);
-    if(!NT_SUCCESS(Status))
-    {
-      SetLastWin32Error(ERROR_ACCESS_DENIED);
+   NTSTATUS Status;
+   PTHRDCARETINFO CaretInfo;
+   GUITHREADINFO SafeGui;
+   PDESKTOP_OBJECT Desktop;
+   PUSER_MESSAGE_QUEUE MsgQueue;
+   PETHREAD Thread = NULL;
+   DECLARE_RETURN(BOOLEAN);
+
+   DPRINT("Enter NtUserGetGUIThreadInfo\n");
+   UserEnterShared();
+
+   Status = MmCopyFromCaller(&SafeGui, lpgui, sizeof(DWORD));
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      RETURN( FALSE);
+   }
+
+   if(SafeGui.cbSize != sizeof(GUITHREADINFO))
+   {
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
       RETURN( FALSE);
-    }
-    Desktop = Thread->Tcb.Win32Thread->Desktop;
-  }
-  else
-  {
-    /* get the foreground thread */
-    PW32THREAD W32Thread = PsGetCurrentThread()->Tcb.Win32Thread;
-    Desktop = W32Thread->Desktop;
-    if(Desktop)
-    {
-      MsgQueue = Desktop->ActiveMessageQueue;
-      if(MsgQueue)
+   }
+
+   if(idThread)
+   {
+      Status = PsLookupThreadByThreadId((HANDLE)idThread, &Thread);
+      if(!NT_SUCCESS(Status))
       {
-        Thread = MsgQueue->Thread;
+         SetLastWin32Error(ERROR_ACCESS_DENIED);
+         RETURN( FALSE);
       }
-    }
-  }
+      Desktop = Thread->Tcb.Win32Thread->Desktop;
+   }
+   else
+   {
+      /* get the foreground thread */
+      PW32THREAD W32Thread = PsGetCurrentThread()->Tcb.Win32Thread;
+      Desktop = W32Thread->Desktop;
+      if(Desktop)
+      {
+         MsgQueue = Desktop->ActiveMessageQueue;
+         if(MsgQueue)
+         {
+            Thread = MsgQueue->Thread;
+         }
+      }
+   }
 
-  if(!Thread || !Desktop)
-  {
-    if(idThread && Thread)
+   if(!Thread || !Desktop)
+   {
+      if(idThread && Thread)
+         ObDereferenceObject(Thread);
+      SetLastWin32Error(ERROR_ACCESS_DENIED);
+      RETURN( FALSE);
+   }
+
+   MsgQueue = (PUSER_MESSAGE_QUEUE)Desktop->ActiveMessageQueue;
+   CaretInfo = MsgQueue->CaretInfo;
+
+   SafeGui.flags = (CaretInfo->Visible ? GUI_CARETBLINKING : 0);
+   if(MsgQueue->MenuOwner)
+      SafeGui.flags |= GUI_INMENUMODE | MsgQueue->MenuState;
+   if(MsgQueue->MoveSize)
+      SafeGui.flags |= GUI_INMOVESIZE;
+
+   /* FIXME add flag GUI_16BITTASK */
+
+   SafeGui.hwndActive = MsgQueue->ActiveWindow;
+   SafeGui.hwndFocus = MsgQueue->FocusWindow;
+   SafeGui.hwndCapture = MsgQueue->CaptureWindow;
+   SafeGui.hwndMenuOwner = MsgQueue->MenuOwner;
+   SafeGui.hwndMoveSize = MsgQueue->MoveSize;
+   SafeGui.hwndCaret = CaretInfo->hWnd;
+
+   SafeGui.rcCaret.left = CaretInfo->Pos.x;
+   SafeGui.rcCaret.top = CaretInfo->Pos.y;
+   SafeGui.rcCaret.right = SafeGui.rcCaret.left + CaretInfo->Size.cx;
+   SafeGui.rcCaret.bottom = SafeGui.rcCaret.top + CaretInfo->Size.cy;
+
+   if(idThread)
       ObDereferenceObject(Thread);
-    SetLastWin32Error(ERROR_ACCESS_DENIED);
-    RETURN( FALSE);
-  }
-
-  MsgQueue = (PUSER_MESSAGE_QUEUE)Desktop->ActiveMessageQueue;
-  CaretInfo = MsgQueue->CaretInfo;
-
-  SafeGui.flags = (CaretInfo->Visible ? GUI_CARETBLINKING : 0);
-  if(MsgQueue->MenuOwner)
-    SafeGui.flags |= GUI_INMENUMODE | MsgQueue->MenuState;
-  if(MsgQueue->MoveSize)
-    SafeGui.flags |= GUI_INMOVESIZE;
-
-  /* FIXME add flag GUI_16BITTASK */
-
-  SafeGui.hwndActive = MsgQueue->ActiveWindow;
-  SafeGui.hwndFocus = MsgQueue->FocusWindow;
-  SafeGui.hwndCapture = MsgQueue->CaptureWindow;
-  SafeGui.hwndMenuOwner = MsgQueue->MenuOwner;
-  SafeGui.hwndMoveSize = MsgQueue->MoveSize;
-  SafeGui.hwndCaret = CaretInfo->hWnd;
-
-  SafeGui.rcCaret.left = CaretInfo->Pos.x;
-  SafeGui.rcCaret.top = CaretInfo->Pos.y;
-  SafeGui.rcCaret.right = SafeGui.rcCaret.left + CaretInfo->Size.cx;
-  SafeGui.rcCaret.bottom = SafeGui.rcCaret.top + CaretInfo->Size.cy;
-
-  if(idThread)
-    ObDereferenceObject(Thread);
-
-  Status = MmCopyToCaller(lpgui, &SafeGui, sizeof(GUITHREADINFO));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    RETURN( FALSE);
-  }
-
-  RETURN( TRUE);
-  
+
+   Status = MmCopyToCaller(lpgui, &SafeGui, sizeof(GUITHREADINFO));
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      RETURN( FALSE);
+   }
+
+   RETURN( TRUE);
+
 CLEANUP:
-  DPRINT("Leave NtUserGetGUIThreadInfo, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP; 
+   DPRINT("Leave NtUserGetGUIThreadInfo, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
 DWORD
 STDCALL
 NtUserGetGuiResources(
-  HANDLE hProcess,
-  DWORD uiFlags)
+   HANDLE hProcess,
+   DWORD uiFlags)
 {
-  PEPROCESS Process;
-  PW32PROCESS W32Process;
-  NTSTATUS Status;
-  DWORD Ret = 0;
-  DECLARE_RETURN(DWORD);  
-
-  DPRINT("Enter NtUserGetGuiResources\n");
-  UserEnterShared();
-
-  Status = ObReferenceObjectByHandle(hProcess,
-                                     PROCESS_QUERY_INFORMATION,
-                                     PsProcessType,
-                                     ExGetPreviousMode(),
-                                     (PVOID*)&Process,
-                                     NULL);
-
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    RETURN( 0);
-  }
-
-  W32Process = (PW32PROCESS)Process->Win32Process;
-  if(!W32Process)
-  {
-    ObDereferenceObject(Process);
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    RETURN( 0);
-  }
-
-  switch(uiFlags)
-  {
-    case GR_GDIOBJECTS:
-    {
-      Ret = (DWORD)W32Process->GDIObjects;
-      break;
-    }
-    case GR_USEROBJECTS:
-    {
-      Ret = (DWORD)W32Process->UserObjects;
-      break;
-    }
-    default:
-    {
+   PEPROCESS Process;
+   PW32PROCESS W32Process;
+   NTSTATUS Status;
+   DWORD Ret = 0;
+   DECLARE_RETURN(DWORD);
+
+   DPRINT("Enter NtUserGetGuiResources\n");
+   UserEnterShared();
+
+   Status = ObReferenceObjectByHandle(hProcess,
+                                      PROCESS_QUERY_INFORMATION,
+                                      PsProcessType,
+                                      ExGetPreviousMode(),
+                                      (PVOID*)&Process,
+                                      NULL);
+
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      RETURN( 0);
+   }
+
+   W32Process = (PW32PROCESS)Process->Win32Process;
+   if(!W32Process)
+   {
+      ObDereferenceObject(Process);
       SetLastWin32Error(ERROR_INVALID_PARAMETER);
-      break;
-    }
-  }
+      RETURN( 0);
+   }
+
+   switch(uiFlags)
+   {
+      case GR_GDIOBJECTS:
+         {
+            Ret = (DWORD)W32Process->GDIObjects;
+            break;
+         }
+      case GR_USEROBJECTS:
+         {
+            Ret = (DWORD)W32Process->UserObjects;
+            break;
+         }
+      default:
+         {
+            SetLastWin32Error(ERROR_INVALID_PARAMETER);
+            break;
+         }
+   }
 
-  ObDereferenceObject(Process);
+   ObDereferenceObject(Process);
+
+   RETURN( Ret);
 
-  RETURN( Ret);
-  
 CLEANUP:
-  DPRINT("Leave NtUserGetGuiResources, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetGuiResources, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 NTSTATUS FASTCALL
 IntSafeCopyUnicodeString(PUNICODE_STRING Dest,
                          PUNICODE_STRING Source)
 {
-  NTSTATUS Status;
-  PWSTR Src;
-
-  Status = MmCopyFromCaller(Dest, Source, sizeof(UNICODE_STRING));
-  if(!NT_SUCCESS(Status))
-  {
-    return Status;
-  }
-
-  if(Dest->Length > 0x4000)
-  {
-    return STATUS_UNSUCCESSFUL;
-  }
-
-  Src = Dest->Buffer;
-  Dest->Buffer = NULL;
-
-  if(Dest->Length > 0 && Src)
-  {
-    Dest->MaximumLength = Dest->Length;
-    Dest->Buffer = ExAllocatePoolWithTag(PagedPool, Dest->MaximumLength, TAG_STRING);
-    if(!Dest->Buffer)
-    {
-      return STATUS_NO_MEMORY;
-    }
+   NTSTATUS Status;
+   PWSTR Src;
 
-    Status = MmCopyFromCaller(Dest->Buffer, Src, Dest->Length);
-    if(!NT_SUCCESS(Status))
-    {
-      ExFreePool(Dest->Buffer);
-      Dest->Buffer = NULL;
+   Status = MmCopyFromCaller(Dest, Source, sizeof(UNICODE_STRING));
+   if(!NT_SUCCESS(Status))
+   {
       return Status;
-    }
+   }
+
+   if(Dest->Length > 0x4000)
+   {
+      return STATUS_UNSUCCESSFUL;
+   }
+
+   Src = Dest->Buffer;
+   Dest->Buffer = NULL;
+
+   if(Dest->Length > 0 && Src)
+   {
+      Dest->MaximumLength = Dest->Length;
+      Dest->Buffer = ExAllocatePoolWithTag(PagedPool, Dest->MaximumLength, TAG_STRING);
+      if(!Dest->Buffer)
+      {
+         return STATUS_NO_MEMORY;
+      }
+
+      Status = MmCopyFromCaller(Dest->Buffer, Src, Dest->Length);
+      if(!NT_SUCCESS(Status))
+      {
+         ExFreePool(Dest->Buffer);
+         Dest->Buffer = NULL;
+         return Status;
+      }
 
 
-    return STATUS_SUCCESS;
-  }
+      return STATUS_SUCCESS;
+   }
 
-  /* string is empty */
-  return STATUS_SUCCESS;
+   /* string is empty */
+   return STATUS_SUCCESS;
 }
 
 NTSTATUS FASTCALL
 IntSafeCopyUnicodeStringTerminateNULL(PUNICODE_STRING Dest,
                                       PUNICODE_STRING Source)
 {
-  NTSTATUS Status;
-  PWSTR Src;
-
-  Status = MmCopyFromCaller(Dest, Source, sizeof(UNICODE_STRING));
-  if(!NT_SUCCESS(Status))
-  {
-    return Status;
-  }
-
-  if(Dest->Length > 0x4000)
-  {
-    return STATUS_UNSUCCESSFUL;
-  }
-
-  Src = Dest->Buffer;
-  Dest->Buffer = NULL;
-
-  if(Dest->Length > 0 && Src)
-  {
-    Dest->MaximumLength = Dest->Length + sizeof(WCHAR);
-    Dest->Buffer = ExAllocatePoolWithTag(PagedPool, Dest->MaximumLength, TAG_STRING);
-    if(!Dest->Buffer)
-    {
-      return STATUS_NO_MEMORY;
-    }
+   NTSTATUS Status;
+   PWSTR Src;
 
-    Status = MmCopyFromCaller(Dest->Buffer, Src, Dest->Length);
-    if(!NT_SUCCESS(Status))
-    {
-      ExFreePool(Dest->Buffer);
-      Dest->Buffer = NULL;
+   Status = MmCopyFromCaller(Dest, Source, sizeof(UNICODE_STRING));
+   if(!NT_SUCCESS(Status))
+   {
       return Status;
-    }
+   }
+
+   if(Dest->Length > 0x4000)
+   {
+      return STATUS_UNSUCCESSFUL;
+   }
+
+   Src = Dest->Buffer;
+   Dest->Buffer = NULL;
+
+   if(Dest->Length > 0 && Src)
+   {
+      Dest->MaximumLength = Dest->Length + sizeof(WCHAR);
+      Dest->Buffer = ExAllocatePoolWithTag(PagedPool, Dest->MaximumLength, TAG_STRING);
+      if(!Dest->Buffer)
+      {
+         return STATUS_NO_MEMORY;
+      }
+
+      Status = MmCopyFromCaller(Dest->Buffer, Src, Dest->Length);
+      if(!NT_SUCCESS(Status))
+      {
+         ExFreePool(Dest->Buffer);
+         Dest->Buffer = NULL;
+         return Status;
+      }
 
-    /* make sure the string is null-terminated */
-    Src = (PWSTR)((PBYTE)Dest->Buffer + Dest->Length);
-    *Src = L'\0';
+      /* make sure the string is null-terminated */
+      Src = (PWSTR)((PBYTE)Dest->Buffer + Dest->Length);
+      *Src = L'\0';
 
-    return STATUS_SUCCESS;
-  }
+      return STATUS_SUCCESS;
+   }
 
-  /* string is empty */
-  return STATUS_SUCCESS;
+   /* string is empty */
+   return STATUS_SUCCESS;
 }
 
 NTSTATUS FASTCALL
 IntUnicodeStringToNULLTerminated(PWSTR *Dest, PUNICODE_STRING Src)
 {
-  if (Src->Length + sizeof(WCHAR) <= Src->MaximumLength
-      && L'\0' == Src->Buffer[Src->Length / sizeof(WCHAR)])
-    {
+   if (Src->Length + sizeof(WCHAR) <= Src->MaximumLength
+         && L'\0' == Src->Buffer[Src->Length / sizeof(WCHAR)])
+   {
       /* The unicode_string is already nul terminated. Just reuse it. */
       *Dest = Src->Buffer;
       return STATUS_SUCCESS;
-    }
+   }
 
-  *Dest = ExAllocatePoolWithTag(PagedPool, Src->Length + sizeof(WCHAR), TAG_STRING);
-  if (NULL == *Dest)
-    {
+   *Dest = ExAllocatePoolWithTag(PagedPool, Src->Length + sizeof(WCHAR), TAG_STRING);
+   if (NULL == *Dest)
+   {
       return STATUS_NO_MEMORY;
-    }
-  RtlCopyMemory(*Dest, Src->Buffer, Src->Length);
-  (*Dest)[Src->Length / 2] = L'\0';
+   }
+   RtlCopyMemory(*Dest, Src->Buffer, Src->Length);
+   (*Dest)[Src->Length / 2] = L'\0';
 
-  return STATUS_SUCCESS;
+   return STATUS_SUCCESS;
 }
 
 void FASTCALL
 IntFreeNULLTerminatedFromUnicodeString(PWSTR NullTerminated, PUNICODE_STRING UnicodeString)
 {
-  if (NullTerminated != UnicodeString->Buffer)
-    {
+   if (NullTerminated != UnicodeString->Buffer)
+   {
       ExFreePool(NullTerminated);
-    }
+   }
 }
 
 BOOL STDCALL
@@ -1608,14 +1617,14 @@ NtUserUpdatePerUserSystemParameters(
    BOOL bEnable)
 {
    BOOL Result = TRUE;
-   DECLARE_RETURN(BOOLEAN);  
+   DECLARE_RETURN(BOOLEAN);
 
    DPRINT("Enter NtUserUpdatePerUserSystemParameters\n");
    UserEnterExclusive();
-   
+
    Result &= IntDesktopUpdatePerUserSettings(bEnable);
    RETURN( Result);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserUpdatePerUserSystemParameters, ret=%i\n",_ret_);
    UserLeave();
index 708c1e0..48e7f84 100644 (file)
@@ -49,19 +49,19 @@ static FAST_MUTEX MonitorListLock; /* R/W lock for monitor list */
 NTSTATUS
 InitMonitorImpl()
 {
-  DPRINT("Initializing monitor implementation...\n");
-  ExInitializeFastMutex(&MonitorListLock);
+   DPRINT("Initializing monitor implementation...\n");
+   ExInitializeFastMutex(&MonitorListLock);
 
-  return STATUS_SUCCESS;
+   return STATUS_SUCCESS;
 }
 
 NTSTATUS
 CleanupMonitorImpl()
 {
-  DPRINT("Cleaning up monitor implementation...\n");
-  /* FIXME: Destroy monitor objects? */
+   DPRINT("Cleaning up monitor implementation...\n");
+   /* FIXME: Destroy monitor objects? */
 
-  return STATUS_SUCCESS;
+   return STATUS_SUCCESS;
 }
 
 /* PRIVATE FUNCTIONS **********************************************************/
@@ -88,19 +88,19 @@ static
 PMONITOR_OBJECT
 IntCreateMonitorObject()
 {
-  HANDLE Handle;
-  PMONITOR_OBJECT Monitor;
+   HANDLE Handle;
+   PMONITOR_OBJECT Monitor;
 
-  Monitor = ObmCreateObject(&gHandleTable, &Handle, otMonitor, sizeof (MONITOR_OBJECT));
-  if (Monitor == NULL)
-    {
+   Monitor = ObmCreateObject(&gHandleTable, &Handle, otMonitor, sizeof (MONITOR_OBJECT));
+   if (Monitor == NULL)
+   {
       return NULL;
-    }
+   }
 
-  Monitor->Handle = Handle;
-  ExInitializeFastMutex(&Monitor->Lock);
+   Monitor->Handle = Handle;
+   ExInitializeFastMutex(&Monitor->Lock);
 
-  return Monitor;
+   return Monitor;
 }
 
 /* IntDestroyMonitorObject
@@ -117,8 +117,8 @@ static
 void
 IntDestroyMonitorObject(IN PMONITOR_OBJECT pMonitor)
 {
-  RtlFreeUnicodeString(&pMonitor->DeviceName);
-  ObmDereferenceObject(pMonitor);
+   RtlFreeUnicodeString(&pMonitor->DeviceName);
+   ObmDereferenceObject(pMonitor);
 }
 
 /* IntGetMonitorObject
@@ -145,11 +145,11 @@ IntGetMonitorObject(IN HMONITOR hMonitor)
       SetLastWin32Error(ERROR_INVALID_MONITOR_HANDLE);
       return NULL;
    }
-   
+
    ASSERT(USER_BODY_TO_HEADER(Monitor)->RefCount >= 0);
-   
+
    USER_BODY_TO_HEADER(Monitor)->RefCount++;
-   
+
    return Monitor;
 }
 
@@ -163,7 +163,7 @@ IntGetMonitorObject(IN HMONITOR hMonitor)
  *     MONITOR_OBJECT to be released
  */
 #define IntReleaseMonitorObject(MonitorObj) \
-                       ObmDereferenceObject(MonitorObj);
+   ObmDereferenceObject(MonitorObj);
 
 /* IntAttachMonitor
  *
@@ -181,47 +181,48 @@ NTSTATUS
 IntAttachMonitor(IN GDIDEVICE *pGdiDevice,
                  IN ULONG DisplayNumber)
 {
-  PMONITOR_OBJECT Monitor;
-  WCHAR Buffer[CCHDEVICENAME];
+   PMONITOR_OBJECT Monitor;
+   WCHAR Buffer[CCHDEVICENAME];
 
-  DPRINT("Attaching monitor...\n");
+   DPRINT("Attaching monitor...\n");
 
-  /* create new monitor object */
-  Monitor = IntCreateMonitorObject();
-  if (Monitor == NULL)
-    {
+   /* create new monitor object */
+   Monitor = IntCreateMonitorObject();
+   if (Monitor == NULL)
+   {
       DPRINT("Couldnt create monitor object\n");
       return STATUS_INSUFFICIENT_RESOURCES;
-    }
+   }
 
-  _snwprintf(Buffer, CCHDEVICENAME, L"\\??\\DISPLAY%d", DisplayNumber + 1);
-  if (!RtlCreateUnicodeString(&Monitor->DeviceName, Buffer))
-    {
+   _snwprintf(Buffer, CCHDEVICENAME, L"\\??\\DISPLAY%d", DisplayNumber + 1);
+   if (!RtlCreateUnicodeString(&Monitor->DeviceName, Buffer))
+   {
       DPRINT("Couldn't duplicate monitor name!\n");
       return STATUS_INSUFFICIENT_RESOURCES;
-    }
+   }
 
-  Monitor->GdiDevice = pGdiDevice;
-  ExAcquireFastMutex(&MonitorListLock);
-  if (MonitorList == NULL)
-    {
+   Monitor->GdiDevice = pGdiDevice;
+   ExAcquireFastMutex(&MonitorListLock);
+   if (MonitorList == NULL)
+   {
       DPRINT("Primary monitor is beeing attached\n");
       Monitor->IsPrimary = TRUE;
       MonitorList = Monitor;
-    }
-  else
-    {
+   }
+   else
+   {
       PMONITOR_OBJECT p;
       DPRINT("Additional monitor is beeing attached\n");
-      for (p = MonitorList; p->Next != NULL; p = p->Next);
-        {
-          p->Next = Monitor;
-        }
+      for (p = MonitorList; p->Next != NULL; p = p->Next)
+         ;
+      {
+         p->Next = Monitor;
+      }
       Monitor->Prev = p;
-    }
-  ExReleaseFastMutex(&MonitorListLock);
+   }
+   ExReleaseFastMutex(&MonitorListLock);
 
-  return STATUS_SUCCESS;
+   return STATUS_SUCCESS;
 }
 
 /* IntDetachMonitor
@@ -238,48 +239,48 @@ IntAttachMonitor(IN GDIDEVICE *pGdiDevice,
 NTSTATUS
 IntDetachMonitor(IN GDIDEVICE *pGdiDevice)
 {
-  PMONITOR_OBJECT Monitor;
+   PMONITOR_OBJECT Monitor;
 
-  ExAcquireFastMutex(&MonitorListLock);
-  for (Monitor = MonitorList; Monitor != NULL; Monitor = Monitor->Next)
-    {
+   ExAcquireFastMutex(&MonitorListLock);
+   for (Monitor = MonitorList; Monitor != NULL; Monitor = Monitor->Next)
+   {
       if (Monitor->GdiDevice == pGdiDevice)
-        break;
-    }
+         break;
+   }
 
-  if (Monitor == NULL)
-    {
+   if (Monitor == NULL)
+   {
       /* no monitor for given device found */
       ExReleaseFastMutex(&MonitorListLock);
       return STATUS_INVALID_PARAMETER;
-    }
+   }
 
-  if (Monitor->IsPrimary && (Monitor->Next != NULL || Monitor->Prev != NULL))
-    {
+   if (Monitor->IsPrimary && (Monitor->Next != NULL || Monitor->Prev != NULL))
+   {
       PMONITOR_OBJECT NewPrimaryMonitor = (Monitor->Prev != NULL) ? (Monitor->Prev) : (Monitor->Next);
 
       ExAcquireFastMutex(&NewPrimaryMonitor->Lock);
       NewPrimaryMonitor->IsPrimary = TRUE;
       ExReleaseFastMutex(&NewPrimaryMonitor->Lock);
-    }
+   }
 
-  if (MonitorList == Monitor)
-    {
+   if (MonitorList == Monitor)
+   {
       MonitorList = Monitor->Next;
       if (Monitor->Next != NULL)
-        Monitor->Next->Prev = NULL;
-    }
-  else
-    {
+         Monitor->Next->Prev = NULL;
+   }
+   else
+   {
       Monitor->Prev->Next = Monitor->Next;
       if (Monitor->Next != NULL)
-        Monitor->Next->Prev = Monitor->Prev;
-    }
-  ExReleaseFastMutex(&MonitorListLock);
+         Monitor->Next->Prev = Monitor->Prev;
+   }
+   ExReleaseFastMutex(&MonitorListLock);
 
-  IntDestroyMonitorObject(Monitor);
+   IntDestroyMonitorObject(Monitor);
 
-  return STATUS_SUCCESS;
+   return STATUS_SUCCESS;
 }
 
 /* IntGetPrimaryMonitor
@@ -293,18 +294,18 @@ static
 PMONITOR_OBJECT
 IntGetPrimaryMonitor()
 {
-  PMONITOR_OBJECT Monitor;
+   PMONITOR_OBJECT Monitor;
 
-  ExAcquireFastMutex(&MonitorListLock);
-  for (Monitor = MonitorList; Monitor != NULL; Monitor = Monitor->Next)
-    {
+   ExAcquireFastMutex(&MonitorListLock);
+   for (Monitor = MonitorList; Monitor != NULL; Monitor = Monitor->Next)
+   {
       /* FIXME: I guess locking the monitor is not neccessary to read 1 int */
       if (Monitor->IsPrimary)
-        break;
-    }
-  ExReleaseFastMutex(&MonitorListLock);
+         break;
+   }
+   ExReleaseFastMutex(&MonitorListLock);
 
-  return Monitor;
+   return Monitor;
 }
 
 /* IntGetMonitorsFromRect
@@ -346,14 +347,14 @@ IntGetMonitorsFromRect(OPTIONAL IN LPCRECT pRect,
                        OPTIONAL IN DWORD listSize,
                        OPTIONAL IN DWORD flags)
 {
-  PMONITOR_OBJECT Monitor, NearestMonitor = NULL;
-  UINT iCount = 0;
-  LONG iNearestDistanceX = 0x7fffffff, iNearestDistanceY = 0x7fffffff;
-
-  /* find monitors which intersect the rectangle */
-  ExAcquireFastMutex(&MonitorListLock);
-  for (Monitor = MonitorList; Monitor != NULL; Monitor = Monitor->Next)
-    {
+   PMONITOR_OBJECT Monitor, NearestMonitor = NULL;
+   UINT iCount = 0;
+   LONG iNearestDistanceX = 0x7fffffff, iNearestDistanceY = 0x7fffffff;
+
+   /* find monitors which intersect the rectangle */
+   ExAcquireFastMutex(&MonitorListLock);
+   for (Monitor = MonitorList; Monitor != NULL; Monitor = Monitor->Next)
+   {
       RECT MonitorRect, IntersectionRect;
 
       ExAcquireFastMutex(&Monitor->Lock);
@@ -367,70 +368,70 @@ IntGetMonitorsFromRect(OPTIONAL IN LPCRECT pRect,
              MonitorRect.left, MonitorRect.top, MonitorRect.right, MonitorRect.bottom);
 
       if (pRect != NULL)
-        {
-          BOOL intersects = TRUE;
-
-          /* check if the rect intersects the monitor */
-          if ((pRect->right < MonitorRect.left) || (pRect->left > MonitorRect.right) ||
-              (pRect->bottom < MonitorRect.top) || (pRect->top > MonitorRect.bottom))
-            {
-              intersects = FALSE;
-            }
-
-          if (flags == MONITOR_DEFAULTTONEAREST && !intersects)
-            {
-              INT distanceX, distanceY;
-
-              distanceX = MIN(ABS(MonitorRect.left - pRect->right),
-                              ABS(pRect->left - MonitorRect.right));
-              distanceY = MIN(ABS(MonitorRect.top - pRect->bottom),
-                              ABS(pRect->top - MonitorRect.bottom));
-
-              if (((distanceX <  iNearestDistanceX) && (distanceY <= iNearestDistanceY)) ||
+      {
+         BOOL intersects = TRUE;
+
+         /* check if the rect intersects the monitor */
+         if ((pRect->right < MonitorRect.left) || (pRect->left > MonitorRect.right) ||
+               (pRect->bottom < MonitorRect.top) || (pRect->top > MonitorRect.bottom))
+         {
+            intersects = FALSE;
+         }
+
+         if (flags == MONITOR_DEFAULTTONEAREST && !intersects)
+         {
+            INT distanceX, distanceY;
+
+            distanceX = MIN(ABS(MonitorRect.left - pRect->right),
+                            ABS(pRect->left - MonitorRect.right));
+            distanceY = MIN(ABS(MonitorRect.top - pRect->bottom),
+                            ABS(pRect->top - MonitorRect.bottom));
+
+            if (((distanceX <  iNearestDistanceX) && (distanceY <= iNearestDistanceY)) ||
                   ((distanceX <= iNearestDistanceX) && (distanceY <  iNearestDistanceY)))
-                {
-                  iNearestDistanceX = distanceX;
-                  iNearestDistanceY = distanceY;
-                  NearestMonitor = Monitor;
-                }
+            {
+               iNearestDistanceX = distanceX;
+               iNearestDistanceY = distanceY;
+               NearestMonitor = Monitor;
             }
+         }
 
-          if (!intersects)
+         if (!intersects)
             continue;
 
-          /* calculate intersection */
-          IntersectionRect.left   = MAX(MonitorRect.left,   pRect->left);
-          IntersectionRect.top    = MAX(MonitorRect.top,    pRect->top);
-          IntersectionRect.right  = MIN(MonitorRect.right,  pRect->right);
-          IntersectionRect.bottom = MIN(MonitorRect.bottom, pRect->bottom);
-        }
+         /* calculate intersection */
+         IntersectionRect.left   = MAX(MonitorRect.left,   pRect->left);
+         IntersectionRect.top    = MAX(MonitorRect.top,    pRect->top);
+         IntersectionRect.right  = MIN(MonitorRect.right,  pRect->right);
+         IntersectionRect.bottom = MIN(MonitorRect.bottom, pRect->bottom);
+      }
       else
-        {
-          IntersectionRect = MonitorRect;
-        }
+      {
+         IntersectionRect = MonitorRect;
+      }
 
       if (iCount < listSize)
-        {
-          if (hMonitorList != NULL)
+      {
+         if (hMonitorList != NULL)
             hMonitorList[iCount] = Monitor->Handle;
-          if (monitorRectList != NULL)
+         if (monitorRectList != NULL)
             monitorRectList[iCount] = IntersectionRect;
-        }
+      }
       iCount++;
-    }
-  ExReleaseFastMutex(&MonitorListLock);
+   }
+   ExReleaseFastMutex(&MonitorListLock);
 
-  if (iCount == 0 && flags == MONITOR_DEFAULTTONEAREST)
-    {
+   if (iCount == 0 && flags == MONITOR_DEFAULTTONEAREST)
+   {
       if (iCount < listSize)
-        {
-          if (hMonitorList != NULL)
+      {
+         if (hMonitorList != NULL)
             hMonitorList[iCount] = NearestMonitor->Handle;
-        }
+      }
       iCount++;
-    }
+   }
 
-  return iCount;
+   return iCount;
 }
 
 /* PUBLIC FUNCTIONS ***********************************************************/
@@ -468,147 +469,148 @@ IntGetMonitorsFromRect(OPTIONAL IN LPCRECT pRect,
 INT
 STDCALL
 NtUserEnumDisplayMonitors(
-       OPTIONAL IN HDC hDC,
-       OPTIONAL IN LPCRECT pRect,
-       OPTIONAL OUT HMONITOR *hMonitorList,
-       OPTIONAL OUT LPRECT monitorRectList,
-       OPTIONAL IN DWORD listSize)
+   OPTIONAL IN HDC hDC,
+   OPTIONAL IN LPCRECT pRect,
+   OPTIONAL OUT HMONITOR *hMonitorList,
+   OPTIONAL OUT LPRECT monitorRectList,
+   OPTIONAL IN DWORD listSize)
 {
-       INT numMonitors, i;
-       HMONITOR *safeHMonitorList = NULL;
-       LPRECT safeRectList = NULL;
-       RECT rect, *myRect;
-       RECT dcRect;
-       NTSTATUS status;
-
-       /* get rect */
-       if (pRect != NULL)
-       {
-               status = MmCopyFromCaller(&rect, pRect, sizeof (RECT));
-               if (!NT_SUCCESS(status))
-               {
-                       DPRINT("MmCopyFromCaller() failed!\n");
-                       SetLastNtError(status);
-                       return -1;
-               }
-       }
-
-       if (hDC != NULL)
-       {
-               PDC dc;
-               HRGN dcVisRgn;
-               INT regionType;
-
-               /* get visible region bounding rect */
-               dc = DC_LockDc(hDC);
-               if (dc == NULL)
-               {
-                       DPRINT("DC_LockDc() failed!\n");
-                       /* FIXME: setlasterror? */
-                       return -1;
-               }
-               dcVisRgn = dc->w.hVisRgn;
-               DC_UnlockDc(dc);
-
-               regionType = NtGdiGetRgnBox(dcVisRgn, &dcRect);
-               if (regionType == 0)
-               {
-                       DPRINT("NtGdiGetRgnBox() failed!\n");
-                       return -1;
-               }
-               if (regionType == NULLREGION)
-                       return 0;
-               if (regionType == COMPLEXREGION)
-               {       /* TODO: warning */ }
-
-               /* if hDC and pRect are given the area of interest is pRect with
-                  coordinate origin at the DC position */
-               if (pRect != NULL)
-               {
-                       rect.left += dcRect.left;
-                       rect.right += dcRect.left;
-                       rect.top += dcRect.top;
-                       rect.bottom += dcRect.top;
-               }
-               /* if hDC is given and pRect is not the area of interest is the
-                  bounding rect of hDC */
-               else
-               {
-                       rect = dcRect;
-               }
-       }
-
-       if (hDC == NULL && pRect == NULL)
-               myRect = NULL;
-       else
-               myRect = &rect;
-
-       /* find intersecting monitors */
-       numMonitors = IntGetMonitorsFromRect(myRect, NULL, NULL, 0, 0);
-       if (numMonitors == 0 || listSize == 0 ||
-           (hMonitorList == NULL && monitorRectList == NULL))
-       {
-               DPRINT("numMonitors = %d\n", numMonitors);
-               return numMonitors;
-       }
-
-       if (hMonitorList != NULL && listSize != 0)
-       {
-               safeHMonitorList = ExAllocatePool(PagedPool, sizeof (HMONITOR) * listSize);
-               if (safeHMonitorList == NULL)
-               {
-                       /* FIXME: SetLastWin32Error? */
-                       return -1;
-               }
-       }
-       if (monitorRectList != NULL && listSize != 0)
-       {
-               safeRectList = ExAllocatePool(PagedPool, sizeof (RECT) * listSize);
-               if (safeRectList == NULL)
-               {
-                       ExFreePool(safeHMonitorList);
-                       /* FIXME: SetLastWin32Error? */
-                       return -1;
-               }
-       }
-
-       /* get intersecting monitors */
-       numMonitors = IntGetMonitorsFromRect(myRect, safeHMonitorList, safeRectList,
-                                            listSize, 0 );
-
-       if (hDC != NULL && pRect != NULL && safeRectList != NULL)
-               for (i = 0; i < numMonitors; i++)
-               {
-                       safeRectList[i].left -= dcRect.left;
-                       safeRectList[i].right -= dcRect.left;
-                       safeRectList[i].top -= dcRect.top;
-                       safeRectList[i].bottom -= dcRect.top;
-               }
-
-       /* output result */
-       if (hMonitorList != NULL && listSize != 0)
-       {
-               status = MmCopyToCaller(hMonitorList, safeHMonitorList, sizeof (HMONITOR) * listSize);
-               ExFreePool(safeHMonitorList);
-               if (!NT_SUCCESS(status))
-               {
-                       ExFreePool(safeRectList);
-                       SetLastNtError(status);
-                       return -1;
-               }
-       }
-       if (monitorRectList != NULL && listSize != 0)
-       {
-               status = MmCopyToCaller(monitorRectList, safeRectList, sizeof (RECT) * listSize);
-               ExFreePool(safeRectList);
-               if (!NT_SUCCESS(status))
-               {
-                       SetLastNtError(status);
-                       return -1;
-               }
-       }
-
-       return numMonitors;
+   INT numMonitors, i;
+   HMONITOR *safeHMonitorList = NULL;
+   LPRECT safeRectList = NULL;
+   RECT rect, *myRect;
+   RECT dcRect;
+   NTSTATUS status;
+
+   /* get rect */
+   if (pRect != NULL)
+   {
+      status = MmCopyFromCaller(&rect, pRect, sizeof (RECT));
+      if (!NT_SUCCESS(status))
+      {
+         DPRINT("MmCopyFromCaller() failed!\n");
+         SetLastNtError(status);
+         return -1;
+      }
+   }
+
+   if (hDC != NULL)
+   {
+      PDC dc;
+      HRGN dcVisRgn;
+      INT regionType;
+
+      /* get visible region bounding rect */
+      dc = DC_LockDc(hDC);
+      if (dc == NULL)
+      {
+         DPRINT("DC_LockDc() failed!\n");
+         /* FIXME: setlasterror? */
+         return -1;
+      }
+      dcVisRgn = dc->w.hVisRgn;
+      DC_UnlockDc(dc);
+
+      regionType = NtGdiGetRgnBox(dcVisRgn, &dcRect);
+      if (regionType == 0)
+      {
+         DPRINT("NtGdiGetRgnBox() failed!\n");
+         return -1;
+      }
+      if (regionType == NULLREGION)
+         return 0;
+      if (regionType == COMPLEXREGION)
+      { /* TODO: warning */
+      }
+
+      /* if hDC and pRect are given the area of interest is pRect with
+         coordinate origin at the DC position */
+      if (pRect != NULL)
+      {
+         rect.left += dcRect.left;
+         rect.right += dcRect.left;
+         rect.top += dcRect.top;
+         rect.bottom += dcRect.top;
+      }
+      /* if hDC is given and pRect is not the area of interest is the
+         bounding rect of hDC */
+      else
+      {
+         rect = dcRect;
+      }
+   }
+
+   if (hDC == NULL && pRect == NULL)
+      myRect = NULL;
+   else
+      myRect = &rect;
+
+   /* find intersecting monitors */
+   numMonitors = IntGetMonitorsFromRect(myRect, NULL, NULL, 0, 0);
+   if (numMonitors == 0 || listSize == 0 ||
+         (hMonitorList == NULL && monitorRectList == NULL))
+   {
+      DPRINT("numMonitors = %d\n", numMonitors);
+      return numMonitors;
+   }
+
+   if (hMonitorList != NULL && listSize != 0)
+   {
+      safeHMonitorList = ExAllocatePool(PagedPool, sizeof (HMONITOR) * listSize);
+      if (safeHMonitorList == NULL)
+      {
+         /* FIXME: SetLastWin32Error? */
+         return -1;
+      }
+   }
+   if (monitorRectList != NULL && listSize != 0)
+   {
+      safeRectList = ExAllocatePool(PagedPool, sizeof (RECT) * listSize);
+      if (safeRectList == NULL)
+      {
+         ExFreePool(safeHMonitorList);
+         /* FIXME: SetLastWin32Error? */
+         return -1;
+      }
+   }
+
+   /* get intersecting monitors */
+   numMonitors = IntGetMonitorsFromRect(myRect, safeHMonitorList, safeRectList,
+                                        listSize, 0 );
+
+   if (hDC != NULL && pRect != NULL && safeRectList != NULL)
+      for (i = 0; i < numMonitors; i++)
+      {
+         safeRectList[i].left -= dcRect.left;
+         safeRectList[i].right -= dcRect.left;
+         safeRectList[i].top -= dcRect.top;
+         safeRectList[i].bottom -= dcRect.top;
+      }
+
+   /* output result */
+   if (hMonitorList != NULL && listSize != 0)
+   {
+      status = MmCopyToCaller(hMonitorList, safeHMonitorList, sizeof (HMONITOR) * listSize);
+      ExFreePool(safeHMonitorList);
+      if (!NT_SUCCESS(status))
+      {
+         ExFreePool(safeRectList);
+         SetLastNtError(status);
+         return -1;
+      }
+   }
+   if (monitorRectList != NULL && listSize != 0)
+   {
+      status = MmCopyToCaller(monitorRectList, safeRectList, sizeof (RECT) * listSize);
+      ExFreePool(safeRectList);
+      if (!NT_SUCCESS(status))
+      {
+         SetLastNtError(status);
+         return -1;
+      }
+   }
+
+   return numMonitors;
 }
 
 /* NtUserGetMonitorInfo
@@ -638,73 +640,73 @@ NtUserEnumDisplayMonitors(
 BOOL
 STDCALL
 NtUserGetMonitorInfo(
-       IN HMONITOR hMonitor,
-       OUT LPMONITORINFO pMonitorInfo)
+   IN HMONITOR hMonitor,
+   OUT LPMONITORINFO pMonitorInfo)
 {
-       PMONITOR_OBJECT Monitor;
-       MONITORINFOEXW MonitorInfo;
-       NTSTATUS Status;
-
-       /* get monitor object */
-       if ((Monitor = IntGetMonitorObject(hMonitor)) == NULL)
-       {
-               DPRINT("Couldnt find monitor 0x%lx\n", hMonitor);
-               SetLastNtError(STATUS_INVALID_HANDLE);
-               return FALSE;
-       }
-
-       /* get size of pMonitorInfo */
-       Status = MmCopyFromCaller(&MonitorInfo.cbSize, &pMonitorInfo->cbSize, sizeof (MonitorInfo.cbSize));
-       if (!NT_SUCCESS(Status))
-       {
-               IntReleaseMonitorObject(Monitor);
-               SetLastNtError(Status);
-               return FALSE;
-       }
-       if ((MonitorInfo.cbSize != sizeof (MONITORINFO)) &&
-           (MonitorInfo.cbSize != sizeof (MONITORINFOEXW)))
-       {
-               SetLastNtError(STATUS_INVALID_PARAMETER);
-               return FALSE;
-       }
-
-       ExAcquireFastMutex(&Monitor->Lock);
-       /* fill monitor info */
-       MonitorInfo.rcMonitor.left = 0; /* FIXME: get origin */
-       MonitorInfo.rcMonitor.top = 0; /* FIXME: get origin */
-       MonitorInfo.rcMonitor.right = MonitorInfo.rcMonitor.left + Monitor->GdiDevice->GDIInfo.ulHorzRes;
-       MonitorInfo.rcMonitor.bottom = MonitorInfo.rcMonitor.top + Monitor->GdiDevice->GDIInfo.ulVertRes;
-       MonitorInfo.rcWork = MonitorInfo.rcMonitor; /* FIXME: use DEVMODE panning to calculate work area? */
-       MonitorInfo.dwFlags = 0;
-       if (Monitor->IsPrimary)
-               MonitorInfo.dwFlags |= MONITORINFOF_PRIMARY;
-
-       /* fill device name */
-       if (MonitorInfo.cbSize == sizeof (MONITORINFOEXW))
-       {
-               WCHAR nul = L'\0';
-               INT len = Monitor->DeviceName.Length;
-               if (len >= CCHDEVICENAME * sizeof (WCHAR))
-                       len = (CCHDEVICENAME - 1) * sizeof (WCHAR);
-
-               memcpy(MonitorInfo.szDevice, Monitor->DeviceName.Buffer, len);
-               memcpy(MonitorInfo.szDevice + (len / sizeof (WCHAR)), &nul, sizeof (WCHAR));
-       }
-       ExReleaseFastMutex(&Monitor->Lock);
-       IntReleaseMonitorObject(Monitor);
-
-       /* output data */
-       Status = MmCopyToCaller(pMonitorInfo, &MonitorInfo, MonitorInfo.cbSize);
-       if (!NT_SUCCESS(Status))
-       {
-               DPRINT("GetMonitorInfo: MmCopyToCaller failed\n");
-               SetLastNtError(Status);
-               return FALSE;
-       }
-
-       DPRINT("GetMonitorInfo: success\n");
-
-       return TRUE;
+   PMONITOR_OBJECT Monitor;
+   MONITORINFOEXW MonitorInfo;
+   NTSTATUS Status;
+
+   /* get monitor object */
+   if ((Monitor = IntGetMonitorObject(hMonitor)) == NULL)
+   {
+      DPRINT("Couldnt find monitor 0x%lx\n", hMonitor);
+      SetLastNtError(STATUS_INVALID_HANDLE);
+      return FALSE;
+   }
+
+   /* get size of pMonitorInfo */
+   Status = MmCopyFromCaller(&MonitorInfo.cbSize, &pMonitorInfo->cbSize, sizeof (MonitorInfo.cbSize));
+   if (!NT_SUCCESS(Status))
+   {
+      IntReleaseMonitorObject(Monitor);
+      SetLastNtError(Status);
+      return FALSE;
+   }
+   if ((MonitorInfo.cbSize != sizeof (MONITORINFO)) &&
+         (MonitorInfo.cbSize != sizeof (MONITORINFOEXW)))
+   {
+      SetLastNtError(STATUS_INVALID_PARAMETER);
+      return FALSE;
+   }
+
+   ExAcquireFastMutex(&Monitor->Lock);
+   /* fill monitor info */
+   MonitorInfo.rcMonitor.left = 0; /* FIXME: get origin */
+   MonitorInfo.rcMonitor.top = 0; /* FIXME: get origin */
+   MonitorInfo.rcMonitor.right = MonitorInfo.rcMonitor.left + Monitor->GdiDevice->GDIInfo.ulHorzRes;
+   MonitorInfo.rcMonitor.bottom = MonitorInfo.rcMonitor.top + Monitor->GdiDevice->GDIInfo.ulVertRes;
+   MonitorInfo.rcWork = MonitorInfo.rcMonitor; /* FIXME: use DEVMODE panning to calculate work area? */
+   MonitorInfo.dwFlags = 0;
+   if (Monitor->IsPrimary)
+      MonitorInfo.dwFlags |= MONITORINFOF_PRIMARY;
+
+   /* fill device name */
+   if (MonitorInfo.cbSize == sizeof (MONITORINFOEXW))
+   {
+      WCHAR nul = L'\0';
+      INT len = Monitor->DeviceName.Length;
+      if (len >= CCHDEVICENAME * sizeof (WCHAR))
+         len = (CCHDEVICENAME - 1) * sizeof (WCHAR);
+
+      memcpy(MonitorInfo.szDevice, Monitor->DeviceName.Buffer, len);
+      memcpy(MonitorInfo.szDevice + (len / sizeof (WCHAR)), &nul, sizeof (WCHAR));
+   }
+   ExReleaseFastMutex(&Monitor->Lock);
+   IntReleaseMonitorObject(Monitor);
+
+   /* output data */
+   Status = MmCopyToCaller(pMonitorInfo, &MonitorInfo, MonitorInfo.cbSize);
+   if (!NT_SUCCESS(Status))
+   {
+      DPRINT("GetMonitorInfo: MmCopyToCaller failed\n");
+      SetLastNtError(Status);
+      return FALSE;
+   }
+
+   DPRINT("GetMonitorInfo: success\n");
+
+   return TRUE;
 }
 
 /* NtUserMonitorFromPoint
@@ -726,42 +728,42 @@ NtUserGetMonitorInfo(
 HMONITOR
 STDCALL
 NtUserMonitorFromPoint(
-       IN POINT point,
-       IN DWORD dwFlags)
+   IN POINT point,
+   IN DWORD dwFlags)
 {
-       INT NumMonitors;
-       RECT InRect;
-       HMONITOR hMonitor = NULL;
-
-       /* fill inRect */
-       InRect.left = InRect.right = point.x;
-       InRect.top = InRect.bottom = point.y;
-
-       /* find intersecting monitor */
-       NumMonitors = IntGetMonitorsFromRect(&InRect, &hMonitor, NULL, 1, 0);
-       if (NumMonitors < 0)
-       {
-               return (HMONITOR)NULL;
-       }
-
-       if (hMonitor == NULL)
-       {
-               if (dwFlags == MONITOR_DEFAULTTOPRIMARY)
-               {
-                       PMONITOR_OBJECT MonitorObj = IntGetPrimaryMonitor();
-                       if (MonitorObj)
-                               hMonitor = MonitorObj->Handle;
-               }
-               else if (dwFlags == MONITOR_DEFAULTTONEAREST)
-               {
-                       NumMonitors = IntGetMonitorsFromRect(&InRect, &hMonitor, NULL,
-                                                            1, MONITOR_DEFAULTTONEAREST);
-                       /*ASSERT( (numMonitors > 0) && (hMonitor != NULL) );*/
-               }
-               /* else flag is DEFAULTTONULL */
-       }
-
-       return hMonitor;
+   INT NumMonitors;
+   RECT InRect;
+   HMONITOR hMonitor = NULL;
+
+   /* fill inRect */
+   InRect.left = InRect.right = point.x;
+   InRect.top = InRect.bottom = point.y;
+
+   /* find intersecting monitor */
+   NumMonitors = IntGetMonitorsFromRect(&InRect, &hMonitor, NULL, 1, 0);
+   if (NumMonitors < 0)
+   {
+      return (HMONITOR)NULL;
+   }
+
+   if (hMonitor == NULL)
+   {
+      if (dwFlags == MONITOR_DEFAULTTOPRIMARY)
+      {
+         PMONITOR_OBJECT MonitorObj = IntGetPrimaryMonitor();
+         if (MonitorObj)
+            hMonitor = MonitorObj->Handle;
+      }
+      else if (dwFlags == MONITOR_DEFAULTTONEAREST)
+      {
+         NumMonitors = IntGetMonitorsFromRect(&InRect, &hMonitor, NULL,
+                                              1, MONITOR_DEFAULTTONEAREST);
+         /*ASSERT( (numMonitors > 0) && (hMonitor != NULL) );*/
+      }
+      /* else flag is DEFAULTTONULL */
+   }
+
+   return hMonitor;
 }
 
 /* NtUserMonitorFromRect
@@ -784,119 +786,119 @@ NtUserMonitorFromPoint(
 HMONITOR
 STDCALL
 NtUserMonitorFromRect(
-       IN LPCRECT pRect,
-       IN DWORD dwFlags)
+   IN LPCRECT pRect,
+   IN DWORD dwFlags)
 {
-       INT numMonitors, iLargestArea = -1, i;
-       LPRECT rectList;
-       HMONITOR *hMonitorList;
-       HMONITOR hMonitor = NULL;
-       RECT rect;
-       NTSTATUS status;
-
-       /* get rect */
-       status = MmCopyFromCaller(&rect, pRect, sizeof (RECT));
-       if (!NT_SUCCESS(status))
-       {
-               SetLastNtError(status);
-               return (HMONITOR)NULL;
-       }
-
-       /* find intersecting monitors */
-       numMonitors = IntGetMonitorsFromRect(&rect, NULL, NULL, 0, 0);
-       if (numMonitors < 0)
-       {
-               return (HMONITOR)NULL;
-       }
-
-       if (numMonitors == 0)
-       {
-               if (dwFlags == MONITOR_DEFAULTTOPRIMARY)
-               {
-                       PMONITOR_OBJECT monitorObj = IntGetPrimaryMonitor();
-                       if (monitorObj)
-                               return monitorObj->Handle;
-               }
-               else if (dwFlags == MONITOR_DEFAULTTONEAREST)
-               {
-                       numMonitors = IntGetMonitorsFromRect(&rect, &hMonitor, NULL,
-                                                            1, MONITOR_DEFAULTTONEAREST);
-                       if (numMonitors <= 0)
-                       {
-                               /* error? */
-                               return (HMONITOR)NULL;
-                       }
-
-                       if (numMonitors > 0)
-                               return hMonitor;
-               }
-               /* else flag is DEFAULTTONULL */
-               return (HMONITOR)NULL;
-       }
-
-       hMonitorList = ExAllocatePool(PagedPool, sizeof (HMONITOR) * numMonitors);
-       if (hMonitorList == NULL)
-       {
-               /* FIXME: SetLastWin32Error? */
-               return (HMONITOR)NULL;
-       }
-       rectList = ExAllocatePool(PagedPool, sizeof (RECT) * numMonitors);
-       if (rectList == NULL)
-       {
-               ExFreePool(hMonitorList);
-               /* FIXME: SetLastWin32Error? */
-               return (HMONITOR)NULL;
-       }
-
-       /* get intersecting monitors */
-       numMonitors = IntGetMonitorsFromRect(&rect, hMonitorList, rectList,
-                                            numMonitors, 0);
-       if (numMonitors <= 0)
-       {
-               return (HMONITOR)NULL;
-       }
-
-       /* find largest intersection */
-       for (i = 0; i < numMonitors; i++)
-       {
-               INT area = (rectList[i].right - rectList[i].left) *
-                          (rectList[i].bottom - rectList[i].top);
-               if (area > iLargestArea)
-               {
-                       hMonitor = hMonitorList[i];
-               }
-       }
-
-       ExFreePool(hMonitorList);
-       ExFreePool(rectList);
-
-       return hMonitor;
+   INT numMonitors, iLargestArea = -1, i;
+   LPRECT rectList;
+   HMONITOR *hMonitorList;
+   HMONITOR hMonitor = NULL;
+   RECT rect;
+   NTSTATUS status;
+
+   /* get rect */
+   status = MmCopyFromCaller(&rect, pRect, sizeof (RECT));
+   if (!NT_SUCCESS(status))
+   {
+      SetLastNtError(status);
+      return (HMONITOR)NULL;
+   }
+
+   /* find intersecting monitors */
+   numMonitors = IntGetMonitorsFromRect(&rect, NULL, NULL, 0, 0);
+   if (numMonitors < 0)
+   {
+      return (HMONITOR)NULL;
+   }
+
+   if (numMonitors == 0)
+   {
+      if (dwFlags == MONITOR_DEFAULTTOPRIMARY)
+      {
+         PMONITOR_OBJECT monitorObj = IntGetPrimaryMonitor();
+         if (monitorObj)
+            return monitorObj->Handle;
+      }
+      else if (dwFlags == MONITOR_DEFAULTTONEAREST)
+      {
+         numMonitors = IntGetMonitorsFromRect(&rect, &hMonitor, NULL,
+                                              1, MONITOR_DEFAULTTONEAREST);
+         if (numMonitors <= 0)
+         {
+            /* error? */
+            return (HMONITOR)NULL;
+         }
+
+         if (numMonitors > 0)
+            return hMonitor;
+      }
+      /* else flag is DEFAULTTONULL */
+      return (HMONITOR)NULL;
+   }
+
+   hMonitorList = ExAllocatePool(PagedPool, sizeof (HMONITOR) * numMonitors);
+   if (hMonitorList == NULL)
+   {
+      /* FIXME: SetLastWin32Error? */
+      return (HMONITOR)NULL;
+   }
+   rectList = ExAllocatePool(PagedPool, sizeof (RECT) * numMonitors);
+   if (rectList == NULL)
+   {
+      ExFreePool(hMonitorList);
+      /* FIXME: SetLastWin32Error? */
+      return (HMONITOR)NULL;
+   }
+
+   /* get intersecting monitors */
+   numMonitors = IntGetMonitorsFromRect(&rect, hMonitorList, rectList,
+                                        numMonitors, 0);
+   if (numMonitors <= 0)
+   {
+      return (HMONITOR)NULL;
+   }
+
+   /* find largest intersection */
+   for (i = 0; i < numMonitors; i++)
+   {
+      INT area = (rectList[i].right - rectList[i].left) *
+                 (rectList[i].bottom - rectList[i].top);
+      if (area > iLargestArea)
+      {
+         hMonitor = hMonitorList[i];
+      }
+   }
+
+   ExFreePool(hMonitorList);
+   ExFreePool(rectList);
+
+   return hMonitor;
 }
 
 
 HMONITOR
 STDCALL
 NtUserMonitorFromWindow(
-       IN HWND hWnd,
-       IN DWORD dwFlags)
+   IN HWND hWnd,
+   IN DWORD dwFlags)
 {
-       PWINDOW_OBJECT Window;
-       HMONITOR hMonitor = NULL;
-       RECT Rect;
+   PWINDOW_OBJECT Window;
+   HMONITOR hMonitor = NULL;
+   RECT Rect;
 
-        Window = IntGetWindowObject(hWnd);
-       if (Window == NULL)
-       {
-               SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-               return (HMONITOR)NULL;
-       }
+   Window = IntGetWindowObject(hWnd);
+   if (Window == NULL)
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      return (HMONITOR)NULL;
+   }
 
-       Rect.left = Rect.right = Window->WindowRect.left;
-       Rect.top = Rect.bottom = Window->WindowRect.bottom;
+   Rect.left = Rect.right = Window->WindowRect.left;
+   Rect.top = Rect.bottom = Window->WindowRect.bottom;
 
-       IntGetMonitorsFromRect(&Rect, &hMonitor, NULL, 1, dwFlags);
+   IntGetMonitorsFromRect(&Rect, &hMonitor, NULL, 1, dwFlags);
 
-       IntReleaseWindowObject(Window);
+   IntReleaseWindowObject(Window);
 
-       return hMonitor;
+   return hMonitor;
 }
index 9e3fa94..e05c18a 100644 (file)
@@ -68,447 +68,449 @@ static PAGED_LOOKASIDE_LIST TimerLookasideList;
 HANDLE FASTCALL
 IntMsqSetWakeMask(DWORD WakeMask)
 {
-  PW32THREAD Win32Thread;
-  PUSER_MESSAGE_QUEUE MessageQueue;
-  HANDLE MessageEventHandle;
+   PW32THREAD Win32Thread;
+   PUSER_MESSAGE_QUEUE MessageQueue;
+   HANDLE MessageEventHandle;
 
-  Win32Thread = PsGetWin32Thread();
-  if (Win32Thread == NULL || Win32Thread->MessageQueue == NULL)
-    return 0;
+   Win32Thread = PsGetWin32Thread();
+   if (Win32Thread == NULL || Win32Thread->MessageQueue == NULL)
+      return 0;
 
-  MessageQueue = Win32Thread->MessageQueue;
-  MessageQueue->WakeMask = WakeMask;
-  MessageEventHandle = MessageQueue->NewMessagesHandle;
+   MessageQueue = Win32Thread->MessageQueue;
+   MessageQueue->WakeMask = WakeMask;
+   MessageEventHandle = MessageQueue->NewMessagesHandle;
 
-  return MessageEventHandle;
+   return MessageEventHandle;
 }
 
 BOOL FASTCALL
 IntMsqClearWakeMask(VOID)
 {
-  PW32THREAD Win32Thread;
-  PUSER_MESSAGE_QUEUE MessageQueue;
+   PW32THREAD Win32Thread;
+   PUSER_MESSAGE_QUEUE MessageQueue;
 
-  Win32Thread = PsGetWin32Thread();
-  if (Win32Thread == NULL || Win32Thread->MessageQueue == NULL)
-    return FALSE;
+   Win32Thread = PsGetWin32Thread();
+   if (Win32Thread == NULL || Win32Thread->MessageQueue == NULL)
+      return FALSE;
 
-  MessageQueue = Win32Thread->MessageQueue;
-  MessageQueue->WakeMask = ~0;
+   MessageQueue = Win32Thread->MessageQueue;
+   MessageQueue->WakeMask = ~0;
 
-  return TRUE;
+   return TRUE;
 }
 
 VOID FASTCALL
 MsqIncPaintCountQueue(PUSER_MESSAGE_QUEUE Queue)
 {
-  Queue->PaintCount++;
-  Queue->PaintPosted = TRUE;
-  Queue->QueueBits |= QS_PAINT;
-  Queue->ChangedBits |= QS_PAINT;
-  if (Queue->WakeMask & QS_PAINT)
-    KeSetEvent(Queue->NewMessages, IO_NO_INCREMENT, FALSE);
+   Queue->PaintCount++;
+   Queue->PaintPosted = TRUE;
+   Queue->QueueBits |= QS_PAINT;
+   Queue->ChangedBits |= QS_PAINT;
+   if (Queue->WakeMask & QS_PAINT)
+      KeSetEvent(Queue->NewMessages, IO_NO_INCREMENT, FALSE);
 }
 
 VOID FASTCALL
 MsqDecPaintCountQueue(PUSER_MESSAGE_QUEUE Queue)
 {
-  Queue->PaintCount--;
-  if (Queue->PaintCount == 0)
-    {
+   Queue->PaintCount--;
+   if (Queue->PaintCount == 0)
+   {
       Queue->PaintPosted = FALSE;
-    }
+   }
 }
 
 
 NTSTATUS FASTCALL
 MsqInitializeImpl(VOID)
 {
-  /*CurrentFocusMessageQueue = NULL;*/
-  InitializeListHead(&HardwareMessageQueueHead);
-  KeInitializeEvent(&HardwareMessageEvent, NotificationEvent, 0);
-  KeInitializeSpinLock(&SystemMessageQueueLock);
-  KeInitializeMutex(&HardwareMessageQueueLock, 0);
-
-  ExInitializePagedLookasideList(&MessageLookasideList,
-                                NULL,
-                                NULL,
-                                0,
-                                sizeof(USER_MESSAGE),
-                                0,
-                                256);
-  ExInitializePagedLookasideList(&TimerLookasideList,
-                                NULL,
-                                NULL,
-                                0,
-                                sizeof(TIMER_ENTRY),
-                                0,
-                                64);
-
-  return(STATUS_SUCCESS);
+   /*CurrentFocusMessageQueue = NULL;*/
+   InitializeListHead(&HardwareMessageQueueHead);
+   KeInitializeEvent(&HardwareMessageEvent, NotificationEvent, 0);
+   KeInitializeSpinLock(&SystemMessageQueueLock);
+   KeInitializeMutex(&HardwareMessageQueueLock, 0);
+
+   ExInitializePagedLookasideList(&MessageLookasideList,
+                                  NULL,
+                                  NULL,
+                                  0,
+                                  sizeof(USER_MESSAGE),
+                                  0,
+                                  256);
+   ExInitializePagedLookasideList(&TimerLookasideList,
+                                  NULL,
+                                  NULL,
+                                  0,
+                                  sizeof(TIMER_ENTRY),
+                                  0,
+                                  64);
+
+   return(STATUS_SUCCESS);
 }
 
 VOID FASTCALL
 MsqInsertSystemMessage(MSG* Msg)
 {
-  LARGE_INTEGER LargeTickCount;
-  KIRQL OldIrql;
-  ULONG mmov = (ULONG)-1;
-
-  KeQueryTickCount(&LargeTickCount);
-  Msg->time = LargeTickCount.u.LowPart;
-
-  IntLockSystemMessageQueue(OldIrql);
-
-  /* only insert WM_MOUSEMOVE messages if not already in system message queue */
-  if(Msg->message == WM_MOUSEMOVE)
-    mmov = SystemMessageQueueMouseMove;
-
-  if(mmov != (ULONG)-1)
-  {
-    /* insert message at the queue head */
-    while (mmov != SystemMessageQueueHead )
-    {
-      ULONG prev = mmov ? mmov - 1 : SYSTEM_MESSAGE_QUEUE_SIZE - 1;
-      ASSERT((LONG) mmov >= 0);
-      ASSERT(mmov < SYSTEM_MESSAGE_QUEUE_SIZE);
-      SystemMessageQueue[mmov] = SystemMessageQueue[prev];
-      mmov = prev;
-    }
-    SystemMessageQueue[SystemMessageQueueHead] = *Msg;
-  }
-  else
-  {
-    if (SystemMessageQueueCount == SYSTEM_MESSAGE_QUEUE_SIZE)
-    {
-      IntUnLockSystemMessageQueue(OldIrql);
-      return;
-    }
-    SystemMessageQueue[SystemMessageQueueTail] = *Msg;
-    if(Msg->message == WM_MOUSEMOVE)
-      SystemMessageQueueMouseMove = SystemMessageQueueTail;
-    SystemMessageQueueTail =
-      (SystemMessageQueueTail + 1) % SYSTEM_MESSAGE_QUEUE_SIZE;
-    SystemMessageQueueCount++;
-  }
-  IntUnLockSystemMessageQueue(OldIrql);
-  KeSetEvent(&HardwareMessageEvent, IO_NO_INCREMENT, FALSE);
+   LARGE_INTEGER LargeTickCount;
+   KIRQL OldIrql;
+   ULONG mmov = (ULONG)-1;
+
+   KeQueryTickCount(&LargeTickCount);
+   Msg->time = LargeTickCount.u.LowPart;
+
+   IntLockSystemMessageQueue(OldIrql);
+
+   /* only insert WM_MOUSEMOVE messages if not already in system message queue */
+   if(Msg->message == WM_MOUSEMOVE)
+      mmov = SystemMessageQueueMouseMove;
+
+   if(mmov != (ULONG)-1)
+   {
+      /* insert message at the queue head */
+      while (mmov != SystemMessageQueueHead )
+      {
+         ULONG prev = mmov ? mmov - 1 : SYSTEM_MESSAGE_QUEUE_SIZE - 1;
+         ASSERT((LONG) mmov >= 0);
+         ASSERT(mmov < SYSTEM_MESSAGE_QUEUE_SIZE);
+         SystemMessageQueue[mmov] = SystemMessageQueue[prev];
+         mmov = prev;
+      }
+      SystemMessageQueue[SystemMessageQueueHead] = *Msg;
+   }
+   else
+   {
+      if (SystemMessageQueueCount == SYSTEM_MESSAGE_QUEUE_SIZE)
+      {
+         IntUnLockSystemMessageQueue(OldIrql);
+         return;
+      }
+      SystemMessageQueue[SystemMessageQueueTail] = *Msg;
+      if(Msg->message == WM_MOUSEMOVE)
+         SystemMessageQueueMouseMove = SystemMessageQueueTail;
+      SystemMessageQueueTail =
+         (SystemMessageQueueTail + 1) % SYSTEM_MESSAGE_QUEUE_SIZE;
+      SystemMessageQueueCount++;
+   }
+   IntUnLockSystemMessageQueue(OldIrql);
+   KeSetEvent(&HardwareMessageEvent, IO_NO_INCREMENT, FALSE);
 }
 
 BOOL FASTCALL
 MsqIsDblClk(LPMSG Msg, BOOL Remove)
 {
-  PWINSTATION_OBJECT WinStaObject;
-  PSYSTEM_CURSORINFO CurInfo;
-  LONG dX, dY;
-  BOOL Res;
-
-  if (PsGetWin32Thread()->Desktop == NULL)
-  {
-    return FALSE;
-  }
-  WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
-
-  CurInfo = IntGetSysCursorInfo(WinStaObject);
-  Res = (Msg->hwnd == (HWND)CurInfo->LastClkWnd) &&
-        ((Msg->time - CurInfo->LastBtnDown) < CurInfo->DblClickSpeed);
-  if(Res)
-  {
-
-    dX = CurInfo->LastBtnDownX - Msg->pt.x;
-    dY = CurInfo->LastBtnDownY - Msg->pt.y;
-    if(dX < 0) dX = -dX;
-    if(dY < 0) dY = -dY;
-
-    Res = (dX <= CurInfo->DblClickWidth) &&
-          (dY <= CurInfo->DblClickHeight);
-  }
-
-  if(Remove)
-  {
-    if (Res)
-    {
-      CurInfo->LastBtnDown = 0;
-      CurInfo->LastBtnDownX = Msg->pt.x;
-      CurInfo->LastBtnDownY = Msg->pt.y;
-      CurInfo->LastClkWnd = NULL;
-    }
-    else
-    {
-      CurInfo->LastBtnDownX = Msg->pt.x;
-      CurInfo->LastBtnDownY = Msg->pt.y;
-      CurInfo->LastClkWnd = (HANDLE)Msg->hwnd;
-      CurInfo->LastBtnDown = Msg->time;
-    }
-  }
-
-  return Res;
+   PWINSTATION_OBJECT WinStaObject;
+   PSYSTEM_CURSORINFO CurInfo;
+   LONG dX, dY;
+   BOOL Res;
+
+   if (PsGetWin32Thread()->Desktop == NULL)
+   {
+      return FALSE;
+   }
+   WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
+
+   CurInfo = IntGetSysCursorInfo(WinStaObject);
+   Res = (Msg->hwnd == (HWND)CurInfo->LastClkWnd) &&
+         ((Msg->time - CurInfo->LastBtnDown) < CurInfo->DblClickSpeed);
+   if(Res)
+   {
+
+      dX = CurInfo->LastBtnDownX - Msg->pt.x;
+      dY = CurInfo->LastBtnDownY - Msg->pt.y;
+      if(dX < 0)
+         dX = -dX;
+      if(dY < 0)
+         dY = -dY;
+
+      Res = (dX <= CurInfo->DblClickWidth) &&
+            (dY <= CurInfo->DblClickHeight);
+   }
+
+   if(Remove)
+   {
+      if (Res)
+      {
+         CurInfo->LastBtnDown = 0;
+         CurInfo->LastBtnDownX = Msg->pt.x;
+         CurInfo->LastBtnDownY = Msg->pt.y;
+         CurInfo->LastClkWnd = NULL;
+      }
+      else
+      {
+         CurInfo->LastBtnDownX = Msg->pt.x;
+         CurInfo->LastBtnDownY = Msg->pt.y;
+         CurInfo->LastClkWnd = (HANDLE)Msg->hwnd;
+         CurInfo->LastBtnDown = Msg->time;
+      }
+   }
+
+   return Res;
 }
 
 BOOL STATIC STDCALL
 co_MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, UINT FilterLow, UINT FilterHigh,
-                        PUSER_MESSAGE Message, BOOL Remove, PBOOL Freed,
-                        PWINDOW_OBJECT ScopeWin, PPOINT ScreenPoint, BOOL FromGlobalQueue)
+                            PUSER_MESSAGE Message, BOOL Remove, PBOOL Freed,
+                            PWINDOW_OBJECT ScopeWin, PPOINT ScreenPoint, BOOL FromGlobalQueue)
 {
-  USHORT Msg = Message->Msg.message;
-  PWINDOW_OBJECT Window = NULL;
-  HWND CaptureWin;
-
-  CaptureWin = IntGetCaptureWindow();
-  if (CaptureWin == NULL)
-  {
-    if(Msg == WM_MOUSEWHEEL)
-    {
-      Window = IntGetWindowObject(IntGetFocusWindow());
-    }
-    else
-    {
-      co_WinPosWindowFromPoint(ScopeWin, NULL, &Message->Msg.pt, &Window);
-      if(Window == NULL)
+   USHORT Msg = Message->Msg.message;
+   PWINDOW_OBJECT Window = NULL;
+   HWND CaptureWin;
+
+   CaptureWin = IntGetCaptureWindow();
+   if (CaptureWin == NULL)
+   {
+      if(Msg == WM_MOUSEWHEEL)
       {
-        Window = ScopeWin;
-        IntReferenceWindowObject(Window);
+         Window = IntGetWindowObject(IntGetFocusWindow());
       }
-    }
-  }
-  else
-  {
-    /* FIXME - window messages should go to the right window if no buttons are
-               pressed */
-    Window = IntGetWindowObject(CaptureWin);
-  }
-
-  if (Window == NULL)
-  {
-    if(!FromGlobalQueue)
-    {
-      RemoveEntryList(&Message->ListEntry);
-      if(MessageQueue->MouseMoveMsg == Message)
+      else
       {
-        MessageQueue->MouseMoveMsg = NULL;
+         co_WinPosWindowFromPoint(ScopeWin, NULL, &Message->Msg.pt, &Window);
+         if(Window == NULL)
+         {
+            Window = ScopeWin;
+            IntReferenceWindowObject(Window);
+         }
       }
-    }
-    ExFreePool(Message);
-    *Freed = TRUE;
-    return(FALSE);
-  }
-
-  if (Window->MessageQueue != MessageQueue)
-  {
-    if (! FromGlobalQueue)
-    {
-      DPRINT("Moving msg between private queues\n");
-      /* This message is already queued in a private queue, but we need
-       * to move it to a different queue, perhaps because a new window
-       * was created which now covers the screen area previously taken
-       * by another window. To move it, we need to take it out of the
-       * old queue. Note that we're already holding the lock mutexes of the
-       * old queue */
-      RemoveEntryList(&Message->ListEntry);
-
-      /* remove the pointer for the current WM_MOUSEMOVE message in case we
-         just removed it */
-      if(MessageQueue->MouseMoveMsg == Message)
+   }
+   else
+   {
+      /* FIXME - window messages should go to the right window if no buttons are
+                 pressed */
+      Window = IntGetWindowObject(CaptureWin);
+   }
+
+   if (Window == NULL)
+   {
+      if(!FromGlobalQueue)
       {
-        MessageQueue->MouseMoveMsg = NULL;
+         RemoveEntryList(&Message->ListEntry);
+         if(MessageQueue->MouseMoveMsg == Message)
+         {
+            MessageQueue->MouseMoveMsg = NULL;
+         }
       }
-    }
-
-    /* lock the destination message queue, so we don't get in trouble with other
-       threads, messing with it at the same time */
-    IntLockHardwareMessageQueue(Window->MessageQueue);
-    InsertTailList(&Window->MessageQueue->HardwareMessagesListHead,
-                   &Message->ListEntry);
-    if(Message->Msg.message == WM_MOUSEMOVE)
-    {
-      if(Window->MessageQueue->MouseMoveMsg)
+      ExFreePool(Message);
+      *Freed = TRUE;
+      return(FALSE);
+   }
+
+   if (Window->MessageQueue != MessageQueue)
+   {
+      if (! FromGlobalQueue)
       {
-        /* remove the old WM_MOUSEMOVE message, we're processing a more recent
-           one */
-        RemoveEntryList(&Window->MessageQueue->MouseMoveMsg->ListEntry);
-        ExFreePool(Window->MessageQueue->MouseMoveMsg);
+         DPRINT("Moving msg between private queues\n");
+         /* This message is already queued in a private queue, but we need
+          * to move it to a different queue, perhaps because a new window
+          * was created which now covers the screen area previously taken
+          * by another window. To move it, we need to take it out of the
+          * old queue. Note that we're already holding the lock mutexes of the
+          * old queue */
+         RemoveEntryList(&Message->ListEntry);
+
+         /* remove the pointer for the current WM_MOUSEMOVE message in case we
+            just removed it */
+         if(MessageQueue->MouseMoveMsg == Message)
+         {
+            MessageQueue->MouseMoveMsg = NULL;
+         }
       }
-      /* save the pointer to the WM_MOUSEMOVE message in the new queue */
-      Window->MessageQueue->MouseMoveMsg = Message;
-
-      Window->MessageQueue->QueueBits |= QS_MOUSEMOVE;
-      Window->MessageQueue->ChangedBits |= QS_MOUSEMOVE;
-      if (Window->MessageQueue->WakeMask & QS_MOUSEMOVE)
-        KeSetEvent(Window->MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
-    }
-    else
-    {
-      Window->MessageQueue->QueueBits |= QS_MOUSEBUTTON;
-      Window->MessageQueue->ChangedBits |= QS_MOUSEBUTTON;
-      if (Window->MessageQueue->WakeMask & QS_MOUSEBUTTON)
-        KeSetEvent(Window->MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
-    }
-    IntUnLockHardwareMessageQueue(Window->MessageQueue);
-
-    *Freed = FALSE;
-    IntReleaseWindowObject(Window);
-    return(FALSE);
-  }
-
-  /* From here on, we're in the same message queue as the caller! */
-
-  *ScreenPoint = Message->Msg.pt;
-
-  if((hWnd != NULL && Window->hSelf != hWnd) ||
-     ((FilterLow != 0 || FilterLow != 0) && (Msg < FilterLow || Msg > FilterHigh)))
-  {
-    /* Reject the message because it doesn't match the filter */
-
-    if(FromGlobalQueue)
-    {
-      /* Lock the message queue so no other thread can mess with it.
-         Our own message queue is not locked while fetching from the global
-         queue, so we have to make sure nothing interferes! */
+
+      /* lock the destination message queue, so we don't get in trouble with other
+         threads, messing with it at the same time */
       IntLockHardwareMessageQueue(Window->MessageQueue);
-      /* if we're from the global queue, we need to add our message to our
-         private queue so we don't loose it! */
       InsertTailList(&Window->MessageQueue->HardwareMessagesListHead,
                      &Message->ListEntry);
-    }
-
-    if (Message->Msg.message == WM_MOUSEMOVE)
-    {
-      if(Window->MessageQueue->MouseMoveMsg &&
-         (Window->MessageQueue->MouseMoveMsg != Message))
+      if(Message->Msg.message == WM_MOUSEMOVE)
       {
-        /* delete the old message */
-        RemoveEntryList(&Window->MessageQueue->MouseMoveMsg->ListEntry);
-        ExFreePool(Window->MessageQueue->MouseMoveMsg);
+         if(Window->MessageQueue->MouseMoveMsg)
+         {
+            /* remove the old WM_MOUSEMOVE message, we're processing a more recent
+               one */
+            RemoveEntryList(&Window->MessageQueue->MouseMoveMsg->ListEntry);
+            ExFreePool(Window->MessageQueue->MouseMoveMsg);
+         }
+         /* save the pointer to the WM_MOUSEMOVE message in the new queue */
+         Window->MessageQueue->MouseMoveMsg = Message;
+
+         Window->MessageQueue->QueueBits |= QS_MOUSEMOVE;
+         Window->MessageQueue->ChangedBits |= QS_MOUSEMOVE;
+         if (Window->MessageQueue->WakeMask & QS_MOUSEMOVE)
+            KeSetEvent(Window->MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
       }
-      /* always save a pointer to this WM_MOUSEMOVE message here because we're
-         sure that the message is in the private queue */
-      Window->MessageQueue->MouseMoveMsg = Message;
-    }
-    if(FromGlobalQueue)
-    {
-      IntUnLockHardwareMessageQueue(Window->MessageQueue);
-    }
-
-    IntReleaseWindowObject(Window);
-    *Freed = FALSE;
-    return(FALSE);
-  }
-
-  /* FIXME - only assign if removing? */
-  Message->Msg.hwnd = Window->hSelf;
-  Message->Msg.message = Msg;
-  Message->Msg.lParam = MAKELONG(Message->Msg.pt.x, Message->Msg.pt.y);
-
-  /* remove the reference to the current WM_(NC)MOUSEMOVE message, if this message
-     is it */
-  if (Message->Msg.message == WM_MOUSEMOVE ||
-      Message->Msg.message == WM_NCMOUSEMOVE)
-  {
-    if(FromGlobalQueue)
-    {
-      /* Lock the message queue so no other thread can mess with it.
-         Our own message queue is not locked while fetching from the global
-         queue, so we have to make sure nothing interferes! */
-      IntLockHardwareMessageQueue(Window->MessageQueue);
-      if(Window->MessageQueue->MouseMoveMsg)
+      else
       {
-        /* delete the WM_(NC)MOUSEMOVE message in the private queue, we're dealing
-           with one that's been sent later */
-        RemoveEntryList(&Window->MessageQueue->MouseMoveMsg->ListEntry);
-        ExFreePool(Window->MessageQueue->MouseMoveMsg);
-        /* our message is not in the private queue so we can remove the pointer
-           instead of setting it to the current message we're processing */
-        Window->MessageQueue->MouseMoveMsg = NULL;
+         Window->MessageQueue->QueueBits |= QS_MOUSEBUTTON;
+         Window->MessageQueue->ChangedBits |= QS_MOUSEBUTTON;
+         if (Window->MessageQueue->WakeMask & QS_MOUSEBUTTON)
+            KeSetEvent(Window->MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
       }
       IntUnLockHardwareMessageQueue(Window->MessageQueue);
-    }
-    else if(Window->MessageQueue->MouseMoveMsg == Message)
-    {
-      Window->MessageQueue->MouseMoveMsg = NULL;
-    }
-  }
-
-  IntReleaseWindowObject(Window);
-  *Freed = FALSE;
-  return(TRUE);
+
+      *Freed = FALSE;
+      IntReleaseWindowObject(Window);
+      return(FALSE);
+   }
+
+   /* From here on, we're in the same message queue as the caller! */
+
+   *ScreenPoint = Message->Msg.pt;
+
+   if((hWnd != NULL && Window->hSelf != hWnd) ||
+         ((FilterLow != 0 || FilterLow != 0) && (Msg < FilterLow || Msg > FilterHigh)))
+   {
+      /* Reject the message because it doesn't match the filter */
+
+      if(FromGlobalQueue)
+      {
+         /* Lock the message queue so no other thread can mess with it.
+            Our own message queue is not locked while fetching from the global
+            queue, so we have to make sure nothing interferes! */
+         IntLockHardwareMessageQueue(Window->MessageQueue);
+         /* if we're from the global queue, we need to add our message to our
+            private queue so we don't loose it! */
+         InsertTailList(&Window->MessageQueue->HardwareMessagesListHead,
+                        &Message->ListEntry);
+      }
+
+      if (Message->Msg.message == WM_MOUSEMOVE)
+      {
+         if(Window->MessageQueue->MouseMoveMsg &&
+               (Window->MessageQueue->MouseMoveMsg != Message))
+         {
+            /* delete the old message */
+            RemoveEntryList(&Window->MessageQueue->MouseMoveMsg->ListEntry);
+            ExFreePool(Window->MessageQueue->MouseMoveMsg);
+         }
+         /* always save a pointer to this WM_MOUSEMOVE message here because we're
+            sure that the message is in the private queue */
+         Window->MessageQueue->MouseMoveMsg = Message;
+      }
+      if(FromGlobalQueue)
+      {
+         IntUnLockHardwareMessageQueue(Window->MessageQueue);
+      }
+
+      IntReleaseWindowObject(Window);
+      *Freed = FALSE;
+      return(FALSE);
+   }
+
+   /* FIXME - only assign if removing? */
+   Message->Msg.hwnd = Window->hSelf;
+   Message->Msg.message = Msg;
+   Message->Msg.lParam = MAKELONG(Message->Msg.pt.x, Message->Msg.pt.y);
+
+   /* remove the reference to the current WM_(NC)MOUSEMOVE message, if this message
+      is it */
+   if (Message->Msg.message == WM_MOUSEMOVE ||
+         Message->Msg.message == WM_NCMOUSEMOVE)
+   {
+      if(FromGlobalQueue)
+      {
+         /* Lock the message queue so no other thread can mess with it.
+            Our own message queue is not locked while fetching from the global
+            queue, so we have to make sure nothing interferes! */
+         IntLockHardwareMessageQueue(Window->MessageQueue);
+         if(Window->MessageQueue->MouseMoveMsg)
+         {
+            /* delete the WM_(NC)MOUSEMOVE message in the private queue, we're dealing
+               with one that's been sent later */
+            RemoveEntryList(&Window->MessageQueue->MouseMoveMsg->ListEntry);
+            ExFreePool(Window->MessageQueue->MouseMoveMsg);
+            /* our message is not in the private queue so we can remove the pointer
+               instead of setting it to the current message we're processing */
+            Window->MessageQueue->MouseMoveMsg = NULL;
+         }
+         IntUnLockHardwareMessageQueue(Window->MessageQueue);
+      }
+      else if(Window->MessageQueue->MouseMoveMsg == Message)
+      {
+         Window->MessageQueue->MouseMoveMsg = NULL;
+      }
+   }
+
+   IntReleaseWindowObject(Window);
+   *Freed = FALSE;
+   return(TRUE);
 }
 
 BOOL STDCALL
 co_MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
-                      UINT FilterLow, UINT FilterHigh, BOOL Remove,
-                      PUSER_MESSAGE* Message)
+                          UINT FilterLow, UINT FilterHigh, BOOL Remove,
+                          PUSER_MESSAGE* Message)
 {
-  KIRQL OldIrql;
-  POINT ScreenPoint;
-  BOOL Accept, Freed;
-  PLIST_ENTRY CurrentEntry;
-  PWINDOW_OBJECT DesktopWindow;
-  PVOID WaitObjects[2];
-  NTSTATUS WaitStatus;
-
-  if( !IntGetScreenDC() ||
-      PsGetWin32Thread()->MessageQueue == W32kGetPrimitiveMessageQueue() )
-  {
-    return FALSE;
-  }
-
-  WaitObjects[1] = MessageQueue->NewMessages;
-  WaitObjects[0] = &HardwareMessageQueueLock;
-  do
-    {
+   KIRQL OldIrql;
+   POINT ScreenPoint;
+   BOOL Accept, Freed;
+   PLIST_ENTRY CurrentEntry;
+   PWINDOW_OBJECT DesktopWindow;
+   PVOID WaitObjects[2];
+   NTSTATUS WaitStatus;
+
+   if( !IntGetScreenDC() ||
+         PsGetWin32Thread()->MessageQueue == W32kGetPrimitiveMessageQueue() )
+   {
+      return FALSE;
+   }
+
+   WaitObjects[1] = MessageQueue->NewMessages;
+   WaitObjects[0] = &HardwareMessageQueueLock;
+   do
+   {
       UserLeaveCo();
-      
+
       WaitStatus = KeWaitForMultipleObjects(2, WaitObjects, WaitAny, UserRequest,
                                             UserMode, FALSE, NULL, NULL);
-                                            
+
       UserEnterCo();
-      
+
       while (co_MsqDispatchOneSentMessage(MessageQueue))
-        {
-          ;
-        }
-    }
-  while (NT_SUCCESS(WaitStatus) && STATUS_WAIT_0 != WaitStatus);
-
-  DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
-
-  /* Process messages in the message queue itself. */
-  IntLockHardwareMessageQueue(MessageQueue);
-  CurrentEntry = MessageQueue->HardwareMessagesListHead.Flink;
-  while (CurrentEntry != &MessageQueue->HardwareMessagesListHead)
-    {
+      {
+         ;
+      }
+   }
+   while (NT_SUCCESS(WaitStatus) && STATUS_WAIT_0 != WaitStatus);
+
+   DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
+
+   /* Process messages in the message queue itself. */
+   IntLockHardwareMessageQueue(MessageQueue);
+   CurrentEntry = MessageQueue->HardwareMessagesListHead.Flink;
+   while (CurrentEntry != &MessageQueue->HardwareMessagesListHead)
+   {
       PUSER_MESSAGE Current =
-       CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry);
+         CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry);
       CurrentEntry = CurrentEntry->Flink;
       if (Current->Msg.message >= WM_MOUSEFIRST &&
-         Current->Msg.message <= WM_MOUSELAST)
-       {
-         Accept = co_MsqTranslateMouseMessage(MessageQueue, hWnd, FilterLow, FilterHigh,
-                                           Current, Remove, &Freed,
-                                           DesktopWindow, &ScreenPoint, FALSE);
-         if (Accept)
-           {
-             if (Remove)
-               {
-                 RemoveEntryList(&Current->ListEntry);
-               }
-             IntUnLockHardwareMessageQueue(MessageQueue);
-              IntUnLockSystemHardwareMessageQueueLock(FALSE);
-             *Message = Current;
-             IntReleaseWindowObject(DesktopWindow);
-             return(TRUE);
-           }
-
-       }
-    }
-  IntUnLockHardwareMessageQueue(MessageQueue);
-
-  /* Now try the global queue. */
-
-  /* Transfer all messages from the DPC accessible queue to the main queue. */
-  IntLockSystemMessageQueue(OldIrql);
-  while (SystemMessageQueueCount > 0)
-    {
+            Current->Msg.message <= WM_MOUSELAST)
+      {
+         Accept = co_MsqTranslateMouseMessage(MessageQueue, hWnd, FilterLow, FilterHigh,
+                                              Current, Remove, &Freed,
+                                              DesktopWindow, &ScreenPoint, FALSE);
+         if (Accept)
+         {
+            if (Remove)
+            {
+               RemoveEntryList(&Current->ListEntry);
+            }
+            IntUnLockHardwareMessageQueue(MessageQueue);
+            IntUnLockSystemHardwareMessageQueueLock(FALSE);
+            *Message = Current;
+            IntReleaseWindowObject(DesktopWindow);
+            return(TRUE);
+         }
+
+      }
+   }
+   IntUnLockHardwareMessageQueue(MessageQueue);
+
+   /* Now try the global queue. */
+
+   /* Transfer all messages from the DPC accessible queue to the main queue. */
+   IntLockSystemMessageQueue(OldIrql);
+   while (SystemMessageQueueCount > 0)
+   {
       PUSER_MESSAGE UserMsg;
       MSG Msg;
       BOOL ProcessMessage;
@@ -516,840 +518,846 @@ co_MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
       ASSERT(SystemMessageQueueHead < SYSTEM_MESSAGE_QUEUE_SIZE);
       Msg = SystemMessageQueue[SystemMessageQueueHead];
       SystemMessageQueueHead =
-       (SystemMessageQueueHead + 1) % SYSTEM_MESSAGE_QUEUE_SIZE;
+         (SystemMessageQueueHead + 1) % SYSTEM_MESSAGE_QUEUE_SIZE;
       SystemMessageQueueCount--;
       IntUnLockSystemMessageQueue(OldIrql);
       if (WM_MOUSEFIRST <= Msg.message && Msg.message <= WM_MOUSELAST)
-        {
-          MSLLHOOKSTRUCT MouseHookData;
-
-          MouseHookData.pt.x = LOWORD(Msg.lParam); 
-          MouseHookData.pt.y = HIWORD(Msg.lParam); 
-          switch(Msg.message)
-            {
-              case WM_MOUSEWHEEL:
-                MouseHookData.mouseData = MAKELONG(0, GET_WHEEL_DELTA_WPARAM(Msg.wParam));
-                break;
-              case WM_XBUTTONDOWN:
-              case WM_XBUTTONUP:
-              case WM_XBUTTONDBLCLK:
-              case WM_NCXBUTTONDOWN:
-              case WM_NCXBUTTONUP:
-              case WM_NCXBUTTONDBLCLK:
-                MouseHookData.mouseData = MAKELONG(0, HIWORD(Msg.wParam));
-                break;
-              default:
-                MouseHookData.mouseData = 0;
-                break;
-            }
-          MouseHookData.flags = 0;
-          MouseHookData.time = Msg.time;
-          MouseHookData.dwExtraInfo = 0;
-          ProcessMessage = (0 == co_HOOK_CallHooks(WH_MOUSE_LL, HC_ACTION,
-                                                Msg.message, (LPARAM) &MouseHookData));
-        }
+      {
+         MSLLHOOKSTRUCT MouseHookData;
+
+         MouseHookData.pt.x = LOWORD(Msg.lParam);
+         MouseHookData.pt.y = HIWORD(Msg.lParam);
+         switch(Msg.message)
+         {
+            case WM_MOUSEWHEEL:
+               MouseHookData.mouseData = MAKELONG(0, GET_WHEEL_DELTA_WPARAM(Msg.wParam));
+               break;
+            case WM_XBUTTONDOWN:
+            case WM_XBUTTONUP:
+            case WM_XBUTTONDBLCLK:
+            case WM_NCXBUTTONDOWN:
+            case WM_NCXBUTTONUP:
+            case WM_NCXBUTTONDBLCLK:
+               MouseHookData.mouseData = MAKELONG(0, HIWORD(Msg.wParam));
+               break;
+            default:
+               MouseHookData.mouseData = 0;
+               break;
+         }
+         MouseHookData.flags = 0;
+         MouseHookData.time = Msg.time;
+         MouseHookData.dwExtraInfo = 0;
+         ProcessMessage = (0 == co_HOOK_CallHooks(WH_MOUSE_LL, HC_ACTION,
+                           Msg.message, (LPARAM) &MouseHookData));
+      }
       else
-        {
-          ProcessMessage = TRUE;
-        }
+      {
+         ProcessMessage = TRUE;
+      }
       if (ProcessMessage)
-        {
-          UserMsg = ExAllocateFromPagedLookasideList(&MessageLookasideList);
-          /* What to do if out of memory? For now we just panic a bit in debug */
-          ASSERT(UserMsg);
-          UserMsg->FreeLParam = FALSE;
-          UserMsg->Msg = Msg;
-          InsertTailList(&HardwareMessageQueueHead, &UserMsg->ListEntry);
-        }
+      {
+         UserMsg = ExAllocateFromPagedLookasideList(&MessageLookasideList);
+         /* What to do if out of memory? For now we just panic a bit in debug */
+         ASSERT(UserMsg);
+         UserMsg->FreeLParam = FALSE;
+         UserMsg->Msg = Msg;
+         InsertTailList(&HardwareMessageQueueHead, &UserMsg->ListEntry);
+      }
       IntLockSystemMessageQueue(OldIrql);
-    }
-  /*
-   * we could set this to -1 conditionally if we find one, but
-   * this is more efficient and just as effective.
-   */
-  SystemMessageQueueMouseMove = -1;
-  HardwareMessageQueueStamp++;
-  IntUnLockSystemMessageQueue(OldIrql);
-
-  /* Process messages in the queue until we find one to return. */
-  CurrentEntry = HardwareMessageQueueHead.Flink;
-  while (CurrentEntry != &HardwareMessageQueueHead)
-    {
+   }
+   /*
+    * we could set this to -1 conditionally if we find one, but
+    * this is more efficient and just as effective.
+    */
+   SystemMessageQueueMouseMove = -1;
+   HardwareMessageQueueStamp++;
+   IntUnLockSystemMessageQueue(OldIrql);
+
+   /* Process messages in the queue until we find one to return. */
+   CurrentEntry = HardwareMessageQueueHead.Flink;
+   while (CurrentEntry != &HardwareMessageQueueHead)
+   {
       PUSER_MESSAGE Current =
-       CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry);
+         CONTAINING_RECORD(CurrentEntry, USER_MESSAGE, ListEntry);
       CurrentEntry = CurrentEntry->Flink;
       RemoveEntryList(&Current->ListEntry);
       HardwareMessageQueueStamp++;
       if (Current->Msg.message >= WM_MOUSEFIRST &&
-         Current->Msg.message <= WM_MOUSELAST)
-       {
-         const ULONG ActiveStamp = HardwareMessageQueueStamp;
-         /* Translate the message. */
-         Accept = co_MsqTranslateMouseMessage(MessageQueue, hWnd, FilterLow, FilterHigh,
-                                           Current, Remove, &Freed,
-                                           DesktopWindow, &ScreenPoint, TRUE);
-         if (Accept)
-           {
-             /* Check for no more messages in the system queue. */
-             IntLockSystemMessageQueue(OldIrql);
-             if (SystemMessageQueueCount == 0 &&
-                 IsListEmpty(&HardwareMessageQueueHead))
-               {
-                 KeClearEvent(&HardwareMessageEvent);
-               }
-             IntUnLockSystemMessageQueue(OldIrql);
-
-             /*
-                If we aren't removing the message then add it to the private
-                queue.
-             */
-             if (!Remove)
-               {
-                  IntLockHardwareMessageQueue(MessageQueue);
-                 if(Current->Msg.message == WM_MOUSEMOVE)
-                 {
-                   if(MessageQueue->MouseMoveMsg)
-                   {
-                     RemoveEntryList(&MessageQueue->MouseMoveMsg->ListEntry);
-                     ExFreePool(MessageQueue->MouseMoveMsg);
-                   }
-                   MessageQueue->MouseMoveMsg = Current;
-                 }
-                 InsertTailList(&MessageQueue->HardwareMessagesListHead,
-                                &Current->ListEntry);
-                  IntUnLockHardwareMessageQueue(MessageQueue);
-               }
-             IntUnLockSystemHardwareMessageQueueLock(FALSE);
-             *Message = Current;
-             IntReleaseWindowObject(DesktopWindow);
-             return(TRUE);
-           }
-         /* If the contents of the queue changed then restart processing. */
-         if (HardwareMessageQueueStamp != ActiveStamp)
-           {
-             CurrentEntry = HardwareMessageQueueHead.Flink;
-             continue;
-           }
-       }
-    }
-  IntReleaseWindowObject(DesktopWindow);
-  /* Check if the system message queue is now empty. */
-  IntLockSystemMessageQueue(OldIrql);
-  if (SystemMessageQueueCount == 0 && IsListEmpty(&HardwareMessageQueueHead))
-    {
+            Current->Msg.message <= WM_MOUSELAST)
+      {
+         const ULONG ActiveStamp = HardwareMessageQueueStamp;
+         /* Translate the message. */
+         Accept = co_MsqTranslateMouseMessage(MessageQueue, hWnd, FilterLow, FilterHigh,
+                                              Current, Remove, &Freed,
+                                              DesktopWindow, &ScreenPoint, TRUE);
+         if (Accept)
+         {
+            /* Check for no more messages in the system queue. */
+            IntLockSystemMessageQueue(OldIrql);
+            if (SystemMessageQueueCount == 0 &&
+                  IsListEmpty(&HardwareMessageQueueHead))
+            {
+               KeClearEvent(&HardwareMessageEvent);
+            }
+            IntUnLockSystemMessageQueue(OldIrql);
+
+            /*
+            If we aren't removing the message then add it to the private
+            queue.
+            */
+            if (!Remove)
+            {
+               IntLockHardwareMessageQueue(MessageQueue);
+               if(Current->Msg.message == WM_MOUSEMOVE)
+               {
+                  if(MessageQueue->MouseMoveMsg)
+                  {
+                     RemoveEntryList(&MessageQueue->MouseMoveMsg->ListEntry);
+                     ExFreePool(MessageQueue->MouseMoveMsg);
+                  }
+                  MessageQueue->MouseMoveMsg = Current;
+               }
+               InsertTailList(&MessageQueue->HardwareMessagesListHead,
+                              &Current->ListEntry);
+               IntUnLockHardwareMessageQueue(MessageQueue);
+            }
+            IntUnLockSystemHardwareMessageQueueLock(FALSE);
+            *Message = Current;
+            IntReleaseWindowObject(DesktopWindow);
+            return(TRUE);
+         }
+         /* If the contents of the queue changed then restart processing. */
+         if (HardwareMessageQueueStamp != ActiveStamp)
+         {
+            CurrentEntry = HardwareMessageQueueHead.Flink;
+            continue;
+         }
+      }
+   }
+   IntReleaseWindowObject(DesktopWindow);
+   /* Check if the system message queue is now empty. */
+   IntLockSystemMessageQueue(OldIrql);
+   if (SystemMessageQueueCount == 0 && IsListEmpty(&HardwareMessageQueueHead))
+   {
       KeClearEvent(&HardwareMessageEvent);
-    }
-  IntUnLockSystemMessageQueue(OldIrql);
-  IntUnLockSystemHardwareMessageQueueLock(FALSE);
+   }
+   IntUnLockSystemMessageQueue(OldIrql);
+   IntUnLockSystemHardwareMessageQueueLock(FALSE);
 
-  return(FALSE);
+   return(FALSE);
 }
 
 VOID FASTCALL
 co_MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
-  PUSER_MESSAGE_QUEUE FocusMessageQueue;
-  MSG Msg;
-  LARGE_INTEGER LargeTickCount;
-  KBDLLHOOKSTRUCT KbdHookData;
-
-  DPRINT("MsqPostKeyboardMessage(uMsg 0x%x, wParam 0x%x, lParam 0x%x)\n",
-    uMsg, wParam, lParam);
-
-  Msg.hwnd = 0;
-  Msg.message = uMsg;
-  Msg.wParam = wParam;
-  Msg.lParam = lParam;
-
-  KeQueryTickCount(&LargeTickCount);
-  Msg.time = LargeTickCount.u.LowPart;
-  /* We can't get the Msg.pt point here since we don't know thread
-     (and thus the window station) the message will end up in yet. */
-
-  KbdHookData.vkCode = Msg.wParam;
-  KbdHookData.scanCode = (Msg.lParam >> 16) & 0xff;
-  KbdHookData.flags = (0 == (Msg.lParam & 0x01000000) ? 0 : LLKHF_EXTENDED) |
-                      (0 == (Msg.lParam & 0x20000000) ? 0 : LLKHF_ALTDOWN) |
-                      (0 == (Msg.lParam & 0x80000000) ? 0 : LLKHF_UP);
-  KbdHookData.time = Msg.time;
-  KbdHookData.dwExtraInfo = 0;
-  if (co_HOOK_CallHooks(WH_KEYBOARD_LL, HC_ACTION, Msg.message, (LPARAM) &KbdHookData))
-    {
+   PUSER_MESSAGE_QUEUE FocusMessageQueue;
+   MSG Msg;
+   LARGE_INTEGER LargeTickCount;
+   KBDLLHOOKSTRUCT KbdHookData;
+
+   DPRINT("MsqPostKeyboardMessage(uMsg 0x%x, wParam 0x%x, lParam 0x%x)\n",
+          uMsg, wParam, lParam);
+
+   Msg.hwnd = 0;
+   Msg.message = uMsg;
+   Msg.wParam = wParam;
+   Msg.lParam = lParam;
+
+   KeQueryTickCount(&LargeTickCount);
+   Msg.time = LargeTickCount.u.LowPart;
+   /* We can't get the Msg.pt point here since we don't know thread
+      (and thus the window station) the message will end up in yet. */
+
+   KbdHookData.vkCode = Msg.wParam;
+   KbdHookData.scanCode = (Msg.lParam >> 16) & 0xff;
+   KbdHookData.flags = (0 == (Msg.lParam & 0x01000000) ? 0 : LLKHF_EXTENDED) |
+                       (0 == (Msg.lParam & 0x20000000) ? 0 : LLKHF_ALTDOWN) |
+                       (0 == (Msg.lParam & 0x80000000) ? 0 : LLKHF_UP);
+   KbdHookData.time = Msg.time;
+   KbdHookData.dwExtraInfo = 0;
+   if (co_HOOK_CallHooks(WH_KEYBOARD_LL, HC_ACTION, Msg.message, (LPARAM) &KbdHookData))
+   {
       DPRINT("Kbd msg %d wParam %d lParam 0x%08x dropped by WH_KEYBOARD_LL hook\n",
              Msg.message, Msg.wParam, Msg.lParam);
       return;
-    }
-
-  FocusMessageQueue = IntGetFocusMessageQueue();
-  if( !IntGetScreenDC() ) {
-    /* FIXME: What to do about Msg.pt here? */
-    if( W32kGetPrimitiveMessageQueue() ) {
-      MsqPostMessage(W32kGetPrimitiveMessageQueue(), &Msg, FALSE, QS_KEY);
-    }
-  } else {
-    if (FocusMessageQueue == NULL)
+   }
+
+   FocusMessageQueue = IntGetFocusMessageQueue();
+   if( !IntGetScreenDC() )
+   {
+      /* FIXME: What to do about Msg.pt here? */
+      if( W32kGetPrimitiveMessageQueue() )
+      {
+         MsqPostMessage(W32kGetPrimitiveMessageQueue(), &Msg, FALSE, QS_KEY);
+      }
+   }
+   else
+   {
+      if (FocusMessageQueue == NULL)
       {
-       DPRINT("No focus message queue\n");
-       return;
+         DPRINT("No focus message queue\n");
+         return;
       }
 
-    if (FocusMessageQueue->FocusWindow != (HWND)0)
+      if (FocusMessageQueue->FocusWindow != (HWND)0)
       {
-       Msg.hwnd = FocusMessageQueue->FocusWindow;
-        DPRINT("Msg.hwnd = %x\n", Msg.hwnd);
-        IntGetCursorLocation(FocusMessageQueue->Desktop->WindowStation,
-                             &Msg.pt);
-       MsqPostMessage(FocusMessageQueue, &Msg, FALSE, QS_KEY);
+         Msg.hwnd = FocusMessageQueue->FocusWindow;
+         DPRINT("Msg.hwnd = %x\n", Msg.hwnd);
+         IntGetCursorLocation(FocusMessageQueue->Desktop->WindowStation,
+                              &Msg.pt);
+         MsqPostMessage(FocusMessageQueue, &Msg, FALSE, QS_KEY);
       }
-    else
+      else
       {
-       DPRINT("Invalid focus window handle\n");
+         DPRINT("Invalid focus window handle\n");
       }
-  }
+   }
 }
 
 VOID FASTCALL
 MsqPostHotKeyMessage(PVOID Thread, HWND hWnd, WPARAM wParam, LPARAM lParam)
 {
-  PWINDOW_OBJECT Window;
-  PW32THREAD Win32Thread;
-  PWINSTATION_OBJECT WinSta;
-  MSG Mesg;
-  LARGE_INTEGER LargeTickCount;
-  NTSTATUS Status;
-
-  Status = ObReferenceObjectByPointer (Thread,
-                                      THREAD_ALL_ACCESS,
-                                      PsThreadType,
-                                      KernelMode);
-  if (!NT_SUCCESS(Status))
-    return;
-
-  Win32Thread = ((PETHREAD)Thread)->Tcb.Win32Thread;
-  if (Win32Thread == NULL || Win32Thread->MessageQueue == NULL)
-    {
+   PWINDOW_OBJECT Window;
+   PW32THREAD Win32Thread;
+   PWINSTATION_OBJECT WinSta;
+   MSG Mesg;
+   LARGE_INTEGER LargeTickCount;
+   NTSTATUS Status;
+
+   Status = ObReferenceObjectByPointer (Thread,
+                                        THREAD_ALL_ACCESS,
+                                        PsThreadType,
+                                        KernelMode);
+   if (!NT_SUCCESS(Status))
+      return;
+
+   Win32Thread = ((PETHREAD)Thread)->Tcb.Win32Thread;
+   if (Win32Thread == NULL || Win32Thread->MessageQueue == NULL)
+   {
       ObDereferenceObject ((PETHREAD)Thread);
       return;
-    }
+   }
 
-  WinSta = Win32Thread->Desktop->WindowStation;
-  Window = IntGetWindowObject(hWnd);
-  if (!Window)
-    {
+   WinSta = Win32Thread->Desktop->WindowStation;
+   Window = IntGetWindowObject(hWnd);
+   if (!Window)
+   {
       ObDereferenceObject ((PETHREAD)Thread);
       return;
-    }
-
-  Mesg.hwnd = hWnd;
-  Mesg.message = WM_HOTKEY;
-  Mesg.wParam = wParam;
-  Mesg.lParam = lParam;
-  KeQueryTickCount(&LargeTickCount);
-  Mesg.time = LargeTickCount.u.LowPart;
-  IntGetCursorLocation(WinSta, &Mesg.pt);
-  MsqPostMessage(Window->MessageQueue, &Mesg, FALSE, QS_HOTKEY);
-  ObmDereferenceObject(Window);
-  ObDereferenceObject (Thread);
-
-//  InsertHeadList(&pThread->MessageQueue->PostedMessagesListHead,
-//              &Message->ListEntry);
-//  KeSetEvent(pThread->MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
+   }
+
+   Mesg.hwnd = hWnd;
+   Mesg.message = WM_HOTKEY;
+   Mesg.wParam = wParam;
+   Mesg.lParam = lParam;
+   KeQueryTickCount(&LargeTickCount);
+   Mesg.time = LargeTickCount.u.LowPart;
+   IntGetCursorLocation(WinSta, &Mesg.pt);
+   MsqPostMessage(Window->MessageQueue, &Mesg, FALSE, QS_HOTKEY);
+   ObmDereferenceObject(Window);
+   ObDereferenceObject (Thread);
+
+   //  InsertHeadList(&pThread->MessageQueue->PostedMessagesListHead,
+   //   &Message->ListEntry);
+   //  KeSetEvent(pThread->MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
 }
 
 PUSER_MESSAGE FASTCALL
 MsqCreateMessage(LPMSG Msg, BOOLEAN FreeLParam)
 {
-  PUSER_MESSAGE Message;
+   PUSER_MESSAGE Message;
 
-  Message = ExAllocateFromPagedLookasideList(&MessageLookasideList);
-  if (!Message)
-    {
+   Message = ExAllocateFromPagedLookasideList(&MessageLookasideList);
+   if (!Message)
+   {
       return NULL;
-    }
+   }
 
-  Message->FreeLParam = FreeLParam;
-  RtlMoveMemory(&Message->Msg, Msg, sizeof(MSG));
+   Message->FreeLParam = FreeLParam;
+   RtlMoveMemory(&Message->Msg, Msg, sizeof(MSG));
 
-  return Message;
+   return Message;
 }
 
 VOID FASTCALL
 MsqDestroyMessage(PUSER_MESSAGE Message)
 {
-  ExFreeToPagedLookasideList(&MessageLookasideList, Message);
+   ExFreeToPagedLookasideList(&MessageLookasideList, Message);
 }
 
 VOID FASTCALL
 co_MsqDispatchSentNotifyMessages(PUSER_MESSAGE_QUEUE MessageQueue)
 {
-  PLIST_ENTRY ListEntry;
-  PUSER_SENT_MESSAGE_NOTIFY Message;
+   PLIST_ENTRY ListEntry;
+   PUSER_SENT_MESSAGE_NOTIFY Message;
 
-  while (!IsListEmpty(&MessageQueue->SentMessagesListHead))
-  {
-    ListEntry = RemoveHeadList(&MessageQueue->SentMessagesListHead);
-    Message = CONTAINING_RECORD(ListEntry, USER_SENT_MESSAGE_NOTIFY,
-                               ListEntry);
+   while (!IsListEmpty(&MessageQueue->SentMessagesListHead))
+   {
+      ListEntry = RemoveHeadList(&MessageQueue->SentMessagesListHead);
+      Message = CONTAINING_RECORD(ListEntry, USER_SENT_MESSAGE_NOTIFY,
+                                  ListEntry);
 
-    co_IntCallSentMessageCallback(Message->CompletionCallback,
-                               Message->hWnd,
-                               Message->Msg,
-                               Message->CompletionCallbackContext,
-                               Message->Result);
+      co_IntCallSentMessageCallback(Message->CompletionCallback,
+                                    Message->hWnd,
+                                    Message->Msg,
+                                    Message->CompletionCallbackContext,
+                                    Message->Result);
 
-  }
+   }
 
 }
 
 BOOLEAN FASTCALL
 MsqPeekSentMessages(PUSER_MESSAGE_QUEUE MessageQueue)
 {
-  return(!IsListEmpty(&MessageQueue->SentMessagesListHead));
+   return(!IsListEmpty(&MessageQueue->SentMessagesListHead));
 }
 
 BOOLEAN FASTCALL
 co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue)
 {
-  PUSER_SENT_MESSAGE Message;
-  PLIST_ENTRY Entry;
-  LRESULT Result;
-  BOOL SenderReturned;
-  PUSER_SENT_MESSAGE_NOTIFY NotifyMessage;
-
-  if (IsListEmpty(&MessageQueue->SentMessagesListHead))
-    {
+   PUSER_SENT_MESSAGE Message;
+   PLIST_ENTRY Entry;
+   LRESULT Result;
+   BOOL SenderReturned;
+   PUSER_SENT_MESSAGE_NOTIFY NotifyMessage;
+
+   if (IsListEmpty(&MessageQueue->SentMessagesListHead))
+   {
       return(FALSE);
-    }
+   }
 
-  /* remove it from the list of pending messages */
-  Entry = RemoveHeadList(&MessageQueue->SentMessagesListHead);
-  Message = CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, ListEntry);
+   /* remove it from the list of pending messages */
+   Entry = RemoveHeadList(&MessageQueue->SentMessagesListHead);
+   Message = CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, ListEntry);
 
-  /* insert it to the list of messages that are currently dispatched by this
-     message queue */
-  InsertTailList(&MessageQueue->LocalDispatchingMessagesHead,
-                &Message->ListEntry);
+   /* insert it to the list of messages that are currently dispatched by this
+      message queue */
+   InsertTailList(&MessageQueue->LocalDispatchingMessagesHead,
+                  &Message->ListEntry);
 
-  if (Message->HookMessage)
-    {
+   if (Message->HookMessage)
+   {
       Result = co_HOOK_CallHooks(Message->Msg.message,
-                              (INT) Message->Msg.hwnd,
-                              Message->Msg.wParam,
-                              Message->Msg.lParam);
-    }
-  else
-    {
+                                 (INT) Message->Msg.hwnd,
+                                 Message->Msg.wParam,
+                                 Message->Msg.lParam);
+   }
+   else
+   {
       /* Call the window procedure. */
       Result = co_IntSendMessage(Message->Msg.hwnd,
-                              Message->Msg.message,
-                              Message->Msg.wParam,
-                              Message->Msg.lParam);
-    }
-
-  /* remove the message from the local dispatching list, because it doesn't need
-     to be cleaned up on thread termination anymore */
-  RemoveEntryList(&Message->ListEntry);
-
-  /* remove the message from the dispatching list, so lock the sender's message queue */
-  SenderReturned = (Message->DispatchingListEntry.Flink == NULL);
-  if(!SenderReturned)
-  {
-    /* only remove it from the dispatching list if not already removed by a timeout */
-    RemoveEntryList(&Message->DispatchingListEntry);
-  }
-  /* still keep the sender's message queue locked, so the sender can't exit the
-     MsqSendMessage() function (if timed out) */
-
-  /* Let the sender know the result. */
-  if (Message->Result != NULL)
-    {
+                                 Message->Msg.message,
+                                 Message->Msg.wParam,
+                                 Message->Msg.lParam);
+   }
+
+   /* remove the message from the local dispatching list, because it doesn't need
+      to be cleaned up on thread termination anymore */
+   RemoveEntryList(&Message->ListEntry);
+
+   /* remove the message from the dispatching list, so lock the sender's message queue */
+   SenderReturned = (Message->DispatchingListEntry.Flink == NULL);
+   if(!SenderReturned)
+   {
+      /* only remove it from the dispatching list if not already removed by a timeout */
+      RemoveEntryList(&Message->DispatchingListEntry);
+   }
+   /* still keep the sender's message queue locked, so the sender can't exit the
+      MsqSendMessage() function (if timed out) */
+
+   /* Let the sender know the result. */
+   if (Message->Result != NULL)
+   {
       *Message->Result = Result;
-    }
+   }
 
-  /* Notify the sender. */
-  if (Message->CompletionEvent != NULL)
-    {
+   /* Notify the sender. */
+   if (Message->CompletionEvent != NULL)
+   {
       KeSetEvent(Message->CompletionEvent, IO_NO_INCREMENT, FALSE);
-    }
+   }
 
-  /* Notify the sender if they specified a callback. */
-  if (!SenderReturned && Message->CompletionCallback != NULL)
-    {
+   /* Notify the sender if they specified a callback. */
+   if (!SenderReturned && Message->CompletionCallback != NULL)
+   {
       if(!(NotifyMessage = ExAllocatePoolWithTag(NonPagedPool,
-                                                sizeof(USER_SENT_MESSAGE_NOTIFY), TAG_USRMSG)))
+                           sizeof(USER_SENT_MESSAGE_NOTIFY), TAG_USRMSG)))
       {
-        DPRINT1("MsqDispatchOneSentMessage(): Not enough memory to create a callback notify message\n");
-        goto Notified;
+         DPRINT1("MsqDispatchOneSentMessage(): Not enough memory to create a callback notify message\n");
+         goto Notified;
       }
       NotifyMessage->CompletionCallback =
-       Message->CompletionCallback;
+         Message->CompletionCallback;
       NotifyMessage->CompletionCallbackContext =
-       Message->CompletionCallbackContext;
+         Message->CompletionCallbackContext;
       NotifyMessage->Result = Result;
       NotifyMessage->hWnd = Message->Msg.hwnd;
       NotifyMessage->Msg = Message->Msg.message;
       MsqSendNotifyMessage(Message->SenderQueue, NotifyMessage);
-    }
+   }
 
 Notified:
 
-  /* dereference both sender and our queue */
-  IntDereferenceMessageQueue(MessageQueue);
-  IntDereferenceMessageQueue(Message->SenderQueue);
+   /* dereference both sender and our queue */
+   IntDereferenceMessageQueue(MessageQueue);
+   IntDereferenceMessageQueue(Message->SenderQueue);
 
-  /* free the message */
-  ExFreePool(Message);
-  return(TRUE);
+   /* free the message */
+   ExFreePool(Message);
+   return(TRUE);
 }
 
 VOID STDCALL
 MsqRemoveWindowMessagesFromQueue(PVOID pWindow)
 {
-  PUSER_SENT_MESSAGE SentMessage;
-  PUSER_MESSAGE PostedMessage;
-  PUSER_MESSAGE_QUEUE MessageQueue;
-  PLIST_ENTRY CurrentEntry, ListHead;
-  PWINDOW_OBJECT Window = pWindow;
-
-  ASSERT(Window);
-
-  MessageQueue = Window->MessageQueue;
-  ASSERT(MessageQueue);
-
-  /* remove the posted messages for this window */
-  CurrentEntry = MessageQueue->PostedMessagesListHead.Flink;
-  ListHead = &MessageQueue->PostedMessagesListHead;
-  while (CurrentEntry != ListHead)
-    {
+   PUSER_SENT_MESSAGE SentMessage;
+   PUSER_MESSAGE PostedMessage;
+   PUSER_MESSAGE_QUEUE MessageQueue;
+   PLIST_ENTRY CurrentEntry, ListHead;
+   PWINDOW_OBJECT Window = pWindow;
+
+   ASSERT(Window);
+
+   MessageQueue = Window->MessageQueue;
+   ASSERT(MessageQueue);
+
+   /* remove the posted messages for this window */
+   CurrentEntry = MessageQueue->PostedMessagesListHead.Flink;
+   ListHead = &MessageQueue->PostedMessagesListHead;
+   while (CurrentEntry != ListHead)
+   {
       PostedMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE,
-                                       ListEntry);
+                                        ListEntry);
       if (PostedMessage->Msg.hwnd == Window->hSelf)
-       {
-         RemoveEntryList(&PostedMessage->ListEntry);
-         MsqDestroyMessage(PostedMessage);
-          CurrentEntry = MessageQueue->PostedMessagesListHead.Flink;
-       }
+      {
+         RemoveEntryList(&PostedMessage->ListEntry);
+         MsqDestroyMessage(PostedMessage);
+         CurrentEntry = MessageQueue->PostedMessagesListHead.Flink;
+      }
       else
-        {
-          CurrentEntry = CurrentEntry->Flink;
-        }
-    }
-
-  /* remove the sent messages for this window */
-  CurrentEntry = MessageQueue->SentMessagesListHead.Flink;
-  ListHead = &MessageQueue->SentMessagesListHead;
-  while (CurrentEntry != ListHead)
-    {
+      {
+         CurrentEntry = CurrentEntry->Flink;
+      }
+   }
+
+   /* remove the sent messages for this window */
+   CurrentEntry = MessageQueue->SentMessagesListHead.Flink;
+   ListHead = &MessageQueue->SentMessagesListHead;
+   while (CurrentEntry != ListHead)
+   {
       CurrentEntry = RemoveHeadList(&MessageQueue->SentMessagesListHead);
       SentMessage = CONTAINING_RECORD(CurrentEntry, USER_SENT_MESSAGE,
                                       ListEntry);
       if(SentMessage->Msg.hwnd == Window->hSelf)
       {
-        DPRINT("Notify the sender and remove a message from the queue that had not been dispatched\n");
+         DPRINT("Notify the sender and remove a message from the queue that had not been dispatched\n");
 
-        /* remove the message from the dispatching list */
-        if(SentMessage->DispatchingListEntry.Flink != NULL)
-        {
-          RemoveEntryList(&SentMessage->DispatchingListEntry);
-        }
+         /* remove the message from the dispatching list */
+         if(SentMessage->DispatchingListEntry.Flink != NULL)
+         {
+            RemoveEntryList(&SentMessage->DispatchingListEntry);
+         }
 
-        /* wake the sender's thread */
-        if (SentMessage->CompletionEvent != NULL)
-        {
-          KeSetEvent(SentMessage->CompletionEvent, IO_NO_INCREMENT, FALSE);
-        }
+         /* wake the sender's thread */
+         if (SentMessage->CompletionEvent != NULL)
+         {
+            KeSetEvent(SentMessage->CompletionEvent, IO_NO_INCREMENT, FALSE);
+         }
 
-        /* dereference our and the sender's message queue */
-        IntDereferenceMessageQueue(MessageQueue);
-        IntDereferenceMessageQueue(SentMessage->SenderQueue);
+         /* dereference our and the sender's message queue */
+         IntDereferenceMessageQueue(MessageQueue);
+         IntDereferenceMessageQueue(SentMessage->SenderQueue);
 
-        /* free the message */
-        ExFreePool(SentMessage);
+         /* free the message */
+         ExFreePool(SentMessage);
 
-        CurrentEntry = MessageQueue->SentMessagesListHead.Flink;
+         CurrentEntry = MessageQueue->SentMessagesListHead.Flink;
       }
       else
       {
-        CurrentEntry = CurrentEntry->Flink;
+         CurrentEntry = CurrentEntry->Flink;
       }
-    }
+   }
 }
 
 VOID FASTCALL
 MsqSendNotifyMessage(PUSER_MESSAGE_QUEUE MessageQueue,
-                    PUSER_SENT_MESSAGE_NOTIFY NotifyMessage)
+                     PUSER_SENT_MESSAGE_NOTIFY NotifyMessage)
 {
-  InsertTailList(&MessageQueue->NotifyMessagesListHead,
-                &NotifyMessage->ListEntry);
-  MessageQueue->QueueBits |= QS_SENDMESSAGE;
-  MessageQueue->ChangedBits |= QS_SENDMESSAGE;
-  if (MessageQueue->WakeMask & QS_SENDMESSAGE)
-    KeSetEvent(MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
+   InsertTailList(&MessageQueue->NotifyMessagesListHead,
+                  &NotifyMessage->ListEntry);
+   MessageQueue->QueueBits |= QS_SENDMESSAGE;
+   MessageQueue->ChangedBits |= QS_SENDMESSAGE;
+   if (MessageQueue->WakeMask & QS_SENDMESSAGE)
+      KeSetEvent(MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
 }
 
 NTSTATUS FASTCALL
 co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue,
-              HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam,
-               UINT uTimeout, BOOL Block, BOOL HookMessage,
-               ULONG_PTR *uResult)
+                  HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam,
+                  UINT uTimeout, BOOL Block, BOOL HookMessage,
+                  ULONG_PTR *uResult)
 {
-  PUSER_SENT_MESSAGE Message;
-  KEVENT CompletionEvent;
-  NTSTATUS WaitStatus;
-  LRESULT Result;
-  PUSER_MESSAGE_QUEUE ThreadQueue;
-  LARGE_INTEGER Timeout;
-  PLIST_ENTRY Entry;
-
-  if(!(Message = ExAllocatePoolWithTag(PagedPool, sizeof(USER_SENT_MESSAGE), TAG_USRMSG)))
-  {
-    DPRINT1("MsqSendMessage(): Not enough memory to allocate a message");
-    return STATUS_INSUFFICIENT_RESOURCES;
-  }
-
-  KeInitializeEvent(&CompletionEvent, NotificationEvent, FALSE);
-
-  ThreadQueue = PsGetWin32Thread()->MessageQueue;
-  ASSERT(ThreadQueue != MessageQueue);
-
-  Timeout.QuadPart = (LONGLONG) uTimeout * (LONGLONG) -10000;
-
-  /* FIXME - increase reference counter of sender's message queue here */
-
-  Result = 0;
-  Message->Msg.hwnd = Wnd;
-  Message->Msg.message = Msg;
-  Message->Msg.wParam = wParam;
-  Message->Msg.lParam = lParam;
-  Message->CompletionEvent = &CompletionEvent;
-  Message->Result = &Result;
-  Message->SenderQueue = ThreadQueue;
-  IntReferenceMessageQueue(ThreadQueue);
-  Message->CompletionCallback = NULL;
-  Message->HookMessage = HookMessage;
-
-  IntReferenceMessageQueue(MessageQueue);
-
-  /* add it to the list of pending messages */
-  InsertTailList(&ThreadQueue->DispatchingMessagesHead, &Message->DispatchingListEntry);
-
-  /* queue it in the destination's message queue */
-  InsertTailList(&MessageQueue->SentMessagesListHead, &Message->ListEntry);
-
-  MessageQueue->QueueBits |= QS_SENDMESSAGE;
-  MessageQueue->ChangedBits |= QS_SENDMESSAGE;
-  if (MessageQueue->WakeMask & QS_SENDMESSAGE)
-    KeSetEvent(MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
-
-  /* we can't access the Message anymore since it could have already been deleted! */
-
-  if(Block)
-  {
-    
-    UserLeaveCo();
-    
-    /* don't process messages sent to the thread */
-    WaitStatus = KeWaitForSingleObject(&CompletionEvent, UserRequest, UserMode,
-                                       FALSE, (uTimeout ? &Timeout : NULL));
-                                       
-    UserEnterCo();
-    
-    if(WaitStatus == STATUS_TIMEOUT)
+   PUSER_SENT_MESSAGE Message;
+   KEVENT CompletionEvent;
+   NTSTATUS WaitStatus;
+   LRESULT Result;
+   PUSER_MESSAGE_QUEUE ThreadQueue;
+   LARGE_INTEGER Timeout;
+   PLIST_ENTRY Entry;
+
+   if(!(Message = ExAllocatePoolWithTag(PagedPool, sizeof(USER_SENT_MESSAGE), TAG_USRMSG)))
+   {
+      DPRINT1("MsqSendMessage(): Not enough memory to allocate a message");
+      return STATUS_INSUFFICIENT_RESOURCES;
+   }
+
+   KeInitializeEvent(&CompletionEvent, NotificationEvent, FALSE);
+
+   ThreadQueue = PsGetWin32Thread()->MessageQueue;
+   ASSERT(ThreadQueue != MessageQueue);
+
+   Timeout.QuadPart = (LONGLONG) uTimeout * (LONGLONG) -10000;
+
+   /* FIXME - increase reference counter of sender's message queue here */
+
+   Result = 0;
+   Message->Msg.hwnd = Wnd;
+   Message->Msg.message = Msg;
+   Message->Msg.wParam = wParam;
+   Message->Msg.lParam = lParam;
+   Message->CompletionEvent = &CompletionEvent;
+   Message->Result = &Result;
+   Message->SenderQueue = ThreadQueue;
+   IntReferenceMessageQueue(ThreadQueue);
+   Message->CompletionCallback = NULL;
+   Message->HookMessage = HookMessage;
+
+   IntReferenceMessageQueue(MessageQueue);
+
+   /* add it to the list of pending messages */
+   InsertTailList(&ThreadQueue->DispatchingMessagesHead, &Message->DispatchingListEntry);
+
+   /* queue it in the destination's message queue */
+   InsertTailList(&MessageQueue->SentMessagesListHead, &Message->ListEntry);
+
+   MessageQueue->QueueBits |= QS_SENDMESSAGE;
+   MessageQueue->ChangedBits |= QS_SENDMESSAGE;
+   if (MessageQueue->WakeMask & QS_SENDMESSAGE)
+      KeSetEvent(MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
+
+   /* we can't access the Message anymore since it could have already been deleted! */
+
+   if(Block)
+   {
+
+      UserLeaveCo();
+
+      /* don't process messages sent to the thread */
+      WaitStatus = KeWaitForSingleObject(&CompletionEvent, UserRequest, UserMode,
+                                         FALSE, (uTimeout ? &Timeout : NULL));
+
+      UserEnterCo();
+
+      if(WaitStatus == STATUS_TIMEOUT)
       {
-        /* look up if the message has not yet dispatched, if so
-           make sure it can't pass a result and it must not set the completion event anymore */
-        Entry = MessageQueue->SentMessagesListHead.Flink;
-        while (Entry != &MessageQueue->SentMessagesListHead)
-          {
+         /* look up if the message has not yet dispatched, if so
+            make sure it can't pass a result and it must not set the completion event anymore */
+         Entry = MessageQueue->SentMessagesListHead.Flink;
+         while (Entry != &MessageQueue->SentMessagesListHead)
+         {
             if ((PUSER_SENT_MESSAGE) CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, ListEntry)
-                == Message)
-              {
-                /* we can access Message here, it's secure because the message queue is locked
-                   and the message is still hasn't been dispatched */
-               Message->CompletionEvent = NULL;
-                Message->Result = NULL;
-                break;
-              }
+                  == Message)
+            {
+               /* we can access Message here, it's secure because the message queue is locked
+                  and the message is still hasn't been dispatched */
+               Message->CompletionEvent = NULL;
+               Message->Result = NULL;
+               break;
+            }
             Entry = Entry->Flink;
-          }
+         }
 
-       /* remove from the local dispatching list so the other thread knows,
-          it can't pass a result and it must not set the completion event anymore */
-        Entry = ThreadQueue->DispatchingMessagesHead.Flink;
-        while (Entry != &ThreadQueue->DispatchingMessagesHead)
-          {
+         /* remove from the local dispatching list so the other thread knows,
+            it can't pass a result and it must not set the completion event anymore */
+         Entry = ThreadQueue->DispatchingMessagesHead.Flink;
+         while (Entry != &ThreadQueue->DispatchingMessagesHead)
+         {
             if ((PUSER_SENT_MESSAGE) CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, DispatchingListEntry)
-                == Message)
-              {
-                /* we can access Message here, it's secure because the sender's message is locked
-                   and the message has definitely not yet been destroyed, otherwise it would
-                   have been removed from this list by the dispatching routine right after
-                  dispatching the message */
-               Message->CompletionEvent = NULL;
-                Message->Result = NULL;
-                RemoveEntryList(&Message->DispatchingListEntry);
-                Message->DispatchingListEntry.Flink = NULL;
-                break;
-              }
+                  == Message)
+            {
+               /* we can access Message here, it's secure because the sender's message is locked
+                  and the message has definitely not yet been destroyed, otherwise it would
+                  have been removed from this list by the dispatching routine right after
+               dispatching the message */
+               Message->CompletionEvent = NULL;
+               Message->Result = NULL;
+               RemoveEntryList(&Message->DispatchingListEntry);
+               Message->DispatchingListEntry.Flink = NULL;
+               break;
+            }
             Entry = Entry->Flink;
-          }
+         }
 
-       DPRINT("MsqSendMessage (blocked) timed out\n");
+         DPRINT("MsqSendMessage (blocked) timed out\n");
       }
-    while (co_MsqDispatchOneSentMessage(ThreadQueue));
-  }
-  else
-  {
-    PVOID WaitObjects[2];
-
-    WaitObjects[0] = &CompletionEvent;
-    WaitObjects[1] = ThreadQueue->NewMessages;
-    do
+      while (co_MsqDispatchOneSentMessage(ThreadQueue))
+         ;
+   }
+   else
+   {
+      PVOID WaitObjects[2];
+
+      WaitObjects[0] = &CompletionEvent;
+      WaitObjects[1] = ThreadQueue->NewMessages;
+      do
       {
-        
-        UserLeaveCo();
-        
-        WaitStatus = KeWaitForMultipleObjects(2, WaitObjects, WaitAny, UserRequest,
-                                              UserMode, FALSE, (uTimeout ? &Timeout : NULL), NULL);
-                                              
-        UserEnterCo();
-        
-        if(WaitStatus == STATUS_TIMEOUT)
-          {
+
+         UserLeaveCo();
+
+         WaitStatus = KeWaitForMultipleObjects(2, WaitObjects, WaitAny, UserRequest,
+                                               UserMode, FALSE, (uTimeout ? &Timeout : NULL), NULL);
+
+         UserEnterCo();
+
+         if(WaitStatus == STATUS_TIMEOUT)
+         {
             /* look up if the message has not yet been dispatched, if so
                make sure it can't pass a result and it must not set the completion event anymore */
             Entry = MessageQueue->SentMessagesListHead.Flink;
             while (Entry != &MessageQueue->SentMessagesListHead)
-              {
-                if ((PUSER_SENT_MESSAGE) CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, ListEntry)
-                    == Message)
-                  {
-                    /* we can access Message here, it's secure because the message queue is locked
-                       and the message is still hasn't been dispatched */
-                   Message->CompletionEvent = NULL;
-                    Message->Result = NULL;
-                    break;
-                  }
-                Entry = Entry->Flink;
-              }
+            {
+               if ((PUSER_SENT_MESSAGE) CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, ListEntry)
+                     == Message)
+               {
+                  /* we can access Message here, it's secure because the message queue is locked
+                     and the message is still hasn't been dispatched */
+                  Message->CompletionEvent = NULL;
+                  Message->Result = NULL;
+                  break;
+               }
+               Entry = Entry->Flink;
+            }
 
-           /* remove from the local dispatching list so the other thread knows,
-              it can't pass a result and it must not set the completion event anymore */
+            /* remove from the local dispatching list so the other thread knows,
+               it can't pass a result and it must not set the completion event anymore */
             Entry = ThreadQueue->DispatchingMessagesHead.Flink;
             while (Entry != &ThreadQueue->DispatchingMessagesHead)
-              {
-                if ((PUSER_SENT_MESSAGE) CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, DispatchingListEntry)
-                    == Message)
-                  {
-                    /* we can access Message here, it's secure because the sender's message is locked
-                       and the message has definitely not yet been destroyed, otherwise it would
-                       have been removed from this list by the dispatching routine right after
-                      dispatching the message */
-                   Message->CompletionEvent = NULL;
-                    Message->Result = NULL;
-                    RemoveEntryList(&Message->DispatchingListEntry);
-                    Message->DispatchingListEntry.Flink = NULL;
-                    break;
-                  }
-                Entry = Entry->Flink;
-              }
+            {
+               if ((PUSER_SENT_MESSAGE) CONTAINING_RECORD(Entry, USER_SENT_MESSAGE, DispatchingListEntry)
+                     == Message)
+               {
+                  /* we can access Message here, it's secure because the sender's message is locked
+                     and the message has definitely not yet been destroyed, otherwise it would
+                     have been removed from this list by the dispatching routine right after
+                  dispatching the message */
+                  Message->CompletionEvent = NULL;
+                  Message->Result = NULL;
+                  RemoveEntryList(&Message->DispatchingListEntry);
+                  Message->DispatchingListEntry.Flink = NULL;
+                  break;
+               }
+               Entry = Entry->Flink;
+            }
 
-           DPRINT("MsqSendMessage timed out\n");
+            DPRINT("MsqSendMessage timed out\n");
             break;
-          }
-        while (co_MsqDispatchOneSentMessage(ThreadQueue));
+         }
+         while (co_MsqDispatchOneSentMessage(ThreadQueue))
+            ;
       }
-    while (NT_SUCCESS(WaitStatus) && STATUS_WAIT_0 != WaitStatus);
-  }
+      while (NT_SUCCESS(WaitStatus) && STATUS_WAIT_0 != WaitStatus);
+   }
 
-  if(WaitStatus != STATUS_TIMEOUT)
-    *uResult = (STATUS_WAIT_0 == WaitStatus ? Result : -1);
+   if(WaitStatus != STATUS_TIMEOUT)
+      *uResult = (STATUS_WAIT_0 == WaitStatus ? Result : -1);
 
-  return WaitStatus;
+   return WaitStatus;
 }
 
 VOID FASTCALL
 MsqPostMessage(PUSER_MESSAGE_QUEUE MessageQueue, MSG* Msg, BOOLEAN FreeLParam,
                DWORD MessageBits)
 {
-  PUSER_MESSAGE Message;
-
-  if(!(Message = MsqCreateMessage(Msg, FreeLParam)))
-  {
-    return;
-  }
-  InsertTailList(&MessageQueue->PostedMessagesListHead,
-                &Message->ListEntry);
-  MessageQueue->QueueBits |= MessageBits;
-  MessageQueue->ChangedBits |= MessageBits;
-  if (MessageQueue->WakeMask & MessageBits)
-    KeSetEvent(MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
+   PUSER_MESSAGE Message;
+
+   if(!(Message = MsqCreateMessage(Msg, FreeLParam)))
+   {
+      return;
+   }
+   InsertTailList(&MessageQueue->PostedMessagesListHead,
+                  &Message->ListEntry);
+   MessageQueue->QueueBits |= MessageBits;
+   MessageQueue->ChangedBits |= MessageBits;
+   if (MessageQueue->WakeMask & MessageBits)
+      KeSetEvent(MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
 }
 
 VOID FASTCALL
 MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue, ULONG ExitCode)
 {
-  MessageQueue->QuitPosted = TRUE;
-  MessageQueue->QuitExitCode = ExitCode;
-  MessageQueue->QueueBits |= QS_POSTMESSAGE;
-  MessageQueue->ChangedBits |= QS_POSTMESSAGE;
-  if (MessageQueue->WakeMask & QS_POSTMESSAGE)
-    KeSetEvent(MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
+   MessageQueue->QuitPosted = TRUE;
+   MessageQueue->QuitExitCode = ExitCode;
+   MessageQueue->QueueBits |= QS_POSTMESSAGE;
+   MessageQueue->ChangedBits |= QS_POSTMESSAGE;
+   if (MessageQueue->WakeMask & QS_POSTMESSAGE)
+      KeSetEvent(MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
 }
 
 BOOLEAN STDCALL
 co_MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue,
-              IN BOOLEAN Hardware,
-              IN BOOLEAN Remove,
-              IN HWND Wnd,
-              IN UINT MsgFilterLow,
-              IN UINT MsgFilterHigh,
-              OUT PUSER_MESSAGE* Message)
+                  IN BOOLEAN Hardware,
+                  IN BOOLEAN Remove,
+                  IN HWND Wnd,
+                  IN UINT MsgFilterLow,
+                  IN UINT MsgFilterHigh,
+                  OUT PUSER_MESSAGE* Message)
 {
-  PLIST_ENTRY CurrentEntry;
-  PUSER_MESSAGE CurrentMessage;
-  PLIST_ENTRY ListHead;
+   PLIST_ENTRY CurrentEntry;
+   PUSER_MESSAGE CurrentMessage;
+   PLIST_ENTRY ListHead;
 
-  if (Hardware)
-    {
+   if (Hardware)
+   {
       return(co_MsqPeekHardwareMessage(MessageQueue, Wnd,
-                                   MsgFilterLow, MsgFilterHigh,
-                                   Remove, Message));
-    }
-
-  CurrentEntry = MessageQueue->PostedMessagesListHead.Flink;
-  ListHead = &MessageQueue->PostedMessagesListHead;
-  while (CurrentEntry != ListHead)
-    {
+                                       MsgFilterLow, MsgFilterHigh,
+                                       Remove, Message));
+   }
+
+   CurrentEntry = MessageQueue->PostedMessagesListHead.Flink;
+   ListHead = &MessageQueue->PostedMessagesListHead;
+   while (CurrentEntry != ListHead)
+   {
       CurrentMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE,
-                                        ListEntry);
+                                         ListEntry);
       if ((Wnd == 0 || Wnd == CurrentMessage->Msg.hwnd) &&
-         ((MsgFilterLow == 0 && MsgFilterHigh == 0) ||
-          (MsgFilterLow <= CurrentMessage->Msg.message &&
-           MsgFilterHigh >= CurrentMessage->Msg.message)))
-       {
-         if (Remove)
-           {
-             RemoveEntryList(&CurrentMessage->ListEntry);
-           }
-
-         *Message = CurrentMessage;
-         return(TRUE);
-       }
+            ((MsgFilterLow == 0 && MsgFilterHigh == 0) ||
+             (MsgFilterLow <= CurrentMessage->Msg.message &&
+              MsgFilterHigh >= CurrentMessage->Msg.message)))
+      {
+         if (Remove)
+         {
+            RemoveEntryList(&CurrentMessage->ListEntry);
+         }
+
+         *Message = CurrentMessage;
+         return(TRUE);
+      }
       CurrentEntry = CurrentEntry->Flink;
-    }
+   }
 
-  return(FALSE);
+   return(FALSE);
 }
 
 NTSTATUS FASTCALL
 co_MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue, HWND WndFilter,
-                      UINT MsgFilterMin, UINT MsgFilterMax)
+                         UINT MsgFilterMin, UINT MsgFilterMax)
 {
-  PVOID WaitObjects[2] = {MessageQueue->NewMessages, &HardwareMessageEvent};
-  LARGE_INTEGER TimerExpiry;
-  PLARGE_INTEGER Timeout;
-  NTSTATUS ret;
+   PVOID WaitObjects[2] = {MessageQueue->NewMessages, &HardwareMessageEvent};
+   LARGE_INTEGER TimerExpiry;
+   PLARGE_INTEGER Timeout;
+   NTSTATUS ret;
 
-  if (MsqGetFirstTimerExpiry(MessageQueue, WndFilter, MsgFilterMin, MsgFilterMax, &TimerExpiry))
-    {
+   if (MsqGetFirstTimerExpiry(MessageQueue, WndFilter, MsgFilterMin, MsgFilterMax, &TimerExpiry))
+   {
       Timeout = &TimerExpiry;
-    }
-  else
-    {
+   }
+   else
+   {
       Timeout = NULL;
-    }
-
-   UserLeaveCo(); 
-
-  ret = KeWaitForMultipleObjects(2,
-                                 WaitObjects,
-                                 WaitAny,
-                                 Executive,
-                                 UserMode,
-                                 FALSE,
-                                 Timeout,
-                                 NULL);
-
-   UserEnterCo();              
-              
-   return ret;              
+   }
+
+   UserLeaveCo();
+
+   ret = KeWaitForMultipleObjects(2,
+                                  WaitObjects,
+                                  WaitAny,
+                                  Executive,
+                                  UserMode,
+                                  FALSE,
+                                  Timeout,
+                                  NULL);
+
+   UserEnterCo();
+
+   return ret;
 }
 
 BOOL FASTCALL
 MsqIsHung(PUSER_MESSAGE_QUEUE MessageQueue)
 {
-  LARGE_INTEGER LargeTickCount;
+   LARGE_INTEGER LargeTickCount;
 
-  KeQueryTickCount(&LargeTickCount);
-  return ((LargeTickCount.u.LowPart - MessageQueue->LastMsgRead) > MSQ_HUNG);
+   KeQueryTickCount(&LargeTickCount);
+   return ((LargeTickCount.u.LowPart - MessageQueue->LastMsgRead) > MSQ_HUNG);
 }
 
 BOOLEAN FASTCALL
 MsqInitializeMessageQueue(struct _ETHREAD *Thread, PUSER_MESSAGE_QUEUE MessageQueue)
 {
-  LARGE_INTEGER LargeTickCount;
-  NTSTATUS Status;
-
-  MessageQueue->Thread = Thread;
-  MessageQueue->CaretInfo = (PTHRDCARETINFO)(MessageQueue + 1);
-  InitializeListHead(&MessageQueue->PostedMessagesListHead);
-  InitializeListHead(&MessageQueue->SentMessagesListHead);
-  InitializeListHead(&MessageQueue->HardwareMessagesListHead);
-  InitializeListHead(&MessageQueue->TimerListHead);
-  InitializeListHead(&MessageQueue->DispatchingMessagesHead);
-  InitializeListHead(&MessageQueue->LocalDispatchingMessagesHead);
-  KeInitializeMutex(&MessageQueue->HardwareLock, 0);
-  MessageQueue->QuitPosted = FALSE;
-  MessageQueue->QuitExitCode = 0;
-  KeQueryTickCount(&LargeTickCount);
-  MessageQueue->LastMsgRead = LargeTickCount.u.LowPart;
-  MessageQueue->FocusWindow = NULL;
-  MessageQueue->PaintPosted = FALSE;
-  MessageQueue->PaintCount = 0;
-  MessageQueue->WakeMask = ~0;
-  MessageQueue->NewMessagesHandle = NULL;
-
-  Status = ZwCreateEvent(&MessageQueue->NewMessagesHandle, EVENT_ALL_ACCESS,
-                         NULL, SynchronizationEvent, FALSE);
-  if (!NT_SUCCESS(Status))
-    {
+   LARGE_INTEGER LargeTickCount;
+   NTSTATUS Status;
+
+   MessageQueue->Thread = Thread;
+   MessageQueue->CaretInfo = (PTHRDCARETINFO)(MessageQueue + 1);
+   InitializeListHead(&MessageQueue->PostedMessagesListHead);
+   InitializeListHead(&MessageQueue->SentMessagesListHead);
+   InitializeListHead(&MessageQueue->HardwareMessagesListHead);
+   InitializeListHead(&MessageQueue->TimerListHead);
+   InitializeListHead(&MessageQueue->DispatchingMessagesHead);
+   InitializeListHead(&MessageQueue->LocalDispatchingMessagesHead);
+   KeInitializeMutex(&MessageQueue->HardwareLock, 0);
+   MessageQueue->QuitPosted = FALSE;
+   MessageQueue->QuitExitCode = 0;
+   KeQueryTickCount(&LargeTickCount);
+   MessageQueue->LastMsgRead = LargeTickCount.u.LowPart;
+   MessageQueue->FocusWindow = NULL;
+   MessageQueue->PaintPosted = FALSE;
+   MessageQueue->PaintCount = 0;
+   MessageQueue->WakeMask = ~0;
+   MessageQueue->NewMessagesHandle = NULL;
+
+   Status = ZwCreateEvent(&MessageQueue->NewMessagesHandle, EVENT_ALL_ACCESS,
+                          NULL, SynchronizationEvent, FALSE);
+   if (!NT_SUCCESS(Status))
+   {
       return FALSE;
-    }
+   }
 
-  Status = ObReferenceObjectByHandle(MessageQueue->NewMessagesHandle, 0,
-                                     ExEventObjectType, KernelMode,
-                                     (PVOID*)&MessageQueue->NewMessages, NULL);
-  if (!NT_SUCCESS(Status))
-    {
+   Status = ObReferenceObjectByHandle(MessageQueue->NewMessagesHandle, 0,
+                                      ExEventObjectType, KernelMode,
+                                      (PVOID*)&MessageQueue->NewMessages, NULL);
+   if (!NT_SUCCESS(Status))
+   {
       ZwClose(MessageQueue->NewMessagesHandle);
       MessageQueue->NewMessagesHandle = NULL;
       return FALSE;
-    }
+   }
 
-  return TRUE;
+   return TRUE;
 }
 
 VOID FASTCALL
 MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue)
 {
-  PLIST_ENTRY CurrentEntry;
-  PUSER_MESSAGE CurrentMessage;
-  PTIMER_ENTRY CurrentTimer;
-  PUSER_SENT_MESSAGE CurrentSentMessage;
-
-  /* cleanup posted messages */
-  while (!IsListEmpty(&MessageQueue->PostedMessagesListHead))
-    {
+   PLIST_ENTRY CurrentEntry;
+   PUSER_MESSAGE CurrentMessage;
+   PTIMER_ENTRY CurrentTimer;
+   PUSER_SENT_MESSAGE CurrentSentMessage;
+
+   /* cleanup posted messages */
+   while (!IsListEmpty(&MessageQueue->PostedMessagesListHead))
+   {
       CurrentEntry = RemoveHeadList(&MessageQueue->PostedMessagesListHead);
       CurrentMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE,
-                                        ListEntry);
+                                         ListEntry);
       MsqDestroyMessage(CurrentMessage);
-    }
+   }
 
-  /* remove the messages that have not yet been dispatched */
-  while (!IsListEmpty(&MessageQueue->SentMessagesListHead))
-    {
+   /* remove the messages that have not yet been dispatched */
+   while (!IsListEmpty(&MessageQueue->SentMessagesListHead))
+   {
       CurrentEntry = RemoveHeadList(&MessageQueue->SentMessagesListHead);
       CurrentSentMessage = CONTAINING_RECORD(CurrentEntry, USER_SENT_MESSAGE,
                                              ListEntry);
@@ -1359,13 +1367,13 @@ MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue)
       /* remove the message from the dispatching list */
       if(CurrentSentMessage->DispatchingListEntry.Flink != NULL)
       {
-        RemoveEntryList(&CurrentSentMessage->DispatchingListEntry);
+         RemoveEntryList(&CurrentSentMessage->DispatchingListEntry);
       }
 
       /* wake the sender's thread */
       if (CurrentSentMessage->CompletionEvent != NULL)
       {
-        KeSetEvent(CurrentSentMessage->CompletionEvent, IO_NO_INCREMENT, FALSE);
+         KeSetEvent(CurrentSentMessage->CompletionEvent, IO_NO_INCREMENT, FALSE);
       }
 
       /* dereference our and the sender's message queue */
@@ -1374,20 +1382,20 @@ MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue)
 
       /* free the message */
       ExFreePool(CurrentSentMessage);
-    }
+   }
 
-  /* cleanup timers */
-  while (! IsListEmpty(&MessageQueue->TimerListHead))
-    {
+   /* cleanup timers */
+   while (! IsListEmpty(&MessageQueue->TimerListHead))
+   {
       CurrentEntry = RemoveHeadList(&MessageQueue->TimerListHead);
       CurrentTimer = CONTAINING_RECORD(CurrentEntry, TIMER_ENTRY, ListEntry);
       ExFreeToPagedLookasideList(&TimerLookasideList, CurrentTimer);
-    }
+   }
 
-  /* notify senders of dispatching messages. This needs to be cleaned up if e.g.
-     ExitThread() was called in a SendMessage() umode callback */
-  while (!IsListEmpty(&MessageQueue->LocalDispatchingMessagesHead))
-    {
+   /* notify senders of dispatching messages. This needs to be cleaned up if e.g.
+      ExitThread() was called in a SendMessage() umode callback */
+   while (!IsListEmpty(&MessageQueue->LocalDispatchingMessagesHead))
+   {
       CurrentEntry = RemoveHeadList(&MessageQueue->LocalDispatchingMessagesHead);
       CurrentSentMessage = CONTAINING_RECORD(CurrentEntry, USER_SENT_MESSAGE,
                                              ListEntry);
@@ -1395,7 +1403,7 @@ MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue)
       /* remove the message from the dispatching list */
       if(CurrentSentMessage->DispatchingListEntry.Flink != NULL)
       {
-        RemoveEntryList(&CurrentSentMessage->DispatchingListEntry);
+         RemoveEntryList(&CurrentSentMessage->DispatchingListEntry);
       }
 
       DPRINT("Notify the sender, the thread has been terminated while dispatching a message!\n");
@@ -1403,20 +1411,20 @@ MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue)
       /* wake the sender's thread */
       if (CurrentSentMessage->CompletionEvent != NULL)
       {
-        KeSetEvent(CurrentSentMessage->CompletionEvent, IO_NO_INCREMENT, FALSE);
+         KeSetEvent(CurrentSentMessage->CompletionEvent, IO_NO_INCREMENT, FALSE);
       }
-      
+
       /* dereference our and the sender's message queue */
       IntDereferenceMessageQueue(MessageQueue);
       IntDereferenceMessageQueue(CurrentSentMessage->SenderQueue);
 
       /* free the message */
       ExFreePool(CurrentSentMessage);
-    }
+   }
 
-  /* tell other threads not to bother returning any info to us */
-  while (! IsListEmpty(&MessageQueue->DispatchingMessagesHead))
-    {
+   /* tell other threads not to bother returning any info to us */
+   while (! IsListEmpty(&MessageQueue->DispatchingMessagesHead))
+   {
       CurrentEntry = RemoveHeadList(&MessageQueue->DispatchingMessagesHead);
       CurrentSentMessage = CONTAINING_RECORD(CurrentEntry, USER_SENT_MESSAGE,
                                              DispatchingListEntry);
@@ -1425,161 +1433,161 @@ MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue)
 
       /* do NOT dereference our message queue as it might get attempted to be
          locked later */
-    }
+   }
 
 }
 
 PUSER_MESSAGE_QUEUE FASTCALL
 MsqCreateMessageQueue(struct _ETHREAD *Thread)
 {
-  PUSER_MESSAGE_QUEUE MessageQueue;
+   PUSER_MESSAGE_QUEUE MessageQueue;
 
-  MessageQueue = (PUSER_MESSAGE_QUEUE)ExAllocatePoolWithTag(PagedPool,
-                                  sizeof(USER_MESSAGE_QUEUE) + sizeof(THRDCARETINFO),
-                                  TAG_MSGQ);
+   MessageQueue = (PUSER_MESSAGE_QUEUE)ExAllocatePoolWithTag(PagedPool,
+                  sizeof(USER_MESSAGE_QUEUE) + sizeof(THRDCARETINFO),
+                  TAG_MSGQ);
 
-  if (!MessageQueue)
-    {
+   if (!MessageQueue)
+   {
       return NULL;
-    }
-
-  RtlZeroMemory(MessageQueue, sizeof(USER_MESSAGE_QUEUE) + sizeof(THRDCARETINFO));
-  /* hold at least one reference until it'll be destroyed */
-  IntReferenceMessageQueue(MessageQueue);
-  /* initialize the queue */
-  if (!MsqInitializeMessageQueue(Thread, MessageQueue))
-    {
+   }
+
+   RtlZeroMemory(MessageQueue, sizeof(USER_MESSAGE_QUEUE) + sizeof(THRDCARETINFO));
+   /* hold at least one reference until it'll be destroyed */
+   IntReferenceMessageQueue(MessageQueue);
+   /* initialize the queue */
+   if (!MsqInitializeMessageQueue(Thread, MessageQueue))
+   {
       IntDereferenceMessageQueue(MessageQueue);
       return NULL;
-    }
+   }
 
-  return MessageQueue;
+   return MessageQueue;
 }
 
 VOID FASTCALL
 MsqDestroyMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue)
 {
-  PDESKTOP_OBJECT desk;
+   PDESKTOP_OBJECT desk;
 
-  /* remove the message queue from any desktops */
-  if ((desk = (PDESKTOP_OBJECT)InterlockedExchange((LONG*)&MessageQueue->Desktop, 0)))
-    {
+   /* remove the message queue from any desktops */
+   if ((desk = (PDESKTOP_OBJECT)InterlockedExchange((LONG*)&MessageQueue->Desktop, 0)))
+   {
       InterlockedExchange((LONG*)&desk->ActiveMessageQueue, 0);
       IntDereferenceMessageQueue(MessageQueue);
-    }
+   }
 
-  /* if this is the primitive message queue, deregister it */
-  if (MessageQueue == W32kGetPrimitiveMessageQueue())
-    W32kUnregisterPrimitiveMessageQueue();
+   /* if this is the primitive message queue, deregister it */
+   if (MessageQueue == W32kGetPrimitiveMessageQueue())
+      W32kUnregisterPrimitiveMessageQueue();
 
-  /* clean it up */
-  MsqCleanupMessageQueue(MessageQueue);
+   /* clean it up */
+   MsqCleanupMessageQueue(MessageQueue);
 
-  /* decrease the reference counter, if it hits zero, the queue will be freed */
-  IntDereferenceMessageQueue(MessageQueue);
+   /* decrease the reference counter, if it hits zero, the queue will be freed */
+   IntDereferenceMessageQueue(MessageQueue);
 }
 
 PHOOKTABLE FASTCALL
 MsqGetHooks(PUSER_MESSAGE_QUEUE Queue)
 {
-  return Queue->Hooks;
+   return Queue->Hooks;
 }
 
 VOID FASTCALL
 MsqSetHooks(PUSER_MESSAGE_QUEUE Queue, PHOOKTABLE Hooks)
 {
-  Queue->Hooks = Hooks;
+   Queue->Hooks = Hooks;
 }
 
 LPARAM FASTCALL
 MsqSetMessageExtraInfo(LPARAM lParam)
 {
-  LPARAM Ret;
-  PUSER_MESSAGE_QUEUE MessageQueue;
+   LPARAM Ret;
+   PUSER_MESSAGE_QUEUE MessageQueue;
 
-  MessageQueue = PsGetWin32Thread()->MessageQueue;
-  if(!MessageQueue)
-  {
-    return 0;
-  }
+   MessageQueue = PsGetWin32Thread()->MessageQueue;
+   if(!MessageQueue)
+   {
+      return 0;
+   }
 
-  Ret = MessageQueue->ExtraInfo;
-  MessageQueue->ExtraInfo = lParam;
+   Ret = MessageQueue->ExtraInfo;
+   MessageQueue->ExtraInfo = lParam;
 
-  return Ret;
+   return Ret;
 }
 
 LPARAM FASTCALL
 MsqGetMessageExtraInfo(VOID)
 {
-  PUSER_MESSAGE_QUEUE MessageQueue;
+   PUSER_MESSAGE_QUEUE MessageQueue;
 
-  MessageQueue = PsGetWin32Thread()->MessageQueue;
-  if(!MessageQueue)
-  {
-    return 0;
-  }
+   MessageQueue = PsGetWin32Thread()->MessageQueue;
+   if(!MessageQueue)
+   {
+      return 0;
+   }
 
-  return MessageQueue->ExtraInfo;
+   return MessageQueue->ExtraInfo;
 }
 
 HWND FASTCALL
 MsqSetStateWindow(PUSER_MESSAGE_QUEUE MessageQueue, ULONG Type, HWND hWnd)
 {
-  HWND Prev;
-
-  switch(Type)
-  {
-    case MSQ_STATE_CAPTURE:
-      Prev = MessageQueue->CaptureWindow;
-      MessageQueue->CaptureWindow = hWnd;
-      return Prev;
-    case MSQ_STATE_ACTIVE:
-      Prev = MessageQueue->ActiveWindow;
-      MessageQueue->ActiveWindow = hWnd;
-      return Prev;
-    case MSQ_STATE_FOCUS:
-      Prev = MessageQueue->FocusWindow;
-      MessageQueue->FocusWindow = hWnd;
-      return Prev;
-    case MSQ_STATE_MENUOWNER:
-      Prev = MessageQueue->MenuOwner;
-      MessageQueue->MenuOwner = hWnd;
-      return Prev;
-    case MSQ_STATE_MOVESIZE:
-      Prev = MessageQueue->MoveSize;
-      MessageQueue->MoveSize = hWnd;
-      return Prev;
-    case MSQ_STATE_CARET:
-      ASSERT(MessageQueue->CaretInfo);
-      Prev = MessageQueue->CaretInfo->hWnd;
-      MessageQueue->CaretInfo->hWnd = hWnd;
-      return Prev;
-  }
-
-  return NULL;
+   HWND Prev;
+
+   switch(Type)
+   {
+      case MSQ_STATE_CAPTURE:
+         Prev = MessageQueue->CaptureWindow;
+         MessageQueue->CaptureWindow = hWnd;
+         return Prev;
+      case MSQ_STATE_ACTIVE:
+         Prev = MessageQueue->ActiveWindow;
+         MessageQueue->ActiveWindow = hWnd;
+         return Prev;
+      case MSQ_STATE_FOCUS:
+         Prev = MessageQueue->FocusWindow;
+         MessageQueue->FocusWindow = hWnd;
+         return Prev;
+      case MSQ_STATE_MENUOWNER:
+         Prev = MessageQueue->MenuOwner;
+         MessageQueue->MenuOwner = hWnd;
+         return Prev;
+      case MSQ_STATE_MOVESIZE:
+         Prev = MessageQueue->MoveSize;
+         MessageQueue->MoveSize = hWnd;
+         return Prev;
+      case MSQ_STATE_CARET:
+         ASSERT(MessageQueue->CaretInfo);
+         Prev = MessageQueue->CaretInfo->hWnd;
+         MessageQueue->CaretInfo->hWnd = hWnd;
+         return Prev;
+   }
+
+   return NULL;
 }
 
 #ifndef NDEBUG
 static VOID FASTCALL
 DumpTimerList(PUSER_MESSAGE_QUEUE MessageQueue)
 {
-  PLIST_ENTRY Current;
-  PTIMER_ENTRY Timer;
+   PLIST_ENTRY Current;
+   PTIMER_ENTRY Timer;
 
-  Current = MessageQueue->TimerListHead.Flink;
-  if (Current == &MessageQueue->TimerListHead)
-    {
+   Current = MessageQueue->TimerListHead.Flink;
+   if (Current == &MessageQueue->TimerListHead)
+   {
       DPRINT("timer list is empty for queue %p\n", MessageQueue);
-    }
-  while (Current != &MessageQueue->TimerListHead)
-    {
+   }
+   while (Current != &MessageQueue->TimerListHead)
+   {
       Timer = CONTAINING_RECORD(Current, TIMER_ENTRY, ListEntry);
       DPRINT("queue %p timer %p expiry %I64d wnd %x id %p period %u timerproc %p msg %u\n",
              MessageQueue, Timer, Timer->ExpiryTime.QuadPart, Timer->Wnd, Timer->IDEvent,
              Timer->Period, Timer->TimerFunc, Timer->Msg);
       Current = Current->Flink;
-    }
+   }
 }
 #endif /* ! defined(NDEBUG) */
 
@@ -1587,46 +1595,46 @@ DumpTimerList(PUSER_MESSAGE_QUEUE MessageQueue)
 static VOID FASTCALL
 InsertTimer(PUSER_MESSAGE_QUEUE MessageQueue, PTIMER_ENTRY NewTimer)
 {
-  PLIST_ENTRY Current;
+   PLIST_ENTRY Current;
 
-  Current = MessageQueue->TimerListHead.Flink;
-  while (Current != &MessageQueue->TimerListHead)
-    {
+   Current = MessageQueue->TimerListHead.Flink;
+   while (Current != &MessageQueue->TimerListHead)
+   {
       if (NewTimer->ExpiryTime.QuadPart <
-          CONTAINING_RECORD(Current, TIMER_ENTRY, ListEntry)->ExpiryTime.QuadPart)
-        {
-          break;
-        }
+            CONTAINING_RECORD(Current, TIMER_ENTRY, ListEntry)->ExpiryTime.QuadPart)
+      {
+         break;
+      }
       Current = Current->Flink;
-    }
+   }
 
-  InsertTailList(Current, &NewTimer->ListEntry);
+   InsertTailList(Current, &NewTimer->ListEntry);
 }
 
 /* Must have the message queue locked while calling this */
 static PTIMER_ENTRY FASTCALL
 RemoveTimer(PUSER_MESSAGE_QUEUE MessageQueue, HWND Wnd, UINT_PTR IDEvent, UINT Msg)
 {
-  PTIMER_ENTRY Timer;
-  PLIST_ENTRY EnumEntry;
+   PTIMER_ENTRY Timer;
+   PLIST_ENTRY EnumEntry;
 
-  /* Remove timer if already in the queue */
-  EnumEntry = MessageQueue->TimerListHead.Flink;
-  while (EnumEntry != &MessageQueue->TimerListHead)
-    {
+   /* Remove timer if already in the queue */
+   EnumEntry = MessageQueue->TimerListHead.Flink;
+   while (EnumEntry != &MessageQueue->TimerListHead)
+   {
       Timer = CONTAINING_RECORD(EnumEntry, TIMER_ENTRY, ListEntry);
       EnumEntry = EnumEntry->Flink;
 
       if (Timer->Wnd == Wnd &&
-          Timer->IDEvent == IDEvent &&
-          Timer->Msg == Msg)
-        {
-          RemoveEntryList(&Timer->ListEntry);
-          return Timer;
-        }
-    }
-
-  return NULL;
+            Timer->IDEvent == IDEvent &&
+            Timer->Msg == Msg)
+      {
+         RemoveEntryList(&Timer->ListEntry);
+         return Timer;
+      }
+   }
+
+   return NULL;
 }
 
 BOOLEAN FASTCALL
@@ -1634,73 +1642,74 @@ MsqSetTimer(PUSER_MESSAGE_QUEUE MessageQueue, HWND Wnd,
             UINT_PTR IDEvent, UINT Period, TIMERPROC TimerFunc,
             UINT Msg)
 {
-  PTIMER_ENTRY Timer;
-  LARGE_INTEGER CurrentTime;
+   PTIMER_ENTRY Timer;
+   LARGE_INTEGER CurrentTime;
 
-  DPRINT("MsqSetTimer queue %p wnd %x id %p period %u timerproc %p msg %d\n",
-         MessageQueue, Wnd, IDEvent, Period, TimerFunc, Msg);
+   DPRINT("MsqSetTimer queue %p wnd %x id %p period %u timerproc %p msg %d\n",
+          MessageQueue, Wnd, IDEvent, Period, TimerFunc, Msg);
 
-  Timer = RemoveTimer(MessageQueue, Wnd, IDEvent, Msg);
-  if (NULL == Timer)
-    {
+   Timer = RemoveTimer(MessageQueue, Wnd, IDEvent, Msg);
+   if (NULL == Timer)
+   {
       Timer = ExAllocateFromPagedLookasideList(&TimerLookasideList);
       if (NULL == Timer)
-        {
-          DPRINT1("Failed to allocate timer entry\n");
-          return FALSE;
-        }
+      {
+         DPRINT1("Failed to allocate timer entry\n");
+         return FALSE;
+      }
       DPRINT("Allocated new timer entry %p\n", Timer);
       Timer->Wnd = Wnd;
       Timer->IDEvent = IDEvent;
       Timer->Msg = Msg;
-    }
-  else
-    {
+   }
+   else
+   {
       DPRINT("Updating existing timer entry %p\n", Timer);
-    }
+   }
 
-  KeQuerySystemTime(&CurrentTime);
-  Timer->ExpiryTime.QuadPart = CurrentTime.QuadPart +
-                               (ULONGLONG) Period * (ULONGLONG) 10000;
-  Timer->Period = Period;
-  Timer->TimerFunc = TimerFunc;
-  DPRINT("Insert timer now %I64d expiry %I64d\n", CurrentTime.QuadPart,
-         Timer->ExpiryTime.QuadPart);
+   KeQuerySystemTime(&CurrentTime);
+   Timer->ExpiryTime.QuadPart = CurrentTime.QuadPart +
+                                (ULONGLONG) Period * (ULONGLONG) 10000;
+   Timer->Period = Period;
+   Timer->TimerFunc = TimerFunc;
+   DPRINT("Insert timer now %I64d expiry %I64d\n", CurrentTime.QuadPart,
+          Timer->ExpiryTime.QuadPart);
 
-  InsertTimer(MessageQueue, Timer);
+   InsertTimer(MessageQueue, Timer);
 
 #ifndef NDEBUG
-  DumpTimerList(MessageQueue);
+
+   DumpTimerList(MessageQueue);
 #endif /* ! defined(NDEBUG) */
 
-  return TRUE;
+   return TRUE;
 }
 
 BOOLEAN FASTCALL
 MsqKillTimer(PUSER_MESSAGE_QUEUE MessageQueue, HWND Wnd,
              UINT_PTR IDEvent, UINT Msg)
 {
-  PTIMER_ENTRY Timer;
+   PTIMER_ENTRY Timer;
 
-  DPRINT("MsqKillTimer queue %p wnd %x id %p msg %d\n",
-         MessageQueue, Wnd, IDEvent, Msg);
+   DPRINT("MsqKillTimer queue %p wnd %x id %p msg %d\n",
+          MessageQueue, Wnd, IDEvent, Msg);
 
-  Timer = RemoveTimer(MessageQueue, Wnd, IDEvent, Msg);
+   Timer = RemoveTimer(MessageQueue, Wnd, IDEvent, Msg);
 
-  if (NULL == Timer)
-    {
+   if (NULL == Timer)
+   {
       DPRINT("Failed to remove timer from list, not found\n");
-    }
-  else
-    {
+   }
+   else
+   {
       ExFreeToPagedLookasideList(&TimerLookasideList, Timer);
-    }
+   }
 
 #ifndef NDEBUG
-  DumpTimerList(MessageQueue);
+   DumpTimerList(MessageQueue);
 #endif /* ! defined(NDEBUG) */
 
-  return NULL != Timer;
+   return NULL != Timer;
 }
 
 BOOLEAN FASTCALL
@@ -1708,62 +1717,62 @@ MsqGetTimerMessage(PUSER_MESSAGE_QUEUE MessageQueue,
                    HWND WndFilter, UINT MsgFilterMin, UINT MsgFilterMax,
                    MSG *Msg, BOOLEAN Restart)
 {
-  PTIMER_ENTRY Timer;
-  LARGE_INTEGER CurrentTime;
-  PLIST_ENTRY EnumEntry;
-  BOOLEAN GotMessage;
-
-  DPRINT("MsqGetTimerMessage queue %p msg %p restart %s\n",
-         MessageQueue, Msg, Restart ? "TRUE" : "FALSE");
-
-  KeQuerySystemTime(&CurrentTime);
-  DPRINT("Current time %I64d\n", CurrentTime.QuadPart);
-  EnumEntry = MessageQueue->TimerListHead.Flink;
-  GotMessage = FALSE;
-  while (EnumEntry != &MessageQueue->TimerListHead)
-    {
+   PTIMER_ENTRY Timer;
+   LARGE_INTEGER CurrentTime;
+   PLIST_ENTRY EnumEntry;
+   BOOLEAN GotMessage;
+
+   DPRINT("MsqGetTimerMessage queue %p msg %p restart %s\n",
+          MessageQueue, Msg, Restart ? "TRUE" : "FALSE");
+
+   KeQuerySystemTime(&CurrentTime);
+   DPRINT("Current time %I64d\n", CurrentTime.QuadPart);
+   EnumEntry = MessageQueue->TimerListHead.Flink;
+   GotMessage = FALSE;
+   while (EnumEntry != &MessageQueue->TimerListHead)
+   {
       Timer = CONTAINING_RECORD(MessageQueue->TimerListHead.Flink,
                                 TIMER_ENTRY, ListEntry);
       DPRINT("Checking timer %p wnd %x expiry %I64d\n", Timer, Timer->Wnd,
              Timer->ExpiryTime.QuadPart);
       EnumEntry = EnumEntry->Flink;
       if ((NULL == WndFilter || Timer->Wnd == WndFilter) &&
-         ((MsgFilterMin == 0 && MsgFilterMax == 0) ||
-          (MsgFilterMin <= Timer->Msg &&
-           Timer->Msg <= MsgFilterMax)))
-        {
-          if (Timer->ExpiryTime.QuadPart <= CurrentTime.QuadPart)
-            {
-              DPRINT("Timer is expired\n");
-              GotMessage = TRUE;
-              break;
-            }
-          else
-            {
-              DPRINT("No need to check later timers\n");
-              break;
-            }
-        }
+            ((MsgFilterMin == 0 && MsgFilterMax == 0) ||
+             (MsgFilterMin <= Timer->Msg &&
+              Timer->Msg <= MsgFilterMax)))
+      {
+         if (Timer->ExpiryTime.QuadPart <= CurrentTime.QuadPart)
+         {
+            DPRINT("Timer is expired\n");
+            GotMessage = TRUE;
+            break;
+         }
+         else
+         {
+            DPRINT("No need to check later timers\n");
+            break;
+         }
+      }
       else
-        {
-          DPRINT("timer %p (wnd %x msg %d) failed filter wnd %x msgmin %d msgmax %d\n",
-                 Timer, Timer->Wnd, Timer->Msg, WndFilter, MsgFilterMin, MsgFilterMax);
-        }
-    }
-
-  if (! GotMessage)
-    {
+      {
+         DPRINT("timer %p (wnd %x msg %d) failed filter wnd %x msgmin %d msgmax %d\n",
+                Timer, Timer->Wnd, Timer->Msg, WndFilter, MsgFilterMin, MsgFilterMax);
+      }
+   }
+
+   if (! GotMessage)
+   {
       DPRINT("No timer pending\n");
       return FALSE;
-    }
+   }
 
-  Msg->hwnd = Timer->Wnd;
-  Msg->message = Timer->Msg;
-  Msg->wParam = (WPARAM) Timer->IDEvent;
-  Msg->lParam = (LPARAM) Timer->TimerFunc;
+   Msg->hwnd = Timer->Wnd;
+   Msg->message = Timer->Msg;
+   Msg->wParam = (WPARAM) Timer->IDEvent;
+   Msg->lParam = (LPARAM) Timer->TimerFunc;
 
-  if (Restart)
-    {
+   if (Restart)
+   {
       RemoveEntryList(&Timer->ListEntry);
       Timer->ExpiryTime.QuadPart = CurrentTime.QuadPart +
                                    (ULONGLONG) Timer->Period * (ULONGLONG) 10000;
@@ -1771,39 +1780,41 @@ MsqGetTimerMessage(PUSER_MESSAGE_QUEUE MessageQueue,
       InsertTimer(MessageQueue, Timer);
 
 #ifndef NDEBUG
+
       DumpTimerList(MessageQueue);
 #endif /* ! defined(NDEBUG) */
-    }
 
-  DPRINT("Created message wnd %x msg %d wParam %u lParam %u\n", Msg->hwnd, Msg->message,
-         Msg->wParam, Msg->lParam);
+   }
+
+   DPRINT("Created message wnd %x msg %d wParam %u lParam %u\n", Msg->hwnd, Msg->message,
+          Msg->wParam, Msg->lParam);
 
-  return TRUE;
+   return TRUE;
 }
 
 VOID FASTCALL
 MsqRemoveTimersWindow(PUSER_MESSAGE_QUEUE MessageQueue, HWND Wnd)
 {
-  PTIMER_ENTRY Timer;
-  PLIST_ENTRY EnumEntry;
+   PTIMER_ENTRY Timer;
+   PLIST_ENTRY EnumEntry;
 
-  DPRINT("MsqRemoveTimersWindow queue %p wnd %x\n", MessageQueue, Wnd);
+   DPRINT("MsqRemoveTimersWindow queue %p wnd %x\n", MessageQueue, Wnd);
 
-  EnumEntry = MessageQueue->TimerListHead.Flink;
-  while (EnumEntry != &MessageQueue->TimerListHead)
-    {
+   EnumEntry = MessageQueue->TimerListHead.Flink;
+   while (EnumEntry != &MessageQueue->TimerListHead)
+   {
       Timer = CONTAINING_RECORD(EnumEntry, TIMER_ENTRY, ListEntry);
       EnumEntry = EnumEntry->Flink;
       if (Timer->Wnd == Wnd)
-        {
-          DPRINT("Removing timer %p because its window is going away\n", Timer);
-          RemoveEntryList(&Timer->ListEntry);
-          ExFreeToPagedLookasideList(&TimerLookasideList, Timer);
-        }
-    }
+      {
+         DPRINT("Removing timer %p because its window is going away\n", Timer);
+         RemoveEntryList(&Timer->ListEntry);
+         ExFreeToPagedLookasideList(&TimerLookasideList, Timer);
+      }
+   }
 
 #ifndef NDEBUG
-  DumpTimerList(MessageQueue);
+   DumpTimerList(MessageQueue);
 #endif /* ! defined(NDEBUG) */
 
 }
@@ -1813,30 +1824,30 @@ MsqGetFirstTimerExpiry(PUSER_MESSAGE_QUEUE MessageQueue,
                        HWND WndFilter, UINT MsgFilterMin, UINT MsgFilterMax,
                        PLARGE_INTEGER FirstTimerExpiry)
 {
-  PTIMER_ENTRY Timer;
-  PLIST_ENTRY EnumEntry;
+   PTIMER_ENTRY Timer;
+   PLIST_ENTRY EnumEntry;
 
-  DPRINT("MsqGetFirstTimerExpiry queue %p wndfilter %x msgfiltermin %d msgfiltermax %d expiry %p\n",
-         MessageQueue, WndFilter, MsgFilterMin, MsgFilterMax, FirstTimerExpiry);
+   DPRINT("MsqGetFirstTimerExpiry queue %p wndfilter %x msgfiltermin %d msgfiltermax %d expiry %p\n",
+          MessageQueue, WndFilter, MsgFilterMin, MsgFilterMax, FirstTimerExpiry);
 
-  EnumEntry = MessageQueue->TimerListHead.Flink;
-  while (EnumEntry != &MessageQueue->TimerListHead)
-    {
+   EnumEntry = MessageQueue->TimerListHead.Flink;
+   while (EnumEntry != &MessageQueue->TimerListHead)
+   {
       Timer = CONTAINING_RECORD(MessageQueue->TimerListHead.Flink,
                                 TIMER_ENTRY, ListEntry);
       EnumEntry = EnumEntry->Flink;
       if ((NULL == WndFilter || Timer->Wnd == WndFilter) &&
-         ((MsgFilterMin == 0 && MsgFilterMax == 0) ||
-          (MsgFilterMin <= Timer->Msg &&
-           Timer->Msg <= MsgFilterMax)))
-        {
-          *FirstTimerExpiry = Timer->ExpiryTime;
-          DPRINT("First timer expires %I64d\n", Timer->ExpiryTime);
-          return TRUE;
-        }
-    }
-
-  return FALSE;
+            ((MsgFilterMin == 0 && MsgFilterMax == 0) ||
+             (MsgFilterMin <= Timer->Msg &&
+              Timer->Msg <= MsgFilterMax)))
+      {
+         *FirstTimerExpiry = Timer->ExpiryTime;
+         DPRINT("First timer expires %I64d\n", Timer->ExpiryTime);
+         return TRUE;
+      }
+   }
+
+   return FALSE;
 }
 
 /* EOF */
index c8ebe0d..b8a6c28 100644 (file)
@@ -46,9 +46,9 @@ DWORD _locked=0;
 NTSTATUS FASTCALL InitUserImpl(VOID)\r
 {\r
    //PVOID mem;\r
-   \r
-//   DPRINT("Enter InitUserImpl\n");\r
-//   ExInitializeResourceLite(&UserLock);\r
+\r
+   //   DPRINT("Enter InitUserImpl\n");\r
+   //   ExInitializeResourceLite(&UserLock);\r
 \r
    ExInitializeFastMutex(&UserLock);\r
 \r
@@ -57,7 +57,7 @@ NTSTATUS FASTCALL InitUserImpl(VOID)
       DPRINT1("Failed creating handle table\n");\r
       return STATUS_INSUFFICIENT_RESOURCES;\r
    }\r
-  \r
+\r
    return STATUS_SUCCESS;\r
 }\r
 \r
@@ -73,35 +73,35 @@ BOOL FASTCALL UserIsEntered()
 \r
 VOID FASTCALL CleanupUser(VOID)\r
 {\r
-//   ExDeleteResourceLite(&UserLock);\r
+   //   ExDeleteResourceLite(&UserLock);\r
 }\r
 \r
 VOID FASTCALL UUserEnterShared(VOID)\r
 {\r
-//   DPRINT("Enter IntLockUserShared\n");\r
-//   KeDumpStackFrames((PULONG)__builtin_frame_address(0));\r
-//DPRINT("%x\n",__builtin_return_address(0));\r
-//   KeEnterCriticalRegion();\r
-//   ExAcquireResourceSharedLite(&UserLock, TRUE);\r
+   //   DPRINT("Enter IntLockUserShared\n");\r
+   //   KeDumpStackFrames((PULONG)__builtin_frame_address(0));\r
+   //DPRINT("%x\n",__builtin_return_address(0));\r
+   //   KeEnterCriticalRegion();\r
+   //   ExAcquireResourceSharedLite(&UserLock, TRUE);\r
    ExAcquireFastMutex(&UserLock);\r
 }\r
 \r
 VOID FASTCALL UUserEnterExclusive(VOID)\r
 {\r
-//   DPRINT("Enter UserEnterExclusive\n");\r
-//   KeDumpStackFrames((PULONG)__builtin_frame_address(0));\r
-//DPRINT("%x\n",__builtin_return_address(0));\r
-//   KeEnterCriticalRegion();\r
-//   ExAcquireResourceExclusiveLite(&UserLock, TRUE);\r
+   //   DPRINT("Enter UserEnterExclusive\n");\r
+   //   KeDumpStackFrames((PULONG)__builtin_frame_address(0));\r
+   //DPRINT("%x\n",__builtin_return_address(0));\r
+   //   KeEnterCriticalRegion();\r
+   //   ExAcquireResourceExclusiveLite(&UserLock, TRUE);\r
    ExAcquireFastMutex(&UserLock);\r
 }\r
 \r
 VOID FASTCALL UUserLeave(VOID)\r
 {\r
-//   DPRINT("Enter UserLeave\n");\r
-//   KeDumpStackFrames((PULONG)__builtin_frame_address(0));\r
-//DPRINT("%x\n",__builtin_return_address(0));\r
-//  ExReleaseResourceLite(&UserLock);\r
-//   KeLeaveCriticalRegion();\r
+   //   DPRINT("Enter UserLeave\n");\r
+   //   KeDumpStackFrames((PULONG)__builtin_frame_address(0));\r
+   //DPRINT("%x\n",__builtin_return_address(0));\r
+   //  ExReleaseResourceLite(&UserLock);\r
+   //   KeLeaveCriticalRegion();\r
    ExReleaseFastMutex(&UserLock);\r
 }\r
index 01a5446..8687772 100644 (file)
@@ -33,167 +33,179 @@ USER_HANDLE_TABLE gHandleTable;
 
 PUSER_HANDLE_ENTRY handle_to_entry(PUSER_HANDLE_TABLE ht, HANDLE handle )
 {
-    unsigned short generation;
-    int index = (((unsigned int)handle & 0xffff) - FIRST_USER_HANDLE) >> 1;
-    if (index < 0 || index >= ht->nb_handles) return NULL;
-    if (!ht->handles[index].type) return NULL;
-    generation = (unsigned int)handle >> 16;
-    if (generation == ht->handles[index].generation || !generation || generation == 0xffff)
-        return &ht->handles[index];
-    return NULL;
+   unsigned short generation;
+   int index = (((unsigned int)handle & 0xffff) - FIRST_USER_HANDLE) >> 1;
+   if (index < 0 || index >= ht->nb_handles)
+      return NULL;
+   if (!ht->handles[index].type)
+      return NULL;
+   generation = (unsigned int)handle >> 16;
+   if (generation == ht->handles[index].generation || !generation || generation == 0xffff)
+      return &ht->handles[index];
+   return NULL;
 }
 
 inline static HANDLE entry_to_handle(PUSER_HANDLE_TABLE ht, PUSER_HANDLE_ENTRY ptr )
 {
-    int index = ptr - ht->handles;
-    return (HANDLE)(((index << 1) + FIRST_USER_HANDLE) + (ptr->generation << 16));
+   int index = ptr - ht->handles;
+   return (HANDLE)(((index << 1) + FIRST_USER_HANDLE) + (ptr->generation << 16));
 }
 
 inline static PUSER_HANDLE_ENTRY alloc_user_entry(PUSER_HANDLE_TABLE ht)
 {
-    PUSER_HANDLE_ENTRY entry;
-
-    if (ht->freelist)
-    {
-        entry = ht->freelist;
-        ht->freelist = entry->ptr;
-    
-        usedHandles++;
-        return entry;
-    }
-    
-    if (ht->nb_handles >= ht->allocated_handles)  /* need to grow the array */
-    {
-       DPRINT1("Out of user handles!\n");
-       return NULL;
+   PUSER_HANDLE_ENTRY entry;
+
+   if (ht->freelist)
+   {
+      entry = ht->freelist;
+      ht->freelist = entry->ptr;
+
+      usedHandles++;
+      return entry;
+   }
+
+   if (ht->nb_handles >= ht->allocated_handles)  /* need to grow the array */
+   {
+      DPRINT1("Out of user handles!\n");
+      return NULL;
 #if 0
-        struct user_handle *new_handles;
-        /* grow array by 50% (but at minimum 32 entries) */
-        int growth = max( 32, allocated_handles / 2 );
-        int new_size = min( allocated_handles + growth, (LAST_USER_HANDLE-FIRST_USER_HANDLE+1) >> 1 );
-        if (new_size <= allocated_handles) return NULL;
-        if (!(new_handles = realloc( handles, new_size * sizeof(*handles) )))
-            return NULL;
-        handles = new_handles;
-        allocated_handles = new_size;
-#endif        
-    }
-    
-    entry = &ht->handles[ht->nb_handles++];
-    
-    entry->generation = 1;
-    
-    usedHandles++;
-    
-    return entry;
+
+      struct user_handle *new_handles;
+      /* grow array by 50% (but at minimum 32 entries) */
+      int growth = max( 32, allocated_handles / 2 );
+      int new_size = min( allocated_handles + growth, (LAST_USER_HANDLE-FIRST_USER_HANDLE+1) >> 1 );
+      if (new_size <= allocated_handles)
+         return NULL;
+      if (!(new_handles = realloc( handles, new_size * sizeof(*handles) )))
+         return NULL;
+      handles = new_handles;
+      allocated_handles = new_size;
+#endif
+
+   }
+
+   entry = &ht->handles[ht->nb_handles++];
+
+   entry->generation = 1;
+
+   usedHandles++;
+
+   return entry;
 }
 
 VOID UserInitHandleTable(PUSER_HANDLE_TABLE ht, PVOID mem, ULONG bytes)
 {
    ht->freelist = NULL;
    ht->handles = mem;
-   
-   ht->nb_handles = 0;   
+
+   ht->nb_handles = 0;
    ht->allocated_handles = bytes / sizeof(USER_HANDLE_ENTRY);
 }
 
 inline static void *free_user_entry(PUSER_HANDLE_TABLE ht, PUSER_HANDLE_ENTRY entry)
 {
-    void *ret;
-    ret = entry->ptr;
-    entry->ptr  = ht->freelist;
-    entry->type = 0;
-    ht->freelist  = entry;
-    
-    usedHandles--;
-    
-    return ret;
+   void *ret;
+   ret = entry->ptr;
+   entry->ptr  = ht->freelist;
+   entry->type = 0;
+   ht->freelist  = entry;
+
+   usedHandles--;
+
+   return ret;
 }
 
 /* allocate a user handle for a given object */
 HANDLE UserAllocHandle(PUSER_HANDLE_TABLE ht, PVOID object, USER_OBJECT_TYPE type )
 {
-    PUSER_HANDLE_ENTRY entry = alloc_user_entry(ht);
-    if (!entry) return 0;
-    entry->ptr  = object;
-    entry->type = type;
-    if (++entry->generation >= 0xffff) entry->generation = 1;
-    return entry_to_handle(ht, entry );
+   PUSER_HANDLE_ENTRY entry = alloc_user_entry(ht);
+   if (!entry)
+      return 0;
+   entry->ptr  = object;
+   entry->type = type;
+   if (++entry->generation >= 0xffff)
+      entry->generation = 1;
+   return entry_to_handle(ht, entry );
 }
 
 /* return a pointer to a user object from its handle */
 PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, USER_OBJECT_TYPE type )
 {
-    PUSER_HANDLE_ENTRY entry;
+   PUSER_HANDLE_ENTRY entry;
 
-    ASSERT(ht);
+   ASSERT(ht);
 
-    if (!(entry = handle_to_entry(ht, handle )) || entry->type != type)
-    {
-       SetLastWin32Error(ERROR_INVALID_HANDLE);
-       return NULL;
-    }
-    return entry->ptr;
+   if (!(entry = handle_to_entry(ht, handle )) || entry->type != type)
+   {
+      SetLastWin32Error(ERROR_INVALID_HANDLE);
+      return NULL;
+   }
+   return entry->ptr;
 }
 
 
 /* get the full handle (32bit) for a possibly truncated (16bit) handle */
 HANDLE get_user_full_handle(PUSER_HANDLE_TABLE ht,  HANDLE handle )
 {
-    PUSER_HANDLE_ENTRY entry;
+   PUSER_HANDLE_ENTRY entry;
 
-    if ((unsigned int)handle >> 16) return handle;
-    if (!(entry = handle_to_entry(ht, handle ))) return handle;
-    return entry_to_handle( ht, entry );
+   if ((unsigned int)handle >> 16)
+      return handle;
+   if (!(entry = handle_to_entry(ht, handle )))
+      return handle;
+   return entry_to_handle( ht, entry );
 }
 
 
 /* same as get_user_object plus set the handle to the full 32-bit value */
 void *get_user_object_handle(PUSER_HANDLE_TABLE ht,  HANDLE* handle, USER_OBJECT_TYPE type )
 {
-    PUSER_HANDLE_ENTRY entry;
+   PUSER_HANDLE_ENTRY entry;
 
-    if (!(entry = handle_to_entry(ht, *handle )) || entry->type != type) return NULL;
-    *handle = entry_to_handle( ht, entry );
-    return entry->ptr;
+   if (!(entry = handle_to_entry(ht, *handle )) || entry->type != type)
+      return NULL;
+   *handle = entry_to_handle( ht, entry );
+   return entry->ptr;
 }
 
 /* free a user handle and return a pointer to the object */
 PVOID UserFreeHandle(PUSER_HANDLE_TABLE ht,  HANDLE handle )
 {
-    PUSER_HANDLE_ENTRY entry;
-
-    if (!(entry = handle_to_entry( ht, handle )))
-    {
-        SetLastNtError( STATUS_INVALID_HANDLE );
-        return NULL;
-    }
-    
-    return free_user_entry(ht, entry );
+   PUSER_HANDLE_ENTRY entry;
+
+   if (!(entry = handle_to_entry( ht, handle )))
+   {
+      SetLastNtError( STATUS_INVALID_HANDLE );
+      return NULL;
+   }
+
+   return free_user_entry(ht, entry );
 }
 
 /* return the next user handle after 'handle' that is of a given type */
 PVOID UserGetNextHandle(PUSER_HANDLE_TABLE ht, HANDLE* handle, USER_OBJECT_TYPE type )
 {
-    PUSER_HANDLE_ENTRY entry;
-
-    if (!*handle) entry = ht->handles;
-    else
-    {
-        int index = (((unsigned int)*handle & 0xffff) - FIRST_USER_HANDLE) >> 1;
-        if (index < 0 || index >= ht->nb_handles) return NULL;
-        entry = ht->handles + index + 1;  /* start from the next one */
-    }
-    while (entry < ht->handles + ht->nb_handles)
-    {
-        if (!type || entry->type == type)
-        {
-            *handle = entry_to_handle(ht, entry );
-            return entry->ptr;
-        }
-        entry++;
-    }
-    return NULL;
+   PUSER_HANDLE_ENTRY entry;
+
+   if (!*handle)
+      entry = ht->handles;
+   else
+   {
+      int index = (((unsigned int)*handle & 0xffff) - FIRST_USER_HANDLE) >> 1;
+      if (index < 0 || index >= ht->nb_handles)
+         return NULL;
+      entry = ht->handles + index + 1;  /* start from the next one */
+   }
+   while (entry < ht->handles + ht->nb_handles)
+   {
+      if (!type || entry->type == type)
+      {
+         *handle = entry_to_handle(ht, entry );
+         return entry->ptr;
+      }
+      entry++;
+   }
+   return NULL;
 }
 
 
@@ -201,14 +213,16 @@ PVOID UserGetNextHandle(PUSER_HANDLE_TABLE ht, HANDLE* handle, USER_OBJECT_TYPE
 PVOID FASTCALL
 ObmCreateObject(PUSER_HANDLE_TABLE ht, HANDLE* h,USER_OBJECT_TYPE type , ULONG size)
 {
-   
+
    HANDLE hi;
    PUSER_OBJECT_HEADER hdr = ExAllocatePool(PagedPool, size + sizeof(USER_OBJECT_HEADER));
-   if (!hdr) return NULL;
-   
-      
+   if (!hdr)
+      return NULL;
+
+
    hi = UserAllocHandle(ht, USER_HEADER_TO_BODY(hdr), type );
-   if (!hi){
+   if (!hi)
+   {
       ExFreePool(hdr);
       return NULL;
    }
@@ -216,33 +230,35 @@ ObmCreateObject(PUSER_HANDLE_TABLE ht, HANDLE* h,USER_OBJECT_TYPE type , ULONG s
    RtlZeroMemory(hdr, size + sizeof(USER_OBJECT_HEADER));
    hdr->hSelf = hi;
    hdr->RefCount++; //temp hack!
-   
-   if (h) *h = hi;
+
+   if (h)
+      *h = hi;
    return USER_HEADER_TO_BODY(hdr);
 }
 
-BOOL FASTCALL 
+BOOL FASTCALL
 ObmDeleteObject(HANDLE h, USER_OBJECT_TYPE type )
 {
    PUSER_OBJECT_HEADER hdr;
    PVOID body = UserGetObject(&gHandleTable, h, type);
-   if (!body) return FALSE;
-   
+   if (!body)
+      return FALSE;
+
    hdr = USER_BODY_TO_HEADER(body);
    ASSERT(hdr->RefCount >= 0);
-   
+
    hdr->destroyed = TRUE;
    if (hdr->RefCount == 0)
    {
       UserFreeHandle(&gHandleTable, h);
-      
+
       memset(hdr, 0x55, sizeof(USER_OBJECT_HEADER));
-      
+
       ExFreePool(hdr);
       return TRUE;
    }
-   
-//   DPRINT1("info: something not destroyed bcause refs still left, inuse %i\n",usedHandles);
+
+   //   DPRINT1("info: something not destroyed bcause refs still left, inuse %i\n",usedHandles);
    return FALSE;
 }
 
@@ -250,9 +266,9 @@ ObmDeleteObject(HANDLE h, USER_OBJECT_TYPE type )
 VOID FASTCALL ObmReferenceObject(PVOID obj)
 {
    PUSER_OBJECT_HEADER hdr = USER_BODY_TO_HEADER(obj);
-   
+
    ASSERT(hdr->RefCount >= 0);
-   
+
    hdr->RefCount++;
 }
 
@@ -260,24 +276,24 @@ VOID FASTCALL ObmReferenceObject(PVOID obj)
 BOOL FASTCALL ObmDereferenceObject(PVOID obj)
 {
    PUSER_OBJECT_HEADER hdr = USER_BODY_TO_HEADER(obj);
-   
+
    ASSERT(hdr->RefCount >= 1);
-   
+
    hdr->RefCount--;
-   
+
    if (hdr->RefCount == 0 && hdr->destroyed)
    {
-//      DPRINT1("info: something destroyed bcaise of deref, in use=%i\n",usedHandles);
-      
+      //      DPRINT1("info: something destroyed bcaise of deref, in use=%i\n",usedHandles);
+
       UserFreeHandle(&gHandleTable, hdr->hSelf);
-      
+
       memset(hdr, 0x55, sizeof(USER_OBJECT_HEADER));
-         
+
       ExFreePool(hdr);
-      
+
       return TRUE;
    }
-   
+
    return FALSE;
 }
 
@@ -285,7 +301,7 @@ BOOL FASTCALL ObmDereferenceObject(PVOID obj)
 
 BOOL FASTCALL ObmCreateHandleTable()
 {
-   
+
    PVOID mem;
 
    //FIXME: dont alloc all at once! must be mapped into umode also...
@@ -295,9 +311,9 @@ BOOL FASTCALL ObmCreateHandleTable()
       DPRINT1("Failed creating handle table\n");
       return FALSE;
    }
-   
+
    //FIXME: make auto growable
    UserInitHandleTable(&gHandleTable, mem, sizeof(USER_HANDLE_ENTRY) * 1024);
-   
+
    return TRUE;
 }
index 913eb73..1513ce1 100644 (file)
@@ -60,7 +60,7 @@ IntValidateParent(PWINDOW_OBJECT Child, HRGN ValidRegion)
             OffsetY = Child->WindowRect.top - ParentWindow->WindowRect.top;
             NtGdiOffsetRgn(ValidRegion, OffsetX, OffsetY);
             NtGdiCombineRgn(ParentWindow->UpdateRegion, ParentWindow->UpdateRegion,
-               ValidRegion, RGN_DIFF);
+                            ValidRegion, RGN_DIFF);
             /* FIXME: If the resulting region is empty, remove fake posted paint message */
             NtGdiOffsetRgn(ValidRegion, -OffsetX, -OffsetY);
          }
@@ -79,101 +79,101 @@ IntValidateParent(PWINDOW_OBJECT Child, HRGN ValidRegion)
 STATIC VOID FASTCALL
 co_IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags)
 {
-  HDC hDC;
-  HWND hWnd = Window->hSelf;
-  HRGN TempRegion;
+   HDC hDC;
+   HWND hWnd = Window->hSelf;
+   HRGN TempRegion;
 
-  if (Flags & (RDW_ERASENOW | RDW_UPDATENOW))
-    {
+   if (Flags & (RDW_ERASENOW | RDW_UPDATENOW))
+   {
       if (Window->Flags & WINDOWOBJECT_NEED_NCPAINT)
-        {
-          if (Window->NCUpdateRegion)
-            {
-              IntValidateParent(Window, Window->NCUpdateRegion);
-            }
-          TempRegion = Window->NCUpdateRegion;
-          if ((HANDLE) 1 != TempRegion && NULL != TempRegion)
-            {
-              GDIOBJ_SetOwnership(TempRegion, PsGetCurrentProcess());
-            }
-          Window->NCUpdateRegion = NULL;
-          Window->Flags &= ~WINDOWOBJECT_NEED_NCPAINT;
-          MsqDecPaintCountQueue(Window->MessageQueue);
-          co_IntSendMessage(hWnd, WM_NCPAINT, (WPARAM)TempRegion, 0);
-          if ((HANDLE) 1 != TempRegion && NULL != TempRegion)
-            {
-              /* NOTE: The region can already be deleted! */
-              GDIOBJ_FreeObj(TempRegion, GDI_OBJECT_TYPE_REGION | GDI_OBJECT_TYPE_SILENT);
-            }
-        }
+      {
+         if (Window->NCUpdateRegion)
+         {
+            IntValidateParent(Window, Window->NCUpdateRegion);
+         }
+         TempRegion = Window->NCUpdateRegion;
+         if ((HANDLE) 1 != TempRegion && NULL != TempRegion)
+         {
+            GDIOBJ_SetOwnership(TempRegion, PsGetCurrentProcess());
+         }
+         Window->NCUpdateRegion = NULL;
+         Window->Flags &= ~WINDOWOBJECT_NEED_NCPAINT;
+         MsqDecPaintCountQueue(Window->MessageQueue);
+         co_IntSendMessage(hWnd, WM_NCPAINT, (WPARAM)TempRegion, 0);
+         if ((HANDLE) 1 != TempRegion && NULL != TempRegion)
+         {
+            /* NOTE: The region can already be deleted! */
+            GDIOBJ_FreeObj(TempRegion, GDI_OBJECT_TYPE_REGION | GDI_OBJECT_TYPE_SILENT);
+         }
+      }
 
       if (Window->Flags & WINDOWOBJECT_NEED_ERASEBKGND)
-        {
-          if (Window->UpdateRegion)
+      {
+         if (Window->UpdateRegion)
+         {
+            /*
+             * This surely wrong! Why we would want to validate the parent?
+             * It breaks quite a few things including dummy WM_ERASEBKGND
+             * implementations that return only TRUE and have corresponding
+             * WM_PAINT that doesn't paint the whole client area.
+             * I left the code here so that no one will readd it again!
+             * - Filip
+             */
+            /* IntValidateParent(Window, Window->UpdateRegion); */
+            hDC = UserGetDCEx(Window, 0, DCX_CACHE | DCX_USESTYLE |
+                              DCX_INTERSECTUPDATE);
+            if (hDC != NULL)
             {
-              /*
-               * This surely wrong! Why we would want to validate the parent?
-               * It breaks quite a few things including dummy WM_ERASEBKGND
-               * implementations that return only TRUE and have corresponding
-               * WM_PAINT that doesn't paint the whole client area.
-               * I left the code here so that no one will readd it again!
-               * - Filip
-               */
-              /* IntValidateParent(Window, Window->UpdateRegion); */
-              hDC = UserGetDCEx(Window, 0, DCX_CACHE | DCX_USESTYLE |
-                                           DCX_INTERSECTUPDATE);
-              if (hDC != NULL)
-                {
-                  if (co_IntSendMessage(hWnd, WM_ERASEBKGND, (WPARAM)hDC, 0))
-                    {
-                      Window->Flags &= ~WINDOWOBJECT_NEED_ERASEBKGND;
-                    }
-                  UserReleaseDC(Window, hDC);
-                }
+               if (co_IntSendMessage(hWnd, WM_ERASEBKGND, (WPARAM)hDC, 0))
+               {
+                  Window->Flags &= ~WINDOWOBJECT_NEED_ERASEBKGND;
+               }
+               UserReleaseDC(Window, hDC);
             }
-        }
+         }
+      }
 
       if (Flags & RDW_UPDATENOW)
-        {
-          if (Window->UpdateRegion != NULL ||
-              Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT)
-            {
-              co_IntSendMessage(hWnd, WM_PAINT, 0, 0);
-            }
-        }
-    }
+      {
+         if (Window->UpdateRegion != NULL ||
+               Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT)
+         {
+            co_IntSendMessage(hWnd, WM_PAINT, 0, 0);
+         }
+      }
+   }
 
-  /*
-   * Check that the window is still valid at this point
-   */
+   /*
+    * Check that the window is still valid at this point
+    */
 
-  if (! IntIsWindow(hWnd))
-    {
+   if (! IntIsWindow(hWnd))
+   {
       return;
-    }
-
-  /*
-   * Paint child windows.
-   */
-  if (!(Flags & RDW_NOCHILDREN) && !(Window->Style & WS_MINIMIZE) &&
-      ((Flags & RDW_ALLCHILDREN) || !(Window->Style & WS_CLIPCHILDREN)))
-    {
+   }
+
+   /*
+    * Paint child windows.
+    */
+   if (!(Flags & RDW_NOCHILDREN) && !(Window->Style & WS_MINIMIZE) &&
+         ((Flags & RDW_ALLCHILDREN) || !(Window->Style & WS_CLIPCHILDREN)))
+   {
       HWND *List, *phWnd;
 
       if ((List = IntWinListChildren(Window)))
-        {
-          for (phWnd = List; *phWnd; ++phWnd)
+      {
+         for (phWnd = List; *phWnd; ++phWnd)
+         {
+            Window = IntGetWindowObject(*phWnd);
+            if (Window && (Window->Style & WS_VISIBLE))
             {
-              Window = IntGetWindowObject(*phWnd);
-              if (Window && (Window->Style & WS_VISIBLE))
-                {
-                  co_IntPaintWindows(Window, Flags);
-                  IntReleaseWindowObject(Window);
-                }
+               co_IntPaintWindows(Window, Flags);
+               IntReleaseWindowObject(Window);
             }
-          ExFreePool(List);
-        }
-    }
+         }
+         ExFreePool(List);
+      }
+   }
 }
 
 /*
@@ -199,8 +199,8 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
 
       hRgnWindow = UnsafeIntCreateRectRgnIndirect(&Window->WindowRect);
       NtGdiOffsetRgn(hRgnWindow,
-         -Window->WindowRect.left,
-         -Window->WindowRect.top);
+                     -Window->WindowRect.left,
+                     -Window->WindowRect.top);
       RgnType = NtGdiCombineRgn(hRgn, hRgn, hRgnWindow, RGN_AND);
       NtGdiDeleteObject(hRgnWindow);
    }
@@ -214,7 +214,7 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
     */
 
    HadPaintMessage = Window->UpdateRegion != NULL ||
-      Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT;
+                     Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT;
    HadNCPaintMessage = Window->Flags & WINDOWOBJECT_NEED_NCPAINT;
 
    /*
@@ -230,7 +230,7 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
       }
 
       if (NtGdiCombineRgn(Window->UpdateRegion, Window->UpdateRegion,
-          hRgn, RGN_OR) == NULLREGION)
+                          hRgn, RGN_OR) == NULLREGION)
       {
          GDIOBJ_SetOwnership(Window->UpdateRegion, PsGetCurrentProcess());
          NtGdiDeleteObject(Window->UpdateRegion);
@@ -250,7 +250,7 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
       if (Window->UpdateRegion != NULL)
       {
          if (NtGdiCombineRgn(Window->UpdateRegion, Window->UpdateRegion,
-             hRgn, RGN_DIFF) == NULLREGION)
+                             hRgn, RGN_DIFF) == NULLREGION)
          {
             GDIOBJ_SetOwnership(Window->UpdateRegion, PsGetCurrentProcess());
             NtGdiDeleteObject(Window->UpdateRegion);
@@ -286,12 +286,12 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
 
       hRgnWindow = UnsafeIntCreateRectRgnIndirect(&Window->ClientRect);
       NtGdiOffsetRgn(hRgnWindow,
-         -Window->WindowRect.left,
-         -Window->WindowRect.top);
+                     -Window->WindowRect.left,
+                     -Window->WindowRect.top);
 
       hRgnNonClient = NtGdiCreateRectRgn(0, 0, 0, 0);
       if (NtGdiCombineRgn(hRgnNonClient, Window->UpdateRegion,
-          hRgnWindow, RGN_DIFF) == NULLREGION)
+                          hRgnWindow, RGN_DIFF) == NULLREGION)
       {
          NtGdiDeleteObject(hRgnNonClient);
          hRgnNonClient = NULL;
@@ -305,7 +305,7 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
        * Remove the nonclient region from the standard update region.
        */
       if (NtGdiCombineRgn(Window->UpdateRegion, Window->UpdateRegion,
-          hRgnWindow, RGN_AND) == NULLREGION)
+                          hRgnWindow, RGN_AND) == NULLREGION)
       {
          GDIOBJ_SetOwnership(Window->UpdateRegion, PsGetCurrentProcess());
          NtGdiDeleteObject(Window->UpdateRegion);
@@ -320,10 +320,10 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
       {
          if(NULL != hRgnNonClient)
          {
-           NtGdiCombineRgn(Window->NCUpdateRegion, Window->NCUpdateRegion,
-               hRgnNonClient, RGN_OR);
-           GDIOBJ_SetOwnership(hRgnNonClient, PsGetCurrentProcess());
-           NtGdiDeleteObject(hRgnNonClient);
+            NtGdiCombineRgn(Window->NCUpdateRegion, Window->NCUpdateRegion,
+                            hRgnNonClient, RGN_OR);
+            GDIOBJ_SetOwnership(hRgnNonClient, PsGetCurrentProcess());
+            NtGdiDeleteObject(hRgnNonClient);
          }
       }
 
@@ -335,7 +335,7 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
     */
 
    if (!(Flags & RDW_NOCHILDREN) && !(Window->Style & WS_MINIMIZE) &&
-       ((Flags & RDW_ALLCHILDREN) || !(Window->Style & WS_CLIPCHILDREN)))
+         ((Flags & RDW_ALLCHILDREN) || !(Window->Style & WS_CLIPCHILDREN)))
    {
       HWND *List, *phWnd;
       PWINDOW_OBJECT Child;
@@ -347,7 +347,7 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
             Child = IntGetWindowObject(*phWnd);
             if(!Child)
             {
-              continue;
+               continue;
             }
             if (Child->Style & WS_VISIBLE)
             {
@@ -357,8 +357,8 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
                HRGN hRgnTemp = NtGdiCreateRectRgn(0, 0, 0, 0);
                NtGdiCombineRgn(hRgnTemp, hRgn, 0, RGN_COPY);
                NtGdiOffsetRgn(hRgnTemp,
-                  Window->WindowRect.left - Child->WindowRect.left,
-                  Window->WindowRect.top - Child->WindowRect.top);
+                              Window->WindowRect.left - Child->WindowRect.left,
+                              Window->WindowRect.top - Child->WindowRect.top);
                IntInvalidateWindows(Child, hRgnTemp, Flags);
                NtGdiDeleteObject(hRgnTemp);
             }
@@ -373,7 +373,7 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
     */
 
    HasPaintMessage = Window->UpdateRegion != NULL ||
-         Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT;
+                     Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT;
    HasNCPaintMessage = Window->Flags & WINDOWOBJECT_NEED_NCPAINT;
 
    if (HasPaintMessage != HadPaintMessage)
@@ -410,14 +410,15 @@ IntIsWindowDrawable(PWINDOW_OBJECT Window)
    do
    {
       if (!(Wnd->Style & WS_VISIBLE) ||
-          ((Wnd->Style & WS_MINIMIZE) && (Wnd != Window)))
+            ((Wnd->Style & WS_MINIMIZE) && (Wnd != Window)))
       {
          return FALSE;
       }
 
       Wnd = Wnd->Parent;
-      
-   } while(Wnd);
+
+   }
+   while(Wnd);
 
    return TRUE;
 }
@@ -431,7 +432,7 @@ IntIsWindowDrawable(PWINDOW_OBJECT Window)
 
 BOOL FASTCALL
 co_UserRedrawWindow(PWINDOW_OBJECT Window, const RECT* UpdateRect, HRGN UpdateRgn,
-   ULONG Flags)
+                    ULONG Flags)
 {
    HRGN hRgn = NULL;
 
@@ -441,8 +442,8 @@ co_UserRedrawWindow(PWINDOW_OBJECT Window, const RECT* UpdateRect, HRGN UpdateRg
     */
 
    if (!IntIsWindowDrawable(Window) ||
-       (Flags & (RDW_VALIDATE | RDW_INVALIDATE)) ==
-       (RDW_VALIDATE | RDW_INVALIDATE))
+         (Flags & (RDW_VALIDATE | RDW_INVALIDATE)) ==
+         (RDW_VALIDATE | RDW_INVALIDATE))
    {
       return FALSE;
    }
@@ -460,31 +461,33 @@ co_UserRedrawWindow(PWINDOW_OBJECT Window, const RECT* UpdateRect, HRGN UpdateRg
          hRgn = NtGdiCreateRectRgn(0, 0, 0, 0);
          NtGdiCombineRgn(hRgn, UpdateRgn, NULL, RGN_COPY);
          NtGdiOffsetRgn(hRgn,
-            Window->ClientRect.left - Window->WindowRect.left,
-            Window->ClientRect.top - Window->WindowRect.top);
-      } else
-      if (UpdateRect != NULL)
-      {
-         hRgn = UnsafeIntCreateRectRgnIndirect((RECT *)UpdateRect);
-         NtGdiOffsetRgn(hRgn,
-            Window->ClientRect.left - Window->WindowRect.left,
-            Window->ClientRect.top - Window->WindowRect.top);
-      } else
-      if ((Flags & (RDW_INVALIDATE | RDW_FRAME)) == (RDW_INVALIDATE | RDW_FRAME) ||
-          (Flags & (RDW_VALIDATE | RDW_NOFRAME)) == (RDW_VALIDATE | RDW_NOFRAME))
-      {
-         hRgn = UnsafeIntCreateRectRgnIndirect(&Window->WindowRect);
-         NtGdiOffsetRgn(hRgn,
-            -Window->WindowRect.left,
-            -Window->WindowRect.top);
+                        Window->ClientRect.left - Window->WindowRect.left,
+                        Window->ClientRect.top - Window->WindowRect.top);
       }
       else
-      {
-         hRgn = UnsafeIntCreateRectRgnIndirect(&Window->ClientRect);
-         NtGdiOffsetRgn(hRgn,
-            -Window->WindowRect.left,
-            -Window->WindowRect.top);
-      }
+         if (UpdateRect != NULL)
+         {
+            hRgn = UnsafeIntCreateRectRgnIndirect((RECT *)UpdateRect);
+            NtGdiOffsetRgn(hRgn,
+                           Window->ClientRect.left - Window->WindowRect.left,
+                           Window->ClientRect.top - Window->WindowRect.top);
+         }
+         else
+            if ((Flags & (RDW_INVALIDATE | RDW_FRAME)) == (RDW_INVALIDATE | RDW_FRAME) ||
+                  (Flags & (RDW_VALIDATE | RDW_NOFRAME)) == (RDW_VALIDATE | RDW_NOFRAME))
+            {
+               hRgn = UnsafeIntCreateRectRgnIndirect(&Window->WindowRect);
+               NtGdiOffsetRgn(hRgn,
+                              -Window->WindowRect.left,
+                              -Window->WindowRect.top);
+            }
+            else
+            {
+               hRgn = UnsafeIntCreateRectRgnIndirect(&Window->ClientRect);
+               NtGdiOffsetRgn(hRgn,
+                              -Window->WindowRect.left,
+                              -Window->WindowRect.top);
+            }
    }
 
    /*
@@ -524,9 +527,9 @@ BOOL FASTCALL
 IntIsWindowDirty(PWINDOW_OBJECT Window)
 {
    return (Window->Style & WS_VISIBLE) &&
-      ((Window->UpdateRegion != NULL) ||
-       (Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT) ||
-       (Window->Flags & WINDOWOBJECT_NEED_NCPAINT));
+          ((Window->UpdateRegion != NULL) ||
+           (Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT) ||
+           (Window->Flags & WINDOWOBJECT_NEED_NCPAINT));
 }
 
 HWND STDCALL
@@ -541,7 +544,7 @@ IntFindWindowToRepaint(HWND hWnd, PW32THREAD Thread)
       return NULL;
 
    if (IntIsWindowDirty(Window) &&
-       IntWndBelongsToThread(Window, Thread))
+         IntWndBelongsToThread(Window, Thread))
    {
       IntReleaseWindowObject(Window);
       return hWnd;
@@ -550,7 +553,7 @@ IntFindWindowToRepaint(HWND hWnd, PW32THREAD Thread)
    for (Child = Window->FirstChild; Child; Child = Child->NextSibling)
    {
       if (IntIsWindowDirty(Child) &&
-          IntWndBelongsToThread(Child, Thread))
+            IntWndBelongsToThread(Child, Thread))
       {
          hFoundWnd = Child->hSelf;
          break;
@@ -591,7 +594,7 @@ IntGetPaintMessage(HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax,
       return FALSE;
 
    if ((MsgFilterMin != 0 || MsgFilterMax != 0) &&
-       (MsgFilterMin > WM_PAINT || MsgFilterMax < WM_PAINT))
+         (MsgFilterMin > WM_PAINT || MsgFilterMax < WM_PAINT))
       return FALSE;
 
    if (hWnd)
@@ -631,17 +634,17 @@ co_IntFixCaret(PWINDOW_OBJECT Window, LPRECT lprc, UINT flags)
    PTHRDCARETINFO CaretInfo;
    HWND hWndCaret;
    PWINDOW_OBJECT WndCaret;
-   
+
    ASSERT_REFS_CO(Window);
 
    Desktop = PsGetCurrentThread()->Tcb.Win32Thread->Desktop;
    CaretInfo = ((PUSER_MESSAGE_QUEUE)Desktop->ActiveMessageQueue)->CaretInfo;
    hWndCaret = CaretInfo->hWnd;
-   
+
    WndCaret = UserGetWindowObject(hWndCaret);
-   
+
    if (WndCaret == Window ||
-       ((flags & SW_SCROLLCHILDREN) && IntIsChildWindow(Window->hSelf, hWndCaret)))
+         ((flags & SW_SCROLLCHILDREN) && IntIsChildWindow(Window->hSelf, hWndCaret)))
    {
       POINT pt, FromOffset, ToOffset, Offset;
       RECT rcCaret;
@@ -702,7 +705,7 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
       HRGN hRgn;
 
       if (Window->NCUpdateRegion != (HANDLE)1 &&
-          Window->NCUpdateRegion != NULL)
+            Window->NCUpdateRegion != NULL)
       {
          GDIOBJ_SetOwnership(Window->NCUpdateRegion, PsGetCurrentProcess());
       }
@@ -720,7 +723,7 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
    }
 
    RtlZeroMemory(&Ps, sizeof(PAINTSTRUCT));
-   
+
    Ps.hdc = UserGetDCEx(Window, 0, DCX_INTERSECTUPDATE | DCX_WINDOWPAINT | DCX_USESTYLE);
 
    if (!Ps.hdc)
@@ -778,12 +781,12 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
    }
 
    RETURN( Ps.hdc);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserBeginPaint, ret=%i\n",_ret_);
    UserLeave();
    END_CLEANUP;
-   
+
 }
 
 /*
@@ -801,19 +804,19 @@ NtUserEndPaint(HWND hWnd, CONST PAINTSTRUCT* lPs)
 
    DPRINT("Enter NtUserEndPaint\n");
    UserEnterExclusive();
-   
+
    if (!(Window = IntGetWindowObject(hWnd)))
    {
       RETURN(FALSE);
    }
-   
+
    UserReleaseDC(Window, lPs->hdc);
    co_UserShowCaret(Window);
 
    IntReleaseWindowObject(Window); //temp hack
 
    RETURN(TRUE);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserEndPaint, ret=%i\n",_ret_);
    UserLeave();
@@ -927,18 +930,18 @@ NtUserGetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase)
 
    DPRINT("Enter NtUserGetUpdateRgn\n");
    UserEnterExclusive();
-   
+
    if (!(Window = UserGetWindowObject(hWnd)))
    {
       RETURN(ERROR);
    }
-   
+
    UserRefObjectCo(Window);
    ret = co_UserGetUpdateRgn(Window, hRgn, bErase);
    UserDerefObjectCo(Window);
-   
+
    RETURN(ret);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserGetUpdateRgn, ret=%i\n",_ret_);
    UserLeave();
@@ -1020,7 +1023,7 @@ CLEANUP:
 
 BOOL STDCALL
 NtUserRedrawWindow(HWND hWnd, CONST RECT *lprcUpdate, HRGN hrgnUpdate,
-   UINT flags)
+                   UINT flags)
 {
    RECT SafeUpdateRect;
    NTSTATUS Status;
@@ -1038,7 +1041,7 @@ NtUserRedrawWindow(HWND hWnd, CONST RECT *lprcUpdate, HRGN hrgnUpdate,
    if (lprcUpdate != NULL)
    {
       Status = MmCopyFromCaller(&SafeUpdateRect, (PRECT)lprcUpdate,
-         sizeof(RECT));
+                                sizeof(RECT));
 
       if (!NT_SUCCESS(Status))
       {
@@ -1050,7 +1053,7 @@ NtUserRedrawWindow(HWND hWnd, CONST RECT *lprcUpdate, HRGN hrgnUpdate,
    UserRefObjectCo(Wnd);
 
    Status = co_UserRedrawWindow(Wnd, NULL == lprcUpdate ? NULL : &SafeUpdateRect,
-      hrgnUpdate, flags);
+                                hrgnUpdate, flags);
 
    UserDerefObjectCo(Wnd);
 
@@ -1062,7 +1065,7 @@ NtUserRedrawWindow(HWND hWnd, CONST RECT *lprcUpdate, HRGN hrgnUpdate,
    }
 
    RETURN( TRUE);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserRedrawWindow, ret=%i\n",_ret_);
    UserLeave();
@@ -1074,7 +1077,7 @@ CLEANUP:
 static
 DWORD FASTCALL
 UserScrollDC(HDC hDC, INT dx, INT dy, const RECT *lprcScroll,
-   const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate)
+             const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate)
 {
    RECT rSrc, rClipped_src, rClip, rDst, offset;
    PDC DC;
@@ -1085,9 +1088,9 @@ UserScrollDC(HDC hDC, INT dx, INT dy, const RECT *lprcScroll,
 
    DC = DC_LockDc(hDC);
    if (NULL == DC)
-     {
-       return FALSE;
-     }
+   {
+      return FALSE;
+   }
    if (lprcScroll)
       rSrc = *lprcScroll;
    else
@@ -1182,20 +1185,20 @@ UserScrollDC(HDC hDC, INT dx, INT dy, const RECT *lprcScroll,
 
 DWORD STDCALL
 NtUserScrollDC(HDC hDC, INT dx, INT dy, const RECT *lprcScroll,
-   const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate)
+               const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate)
 {
    DECLARE_RETURN(DWORD);
 
    DPRINT("Enter NtUserScrollDC\n");
    UserEnterExclusive();
-   
+
    RETURN( UserScrollDC(hDC, dx, dy, lprcScroll, lprcClip, hrgnUpdate, lprcUpdate));
 
 CLEANUP:
    DPRINT("Leave NtUserScrollDC, ret=%i\n",_ret_);
    UserLeave();
    END_CLEANUP;
-   
+
 }
 
 /*
@@ -1207,7 +1210,7 @@ CLEANUP:
 
 DWORD STDCALL
 NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect,
-   const RECT *UnsafeClipRect, HRGN hrgnUpdate, LPRECT rcUpdate, UINT flags)
+                     const RECT *UnsafeClipRect, HRGN hrgnUpdate, LPRECT rcUpdate, UINT flags)
 {
    RECT rc, cliprc, caretrc, rect, clipRect;
    INT Result;
@@ -1229,10 +1232,10 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect,
       Window = NULL; /* prevent deref at cleanup */
       RETURN( ERROR);
    }
-   UserRefObjectCo(Window);  
-   
+   UserRefObjectCo(Window);
+
    IntGetClientRect(Window, &rc);
-   
+
    if (NULL != UnsafeRect)
    {
       Status = MmCopyFromCaller(&rect, UnsafeRect, sizeof(RECT));
@@ -1258,7 +1261,7 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect,
       cliprc = rc;
 
    if (cliprc.right <= cliprc.left || cliprc.bottom <= cliprc.top ||
-       (dx == 0 && dy == 0))
+         (dx == 0 && dy == 0))
    {
       RETURN( NULLREGION);
    }
@@ -1293,7 +1296,7 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect,
       co_UserRedrawWindow(Window, NULL, hrgnTemp, RDW_INVALIDATE | RDW_ERASE);
       NtGdiDeleteObject(hrgnClip);
    }
-   
+
    NtGdiDeleteObject(hrgnTemp);
 
    if (flags & SW_SCROLLCHILDREN)
@@ -1305,11 +1308,12 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect,
          RECT r, dummy;
          POINT ClientOrigin;
          PWINDOW_OBJECT Wnd;
-         
+
          IntGetClientOrigin(Window, &ClientOrigin);
          for (i = 0; List[i]; i++)
          {
-            if (!(Wnd = UserGetWindowObject(List[i]))) continue;
+            if (!(Wnd = UserGetWindowObject(List[i])))
+               continue;
 
             r = Wnd->WindowRect;
             r.left -= ClientOrigin.x;
@@ -1321,11 +1325,11 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect,
             {
                UserRefObjectCo(Wnd);
                co_WinPosSetWindowPos(Wnd, 0, r.left + dx, r.top + dy, 0, 0,
-                                  SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE |
-                                  SWP_NOREDRAW);
-               UserDerefObjectCo(Wnd);                                  
+                                     SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE |
+                                     SWP_NOREDRAW);
+               UserDerefObjectCo(Wnd);
             }
-                                  
+
          }
          ExFreePool(List);
       }
@@ -1333,8 +1337,8 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect,
 
    if (flags & (SW_INVALIDATE | SW_ERASE))
       co_UserRedrawWindow(Window, NULL, hrgnUpdate, RDW_INVALIDATE | RDW_ERASE |
-                         ((flags & SW_ERASE) ? RDW_ERASENOW : 0) |
-                         ((flags & SW_SCROLLCHILDREN) ? RDW_ALLCHILDREN : 0));
+                          ((flags & SW_ERASE) ? RDW_ERASENOW : 0) |
+                          ((flags & SW_SCROLLCHILDREN) ? RDW_ALLCHILDREN : 0));
 
    if (bOwnRgn && hrgnUpdate)
       NtGdiDeleteObject(hrgnUpdate);
@@ -1342,17 +1346,18 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect,
    if ((CaretWnd = UserGetWindowObject(hwndCaret)))
    {
       UserRefObjectCo(CaretWnd);
-      
+
       co_IntSetCaretPos(caretrc.left + dx, caretrc.top + dy);
       co_UserShowCaret(CaretWnd);
-      
+
       UserDerefObjectCo(CaretWnd);
    }
 
    RETURN( Result);
-   
+
 CLEANUP:
-   if (Window) UserDerefObjectCo(Window);
+   if (Window)
+      UserDerefObjectCo(Window);
 
    DPRINT("Leave NtUserScrollWindowEx, ret=%i\n",_ret_);
    UserLeave();
index 0d68230..b92a198 100644 (file)
 
 typedef struct _PROPLISTITEM
 {
-  ATOM Atom;
-  HANDLE Data;
-} PROPLISTITEM, *PPROPLISTITEM;
+   ATOM Atom;
+   HANDLE Data;
+}
+PROPLISTITEM, *PPROPLISTITEM;
 
 
 /* STATIC FUNCTIONS **********************************************************/
@@ -48,205 +49,205 @@ static
 PPROPERTY FASTCALL
 IntGetProp(PWINDOW_OBJECT Window, ATOM Atom)
 {
-  PLIST_ENTRY ListEntry;
-  PPROPERTY Property;
+   PLIST_ENTRY ListEntry;
+   PPROPERTY Property;
 
-  ListEntry = Window->PropListHead.Flink;
-  while (ListEntry != &Window->PropListHead)
-    {
+   ListEntry = Window->PropListHead.Flink;
+   while (ListEntry != &Window->PropListHead)
+   {
       Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
       if (Property->Atom == Atom)
-       {
-         return(Property);
-       }
+      {
+         return(Property);
+      }
       ListEntry = ListEntry->Flink;
-    }
-  return(NULL);
+   }
+   return(NULL);
 }
 
 NTSTATUS STDCALL
 NtUserBuildPropList(HWND hWnd,
-                   LPVOID Buffer,
-                   DWORD BufferSize,
-                   DWORD *Count)
+                    LPVOID Buffer,
+                    DWORD BufferSize,
+                    DWORD *Count)
 {
-  PWINDOW_OBJECT Window;
-  PPROPERTY Property;
-  PLIST_ENTRY ListEntry;
-  PROPLISTITEM listitem, *li;
-  NTSTATUS Status;
-  DWORD Cnt = 0;
-  DECLARE_RETURN(NTSTATUS);
-  
-  DPRINT("Enter NtUserBuildPropList\n");
-  UserEnterShared();
-
-  if (!(Window = UserGetWindowObject(hWnd)))
-  {
-    RETURN( STATUS_INVALID_HANDLE);
-  }
-
-  if(Buffer)
-  {
-    if(!BufferSize || (BufferSize % sizeof(PROPLISTITEM) != 0))
-    {
-      RETURN( STATUS_INVALID_PARAMETER);
-    }
-
-    /* copy list */
-    li = (PROPLISTITEM *)Buffer;
-    ListEntry = Window->PropListHead.Flink;
-    while((BufferSize >= sizeof(PROPLISTITEM)) && (ListEntry != &Window->PropListHead))
-    {
-      Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
-      listitem.Atom = Property->Atom;
-      listitem.Data = Property->Data;
+   PWINDOW_OBJECT Window;
+   PPROPERTY Property;
+   PLIST_ENTRY ListEntry;
+   PROPLISTITEM listitem, *li;
+   NTSTATUS Status;
+   DWORD Cnt = 0;
+   DECLARE_RETURN(NTSTATUS);
+
+   DPRINT("Enter NtUserBuildPropList\n");
+   UserEnterShared();
+
+   if (!(Window = UserGetWindowObject(hWnd)))
+   {
+      RETURN( STATUS_INVALID_HANDLE);
+   }
+
+   if(Buffer)
+   {
+      if(!BufferSize || (BufferSize % sizeof(PROPLISTITEM) != 0))
+      {
+         RETURN( STATUS_INVALID_PARAMETER);
+      }
+
+      /* copy list */
+      li = (PROPLISTITEM *)Buffer;
+      ListEntry = Window->PropListHead.Flink;
+      while((BufferSize >= sizeof(PROPLISTITEM)) && (ListEntry != &Window->PropListHead))
+      {
+         Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
+         listitem.Atom = Property->Atom;
+         listitem.Data = Property->Data;
+
+         Status = MmCopyToCaller(li, &listitem, sizeof(PROPLISTITEM));
+         if(!NT_SUCCESS(Status))
+         {
+            RETURN( Status);
+         }
+
+         BufferSize -= sizeof(PROPLISTITEM);
+         Cnt++;
+         li++;
+         ListEntry = ListEntry->Flink;
+      }
+
+   }
+   else
+   {
+      Cnt = Window->PropListItems * sizeof(PROPLISTITEM);
+   }
 
-      Status = MmCopyToCaller(li, &listitem, sizeof(PROPLISTITEM));
+   if(Count)
+   {
+      Status = MmCopyToCaller(Count, &Cnt, sizeof(DWORD));
       if(!NT_SUCCESS(Status))
       {
-        RETURN( Status);
+         RETURN( Status);
       }
+   }
+
+   RETURN( STATUS_SUCCESS);
 
-      BufferSize -= sizeof(PROPLISTITEM);
-      Cnt++;
-      li++;
-      ListEntry = ListEntry->Flink;
-    }
-
-  }
-  else
-  {
-    Cnt = Window->PropListItems * sizeof(PROPLISTITEM);
-  }
-
-  if(Count)
-  {
-    Status = MmCopyToCaller(Count, &Cnt, sizeof(DWORD));
-    if(!NT_SUCCESS(Status))
-    {
-      RETURN( Status);
-    }
-  }
-
-  RETURN( STATUS_SUCCESS);
-  
 CLEANUP:
-  DPRINT("Leave NtUserBuildPropList, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserBuildPropList, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 HANDLE STDCALL
 NtUserRemoveProp(HWND hWnd, ATOM Atom)
 {
-  PWINDOW_OBJECT Window;
-  PPROPERTY Prop;
-  HANDLE Data;
-  DECLARE_RETURN(HANDLE);
-  
-  DPRINT("Enter NtUserRemoveProp\n");
-  UserEnterExclusive();
-
-  if (!(Window = UserGetWindowObject(hWnd)))
-  {
-    RETURN( NULL);
-  }
-
-  Prop = IntGetProp(Window, Atom);
-
-  if (Prop == NULL)
-    {
+   PWINDOW_OBJECT Window;
+   PPROPERTY Prop;
+   HANDLE Data;
+   DECLARE_RETURN(HANDLE);
+
+   DPRINT("Enter NtUserRemoveProp\n");
+   UserEnterExclusive();
+
+   if (!(Window = UserGetWindowObject(hWnd)))
+   {
+      RETURN( NULL);
+   }
+
+   Prop = IntGetProp(Window, Atom);
+
+   if (Prop == NULL)
+   {
       RETURN(NULL);
-    }
-  Data = Prop->Data;
-  RemoveEntryList(&Prop->PropListEntry);
-  ExFreePool(Prop);
-  Window->PropListItems--;
-
-  RETURN(Data);
-  
+   }
+   Data = Prop->Data;
+   RemoveEntryList(&Prop->PropListEntry);
+   ExFreePool(Prop);
+   Window->PropListItems--;
+
+   RETURN(Data);
+
 CLEANUP:
-  DPRINT("Leave NtUserRemoveProp, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;  
+   DPRINT("Leave NtUserRemoveProp, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 HANDLE STDCALL
 NtUserGetProp(HWND hWnd, ATOM Atom)
 {
-  PWINDOW_OBJECT Window;
-  PPROPERTY Prop;
-  HANDLE Data = NULL;
-  DECLARE_RETURN(HANDLE);
-  
-  DPRINT("Enter NtUserGetProp\n");
-  UserEnterShared();
-
-  if (!(Window = UserGetWindowObject(hWnd)))
-  {
-    RETURN( FALSE);
-  }
-
-  Prop = IntGetProp(Window, Atom);
-  if (Prop != NULL)
-  {
-    Data = Prop->Data;
-  }
-
-  RETURN(Data);
-  
+   PWINDOW_OBJECT Window;
+   PPROPERTY Prop;
+   HANDLE Data = NULL;
+   DECLARE_RETURN(HANDLE);
+
+   DPRINT("Enter NtUserGetProp\n");
+   UserEnterShared();
+
+   if (!(Window = UserGetWindowObject(hWnd)))
+   {
+      RETURN( FALSE);
+   }
+
+   Prop = IntGetProp(Window, Atom);
+   if (Prop != NULL)
+   {
+      Data = Prop->Data;
+   }
+
+   RETURN(Data);
+
 CLEANUP:
-  DPRINT("Leave NtUserGetProp, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetProp, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 static
 BOOL FASTCALL
 IntSetProp(PWINDOW_OBJECT Wnd, ATOM Atom, HANDLE Data)
 {
-  PPROPERTY Prop;
-
-  Prop = IntGetProp(Wnd, Atom);
-
-  if (Prop == NULL)
-  {
-    Prop = ExAllocatePoolWithTag(PagedPool, sizeof(PROPERTY), TAG_WNDPROP);
-    if (Prop == NULL)
-    {
-      return FALSE;
-    }
-    Prop->Atom = Atom;
-    InsertTailList(&Wnd->PropListHead, &Prop->PropListEntry);
-    Wnd->PropListItems++;
-  }
-
-  Prop->Data = Data;
-  return TRUE;
+   PPROPERTY Prop;
+
+   Prop = IntGetProp(Wnd, Atom);
+
+   if (Prop == NULL)
+   {
+      Prop = ExAllocatePoolWithTag(PagedPool, sizeof(PROPERTY), TAG_WNDPROP);
+      if (Prop == NULL)
+      {
+         return FALSE;
+      }
+      Prop->Atom = Atom;
+      InsertTailList(&Wnd->PropListHead, &Prop->PropListEntry);
+      Wnd->PropListItems++;
+   }
+
+   Prop->Data = Data;
+   return TRUE;
 }
 
 
 BOOL STDCALL
 NtUserSetProp(HWND hWnd, ATOM Atom, HANDLE Data)
 {
-  PWINDOW_OBJECT Window;
-  DECLARE_RETURN(BOOL);
-  
-  DPRINT("Enter NtUserSetProp\n");
-  UserEnterExclusive();
-
-  if (!(Window = UserGetWindowObject(hWnd)))
-  {
-    RETURN( FALSE);
-  }
-
-  RETURN( IntSetProp(Window, Atom, Data));
-  
+   PWINDOW_OBJECT Window;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserSetProp\n");
+   UserEnterExclusive();
+
+   if (!(Window = UserGetWindowObject(hWnd)))
+   {
+      RETURN( FALSE);
+   }
+
+   RETURN( IntSetProp(Window, Atom, Data));
+
 CLEANUP:
-  DPRINT("Leave NtUserSetProp, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserSetProp, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 /* EOF */
index 38a46d5..8341ee1 100644 (file)
 BOOL FASTCALL
 IntGetScrollBarRect (PWINDOW_OBJECT Window, INT nBar, PRECT lprect)
 {
-  BOOL vertical;
-  RECT ClientRect = Window->ClientRect;
-  RECT WindowRect = Window->WindowRect;
-
-  switch (nBar)
-    {
-    case SB_HORZ:
-      lprect->left = ClientRect.left - WindowRect.left;
-      lprect->top = ClientRect.bottom - WindowRect.top;
-      lprect->right = ClientRect.right - WindowRect.left;
-      lprect->bottom = lprect->top + UserGetSystemMetrics (SM_CYHSCROLL);
-      vertical = FALSE;
-      break;
-
-    case SB_VERT:
-      if(Window->ExStyle & WS_EX_LEFTSCROLLBAR)
-      {
-        lprect->right = ClientRect.left - WindowRect.left;
-        lprect->left = lprect->right - UserGetSystemMetrics(SM_CXVSCROLL);
-      }
-      else
-      {
-        lprect->left = ClientRect.right - WindowRect.left;
-        lprect->right = lprect->left + UserGetSystemMetrics(SM_CXVSCROLL);
-      }
-      lprect->top = ClientRect.top - WindowRect.top;
-      lprect->bottom = ClientRect.bottom - WindowRect.top;
-      vertical = TRUE;
-      break;
+   BOOL vertical;
+   RECT ClientRect = Window->ClientRect;
+   RECT WindowRect = Window->WindowRect;
 
-    case SB_CTL:
-      IntGetClientRect (Window, lprect);
-      vertical = ((Window->Style & SBS_VERT) != 0);
-      break;
-
-    default:
-      return FALSE;
-    }
+   switch (nBar)
+   {
+      case SB_HORZ:
+         lprect->left = ClientRect.left - WindowRect.left;
+         lprect->top = ClientRect.bottom - WindowRect.top;
+         lprect->right = ClientRect.right - WindowRect.left;
+         lprect->bottom = lprect->top + UserGetSystemMetrics (SM_CYHSCROLL);
+         vertical = FALSE;
+         break;
+
+      case SB_VERT:
+         if(Window->ExStyle & WS_EX_LEFTSCROLLBAR)
+         {
+            lprect->right = ClientRect.left - WindowRect.left;
+            lprect->left = lprect->right - UserGetSystemMetrics(SM_CXVSCROLL);
+         }
+         else
+         {
+            lprect->left = ClientRect.right - WindowRect.left;
+            lprect->right = lprect->left + UserGetSystemMetrics(SM_CXVSCROLL);
+         }
+         lprect->top = ClientRect.top - WindowRect.top;
+         lprect->bottom = ClientRect.bottom - WindowRect.top;
+         vertical = TRUE;
+         break;
+
+      case SB_CTL:
+         IntGetClientRect (Window, lprect);
+         vertical = ((Window->Style & SBS_VERT) != 0);
+         break;
+
+      default:
+         return FALSE;
+   }
 
-  return vertical;
+   return vertical;
 }
 
 BOOL FASTCALL
 IntCalculateThumb(PWINDOW_OBJECT Window, LONG idObject, PSCROLLBARINFO psbi, LPSCROLLINFO psi)
 {
-  INT Thumb, ThumbBox, ThumbPos, cxy, mx;
-  RECT ClientRect;
-
-  switch(idObject)
-  {
-    case SB_HORZ:
-      Thumb = UserGetSystemMetrics(SM_CXHSCROLL);
-      cxy = psbi->rcScrollBar.right - psbi->rcScrollBar.left;
-      break;
-    case SB_VERT:
-      Thumb = UserGetSystemMetrics(SM_CYVSCROLL);
-      cxy = psbi->rcScrollBar.bottom - psbi->rcScrollBar.top;
-      break;
-    case SB_CTL:
-      IntGetClientRect (Window, &ClientRect);
-      if(Window->Style & SBS_VERT)
+   INT Thumb, ThumbBox, ThumbPos, cxy, mx;
+   RECT ClientRect;
+
+   switch(idObject)
+   {
+      case SB_HORZ:
+         Thumb = UserGetSystemMetrics(SM_CXHSCROLL);
+         cxy = psbi->rcScrollBar.right - psbi->rcScrollBar.left;
+         break;
+      case SB_VERT:
+         Thumb = UserGetSystemMetrics(SM_CYVSCROLL);
+         cxy = psbi->rcScrollBar.bottom - psbi->rcScrollBar.top;
+         break;
+      case SB_CTL:
+         IntGetClientRect (Window, &ClientRect);
+         if(Window->Style & SBS_VERT)
+         {
+            Thumb = UserGetSystemMetrics(SM_CYVSCROLL);
+            cxy = ClientRect.bottom - ClientRect.top;
+         }
+         else
+         {
+            Thumb = UserGetSystemMetrics(SM_CXHSCROLL);
+            cxy = ClientRect.right - ClientRect.left;
+         }
+         break;
+      default:
+         return FALSE;
+   }
+
+   ThumbPos = Thumb;
+   /* calculate Thumb */
+   if(cxy <= (2 * Thumb))
+   {
+      Thumb = cxy / 2;
+      psbi->xyThumbTop = 0;
+      psbi->xyThumbBottom = 0;
+      ThumbPos = Thumb;
+   }
+   else
+   {
+      ThumbBox = psi->nPage ? MINTRACKTHUMB : UserGetSystemMetrics(SM_CXHTHUMB);
+      cxy -= (2 * Thumb);
+      if(cxy >= ThumbBox)
       {
-        Thumb = UserGetSystemMetrics(SM_CYVSCROLL);
-        cxy = ClientRect.bottom - ClientRect.top;
+         if(psi->nPage)
+         {
+            ThumbBox = max(EngMulDiv(cxy, psi->nPage, psi->nMax - psi->nMin + 1), ThumbBox);
+         }
+
+         if(cxy > ThumbBox)
+         {
+            mx = psi->nMax - max(psi->nPage - 1, 0);
+            if(psi->nMin < mx)
+               ThumbPos = Thumb + EngMulDiv(cxy - ThumbBox, psi->nPos - psi->nMin, mx - psi->nMin);
+            else
+               ThumbPos = Thumb + ThumbBox;
+         }
+
+         psbi->xyThumbTop = ThumbPos;
+         psbi->xyThumbBottom = ThumbPos + ThumbBox;
       }
       else
       {
-        Thumb = UserGetSystemMetrics(SM_CXHSCROLL);
-        cxy = ClientRect.right - ClientRect.left;
-      }
-      break;
-    default:
-      return FALSE;
-  }
-
-  ThumbPos = Thumb;
-  /* calculate Thumb */
-  if(cxy <= (2 * Thumb))
-  {
-    Thumb = cxy / 2;
-    psbi->xyThumbTop = 0;
-    psbi->xyThumbBottom = 0;
-    ThumbPos = Thumb;
-  }
-  else
-  {
-    ThumbBox = psi->nPage ? MINTRACKTHUMB : UserGetSystemMetrics(SM_CXHTHUMB);
-    cxy -= (2 * Thumb);
-    if(cxy >= ThumbBox)
-    {
-      if(psi->nPage)
-      {
-        ThumbBox = max(EngMulDiv(cxy, psi->nPage, psi->nMax - psi->nMin + 1), ThumbBox);
-      }
-
-      if(cxy > ThumbBox)
-      {
-        mx = psi->nMax - max(psi->nPage - 1, 0);
-        if(psi->nMin < mx)
-          ThumbPos = Thumb + EngMulDiv(cxy - ThumbBox, psi->nPos - psi->nMin, mx - psi->nMin);
-        else
-          ThumbPos = Thumb + ThumbBox;
+         psbi->xyThumbTop = 0;
+         psbi->xyThumbBottom = 0;
       }
+   }
+   psbi->dxyLineButton = Thumb;
 
-      psbi->xyThumbTop = ThumbPos;
-      psbi->xyThumbBottom = ThumbPos + ThumbBox;
-    }
-    else
-    {
-      psbi->xyThumbTop = 0;
-      psbi->xyThumbBottom = 0;
-    }
-  }
-  psbi->dxyLineButton = Thumb;
-
-  return TRUE;
+   return TRUE;
 }
 
 static VOID FASTCALL
 IntUpdateSBInfo(PWINDOW_OBJECT Window, int wBar)
 {
-  PSCROLLBARINFO sbi;
-  LPSCROLLINFO psi;
+   PSCROLLBARINFO sbi;
+   LPSCROLLINFO psi;
 
-  ASSERT(Window);
-  ASSERT(Window->Scroll);
+   ASSERT(Window);
+   ASSERT(Window->Scroll);
 
-  sbi = IntGetScrollbarInfoFromWindow(Window, wBar);
-  psi = IntGetScrollInfoFromWindow(Window, wBar);
-  IntGetScrollBarRect(Window, wBar, &(sbi->rcScrollBar));
-  IntCalculateThumb(Window, wBar, sbi, psi);
+   sbi = IntGetScrollbarInfoFromWindow(Window, wBar);
+   psi = IntGetScrollInfoFromWindow(Window, wBar);
+   IntGetScrollBarRect(Window, wBar, &(sbi->rcScrollBar));
+   IntCalculateThumb(Window, wBar, sbi, psi);
 }
 
 static BOOL FASTCALL
 co_IntGetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPSCROLLINFO lpsi)
 {
-  UINT Mask;
-  LPSCROLLINFO psi;
+   UINT Mask;
+   LPSCROLLINFO psi;
 
-  ASSERT_REFS_CO(Window); 
+   ASSERT_REFS_CO(Window);
 
-  if(!SBID_IS_VALID(nBar))
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    DPRINT1("Trying to get scrollinfo for unknown scrollbar type %d\n", nBar);
-    return FALSE;
-  }
+   if(!SBID_IS_VALID(nBar))
+   {
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      DPRINT1("Trying to get scrollinfo for unknown scrollbar type %d\n", nBar);
+      return FALSE;
+   }
 
-  if(!co_IntCreateScrollBars(Window))
-    {
+   if(!co_IntCreateScrollBars(Window))
+   {
       return FALSE;
-    }
+   }
 
-  psi = IntGetScrollInfoFromWindow(Window, nBar);
+   psi = IntGetScrollInfoFromWindow(Window, nBar);
 
-  if (lpsi->fMask == SIF_ALL)
-    {
+   if (lpsi->fMask == SIF_ALL)
+   {
       Mask = SIF_PAGE | SIF_POS | SIF_RANGE | SIF_TRACKPOS;
-    }
-  else
-    {
+   }
+   else
+   {
       Mask = lpsi->fMask;
-    }
+   }
 
-  if (0 != (Mask & SIF_PAGE))
-    {
+   if (0 != (Mask & SIF_PAGE))
+   {
       lpsi->nPage = psi->nPage;
-    }
+   }
 
-  if (0 != (Mask & SIF_POS))
-    {
+   if (0 != (Mask & SIF_POS))
+   {
       lpsi->nPos = psi->nPos;
-    }
+   }
 
-  if (0 != (Mask & SIF_RANGE))
-    {
+   if (0 != (Mask & SIF_RANGE))
+   {
       lpsi->nMin = psi->nMin;
       lpsi->nMax = psi->nMax;
-    }
+   }
 
-  if (0 != (Mask & SIF_TRACKPOS))
-    {
+   if (0 != (Mask & SIF_TRACKPOS))
+   {
       lpsi->nTrackPos = psi->nTrackPos;
-    }
+   }
 
-  return TRUE;
+   return TRUE;
 }
 
 static DWORD FASTCALL
 co_IntSetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
 {
-  /*
-   * Update the scrollbar state and set action flags according to
-   * what has to be done graphics wise.
-   */
-
-  LPSCROLLINFO Info;
-  PSCROLLBARINFO psbi;
-/*   UINT new_flags;*/
-  BOOL bChangeParams = FALSE; /* don't show/hide scrollbar if params don't change */
-
-  ASSERT_REFS_CO(Window); 
-
-  if(!SBID_IS_VALID(nBar))
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    DPRINT1("Trying to set scrollinfo for unknown scrollbar type %d", nBar);
-    return FALSE;
-  }
-
-  if(!co_IntCreateScrollBars(Window))
-    {
+   /*
+    * Update the scrollbar state and set action flags according to
+    * what has to be done graphics wise.
+    */
+
+   LPSCROLLINFO Info;
+   PSCROLLBARINFO psbi;
+   /*   UINT new_flags;*/
+   BOOL bChangeParams = FALSE; /* don't show/hide scrollbar if params don't change */
+
+   ASSERT_REFS_CO(Window);
+
+   if(!SBID_IS_VALID(nBar))
+   {
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      DPRINT1("Trying to set scrollinfo for unknown scrollbar type %d", nBar);
+      return FALSE;
+   }
+
+   if(!co_IntCreateScrollBars(Window))
+   {
       return FALSE;
-    }
+   }
 
-  if (lpsi->cbSize != sizeof(SCROLLINFO) &&
-      lpsi->cbSize != (sizeof(SCROLLINFO) - sizeof(lpsi->nTrackPos)))
-    {
+   if (lpsi->cbSize != sizeof(SCROLLINFO) &&
+         lpsi->cbSize != (sizeof(SCROLLINFO) - sizeof(lpsi->nTrackPos)))
+   {
       SetLastWin32Error(ERROR_INVALID_PARAMETER);
       return 0;
-    }
-  if (lpsi->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL))
-    {
+   }
+   if (lpsi->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL))
+   {
       SetLastWin32Error(ERROR_INVALID_PARAMETER);
       return 0;
-    }
+   }
 
-  psbi = IntGetScrollbarInfoFromWindow(Window, nBar);
-  Info = IntGetScrollInfoFromWindow(Window, nBar);
+   psbi = IntGetScrollbarInfoFromWindow(Window, nBar);
+   Info = IntGetScrollInfoFromWindow(Window, nBar);
 
-  /* Set the page size */
-  if (0 != (lpsi->fMask & SIF_PAGE))
-    {
+   /* Set the page size */
+   if (0 != (lpsi->fMask & SIF_PAGE))
+   {
       if (Info->nPage != lpsi->nPage)
-        {
-          Info->nPage = lpsi->nPage;
-          bChangeParams = TRUE;
-        }
-    }
-
-  /* Set the scroll pos */
-  if (0 != (lpsi->fMask & SIF_POS))
-    {
+      {
+         Info->nPage = lpsi->nPage;
+         bChangeParams = TRUE;
+      }
+   }
+
+   /* Set the scroll pos */
+   if (0 != (lpsi->fMask & SIF_POS))
+   {
       if (Info->nPos != lpsi->nPos)
-        {
-          Info->nPos = lpsi->nPos;
-        }
-    }
-
-  /* Set the scroll range */
-  if (0 != (lpsi->fMask & SIF_RANGE))
-    {
+      {
+         Info->nPos = lpsi->nPos;
+      }
+   }
+
+   /* Set the scroll range */
+   if (0 != (lpsi->fMask & SIF_RANGE))
+   {
       /* Invalid range -> range is set to (0,0) */
       if (lpsi->nMin > lpsi->nMax ||
-          0x80000000 <= (UINT)(lpsi->nMax - lpsi->nMin))
-        {
-          Info->nMin = 0;
-          Info->nMax = 0;
-          bChangeParams = TRUE;
-        }
+            0x80000000 <= (UINT)(lpsi->nMax - lpsi->nMin))
+      {
+         Info->nMin = 0;
+         Info->nMax = 0;
+         bChangeParams = TRUE;
+      }
       else if (Info->nMin != lpsi->nMin || Info->nMax != lpsi->nMax)
-        {
-          Info->nMin = lpsi->nMin;
-          Info->nMax = lpsi->nMax;
-          bChangeParams = TRUE;
-        }
-    }
-
-  /* Make sure the page size is valid */
-  if (Info->nPage < 0)
-    {
+      {
+         Info->nMin = lpsi->nMin;
+         Info->nMax = lpsi->nMax;
+         bChangeParams = TRUE;
+      }
+   }
+
+   /* Make sure the page size is valid */
+   if (Info->nPage < 0)
+   {
       Info->nPage = 0;
-    }
-  else if (Info->nMax - Info->nMin + 1 < Info->nPage)
-    {
+   }
+   else if (Info->nMax - Info->nMin + 1 < Info->nPage)
+   {
       Info->nPage = Info->nMax - Info->nMin + 1;
-    }
+   }
 
-  /* Make sure the pos is inside the range */
-  if (Info->nPos < Info->nMin)
-    {
+   /* Make sure the pos is inside the range */
+   if (Info->nPos < Info->nMin)
+   {
       Info->nPos = Info->nMin;
-    }
-  else if (Info->nPos > Info->nMax - max(Info->nPage - 1, 0))
-    {
+   }
+   else if (Info->nPos > Info->nMax - max(Info->nPage - 1, 0))
+   {
       Info->nPos = Info->nMax - max(Info->nPage - 1, 0);
-    }
-
-  /*
-   * Don't change the scrollbar state if SetScrollInfo is just called
-   * with SIF_DISABLENOSCROLL
-   */
-  if (0 == (lpsi->fMask & SIF_ALL))
-    {
+   }
+
+   /*
+    * Don't change the scrollbar state if SetScrollInfo is just called
+    * with SIF_DISABLENOSCROLL
+    */
+   if (0 == (lpsi->fMask & SIF_ALL))
+   {
       return Info->nPos;
-    }
+   }
 
-  /* Check if the scrollbar should be hidden or disabled */
-  if (0 != (lpsi->fMask & (SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL)))
-    {
+   /* Check if the scrollbar should be hidden or disabled */
+   if (0 != (lpsi->fMask & (SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL)))
+   {
       if (Info->nMin >= (int)(Info->nMax - max(Info->nPage - 1, 0)))
-        {
-          /* Hide or disable scroll-bar */
-          if (0 != (lpsi->fMask & SIF_DISABLENOSCROLL))
-            {
-/*            new_flags = ESB_DISABLE_BOTH;*/
-            }
-          else if ((nBar != SB_CTL) && bChangeParams)
-            {
-              co_UserShowScrollBar(Window, nBar, FALSE);
-              return Info->nPos;
-            }
-        }
+      {
+         /* Hide or disable scroll-bar */
+         if (0 != (lpsi->fMask & SIF_DISABLENOSCROLL))
+         {
+            /*            new_flags = ESB_DISABLE_BOTH;*/
+         }
+         else if ((nBar != SB_CTL) && bChangeParams)
+         {
+            co_UserShowScrollBar(Window, nBar, FALSE);
+            return Info->nPos;
+         }
+      }
       else  /* Show and enable scroll-bar */
-        {
-/*         new_flags = 0;*/
-          if ((nBar != SB_CTL) && bChangeParams)
-            {
-              co_UserShowScrollBar(Window, nBar, TRUE);
-            }
-        }
+      {
+         /*         new_flags = 0;*/
+         if ((nBar != SB_CTL) && bChangeParams)
+         {
+            co_UserShowScrollBar(Window, nBar, TRUE);
+         }
+      }
 
 #if 0
       if (infoPtr->flags != new_flags) /* check arrow flags */
-        {
-          infoPtr->flags = new_flags;
-          *Action |= SA_SSI_REPAINT_ARROWS;
-        }
+      {
+         infoPtr->flags = new_flags;
+         *Action |= SA_SSI_REPAINT_ARROWS;
+      }
 #endif
-    }
 
-  if (bRedraw)
-    {
+   }
+
+   if (bRedraw)
+   {
       RECT UpdateRect = psbi->rcScrollBar;
       UpdateRect.left -= Window->ClientRect.left - Window->WindowRect.left;
       UpdateRect.right -= Window->ClientRect.left - Window->WindowRect.left;
       UpdateRect.top -= Window->ClientRect.top - Window->WindowRect.top;
       UpdateRect.bottom -= Window->ClientRect.top - Window->WindowRect.top;
       co_UserRedrawWindow(Window, &UpdateRect, 0, RDW_INVALIDATE | RDW_FRAME);
-    }
+   }
 
    /* Return current position */
    return Info->nPos;
@@ -407,134 +408,134 @@ co_IntSetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bR
 BOOL FASTCALL
 co_IntGetScrollBarInfo(PWINDOW_OBJECT Window, LONG idObject, PSCROLLBARINFO psbi)
 {
-  INT Bar;
-  PSCROLLBARINFO sbi;
-  LPSCROLLINFO psi;
+   INT Bar;
+   PSCROLLBARINFO sbi;
+   LPSCROLLINFO psi;
 
-  ASSERT_REFS_CO(Window); 
+   ASSERT_REFS_CO(Window);
 
-  Bar = SBOBJ_TO_SBID(idObject);
+   Bar = SBOBJ_TO_SBID(idObject);
 
-  if(!SBID_IS_VALID(Bar))
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    DPRINT1("Trying to get scrollinfo for unknown scrollbar type %d\n", Bar);
-    return FALSE;
-  }
+   if(!SBID_IS_VALID(Bar))
+   {
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      DPRINT1("Trying to get scrollinfo for unknown scrollbar type %d\n", Bar);
+      return FALSE;
+   }
 
-  if(!co_IntCreateScrollBars(Window))
-    {
+   if(!co_IntCreateScrollBars(Window))
+   {
       return FALSE;
-    }
+   }
 
-  sbi = IntGetScrollbarInfoFromWindow(Window, Bar);
-  psi = IntGetScrollInfoFromWindow(Window, Bar);
+   sbi = IntGetScrollbarInfoFromWindow(Window, Bar);
+   psi = IntGetScrollInfoFromWindow(Window, Bar);
 
-  IntGetScrollBarRect(Window, Bar, &(sbi->rcScrollBar));
-  IntCalculateThumb(Window, Bar, sbi, psi);
+   IntGetScrollBarRect(Window, Bar, &(sbi->rcScrollBar));
+   IntCalculateThumb(Window, Bar, sbi, psi);
 
-  RtlCopyMemory(psbi, sbi, sizeof(SCROLLBARINFO));
+   RtlCopyMemory(psbi, sbi, sizeof(SCROLLBARINFO));
 
-  return TRUE;
+   return TRUE;
 }
 
 BOOL FASTCALL
 co_IntCreateScrollBars(PWINDOW_OBJECT Window)
 {
-  PSCROLLBARINFO psbi;
-  LPSCROLLINFO psi;
-  LRESULT Result;
-  ULONG Size, s;
-  INT i;
-
-  ASSERT_REFS_CO(Window); 
-
-  if(Window->Scroll)
-  {
-    /* no need to create it anymore */
-    return TRUE;
-  }
-
-  /* allocate memory for all scrollbars (HORZ, VERT, CONTROL) */
-  Size = 3 * (sizeof(WINDOW_SCROLLINFO));
-  if(!(Window->Scroll = ExAllocatePoolWithTag(PagedPool, Size, TAG_SBARINFO)))
-  {
-    DPRINT1("Unable to allocate memory for scrollbar information for window 0x%x\n", Window->hSelf);
-    return FALSE;
-  }
-
-  RtlZeroMemory(Window->Scroll, Size);
-
-  Result = co_WinPosGetNonClientSize(Window->hSelf,
-                                 &Window->WindowRect,
-                                 &Window->ClientRect);
-
-  for(s = SB_HORZ; s <= SB_VERT; s++)
-  {
-    psbi = IntGetScrollbarInfoFromWindow(Window, s);
-    psbi->cbSize = sizeof(SCROLLBARINFO);
-    for (i = 0; i < CCHILDREN_SCROLLBAR + 1; i++)
-      psbi->rgstate[i] = 0;
-
-    psi = IntGetScrollInfoFromWindow(Window, s);
-    psi->cbSize = sizeof(LPSCROLLINFO);
-    psi->nMax = 100;
-
-    IntGetScrollBarRect(Window, s, &(psbi->rcScrollBar));
-    IntCalculateThumb(Window, s, psbi, psi);
-  }
-
-  return TRUE;
+   PSCROLLBARINFO psbi;
+   LPSCROLLINFO psi;
+   LRESULT Result;
+   ULONG Size, s;
+   INT i;
+
+   ASSERT_REFS_CO(Window);
+
+   if(Window->Scroll)
+   {
+      /* no need to create it anymore */
+      return TRUE;
+   }
+
+   /* allocate memory for all scrollbars (HORZ, VERT, CONTROL) */
+   Size = 3 * (sizeof(WINDOW_SCROLLINFO));
+   if(!(Window->Scroll = ExAllocatePoolWithTag(PagedPool, Size, TAG_SBARINFO)))
+   {
+      DPRINT1("Unable to allocate memory for scrollbar information for window 0x%x\n", Window->hSelf);
+      return FALSE;
+   }
+
+   RtlZeroMemory(Window->Scroll, Size);
+
+   Result = co_WinPosGetNonClientSize(Window->hSelf,
+                                      &Window->WindowRect,
+                                      &Window->ClientRect);
+
+   for(s = SB_HORZ; s <= SB_VERT; s++)
+   {
+      psbi = IntGetScrollbarInfoFromWindow(Window, s);
+      psbi->cbSize = sizeof(SCROLLBARINFO);
+      for (i = 0; i < CCHILDREN_SCROLLBAR + 1; i++)
+         psbi->rgstate[i] = 0;
+
+      psi = IntGetScrollInfoFromWindow(Window, s);
+      psi->cbSize = sizeof(LPSCROLLINFO);
+      psi->nMax = 100;
+
+      IntGetScrollBarRect(Window, s, &(psbi->rcScrollBar));
+      IntCalculateThumb(Window, s, psbi, psi);
+   }
+
+   return TRUE;
 }
 
 BOOL FASTCALL
 IntDestroyScrollBars(PWINDOW_OBJECT Window)
 {
-  if(Window->Scroll)
-  {
-    ExFreePool(Window->Scroll);
-    Window->Scroll = NULL;
-    return TRUE;
-  }
-  return FALSE;
+   if(Window->Scroll)
+   {
+      ExFreePool(Window->Scroll);
+      Window->Scroll = NULL;
+      return TRUE;
+   }
+   return FALSE;
 }
 
 BOOL STDCALL
 IntEnableScrollBar(BOOL Horz, PSCROLLBARINFO Info, UINT wArrows)
 {
-  BOOL Chg = FALSE;
-  switch(wArrows)
-  {
-    case ESB_DISABLE_BOTH:
-      CHANGERGSTATE(SBRG_TOPRIGHTBTN, STATE_SYSTEM_UNAVAILABLE);
-      CHANGERGSTATE(SBRG_BOTTOMLEFTBTN, STATE_SYSTEM_UNAVAILABLE);
-      break;
-    case ESB_DISABLE_RTDN:
-      if(Horz)
-      {
-        CHANGERGSTATE(SBRG_BOTTOMLEFTBTN, STATE_SYSTEM_UNAVAILABLE);
-      }
-      else
-      {
-        CHANGERGSTATE(SBRG_TOPRIGHTBTN, STATE_SYSTEM_UNAVAILABLE);
-      }
-      break;
-    case ESB_DISABLE_LTUP:
-      if(Horz)
-      {
-        CHANGERGSTATE(SBRG_TOPRIGHTBTN, STATE_SYSTEM_UNAVAILABLE);
-      }
-      else
-      {
-        CHANGERGSTATE(SBRG_BOTTOMLEFTBTN, STATE_SYSTEM_UNAVAILABLE);
-      }
-      break;
-    case ESB_ENABLE_BOTH:
-      CHANGERGSTATE(SBRG_TOPRIGHTBTN, 0);
-      CHANGERGSTATE(SBRG_BOTTOMLEFTBTN, 0);
-      break;
-  }
-  return Chg;
+   BOOL Chg = FALSE;
+   switch(wArrows)
+   {
+      case ESB_DISABLE_BOTH:
+         CHANGERGSTATE(SBRG_TOPRIGHTBTN, STATE_SYSTEM_UNAVAILABLE);
+         CHANGERGSTATE(SBRG_BOTTOMLEFTBTN, STATE_SYSTEM_UNAVAILABLE);
+         break;
+      case ESB_DISABLE_RTDN:
+         if(Horz)
+         {
+            CHANGERGSTATE(SBRG_BOTTOMLEFTBTN, STATE_SYSTEM_UNAVAILABLE);
+         }
+         else
+         {
+            CHANGERGSTATE(SBRG_TOPRIGHTBTN, STATE_SYSTEM_UNAVAILABLE);
+         }
+         break;
+      case ESB_DISABLE_LTUP:
+         if(Horz)
+         {
+            CHANGERGSTATE(SBRG_TOPRIGHTBTN, STATE_SYSTEM_UNAVAILABLE);
+         }
+         else
+         {
+            CHANGERGSTATE(SBRG_BOTTOMLEFTBTN, STATE_SYSTEM_UNAVAILABLE);
+         }
+         break;
+      case ESB_ENABLE_BOTH:
+         CHANGERGSTATE(SBRG_TOPRIGHTBTN, 0);
+         CHANGERGSTATE(SBRG_BOTTOMLEFTBTN, 0);
+         break;
+   }
+   return Chg;
 }
 
 
@@ -542,45 +543,45 @@ BOOL
 STDCALL
 NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO psbi)
 {
-  NTSTATUS Status;
-  SCROLLBARINFO sbi;
-  PWINDOW_OBJECT Window;
-  BOOL Ret;
-  DECLARE_RETURN(BOOL);
-  
-  DPRINT("Enter NtUserGetScrollBarInfo\n");
-  UserEnterExclusive();
-
-  Status = MmCopyFromCaller(&sbi, psbi, sizeof(SCROLLBARINFO));
-  if(!NT_SUCCESS(Status) || (sbi.cbSize != sizeof(SCROLLBARINFO)))
-  {
-    SetLastNtError(Status);
-    RETURN(FALSE);
-  }
-
-  if(!(Window = UserGetWindowObject(hWnd)))
-  {
-    RETURN(FALSE);
-  }
-
-  UserRefObjectCo(Window);
-  Ret = co_IntGetScrollBarInfo(Window, idObject, &sbi);
-  UserDerefObjectCo(Window);
-
-  Status = MmCopyToCaller(psbi, &sbi, sizeof(SCROLLBARINFO));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    Ret = FALSE;
-  }
-
-  RETURN( Ret);
-  
+   NTSTATUS Status;
+   SCROLLBARINFO sbi;
+   PWINDOW_OBJECT Window;
+   BOOL Ret;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserGetScrollBarInfo\n");
+   UserEnterExclusive();
+
+   Status = MmCopyFromCaller(&sbi, psbi, sizeof(SCROLLBARINFO));
+   if(!NT_SUCCESS(Status) || (sbi.cbSize != sizeof(SCROLLBARINFO)))
+   {
+      SetLastNtError(Status);
+      RETURN(FALSE);
+   }
+
+   if(!(Window = UserGetWindowObject(hWnd)))
+   {
+      RETURN(FALSE);
+   }
+
+   UserRefObjectCo(Window);
+   Ret = co_IntGetScrollBarInfo(Window, idObject, &sbi);
+   UserDerefObjectCo(Window);
+
+   Status = MmCopyToCaller(psbi, &sbi, sizeof(SCROLLBARINFO));
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      Ret = FALSE;
+   }
+
+   RETURN( Ret);
+
 CLEANUP:
-  DPRINT("Leave NtUserGetScrollBarInfo, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
-  
+   DPRINT("Leave NtUserGetScrollBarInfo, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
+
 }
 
 
@@ -588,233 +589,236 @@ BOOL
 STDCALL
 NtUserGetScrollInfo(HWND hWnd, int fnBar, LPSCROLLINFO lpsi)
 {
-  NTSTATUS Status;
-  PWINDOW_OBJECT Window;
-  SCROLLINFO psi;
-  DWORD sz;
-  BOOL Ret;
-  DECLARE_RETURN(BOOL);
-  
-  DPRINT("Enter NtUserGetScrollInfo\n");
-  UserEnterShared();
-
-  Status = MmCopyFromCaller(&psi.cbSize, &(lpsi->cbSize), sizeof(UINT));
-  if(!NT_SUCCESS(Status) ||
-     !((psi.cbSize == sizeof(SCROLLINFO)) || (psi.cbSize == sizeof(SCROLLINFO) - sizeof(psi.nTrackPos))))
-  {
-    SetLastNtError(Status);
-    RETURN(FALSE);
-  }
-  sz = psi.cbSize;
-  Status = MmCopyFromCaller(&psi, lpsi, sz);
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    RETURN(FALSE);
-  }
-
-  if(!(Window = UserGetWindowObject(hWnd)))
-  {
-    RETURN(FALSE);
-  }
-
-  UserRefObjectCo(Window);   
-  Ret = co_IntGetScrollInfo(Window, fnBar, &psi);
-  UserDerefObjectCo(Window);
-
-  Status = MmCopyToCaller(lpsi, &psi, sz);
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    RETURN( FALSE);
-  }
-
-  RETURN( Ret);
-  
+   NTSTATUS Status;
+   PWINDOW_OBJECT Window;
+   SCROLLINFO psi;
+   DWORD sz;
+   BOOL Ret;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserGetScrollInfo\n");
+   UserEnterShared();
+
+   Status = MmCopyFromCaller(&psi.cbSize, &(lpsi->cbSize), sizeof(UINT));
+   if(!NT_SUCCESS(Status) ||
+         !((psi.cbSize == sizeof(SCROLLINFO)) || (psi.cbSize == sizeof(SCROLLINFO) - sizeof(psi.nTrackPos))))
+   {
+      SetLastNtError(Status);
+      RETURN(FALSE);
+   }
+   sz = psi.cbSize;
+   Status = MmCopyFromCaller(&psi, lpsi, sz);
+   if (!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      RETURN(FALSE);
+   }
+
+   if(!(Window = UserGetWindowObject(hWnd)))
+   {
+      RETURN(FALSE);
+   }
+
+   UserRefObjectCo(Window);
+   Ret = co_IntGetScrollInfo(Window, fnBar, &psi);
+   UserDerefObjectCo(Window);
+
+   Status = MmCopyToCaller(lpsi, &psi, sz);
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      RETURN( FALSE);
+   }
+
+   RETURN( Ret);
+
 CLEANUP:
-  DPRINT("Leave NtUserGetScrollInfo, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;  
+   DPRINT("Leave NtUserGetScrollInfo, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
 BOOL
 STDCALL
 NtUserEnableScrollBar(
-  HWND hWnd,
-  UINT wSBflags,
-  UINT wArrows)
+   HWND hWnd,
+   UINT wSBflags,
+   UINT wArrows)
 {
-  PWINDOW_OBJECT Window = NULL;
-  PSCROLLBARINFO InfoV = NULL, InfoH = NULL;
-  BOOL Chg = FALSE;
-  DECLARE_RETURN(BOOL);
-  
-  DPRINT("Enter NtUserEnableScrollBar\n");
-  UserEnterExclusive();
-
-  if(!(Window = UserGetWindowObject(hWnd)))
-  {
-    RETURN(FALSE);
-  }
-  UserRefObjectCo(Window);
-
-  if(wSBflags == SB_CTL)
-  {
-    /* FIXME Enable or Disable SB Ctrl*/
-    DPRINT1("Enable Scrollbar SB_CTL\n");
-    InfoV = IntGetScrollbarInfoFromWindow(Window, SB_CTL);
-    Chg = IntEnableScrollBar(FALSE, InfoV ,wArrows);
-    /* Chg? Scrollbar is Refresh in user32/controls/scrollbar.c. */
-
-    RETURN(TRUE);
-  }
-
-  if(wSBflags != SB_BOTH && !SBID_IS_VALID(wSBflags))
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    DPRINT1("Trying to set scrollinfo for unknown scrollbar type %d", wSBflags);
-    RETURN(FALSE);
-  }
-
-  if(!co_IntCreateScrollBars(Window))
-    {
-      RETURN( FALSE);
-    }
-
-  switch(wSBflags)
-  {
-    case SB_BOTH:
-      InfoV = IntGetScrollbarInfoFromWindow(Window, SB_VERT);
-      /* fall through */
-    case SB_HORZ:
-      InfoH = IntGetScrollbarInfoFromWindow(Window, SB_HORZ);
-      break;
-    case SB_VERT:
-      InfoV = IntGetScrollbarInfoFromWindow(Window, SB_VERT);
-      break;
-    default:
+   PWINDOW_OBJECT Window = NULL;
+   PSCROLLBARINFO InfoV = NULL, InfoH = NULL;
+   BOOL Chg = FALSE;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserEnableScrollBar\n");
+   UserEnterExclusive();
+
+   if(!(Window = UserGetWindowObject(hWnd)))
+   {
       RETURN(FALSE);
-  }
+   }
+   UserRefObjectCo(Window);
 
-  if(InfoV)
-    Chg = IntEnableScrollBar(FALSE, InfoV, wArrows);
+   if(wSBflags == SB_CTL)
+   {
+      /* FIXME Enable or Disable SB Ctrl*/
+      DPRINT1("Enable Scrollbar SB_CTL\n");
+      InfoV = IntGetScrollbarInfoFromWindow(Window, SB_CTL);
+      Chg = IntEnableScrollBar(FALSE, InfoV ,wArrows);
+      /* Chg? Scrollbar is Refresh in user32/controls/scrollbar.c. */
 
-  if(InfoH)
-    Chg = (IntEnableScrollBar(TRUE, InfoH, wArrows) || Chg);
+      RETURN(TRUE);
+   }
+
+   if(wSBflags != SB_BOTH && !SBID_IS_VALID(wSBflags))
+   {
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      DPRINT1("Trying to set scrollinfo for unknown scrollbar type %d", wSBflags);
+      RETURN(FALSE);
+   }
+
+   if(!co_IntCreateScrollBars(Window))
+   {
+      RETURN( FALSE);
+   }
+
+   switch(wSBflags)
+   {
+      case SB_BOTH:
+         InfoV = IntGetScrollbarInfoFromWindow(Window, SB_VERT);
+         /* fall through */
+      case SB_HORZ:
+         InfoH = IntGetScrollbarInfoFromWindow(Window, SB_HORZ);
+         break;
+      case SB_VERT:
+         InfoV = IntGetScrollbarInfoFromWindow(Window, SB_VERT);
+         break;
+      default:
+         RETURN(FALSE);
+   }
+
+   if(InfoV)
+      Chg = IntEnableScrollBar(FALSE, InfoV, wArrows);
+
+   if(InfoH)
+      Chg = (IntEnableScrollBar(TRUE, InfoH, wArrows) || Chg);
+
+   //if(Chg && (Window->Style & WS_VISIBLE))
+   /* FIXME - repaint scrollbars */
 
-  //if(Chg && (Window->Style & WS_VISIBLE))
-    /* FIXME - repaint scrollbars */
+   RETURN( TRUE);
 
-  RETURN( TRUE);
-  
 CLEANUP:
-  if (Window) UserDerefObjectCo(Window);
+   if (Window)
+      UserDerefObjectCo(Window);
 
-  DPRINT("Leave NtUserEnableScrollBar, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserEnableScrollBar, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 BOOL
 STDCALL
 NtUserSetScrollBarInfo(
-  HWND hWnd,
-  LONG idObject,
-  SETSCROLLBARINFO *info)
+   HWND hWnd,
+   LONG idObject,
+   SETSCROLLBARINFO *info)
 {
-  PWINDOW_OBJECT Window = NULL;
-  SETSCROLLBARINFO Safeinfo;
-  PSCROLLBARINFO sbi;
-  LPSCROLLINFO psi;
-  NTSTATUS Status;
-  LONG Obj;
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserSetScrollBarInfo\n");
-  UserEnterExclusive();
-
-  if(!(Window = UserGetWindowObject(hWnd)))
-  {
-    RETURN( FALSE);
-  }
-  UserRefObjectCo(Window);
-
-  Obj = SBOBJ_TO_SBID(idObject);
-  if(!SBID_IS_VALID(Obj))
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    DPRINT1("Trying to set scrollinfo for unknown scrollbar type %d", Obj);
-    RETURN( FALSE);
-  }
-
-  if(!co_IntCreateScrollBars(Window))
-    {
+   PWINDOW_OBJECT Window = NULL;
+   SETSCROLLBARINFO Safeinfo;
+   PSCROLLBARINFO sbi;
+   LPSCROLLINFO psi;
+   NTSTATUS Status;
+   LONG Obj;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserSetScrollBarInfo\n");
+   UserEnterExclusive();
+
+   if(!(Window = UserGetWindowObject(hWnd)))
+   {
+      RETURN( FALSE);
+   }
+   UserRefObjectCo(Window);
+
+   Obj = SBOBJ_TO_SBID(idObject);
+   if(!SBID_IS_VALID(Obj))
+   {
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      DPRINT1("Trying to set scrollinfo for unknown scrollbar type %d", Obj);
+      RETURN( FALSE);
+   }
+
+   if(!co_IntCreateScrollBars(Window))
+   {
+      RETURN(FALSE);
+   }
+
+   Status = MmCopyFromCaller(&Safeinfo, info, sizeof(SETSCROLLBARINFO));
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
       RETURN(FALSE);
-    }
+   }
 
-  Status = MmCopyFromCaller(&Safeinfo, info, sizeof(SETSCROLLBARINFO));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    RETURN(FALSE);
-  }
+   sbi = IntGetScrollbarInfoFromWindow(Window, Obj);
+   psi = IntGetScrollInfoFromWindow(Window, Obj);
 
-  sbi = IntGetScrollbarInfoFromWindow(Window, Obj);
-  psi = IntGetScrollInfoFromWindow(Window, Obj);
+   psi->nTrackPos = Safeinfo.nTrackPos;
+   sbi->reserved = Safeinfo.reserved;
+   RtlCopyMemory(&sbi->rgstate, &Safeinfo.rgstate, sizeof(Safeinfo.rgstate));
 
-  psi->nTrackPos = Safeinfo.nTrackPos;
-  sbi->reserved = Safeinfo.reserved;
-  RtlCopyMemory(&sbi->rgstate, &Safeinfo.rgstate, sizeof(Safeinfo.rgstate));
+   RETURN(TRUE);
 
-  RETURN(TRUE);
-  
 CLEANUP:
-  if (Window) UserDerefObjectCo(Window);
+   if (Window)
+      UserDerefObjectCo(Window);
 
-  DPRINT("Leave NtUserSetScrollBarInfo, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserSetScrollBarInfo, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 DWORD
 STDCALL
 NtUserSetScrollInfo(
-  HWND hWnd,
-  int fnBar,
-  LPCSCROLLINFO lpsi,
-  BOOL bRedraw)
+   HWND hWnd,
+   int fnBar,
+   LPCSCROLLINFO lpsi,
+   BOOL bRedraw)
 {
-  PWINDOW_OBJECT Window = NULL;
-  NTSTATUS Status;
-  SCROLLINFO ScrollInfo;
-  DECLARE_RETURN(DWORD);
-  
-  DPRINT("Enter NtUserSetScrollInfo\n");
-  UserEnterExclusive();
-
-  if(!(Window = UserGetWindowObject(hWnd)))
-  {
-    RETURN( 0);
-  }
-  UserRefObjectCo(Window);
-
-  Status = MmCopyFromCaller(&ScrollInfo, lpsi, sizeof(SCROLLINFO) - sizeof(ScrollInfo.nTrackPos));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    RETURN( 0);
-  }
-
-  RETURN(co_IntSetScrollInfo(Window, fnBar, &ScrollInfo, bRedraw));
+   PWINDOW_OBJECT Window = NULL;
+   NTSTATUS Status;
+   SCROLLINFO ScrollInfo;
+   DECLARE_RETURN(DWORD);
+
+   DPRINT("Enter NtUserSetScrollInfo\n");
+   UserEnterExclusive();
+
+   if(!(Window = UserGetWindowObject(hWnd)))
+   {
+      RETURN( 0);
+   }
+   UserRefObjectCo(Window);
+
+   Status = MmCopyFromCaller(&ScrollInfo, lpsi, sizeof(SCROLLINFO) - sizeof(ScrollInfo.nTrackPos));
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      RETURN( 0);
+   }
+
+   RETURN(co_IntSetScrollInfo(Window, fnBar, &ScrollInfo, bRedraw));
 
 CLEANUP:
-  if (Window) UserDerefObjectCo(Window); 
-   
-  DPRINT("Leave NtUserSetScrollInfo, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
-  
+   if (Window)
+      UserDerefObjectCo(Window);
+
+   DPRINT("Leave NtUserSetScrollInfo, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
+
 }
 
 /* Ported from WINE20020904 (SCROLL_ShowScrollBar) */
@@ -827,27 +831,27 @@ co_UserShowScrollBar(PWINDOW_OBJECT Window, int wBar, DWORD bShow)
 
    switch(wBar)
    {
-     case SB_HORZ:
-       Style = WS_HSCROLL;
-       break;
-     case SB_VERT:
-       Style = WS_VSCROLL;
-       break;
-     case SB_BOTH:
-       Style = WS_HSCROLL | WS_VSCROLL;
-       break;
-     case SB_CTL:
-       Style = 0;
-       break;
-     default:
-       SetLastWin32Error(ERROR_INVALID_PARAMETER);
-       return( FALSE);
-   }
-
-  if(!co_IntCreateScrollBars(Window))
-    {
+      case SB_HORZ:
+         Style = WS_HSCROLL;
+         break;
+      case SB_VERT:
+         Style = WS_VSCROLL;
+         break;
+      case SB_BOTH:
+         Style = WS_HSCROLL | WS_VSCROLL;
+         break;
+      case SB_CTL:
+         Style = 0;
+         break;
+      default:
+         SetLastWin32Error(ERROR_INVALID_PARAMETER);
+         return( FALSE);
+   }
+
+   if(!co_IntCreateScrollBars(Window))
+   {
       return( FALSE);
-    }
+   }
 
    if (wBar == SB_CTL)
    {
@@ -859,23 +863,23 @@ co_UserShowScrollBar(PWINDOW_OBJECT Window, int wBar, DWORD bShow)
 
    OldStyle = Window->Style;
    if(bShow)
-     Window->Style |= Style;
+      Window->Style |= Style;
    else
-     Window->Style &= ~Style;
+      Window->Style &= ~Style;
 
    if(Window->Style != OldStyle)
    {
-     if(Window->Style & WS_HSCROLL)
-       IntUpdateSBInfo(Window, SB_HORZ);
-     if(Window->Style & WS_VSCROLL)
-       IntUpdateSBInfo(Window, SB_VERT);
+      if(Window->Style & WS_HSCROLL)
+         IntUpdateSBInfo(Window, SB_HORZ);
+      if(Window->Style & WS_VSCROLL)
+         IntUpdateSBInfo(Window, SB_VERT);
 
-     if(Window->Style & WS_VISIBLE)
-     {
-       /* Frame has been changed, let the window redraw itself */
-       co_WinPosSetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
-          SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING);
-     }
+      if(Window->Style & WS_VISIBLE)
+      {
+         /* Frame has been changed, let the window redraw itself */
+         co_WinPosSetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
+                               SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING);
+      }
    }
 
    return( TRUE);
@@ -888,21 +892,21 @@ NtUserShowScrollBar(HWND hWnd, int wBar, DWORD bShow)
    PWINDOW_OBJECT Window;
    DECLARE_RETURN(DWORD);
    DWORD ret;
-   
+
    DPRINT("Enter NtUserShowScrollBar\n");
    UserEnterExclusive();
-   
+
    if (!(Window = UserGetWindowObject(hWnd)))
    {
       RETURN(0);
    }
-   
+
    UserRefObjectCo(Window);
    ret = co_UserShowScrollBar(Window, wBar, bShow);
    UserDerefObjectCo(Window);
-   
+
    RETURN(ret);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserShowScrollBar,  ret%i\n",_ret_);
    UserLeave();
index e0d2101..8c18e9d 100644 (file)
@@ -39,82 +39,82 @@ NTSTATUS INTERNAL_CALL
 IntUserCreateSharedSectionPool(IN ULONG MaximumPoolSize,
                                IN PSHARED_SECTION_POOL *SharedSectionPool)
 {
-  PSHARED_SECTION_POOL Pool;
-  ULONG PoolStructSize;
+   PSHARED_SECTION_POOL Pool;
+   ULONG PoolStructSize;
 
-  ASSERT(SharedSectionPool);
+   ASSERT(SharedSectionPool);
 
-  PoolStructSize = ROUND_UP(sizeof(SHARED_SECTION_POOL), PAGE_SIZE);
-  Pool = ExAllocatePoolWithTag(NonPagedPool,
-                               PoolStructSize,
-                               TAG_SSECTPOOL);
-  if(Pool != NULL)
-  {
-    RtlZeroMemory(Pool, PoolStructSize);
+   PoolStructSize = ROUND_UP(sizeof(SHARED_SECTION_POOL), PAGE_SIZE);
+   Pool = ExAllocatePoolWithTag(NonPagedPool,
+                                PoolStructSize,
+                                TAG_SSECTPOOL);
+   if(Pool != NULL)
+   {
+      RtlZeroMemory(Pool, PoolStructSize);
 
-    /* initialize the session heap */
-    ExInitializeFastMutex(&Pool->Lock);
-    Pool->PoolSize = ROUND_UP(MaximumPoolSize, PAGE_SIZE);
-    Pool->PoolFree = Pool->PoolSize;
-    Pool->SharedSectionCount = 0;
-    Pool->SectionsArray.Next = NULL;
-    Pool->SectionsArray.nEntries = ((PoolStructSize - sizeof(SHARED_SECTION_POOL)) /
-                                    sizeof(SHARED_SECTION)) - 1;
+      /* initialize the session heap */
+      ExInitializeFastMutex(&Pool->Lock);
+      Pool->PoolSize = ROUND_UP(MaximumPoolSize, PAGE_SIZE);
+      Pool->PoolFree = Pool->PoolSize;
+      Pool->SharedSectionCount = 0;
+      Pool->SectionsArray.Next = NULL;
+      Pool->SectionsArray.nEntries = ((PoolStructSize - sizeof(SHARED_SECTION_POOL)) /
+                                      sizeof(SHARED_SECTION)) - 1;
 
-    ASSERT(Pool->SectionsArray.nEntries > 0);
+      ASSERT(Pool->SectionsArray.nEntries > 0);
 
-    *SharedSectionPool = Pool;
+      *SharedSectionPool = Pool;
 
-    return STATUS_SUCCESS;
-  }
+      return STATUS_SUCCESS;
+   }
 
-  return STATUS_INSUFFICIENT_RESOURCES;
+   return STATUS_INSUFFICIENT_RESOURCES;
 }
 
 
 VOID INTERNAL_CALL
 IntUserFreeSharedSectionPool(IN PSHARED_SECTION_POOL SharedSectionPool)
 {
-  PSHARED_SECTIONS_ARRAY Array, OldArray;
-  PSHARED_SECTION SharedSection, LastSharedSection;
+   PSHARED_SECTIONS_ARRAY Array, OldArray;
+   PSHARED_SECTION SharedSection, LastSharedSection;
 
-  ASSERT(SharedSectionPool);
+   ASSERT(SharedSectionPool);
 
-  Array = &SharedSectionPool->SectionsArray;
+   Array = &SharedSectionPool->SectionsArray;
 
-  ExAcquireFastMutex(&SharedSectionPool->Lock);
-  while(SharedSectionPool->SharedSectionCount > 0 && Array != NULL)
-  {
-    for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
-        SharedSection != LastSharedSection && SharedSectionPool->SharedSectionCount > 0;
-        SharedSection++)
-    {
-      if(SharedSection->SectionObject != NULL)
+   ExAcquireFastMutex(&SharedSectionPool->Lock);
+   while(SharedSectionPool->SharedSectionCount > 0 && Array != NULL)
+   {
+      for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
+            SharedSection != LastSharedSection && SharedSectionPool->SharedSectionCount > 0;
+            SharedSection++)
       {
-        ASSERT(SharedSection->SystemMappedBase);
+         if(SharedSection->SectionObject != NULL)
+         {
+            ASSERT(SharedSection->SystemMappedBase);
 
-        /* FIXME - use MmUnmapViewInSessionSpace() once implemented! */
-        MmUnmapViewInSystemSpace(SharedSection->SystemMappedBase);
-        /* dereference the keep-alive reference so the section get's deleted */
-        ObDereferenceObject(SharedSection->SectionObject);
+            /* FIXME - use MmUnmapViewInSessionSpace() once implemented! */
+            MmUnmapViewInSystemSpace(SharedSection->SystemMappedBase);
+            /* dereference the keep-alive reference so the section get's deleted */
+            ObDereferenceObject(SharedSection->SectionObject);
 
-        SharedSectionPool->SharedSectionCount--;
+            SharedSectionPool->SharedSectionCount--;
+         }
       }
-    }
 
-    OldArray = Array;
-    Array = Array->Next;
+      OldArray = Array;
+      Array = Array->Next;
 
-    /* all shared sections in this array were freed, link the following array to
-       the main session heap and free this array */
-    SharedSectionPool->SectionsArray.Next = Array;
-    ExFreePool(OldArray);
-  }
+      /* all shared sections in this array were freed, link the following array to
+         the main session heap and free this array */
+      SharedSectionPool->SectionsArray.Next = Array;
+      ExFreePool(OldArray);
+   }
 
-  ASSERT(SharedSectionPool->SectionsArray.Next == NULL);
-  ASSERT(SharedSectionPool->SharedSectionCount == 0);
+   ASSERT(SharedSectionPool->SectionsArray.Next == NULL);
+   ASSERT(SharedSectionPool->SharedSectionCount == 0);
 
-  ExReleaseFastMutex(&SharedSectionPool->Lock);
+   ExReleaseFastMutex(&SharedSectionPool->Lock);
 }
 
 
@@ -123,120 +123,120 @@ IntUserCreateSharedSection(IN PSHARED_SECTION_POOL SharedSectionPool,
                            IN OUT PVOID *SystemMappedBase,
                            IN OUT ULONG *SharedSectionSize)
 {
-  PSHARED_SECTIONS_ARRAY Array, LastArray;
-  PSHARED_SECTION FreeSharedSection, SharedSection, LastSharedSection;
-  LARGE_INTEGER SectionSize;
-  ULONG Size;
-  NTSTATUS Status;
-
-  ASSERT(SharedSectionPool && SharedSectionSize && (*SharedSectionSize) > 0 && SystemMappedBase);
-
-  FreeSharedSection = NULL;
-
-  Size = ROUND_UP(*SharedSectionSize, PAGE_SIZE);
-
-  ExAcquireFastMutex(&SharedSectionPool->Lock);
-
-  if(Size > SharedSectionPool->PoolFree)
-  {
-    ExReleaseFastMutex(&SharedSectionPool->Lock);
-    DPRINT1("Shared Section Pool limit (0x%x KB) reached, attempted to allocate a 0x%x KB shared section!\n",
-            SharedSectionPool->PoolSize / 1024, (*SharedSectionSize) / 1024);
-    return STATUS_INSUFFICIENT_RESOURCES;
-  }
-
-  /* walk the array to find a free entry */
-  for(Array = &SharedSectionPool->SectionsArray, LastArray = Array;
-      Array != NULL && FreeSharedSection == NULL;
-      Array = Array->Next)
-  {
-    LastArray = Array;
-
-    for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
-        SharedSection != LastSharedSection;
-        SharedSection++)
-    {
-      if(SharedSection->SectionObject == NULL)
+   PSHARED_SECTIONS_ARRAY Array, LastArray;
+   PSHARED_SECTION FreeSharedSection, SharedSection, LastSharedSection;
+   LARGE_INTEGER SectionSize;
+   ULONG Size;
+   NTSTATUS Status;
+
+   ASSERT(SharedSectionPool && SharedSectionSize && (*SharedSectionSize) > 0 && SystemMappedBase);
+
+   FreeSharedSection = NULL;
+
+   Size = ROUND_UP(*SharedSectionSize, PAGE_SIZE);
+
+   ExAcquireFastMutex(&SharedSectionPool->Lock);
+
+   if(Size > SharedSectionPool->PoolFree)
+   {
+      ExReleaseFastMutex(&SharedSectionPool->Lock);
+      DPRINT1("Shared Section Pool limit (0x%x KB) reached, attempted to allocate a 0x%x KB shared section!\n",
+              SharedSectionPool->PoolSize / 1024, (*SharedSectionSize) / 1024);
+      return STATUS_INSUFFICIENT_RESOURCES;
+   }
+
+   /* walk the array to find a free entry */
+   for(Array = &SharedSectionPool->SectionsArray, LastArray = Array;
+         Array != NULL && FreeSharedSection == NULL;
+         Array = Array->Next)
+   {
+      LastArray = Array;
+
+      for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
+            SharedSection != LastSharedSection;
+            SharedSection++)
       {
-        FreeSharedSection = SharedSection;
-        break;
+         if(SharedSection->SectionObject == NULL)
+         {
+            FreeSharedSection = SharedSection;
+            break;
+         }
       }
-    }
 
-    if(Array->Next != NULL)
-    {
-      LastArray = Array;
-    }
-  }
+      if(Array->Next != NULL)
+      {
+         LastArray = Array;
+      }
+   }
 
-  ASSERT(LastArray);
+   ASSERT(LastArray);
 
-  if(FreeSharedSection == NULL)
-  {
-    ULONG nNewEntries;
-    PSHARED_SECTIONS_ARRAY NewArray;
+   if(FreeSharedSection == NULL)
+   {
+      ULONG nNewEntries;
+      PSHARED_SECTIONS_ARRAY NewArray;
 
-    ASSERT(LastArray->Next == NULL);
+      ASSERT(LastArray->Next == NULL);
 
-    /* couldn't find a free entry in the array, extend the array */
+      /* couldn't find a free entry in the array, extend the array */
 
-    nNewEntries = ((PAGE_SIZE - sizeof(SHARED_SECTIONS_ARRAY)) / sizeof(SHARED_SECTION)) + 1;
-    NewArray = ExAllocatePoolWithTag(NonPagedPool,
-                                     sizeof(SHARED_SECTIONS_ARRAY) + ((nNewEntries - 1) *
-                                                                      sizeof(SHARED_SECTION)),
-                                     TAG_SSECTPOOL);
-    if(NewArray == NULL)
-    {
-      ExReleaseFastMutex(&SharedSectionPool->Lock);
-      DPRINT1("Failed to allocate new array for shared sections!\n");
-      return STATUS_INSUFFICIENT_RESOURCES;
-    }
-
-    NewArray->nEntries = nNewEntries;
-    NewArray->Next = NULL;
-    LastArray->Next = NewArray;
-
-    Array = NewArray;
-    FreeSharedSection = &Array->SharedSection[0];
-  }
-
-  ASSERT(FreeSharedSection);
-
-  /* now allocate a real section */
-
-  SectionSize.QuadPart = Size;
-  Status = MmCreateSection(&FreeSharedSection->SectionObject,
-                           SECTION_ALL_ACCESS,
-                           NULL,
-                           &SectionSize,
-                           PAGE_EXECUTE_READWRITE,
-                           SEC_COMMIT,
-                           NULL,
-                           NULL);
-  if(NT_SUCCESS(Status))
-  {
-    Status = MmMapViewInSystemSpace(FreeSharedSection->SectionObject,
-                                    &FreeSharedSection->SystemMappedBase,
-                                    &FreeSharedSection->ViewSize);
-    if(NT_SUCCESS(Status))
-    {
-      (*SharedSectionSize) -= Size;
-      SharedSectionPool->SharedSectionCount++;
-
-      *SystemMappedBase = FreeSharedSection->SystemMappedBase;
-      *SharedSectionSize = FreeSharedSection->ViewSize;
-    }
-    else
-    {
-      ObDereferenceObject(FreeSharedSection->SectionObject);
-      FreeSharedSection->SectionObject = NULL;
-      DPRINT1("Failed to map the shared section into system space! Status 0x%x\n", Status);
-    }
-  }
-
-  ExReleaseFastMutex(&SharedSectionPool->Lock);
-
-  return Status;
+      nNewEntries = ((PAGE_SIZE - sizeof(SHARED_SECTIONS_ARRAY)) / sizeof(SHARED_SECTION)) + 1;
+      NewArray = ExAllocatePoolWithTag(NonPagedPool,
+                                       sizeof(SHARED_SECTIONS_ARRAY) + ((nNewEntries - 1) *
+                                                                        sizeof(SHARED_SECTION)),
+                                       TAG_SSECTPOOL);
+      if(NewArray == NULL)
+      {
+         ExReleaseFastMutex(&SharedSectionPool->Lock);
+         DPRINT1("Failed to allocate new array for shared sections!\n");
+         return STATUS_INSUFFICIENT_RESOURCES;
+      }
+
+      NewArray->nEntries = nNewEntries;
+      NewArray->Next = NULL;
+      LastArray->Next = NewArray;
+
+      Array = NewArray;
+      FreeSharedSection = &Array->SharedSection[0];
+   }
+
+   ASSERT(FreeSharedSection);
+
+   /* now allocate a real section */
+
+   SectionSize.QuadPart = Size;
+   Status = MmCreateSection(&FreeSharedSection->SectionObject,
+                            SECTION_ALL_ACCESS,
+                            NULL,
+                            &SectionSize,
+                            PAGE_EXECUTE_READWRITE,
+                            SEC_COMMIT,
+                            NULL,
+                            NULL);
+   if(NT_SUCCESS(Status))
+   {
+      Status = MmMapViewInSystemSpace(FreeSharedSection->SectionObject,
+                                      &FreeSharedSection->SystemMappedBase,
+                                      &FreeSharedSection->ViewSize);
+      if(NT_SUCCESS(Status))
+      {
+         (*SharedSectionSize) -= Size;
+         SharedSectionPool->SharedSectionCount++;
+
+         *SystemMappedBase = FreeSharedSection->SystemMappedBase;
+         *SharedSectionSize = FreeSharedSection->ViewSize;
+      }
+      else
+      {
+         ObDereferenceObject(FreeSharedSection->SectionObject);
+         FreeSharedSection->SectionObject = NULL;
+         DPRINT1("Failed to map the shared section into system space! Status 0x%x\n", Status);
+      }
+   }
+
+   ExReleaseFastMutex(&SharedSectionPool->Lock);
+
+   return Status;
 }
 
 
@@ -244,52 +244,52 @@ NTSTATUS INTERNAL_CALL
 InUserDeleteSharedSection(PSHARED_SECTION_POOL SharedSectionPool,
                           PVOID SystemMappedBase)
 {
-  PSHARED_SECTIONS_ARRAY Array;
-  PSECTION_OBJECT SectionObject;
-  PSHARED_SECTION SharedSection, LastSharedSection;
-  NTSTATUS Status;
-
-  ASSERT(SharedSectionPool && SystemMappedBase);
-
-  SectionObject = NULL;
-
-  ExAcquireFastMutex(&SharedSectionPool->Lock);
-
-  for(Array = &SharedSectionPool->SectionsArray;
-      Array != NULL && SectionObject == NULL;
-      Array = Array->Next)
-  {
-    for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
-        SharedSection != LastSharedSection;
-        SharedSection++)
-    {
-      if(SharedSection->SystemMappedBase == SystemMappedBase)
-      {
-        SectionObject = SharedSection->SectionObject;
-        SharedSection->SectionObject = NULL;
-        SharedSection->SystemMappedBase = NULL;
+   PSHARED_SECTIONS_ARRAY Array;
+   PSECTION_OBJECT SectionObject;
+   PSHARED_SECTION SharedSection, LastSharedSection;
+   NTSTATUS Status;
+
+   ASSERT(SharedSectionPool && SystemMappedBase);
+
+   SectionObject = NULL;
+
+   ExAcquireFastMutex(&SharedSectionPool->Lock);
 
-        ASSERT(SharedSectionPool->SharedSectionCount > 0);
-        SharedSectionPool->SharedSectionCount--;
-        break;
+   for(Array = &SharedSectionPool->SectionsArray;
+         Array != NULL && SectionObject == NULL;
+         Array = Array->Next)
+   {
+      for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
+            SharedSection != LastSharedSection;
+            SharedSection++)
+      {
+         if(SharedSection->SystemMappedBase == SystemMappedBase)
+         {
+            SectionObject = SharedSection->SectionObject;
+            SharedSection->SectionObject = NULL;
+            SharedSection->SystemMappedBase = NULL;
+
+            ASSERT(SharedSectionPool->SharedSectionCount > 0);
+            SharedSectionPool->SharedSectionCount--;
+            break;
+         }
       }
-    }
-  }
-
-  ExReleaseFastMutex(&SharedSectionPool->Lock);
-
-  if(SectionObject != NULL)
-  {
-    Status = MmUnmapViewInSystemSpace(SystemMappedBase);
-    ObDereferenceObject(SectionObject);
-  }
-  else
-  {
-    DPRINT1("Couldn't find and delete a shared section with SystemMappedBase=0x%x!\n", SystemMappedBase);
-    Status = STATUS_UNSUCCESSFUL;
-  }
-
-  return Status;
+   }
+
+   ExReleaseFastMutex(&SharedSectionPool->Lock);
+
+   if(SectionObject != NULL)
+   {
+      Status = MmUnmapViewInSystemSpace(SystemMappedBase);
+      ObDereferenceObject(SectionObject);
+   }
+   else
+   {
+      DPRINT1("Couldn't find and delete a shared section with SystemMappedBase=0x%x!\n", SystemMappedBase);
+      Status = STATUS_UNSUCCESSFUL;
+   }
+
+   return Status;
 }
 
 
@@ -302,67 +302,67 @@ IntUserMapSharedSection(IN PSHARED_SECTION_POOL SharedSectionPool,
                         IN PULONG ViewSize  OPTIONAL,
                         IN BOOLEAN ReadOnly)
 {
-  PSHARED_SECTIONS_ARRAY Array;
-  PSECTION_OBJECT SectionObject;
-  PSHARED_SECTION SharedSection, LastSharedSection;
-  NTSTATUS Status;
-
-  ASSERT(SharedSectionPool && Process && SystemMappedBase && UserMappedBase);
-
-  SectionObject = NULL;
-  SharedSection = NULL;
-
-  ExAcquireFastMutex(&SharedSectionPool->Lock);
-
-  for(Array = &SharedSectionPool->SectionsArray;
-      Array != NULL && SectionObject == NULL;
-      Array = Array->Next)
-  {
-    for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
-        SharedSection != LastSharedSection;
-        SharedSection++)
-    {
-      if(SharedSection->SystemMappedBase == SystemMappedBase)
+   PSHARED_SECTIONS_ARRAY Array;
+   PSECTION_OBJECT SectionObject;
+   PSHARED_SECTION SharedSection, LastSharedSection;
+   NTSTATUS Status;
+
+   ASSERT(SharedSectionPool && Process && SystemMappedBase && UserMappedBase);
+
+   SectionObject = NULL;
+   SharedSection = NULL;
+
+   ExAcquireFastMutex(&SharedSectionPool->Lock);
+
+   for(Array = &SharedSectionPool->SectionsArray;
+         Array != NULL && SectionObject == NULL;
+         Array = Array->Next)
+   {
+      for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
+            SharedSection != LastSharedSection;
+            SharedSection++)
       {
-        SectionObject = SharedSection->SectionObject;
-        break;
+         if(SharedSection->SystemMappedBase == SystemMappedBase)
+         {
+            SectionObject = SharedSection->SectionObject;
+            break;
+         }
       }
-    }
-  }
-
-  if(SectionObject != NULL)
-  {
-    ULONG RealViewSize = (ViewSize ? min(*ViewSize, SharedSection->ViewSize) : SharedSection->ViewSize);
-
-    ObReferenceObjectByPointer(SectionObject,
-                               (ReadOnly ? SECTION_MAP_READ : SECTION_MAP_READ | SECTION_MAP_WRITE),
-                               NULL,
-                               KernelMode);
-
-    Status = MmMapViewOfSection(SectionObject,
-                                Process,
-                                UserMappedBase,
-                                0,
-                                0,
-                                SectionOffset,
-                                &RealViewSize,
-                                ViewUnmap, /* not sure if we should inherit it... */
-                                MEM_COMMIT,
-                                (ReadOnly ? PAGE_READONLY : PAGE_READWRITE));
-    if(!NT_SUCCESS(Status))
-    {
-      DPRINT1("Failed to map shared section (readonly=%d) into user memory! Status: 0x%x\n", ReadOnly, Status);
-    }
-  }
-  else
-  {
-    DPRINT1("Couldn't find and map a shared section with SystemMappedBase=0x%x!\n", SystemMappedBase);
-    Status = STATUS_UNSUCCESSFUL;
-  }
-
-  ExReleaseFastMutex(&SharedSectionPool->Lock);
-
-  return Status;
+   }
+
+   if(SectionObject != NULL)
+   {
+      ULONG RealViewSize = (ViewSize ? min(*ViewSize, SharedSection->ViewSize) : SharedSection->ViewSize);
+
+      ObReferenceObjectByPointer(SectionObject,
+                                 (ReadOnly ? SECTION_MAP_READ : SECTION_MAP_READ | SECTION_MAP_WRITE),
+                                 NULL,
+                                 KernelMode);
+
+      Status = MmMapViewOfSection(SectionObject,
+                                  Process,
+                                  UserMappedBase,
+                                  0,
+                                  0,
+                                  SectionOffset,
+                                  &RealViewSize,
+                                  ViewUnmap, /* not sure if we should inherit it... */
+                                  MEM_COMMIT,
+                                  (ReadOnly ? PAGE_READONLY : PAGE_READWRITE));
+      if(!NT_SUCCESS(Status))
+      {
+         DPRINT1("Failed to map shared section (readonly=%d) into user memory! Status: 0x%x\n", ReadOnly, Status);
+      }
+   }
+   else
+   {
+      DPRINT1("Couldn't find and map a shared section with SystemMappedBase=0x%x!\n", SystemMappedBase);
+      Status = STATUS_UNSUCCESSFUL;
+   }
+
+   ExReleaseFastMutex(&SharedSectionPool->Lock);
+
+   return Status;
 }
 
 
@@ -372,50 +372,50 @@ IntUserUnMapSharedSection(IN PSHARED_SECTION_POOL SharedSectionPool,
                           IN PVOID SystemMappedBase,
                           IN PVOID UserMappedBase)
 {
-  PSHARED_SECTIONS_ARRAY Array;
-  PSECTION_OBJECT SectionObject;
-  PSHARED_SECTION SharedSection, LastSharedSection;
-  NTSTATUS Status;
-
-  ASSERT(SharedSectionPool && Process && SystemMappedBase && UserMappedBase);
-
-  SectionObject = NULL;
-
-  ExAcquireFastMutex(&SharedSectionPool->Lock);
-
-  for(Array = &SharedSectionPool->SectionsArray;
-      Array != NULL && SectionObject == NULL;
-      Array = Array->Next)
-  {
-    for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
-        SharedSection != LastSharedSection;
-        SharedSection++)
-    {
-      if(SharedSection->SystemMappedBase == SystemMappedBase)
+   PSHARED_SECTIONS_ARRAY Array;
+   PSECTION_OBJECT SectionObject;
+   PSHARED_SECTION SharedSection, LastSharedSection;
+   NTSTATUS Status;
+
+   ASSERT(SharedSectionPool && Process && SystemMappedBase && UserMappedBase);
+
+   SectionObject = NULL;
+
+   ExAcquireFastMutex(&SharedSectionPool->Lock);
+
+   for(Array = &SharedSectionPool->SectionsArray;
+         Array != NULL && SectionObject == NULL;
+         Array = Array->Next)
+   {
+      for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
+            SharedSection != LastSharedSection;
+            SharedSection++)
+      {
+         if(SharedSection->SystemMappedBase == SystemMappedBase)
+         {
+            SectionObject = SharedSection->SectionObject;
+            break;
+         }
+      }
+   }
+
+   ExReleaseFastMutex(&SharedSectionPool->Lock);
+
+   if(SectionObject != NULL)
+   {
+      Status = MmUnmapViewOfSection(Process,
+                                    UserMappedBase);
+      ObDereferenceObject(SectionObject);
+      if(!NT_SUCCESS(Status))
       {
-        SectionObject = SharedSection->SectionObject;
-        break;
+         DPRINT1("Failed to unmap shared section UserMappedBase=0x%x! Status: 0x%x\n", UserMappedBase, Status);
       }
-    }
-  }
-
-  ExReleaseFastMutex(&SharedSectionPool->Lock);
-
-  if(SectionObject != NULL)
-  {
-    Status = MmUnmapViewOfSection(Process,
-                                  UserMappedBase);
-    ObDereferenceObject(SectionObject);
-    if(!NT_SUCCESS(Status))
-    {
-      DPRINT1("Failed to unmap shared section UserMappedBase=0x%x! Status: 0x%x\n", UserMappedBase, Status);
-    }
-  }
-  else
-  {
-    DPRINT1("Couldn't find and unmap a shared section with SystemMappedBase=0x%x!\n", SystemMappedBase);
-    Status = STATUS_UNSUCCESSFUL;
-  }
-
-  return Status;
+   }
+   else
+   {
+      DPRINT1("Couldn't find and unmap a shared section with SystemMappedBase=0x%x!\n", SystemMappedBase);
+      Status = STATUS_UNSUCCESSFUL;
+   }
+
+   return Status;
 }
index 20cedf2..567287d 100644 (file)
 DWORD
 STDCALL
 NtUserActivateKeyboardLayout(
-  DWORD Unknown0,
-  DWORD Unknown1)
+   DWORD Unknown0,
+   DWORD Unknown1)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserAttachThreadInput(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserBitBltSysBmp(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5,
-  DWORD Unknown6,
-  DWORD Unknown7)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3,
+   DWORD Unknown4,
+   DWORD Unknown5,
+   DWORD Unknown6,
+   DWORD Unknown7)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserCallHwnd(
-  DWORD Unknown0,
-  DWORD Unknown1)
+   DWORD Unknown0,
+   DWORD Unknown1)
 {
-  switch (Unknown0) {
-    case HWND_ROUTINE_REGISTERSHELLHOOKWINDOW:
-      if (IntIsWindow((HWND) Unknown1))
-        return IntRegisterShellHookWindow((HWND) Unknown1);
-      return FALSE;
-      break;
-    case HWND_ROUTINE_DEREGISTERSHELLHOOKWINDOW:
-      if (IntIsWindow((HWND) Unknown1))
-        return IntDeRegisterShellHookWindow((HWND) Unknown1);
-      return FALSE;
-  }
-  UNIMPLEMENTED
+   switch (Unknown0)
+   {
+      case HWND_ROUTINE_REGISTERSHELLHOOKWINDOW:
+         if (IntIsWindow((HWND) Unknown1))
+            return IntRegisterShellHookWindow((HWND) Unknown1);
+         return FALSE;
+         break;
+      case HWND_ROUTINE_DEREGISTERSHELLHOOKWINDOW:
+         if (IntIsWindow((HWND) Unknown1))
+            return IntDeRegisterShellHookWindow((HWND) Unknown1);
+         return FALSE;
+   }
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserCallHwndParam(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserCallHwndParamLock(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
 DWORD
 STDCALL
 NtUserConvertMemHandle(
-  DWORD Unknown0,
-  DWORD Unknown1)
+   DWORD Unknown0,
+   DWORD Unknown1)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserCreateLocalMemHandle(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserDdeGetQualityOfService(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserDdeInitialize(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3,
+   DWORD Unknown4)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserDdeSetQualityOfService(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserDragObject(
-          HWND    hwnd1,
-          HWND    hwnd2,
-          UINT    u1,
-          DWORD   dw1,
-          HCURSOR hc1
-          )
+   HWND    hwnd1,
+   HWND    hwnd2,
+   UINT    u1,
+   DWORD   dw1,
+   HCURSOR hc1
+)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserDrawAnimatedRects(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserDrawCaption(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserDrawCaptionTemp(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5,
-  DWORD Unknown6)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3,
+   DWORD Unknown4,
+   DWORD Unknown5,
+   DWORD Unknown6)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 BOOL
 STDCALL
 NtUserEnumDisplayDevices (
-  PUNICODE_STRING lpDevice, /* device name */
-  DWORD iDevNum, /* display device */
-  PDISPLAY_DEVICE lpDisplayDevice, /* device information */
-  DWORD dwFlags ) /* reserved */
-{
-  DPRINT1("NtUserEnumDisplayDevices() is UNIMPLEMENTED!\n");
-  if (lpDevice->Length == 0 && iDevNum > 0)
-  {
-        /* Only one display device present */
-    return FALSE;
-  }
-  if (lpDisplayDevice->cb < sizeof(DISPLAY_DEVICE))
-    return FALSE;
+   PUNICODE_STRING lpDevice, /* device name */
+   DWORD iDevNum, /* display device */
+   PDISPLAY_DEVICE lpDisplayDevice, /* device information */
+   DWORD dwFlags ) /* reserved */
+{
+   DPRINT1("NtUserEnumDisplayDevices() is UNIMPLEMENTED!\n");
+   if (lpDevice->Length == 0 && iDevNum > 0)
+   {
+      /* Only one display device present */
+      return FALSE;
+   }
+   if (lpDisplayDevice->cb < sizeof(DISPLAY_DEVICE))
+      return FALSE;
 
-  swprintf(lpDisplayDevice->DeviceName, L"\\\\.\\DISPLAY1");
-  swprintf(lpDisplayDevice->DeviceString, L"<Unknown>");
-  lpDisplayDevice->StateFlags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP
-                              | DISPLAY_DEVICE_MODESPRUNED
-                              | DISPLAY_DEVICE_PRIMARY_DEVICE
-                              | DISPLAY_DEVICE_VGA_COMPATIBLE;
-  lpDisplayDevice->DeviceID[0] = L'0';
-  lpDisplayDevice->DeviceKey[0] = L'0';
-  return TRUE;
+   swprintf(lpDisplayDevice->DeviceName, L"\\\\.\\DISPLAY1");
+   swprintf(lpDisplayDevice->DeviceString, L"<Unknown>");
+   lpDisplayDevice->StateFlags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP
+                                 | DISPLAY_DEVICE_MODESPRUNED
+                                 | DISPLAY_DEVICE_PRIMARY_DEVICE
+                                 | DISPLAY_DEVICE_VGA_COMPATIBLE;
+   lpDisplayDevice->DeviceID[0] = L'0';
+   lpDisplayDevice->DeviceKey[0] = L'0';
+   return TRUE;
 }
 
 DWORD
 STDCALL
 NtUserEvent(
-  DWORD Unknown0)
+   DWORD Unknown0)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserExcludeUpdateRgn(
-  DWORD Unknown0,
-  DWORD Unknown1)
+   DWORD Unknown0,
+   DWORD Unknown1)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserGetAltTabInfo(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3,
+   DWORD Unknown4,
+   DWORD Unknown5)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserGetComboBoxInfo(
-  DWORD Unknown0,
-  DWORD Unknown1)
+   DWORD Unknown0,
+   DWORD Unknown1)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserGetControlBrush(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserGetControlColor(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserGetCPD(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserGetImeHotKey(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
 DWORD
 STDCALL
 NtUserGetListBoxInfo(
-  DWORD Unknown0)
+   DWORD Unknown0)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserGetMouseMovePointsEx(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3,
+   DWORD Unknown4)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserGetTitleBarInfo(
-  DWORD Unknown0,
-  DWORD Unknown1)
+   DWORD Unknown0,
+   DWORD Unknown1)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserImpersonateDdeClientWindow(
-  DWORD Unknown0,
-  DWORD Unknown1)
+   DWORD Unknown0,
+   DWORD Unknown1)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserInitializeClientPfnArrays(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserInitTask(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5,
-  DWORD Unknown6,
-  DWORD Unknown7,
-  DWORD Unknown8,
-  DWORD Unknown9,
-  DWORD Unknown10)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3,
+   DWORD Unknown4,
+   DWORD Unknown5,
+   DWORD Unknown6,
+   DWORD Unknown7,
+   DWORD Unknown8,
+   DWORD Unknown9,
+   DWORD Unknown10)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserLoadKeyboardLayoutEx(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3,
+   DWORD Unknown4,
+   DWORD Unknown5)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserLockWorkStation(VOID)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserMNDragLeave(VOID)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserMNDragOver(
-  DWORD Unknown0,
-  DWORD Unknown1)
+   DWORD Unknown0,
+   DWORD Unknown1)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserModifyUserStartupInfoFlags(
-  DWORD Unknown0,
-  DWORD Unknown1)
+   DWORD Unknown0,
+   DWORD Unknown1)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserNotifyIMEStatus(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserNotifyWinEvent(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserQueryUserCounters(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3,
+   DWORD Unknown4)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
 DWORD
 STDCALL
 NtUserRegisterTasklist(
-  DWORD Unknown0)
+   DWORD Unknown0)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
 DWORD
 STDCALL
 NtUserSBGetParms(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserSetConsoleReserveKeys(
-  DWORD Unknown0,
-  DWORD Unknown1)
+   DWORD Unknown0,
+   DWORD Unknown1)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserSetDbgTag(
-  DWORD Unknown0,
-  DWORD Unknown1)
+   DWORD Unknown0,
+   DWORD Unknown1)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserSetImeHotKey(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3,
+   DWORD Unknown4)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
 DWORD
 STDCALL
 NtUserSetRipFlags(
-  DWORD Unknown0,
-  DWORD Unknown1)
+   DWORD Unknown0,
+   DWORD Unknown1)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserSetSysColors(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserSetThreadState(
-  DWORD Unknown0,
-  DWORD Unknown1)
+   DWORD Unknown0,
+   DWORD Unknown1)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserTrackMouseEvent(
-  DWORD Unknown0)
+   DWORD Unknown0)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserUnloadKeyboardLayout(
-  DWORD Unknown0)
+   DWORD Unknown0)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserUpdateInputContext(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserUpdateInstance(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserUserHandleGrantAccess(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserValidateHandleSecure(
-  DWORD Unknown0)
+   DWORD Unknown0)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserWaitForInputIdle(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserWaitForMsgAndEvent(
-  DWORD Unknown0)
+   DWORD Unknown0)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserWin32PoolAllocationStats(
-  DWORD Unknown0,
-  DWORD Unknown1,
-  DWORD Unknown2,
-  DWORD Unknown3,
-  DWORD Unknown4,
-  DWORD Unknown5)
+   DWORD Unknown0,
+   DWORD Unknown1,
+   DWORD Unknown2,
+   DWORD Unknown3,
+   DWORD Unknown4,
+   DWORD Unknown5)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 DWORD
 STDCALL
 NtUserYieldTask(VOID)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 /* EOF */
index 340ad14..70b36f7 100644 (file)
@@ -58,110 +58,110 @@ static ULONG          HintIndex = 0;
 UINT_PTR FASTCALL
 IntSetTimer(HWND Wnd, UINT_PTR IDEvent, UINT Elapse, TIMERPROC TimerFunc, BOOL SystemTimer)
 {
-  PWINDOW_OBJECT WindowObject;
-  UINT_PTR Ret = 0;
+   PWINDOW_OBJECT WindowObject;
+   UINT_PTR Ret = 0;
 
-  DPRINT("IntSetTimer wnd %x id %p elapse %u timerproc %p systemtimer %s\n",
-         Wnd, IDEvent, Elapse, TimerFunc, SystemTimer ? "TRUE" : "FALSE");
+   DPRINT("IntSetTimer wnd %x id %p elapse %u timerproc %p systemtimer %s\n",
+          Wnd, IDEvent, Elapse, TimerFunc, SystemTimer ? "TRUE" : "FALSE");
 
-  if ((Wnd == NULL) && ! SystemTimer)
-    {
+   if ((Wnd == NULL) && ! SystemTimer)
+   {
       DPRINT("Window-less timer\n");
       /* find a free, window-less timer id */
       IntLockWindowlessTimerBitmap();
       IDEvent = RtlFindClearBitsAndSet(&WindowLessTimersBitMap, 1, HintIndex);
 
       if (IDEvent == (UINT_PTR) -1)
-        {
-          IntUnlockWindowlessTimerBitmap();
-          DPRINT1("Unable to find a free window-less timer id\n");
-          SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
-          return 0;
-        }
+      {
+         IntUnlockWindowlessTimerBitmap();
+         DPRINT1("Unable to find a free window-less timer id\n");
+         SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
+         return 0;
+      }
 
       HintIndex = ++IDEvent;
       IntUnlockWindowlessTimerBitmap();
       Ret = IDEvent;
-    }
-  else
-    {
+   }
+   else
+   {
       WindowObject = IntGetWindowObject(Wnd);
       if (! WindowObject)
-        {
-          DPRINT1("Invalid window handle\n");
-          SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-          return 0;
-        }
+      {
+         DPRINT1("Invalid window handle\n");
+         SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+         return 0;
+      }
 
       if (WindowObject->OwnerThread->ThreadsProcess != PsGetCurrentProcess())
-        {
-          IntReleaseWindowObject(WindowObject);
-          DPRINT1("Trying to set timer for window in another process (shatter attack?)\n");
-          SetLastWin32Error(ERROR_ACCESS_DENIED);
-          return 0;
-        }
+      {
+         IntReleaseWindowObject(WindowObject);
+         DPRINT1("Trying to set timer for window in another process (shatter attack?)\n");
+         SetLastWin32Error(ERROR_ACCESS_DENIED);
+         return 0;
+      }
       IntReleaseWindowObject(WindowObject);
       Ret = IDEvent;
-    }
+   }
 
-  #if 1
+#if 1
 
-  /* Win NT/2k/XP */
-  if (Elapse > 0x7fffffff)
-    {
+   /* Win NT/2k/XP */
+   if (Elapse > 0x7fffffff)
+   {
       DPRINT("Adjusting uElapse\n");
       Elapse = 1;
-    }
+   }
 
-  #else
+#else
 
-  /* Win Server 2003 */
-  if (Elapse > 0x7fffffff)
-    {
+   /* Win Server 2003 */
+   if (Elapse > 0x7fffffff)
+   {
       DPRINT("Adjusting uElapse\n");
       Elapse = 0x7fffffff;
-    }
+   }
 
-  #endif
+#endif
 
-  /* Win 2k/XP */
-  if (Elapse < 10)
-    {
+   /* Win 2k/XP */
+   if (Elapse < 10)
+   {
       DPRINT("Adjusting uElapse\n");
       Elapse = 10;
-    }
+   }
 
-  if (! MsqSetTimer(PsGetWin32Thread()->MessageQueue, Wnd,
-                    IDEvent, Elapse, TimerFunc,
-                    SystemTimer ? WM_SYSTIMER : WM_TIMER))
-    {
+   if (! MsqSetTimer(PsGetWin32Thread()->MessageQueue, Wnd,
+                     IDEvent, Elapse, TimerFunc,
+                     SystemTimer ? WM_SYSTIMER : WM_TIMER))
+   {
       DPRINT1("Failed to set timer in message queue\n");
       SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
       return 0;
-    }
+   }
 
 
-  return Ret;
+   return Ret;
 }
 
 
 BOOL FASTCALL
 IntKillTimer(HWND Wnd, UINT_PTR IDEvent, BOOL SystemTimer)
 {
-  DPRINT("IntKillTimer wnd %x id %p systemtimer %s\n",
-         Wnd, IDEvent, SystemTimer ? "TRUE" : "FALSE");
+   DPRINT("IntKillTimer wnd %x id %p systemtimer %s\n",
+          Wnd, IDEvent, SystemTimer ? "TRUE" : "FALSE");
 
-  if (! MsqKillTimer(PsGetWin32Thread()->MessageQueue, Wnd,
-                     IDEvent, SystemTimer ? WM_SYSTIMER : WM_TIMER))
-    {
+   if (! MsqKillTimer(PsGetWin32Thread()->MessageQueue, Wnd,
+                      IDEvent, SystemTimer ? WM_SYSTIMER : WM_TIMER))
+   {
       DPRINT1("Unable to locate timer in message queue\n");
       SetLastWin32Error(ERROR_INVALID_PARAMETER);
       return FALSE;
-    }
+   }
 
-  /* window-less timer? */
-  if ((Wnd == NULL) && ! SystemTimer)
-    {
+   /* window-less timer? */
+   if ((Wnd == NULL) && ! SystemTimer)
+   {
       /* Release the id */
       IntLockWindowlessTimerBitmap();
 
@@ -169,28 +169,28 @@ IntKillTimer(HWND Wnd, UINT_PTR IDEvent, BOOL SystemTimer)
       RtlClearBits(&WindowLessTimersBitMap, IDEvent - 1, 1);
 
       IntUnlockWindowlessTimerBitmap();
-    }
+   }
 
-  return TRUE;
+   return TRUE;
 }
 
 NTSTATUS FASTCALL
 InitTimerImpl(VOID)
 {
-  ULONG BitmapBytes;
+   ULONG BitmapBytes;
 
-  ExInitializeFastMutex(&Mutex);
+   ExInitializeFastMutex(&Mutex);
 
-  BitmapBytes = ROUND_UP(NUM_WINDOW_LESS_TIMERS, sizeof(ULONG) * 8) / 8;
-  WindowLessTimersBitMapBuffer = ExAllocatePoolWithTag(PagedPool, BitmapBytes, TAG_TIMERBMP);
-  RtlInitializeBitMap(&WindowLessTimersBitMap,
-                      WindowLessTimersBitMapBuffer,
-                      BitmapBytes * 8);
+   BitmapBytes = ROUND_UP(NUM_WINDOW_LESS_TIMERS, sizeof(ULONG) * 8) / 8;
+   WindowLessTimersBitMapBuffer = ExAllocatePoolWithTag(PagedPool, BitmapBytes, TAG_TIMERBMP);
+   RtlInitializeBitMap(&WindowLessTimersBitMap,
+                       WindowLessTimersBitMapBuffer,
+                       BitmapBytes * 8);
 
-  /* yes we need this, since ExAllocatePool isn't supposed to zero out allocated memory */
-  RtlClearAllBits(&WindowLessTimersBitMap);
+   /* yes we need this, since ExAllocatePool isn't supposed to zero out allocated memory */
+   RtlClearAllBits(&WindowLessTimersBitMap);
 
-  return STATUS_SUCCESS;
+   return STATUS_SUCCESS;
 }
 
 
@@ -198,19 +198,19 @@ UINT_PTR
 STDCALL
 NtUserSetTimer
 (
- HWND hWnd,
- UINT_PTR nIDEvent,
- UINT uElapse,
- TIMERPROC lpTimerFunc
  HWND hWnd,
  UINT_PTR nIDEvent,
  UINT uElapse,
  TIMERPROC lpTimerFunc
 )
 {
    DECLARE_RETURN(UINT_PTR);
 
    DPRINT("Enter NtUserSetTimer\n");
    UserEnterExclusive();
-   
+
    RETURN(IntSetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc, FALSE));
-   
+
 CLEANUP:
    DPRINT("Leave NtUserSetTimer, ret=%i\n", _ret_);
    UserLeave();
@@ -222,17 +222,17 @@ BOOL
 STDCALL
 NtUserKillTimer
 (
- HWND hWnd,
- UINT_PTR uIDEvent
  HWND hWnd,
  UINT_PTR uIDEvent
 )
 {
    DECLARE_RETURN(BOOL);
 
    DPRINT("Enter NtUserKillTimer\n");
    UserEnterExclusive();
-   
+
    RETURN(IntKillTimer(hWnd, uIDEvent, FALSE));
-   
+
 CLEANUP:
    DPRINT("Leave NtUserKillTimer, ret=%i\n", _ret_);
    UserLeave();
@@ -243,19 +243,19 @@ CLEANUP:
 UINT_PTR
 STDCALL
 NtUserSetSystemTimer(
- HWND hWnd,
- UINT_PTR nIDEvent,
- UINT uElapse,
- TIMERPROC lpTimerFunc
  HWND hWnd,
  UINT_PTR nIDEvent,
  UINT uElapse,
  TIMERPROC lpTimerFunc
 )
 {
    DECLARE_RETURN(UINT_PTR);
 
    DPRINT("Enter NtUserSetSystemTimer\n");
    UserEnterExclusive();
-   
+
    RETURN(IntSetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc, TRUE));
-   
+
 CLEANUP:
    DPRINT("Leave NtUserSetSystemTimer, ret=%i\n", _ret_);
    UserLeave();
@@ -266,17 +266,17 @@ CLEANUP:
 BOOL
 STDCALL
 NtUserKillSystemTimer(
- HWND hWnd,
- UINT_PTR uIDEvent
  HWND hWnd,
  UINT_PTR uIDEvent
 )
 {
    DECLARE_RETURN(BOOL);
 
    DPRINT("Enter NtUserKillSystemTimer\n");
    UserEnterExclusive();
-   
+
    RETURN(IntKillTimer(hWnd, uIDEvent, TRUE));
-   
+
 CLEANUP:
    DPRINT("Leave NtUserKillSystemTimer, ret=%i\n", _ret_);
    UserLeave();
index 8b3adde..efdaa0e 100644 (file)
@@ -43,7 +43,7 @@ IntAddAtom(LPWSTR AtomName)
    }
    WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
    Status = RtlAddAtomToAtomTable(WinStaObject->AtomTable,
-                                 AtomName, &Atom);
+                                  AtomName, &Atom);
    if (!NT_SUCCESS(Status))
    {
       SetLastNtError(Status);
@@ -66,7 +66,7 @@ IntGetAtomName(RTL_ATOM nAtom, LPWSTR lpBuffer, ULONG nSize)
    }
    WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
    Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,
-      nAtom, NULL, NULL, lpBuffer, &Size);
+                                    nAtom, NULL, NULL, lpBuffer, &Size);
    if (Size < nSize)
       *(lpBuffer + Size) = 0;
    if (!NT_SUCCESS(Status))
index 3d04878..f837136 100644 (file)
@@ -50,12 +50,12 @@ VIS_ComputeVisibleRegion(
    {
       if(!(ClipRgn = VIS_ComputeVisibleRegion(Window, FALSE, ClipChildren, ClipSiblings)))
       {
-        return NtGdiCreateRectRgn(0, 0, 0, 0);
+         return NtGdiCreateRectRgn(0, 0, 0, 0);
       }
       if(!(VisRgn = UnsafeIntCreateRectRgnIndirect(&Window->ClientRect)))
       {
-        NtGdiDeleteObject(VisRgn);
-        return NtGdiCreateRectRgn(0, 0, 0, 0);
+         NtGdiDeleteObject(VisRgn);
+         return NtGdiCreateRectRgn(0, 0, 0, 0);
       }
       LeftOffset = Window->ClientRect.left - Window->WindowRect.left;
       TopOffset = Window->ClientRect.top - Window->WindowRect.top;
@@ -90,7 +90,7 @@ VIS_ComputeVisibleRegion(
       NtGdiDeleteObject(ClipRgn);
 
       if ((PreviousWindow->Style & WS_CLIPSIBLINGS) ||
-          (PreviousWindow == Window && ClipSiblings))
+            (PreviousWindow == Window && ClipSiblings))
       {
          CurrentSibling = CurrentWindow->FirstChild;
          while (CurrentSibling != NULL && CurrentSibling != PreviousWindow)
@@ -101,9 +101,9 @@ VIS_ComputeVisibleRegion(
                /* Combine it with the window region if available */
                if(CurrentSibling->WindowRegion && !(CurrentSibling->Style & WS_MINIMIZE))
                {
-                 NtGdiOffsetRgn(ClipRgn, -CurrentSibling->WindowRect.left, -CurrentSibling->WindowRect.top);
-                 NtGdiCombineRgn(ClipRgn, ClipRgn, CurrentSibling->WindowRegion, RGN_AND);
-                 NtGdiOffsetRgn(ClipRgn, CurrentSibling->WindowRect.left, CurrentSibling->WindowRect.top);
+                  NtGdiOffsetRgn(ClipRgn, -CurrentSibling->WindowRect.left, -CurrentSibling->WindowRect.top);
+                  NtGdiCombineRgn(ClipRgn, ClipRgn, CurrentSibling->WindowRegion, RGN_AND);
+                  NtGdiOffsetRgn(ClipRgn, CurrentSibling->WindowRect.left, CurrentSibling->WindowRect.top);
                }
                NtGdiCombineRgn(VisRgn, VisRgn, ClipRgn, RGN_DIFF);
                NtGdiDeleteObject(ClipRgn);
@@ -127,9 +127,9 @@ VIS_ComputeVisibleRegion(
             /* Combine it with the window region if available */
             if(CurrentWindow->WindowRegion && !(CurrentWindow->Style & WS_MINIMIZE))
             {
-              NtGdiOffsetRgn(ClipRgn, -CurrentWindow->WindowRect.left, -CurrentWindow->WindowRect.top);
-              NtGdiCombineRgn(ClipRgn, ClipRgn, CurrentWindow->WindowRegion, RGN_AND);
-              NtGdiOffsetRgn(ClipRgn, CurrentWindow->WindowRect.left, CurrentWindow->WindowRect.top);
+               NtGdiOffsetRgn(ClipRgn, -CurrentWindow->WindowRect.left, -CurrentWindow->WindowRect.top);
+               NtGdiCombineRgn(ClipRgn, ClipRgn, CurrentWindow->WindowRegion, RGN_AND);
+               NtGdiOffsetRgn(ClipRgn, CurrentWindow->WindowRect.left, CurrentWindow->WindowRect.top);
             }
             NtGdiCombineRgn(VisRgn, VisRgn, ClipRgn, RGN_DIFF);
             NtGdiDeleteObject(ClipRgn);
@@ -140,9 +140,9 @@ VIS_ComputeVisibleRegion(
 
    if(Window->WindowRegion && !(Window->Style & WS_MINIMIZE))
    {
-     NtGdiOffsetRgn(VisRgn, -LeftOffset, -TopOffset);
-     NtGdiCombineRgn(VisRgn, VisRgn, Window->WindowRegion, RGN_AND);
-     return VisRgn;
+      NtGdiOffsetRgn(VisRgn, -LeftOffset, -TopOffset);
+      NtGdiCombineRgn(VisRgn, VisRgn, Window->WindowRegion, RGN_AND);
+      return VisRgn;
    }
 
    NtGdiOffsetRgn(VisRgn, -LeftOffset, -TopOffset);
@@ -169,11 +169,11 @@ co_VIS_WindowLayoutChanged(
       NtGdiOffsetRgn(Temp,
                      Window->WindowRect.left - Parent->ClientRect.left,
                      Window->WindowRect.top - Parent->ClientRect.top);
-                     
+
       UserRefObjectCo(Parent);
       co_UserRedrawWindow(Parent, NULL, Temp,
-                     RDW_FRAME | RDW_ERASE | RDW_INVALIDATE |
-                     RDW_ALLCHILDREN);
+                          RDW_FRAME | RDW_ERASE | RDW_INVALIDATE |
+                          RDW_ALLCHILDREN);
       UserDerefObjectCo(Parent);
    }
    NtGdiDeleteObject(Temp);
index caae710..55d6f82 100644 (file)
@@ -64,30 +64,30 @@ static HDC defaultDCstate;
 VOID FASTCALL
 DceInit(VOID)
 {
-  ExInitializeFastMutex(&DceListLock);
+   ExInitializeFastMutex(&DceListLock);
 }
 
 HRGN STDCALL
 DceGetVisRgn(HWND hWnd, ULONG Flags, HWND hWndChild, ULONG CFlags)
 {
-  PWINDOW_OBJECT Window;
-  HRGN VisRgn;
+   PWINDOW_OBJECT Window;
+   HRGN VisRgn;
 
-  Window = IntGetWindowObject(hWnd);
+   Window = IntGetWindowObject(hWnd);
 
-  if (NULL == Window)
-    {
+   if (NULL == Window)
+   {
       return NULL;
-    }
+   }
 
-  VisRgn = VIS_ComputeVisibleRegion(Window,
-                                    0 == (Flags & DCX_WINDOW),
-                                    0 != (Flags & DCX_CLIPCHILDREN),
-                                    0 != (Flags & DCX_CLIPSIBLINGS));
+   VisRgn = VIS_ComputeVisibleRegion(Window,
+                                     0 == (Flags & DCX_WINDOW),
+                                     0 != (Flags & DCX_CLIPCHILDREN),
+                                     0 != (Flags & DCX_CLIPSIBLINGS));
 
-  IntReleaseWindowObject(Window);
+   IntReleaseWindowObject(Window);
 
-  return VisRgn;
+   return VisRgn;
 }
 
 /*
@@ -124,147 +124,147 @@ NtUserGetDC(HWND hWnd)
 PDCE FASTCALL
 DceAllocDCE(HWND hWnd, DCE_TYPE Type)
 {
-  HDCE DceHandle;
-  DCE* Dce;
-  UNICODE_STRING DriverName;
-
-  DceHandle = DCEOBJ_AllocDCE();
-  if(!DceHandle)
-    return NULL;
-
-  RtlInitUnicodeString(&DriverName, L"DISPLAY");
-
-  Dce = DCEOBJ_LockDCE(DceHandle);
-  /* No real locking, just get the pointer */
-  DCEOBJ_UnlockDCE(Dce);
-  Dce->Self = DceHandle;
-  Dce->hDC = IntGdiCreateDC(&DriverName, NULL, NULL, NULL, FALSE);
-  if (NULL == defaultDCstate)
-    {
+   HDCE DceHandle;
+   DCE* Dce;
+   UNICODE_STRING DriverName;
+
+   DceHandle = DCEOBJ_AllocDCE();
+   if(!DceHandle)
+      return NULL;
+
+   RtlInitUnicodeString(&DriverName, L"DISPLAY");
+
+   Dce = DCEOBJ_LockDCE(DceHandle);
+   /* No real locking, just get the pointer */
+   DCEOBJ_UnlockDCE(Dce);
+   Dce->Self = DceHandle;
+   Dce->hDC = IntGdiCreateDC(&DriverName, NULL, NULL, NULL, FALSE);
+   if (NULL == defaultDCstate)
+   {
       defaultDCstate = NtGdiGetDCState(Dce->hDC);
       GDIOBJ_SetOwnership(defaultDCstate, NULL);
-    }
-  GDIOBJ_SetOwnership(Dce->Self, NULL);
-  DC_SetOwnership(Dce->hDC, NULL);
-  Dce->hwndCurrent = hWnd;
-  Dce->hClipRgn = NULL;
-  DCE_LockList();
-  Dce->next = FirstDce;
-  FirstDce = Dce;
-  DCE_UnlockList();
-
-  if (Type != DCE_CACHE_DC)
-    {
+   }
+   GDIOBJ_SetOwnership(Dce->Self, NULL);
+   DC_SetOwnership(Dce->hDC, NULL);
+   Dce->hwndCurrent = hWnd;
+   Dce->hClipRgn = NULL;
+   DCE_LockList();
+   Dce->next = FirstDce;
+   FirstDce = Dce;
+   DCE_UnlockList();
+
+   if (Type != DCE_CACHE_DC)
+   {
       Dce->DCXFlags = DCX_DCEBUSY;
       if (hWnd != NULL)
-       {
-         PWINDOW_OBJECT WindowObject;
-
-         WindowObject = IntGetWindowObject(hWnd);
-         if (WindowObject->Style & WS_CLIPCHILDREN)
-           {
-             Dce->DCXFlags |= DCX_CLIPCHILDREN;
-           }
-         if (WindowObject->Style & WS_CLIPSIBLINGS)
-           {
-             Dce->DCXFlags |= DCX_CLIPSIBLINGS;
-           }
-         IntReleaseWindowObject(WindowObject);
-       }
-    }
-  else
-    {
+      {
+         PWINDOW_OBJECT WindowObject;
+
+         WindowObject = IntGetWindowObject(hWnd);
+         if (WindowObject->Style & WS_CLIPCHILDREN)
+         {
+            Dce->DCXFlags |= DCX_CLIPCHILDREN;
+         }
+         if (WindowObject->Style & WS_CLIPSIBLINGS)
+         {
+            Dce->DCXFlags |= DCX_CLIPSIBLINGS;
+         }
+         IntReleaseWindowObject(WindowObject);
+      }
+   }
+   else
+   {
       Dce->DCXFlags = DCX_CACHE | DCX_DCEEMPTY;
-    }
+   }
 
-  return(Dce);
+   return(Dce);
 }
 
 VOID STATIC STDCALL
 DceSetDrawable(PWINDOW_OBJECT WindowObject, HDC hDC, ULONG Flags,
-              BOOL SetClipOrigin)
+               BOOL SetClipOrigin)
 {
-  DC *dc = DC_LockDc(hDC);
-  if(!dc)
-    return;
+   DC *dc = DC_LockDc(hDC);
+   if(!dc)
+      return;
 
-  if (WindowObject == NULL)
-    {
+   if (WindowObject == NULL)
+   {
       dc->w.DCOrgX = 0;
       dc->w.DCOrgY = 0;
-    }
-  else
-    {
+   }
+   else
+   {
       if (Flags & DCX_WINDOW)
-       {
-         dc->w.DCOrgX = WindowObject->WindowRect.left;
-         dc->w.DCOrgY = WindowObject->WindowRect.top;
-       }
+      {
+         dc->w.DCOrgX = WindowObject->WindowRect.left;
+         dc->w.DCOrgY = WindowObject->WindowRect.top;
+      }
       else
-       {
-         dc->w.DCOrgX = WindowObject->ClientRect.left;
-         dc->w.DCOrgY = WindowObject->ClientRect.top;
-       }
-    }
-  DC_UnlockDc(dc);
+      {
+         dc->w.DCOrgX = WindowObject->ClientRect.left;
+         dc->w.DCOrgY = WindowObject->ClientRect.top;
+      }
+   }
+   DC_UnlockDc(dc);
 }
 
 
 STATIC VOID FASTCALL
 DceDeleteClipRgn(DCE* Dce)
 {
-  Dce->DCXFlags &= ~(DCX_EXCLUDERGN | DCX_INTERSECTRGN | DCX_WINDOWPAINT);
+   Dce->DCXFlags &= ~(DCX_EXCLUDERGN | DCX_INTERSECTRGN | DCX_WINDOWPAINT);
 
-  if (Dce->DCXFlags & DCX_KEEPCLIPRGN )
-    {
+   if (Dce->DCXFlags & DCX_KEEPCLIPRGN )
+   {
       Dce->DCXFlags &= ~DCX_KEEPCLIPRGN;
-    }
-  else if (Dce->hClipRgn != NULL)
-    {
+   }
+   else if (Dce->hClipRgn != NULL)
+   {
       GDIOBJ_SetOwnership(Dce->hClipRgn, PsGetCurrentProcess());
       NtGdiDeleteObject(Dce->hClipRgn);
-    }
+   }
 
-  Dce->hClipRgn = NULL;
+   Dce->hClipRgn = NULL;
 
-  /* make it dirty so that the vis rgn gets recomputed next time */
-  Dce->DCXFlags |= DCX_DCEDIRTY;
+   /* make it dirty so that the vis rgn gets recomputed next time */
+   Dce->DCXFlags |= DCX_DCEDIRTY;
 }
 
 STATIC INT FASTCALL
 DceReleaseDC(DCE* dce)
 {
-  if (DCX_DCEBUSY != (dce->DCXFlags & (DCX_DCEEMPTY | DCX_DCEBUSY)))
-    {
+   if (DCX_DCEBUSY != (dce->DCXFlags & (DCX_DCEEMPTY | DCX_DCEBUSY)))
+   {
       return 0;
-    }
+   }
 
-  /* restore previous visible region */
+   /* restore previous visible region */
 
-  if ((dce->DCXFlags & (DCX_INTERSECTRGN | DCX_EXCLUDERGN)) &&
-      (dce->DCXFlags & (DCX_CACHE | DCX_WINDOWPAINT)) )
-    {
+   if ((dce->DCXFlags & (DCX_INTERSECTRGN | DCX_EXCLUDERGN)) &&
+         (dce->DCXFlags & (DCX_CACHE | DCX_WINDOWPAINT)) )
+   {
       DceDeleteClipRgn(dce);
-    }
+   }
 
-  if (dce->DCXFlags & DCX_CACHE)
-    {
+   if (dce->DCXFlags & DCX_CACHE)
+   {
       /* make the DC clean so that SetDCState doesn't try to update the vis rgn */
       NtGdiSetHookFlags(dce->hDC, DCHF_VALIDATEVISRGN);
       NtGdiSetDCState(dce->hDC, defaultDCstate);
       dce->DCXFlags &= ~DCX_DCEBUSY;
       if (dce->DCXFlags & DCX_DCEDIRTY)
-       {
-         /* don't keep around invalidated entries
-          * because SetDCState() disables hVisRgn updates
-          * by removing dirty bit. */
-         dce->hwndCurrent = 0;
-         dce->DCXFlags &= DCX_CACHE;
-         dce->DCXFlags |= DCX_DCEEMPTY;
-       }
-    }
+      {
+         /* don't keep around invalidated entries
+          * because SetDCState() disables hVisRgn updates
+          * by removing dirty bit. */
+         dce->hwndCurrent = 0;
+         dce->DCXFlags &= DCX_CACHE;
+         dce->DCXFlags |= DCX_DCEEMPTY;
+      }
+   }
 
-  return 1;
+   return 1;
 }
 
 STATIC VOID FASTCALL
@@ -281,14 +281,14 @@ DceUpdateVisRgn(DCE *Dce, PWINDOW_OBJECT Window, ULONG Flags)
       Parent = Window->Parent;
       if(!Parent)
       {
-        hRgnVisible = NULL;
-        goto noparent;
+         hRgnVisible = NULL;
+         goto noparent;
       }
 
       if (Parent->Style & WS_CLIPSIBLINGS)
       {
          DcxFlags = DCX_CLIPSIBLINGS |
-            (Flags & ~(DCX_CLIPCHILDREN | DCX_WINDOW));
+                    (Flags & ~(DCX_CLIPCHILDREN | DCX_WINDOW));
       }
       else
       {
@@ -374,225 +374,227 @@ noparent:
 HDC FASTCALL
 UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
 {
-  PWINDOW_OBJECT Parent;
-  ULONG DcxFlags;
-  DCE* Dce;
-  BOOL UpdateVisRgn = TRUE;
-  BOOL UpdateClipOrigin = FALSE;
-
-  if (NULL == Window)
-    {
+   PWINDOW_OBJECT Parent;
+   ULONG DcxFlags;
+   DCE* Dce;
+   BOOL UpdateVisRgn = TRUE;
+   BOOL UpdateClipOrigin = FALSE;
+
+   if (NULL == Window)
+   {
       Flags &= ~DCX_USESTYLE;
-    }
+   }
 
-  if (NULL == Window || NULL == Window->Dce)
-    {
+   if (NULL == Window || NULL == Window->Dce)
+   {
       Flags |= DCX_CACHE;
-    }
+   }
 
 
-  if (Flags & DCX_USESTYLE)
-    {
+   if (Flags & DCX_USESTYLE)
+   {
       Flags &= ~(DCX_CLIPCHILDREN | DCX_CLIPSIBLINGS | DCX_PARENTCLIP);
 
       if (Window->Style & WS_CLIPSIBLINGS)
-       {
-         Flags |= DCX_CLIPSIBLINGS;
-       }
+      {
+         Flags |= DCX_CLIPSIBLINGS;
+      }
 
       if (!(Flags & DCX_WINDOW))
-       {
-         if (Window->Class->style & CS_PARENTDC)
-           {
-             Flags |= DCX_PARENTCLIP;
-           }
-
-         if (Window->Style & WS_CLIPCHILDREN &&
-             !(Window->Style & WS_MINIMIZE))
-           {
-             Flags |= DCX_CLIPCHILDREN;
-           }
-       }
+      {
+         if (Window->Class->style & CS_PARENTDC)
+         {
+            Flags |= DCX_PARENTCLIP;
+         }
+
+         if (Window->Style & WS_CLIPCHILDREN &&
+               !(Window->Style & WS_MINIMIZE))
+         {
+            Flags |= DCX_CLIPCHILDREN;
+         }
+      }
       else
-       {
-         Flags |= DCX_CACHE;
-       }
-    }
+      {
+         Flags |= DCX_CACHE;
+      }
+   }
 
-  if (Flags & DCX_NOCLIPCHILDREN)
-    {
+   if (Flags & DCX_NOCLIPCHILDREN)
+   {
       Flags |= DCX_CACHE;
       Flags |= ~(DCX_PARENTCLIP | DCX_CLIPCHILDREN);
-    }
+   }
 
-  if (Flags & DCX_WINDOW)
-    {
+   if (Flags & DCX_WINDOW)
+   {
       Flags = (Flags & ~DCX_CLIPCHILDREN) | DCX_CACHE;
-    }
+   }
 
-  Parent = (Window ? Window->Parent : NULL);
+   Parent = (Window ? Window->Parent : NULL);
 
-  if (NULL == Window || !(Window->Style & WS_CHILD) || NULL == Parent)
-    {
+   if (NULL == Window || !(Window->Style & WS_CHILD) || NULL == Parent)
+   {
       Flags &= ~DCX_PARENTCLIP;
-    }
-  else if (Flags & DCX_PARENTCLIP)
-    {
+   }
+   else if (Flags & DCX_PARENTCLIP)
+   {
       Flags |= DCX_CACHE;
       if ((Window->Style & WS_VISIBLE) &&
-          (Parent->Style & WS_VISIBLE))
-        {
-          Flags &= ~DCX_CLIPCHILDREN;
-          if (Parent->Style & WS_CLIPSIBLINGS)
-            {
-              Flags |= DCX_CLIPSIBLINGS;
-            }
-        }
-    }
+            (Parent->Style & WS_VISIBLE))
+      {
+         Flags &= ~DCX_CLIPCHILDREN;
+         if (Parent->Style & WS_CLIPSIBLINGS)
+         {
+            Flags |= DCX_CLIPSIBLINGS;
+         }
+      }
+   }
 
-  DcxFlags = Flags & DCX_CACHECOMPAREMASK;
+   DcxFlags = Flags & DCX_CACHECOMPAREMASK;
 
-  if (Flags & DCX_CACHE)
-    {
+   if (Flags & DCX_CACHE)
+   {
       DCE* DceEmpty = NULL;
       DCE* DceUnused = NULL;
 
       DCE_LockList();
 
       for (Dce = FirstDce; Dce != NULL; Dce = Dce->next)
-       {
-         if ((Dce->DCXFlags & (DCX_CACHE | DCX_DCEBUSY)) == DCX_CACHE)
-           {
-             DceUnused = Dce;
-             if (Dce->DCXFlags & DCX_DCEEMPTY)
-               {
-                 DceEmpty = Dce;
-               }
-         else if (Dce->hwndCurrent == (Window ? Window->hSelf : NULL) &&
-                      ((Dce->DCXFlags & DCX_CACHECOMPAREMASK) == DcxFlags))
-               {
+      {
+         if ((Dce->DCXFlags & (DCX_CACHE | DCX_DCEBUSY)) == DCX_CACHE)
+         {
+            DceUnused = Dce;
+            if (Dce->DCXFlags & DCX_DCEEMPTY)
+            {
+               DceEmpty = Dce;
+            }
+            else if (Dce->hwndCurrent == (Window ? Window->hSelf : NULL) &&
+                     ((Dce->DCXFlags & DCX_CACHECOMPAREMASK) == DcxFlags))
+            {
 #if 0 /* FIXME */
-                 UpdateVisRgn = FALSE;
+               UpdateVisRgn = FALSE;
 #endif
-                 UpdateClipOrigin = TRUE;
-                 break;
-               }
-           }
-       }
+
+               UpdateClipOrigin = TRUE;
+               break;
+            }
+         }
+      }
 
       DCE_UnlockList();
 
       if (Dce == NULL)
-       {
-         Dce = (DceEmpty == NULL) ? DceUnused : DceEmpty;
-       }
+      {
+         Dce = (DceEmpty == NULL) ? DceUnused : DceEmpty;
+      }
 
       if (Dce == NULL)
-       {
-         Dce = DceAllocDCE(NULL, DCE_CACHE_DC);
-       }
-    }
-  else
-    {
+      {
+         Dce = DceAllocDCE(NULL, DCE_CACHE_DC);
+      }
+   }
+   else
+   {
       Dce = Window->Dce;
       if (NULL != Dce && Dce->hwndCurrent == (Window ? Window->hSelf : NULL))
-        {
-          UpdateVisRgn = FALSE; /* updated automatically, via DCHook() */
-        }
+      {
+         UpdateVisRgn = FALSE; /* updated automatically, via DCHook() */
+      }
 #if 1 /* FIXME */
       UpdateVisRgn = TRUE;
 #endif
-    }
 
-  if (NULL == Dce)
-    {
+   }
+
+   if (NULL == Dce)
+   {
       return(NULL);
-    }
+   }
 
-  Dce->hwndCurrent = (Window ? Window->hSelf : NULL);
-  Dce->DCXFlags = DcxFlags | (Flags & DCX_WINDOWPAINT) | DCX_DCEBUSY;
+   Dce->hwndCurrent = (Window ? Window->hSelf : NULL);
+   Dce->DCXFlags = DcxFlags | (Flags & DCX_WINDOWPAINT) | DCX_DCEBUSY;
 
-  if (0 == (Flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN)) && NULL != ClipRegion)
-    {
+   if (0 == (Flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN)) && NULL != ClipRegion)
+   {
       NtGdiDeleteObject(ClipRegion);
       ClipRegion = NULL;
-    }
+   }
 
-  if (NULL != Dce->hClipRgn)
-    {
+   if (NULL != Dce->hClipRgn)
+   {
       DceDeleteClipRgn(Dce);
       Dce->hClipRgn = NULL;
-    }
+   }
 
-  if (0 != (Flags & DCX_INTERSECTUPDATE) && NULL == ClipRegion)
-    {
+   if (0 != (Flags & DCX_INTERSECTUPDATE) && NULL == ClipRegion)
+   {
       Dce->hClipRgn = NtGdiCreateRectRgn(0, 0, 0, 0);
       if (Dce->hClipRgn && Window->UpdateRegion)
-        {
-          GDIOBJ_SetOwnership(Dce->hClipRgn, NULL);
-          NtGdiCombineRgn(Dce->hClipRgn, Window->UpdateRegion, NULL, RGN_COPY);
-          if(Window->WindowRegion && !(Window->Style & WS_MINIMIZE))
+      {
+         GDIOBJ_SetOwnership(Dce->hClipRgn, NULL);
+         NtGdiCombineRgn(Dce->hClipRgn, Window->UpdateRegion, NULL, RGN_COPY);
+         if(Window->WindowRegion && !(Window->Style & WS_MINIMIZE))
             NtGdiCombineRgn(Dce->hClipRgn, Dce->hClipRgn, Window->WindowRegion, RGN_AND);
-          if (!(Flags & DCX_WINDOW))
-            {
-              NtGdiOffsetRgn(Dce->hClipRgn,
-                Window->WindowRect.left - Window->ClientRect.left,
-                Window->WindowRect.top - Window->ClientRect.top);
-            }
-        }
+         if (!(Flags & DCX_WINDOW))
+         {
+            NtGdiOffsetRgn(Dce->hClipRgn,
+                           Window->WindowRect.left - Window->ClientRect.left,
+                           Window->WindowRect.top - Window->ClientRect.top);
+         }
+      }
       Flags |= DCX_INTERSECTRGN;
-    }
+   }
 
-  if (ClipRegion == (HRGN) 1)
-    {
+   if (ClipRegion == (HRGN) 1)
+   {
       if (!(Flags & DCX_WINDOW))
-        {
-          Dce->hClipRgn = UnsafeIntCreateRectRgnIndirect(&Window->ClientRect);
-          GDIOBJ_SetOwnership(Dce->hClipRgn, NULL);
-          if(!Window->WindowRegion || (Window->Style & WS_MINIMIZE))
-          {
+      {
+         Dce->hClipRgn = UnsafeIntCreateRectRgnIndirect(&Window->ClientRect);
+         GDIOBJ_SetOwnership(Dce->hClipRgn, NULL);
+         if(!Window->WindowRegion || (Window->Style & WS_MINIMIZE))
+         {
             NtGdiOffsetRgn(Dce->hClipRgn, -Window->ClientRect.left, -Window->ClientRect.top);
-          }
-          else
-          {
+         }
+         else
+         {
             NtGdiOffsetRgn(Dce->hClipRgn, -Window->WindowRect.left, -Window->WindowRect.top);
             NtGdiCombineRgn(Dce->hClipRgn, Dce->hClipRgn, Window->WindowRegion, RGN_AND);
             NtGdiOffsetRgn(Dce->hClipRgn, -(Window->ClientRect.left - Window->WindowRect.left),
-                                          -(Window->ClientRect.top - Window->WindowRect.top));
-          }
-        }
+                           -(Window->ClientRect.top - Window->WindowRect.top));
+         }
+      }
       else
-        {
-          Dce->hClipRgn = UnsafeIntCreateRectRgnIndirect(&Window->WindowRect);
-          GDIOBJ_SetOwnership(Dce->hClipRgn, NULL);
-          NtGdiOffsetRgn(Dce->hClipRgn, -Window->WindowRect.left,
-             -Window->WindowRect.top);
-          if(Window->WindowRegion && !(Window->Style & WS_MINIMIZE))
+      {
+         Dce->hClipRgn = UnsafeIntCreateRectRgnIndirect(&Window->WindowRect);
+         GDIOBJ_SetOwnership(Dce->hClipRgn, NULL);
+         NtGdiOffsetRgn(Dce->hClipRgn, -Window->WindowRect.left,
+                        -Window->WindowRect.top);
+         if(Window->WindowRegion && !(Window->Style & WS_MINIMIZE))
             NtGdiCombineRgn(Dce->hClipRgn, Dce->hClipRgn, Window->WindowRegion, RGN_AND);
-        }
-    }
-  else if (NULL != ClipRegion)
-    {
+      }
+   }
+   else if (NULL != ClipRegion)
+   {
       Dce->hClipRgn = NtGdiCreateRectRgn(0, 0, 0, 0);
       if (Dce->hClipRgn)
-        {
-          GDIOBJ_SetOwnership(Dce->hClipRgn, NULL);
-          if(!Window->WindowRegion || (Window->Style & WS_MINIMIZE))
+      {
+         GDIOBJ_SetOwnership(Dce->hClipRgn, NULL);
+         if(!Window->WindowRegion || (Window->Style & WS_MINIMIZE))
             NtGdiCombineRgn(Dce->hClipRgn, ClipRegion, NULL, RGN_COPY);
-          else
+         else
             NtGdiCombineRgn(Dce->hClipRgn, ClipRegion, Window->WindowRegion, RGN_AND);
-        }
+      }
       NtGdiDeleteObject(ClipRegion);
-    }
+   }
 
-  DceSetDrawable(Window, Dce->hDC, Flags, UpdateClipOrigin);
+   DceSetDrawable(Window, Dce->hDC, Flags, UpdateClipOrigin);
 
-//  if (UpdateVisRgn)
-    {
+   //  if (UpdateVisRgn)
+   {
       DceUpdateVisRgn(Dce, Window, Flags);
-    }
+   }
 
-  return(Dce->hDC);
+   return(Dce->hDC);
 }
 
 
@@ -600,32 +602,33 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
 HDC STDCALL
 NtUserGetDCEx(HWND hWnd, HANDLE ClipRegion, ULONG Flags)
 {
-  PWINDOW_OBJECT Wnd=NULL;
-  DECLARE_RETURN(HDC);
-  HDC ret;
-  
-  DPRINT("Enter NtUserGetDCEx\n");
-  UserEnterExclusive();
-
-  if (hWnd)
-  {
-     if (!(Wnd = IntGetWindowObject(hWnd)))
-     {
-        SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-        RETURN(NULL);
-     }
-  }
-
-  ret = UserGetDCEx(Wnd, ClipRegion, Flags);
-  
-  if (Wnd) IntReleaseWindowObject(Wnd);
-  
-  RETURN(ret);
-  
+   PWINDOW_OBJECT Wnd=NULL;
+   DECLARE_RETURN(HDC);
+   HDC ret;
+
+   DPRINT("Enter NtUserGetDCEx\n");
+   UserEnterExclusive();
+
+   if (hWnd)
+   {
+      if (!(Wnd = IntGetWindowObject(hWnd)))
+      {
+         SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+         RETURN(NULL);
+      }
+   }
+
+   ret = UserGetDCEx(Wnd, ClipRegion, Flags);
+
+   if (Wnd)
+      IntReleaseWindowObject(Wnd);
+
+   RETURN(ret);
+
 CLEANUP:
-  DPRINT("Leave NtUserGetDCEx, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetDCEx, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -633,78 +636,78 @@ CLEANUP:
 BOOL INTERNAL_CALL
 DCE_Cleanup(PVOID ObjectBody)
 {
-  PDCE PrevInList;
-  PDCE pDce = (PDCE)ObjectBody;
+   PDCE PrevInList;
+   PDCE pDce = (PDCE)ObjectBody;
 
-  DCE_LockList();
+   DCE_LockList();
 
-  if (pDce == FirstDce)
-    {
+   if (pDce == FirstDce)
+   {
       FirstDce = pDce->next;
       PrevInList = pDce;
-    }
-  else
-    {
+   }
+   else
+   {
       for (PrevInList = FirstDce; NULL != PrevInList; PrevInList = PrevInList->next)
-       {
-         if (pDce == PrevInList->next)
-           {
-             PrevInList->next = pDce->next;
-             break;
-           }
-       }
+      {
+         if (pDce == PrevInList->next)
+         {
+            PrevInList->next = pDce->next;
+            break;
+         }
+      }
       assert(NULL != PrevInList);
-    }
+   }
 
-  DCE_UnlockList();
+   DCE_UnlockList();
 
-  return NULL != PrevInList;
+   return NULL != PrevInList;
 }
 
 HWND FASTCALL
 IntWindowFromDC(HDC hDc)
 {
-  DCE *Dce;
+   DCE *Dce;
 
-  DCE_LockList();
-  for (Dce = FirstDce; Dce != NULL; Dce = Dce->next)
-  {
-    if(Dce->hDC == hDc)
-    {
-      DCE_UnlockList();
-      return Dce->hwndCurrent;
-    }
-  }
-  DCE_UnlockList();
-  return 0;
+   DCE_LockList();
+   for (Dce = FirstDce; Dce != NULL; Dce = Dce->next)
+   {
+      if(Dce->hDC == hDc)
+      {
+         DCE_UnlockList();
+         return Dce->hwndCurrent;
+      }
+   }
+   DCE_UnlockList();
+   return 0;
 }
 
 
 INT FASTCALL
 UserReleaseDC(PWINDOW_OBJECT Window, HDC hDc)
 {
-  DCE *dce;
-  INT nRet = 0;
+   DCE *dce;
+   INT nRet = 0;
 
-  DCE_LockList();
+   DCE_LockList();
 
-  dce = FirstDce;
+   dce = FirstDce;
 
-  DPRINT("%p %p\n", Window, hDc);
+   DPRINT("%p %p\n", Window, hDc);
 
-  while (dce && (dce->hDC != hDc))
-    {
+   while (dce && (dce->hDC != hDc))
+   {
       dce = dce->next;
-    }
+   }
 
-  if (dce && (dce->DCXFlags & DCX_DCEBUSY))
-    {
+   if (dce && (dce->DCXFlags & DCX_DCEBUSY))
+   {
       nRet = DceReleaseDC(dce);
-    }
+   }
 
-  DCE_UnlockList();
+   DCE_UnlockList();
 
-  return nRet;
+   return nRet;
 }
 
 
@@ -712,17 +715,17 @@ UserReleaseDC(PWINDOW_OBJECT Window, HDC hDc)
 INT STDCALL
 NtUserReleaseDC(HWND hWnd, HDC hDc)
 {
-  DECLARE_RETURN(INT);
-  
-  DPRINT("Enter NtUserReleaseDC\n");
-  UserEnterExclusive();
-  
-  RETURN(UserReleaseDC(NULL, hDc));
-  
+   DECLARE_RETURN(INT);
+
+   DPRINT("Enter NtUserReleaseDC\n");
+   UserEnterExclusive();
+
+   RETURN(UserReleaseDC(NULL, hDc));
+
 CLEANUP:
-  DPRINT("Leave NtUserReleaseDC, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserReleaseDC, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 /***********************************************************************
@@ -731,35 +734,36 @@ CLEANUP:
 PDCE FASTCALL
 DceFreeDCE(PDCE dce, BOOLEAN Force)
 {
-  DCE *ret;
+   DCE *ret;
 
-  if (NULL == dce)
-    {
+   if (NULL == dce)
+   {
       return NULL;
-    }
+   }
 
-  ret = dce->next;
+   ret = dce->next;
 
 #if 0 /* FIXME */
-  SetDCHook(dce->hDC, NULL, 0L);
+
+   SetDCHook(dce->hDC, NULL, 0L);
 #endif
 
-  if(Force && !GDIOBJ_OwnedByCurrentProcess(dce->hDC))
-  {
-    GDIOBJ_SetOwnership(dce->Self, PsGetCurrentProcess());
-    DC_SetOwnership(dce->hDC, PsGetCurrentProcess());
-  }
+   if(Force && !GDIOBJ_OwnedByCurrentProcess(dce->hDC))
+   {
+      GDIOBJ_SetOwnership(dce->Self, PsGetCurrentProcess());
+      DC_SetOwnership(dce->hDC, PsGetCurrentProcess());
+   }
 
-  NtGdiDeleteDC(dce->hDC);
-  if (dce->hClipRgn && ! (dce->DCXFlags & DCX_KEEPCLIPRGN))
-    {
+   NtGdiDeleteDC(dce->hDC);
+   if (dce->hClipRgn && ! (dce->DCXFlags & DCX_KEEPCLIPRGN))
+   {
       GDIOBJ_SetOwnership(dce->hClipRgn, PsGetCurrentProcess());
       NtGdiDeleteObject(dce->hClipRgn);
-    }
+   }
 
-  DCEOBJ_FreeDCE(dce->Self);
+   DCEOBJ_FreeDCE(dce->Self);
 
-  return ret;
+   return ret;
 }
 
 
@@ -771,150 +775,150 @@ DceFreeDCE(PDCE dce, BOOLEAN Force)
 void FASTCALL
 DceFreeWindowDCE(PWINDOW_OBJECT Window)
 {
-  DCE *pDCE;
+   DCE *pDCE;
 
-  DCE_LockList();
+   DCE_LockList();
 
-  pDCE = FirstDce;
-  while (pDCE)
-    {
+   pDCE = FirstDce;
+   while (pDCE)
+   {
       if (pDCE->hwndCurrent == Window->hSelf)
-        {
-          if (pDCE == Window->Dce) /* owned or Class DCE*/
+      {
+         if (pDCE == Window->Dce) /* owned or Class DCE*/
+         {
+            if (Window->Class->style & CS_OWNDC) /* owned DCE*/
             {
-              if (Window->Class->style & CS_OWNDC) /* owned DCE*/
-                {
-                  pDCE = DceFreeDCE(pDCE, FALSE);
-                  Window->Dce = NULL;
-                  continue;
-                }
-              else if (pDCE->DCXFlags & (DCX_INTERSECTRGN | DCX_EXCLUDERGN))   /* Class DCE*/
-               {
-                  DceDeleteClipRgn(pDCE);
-                  pDCE->hwndCurrent = 0;
-                }
+               pDCE = DceFreeDCE(pDCE, FALSE);
+               Window->Dce = NULL;
+               continue;
             }
-          else
+            else if (pDCE->DCXFlags & (DCX_INTERSECTRGN | DCX_EXCLUDERGN)) /* Class DCE*/
             {
-              if (pDCE->DCXFlags & DCX_DCEBUSY) /* shared cache DCE */
-                {
-                  /* FIXME: AFAICS we are doing the right thing here so
-                   * this should be a DPRINT. But this is best left as an ERR
-                   * because the 'application error' is likely to come from
-                   * another part of Wine (i.e. it's our fault after all).
-                   * We should change this to DPRINT when ReactOS is more stable
-                   * (for 1.0?).
-                   */
-                  DPRINT1("[%p] GetDC() without ReleaseDC()!\n", Window->hSelf);
-                  DceReleaseDC(pDCE);
-                }
-
-              pDCE->DCXFlags &= DCX_CACHE;
-              pDCE->DCXFlags |= DCX_DCEEMPTY;
-              pDCE->hwndCurrent = 0;
+               DceDeleteClipRgn(pDCE);
+               pDCE->hwndCurrent = 0;
             }
-        }
+         }
+         else
+         {
+            if (pDCE->DCXFlags & DCX_DCEBUSY) /* shared cache DCE */
+            {
+               /* FIXME: AFAICS we are doing the right thing here so
+                * this should be a DPRINT. But this is best left as an ERR
+                * because the 'application error' is likely to come from
+                * another part of Wine (i.e. it's our fault after all).
+                * We should change this to DPRINT when ReactOS is more stable
+                * (for 1.0?).
+                */
+               DPRINT1("[%p] GetDC() without ReleaseDC()!\n", Window->hSelf);
+               DceReleaseDC(pDCE);
+            }
+
+            pDCE->DCXFlags &= DCX_CACHE;
+            pDCE->DCXFlags |= DCX_DCEEMPTY;
+            pDCE->hwndCurrent = 0;
+         }
+      }
       pDCE = pDCE->next;
-    }
-    DCE_UnlockList();
+   }
+   DCE_UnlockList();
 }
 
 void FASTCALL
 DceEmptyCache()
 {
-  DCE_LockList();
-  while (FirstDce != NULL)
-    {
+   DCE_LockList();
+   while (FirstDce != NULL)
+   {
       DceFreeDCE(FirstDce, TRUE);
-    }
-  DCE_UnlockList();
+   }
+   DCE_UnlockList();
 }
 
 VOID FASTCALL
 DceResetActiveDCEs(PWINDOW_OBJECT Window)
 {
-  DCE *pDCE;
-  PDC dc;
-  PWINDOW_OBJECT CurrentWindow;
-  INT DeltaX;
-  INT DeltaY;
-
-  if (NULL == Window)
-    {
+   DCE *pDCE;
+   PDC dc;
+   PWINDOW_OBJECT CurrentWindow;
+   INT DeltaX;
+   INT DeltaY;
+
+   if (NULL == Window)
+   {
       return;
-    }
+   }
 
-  DCE_LockList();
+   DCE_LockList();
 
-  pDCE = FirstDce;
-  while (pDCE)
-    {
+   pDCE = FirstDce;
+   while (pDCE)
+   {
       if (0 == (pDCE->DCXFlags & DCX_DCEEMPTY))
-        {
-          if (Window->hSelf == pDCE->hwndCurrent)
+      {
+         if (Window->hSelf == pDCE->hwndCurrent)
+         {
+            CurrentWindow = Window;
+         }
+         else
+         {
+            CurrentWindow = IntGetWindowObject(pDCE->hwndCurrent);
+            if (NULL == CurrentWindow)
             {
-              CurrentWindow = Window;
+               pDCE = pDCE->next;
+               continue;
             }
-          else
+         }
+
+         dc = DC_LockDc(pDCE->hDC);
+         if (dc == NULL)
+         {
+            if (Window->hSelf != pDCE->hwndCurrent)
             {
-              CurrentWindow = IntGetWindowObject(pDCE->hwndCurrent);
-              if (NULL == CurrentWindow)
-                {
-                  pDCE = pDCE->next;
-                  continue;
-                }
+               IntReleaseWindowObject(CurrentWindow);
             }
-
-          dc = DC_LockDc(pDCE->hDC);
-          if (dc == NULL)
+            pDCE = pDCE->next;
+            continue;
+         }
+         if (Window == CurrentWindow || IntIsChildWindow(Window->hSelf, CurrentWindow->hSelf))
+         {
+            if (pDCE->DCXFlags & DCX_WINDOW)
             {
-              if (Window->hSelf != pDCE->hwndCurrent)
-                {
-                  IntReleaseWindowObject(CurrentWindow);
-                }
-              pDCE = pDCE->next;
-              continue;
+               DeltaX = CurrentWindow->WindowRect.left - dc->w.DCOrgX;
+               DeltaY = CurrentWindow->WindowRect.top - dc->w.DCOrgY;
+               dc->w.DCOrgX = CurrentWindow->WindowRect.left;
+               dc->w.DCOrgY = CurrentWindow->WindowRect.top;
             }
-          if (Window == CurrentWindow || IntIsChildWindow(Window->hSelf, CurrentWindow->hSelf))
+            else
             {
-              if (pDCE->DCXFlags & DCX_WINDOW)
-                {
-                  DeltaX = CurrentWindow->WindowRect.left - dc->w.DCOrgX;
-                  DeltaY = CurrentWindow->WindowRect.top - dc->w.DCOrgY;
-                  dc->w.DCOrgX = CurrentWindow->WindowRect.left;
-                  dc->w.DCOrgY = CurrentWindow->WindowRect.top;
-                }
-              else
-                {
-                  DeltaX = CurrentWindow->ClientRect.left - dc->w.DCOrgX;
-                  DeltaY = CurrentWindow->ClientRect.top - dc->w.DCOrgY;
-                  dc->w.DCOrgX = CurrentWindow->ClientRect.left;
-                  dc->w.DCOrgY = CurrentWindow->ClientRect.top;
-                }
-              if (NULL != dc->w.hClipRgn)
-                {
-                  NtGdiOffsetRgn(dc->w.hClipRgn, DeltaX, DeltaY);
-                }
-              if (NULL != pDCE->hClipRgn)
-                {
-                  NtGdiOffsetRgn(pDCE->hClipRgn, DeltaX, DeltaY);
-                }
+               DeltaX = CurrentWindow->ClientRect.left - dc->w.DCOrgX;
+               DeltaY = CurrentWindow->ClientRect.top - dc->w.DCOrgY;
+               dc->w.DCOrgX = CurrentWindow->ClientRect.left;
+               dc->w.DCOrgY = CurrentWindow->ClientRect.top;
             }
-          DC_UnlockDc(dc);
-
-          DceUpdateVisRgn(pDCE, CurrentWindow, pDCE->DCXFlags);
-
-          if (Window->hSelf != pDCE->hwndCurrent)
+            if (NULL != dc->w.hClipRgn)
+            {
+               NtGdiOffsetRgn(dc->w.hClipRgn, DeltaX, DeltaY);
+            }
+            if (NULL != pDCE->hClipRgn)
             {
-//              IntEngWindowChanged(CurrentWindow, WOC_RGN_CLIENT);
-              IntReleaseWindowObject(CurrentWindow);
+               NtGdiOffsetRgn(pDCE->hClipRgn, DeltaX, DeltaY);
             }
-        }
+         }
+         DC_UnlockDc(dc);
+
+         DceUpdateVisRgn(pDCE, CurrentWindow, pDCE->DCXFlags);
+
+         if (Window->hSelf != pDCE->hwndCurrent)
+         {
+            //              IntEngWindowChanged(CurrentWindow, WOC_RGN_CLIENT);
+            IntReleaseWindowObject(CurrentWindow);
+         }
+      }
 
       pDCE = pDCE->next;
-    }
+   }
 
-  DCE_UnlockList();
+   DCE_UnlockList();
 }
 
 
@@ -930,84 +934,84 @@ DceResetActiveDCEs(PWINDOW_OBJECT Window)
 BOOL
 STDCALL
 NtUserEnumDisplaySettings(
-  PUNICODE_STRING lpszDeviceName,
-  DWORD iModeNum,
-  LPDEVMODEW lpDevMode, /* FIXME is this correct? */
-  DWORD dwFlags )
+   PUNICODE_STRING lpszDeviceName,
+   DWORD iModeNum,
+   LPDEVMODEW lpDevMode, /* FIXME is this correct? */
+   DWORD dwFlags )
 {
-  NTSTATUS Status;
-  LPDEVMODEW pSafeDevMode;
-  PUNICODE_STRING pSafeDeviceName = NULL;
-  UNICODE_STRING SafeDeviceName;
-  USHORT Size = 0, ExtraSize = 0;
-
-  /* Copy the devmode */
-  Status = MmCopyFromCaller(&Size, &lpDevMode->dmSize, sizeof (Size));
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return FALSE;
-  }
-  Status = MmCopyFromCaller(&ExtraSize, &lpDevMode->dmDriverExtra, sizeof (ExtraSize));
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return FALSE;
-  }
-  pSafeDevMode = ExAllocatePool(PagedPool, Size + ExtraSize);
-  if (pSafeDevMode == NULL)
-  {
-    SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-    return FALSE;
-  }
-  pSafeDevMode->dmSize = Size;
-  pSafeDevMode->dmDriverExtra = ExtraSize;
-
-  /* Copy the device name */
-  if (lpszDeviceName != NULL)
-  {
-    Status = IntSafeCopyUnicodeString(&SafeDeviceName, lpszDeviceName);
-    if (!NT_SUCCESS(Status))
-    {
-      ExFreePool(pSafeDevMode);
+   NTSTATUS Status;
+   LPDEVMODEW pSafeDevMode;
+   PUNICODE_STRING pSafeDeviceName = NULL;
+   UNICODE_STRING SafeDeviceName;
+   USHORT Size = 0, ExtraSize = 0;
+
+   /* Copy the devmode */
+   Status = MmCopyFromCaller(&Size, &lpDevMode->dmSize, sizeof (Size));
+   if (!NT_SUCCESS(Status))
+   {
       SetLastNtError(Status);
       return FALSE;
-    }
-    pSafeDeviceName = &SafeDeviceName;
-  }
-
-  /* Call internal function */
-  if (!IntEnumDisplaySettings(pSafeDeviceName, iModeNum, pSafeDevMode, dwFlags))
-  {
-    if (pSafeDeviceName != NULL)
-      RtlFreeUnicodeString(pSafeDeviceName);
-    ExFreePool(pSafeDevMode);
-    return FALSE;
-  }
-  if (pSafeDeviceName != NULL)
-    RtlFreeUnicodeString(pSafeDeviceName);
-
-  /* Copy some information back */
-  COPY_DEVMODE_VALUE_TO_CALLER(lpDevMode, pSafeDevMode, dmPelsWidth);
-  COPY_DEVMODE_VALUE_TO_CALLER(lpDevMode, pSafeDevMode, dmPelsHeight);
-  COPY_DEVMODE_VALUE_TO_CALLER(lpDevMode, pSafeDevMode, dmBitsPerPel);
-  COPY_DEVMODE_VALUE_TO_CALLER(lpDevMode, pSafeDevMode, dmDisplayFrequency);
-  COPY_DEVMODE_VALUE_TO_CALLER(lpDevMode, pSafeDevMode, dmDisplayFlags);
-
-  /* output private/extra driver data */
-  if (ExtraSize > 0)
-  {
-    Status = MmCopyToCaller((PCHAR)lpDevMode + Size, (PCHAR)pSafeDevMode + Size, ExtraSize);
-    if (!NT_SUCCESS(Status))
-    {
+   }
+   Status = MmCopyFromCaller(&ExtraSize, &lpDevMode->dmDriverExtra, sizeof (ExtraSize));
+   if (!NT_SUCCESS(Status))
+   {
       SetLastNtError(Status);
+      return FALSE;
+   }
+   pSafeDevMode = ExAllocatePool(PagedPool, Size + ExtraSize);
+   if (pSafeDevMode == NULL)
+   {
+      SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+      return FALSE;
+   }
+   pSafeDevMode->dmSize = Size;
+   pSafeDevMode->dmDriverExtra = ExtraSize;
+
+   /* Copy the device name */
+   if (lpszDeviceName != NULL)
+   {
+      Status = IntSafeCopyUnicodeString(&SafeDeviceName, lpszDeviceName);
+      if (!NT_SUCCESS(Status))
+      {
+         ExFreePool(pSafeDevMode);
+         SetLastNtError(Status);
+         return FALSE;
+      }
+      pSafeDeviceName = &SafeDeviceName;
+   }
+
+   /* Call internal function */
+   if (!IntEnumDisplaySettings(pSafeDeviceName, iModeNum, pSafeDevMode, dwFlags))
+   {
+      if (pSafeDeviceName != NULL)
+         RtlFreeUnicodeString(pSafeDeviceName);
       ExFreePool(pSafeDevMode);
       return FALSE;
-    }
-  }
+   }
+   if (pSafeDeviceName != NULL)
+      RtlFreeUnicodeString(pSafeDeviceName);
+
+   /* Copy some information back */
+   COPY_DEVMODE_VALUE_TO_CALLER(lpDevMode, pSafeDevMode, dmPelsWidth);
+   COPY_DEVMODE_VALUE_TO_CALLER(lpDevMode, pSafeDevMode, dmPelsHeight);
+   COPY_DEVMODE_VALUE_TO_CALLER(lpDevMode, pSafeDevMode, dmBitsPerPel);
+   COPY_DEVMODE_VALUE_TO_CALLER(lpDevMode, pSafeDevMode, dmDisplayFrequency);
+   COPY_DEVMODE_VALUE_TO_CALLER(lpDevMode, pSafeDevMode, dmDisplayFlags);
 
-  ExFreePool(pSafeDevMode);
-  return TRUE;
+   /* output private/extra driver data */
+   if (ExtraSize > 0)
+   {
+      Status = MmCopyToCaller((PCHAR)lpDevMode + Size, (PCHAR)pSafeDevMode + Size, ExtraSize);
+      if (!NT_SUCCESS(Status))
+      {
+         SetLastNtError(Status);
+         ExFreePool(pSafeDevMode);
+         return FALSE;
+      }
+   }
+
+   ExFreePool(pSafeDevMode);
+   return TRUE;
 }
 
 #undef COPY_DEVMODE_VALUE_TO_CALLER
@@ -1016,73 +1020,76 @@ NtUserEnumDisplaySettings(
 LONG
 STDCALL
 NtUserChangeDisplaySettings(
-  PUNICODE_STRING lpszDeviceName,
-  LPDEVMODEW lpDevMode,
-  HWND hwnd,
-  DWORD dwflags,
-  LPVOID lParam)
+   PUNICODE_STRING lpszDeviceName,
+   LPDEVMODEW lpDevMode,
+   HWND hwnd,
+   DWORD dwflags,
+   LPVOID lParam)
 {
-  NTSTATUS Status;
-  DEVMODEW DevMode;
-  PUNICODE_STRING pSafeDeviceName = NULL;
-  UNICODE_STRING SafeDeviceName;
-  LONG Ret;
+   NTSTATUS Status;
+   DEVMODEW DevMode;
+   PUNICODE_STRING pSafeDeviceName = NULL;
+   UNICODE_STRING SafeDeviceName;
+   LONG Ret;
 
-  /* Check arguments */
+   /* Check arguments */
 #ifdef CDS_VIDEOPARAMETERS
-  if (dwflags != CDS_VIDEOPARAMETERS && lParam != NULL)
+
+   if (dwflags != CDS_VIDEOPARAMETERS && lParam != NULL)
 #else
-  if (lParam != NULL)
+
+   if (lParam != NULL)
 #endif
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    return DISP_CHANGE_BADPARAM;
-  }
-  if (hwnd != NULL)
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    return DISP_CHANGE_BADPARAM;
-  }
-
-  /* Copy devmode */
-  Status = MmCopyFromCaller(&DevMode.dmSize, &lpDevMode->dmSize, sizeof (DevMode.dmSize));
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return DISP_CHANGE_BADPARAM;
-  }
-  DevMode.dmSize = min(sizeof (DevMode), DevMode.dmSize);
-  Status = MmCopyFromCaller(&DevMode, lpDevMode, DevMode.dmSize);
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return DISP_CHANGE_BADPARAM;
-  }
-  if (DevMode.dmDriverExtra > 0)
-  {
-    DbgPrint("(%s:%i) WIN32K: %s lpDevMode->dmDriverExtra is IGNORED!\n", __FILE__, __LINE__, __FUNCTION__);
-    DevMode.dmDriverExtra = 0;
-  }
-
-  /* Copy the device name */
-  if (lpszDeviceName != NULL)
-  {
-    Status = IntSafeCopyUnicodeString(&SafeDeviceName, lpszDeviceName);
-    if (!NT_SUCCESS(Status))
-    {
+
+   {
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      return DISP_CHANGE_BADPARAM;
+   }
+   if (hwnd != NULL)
+   {
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      return DISP_CHANGE_BADPARAM;
+   }
+
+   /* Copy devmode */
+   Status = MmCopyFromCaller(&DevMode.dmSize, &lpDevMode->dmSize, sizeof (DevMode.dmSize));
+   if (!NT_SUCCESS(Status))
+   {
       SetLastNtError(Status);
       return DISP_CHANGE_BADPARAM;
-    }
-    pSafeDeviceName = &SafeDeviceName;
-  }
+   }
+   DevMode.dmSize = min(sizeof (DevMode), DevMode.dmSize);
+   Status = MmCopyFromCaller(&DevMode, lpDevMode, DevMode.dmSize);
+   if (!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      return DISP_CHANGE_BADPARAM;
+   }
+   if (DevMode.dmDriverExtra > 0)
+   {
+      DbgPrint("(%s:%i) WIN32K: %s lpDevMode->dmDriverExtra is IGNORED!\n", __FILE__, __LINE__, __FUNCTION__);
+      DevMode.dmDriverExtra = 0;
+   }
 
-  /* Call internal function */
-  Ret = IntChangeDisplaySettings(pSafeDeviceName, &DevMode, dwflags, lParam);
+   /* Copy the device name */
+   if (lpszDeviceName != NULL)
+   {
+      Status = IntSafeCopyUnicodeString(&SafeDeviceName, lpszDeviceName);
+      if (!NT_SUCCESS(Status))
+      {
+         SetLastNtError(Status);
+         return DISP_CHANGE_BADPARAM;
+      }
+      pSafeDeviceName = &SafeDeviceName;
+   }
 
-  if (pSafeDeviceName != NULL)
-    RtlFreeUnicodeString(pSafeDeviceName);
+   /* Call internal function */
+   Ret = IntChangeDisplaySettings(pSafeDeviceName, &DevMode, dwflags, lParam);
+
+   if (pSafeDeviceName != NULL)
+      RtlFreeUnicodeString(pSafeDeviceName);
 
-  return Ret;
+   return Ret;
 }
 
 
index 161c46c..5552653 100644 (file)
@@ -38,7 +38,7 @@ static WORD WndProcHandlesArraySize = 0;
 #define WPH_SIZE 0x40 /* the size to add to the WndProcHandle array each time */
 
 /* dialog resources appear to pass this in 16 bits, handle them properly */
-#define CW_USEDEFAULT16        (0x8000)
+#define CW_USEDEFAULT16 (0x8000)
 
 #define POINT_IN_RECT(p, r) (((r.bottom >= p.y) && (r.top <= p.y))&&((r.left <= p.x )&&( r.right >= p.x )))
 
@@ -78,14 +78,13 @@ CleanupWindowImpl(VOID)
 VOID FASTCALL IntReleaseWindowObject(PWINDOW_OBJECT Window)
 {
    ASSERT(Window);
-   
+
    ASSERT(USER_BODY_TO_HEADER(Window)->RefCount >= 1);
-   
+
    USER_BODY_TO_HEADER(Window)->RefCount--;
-   
+
    if (USER_BODY_TO_HEADER(Window)->RefCount == 0 && USER_BODY_TO_HEADER(Window)->destroyed)
    {
-      
    }
 }
 
@@ -96,7 +95,7 @@ PWINDOW_OBJECT FASTCALL IntGetWindowObject(HWND hWnd)
    if (Window)
    {
       ASSERT(USER_BODY_TO_HEADER(Window)->RefCount >= 0);
-      
+
       USER_BODY_TO_HEADER(Window)->RefCount++;
    }
    return Window;
@@ -111,7 +110,7 @@ PWINDOW_OBJECT FASTCALL UserGetWindowObject(HWND hWnd)
       SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
       return NULL;
    }
-   
+
    ASSERT(USER_BODY_TO_HEADER(Window)->RefCount >= 0);
    return Window;
 }
@@ -151,44 +150,46 @@ IntIsWindow(HWND hWnd)
 PWINDOW_OBJECT FASTCALL
 IntGetParent(PWINDOW_OBJECT Wnd)
 {
-  HWND hWnd;
-
-  if (Wnd->Style & WS_POPUP)
-  {
-    hWnd = Wnd->hOwner;
-    return IntGetWindowObject(hWnd);
-  }
-  else if (Wnd->Style & WS_CHILD)
-  {
-    PWINDOW_OBJECT par;
-    
-    par = Wnd->Parent;
-    if (par) IntReferenceWindowObject(par);
-    return par;
-    //return IntGetWindowObject(hWnd);
-  }
-
-  return NULL;
+   HWND hWnd;
+
+   if (Wnd->Style & WS_POPUP)
+   {
+      hWnd = Wnd->hOwner;
+      return IntGetWindowObject(hWnd);
+   }
+   else if (Wnd->Style & WS_CHILD)
+   {
+      PWINDOW_OBJECT par;
+
+      par = Wnd->Parent;
+      if (par)
+         IntReferenceWindowObject(par);
+      return par;
+      //return IntGetWindowObject(hWnd);
+   }
+
+   return NULL;
 }
 
 PWINDOW_OBJECT FASTCALL
 IntGetOwner(PWINDOW_OBJECT Wnd)
 {
-  HWND hWnd;
+   HWND hWnd;
 
-  hWnd = Wnd->hOwner;
+   hWnd = Wnd->hOwner;
 
-  return IntGetWindowObject(hWnd);
+   return IntGetWindowObject(hWnd);
 }
 
 PWINDOW_OBJECT FASTCALL
 IntGetParentObject(PWINDOW_OBJECT Wnd)
 {
-  PWINDOW_OBJECT par;
-  
-  par = Wnd->Parent;
-  if (par) IntReferenceWindowObject(par);
-  return par;
+   PWINDOW_OBJECT par;
+
+   par = Wnd->Parent;
+   if (par)
+      IntReferenceWindowObject(par);
+   return par;
 }
 
 /*
@@ -214,13 +215,13 @@ IntWinListChildren(PWINDOW_OBJECT Window)
    List = ExAllocatePoolWithTag(PagedPool, (NumChildren + 1) * sizeof(HWND), TAG_WINLIST);
    if(!List)
    {
-     DPRINT1("Failed to allocate memory for children array\n");
-     SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-     return NULL;
+      DPRINT1("Failed to allocate memory for children array\n");
+      SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+      return NULL;
    }
    for (Child = Window->FirstChild, Index = 0;
-        Child != NULL;
-        Child = Child->NextSibling, ++Index)
+         Child != NULL;
+         Child = Child->NextSibling, ++Index)
       List[Index] = Child->hSelf;
    List[Index] = NULL;
 
@@ -233,68 +234,77 @@ IntWinListChildren(PWINDOW_OBJECT Window)
 static void IntSendDestroyMsg(HWND Wnd)
 {
 
-  PWINDOW_OBJECT Window, Owner, Parent;
+   PWINDOW_OBJECT Window, Owner, Parent;
 #if 0 /* FIXME */
-  GUITHREADINFO info;
 
-  if (GetGUIThreadInfo(GetCurrentThreadId(), &info))
-    {
+   GUITHREADINFO info;
+
+   if (GetGUIThreadInfo(GetCurrentThreadId(), &info))
+   {
       if (Wnd == info.hwndCaret)
-       {
-         DestroyCaret();
-       }
-    }
+      {
+         DestroyCaret();
+      }
+   }
 #endif
 
-  Window = IntGetWindowObject(Wnd);
-  if (Window) {
-    Owner = IntGetOwner(Window);
-    if (!Owner) {
-      Parent = IntGetParent(Window);
-      if (!Parent)
-        co_IntShellHookNotify(HSHELL_WINDOWDESTROYED, (LPARAM) Wnd);
+   Window = IntGetWindowObject(Wnd);
+   if (Window)
+   {
+      Owner = IntGetOwner(Window);
+      if (!Owner)
+      {
+         Parent = IntGetParent(Window);
+         if (!Parent)
+            co_IntShellHookNotify(HSHELL_WINDOWDESTROYED, (LPARAM) Wnd);
+         else
+            IntReleaseWindowObject(Parent);
+      }
       else
-        IntReleaseWindowObject(Parent);
-    } else {
-      IntReleaseWindowObject(Owner);
-    }
+      {
+         IntReleaseWindowObject(Owner);
+      }
 
-    IntReleaseWindowObject(Window);
-  }
+      IntReleaseWindowObject(Window);
+   }
 
-  /* The window could already be destroyed here */
+   /* The window could already be destroyed here */
 
-  /*
-   * Send the WM_DESTROY to the window.
-   */
+   /*
+    * Send the WM_DESTROY to the window.
+    */
 
-  co_IntSendMessage(Wnd, WM_DESTROY, 0, 0);
+   co_IntSendMessage(Wnd, WM_DESTROY, 0, 0);
 
-  /*
-   * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow
-   * make sure that the window still exists when we come back.
-   */
+   /*
+    * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow
+    * make sure that the window still exists when we come back.
+    */
 #if 0 /* FIXME */
-  if (IsWindow(Wnd))
-    {
+
+   if (IsWindow(Wnd))
+   {
       HWND* pWndArray;
       int i;
 
-      if (!(pWndArray = WIN_ListChildren( hwnd ))) return;
+      if (!(pWndArray = WIN_ListChildren( hwnd )))
+         return;
 
       /* start from the end (FIXME: is this needed?) */
-      for (i = 0; pWndArray[i]; i++) ;
+      for (i = 0; pWndArray[i]; i++)
+         ;
 
       while (--i >= 0)
-       {
-         if (IsWindow( pWndArray[i] )) WIN_SendDestroyMsg( pWndArray[i] );
-       }
+      {
+         if (IsWindow( pWndArray[i] ))
+            WIN_SendDestroyMsg( pWndArray[i] );
+      }
       HeapFree(GetProcessHeap(), 0, pWndArray);
-    }
-  else
-    {
+   }
+   else
+   {
       DPRINT("destroyed itself while in WM_DESTROY!\n");
-    }
+   }
 #endif
 }
 
@@ -304,196 +314,198 @@ static void IntSendDestroyMsg(HWND Wnd)
  * Destroy storage associated to a window. "Internals" p.358
  */
 static LRESULT co_IntDestroyWindow(PWINDOW_OBJECT Window,
-                                PW32PROCESS ProcessData,
-                                PW32THREAD ThreadData,
-                                BOOLEAN SendMessages)
+                                   PW32PROCESS ProcessData,
+                                   PW32THREAD ThreadData,
+                                   BOOLEAN SendMessages)
 {
-  HWND *Children;
-  HWND *ChildHandle;
-  PWINDOW_OBJECT Child;
-  PMENU_OBJECT Menu;
-  BOOLEAN BelongsToThreadData;
-
-  ASSERT(Window);
-
-  if(Window->Status & WINDOWSTATUS_DESTROYING)
-  {
-    DPRINT("Tried to call IntDestroyWindow() twice\n");
-    return 0;
-  }
-  Window->Status |= WINDOWSTATUS_DESTROYING;
-  Window->Flags &= ~WS_VISIBLE;
-  /* remove the window already at this point from the thread window list so we
-     don't get into trouble when destroying the thread windows while we're still
-     in IntDestroyWindow() */
-  RemoveEntryList(&Window->ThreadListEntry);
-
-  BelongsToThreadData = IntWndBelongsToThread(Window, ThreadData);
-
-  IntDeRegisterShellHookWindow(Window->hSelf);
-
-  if(SendMessages)
-  {
-    /* Send destroy messages */
-    IntSendDestroyMsg(Window->hSelf);
-  }
-
-  /* free child windows */
-  Children = IntWinListChildren(Window);
-  if (Children)
-    {
+   HWND *Children;
+   HWND *ChildHandle;
+   PWINDOW_OBJECT Child;
+   PMENU_OBJECT Menu;
+   BOOLEAN BelongsToThreadData;
+
+   ASSERT(Window);
+
+   if(Window->Status & WINDOWSTATUS_DESTROYING)
+   {
+      DPRINT("Tried to call IntDestroyWindow() twice\n");
+      return 0;
+   }
+   Window->Status |= WINDOWSTATUS_DESTROYING;
+   Window->Flags &= ~WS_VISIBLE;
+   /* remove the window already at this point from the thread window list so we
+      don't get into trouble when destroying the thread windows while we're still
+      in IntDestroyWindow() */
+   RemoveEntryList(&Window->ThreadListEntry);
+
+   BelongsToThreadData = IntWndBelongsToThread(Window, ThreadData);
+
+   IntDeRegisterShellHookWindow(Window->hSelf);
+
+   if(SendMessages)
+   {
+      /* Send destroy messages */
+      IntSendDestroyMsg(Window->hSelf);
+   }
+
+   /* free child windows */
+   Children = IntWinListChildren(Window);
+   if (Children)
+   {
       for (ChildHandle = Children; *ChildHandle; ++ChildHandle)
-        {
-          if ((Child = IntGetWindowObject(*ChildHandle)))
+      {
+         if ((Child = IntGetWindowObject(*ChildHandle)))
+         {
+            if(!IntWndBelongsToThread(Child, ThreadData))
             {
-              if(!IntWndBelongsToThread(Child, ThreadData))
-              {
-                /* send WM_DESTROY messages to windows not belonging to the same thread */
-                IntSendDestroyMsg(Child->hSelf);
-              }
-              else
-                co_IntDestroyWindow(Child, ProcessData, ThreadData, SendMessages);
-              IntReleaseWindowObject(Child);
+               /* send WM_DESTROY messages to windows not belonging to the same thread */
+               IntSendDestroyMsg(Child->hSelf);
             }
-        }
+            else
+               co_IntDestroyWindow(Child, ProcessData, ThreadData, SendMessages);
+            IntReleaseWindowObject(Child);
+         }
+      }
       ExFreePool(Children);
-    }
-
-  if(SendMessages)
-  {
-    /*
-     * Clear the update region to make sure no WM_PAINT messages will be
-     * generated for this window while processing the WM_NCDESTROY.
-     */
-    co_UserRedrawWindow(Window, NULL, 0,
-                    RDW_VALIDATE | RDW_NOFRAME | RDW_NOERASE |
-                    RDW_NOINTERNALPAINT | RDW_NOCHILDREN);
-    if(BelongsToThreadData)
-      co_IntSendMessage(Window->hSelf, WM_NCDESTROY, 0, 0);
-  }
-  MsqRemoveTimersWindow(ThreadData->MessageQueue, Window->hSelf);
-
-  /* flush the message queue */
-  MsqRemoveWindowMessagesFromQueue(Window);
-
-  /* from now on no messages can be sent to this window anymore */
-  Window->Status |= WINDOWSTATUS_DESTROYED;
-  /* don't remove the WINDOWSTATUS_DESTROYING bit */
-
-  /* reset shell window handles */
-  if(ThreadData->Desktop)
-  {
-    if (Window->hSelf == ThreadData->Desktop->WindowStation->ShellWindow)
-      ThreadData->Desktop->WindowStation->ShellWindow = NULL;
-
-    if (Window->hSelf == ThreadData->Desktop->WindowStation->ShellListView)
-      ThreadData->Desktop->WindowStation->ShellListView = NULL;
-  }
-
-  /* Unregister hot keys */
-  UnregisterWindowHotKeys (Window);
-
-  /* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */
+   }
+
+   if(SendMessages)
+   {
+      /*
+       * Clear the update region to make sure no WM_PAINT messages will be
+       * generated for this window while processing the WM_NCDESTROY.
+       */
+      co_UserRedrawWindow(Window, NULL, 0,
+                          RDW_VALIDATE | RDW_NOFRAME | RDW_NOERASE |
+                          RDW_NOINTERNALPAINT | RDW_NOCHILDREN);
+      if(BelongsToThreadData)
+         co_IntSendMessage(Window->hSelf, WM_NCDESTROY, 0, 0);
+   }
+   MsqRemoveTimersWindow(ThreadData->MessageQueue, Window->hSelf);
+
+   /* flush the message queue */
+   MsqRemoveWindowMessagesFromQueue(Window);
+
+   /* from now on no messages can be sent to this window anymore */
+   Window->Status |= WINDOWSTATUS_DESTROYED;
+   /* don't remove the WINDOWSTATUS_DESTROYING bit */
+
+   /* reset shell window handles */
+   if(ThreadData->Desktop)
+   {
+      if (Window->hSelf == ThreadData->Desktop->WindowStation->ShellWindow)
+         ThreadData->Desktop->WindowStation->ShellWindow = NULL;
+
+      if (Window->hSelf == ThreadData->Desktop->WindowStation->ShellListView)
+         ThreadData->Desktop->WindowStation->ShellListView = NULL;
+   }
+
+   /* Unregister hot keys */
+   UnregisterWindowHotKeys (Window);
+
+   /* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */
 
 #if 0 /* FIXME */
-  WinPosCheckInternalPos(Window->hSelf);
-  if (Window->hSelf == GetCapture())
-    {
+
+   WinPosCheckInternalPos(Window->hSelf);
+   if (Window->hSelf == GetCapture())
+   {
       ReleaseCapture();
-    }
+   }
 
-  /* free resources associated with the window */
-  TIMER_RemoveWindowTimers(Window->hSelf);
+   /* free resources associated with the window */
+   TIMER_RemoveWindowTimers(Window->hSelf);
 #endif
 
-  if (!(Window->Style & WS_CHILD) && Window->IDMenu
-      && (Menu = IntGetMenuObject((HMENU)Window->IDMenu)))
-    {
-       IntDestroyMenuObject(Menu, TRUE, TRUE);
-       Window->IDMenu = 0;
-       IntReleaseMenuObject(Menu);
-    }
-
-  if(Window->SystemMenu
-     && (Menu = IntGetMenuObject(Window->SystemMenu)))
-  {
-    IntDestroyMenuObject(Menu, TRUE, TRUE);
-    Window->SystemMenu = (HMENU)0;
-    IntReleaseMenuObject(Menu);
-  }
-
-  DceFreeWindowDCE(Window);    /* Always do this to catch orphaned DCs */
+   if (!(Window->Style & WS_CHILD) && Window->IDMenu
+         && (Menu = IntGetMenuObject((HMENU)Window->IDMenu)))
+   {
+      IntDestroyMenuObject(Menu, TRUE, TRUE);
+      Window->IDMenu = 0;
+      IntReleaseMenuObject(Menu);
+   }
+
+   if(Window->SystemMenu
+         && (Menu = IntGetMenuObject(Window->SystemMenu)))
+   {
+      IntDestroyMenuObject(Menu, TRUE, TRUE);
+      Window->SystemMenu = (HMENU)0;
+      IntReleaseMenuObject(Menu);
+   }
+
+   DceFreeWindowDCE(Window);    /* Always do this to catch orphaned DCs */
 #if 0 /* FIXME */
-  WINPROC_FreeProc(Window->winproc, WIN_PROC_WINDOW);
-  CLASS_RemoveWindow(Window->Class);
+
+   WINPROC_FreeProc(Window->winproc, WIN_PROC_WINDOW);
+   CLASS_RemoveWindow(Window->Class);
 #endif
 
-  IntUnlinkWindow(Window);
+   IntUnlinkWindow(Window);
 
-  IntReferenceWindowObject(Window);
-  ObmDeleteObject(Window->hSelf, otWindow);
+   IntReferenceWindowObject(Window);
+   ObmDeleteObject(Window->hSelf, otWindow);
 
-  IntDestroyScrollBars(Window);
+   IntDestroyScrollBars(Window);
 
-  /* remove the window from the class object */
-  RemoveEntryList(&Window->ClassListEntry);
+   /* remove the window from the class object */
+   RemoveEntryList(&Window->ClassListEntry);
 
-  /* dereference the class */
-  ClassDereferenceObject(Window->Class);
-  Window->Class = NULL;
+   /* dereference the class */
+   ClassDereferenceObject(Window->Class);
+   Window->Class = NULL;
 
-  if(Window->WindowRegion)
-  {
-    NtGdiDeleteObject(Window->WindowRegion);
-  }
+   if(Window->WindowRegion)
+   {
+      NtGdiDeleteObject(Window->WindowRegion);
+   }
 
-  RtlFreeUnicodeString(&Window->WindowName);
+   RtlFreeUnicodeString(&Window->WindowName);
 
-  IntReleaseWindowObject(Window);
+   IntReleaseWindowObject(Window);
 
-  return 0;
+   return 0;
 }
 
 VOID FASTCALL
 IntGetWindowBorderMeasures(PWINDOW_OBJECT Window, UINT *cx, UINT *cy)
 {
-  if(HAS_DLGFRAME(Window->Style, Window->ExStyle) && !(Window->Style & WS_MINIMIZE))
-  {
-    *cx = UserGetSystemMetrics(SM_CXDLGFRAME);
-    *cy = UserGetSystemMetrics(SM_CYDLGFRAME);
-  }
-  else
-  {
-    if(HAS_THICKFRAME(Window->Style, Window->ExStyle)&& !(Window->Style & WS_MINIMIZE))
-    {
-      *cx = UserGetSystemMetrics(SM_CXFRAME);
-      *cy = UserGetSystemMetrics(SM_CYFRAME);
-    }
-    else if(HAS_THINFRAME(Window->Style, Window->ExStyle))
-    {
-      *cx = UserGetSystemMetrics(SM_CXBORDER);
-      *cy = UserGetSystemMetrics(SM_CYBORDER);
-    }
-    else
-    {
-      *cx = *cy = 0;
-    }
-  }
+   if(HAS_DLGFRAME(Window->Style, Window->ExStyle) && !(Window->Style & WS_MINIMIZE))
+   {
+      *cx = UserGetSystemMetrics(SM_CXDLGFRAME);
+      *cy = UserGetSystemMetrics(SM_CYDLGFRAME);
+   }
+   else
+   {
+      if(HAS_THICKFRAME(Window->Style, Window->ExStyle)&& !(Window->Style & WS_MINIMIZE))
+      {
+         *cx = UserGetSystemMetrics(SM_CXFRAME);
+         *cy = UserGetSystemMetrics(SM_CYFRAME);
+      }
+      else if(HAS_THINFRAME(Window->Style, Window->ExStyle))
+      {
+         *cx = UserGetSystemMetrics(SM_CXBORDER);
+         *cy = UserGetSystemMetrics(SM_CYBORDER);
+      }
+      else
+      {
+         *cx = *cy = 0;
+      }
+   }
 }
 
 BOOL FASTCALL
 IntGetWindowInfo(PWINDOW_OBJECT Window, PWINDOWINFO pwi)
 {
-  pwi->cbSize = sizeof(WINDOWINFO);
-  pwi->rcWindow = Window->WindowRect;
-  pwi->rcClient = Window->ClientRect;
-  pwi->dwStyle = Window->Style;
-  pwi->dwExStyle = Window->ExStyle;
-  pwi->dwWindowStatus = (UserGetForegroundWindow() == Window->hSelf); /* WS_ACTIVECAPTION */
-  IntGetWindowBorderMeasures(Window, &pwi->cxWindowBorders, &pwi->cyWindowBorders);
-  pwi->atomWindowType = (Window->Class ? Window->Class->Atom : 0);
-  pwi->wCreatorVersion = 0x400; /* FIXME - return a real version number */
-  return TRUE;
+   pwi->cbSize = sizeof(WINDOWINFO);
+   pwi->rcWindow = Window->WindowRect;
+   pwi->rcClient = Window->ClientRect;
+   pwi->dwStyle = Window->Style;
+   pwi->dwExStyle = Window->ExStyle;
+   pwi->dwWindowStatus = (UserGetForegroundWindow() == Window->hSelf); /* WS_ACTIVECAPTION */
+   IntGetWindowBorderMeasures(Window, &pwi->cxWindowBorders, &pwi->cyWindowBorders);
+   pwi->atomWindowType = (Window->Class ? Window->Class->Atom : 0);
+   pwi->wCreatorVersion = 0x400; /* FIXME - return a real version number */
+   return TRUE;
 }
 
 static BOOL FASTCALL
@@ -502,68 +514,68 @@ IntSetMenu(
    HMENU Menu,
    BOOL *Changed)
 {
-  PMENU_OBJECT OldMenu, NewMenu = NULL;
+   PMENU_OBJECT OldMenu, NewMenu = NULL;
 
-  if ((Window->Style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
-    {
+   if ((Window->Style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
+   {
       SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
       return FALSE;
-    }
+   }
 
-  *Changed = (Window->IDMenu != (UINT) Menu);
-  if (! *Changed)
-    {
+   *Changed = (Window->IDMenu != (UINT) Menu);
+   if (! *Changed)
+   {
       return TRUE;
-    }
+   }
 
-  if (Window->IDMenu)
-    {
+   if (Window->IDMenu)
+   {
       OldMenu = IntGetMenuObject((HMENU) Window->IDMenu);
       ASSERT(NULL == OldMenu || OldMenu->MenuInfo.Wnd == Window->hSelf);
-    }
-  else
-    {
+   }
+   else
+   {
       OldMenu = NULL;
-    }
+   }
 
-  if (NULL != Menu)
-    {
+   if (NULL != Menu)
+   {
       NewMenu = IntGetMenuObject(Menu);
       if (NULL == NewMenu)
-        {
-          if (NULL != OldMenu)
-            {
-              IntReleaseMenuObject(OldMenu);
-            }
-          SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
-          return FALSE;
-        }
+      {
+         if (NULL != OldMenu)
+         {
+            IntReleaseMenuObject(OldMenu);
+         }
+         SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
+         return FALSE;
+      }
       if (NULL != NewMenu->MenuInfo.Wnd)
-        {
-          /* Can't use the same menu for two windows */
-          if (NULL != OldMenu)
-            {
-              IntReleaseMenuObject(OldMenu);
-            }
-          SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
-          return FALSE;
-        }
+      {
+         /* Can't use the same menu for two windows */
+         if (NULL != OldMenu)
+         {
+            IntReleaseMenuObject(OldMenu);
+         }
+         SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
+         return FALSE;
+      }
 
-    }
+   }
 
-  Window->IDMenu = (UINT) Menu;
-  if (NULL != NewMenu)
-    {
+   Window->IDMenu = (UINT) Menu;
+   if (NULL != NewMenu)
+   {
       NewMenu->MenuInfo.Wnd = Window->hSelf;
       IntReleaseMenuObject(NewMenu);
-    }
-  if (NULL != OldMenu)
-    {
+   }
+   if (NULL != OldMenu)
+   {
       OldMenu->MenuInfo.Wnd = NULL;
       IntReleaseMenuObject(OldMenu);
-    }
+   }
 
-  return TRUE;
+   return TRUE;
 }
 
 
@@ -573,49 +585,49 @@ IntSetMenu(
 VOID FASTCALL
 co_DestroyThreadWindows(struct _ETHREAD *Thread)
 {
-  PLIST_ENTRY Current;
-  PW32PROCESS Win32Process;
-  PW32THREAD Win32Thread;
-  PWINDOW_OBJECT *List, *pWnd;
-  ULONG Cnt = 0;
-
-  Win32Thread = Thread->Tcb.Win32Thread;
-  Win32Process = (PW32PROCESS)Thread->ThreadsProcess->Win32Process;
-
-  Current = Win32Thread->WindowListHead.Flink;
-  while (Current != &(Win32Thread->WindowListHead))
-  {
-    Cnt++;
-    Current = Current->Flink;
-  }
-
-  if(Cnt > 0)
-  {
-    List = ExAllocatePool(PagedPool, (Cnt + 1) * sizeof(PWINDOW_OBJECT));
-    if(!List)
-    {
-      DPRINT("Not enough memory to allocate window handle list\n");
-      return;
-    }
-    pWnd = List;
-    Current = Win32Thread->WindowListHead.Flink;
-    while (Current != &(Win32Thread->WindowListHead))
-    {
-      *pWnd = CONTAINING_RECORD(Current, WINDOW_OBJECT, ThreadListEntry);
-      IntReferenceWindowObject(*pWnd);
-      pWnd++;
+   PLIST_ENTRY Current;
+   PW32PROCESS Win32Process;
+   PW32THREAD Win32Thread;
+   PWINDOW_OBJECT *List, *pWnd;
+   ULONG Cnt = 0;
+
+   Win32Thread = Thread->Tcb.Win32Thread;
+   Win32Process = (PW32PROCESS)Thread->ThreadsProcess->Win32Process;
+
+   Current = Win32Thread->WindowListHead.Flink;
+   while (Current != &(Win32Thread->WindowListHead))
+   {
+      Cnt++;
       Current = Current->Flink;
-    }
-    *pWnd = NULL;
-
-    for(pWnd = List; *pWnd; pWnd++)
-    {
-      co_UserDestroyWindow(*pWnd);
-      IntReleaseWindowObject(*pWnd);
-    }
-    ExFreePool(List);
-    return;
-  }
+   }
+
+   if(Cnt > 0)
+   {
+      List = ExAllocatePool(PagedPool, (Cnt + 1) * sizeof(PWINDOW_OBJECT));
+      if(!List)
+      {
+         DPRINT("Not enough memory to allocate window handle list\n");
+         return;
+      }
+      pWnd = List;
+      Current = Win32Thread->WindowListHead.Flink;
+      while (Current != &(Win32Thread->WindowListHead))
+      {
+         *pWnd = CONTAINING_RECORD(Current, WINDOW_OBJECT, ThreadListEntry);
+         IntReferenceWindowObject(*pWnd);
+         pWnd++;
+         Current = Current->Flink;
+      }
+      *pWnd = NULL;
+
+      for(pWnd = List; *pWnd; pWnd++)
+      {
+         co_UserDestroyWindow(*pWnd);
+         IntReleaseWindowObject(*pWnd);
+      }
+      ExFreePool(List);
+      return;
+   }
 
 }
 
@@ -629,12 +641,12 @@ co_DestroyThreadWindows(struct _ETHREAD *Thread)
 VOID FASTCALL
 IntGetClientRect(PWINDOW_OBJECT Window, PRECT Rect)
 {
-  ASSERT( Window );
-  ASSERT( Rect );
+   ASSERT( Window );
+   ASSERT( Rect );
 
-  Rect->left = Rect->top = 0;
-  Rect->right = Window->ClientRect.right - Window->ClientRect.left;
-  Rect->bottom = Window->ClientRect.bottom - Window->ClientRect.top;
+   Rect->left = Rect->top = 0;
+   Rect->right = Window->ClientRect.right - Window->ClientRect.left;
+   Rect->bottom = Window->ClientRect.bottom - Window->ClientRect.top;
 }
 
 
@@ -642,17 +654,17 @@ IntGetClientRect(PWINDOW_OBJECT Window, PRECT Rect)
 HWND FASTCALL
 IntGetFocusWindow(VOID)
 {
-  PUSER_MESSAGE_QUEUE Queue;
-  PDESKTOP_OBJECT pdo = IntGetActiveDesktop();
+   PUSER_MESSAGE_QUEUE Queue;
+   PDESKTOP_OBJECT pdo = IntGetActiveDesktop();
 
-  if( !pdo )
-       return NULL;
+   if( !pdo )
+      return NULL;
 
-  Queue = (PUSER_MESSAGE_QUEUE)pdo->ActiveMessageQueue;
+   Queue = (PUSER_MESSAGE_QUEUE)pdo->ActiveMessageQueue;
 
-  if (Queue == NULL)
+   if (Queue == NULL)
       return(NULL);
-  else
+   else
       return(Queue->FocusWindow);
 }
 #endif
@@ -660,264 +672,264 @@ IntGetFocusWindow(VOID)
 PMENU_OBJECT FASTCALL
 IntGetSystemMenu(PWINDOW_OBJECT Window, BOOL bRevert, BOOL RetMenu)
 {
-  PMENU_OBJECT Menu, NewMenu = NULL, SysMenu = NULL, ret = NULL;
-  PW32THREAD W32Thread;
-  HMENU hNewMenu, hSysMenu;
-  ROSMENUITEMINFO ItemInfo;
+   PMENU_OBJECT Menu, NewMenu = NULL, SysMenu = NULL, ret = NULL;
+   PW32THREAD W32Thread;
+   HMENU hNewMenu, hSysMenu;
+   ROSMENUITEMINFO ItemInfo;
 
-  if(bRevert)
-  {
-    W32Thread = PsGetWin32Thread();
+   if(bRevert)
+   {
+      W32Thread = PsGetWin32Thread();
 
-    if(!W32Thread->Desktop)
-      return NULL;
+      if(!W32Thread->Desktop)
+         return NULL;
 
-    if(Window->SystemMenu)
-    {
-      Menu = IntGetMenuObject(Window->SystemMenu);
-      if(Menu)
+      if(Window->SystemMenu)
       {
-        IntDestroyMenuObject(Menu, FALSE, TRUE);
-        Window->SystemMenu = (HMENU)0;
-        IntReleaseMenuObject(Menu);
+         Menu = IntGetMenuObject(Window->SystemMenu);
+         if(Menu)
+         {
+            IntDestroyMenuObject(Menu, FALSE, TRUE);
+            Window->SystemMenu = (HMENU)0;
+            IntReleaseMenuObject(Menu);
+         }
       }
-    }
 
-    if(W32Thread->Desktop->WindowStation->SystemMenuTemplate)
-    {
-      /* clone system menu */
-      Menu = IntGetMenuObject(W32Thread->Desktop->WindowStation->SystemMenuTemplate);
-      if(!Menu)
-        return NULL;
-
-      NewMenu = IntCloneMenu(Menu);
-      if(NewMenu)
-      {
-        Window->SystemMenu = NewMenu->MenuInfo.Self;
-        NewMenu->MenuInfo.Flags |= MF_SYSMENU;
-        NewMenu->MenuInfo.Wnd = Window->hSelf;
-        ret = NewMenu;
-        //IntReleaseMenuObject(NewMenuObject);
-      }
-      IntReleaseMenuObject(Menu);
-    }
-    else
-    {
-      hSysMenu = UserCreateMenu(FALSE);
-      if (NULL == SysMenu)
-      {
-        return NULL;
-      }
-      SysMenu = IntGetMenuObject(hSysMenu);
-      if (NULL == SysMenu)
-      {
-        UserDestroyMenu(hSysMenu);
-        return NULL;
-      }
-      SysMenu->MenuInfo.Flags |= MF_SYSMENU;
-      SysMenu->MenuInfo.Wnd = Window->hSelf;
-      hNewMenu = co_IntLoadSysMenuTemplate();
-      if(!NewMenu)
+      if(W32Thread->Desktop->WindowStation->SystemMenuTemplate)
       {
-        IntReleaseMenuObject(SysMenu);
-        UserDestroyMenu(hSysMenu);
-        return NULL;
+         /* clone system menu */
+         Menu = IntGetMenuObject(W32Thread->Desktop->WindowStation->SystemMenuTemplate);
+         if(!Menu)
+            return NULL;
+
+         NewMenu = IntCloneMenu(Menu);
+         if(NewMenu)
+         {
+            Window->SystemMenu = NewMenu->MenuInfo.Self;
+            NewMenu->MenuInfo.Flags |= MF_SYSMENU;
+            NewMenu->MenuInfo.Wnd = Window->hSelf;
+            ret = NewMenu;
+            //IntReleaseMenuObject(NewMenuObject);
+         }
+         IntReleaseMenuObject(Menu);
       }
-      Menu = IntGetMenuObject(hNewMenu);
-      if(!Menu)
+      else
       {
-        IntReleaseMenuObject(SysMenu);
-        UserDestroyMenu(hSysMenu);
-        return NULL;
-      }
+         hSysMenu = UserCreateMenu(FALSE);
+         if (NULL == SysMenu)
+         {
+            return NULL;
+         }
+         SysMenu = IntGetMenuObject(hSysMenu);
+         if (NULL == SysMenu)
+         {
+            UserDestroyMenu(hSysMenu);
+            return NULL;
+         }
+         SysMenu->MenuInfo.Flags |= MF_SYSMENU;
+         SysMenu->MenuInfo.Wnd = Window->hSelf;
+         hNewMenu = co_IntLoadSysMenuTemplate();
+         if(!NewMenu)
+         {
+            IntReleaseMenuObject(SysMenu);
+            UserDestroyMenu(hSysMenu);
+            return NULL;
+         }
+         Menu = IntGetMenuObject(hNewMenu);
+         if(!Menu)
+         {
+            IntReleaseMenuObject(SysMenu);
+            UserDestroyMenu(hSysMenu);
+            return NULL;
+         }
 
-      NewMenu = IntCloneMenu(Menu);
-      if(NewMenu)
-      {
-        NewMenu->MenuInfo.Flags |= MF_SYSMENU | MF_POPUP;
-        IntReleaseMenuObject(NewMenu);
-        UserSetMenuDefaultItem(NewMenu, SC_CLOSE, FALSE);
-
-        ItemInfo.cbSize = sizeof(MENUITEMINFOW);
-        ItemInfo.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_STATE | MIIM_SUBMENU;
-        ItemInfo.fType = MF_POPUP;
-        ItemInfo.fState = MFS_ENABLED;
-        ItemInfo.dwTypeData = NULL;
-        ItemInfo.cch = 0;
-        ItemInfo.hSubMenu = NewMenu->MenuInfo.Self;
-        IntInsertMenuItem(SysMenu, (UINT) -1, TRUE, &ItemInfo);
-
-        Window->SystemMenu = SysMenu->MenuInfo.Self;
-
-        ret = SysMenu;
+         NewMenu = IntCloneMenu(Menu);
+         if(NewMenu)
+         {
+            NewMenu->MenuInfo.Flags |= MF_SYSMENU | MF_POPUP;
+            IntReleaseMenuObject(NewMenu);
+            UserSetMenuDefaultItem(NewMenu, SC_CLOSE, FALSE);
+
+            ItemInfo.cbSize = sizeof(MENUITEMINFOW);
+            ItemInfo.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_STATE | MIIM_SUBMENU;
+            ItemInfo.fType = MF_POPUP;
+            ItemInfo.fState = MFS_ENABLED;
+            ItemInfo.dwTypeData = NULL;
+            ItemInfo.cch = 0;
+            ItemInfo.hSubMenu = NewMenu->MenuInfo.Self;
+            IntInsertMenuItem(SysMenu, (UINT) -1, TRUE, &ItemInfo);
+
+            Window->SystemMenu = SysMenu->MenuInfo.Self;
+
+            ret = SysMenu;
+         }
+         IntDestroyMenuObject(Menu, FALSE, TRUE);
+         IntReleaseMenuObject(Menu);
       }
-      IntDestroyMenuObject(Menu, FALSE, TRUE);
-      IntReleaseMenuObject(Menu);
-    }
-    if(RetMenu)
-      return ret;
-    else
-      return NULL;
-  }
-  else
-  {
-    if(Window->SystemMenu)
-      return IntGetMenuObject((HMENU)Window->SystemMenu);
-    else
-      return NULL;
-  }
+      if(RetMenu)
+         return ret;
+      else
+         return NULL;
+   }
+   else
+   {
+      if(Window->SystemMenu)
+         return IntGetMenuObject((HMENU)Window->SystemMenu);
+      else
+         return NULL;
+   }
 }
 
 
 BOOL FASTCALL
 IntIsChildWindow(HWND Parent, HWND Child)
 {
-  PWINDOW_OBJECT BaseWindow, Window;
-
-  if(!(BaseWindow = UserGetWindowObject(Child)))
-  {
-    return FALSE;
-  }
-
-  Window = BaseWindow;
-  while (Window)
-  {
-    if (Window->hSelf == Parent)
-    {
-      return(TRUE);
-    }
-    if(!(Window->Style & WS_CHILD))
-    {
-      break;
-    }
-
-    Window = Window->Parent;
-  }
-
-  return(FALSE);
+   PWINDOW_OBJECT BaseWindow, Window;
+
+   if(!(BaseWindow = UserGetWindowObject(Child)))
+   {
+      return FALSE;
+   }
+
+   Window = BaseWindow;
+   while (Window)
+   {
+      if (Window->hSelf == Parent)
+      {
+         return(TRUE);
+      }
+      if(!(Window->Style & WS_CHILD))
+      {
+         break;
+      }
+
+      Window = Window->Parent;
+   }
+
+   return(FALSE);
 }
 
 BOOL FASTCALL
 IntIsWindowVisible(HWND hWnd)
 {
-  PWINDOW_OBJECT BaseWindow, Window, Old;
-
-  if(!(BaseWindow = IntGetWindowObject(hWnd)))
-  {
-    return FALSE;
-  }
-
-  Window = BaseWindow;
-  while(Window)
-  {
-    if(!(Window->Style & WS_CHILD))
-    {
-      break;
-    }
-    if(!(Window->Style & WS_VISIBLE))
-    {
-      if(Window != BaseWindow)
-        IntReleaseWindowObject(Window);
-      IntReleaseWindowObject(BaseWindow);
+   PWINDOW_OBJECT BaseWindow, Window, Old;
+
+   if(!(BaseWindow = IntGetWindowObject(hWnd)))
+   {
       return FALSE;
-    }
-    Old = Window;
-    Window = IntGetParentObject(Window);
-    if(Old != BaseWindow)
-      IntReleaseWindowObject(Old);
-  }
-
-  if(Window)
-  {
-    if(Window->Style & WS_VISIBLE)
-    {
+   }
+
+   Window = BaseWindow;
+   while(Window)
+   {
+      if(!(Window->Style & WS_CHILD))
+      {
+         break;
+      }
+      if(!(Window->Style & WS_VISIBLE))
+      {
+         if(Window != BaseWindow)
+            IntReleaseWindowObject(Window);
+         IntReleaseWindowObject(BaseWindow);
+         return FALSE;
+      }
+      Old = Window;
+      Window = IntGetParentObject(Window);
+      if(Old != BaseWindow)
+         IntReleaseWindowObject(Old);
+   }
+
+   if(Window)
+   {
+      if(Window->Style & WS_VISIBLE)
+      {
+         if(Window != BaseWindow)
+            IntReleaseWindowObject(Window);
+         IntReleaseWindowObject(BaseWindow);
+         return TRUE;
+      }
       if(Window != BaseWindow)
-        IntReleaseWindowObject(Window);
-      IntReleaseWindowObject(BaseWindow);
-      return TRUE;
-    }
-    if(Window != BaseWindow)
-      IntReleaseWindowObject(Window);
-  }
-  IntReleaseWindowObject(BaseWindow);
-  return FALSE;
+         IntReleaseWindowObject(Window);
+   }
+   IntReleaseWindowObject(BaseWindow);
+   return FALSE;
 }
 
 
 /* link the window into siblings and parent. children are kept in place. */
 VOID FASTCALL
 IntLinkWindow(
-  PWINDOW_OBJECT Wnd,
-  PWINDOW_OBJECT WndParent,
-  PWINDOW_OBJECT WndPrevSibling /* set to NULL if top sibling */
-  )
+   PWINDOW_OBJECT Wnd,
+   PWINDOW_OBJECT WndParent,
+   PWINDOW_OBJECT WndPrevSibling /* set to NULL if top sibling */
+)
 {
-  PWINDOW_OBJECT Parent;
-
-  Wnd->Parent = WndParent;
-  if ((Wnd->PrevSibling = WndPrevSibling))
-  {
-    /* link after WndPrevSibling */
-    if ((Wnd->NextSibling = WndPrevSibling->NextSibling))
-      Wnd->NextSibling->PrevSibling = Wnd;
-    else if ((Parent = Wnd->Parent))
-    {
-      if(Parent->LastChild == WndPrevSibling)
-        Parent->LastChild = Wnd;
-    }
-    Wnd->PrevSibling->NextSibling = Wnd;
-  }
-  else
-  {
-    /* link at top */
-    Parent = Wnd->Parent;
-    if ((Wnd->NextSibling = WndParent->FirstChild))
-      Wnd->NextSibling->PrevSibling = Wnd;
-    else if (Parent)
-    {
-      Parent->LastChild = Wnd;
-      Parent->FirstChild = Wnd;
-      return;
-    }
-    if(Parent)
-    {
-      Parent->FirstChild = Wnd;
-    }
-  }
+   PWINDOW_OBJECT Parent;
+
+   Wnd->Parent = WndParent;
+   if ((Wnd->PrevSibling = WndPrevSibling))
+   {
+      /* link after WndPrevSibling */
+      if ((Wnd->NextSibling = WndPrevSibling->NextSibling))
+         Wnd->NextSibling->PrevSibling = Wnd;
+      else if ((Parent = Wnd->Parent))
+      {
+         if(Parent->LastChild == WndPrevSibling)
+            Parent->LastChild = Wnd;
+      }
+      Wnd->PrevSibling->NextSibling = Wnd;
+   }
+   else
+   {
+      /* link at top */
+      Parent = Wnd->Parent;
+      if ((Wnd->NextSibling = WndParent->FirstChild))
+         Wnd->NextSibling->PrevSibling = Wnd;
+      else if (Parent)
+      {
+         Parent->LastChild = Wnd;
+         Parent->FirstChild = Wnd;
+         return;
+      }
+      if(Parent)
+      {
+         Parent->FirstChild = Wnd;
+      }
+   }
 
 }
 
 HWND FASTCALL
 IntSetOwner(HWND hWnd, HWND hWndNewOwner)
 {
-  PWINDOW_OBJECT Wnd, WndOldOwner, WndNewOwner;
-  HWND ret;
-
-  Wnd = IntGetWindowObject(hWnd);
-  if(!Wnd)
-    return NULL;
-
-  WndOldOwner = IntGetWindowObject(Wnd->hOwner);
-  if (WndOldOwner)
-  {
-     ret = WndOldOwner->hSelf;
-     IntReleaseWindowObject(WndOldOwner);
-  }
-  else
-  {
-     ret = 0;
-  }
-
-  if((WndNewOwner = IntGetWindowObject(hWndNewOwner)))
-  {
-    Wnd->hOwner = hWndNewOwner;
-    IntReleaseWindowObject(WndNewOwner);
-  }
-  else
-    Wnd->hOwner = NULL;
-
-  IntReleaseWindowObject(Wnd);
-  return ret;
+   PWINDOW_OBJECT Wnd, WndOldOwner, WndNewOwner;
+   HWND ret;
+
+   Wnd = IntGetWindowObject(hWnd);
+   if(!Wnd)
+      return NULL;
+
+   WndOldOwner = IntGetWindowObject(Wnd->hOwner);
+   if (WndOldOwner)
+   {
+      ret = WndOldOwner->hSelf;
+      IntReleaseWindowObject(WndOldOwner);
+   }
+   else
+   {
+      ret = 0;
+   }
+
+   if((WndNewOwner = IntGetWindowObject(hWndNewOwner)))
+   {
+      Wnd->hOwner = hWndNewOwner;
+      IntReleaseWindowObject(WndNewOwner);
+   }
+   else
+      Wnd->hOwner = NULL;
+
+   IntReleaseWindowObject(Wnd);
+   return ret;
 }
 
 PWINDOW_OBJECT FASTCALL
@@ -959,23 +971,23 @@ co_IntSetParent(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndNewParent)
       InsertAfter = NULL;
       if (0 == (Wnd->ExStyle & WS_EX_TOPMOST))
       {
-        /* Not a TOPMOST window, put after TOPMOSTs of new parent */
-        Sibling = WndNewParent->FirstChild;
-        while (NULL != Sibling && 0 != (Sibling->ExStyle & WS_EX_TOPMOST))
-        {
-          InsertAfter = Sibling;
-          Sibling = Sibling->NextSibling;
-        }
+         /* Not a TOPMOST window, put after TOPMOSTs of new parent */
+         Sibling = WndNewParent->FirstChild;
+         while (NULL != Sibling && 0 != (Sibling->ExStyle & WS_EX_TOPMOST))
+         {
+            InsertAfter = Sibling;
+            Sibling = Sibling->NextSibling;
+         }
       }
       if (NULL == InsertAfter)
       {
-        IntLinkWindow(Wnd, WndNewParent, InsertAfter /*prev sibling*/);
+         IntLinkWindow(Wnd, WndNewParent, InsertAfter /*prev sibling*/);
       }
       else
       {
-        IntReferenceWindowObject(InsertAfter);
-        IntLinkWindow(Wnd, WndNewParent, InsertAfter /*prev sibling*/);
-        IntReleaseWindowObject(InsertAfter);
+         IntReferenceWindowObject(InsertAfter);
+         IntLinkWindow(Wnd, WndNewParent, InsertAfter /*prev sibling*/);
+         IntReleaseWindowObject(InsertAfter);
       }
 
       if (WndNewParent->hSelf != IntGetDesktopWindow()) /* a child window */
@@ -994,8 +1006,8 @@ co_IntSetParent(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndNewParent)
     * WM_WINDOWPOSCHANGED notification messages.
     */
    co_WinPosSetWindowPos(Wnd, (0 == (Wnd->ExStyle & WS_EX_TOPMOST) ? HWND_TOP : HWND_TOPMOST),
-                      0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE
-                                | (WasVisible ? SWP_SHOWWINDOW : 0));
+                         0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE
+                         | (WasVisible ? SWP_SHOWWINDOW : 0));
 
    /*
     * FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
@@ -1008,15 +1020,15 @@ co_IntSetParent(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndNewParent)
     */
    if(WndOldParent)
    {
-     if(!IntIsWindow(WndOldParent->hSelf))
-     {
-       IntReleaseWindowObject(WndOldParent);
-       return NULL;
-     }
+      if(!IntIsWindow(WndOldParent->hSelf))
+      {
+         IntReleaseWindowObject(WndOldParent);
+         return NULL;
+      }
 
-     /* don't dereference the window object here, it must be done by the caller
-        of IntSetParent() */
-     return WndOldParent;
+      /* don't dereference the window object here, it must be done by the caller
+         of IntSetParent() */
+      return WndOldParent;
    }
    return NULL;
 }
@@ -1024,27 +1036,27 @@ co_IntSetParent(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndNewParent)
 BOOL FASTCALL
 IntSetSystemMenu(PWINDOW_OBJECT Window, PMENU_OBJECT Menu)
 {
-  PMENU_OBJECT OldMenu;
-  if(Window->SystemMenu)
-  {
-    OldMenu = IntGetMenuObject(Window->SystemMenu);
-    if(OldMenu)
-    {
-      OldMenu->MenuInfo.Flags &= ~ MF_SYSMENU;
-      IntReleaseMenuObject(OldMenu);
-    }
-  }
-
-  if(Menu)
-  {
-    /* FIXME check window style, propably return FALSE ? */
-    Window->SystemMenu = Menu->MenuInfo.Self;
-    Menu->MenuInfo.Flags |= MF_SYSMENU;
-  }
-  else
-    Window->SystemMenu = (HMENU)0;
-
-  return TRUE;
+   PMENU_OBJECT OldMenu;
+   if(Window->SystemMenu)
+   {
+      OldMenu = IntGetMenuObject(Window->SystemMenu);
+      if(OldMenu)
+      {
+         OldMenu->MenuInfo.Flags &= ~ MF_SYSMENU;
+         IntReleaseMenuObject(OldMenu);
+      }
+   }
+
+   if(Menu)
+   {
+      /* FIXME check window style, propably return FALSE ? */
+      Window->SystemMenu = Menu->MenuInfo.Self;
+      Menu->MenuInfo.Flags |= MF_SYSMENU;
+   }
+   else
+      Window->SystemMenu = (HMENU)0;
+
+   return TRUE;
 }
 
 
@@ -1052,49 +1064,53 @@ IntSetSystemMenu(PWINDOW_OBJECT Window, PMENU_OBJECT Menu)
 VOID FASTCALL
 IntUnlinkWindow(PWINDOW_OBJECT Wnd)
 {
-  PWINDOW_OBJECT WndParent = Wnd->Parent;
+   PWINDOW_OBJECT WndParent = Wnd->Parent;
 
-  if (Wnd->NextSibling) Wnd->NextSibling->PrevSibling = Wnd->PrevSibling;
-  else if (WndParent && WndParent->LastChild == Wnd) WndParent->LastChild = Wnd->PrevSibling;
+   if (Wnd->NextSibling)
+      Wnd->NextSibling->PrevSibling = Wnd->PrevSibling;
+   else if (WndParent && WndParent->LastChild == Wnd)
+      WndParent->LastChild = Wnd->PrevSibling;
 
-  if (Wnd->PrevSibling) Wnd->PrevSibling->NextSibling = Wnd->NextSibling;
-  else if (WndParent && WndParent->FirstChild == Wnd) WndParent->FirstChild = Wnd->NextSibling;
+   if (Wnd->PrevSibling)
+      Wnd->PrevSibling->NextSibling = Wnd->NextSibling;
+   else if (WndParent && WndParent->FirstChild == Wnd)
+      WndParent->FirstChild = Wnd->NextSibling;
 
-  Wnd->PrevSibling = Wnd->NextSibling = Wnd->Parent = NULL;
+   Wnd->PrevSibling = Wnd->NextSibling = Wnd->Parent = NULL;
 }
 
 BOOL FASTCALL
 IntAnyPopup(VOID)
 {
-  PWINDOW_OBJECT Window, Child;
-
-  if(!(Window = IntGetWindowObject(IntGetDesktopWindow())))
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return FALSE;
-  }
-
-  for(Child = Window->FirstChild; Child; Child = Child->NextSibling)
-  {
-    if(Child->hOwner && Child->Style & WS_VISIBLE)
-    {
-      /*
-       * The desktop has a popup window if one of them has
-       * an owner window and is visible
-       */
-      IntReleaseWindowObject(Window);
-      return TRUE;
-    }
-  }
+   PWINDOW_OBJECT Window, Child;
 
-  IntReleaseWindowObject(Window);
-  return FALSE;
+   if(!(Window = IntGetWindowObject(IntGetDesktopWindow())))
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      return FALSE;
+   }
+
+   for(Child = Window->FirstChild; Child; Child = Child->NextSibling)
+   {
+      if(Child->hOwner && Child->Style & WS_VISIBLE)
+      {
+         /*
+          * The desktop has a popup window if one of them has
+          * an owner window and is visible
+          */
+         IntReleaseWindowObject(Window);
+         return TRUE;
+      }
+   }
+
+   IntReleaseWindowObject(Window);
+   return FALSE;
 }
 
 BOOL FASTCALL
 IntIsWindowInDestroy(PWINDOW_OBJECT Window)
 {
-  return ((Window->Status & WINDOWSTATUS_DESTROYING) == WINDOWSTATUS_DESTROYING);
+   return ((Window->Status & WINDOWSTATUS_DESTROYING) == WINDOWSTATUS_DESTROYING);
 }
 
 /* FUNCTIONS *****************************************************************/
@@ -1104,12 +1120,12 @@ IntIsWindowInDestroy(PWINDOW_OBJECT Window)
  */
 DWORD STDCALL
 NtUserAlterWindowStyle(DWORD Unknown0,
-                      DWORD Unknown1,
-                      DWORD Unknown2)
+                       DWORD Unknown1,
+                       DWORD Unknown2)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return(0);
+   return(0);
 }
 
 
@@ -1127,135 +1143,135 @@ NtUserAlterWindowStyle(DWORD Unknown0,
 ULONG
 STDCALL
 NtUserBuildHwndList(
-  HDESK hDesktop,
-  HWND hwndParent,
-  BOOLEAN bChildren,
-  ULONG dwThreadId,
-  ULONG lParam,
-  HWND* pWnd,
-  ULONG nBufSize)
+   HDESK hDesktop,
+   HWND hwndParent,
+   BOOLEAN bChildren,
+   ULONG dwThreadId,
+   ULONG lParam,
+   HWND* pWnd,
+   ULONG nBufSize)
 {
-  NTSTATUS Status;
-  ULONG dwCount = 0;
+   NTSTATUS Status;
+   ULONG dwCount = 0;
 
-  /* FIXME handle bChildren */
+   /* FIXME handle bChildren */
 
-  if(hwndParent)
-  {
-    PWINDOW_OBJECT Window, Child;
-    if(!(Window = IntGetWindowObject(hwndParent)))
-    {
-      SetLastWin32Error(ERROR_INVALID_HANDLE);
-      return 0;
-    }
+   if(hwndParent)
+   {
+      PWINDOW_OBJECT Window, Child;
+      if(!(Window = IntGetWindowObject(hwndParent)))
+      {
+         SetLastWin32Error(ERROR_INVALID_HANDLE);
+         return 0;
+      }
 
-    for(Child = Window->FirstChild; Child != NULL; Child = Child->NextSibling)
-    {
-      if(dwCount++ < nBufSize && pWnd)
+      for(Child = Window->FirstChild; Child != NULL; Child = Child->NextSibling)
       {
-        Status = MmCopyToCaller(pWnd++, &Child->hSelf, sizeof(HWND));
-        if(!NT_SUCCESS(Status))
-        {
-          SetLastNtError(Status);
-          break;
-        }
+         if(dwCount++ < nBufSize && pWnd)
+         {
+            Status = MmCopyToCaller(pWnd++, &Child->hSelf, sizeof(HWND));
+            if(!NT_SUCCESS(Status))
+            {
+               SetLastNtError(Status);
+               break;
+            }
+         }
       }
-    }
-
-    IntReleaseWindowObject(Window);
-  }
-  else if(dwThreadId)
-  {
-    PETHREAD Thread;
-    PW32THREAD W32Thread;
-    PLIST_ENTRY Current;
-    PWINDOW_OBJECT Window;
-
-    Status = PsLookupThreadByThreadId((HANDLE)dwThreadId, &Thread);
-    if(!NT_SUCCESS(Status))
-    {
-      SetLastWin32Error(ERROR_INVALID_PARAMETER);
-      return 0;
-    }
-    if(!(W32Thread = Thread->Tcb.Win32Thread))
-    {
-      ObDereferenceObject(Thread);
-      DPRINT("Thread is not a GUI Thread!\n");
-      SetLastWin32Error(ERROR_INVALID_PARAMETER);
-      return 0;
-    }
 
-    Current = W32Thread->WindowListHead.Flink;
-    while(Current != &(W32Thread->WindowListHead))
-    {
-      Window = CONTAINING_RECORD(Current, WINDOW_OBJECT, ThreadListEntry);
-      ASSERT(Window);
+      IntReleaseWindowObject(Window);
+   }
+   else if(dwThreadId)
+   {
+      PETHREAD Thread;
+      PW32THREAD W32Thread;
+      PLIST_ENTRY Current;
+      PWINDOW_OBJECT Window;
 
-      if(dwCount < nBufSize && pWnd)
+      Status = PsLookupThreadByThreadId((HANDLE)dwThreadId, &Thread);
+      if(!NT_SUCCESS(Status))
       {
-        Status = MmCopyToCaller(pWnd++, &Window->hSelf, sizeof(HWND));
-        if(!NT_SUCCESS(Status))
-        {
-          SetLastNtError(Status);
-          break;
-        }
+         SetLastWin32Error(ERROR_INVALID_PARAMETER);
+         return 0;
       }
-      dwCount++;
-      Current = Current->Flink;
-    }
-
-    ObDereferenceObject(Thread);
-  }
-  else
-  {
-    PDESKTOP_OBJECT Desktop;
-    PWINDOW_OBJECT Window, Child;
-
-    if(hDesktop == NULL && !(Desktop = IntGetActiveDesktop()))
-    {
-      SetLastWin32Error(ERROR_INVALID_HANDLE);
-      return 0;
-    }
-
-    if(hDesktop)
-    {
-      Status = IntValidateDesktopHandle(hDesktop,
-                                        UserMode,
-                                        0,
-                                        &Desktop);
-      if(!NT_SUCCESS(Status))
+      if(!(W32Thread = Thread->Tcb.Win32Thread))
       {
-        SetLastWin32Error(ERROR_INVALID_HANDLE);
-        return 0;
+         ObDereferenceObject(Thread);
+         DPRINT("Thread is not a GUI Thread!\n");
+         SetLastWin32Error(ERROR_INVALID_PARAMETER);
+         return 0;
       }
-    }
-    if(!(Window = IntGetWindowObject(Desktop->DesktopWindow)))
-    {
+
+      Current = W32Thread->WindowListHead.Flink;
+      while(Current != &(W32Thread->WindowListHead))
+      {
+         Window = CONTAINING_RECORD(Current, WINDOW_OBJECT, ThreadListEntry);
+         ASSERT(Window);
+
+         if(dwCount < nBufSize && pWnd)
+         {
+            Status = MmCopyToCaller(pWnd++, &Window->hSelf, sizeof(HWND));
+            if(!NT_SUCCESS(Status))
+            {
+               SetLastNtError(Status);
+               break;
+            }
+         }
+         dwCount++;
+         Current = Current->Flink;
+      }
+
+      ObDereferenceObject(Thread);
+   }
+   else
+   {
+      PDESKTOP_OBJECT Desktop;
+      PWINDOW_OBJECT Window, Child;
+
+      if(hDesktop == NULL && !(Desktop = IntGetActiveDesktop()))
+      {
+         SetLastWin32Error(ERROR_INVALID_HANDLE);
+         return 0;
+      }
+
       if(hDesktop)
-        ObDereferenceObject(Desktop);
-      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-      return 0;
-    }
+      {
+         Status = IntValidateDesktopHandle(hDesktop,
+                                           UserMode,
+                                           0,
+                                           &Desktop);
+         if(!NT_SUCCESS(Status))
+         {
+            SetLastWin32Error(ERROR_INVALID_HANDLE);
+            return 0;
+         }
+      }
+      if(!(Window = IntGetWindowObject(Desktop->DesktopWindow)))
+      {
+         if(hDesktop)
+            ObDereferenceObject(Desktop);
+         SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+         return 0;
+      }
 
-    for(Child = Window->FirstChild; Child != NULL; Child = Child->NextSibling)
-    {
-      if(dwCount++ < nBufSize && pWnd)
+      for(Child = Window->FirstChild; Child != NULL; Child = Child->NextSibling)
       {
-        Status = MmCopyToCaller(pWnd++, &Child->hSelf, sizeof(HWND));
-        if(!NT_SUCCESS(Status))
-        {
-          SetLastNtError(Status);
-          break;
-        }
+         if(dwCount++ < nBufSize && pWnd)
+         {
+            Status = MmCopyToCaller(pWnd++, &Child->hSelf, sizeof(HWND));
+            if(!NT_SUCCESS(Status))
+            {
+               SetLastNtError(Status);
+               break;
+            }
+         }
       }
-    }
 
-    IntReleaseWindowObject(Window);
-    if(hDesktop)
-      ObDereferenceObject(Desktop);
-  }
+      IntReleaseWindowObject(Window);
+      if(hDesktop)
+         ObDereferenceObject(Desktop);
+   }
 
-  return dwCount;
+   return dwCount;
 }
 
 
@@ -1264,73 +1280,73 @@ NtUserBuildHwndList(
  */
 HWND STDCALL
 NtUserChildWindowFromPointEx(HWND hwndParent,
-                            LONG x,
-                            LONG y,
-                            UINT uiFlags)
+                             LONG x,
+                             LONG y,
+                             UINT uiFlags)
 {
-  PWINDOW_OBJECT Parent;
-  POINTL Pt;
-  HWND Ret;
-  HWND *List, *phWnd;
-
-  if(!(Parent = IntGetWindowObject(hwndParent)))
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return NULL;
-  }
-
-  Pt.x = x;
-  Pt.y = y;
-
-  if(Parent->hSelf != IntGetDesktopWindow())
-  {
-    Pt.x += Parent->ClientRect.left;
-    Pt.y += Parent->ClientRect.top;
-  }
-
-  if(!IntPtInWindow(Parent, Pt.x, Pt.y))
-  {
-    IntReleaseWindowObject(Parent);
-    return NULL;
-  }
-
-  Ret = Parent->hSelf;
-  if((List = IntWinListChildren(Parent)))
-  {
-    for(phWnd = List; *phWnd; phWnd++)
-    {
-      PWINDOW_OBJECT Child;
-      if((Child = IntGetWindowObject(*phWnd)))
+   PWINDOW_OBJECT Parent;
+   POINTL Pt;
+   HWND Ret;
+   HWND *List, *phWnd;
+
+   if(!(Parent = IntGetWindowObject(hwndParent)))
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      return NULL;
+   }
+
+   Pt.x = x;
+   Pt.y = y;
+
+   if(Parent->hSelf != IntGetDesktopWindow())
+   {
+      Pt.x += Parent->ClientRect.left;
+      Pt.y += Parent->ClientRect.top;
+   }
+
+   if(!IntPtInWindow(Parent, Pt.x, Pt.y))
+   {
+      IntReleaseWindowObject(Parent);
+      return NULL;
+   }
+
+   Ret = Parent->hSelf;
+   if((List = IntWinListChildren(Parent)))
+   {
+      for(phWnd = List; *phWnd; phWnd++)
       {
-        if(!(Child->Style & WS_VISIBLE) && (uiFlags & CWP_SKIPINVISIBLE))
-        {
-          IntReleaseWindowObject(Child);
-          continue;
-        }
-        if((Child->Style & WS_DISABLED) && (uiFlags & CWP_SKIPDISABLED))
-        {
-          IntReleaseWindowObject(Child);
-          continue;
-        }
-        if((Child->ExStyle & WS_EX_TRANSPARENT) && (uiFlags & CWP_SKIPTRANSPARENT))
-        {
-          IntReleaseWindowObject(Child);
-          continue;
-        }
-        if(IntPtInWindow(Child, Pt.x, Pt.y))
-        {
-          Ret = Child->hSelf;
-          IntReleaseWindowObject(Child);
-          break;
-        }
-        IntReleaseWindowObject(Child);
+         PWINDOW_OBJECT Child;
+         if((Child = IntGetWindowObject(*phWnd)))
+         {
+            if(!(Child->Style & WS_VISIBLE) && (uiFlags & CWP_SKIPINVISIBLE))
+            {
+               IntReleaseWindowObject(Child);
+               continue;
+            }
+            if((Child->Style & WS_DISABLED) && (uiFlags & CWP_SKIPDISABLED))
+            {
+               IntReleaseWindowObject(Child);
+               continue;
+            }
+            if((Child->ExStyle & WS_EX_TRANSPARENT) && (uiFlags & CWP_SKIPTRANSPARENT))
+            {
+               IntReleaseWindowObject(Child);
+               continue;
+            }
+            if(IntPtInWindow(Child, Pt.x, Pt.y))
+            {
+               Ret = Child->hSelf;
+               IntReleaseWindowObject(Child);
+               break;
+            }
+            IntReleaseWindowObject(Child);
+         }
       }
-    }
-    ExFreePool(List);
-  }
+      ExFreePool(List);
+   }
 
-  IntReleaseWindowObject(Parent);
-  return Ret;
+   IntReleaseWindowObject(Parent);
+   return Ret;
 }
 
 
@@ -1340,44 +1356,44 @@ NtUserChildWindowFromPointEx(HWND hwndParent,
 BOOL FASTCALL
 IntCalcDefPosSize(PWINDOW_OBJECT Parent, PWINDOW_OBJECT Window, RECT *rc, BOOL IncPos)
 {
-  SIZE Sz;
-  POINT Pos = {0, 0};
-
-  if(Parent != NULL)
-  {
-    IntGdiIntersectRect(rc, rc, &Parent->ClientRect);
-
-    if(IncPos)
-    {
-      Pos.x = Parent->TiledCounter * (UserGetSystemMetrics(SM_CXSIZE) + UserGetSystemMetrics(SM_CXFRAME));
-      Pos.y = Parent->TiledCounter * (UserGetSystemMetrics(SM_CYSIZE) + UserGetSystemMetrics(SM_CYFRAME));
-      if(Pos.x > ((rc->right - rc->left) / 4) ||
-         Pos.y > ((rc->bottom - rc->top) / 4))
+   SIZE Sz;
+   POINT Pos = {0, 0};
+
+   if(Parent != NULL)
+   {
+      IntGdiIntersectRect(rc, rc, &Parent->ClientRect);
+
+      if(IncPos)
       {
-        /* reset counter and position */
-        Pos.x = 0;
-        Pos.y = 0;
-        Parent->TiledCounter = 0;
+         Pos.x = Parent->TiledCounter * (UserGetSystemMetrics(SM_CXSIZE) + UserGetSystemMetrics(SM_CXFRAME));
+         Pos.y = Parent->TiledCounter * (UserGetSystemMetrics(SM_CYSIZE) + UserGetSystemMetrics(SM_CYFRAME));
+         if(Pos.x > ((rc->right - rc->left) / 4) ||
+               Pos.y > ((rc->bottom - rc->top) / 4))
+         {
+            /* reset counter and position */
+            Pos.x = 0;
+            Pos.y = 0;
+            Parent->TiledCounter = 0;
+         }
+         Parent->TiledCounter++;
       }
-      Parent->TiledCounter++;
-    }
-    Pos.x += rc->left;
-    Pos.y += rc->top;
-  }
-  else
-  {
-    Pos.x = rc->left;
-    Pos.y = rc->top;
-  }
-
-  Sz.cx = EngMulDiv(rc->right - rc->left, 3, 4);
-  Sz.cy = EngMulDiv(rc->bottom - rc->top, 3, 4);
-
-  rc->left = Pos.x;
-  rc->top = Pos.y;
-  rc->right = rc->left + Sz.cx;
-  rc->bottom = rc->top + Sz.cy;
-  return TRUE;
+      Pos.x += rc->left;
+      Pos.y += rc->top;
+   }
+   else
+   {
+      Pos.x = rc->left;
+      Pos.y = rc->top;
+   }
+
+   Sz.cx = EngMulDiv(rc->right - rc->left, 3, 4);
+   Sz.cy = EngMulDiv(rc->bottom - rc->top, 3, 4);
+
+   rc->left = Pos.x;
+   rc->top = Pos.y;
+   rc->right = rc->left + Sz.cx;
+   rc->bottom = rc->top + Sz.cy;
+   return TRUE;
 }
 
 
@@ -1386,292 +1402,298 @@ IntCalcDefPosSize(PWINDOW_OBJECT Parent, PWINDOW_OBJECT Window, RECT *rc, BOOL I
  */
 HWND STDCALL
 co_IntCreateWindowEx(DWORD dwExStyle,
-                 PUNICODE_STRING ClassName,
-                 PUNICODE_STRING WindowName,
-                 DWORD dwStyle,
-                 LONG x,
-                 LONG y,
-                 LONG nWidth,
-                 LONG nHeight,
-                 HWND hWndParent,
-                 HMENU hMenu,
-                 HINSTANCE hInstance,
-                 LPVOID lpParam,
-                 DWORD dwShowMode,
-                 BOOL bUnicodeWindow)
+                     PUNICODE_STRING ClassName,
+                     PUNICODE_STRING WindowName,
+                     DWORD dwStyle,
+                     LONG x,
+                     LONG y,
+                     LONG nWidth,
+                     LONG nHeight,
+                     HWND hWndParent,
+                     HMENU hMenu,
+                     HINSTANCE hInstance,
+                     LPVOID lpParam,
+                     DWORD dwShowMode,
+                     BOOL bUnicodeWindow)
 {
-  PWINSTATION_OBJECT WinSta;
-  PWNDCLASS_OBJECT Class;
-  PWINDOW_OBJECT Window = NULL;
-  PWINDOW_OBJECT ParentWindow = NULL, OwnerWindow;
-  HWND ParentWindowHandle;
-  HWND OwnerWindowHandle;
-  PMENU_OBJECT SystemMenu;
-  HANDLE Handle;
-  POINT Pos;
-  SIZE Size;
+   PWINSTATION_OBJECT WinSta;
+   PWNDCLASS_OBJECT Class;
+   PWINDOW_OBJECT Window = NULL;
+   PWINDOW_OBJECT ParentWindow = NULL, OwnerWindow;
+   HWND ParentWindowHandle;
+   HWND OwnerWindowHandle;
+   PMENU_OBJECT SystemMenu;
+   HANDLE Handle;
+   POINT Pos;
+   SIZE Size;
 #if 0
-  POINT MaxSize, MaxPos, MinTrack, MaxTrack;
+
+   POINT MaxSize, MaxPos, MinTrack, MaxTrack;
 #else
-  POINT MaxPos;
+
+   POINT MaxPos;
 #endif
-  CREATESTRUCTW Cs;
-  CBT_CREATEWNDW CbtCreate;
-  LRESULT Result;
-  BOOL MenuChanged;
-  BOOL ClassFound;
-  DECLARE_RETURN(HWND);
-  BOOL HasOwner;
-
-  ParentWindowHandle = PsGetWin32Thread()->Desktop->DesktopWindow;
-  OwnerWindowHandle = NULL;
-
-  if (hWndParent == HWND_MESSAGE)
-    {
+
+   CREATESTRUCTW Cs;
+   CBT_CREATEWNDW CbtCreate;
+   LRESULT Result;
+   BOOL MenuChanged;
+   BOOL ClassFound;
+   DECLARE_RETURN(HWND);
+   BOOL HasOwner;
+
+   ParentWindowHandle = PsGetWin32Thread()->Desktop->DesktopWindow;
+   OwnerWindowHandle = NULL;
+
+   if (hWndParent == HWND_MESSAGE)
+   {
       /*
        * native ole32.OleInitialize uses HWND_MESSAGE to create the
        * message window (style: WS_POPUP|WS_DISABLED)
        */
       DPRINT1("FIXME - Parent is HWND_MESSAGE\n");
-    }
-  else if (hWndParent)
-    {
+   }
+   else if (hWndParent)
+   {
       if ((dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD)
-        ParentWindowHandle = hWndParent;
+         ParentWindowHandle = hWndParent;
       else
-        OwnerWindowHandle = UserGetAncestor(hWndParent, GA_ROOT);
-    }
-  else if ((dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD)
-    {
+         OwnerWindowHandle = UserGetAncestor(hWndParent, GA_ROOT);
+   }
+   else if ((dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD)
+   {
       RETURN( (HWND)0);  /* WS_CHILD needs a parent, but WS_POPUP doesn't */
-    }
+   }
 
-  if (NULL != ParentWindowHandle)
-    {
+   if (NULL != ParentWindowHandle)
+   {
       ParentWindow = UserGetWindowObject(ParentWindowHandle);
-      
-      if (ParentWindow) UserRefObjectCo(ParentWindow);
-    }
-  else
-    {
+
+      if (ParentWindow)
+         UserRefObjectCo(ParentWindow);
+   }
+   else
+   {
       ParentWindow = NULL;
-    }
+   }
 
-  /* FIXME: parent must belong to the current process */
+   /* FIXME: parent must belong to the current process */
 
-  /* Check the class. */
-  ClassFound = ClassReferenceClassByNameOrAtom(&Class, ClassName->Buffer, hInstance);
-  if (!ClassFound)
-  {
-     if (IS_ATOM(ClassName->Buffer))
-       {
+   /* Check the class. */
+   ClassFound = ClassReferenceClassByNameOrAtom(&Class, ClassName->Buffer, hInstance);
+   if (!ClassFound)
+   {
+      if (IS_ATOM(ClassName->Buffer))
+      {
          DPRINT1("Class 0x%x not found\n", (DWORD_PTR) ClassName->Buffer);
-       }
-     else
-       {
+      }
+      else
+      {
          DPRINT1("Class %wZ not found\n", ClassName);
-       }
+      }
 
-     SetLastWin32Error(ERROR_CANNOT_FIND_WND_CLASS);
-     RETURN((HWND)0);
-  }
+      SetLastWin32Error(ERROR_CANNOT_FIND_WND_CLASS);
+      RETURN((HWND)0);
+   }
 
-  /* Check the window station. */
-  if (PsGetWin32Thread()->Desktop == NULL)
-    {
+   /* Check the window station. */
+   if (PsGetWin32Thread()->Desktop == NULL)
+   {
       ClassDereferenceObject(Class);
 
       DPRINT("Thread is not attached to a desktop! Cannot create window!\n");
       RETURN( (HWND)0);
-    }
-  WinSta = PsGetWin32Thread()->Desktop->WindowStation;
-  ObReferenceObjectByPointer(WinSta, KernelMode, ExWindowStationObjectType, 0);
-
-  /* Create the window object. */
-  Window = (PWINDOW_OBJECT)
-    ObmCreateObject(&gHandleTable, &Handle,
-        otWindow, sizeof(WINDOW_OBJECT) + Class->cbWndExtra
-        );
-
-  DPRINT("Created object with handle %X\n", Handle);
-  if (!Window)
-    {
+   }
+   WinSta = PsGetWin32Thread()->Desktop->WindowStation;
+   ObReferenceObjectByPointer(WinSta, KernelMode, ExWindowStationObjectType, 0);
+
+   /* Create the window object. */
+   Window = (PWINDOW_OBJECT)
+            ObmCreateObject(&gHandleTable, &Handle,
+                            otWindow, sizeof(WINDOW_OBJECT) + Class->cbWndExtra
+                           );
+
+   DPRINT("Created object with handle %X\n", Handle);
+   if (!Window)
+   {
       ObDereferenceObject(WinSta);
       ClassDereferenceObject(Class);
       SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
       RETURN( (HWND)0);
-    }
-    
-  UserRefObjectCo(Window); 
+   }
+
+   UserRefObjectCo(Window);
 
 
-  ObDereferenceObject(WinSta);
+   ObDereferenceObject(WinSta);
 
-  if (NULL == PsGetWin32Thread()->Desktop->DesktopWindow)
-    {
+   if (NULL == PsGetWin32Thread()->Desktop->DesktopWindow)
+   {
       /* If there is no desktop window yet, we must be creating it */
       PsGetWin32Thread()->Desktop->DesktopWindow = Handle;
-    }
+   }
 
-  /*
-   * Fill out the structure describing it.
-   */
-  Window->Class = Class;
+   /*
+    * Fill out the structure describing it.
+    */
+   Window->Class = Class;
 
-  InsertTailList(&Class->ClassWindowsListHead, &Window->ClassListEntry);
+   InsertTailList(&Class->ClassWindowsListHead, &Window->ClassListEntry);
 
-  Window->ExStyle = dwExStyle;
-  Window->Style = dwStyle & ~WS_VISIBLE;
-  DPRINT("1: Style is now %lx\n", Window->Style);
+   Window->ExStyle = dwExStyle;
+   Window->Style = dwStyle & ~WS_VISIBLE;
+   DPRINT("1: Style is now %lx\n", Window->Style);
 
-  Window->SystemMenu = (HMENU)0;
-  Window->ContextHelpId = 0;
-  Window->IDMenu = 0;
-  Window->Instance = hInstance;
-  Window->hSelf = Handle;
-  if (0 != (dwStyle & WS_CHILD))
-    {
+   Window->SystemMenu = (HMENU)0;
+   Window->ContextHelpId = 0;
+   Window->IDMenu = 0;
+   Window->Instance = hInstance;
+   Window->hSelf = Handle;
+   if (0 != (dwStyle & WS_CHILD))
+   {
       Window->IDMenu = (UINT) hMenu;
-    }
-  else
-    {
+   }
+   else
+   {
       IntSetMenu(Window, hMenu, &MenuChanged);
-    }
-  Window->MessageQueue = PsGetWin32Thread()->MessageQueue;
-  IntReferenceMessageQueue(Window->MessageQueue);
-  Window->Parent = ParentWindow;
-  if((OwnerWindow = IntGetWindowObject(OwnerWindowHandle)))
-  {
-    Window->hOwner = OwnerWindowHandle;
-    IntReleaseWindowObject(OwnerWindow);
-    HasOwner = TRUE;
-  } else {
-    Window->hOwner = NULL;
-    HasOwner = FALSE;
-  }
-  Window->UserData = 0;
-  if ((((DWORD)Class->lpfnWndProcA & 0xFFFF0000) != 0xFFFF0000)
-      && (((DWORD)Class->lpfnWndProcW & 0xFFFF0000) != 0xFFFF0000))
-    {
+   }
+   Window->MessageQueue = PsGetWin32Thread()->MessageQueue;
+   IntReferenceMessageQueue(Window->MessageQueue);
+   Window->Parent = ParentWindow;
+   if((OwnerWindow = IntGetWindowObject(OwnerWindowHandle)))
+   {
+      Window->hOwner = OwnerWindowHandle;
+      IntReleaseWindowObject(OwnerWindow);
+      HasOwner = TRUE;
+   }
+   else
+   {
+      Window->hOwner = NULL;
+      HasOwner = FALSE;
+   }
+   Window->UserData = 0;
+   if ((((DWORD)Class->lpfnWndProcA & 0xFFFF0000) != 0xFFFF0000)
+         && (((DWORD)Class->lpfnWndProcW & 0xFFFF0000) != 0xFFFF0000))
+   {
       Window->Unicode = bUnicodeWindow;
-    }
-  else
-    {
+   }
+   else
+   {
       Window->Unicode = Class->Unicode;
-    }
-  Window->WndProcA = Class->lpfnWndProcA;
-  Window->WndProcW = Class->lpfnWndProcW;
-  Window->OwnerThread = PsGetCurrentThread();
-  Window->FirstChild = NULL;
-  Window->LastChild = NULL;
-  Window->PrevSibling = NULL;
-  Window->NextSibling = NULL;
-
-  /* extra window data */
-  if (Class->cbWndExtra != 0)
-    {
+   }
+   Window->WndProcA = Class->lpfnWndProcA;
+   Window->WndProcW = Class->lpfnWndProcW;
+   Window->OwnerThread = PsGetCurrentThread();
+   Window->FirstChild = NULL;
+   Window->LastChild = NULL;
+   Window->PrevSibling = NULL;
+   Window->NextSibling = NULL;
+
+   /* extra window data */
+   if (Class->cbWndExtra != 0)
+   {
       Window->ExtraData = (PCHAR)(Window + 1);
       Window->ExtraDataSize = Class->cbWndExtra;
       RtlZeroMemory(Window->ExtraData, Window->ExtraDataSize);
-    }
-  else
-    {
+   }
+   else
+   {
       Window->ExtraData = NULL;
       Window->ExtraDataSize = 0;
-    }
+   }
 
-  InitializeListHead(&Window->PropListHead);
-  InitializeListHead(&Window->WndObjListHead);
+   InitializeListHead(&Window->PropListHead);
+   InitializeListHead(&Window->WndObjListHead);
 
-  if (NULL != WindowName->Buffer)
-    {
+   if (NULL != WindowName->Buffer)
+   {
       Window->WindowName.MaximumLength = WindowName->MaximumLength;
       Window->WindowName.Length = WindowName->Length;
       Window->WindowName.Buffer = ExAllocatePoolWithTag(PagedPool, WindowName->MaximumLength,
-                                                              TAG_STRING);
+                                  TAG_STRING);
       if (NULL == Window->WindowName.Buffer)
-        {
-          ClassDereferenceObject(Class);
-          DPRINT1("Failed to allocate mem for window name\n");
-          SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-          RETURN( NULL);
-        }
+      {
+         ClassDereferenceObject(Class);
+         DPRINT1("Failed to allocate mem for window name\n");
+         SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+         RETURN( NULL);
+      }
       RtlCopyMemory(Window->WindowName.Buffer, WindowName->Buffer, WindowName->MaximumLength);
-    }
-  else
-    {
+   }
+   else
+   {
       RtlInitUnicodeString(&Window->WindowName, NULL);
-    }
+   }
 
 
-  /*
-   * This has been tested for WS_CHILD | WS_VISIBLE.  It has not been
-   * tested for WS_POPUP
-   */
-  if ((dwExStyle & WS_EX_DLGMODALFRAME) ||
-      ((!(dwExStyle & WS_EX_STATICEDGE)) &&
-      (dwStyle & (WS_DLGFRAME | WS_THICKFRAME))))
-    dwExStyle |= WS_EX_WINDOWEDGE;
-  else
-    dwExStyle &= ~WS_EX_WINDOWEDGE;
-
-  /* Correct the window style. */
-  if (!(dwStyle & WS_CHILD))
-    {
+   /*
+    * This has been tested for WS_CHILD | WS_VISIBLE.  It has not been
+    * tested for WS_POPUP
+    */
+   if ((dwExStyle & WS_EX_DLGMODALFRAME) ||
+         ((!(dwExStyle & WS_EX_STATICEDGE)) &&
+          (dwStyle & (WS_DLGFRAME | WS_THICKFRAME))))
+      dwExStyle |= WS_EX_WINDOWEDGE;
+   else
+      dwExStyle &= ~WS_EX_WINDOWEDGE;
+
+   /* Correct the window style. */
+   if (!(dwStyle & WS_CHILD))
+   {
       Window->Style |= WS_CLIPSIBLINGS;
       DPRINT("3: Style is now %lx\n", Window->Style);
       if (!(dwStyle & WS_POPUP))
-       {
-         Window->Style |= WS_CAPTION;
-          Window->Flags |= WINDOWOBJECT_NEED_SIZE;
-          DPRINT("4: Style is now %lx\n", Window->Style);
-       }
-    }
-
-  /* create system menu */
-  if((Window->Style & WS_SYSMENU) &&
-     (Window->Style & WS_CAPTION) == WS_CAPTION)
-  {
-    SystemMenu = IntGetSystemMenu(Window, TRUE, TRUE);
-    if(SystemMenu)
-    {
-      Window->SystemMenu = SystemMenu->MenuInfo.Self;
-      IntReleaseMenuObject(SystemMenu);
-    }
-  }
-
-  /* Insert the window into the thread's window list. */
-  InsertTailList (&PsGetWin32Thread()->WindowListHead, &Window->ThreadListEntry);
-
-  /* Allocate a DCE for this window. */
-  if (dwStyle & CS_OWNDC)
-    {
+      {
+         Window->Style |= WS_CAPTION;
+         Window->Flags |= WINDOWOBJECT_NEED_SIZE;
+         DPRINT("4: Style is now %lx\n", Window->Style);
+      }
+   }
+
+   /* create system menu */
+   if((Window->Style & WS_SYSMENU) &&
+         (Window->Style & WS_CAPTION) == WS_CAPTION)
+   {
+      SystemMenu = IntGetSystemMenu(Window, TRUE, TRUE);
+      if(SystemMenu)
+      {
+         Window->SystemMenu = SystemMenu->MenuInfo.Self;
+         IntReleaseMenuObject(SystemMenu);
+      }
+   }
+
+   /* Insert the window into the thread's window list. */
+   InsertTailList (&PsGetWin32Thread()->WindowListHead, &Window->ThreadListEntry);
+
+   /* Allocate a DCE for this window. */
+   if (dwStyle & CS_OWNDC)
+   {
       Window->Dce = DceAllocDCE(Window->hSelf, DCE_WINDOW_DC);
-    }
-  /* FIXME:  Handle "CS_CLASSDC" */
-
-  Pos.x = x;
-  Pos.y = y;
-  Size.cx = nWidth;
-  Size.cy = nHeight;
-
-  /* call hook */
-  Cs.lpCreateParams = lpParam;
-  Cs.hInstance = hInstance;
-  Cs.hMenu = hMenu;
-  Cs.hwndParent = ParentWindowHandle;
-  Cs.cx = Size.cx;
-  Cs.cy = Size.cy;
-  Cs.x = Pos.x;
-  Cs.y = Pos.y;
-  Cs.style = dwStyle;
-  Cs.lpszName = (LPCWSTR) WindowName;
-  Cs.lpszClass = (LPCWSTR) ClassName;
-  Cs.dwExStyle = dwExStyle;
-  CbtCreate.lpcs = &Cs;
-  CbtCreate.hwndInsertAfter = HWND_TOP;
-  if (co_HOOK_CallHooks(WH_CBT, HCBT_CREATEWND, (WPARAM) Handle, (LPARAM) &CbtCreate))
-    {
+   }
+   /* FIXME:  Handle "CS_CLASSDC" */
+
+   Pos.x = x;
+   Pos.y = y;
+   Size.cx = nWidth;
+   Size.cy = nHeight;
+
+   /* call hook */
+   Cs.lpCreateParams = lpParam;
+   Cs.hInstance = hInstance;
+   Cs.hMenu = hMenu;
+   Cs.hwndParent = ParentWindowHandle;
+   Cs.cx = Size.cx;
+   Cs.cy = Size.cy;
+   Cs.x = Pos.x;
+   Cs.y = Pos.y;
+   Cs.style = dwStyle;
+   Cs.lpszName = (LPCWSTR) WindowName;
+   Cs.lpszClass = (LPCWSTR) ClassName;
+   Cs.dwExStyle = dwExStyle;
+   CbtCreate.lpcs = &Cs;
+   CbtCreate.hwndInsertAfter = HWND_TOP;
+   if (co_HOOK_CallHooks(WH_CBT, HCBT_CREATEWND, (WPARAM) Handle, (LPARAM) &CbtCreate))
+   {
 
       /* FIXME - Delete window object and remove it from the thread windows list */
       /* FIXME - delete allocated DCE */
@@ -1679,392 +1701,403 @@ co_IntCreateWindowEx(DWORD dwExStyle,
       ClassDereferenceObject(Class);
       DPRINT1("CBT-hook returned !0\n");
       RETURN( (HWND) NULL);
-    }
-
-  x = Cs.x;
-  y = Cs.y;
-  nWidth = Cs.cx;
-  nHeight = Cs.cy;
+   }
 
-  /* default positioning for overlapped windows */
-  if(!(Window->Style & (WS_POPUP | WS_CHILD)))
-  {
-    RECT rc, WorkArea;
-    PRTL_USER_PROCESS_PARAMETERS ProcessParams;
-    BOOL CalculatedDefPosSize = FALSE;
+   x = Cs.x;
+   y = Cs.y;
+   nWidth = Cs.cx;
+   nHeight = Cs.cy;
 
-    IntGetDesktopWorkArea(Window->OwnerThread->Tcb.Win32Thread->Desktop, &WorkArea);
+   /* default positioning for overlapped windows */
+   if(!(Window->Style & (WS_POPUP | WS_CHILD)))
+   {
+      RECT rc, WorkArea;
+      PRTL_USER_PROCESS_PARAMETERS ProcessParams;
+      BOOL CalculatedDefPosSize = FALSE;
 
-    rc = WorkArea;
-    ProcessParams = PsGetCurrentProcess()->Peb->ProcessParameters;
+      IntGetDesktopWorkArea(Window->OwnerThread->Tcb.Win32Thread->Desktop, &WorkArea);
 
-    if(x == CW_USEDEFAULT || x == CW_USEDEFAULT16)
-    {
-      CalculatedDefPosSize = IntCalcDefPosSize(ParentWindow, Window, &rc, TRUE);
+      rc = WorkArea;
+      ProcessParams = PsGetCurrentProcess()->Peb->ProcessParameters;
 
-      if(ProcessParams->WindowFlags & STARTF_USEPOSITION)
-      {
-        ProcessParams->WindowFlags &= ~STARTF_USEPOSITION;
-        Pos.x = WorkArea.left + ProcessParams->StartingX;
-        Pos.y = WorkArea.top + ProcessParams->StartingY;
-      }
-      else
+      if(x == CW_USEDEFAULT || x == CW_USEDEFAULT16)
       {
-        Pos.x = rc.left;
-        Pos.y = rc.top;
-      }
+         CalculatedDefPosSize = IntCalcDefPosSize(ParentWindow, Window, &rc, TRUE);
 
-      /* According to wine, the ShowMode is set to y if x == CW_USEDEFAULT(16) and
-         y is something else */
-      if(y != CW_USEDEFAULT && y != CW_USEDEFAULT16)
-      {
-        dwShowMode = y;
+         if(ProcessParams->WindowFlags & STARTF_USEPOSITION)
+         {
+            ProcessParams->WindowFlags &= ~STARTF_USEPOSITION;
+            Pos.x = WorkArea.left + ProcessParams->StartingX;
+            Pos.y = WorkArea.top + ProcessParams->StartingY;
+         }
+         else
+         {
+            Pos.x = rc.left;
+            Pos.y = rc.top;
+         }
+
+         /* According to wine, the ShowMode is set to y if x == CW_USEDEFAULT(16) and
+            y is something else */
+         if(y != CW_USEDEFAULT && y != CW_USEDEFAULT16)
+         {
+            dwShowMode = y;
+         }
       }
-    }
-    if(nWidth == CW_USEDEFAULT || nWidth == CW_USEDEFAULT16)
-    {
-      if(!CalculatedDefPosSize)
+      if(nWidth == CW_USEDEFAULT || nWidth == CW_USEDEFAULT16)
       {
-        IntCalcDefPosSize(ParentWindow, Window, &rc, FALSE);
+         if(!CalculatedDefPosSize)
+         {
+            IntCalcDefPosSize(ParentWindow, Window, &rc, FALSE);
+         }
+         if(ProcessParams->WindowFlags & STARTF_USESIZE)
+         {
+            ProcessParams->WindowFlags &= ~STARTF_USESIZE;
+            Size.cx = ProcessParams->CountX;
+            Size.cy = ProcessParams->CountY;
+         }
+         else
+         {
+            Size.cx = rc.right - rc.left;
+            Size.cy = rc.bottom - rc.top;
+         }
+
+         /* move the window if necessary */
+         if(Pos.x > rc.left)
+            Pos.x = max(rc.left, 0);
+         if(Pos.y > rc.top)
+            Pos.y = max(rc.top, 0);
       }
-      if(ProcessParams->WindowFlags & STARTF_USESIZE)
+   }
+   else
+   {
+      /* if CW_USEDEFAULT(16) is set for non-overlapped windows, both values are set to zero) */
+      if(x == CW_USEDEFAULT || x == CW_USEDEFAULT16)
       {
-        ProcessParams->WindowFlags &= ~STARTF_USESIZE;
-        Size.cx = ProcessParams->CountX;
-        Size.cy = ProcessParams->CountY;
+         Pos.x = 0;
+         Pos.y = 0;
       }
-      else
+      if(nWidth == CW_USEDEFAULT || nWidth == CW_USEDEFAULT16)
       {
-        Size.cx = rc.right - rc.left;
-        Size.cy = rc.bottom - rc.top;
+         Size.cx = 0;
+         Size.cy = 0;
       }
+   }
 
-      /* move the window if necessary */
-      if(Pos.x > rc.left)
-        Pos.x = max(rc.left, 0);
-      if(Pos.y > rc.top)
-        Pos.y = max(rc.top, 0);
-    }
-  }
-  else
-  {
-    /* if CW_USEDEFAULT(16) is set for non-overlapped windows, both values are set to zero) */
-    if(x == CW_USEDEFAULT || x == CW_USEDEFAULT16)
-    {
-      Pos.x = 0;
-      Pos.y = 0;
-    }
-    if(nWidth == CW_USEDEFAULT || nWidth == CW_USEDEFAULT16)
-    {
-      Size.cx = 0;
-      Size.cy = 0;
-    }
-  }
-
-  /* Initialize the window dimensions. */
-  Window->WindowRect.left = Pos.x;
-  Window->WindowRect.top = Pos.y;
-  Window->WindowRect.right = Pos.x + Size.cx;
-  Window->WindowRect.bottom = Pos.y + Size.cy;
-  if (0 != (Window->Style & WS_CHILD) && ParentWindow)
-    {
+   /* Initialize the window dimensions. */
+   Window->WindowRect.left = Pos.x;
+   Window->WindowRect.top = Pos.y;
+   Window->WindowRect.right = Pos.x + Size.cx;
+   Window->WindowRect.bottom = Pos.y + Size.cy;
+   if (0 != (Window->Style & WS_CHILD) && ParentWindow)
+   {
       IntGdiOffsetRect(&(Window->WindowRect), ParentWindow->ClientRect.left,
-                      ParentWindow->ClientRect.top);
-    }
-  Window->ClientRect = Window->WindowRect;
+                       ParentWindow->ClientRect.top);
+   }
+   Window->ClientRect = Window->WindowRect;
 
-  /*
-   * Get the size and position of the window.
-   */
-  if ((dwStyle & WS_THICKFRAME) || !(dwStyle & (WS_POPUP | WS_CHILD)))
-    {
+   /*
+    * Get the size and position of the window.
+    */
+   if ((dwStyle & WS_THICKFRAME) || !(dwStyle & (WS_POPUP | WS_CHILD)))
+   {
       POINT MaxSize, MaxPos, MinTrack, MaxTrack;
 
       /* WinPosGetMinMaxInfo sends the WM_GETMINMAXINFO message */
       co_WinPosGetMinMaxInfo(Window, &MaxSize, &MaxPos, &MinTrack,
-                         &MaxTrack);
-      if (MaxSize.x < nWidth) nWidth = MaxSize.x;
-      if (MaxSize.y < nHeight) nHeight = MaxSize.y;
-      if (nWidth < MinTrack.x ) nWidth = MinTrack.x;
-      if (nHeight < MinTrack.y ) nHeight = MinTrack.y;
-      if (nWidth < 0) nWidth = 0;
-      if (nHeight < 0) nHeight = 0;
-    }
-
-  Window->WindowRect.left = Pos.x;
-  Window->WindowRect.top = Pos.y;
-  Window->WindowRect.right = Pos.x + Size.cx;
-  Window->WindowRect.bottom = Pos.y + Size.cy;
-  if (0 != (Window->Style & WS_CHILD) && ParentWindow)
-    {
+                             &MaxTrack);
+      if (MaxSize.x < nWidth)
+         nWidth = MaxSize.x;
+      if (MaxSize.y < nHeight)
+         nHeight = MaxSize.y;
+      if (nWidth < MinTrack.x )
+         nWidth = MinTrack.x;
+      if (nHeight < MinTrack.y )
+         nHeight = MinTrack.y;
+      if (nWidth < 0)
+         nWidth = 0;
+      if (nHeight < 0)
+         nHeight = 0;
+   }
+
+   Window->WindowRect.left = Pos.x;
+   Window->WindowRect.top = Pos.y;
+   Window->WindowRect.right = Pos.x + Size.cx;
+   Window->WindowRect.bottom = Pos.y + Size.cy;
+   if (0 != (Window->Style & WS_CHILD) && ParentWindow)
+   {
       IntGdiOffsetRect(&(Window->WindowRect), ParentWindow->ClientRect.left,
-                      ParentWindow->ClientRect.top);
-    }
-  Window->ClientRect = Window->WindowRect;
-
-  /* FIXME: Initialize the window menu. */
-
-  /* Send a NCCREATE message. */
-  Cs.cx = Size.cx;
-  Cs.cy = Size.cy;
-  Cs.x = Pos.x;
-  Cs.y = Pos.y;
-
-  DPRINT("[win32k.window] IntCreateWindowEx style %d, exstyle %d, parent %d\n", Cs.style, Cs.dwExStyle, Cs.hwndParent);
-  DPRINT("IntCreateWindowEx(): (%d,%d-%d,%d)\n", x, y, nWidth, nHeight);
-  DPRINT("IntCreateWindowEx(): About to send NCCREATE message.\n");
-  Result = co_IntSendMessage(Window->hSelf, WM_NCCREATE, 0, (LPARAM) &Cs);
-  if (!Result)
-    {
+                       ParentWindow->ClientRect.top);
+   }
+   Window->ClientRect = Window->WindowRect;
+
+   /* FIXME: Initialize the window menu. */
+
+   /* Send a NCCREATE message. */
+   Cs.cx = Size.cx;
+   Cs.cy = Size.cy;
+   Cs.x = Pos.x;
+   Cs.y = Pos.y;
+
+   DPRINT("[win32k.window] IntCreateWindowEx style %d, exstyle %d, parent %d\n", Cs.style, Cs.dwExStyle, Cs.hwndParent);
+   DPRINT("IntCreateWindowEx(): (%d,%d-%d,%d)\n", x, y, nWidth, nHeight);
+   DPRINT("IntCreateWindowEx(): About to send NCCREATE message.\n");
+   Result = co_IntSendMessage(Window->hSelf, WM_NCCREATE, 0, (LPARAM) &Cs);
+   if (!Result)
+   {
       /* FIXME: Cleanup. */
       DPRINT("IntCreateWindowEx(): NCCREATE message failed.\n");
       RETURN((HWND)0);
-    }
-
-  /* Calculate the non-client size. */
-  MaxPos.x = Window->WindowRect.left;
-  MaxPos.y = Window->WindowRect.top;
-  DPRINT("IntCreateWindowEx(): About to get non-client size.\n");
-  /* WinPosGetNonClientSize SENDS THE WM_NCCALCSIZE message */
-  Result = co_WinPosGetNonClientSize(Window->hSelf,
-                                 &Window->WindowRect,
-                                 &Window->ClientRect);
-  IntGdiOffsetRect(&Window->WindowRect,
-                MaxPos.x - Window->WindowRect.left,
-                MaxPos.y - Window->WindowRect.top);
-
-  if (NULL != ParentWindow)
-    {
+   }
+
+   /* Calculate the non-client size. */
+   MaxPos.x = Window->WindowRect.left;
+   MaxPos.y = Window->WindowRect.top;
+   DPRINT("IntCreateWindowEx(): About to get non-client size.\n");
+   /* WinPosGetNonClientSize SENDS THE WM_NCCALCSIZE message */
+   Result = co_WinPosGetNonClientSize(Window->hSelf,
+                                      &Window->WindowRect,
+                                      &Window->ClientRect);
+   IntGdiOffsetRect(&Window->WindowRect,
+                    MaxPos.x - Window->WindowRect.left,
+                    MaxPos.y - Window->WindowRect.top);
+
+   if (NULL != ParentWindow)
+   {
       /* link the window into the parent's child list */
       if ((dwStyle & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD)
-        {
-          PWINDOW_OBJECT PrevSibling;
-          if((PrevSibling = ParentWindow->LastChild))
+      {
+         PWINDOW_OBJECT PrevSibling;
+         if((PrevSibling = ParentWindow->LastChild))
             IntReferenceWindowObject(PrevSibling);
-          /* link window as bottom sibling */
-          IntLinkWindow(Window, ParentWindow, PrevSibling /*prev sibling*/);
-          if(PrevSibling)
+         /* link window as bottom sibling */
+         IntLinkWindow(Window, ParentWindow, PrevSibling /*prev sibling*/);
+         if(PrevSibling)
             IntReleaseWindowObject(PrevSibling);
-        }
+      }
       else
-        {
-          /* link window as top sibling (but after topmost siblings) */
-          PWINDOW_OBJECT InsertAfter, Sibling;
-          if (0 == (dwExStyle & WS_EX_TOPMOST))
-            {
-              InsertAfter = NULL;
-              Sibling = ParentWindow->FirstChild;
-              while (NULL != Sibling && 0 != (Sibling->ExStyle & WS_EX_TOPMOST))
-                {
-                  InsertAfter = Sibling;
-                  Sibling = Sibling->NextSibling;
-                }
-            }
-          else
-            {
-              InsertAfter = NULL;
-            }
-          if (NULL != InsertAfter)
-            {
-              IntReferenceWindowObject(InsertAfter);
-            }
-          IntLinkWindow(Window, ParentWindow, InsertAfter /* prev sibling */);
-          if (NULL != InsertAfter)
+      {
+         /* link window as top sibling (but after topmost siblings) */
+         PWINDOW_OBJECT InsertAfter, Sibling;
+         if (0 == (dwExStyle & WS_EX_TOPMOST))
+         {
+            InsertAfter = NULL;
+            Sibling = ParentWindow->FirstChild;
+            while (NULL != Sibling && 0 != (Sibling->ExStyle & WS_EX_TOPMOST))
             {
-              IntReleaseWindowObject(InsertAfter);
+               InsertAfter = Sibling;
+               Sibling = Sibling->NextSibling;
             }
-        }
-    }
-
-  /* Send the WM_CREATE message. */
-  DPRINT("IntCreateWindowEx(): about to send CREATE message.\n");
-  Result = co_IntSendMessage(Window->hSelf, WM_CREATE, 0, (LPARAM) &Cs);
-  if (Result == (LRESULT)-1)
-    {
+         }
+         else
+         {
+            InsertAfter = NULL;
+         }
+         if (NULL != InsertAfter)
+         {
+            IntReferenceWindowObject(InsertAfter);
+         }
+         IntLinkWindow(Window, ParentWindow, InsertAfter /* prev sibling */);
+         if (NULL != InsertAfter)
+         {
+            IntReleaseWindowObject(InsertAfter);
+         }
+      }
+   }
+
+   /* Send the WM_CREATE message. */
+   DPRINT("IntCreateWindowEx(): about to send CREATE message.\n");
+   Result = co_IntSendMessage(Window->hSelf, WM_CREATE, 0, (LPARAM) &Cs);
+   if (Result == (LRESULT)-1)
+   {
       /* FIXME: Cleanup. */
       ClassDereferenceObject(Class);
       DPRINT("IntCreateWindowEx(): send CREATE message failed.\n");
       RETURN((HWND)0);
-    }
+   }
 
-  /* Send move and size messages. */
-  if (!(Window->Flags & WINDOWOBJECT_NEED_SIZE))
-    {
+   /* Send move and size messages. */
+   if (!(Window->Flags & WINDOWOBJECT_NEED_SIZE))
+   {
       LONG lParam;
 
       DPRINT("IntCreateWindow(): About to send WM_SIZE\n");
 
       if ((Window->ClientRect.right - Window->ClientRect.left) < 0 ||
-          (Window->ClientRect.bottom - Window->ClientRect.top) < 0)
+            (Window->ClientRect.bottom - Window->ClientRect.top) < 0)
       {
          DPRINT("Sending bogus WM_SIZE\n");
       }
 
       lParam = MAKE_LONG(Window->ClientRect.right -
-                 Window->ClientRect.left,
-                 Window->ClientRect.bottom -
-                 Window->ClientRect.top);
+                         Window->ClientRect.left,
+                         Window->ClientRect.bottom -
+                         Window->ClientRect.top);
       co_IntSendMessage(Window->hSelf, WM_SIZE, SIZE_RESTORED,
-          lParam);
+                        lParam);
 
       DPRINT("IntCreateWindow(): About to send WM_MOVE\n");
 
       if (0 != (Window->Style & WS_CHILD) && ParentWindow)
-       {
-         lParam = MAKE_LONG(Window->ClientRect.left - ParentWindow->ClientRect.left,
-             Window->ClientRect.top - ParentWindow->ClientRect.top);
-       }
+      {
+         lParam = MAKE_LONG(Window->ClientRect.left - ParentWindow->ClientRect.left,
+                            Window->ClientRect.top - ParentWindow->ClientRect.top);
+      }
       else
-       {
-         lParam = MAKE_LONG(Window->ClientRect.left,
-             Window->ClientRect.top);
-       }
+      {
+         lParam = MAKE_LONG(Window->ClientRect.left,
+                            Window->ClientRect.top);
+      }
       co_IntSendMessage(Window->hSelf, WM_MOVE, 0, lParam);
 
       /* Call WNDOBJ change procs */
       IntEngWindowChanged(Window, WOC_RGN_CLIENT);
-    }
+   }
 
-  /* Show or maybe minimize or maximize the window. */
-  if (Window->Style & (WS_MINIMIZE | WS_MAXIMIZE))
-    {
+   /* Show or maybe minimize or maximize the window. */
+   if (Window->Style & (WS_MINIMIZE | WS_MAXIMIZE))
+   {
       RECT NewPos;
       UINT16 SwFlag;
 
       SwFlag = (Window->Style & WS_MINIMIZE) ? SW_MINIMIZE :
-       SW_MAXIMIZE;
+               SW_MAXIMIZE;
       co_WinPosMinMaximize(Window, SwFlag, &NewPos);
       SwFlag =
-       ((Window->Style & WS_CHILD) || UserGetActiveWindow()) ?
-       SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED :
-       SWP_NOZORDER | SWP_FRAMECHANGED;
+         ((Window->Style & WS_CHILD) || UserGetActiveWindow()) ?
+         SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED :
+         SWP_NOZORDER | SWP_FRAMECHANGED;
       DPRINT("IntCreateWindow(): About to minimize/maximize\n");
       DPRINT("%d,%d %dx%d\n", NewPos.left, NewPos.top, NewPos.right, NewPos.bottom);
       co_WinPosSetWindowPos(Window, 0, NewPos.left, NewPos.top,
-                        NewPos.right, NewPos.bottom, SwFlag);
-    }
+                            NewPos.right, NewPos.bottom, SwFlag);
+   }
 
-  /* Notify the parent window of a new child. */
-  if ((Window->Style & WS_CHILD) &&
-      (!(Window->ExStyle & WS_EX_NOPARENTNOTIFY)) && ParentWindow)
-    {
+   /* Notify the parent window of a new child. */
+   if ((Window->Style & WS_CHILD) &&
+         (!(Window->ExStyle & WS_EX_NOPARENTNOTIFY)) && ParentWindow)
+   {
       DPRINT("IntCreateWindow(): About to notify parent\n");
       co_IntSendMessage(ParentWindow->hSelf,
-                     WM_PARENTNOTIFY,
-                     MAKEWPARAM(WM_CREATE, Window->IDMenu),
-                     (LPARAM)Window->hSelf);
-    }
+                        WM_PARENTNOTIFY,
+                        MAKEWPARAM(WM_CREATE, Window->IDMenu),
+                        (LPARAM)Window->hSelf);
+   }
 
-  if ((!hWndParent) && (!HasOwner)) {
+   if ((!hWndParent) && (!HasOwner))
+   {
       DPRINT("Sending CREATED notify\n");
       co_IntShellHookNotify(HSHELL_WINDOWCREATED, (LPARAM)Handle);
-  } else {
+   }
+   else
+   {
       DPRINT("Not sending CREATED notify, %x %d\n", ParentWindow, HasOwner);
-  }
-
-  /* Initialize and show the window's scrollbars */
-  if (Window->Style & WS_VSCROLL)
-  {
-     co_UserShowScrollBar(Window, SB_VERT, TRUE);
-  }
-  if (Window->Style & WS_HSCROLL)
-  {
-     co_UserShowScrollBar(Window, SB_HORZ, TRUE);
-  }
-
-  if (dwStyle & WS_VISIBLE)
-    {
+   }
+
+   /* Initialize and show the window's scrollbars */
+   if (Window->Style & WS_VSCROLL)
+   {
+      co_UserShowScrollBar(Window, SB_VERT, TRUE);
+   }
+   if (Window->Style & WS_HSCROLL)
+   {
+      co_UserShowScrollBar(Window, SB_HORZ, TRUE);
+   }
+
+   if (dwStyle & WS_VISIBLE)
+   {
       DPRINT("IntCreateWindow(): About to show window\n");
       co_WinPosShowWindow(Window, dwShowMode);
-    }
+   }
+
+   DPRINT("IntCreateWindow(): = %X\n", Handle);
+   DPRINT("WindowObject->SystemMenu = 0x%x\n", Window->SystemMenu);
+   RETURN((HWND)Handle);
 
-  DPRINT("IntCreateWindow(): = %X\n", Handle);
-  DPRINT("WindowObject->SystemMenu = 0x%x\n", Window->SystemMenu);
-  RETURN((HWND)Handle);
-  
 CLEANUP:
-  if (Window) UserDerefObjectCo(Window);
-  if (ParentWindow) UserDerefObjectCo(ParentWindow);
-  
-  END_CLEANUP;
+   if (Window)
+      UserDerefObjectCo(Window);
+   if (ParentWindow)
+      UserDerefObjectCo(ParentWindow);
+
+   END_CLEANUP;
 }
 
 HWND STDCALL
 NtUserCreateWindowEx(DWORD dwExStyle,
-                    PUNICODE_STRING UnsafeClassName,
-                    PUNICODE_STRING UnsafeWindowName,
-                    DWORD dwStyle,
-                    LONG x,
-                    LONG y,
-                    LONG nWidth,
-                    LONG nHeight,
-                    HWND hWndParent,
-                    HMENU hMenu,
-                    HINSTANCE hInstance,
-                    LPVOID lpParam,
-                    DWORD dwShowMode,
-                    BOOL bUnicodeWindow)
+                     PUNICODE_STRING UnsafeClassName,
+                     PUNICODE_STRING UnsafeWindowName,
+                     DWORD dwStyle,
+                     LONG x,
+                     LONG y,
+                     LONG nWidth,
+                     LONG nHeight,
+                     HWND hWndParent,
+                     HMENU hMenu,
+                     HINSTANCE hInstance,
+                     LPVOID lpParam,
+                     DWORD dwShowMode,
+                     BOOL bUnicodeWindow)
 {
-  NTSTATUS Status;
-  UNICODE_STRING WindowName;
-  UNICODE_STRING ClassName;
-  HWND NewWindow;
-  DECLARE_RETURN(HWND);
-
-  DPRINT("Enter NtUserCreateWindowEx(): (%d,%d-%d,%d)\n", x, y, nWidth, nHeight);
-  UserEnterExclusive();
-
-  /* Get the class name (string or atom) */
-  Status = MmCopyFromCaller(&ClassName, UnsafeClassName, sizeof(UNICODE_STRING));
-  if (! NT_SUCCESS(Status))
-    {
+   NTSTATUS Status;
+   UNICODE_STRING WindowName;
+   UNICODE_STRING ClassName;
+   HWND NewWindow;
+   DECLARE_RETURN(HWND);
+
+   DPRINT("Enter NtUserCreateWindowEx(): (%d,%d-%d,%d)\n", x, y, nWidth, nHeight);
+   UserEnterExclusive();
+
+   /* Get the class name (string or atom) */
+   Status = MmCopyFromCaller(&ClassName, UnsafeClassName, sizeof(UNICODE_STRING));
+   if (! NT_SUCCESS(Status))
+   {
       SetLastNtError(Status);
       RETURN( NULL);
-    }
-  if (! IS_ATOM(ClassName.Buffer))
-    {
+   }
+   if (! IS_ATOM(ClassName.Buffer))
+   {
       Status = IntSafeCopyUnicodeStringTerminateNULL(&ClassName, UnsafeClassName);
       if (! NT_SUCCESS(Status))
-        {
-          SetLastNtError(Status);
-          RETURN( NULL);
-        }
-    }
-
-  /* safely copy the window name */
-  if (NULL != UnsafeWindowName)
-    {
+      {
+         SetLastNtError(Status);
+         RETURN( NULL);
+      }
+   }
+
+   /* safely copy the window name */
+   if (NULL != UnsafeWindowName)
+   {
       Status = IntSafeCopyUnicodeString(&WindowName, UnsafeWindowName);
       if (! NT_SUCCESS(Status))
-        {
-          if (! IS_ATOM(ClassName.Buffer))
-            {
-              RtlFreeUnicodeString(&ClassName);
-            }
-          SetLastNtError(Status);
-          RETURN( NULL);
-        }
-    }
-  else
-    {
+      {
+         if (! IS_ATOM(ClassName.Buffer))
+         {
+            RtlFreeUnicodeString(&ClassName);
+         }
+         SetLastNtError(Status);
+         RETURN( NULL);
+      }
+   }
+   else
+   {
       RtlInitUnicodeString(&WindowName, NULL);
-    }
+   }
 
-  NewWindow = co_IntCreateWindowEx(dwExStyle, &ClassName, &WindowName, dwStyle, x, y, nWidth, nHeight,
-                               hWndParent, hMenu, hInstance, lpParam, dwShowMode, bUnicodeWindow);
+   NewWindow = co_IntCreateWindowEx(dwExStyle, &ClassName, &WindowName, dwStyle, x, y, nWidth, nHeight,
+                                    hWndParent, hMenu, hInstance, lpParam, dwShowMode, bUnicodeWindow);
 
-  RtlFreeUnicodeString(&WindowName);
-  if (! IS_ATOM(ClassName.Buffer))
-    {
+   RtlFreeUnicodeString(&WindowName);
+   if (! IS_ATOM(ClassName.Buffer))
+   {
       RtlFreeUnicodeString(&ClassName);
-    }
+   }
+
+   RETURN( NewWindow);
 
-  RETURN( NewWindow);
-  
 CLEANUP:
-  DPRINT("Leave NtUserCreateWindowEx, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserCreateWindowEx, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 /*
@@ -2072,147 +2105,149 @@ CLEANUP:
  */
 HDWP STDCALL
 NtUserDeferWindowPos(HDWP WinPosInfo,
-                    HWND Wnd,
-                    HWND WndInsertAfter,
-                    int x,
-         int y,
-         int cx,
-         int cy,
-                    UINT Flags)
+                     HWND Wnd,
+                     HWND WndInsertAfter,
+                     int x,
+                     int y,
+                     int cx,
+                     int cy,
+                     UINT Flags)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
 BOOLEAN FASTCALL co_UserDestroyWindow(PWINDOW_OBJECT Window)
 {
-  BOOLEAN isChild;
+   BOOLEAN isChild;
 
-  ASSERT_REFS_CO(Window); 
+   ASSERT_REFS_CO(Window);
 
-  if (Window == NULL)
-    {
+   if (Window == NULL)
+   {
       return FALSE;
-    }
+   }
 
-  /* Check for owner thread and desktop window */
-  if ((Window->OwnerThread != PsGetCurrentThread()) || IntIsDesktopWindow(Window))
-    {
+   /* Check for owner thread and desktop window */
+   if ((Window->OwnerThread != PsGetCurrentThread()) || IntIsDesktopWindow(Window))
+   {
       SetLastWin32Error(ERROR_ACCESS_DENIED);
       return FALSE;
-    }
+   }
 
-  /* Look whether the focus is within the tree of windows we will
-   * be destroying.
-   */
-  if (!co_WinPosShowWindow(Window, SW_HIDE))
-    {
+   /* Look whether the focus is within the tree of windows we will
+    * be destroying.
+    */
+   if (!co_WinPosShowWindow(Window, SW_HIDE))
+   {
       if (UserGetActiveWindow() == Window->hSelf)
-        {
-          co_WinPosActivateOtherWindow(Window);
-        }
-    }
-
-  if (Window->MessageQueue->ActiveWindow == Window->hSelf)
-    Window->MessageQueue->ActiveWindow = NULL;
-  if (Window->MessageQueue->FocusWindow == Window->hSelf)
-    Window->MessageQueue->FocusWindow = NULL;
-  if (Window->MessageQueue->CaptureWindow == Window->hSelf)
-    Window->MessageQueue->CaptureWindow = NULL;
-
-  IntDereferenceMessageQueue(Window->MessageQueue);
-  /* Call hooks */
+      {
+         co_WinPosActivateOtherWindow(Window);
+      }
+   }
+
+   if (Window->MessageQueue->ActiveWindow == Window->hSelf)
+      Window->MessageQueue->ActiveWindow = NULL;
+   if (Window->MessageQueue->FocusWindow == Window->hSelf)
+      Window->MessageQueue->FocusWindow = NULL;
+   if (Window->MessageQueue->CaptureWindow == Window->hSelf)
+      Window->MessageQueue->CaptureWindow = NULL;
+
+   IntDereferenceMessageQueue(Window->MessageQueue);
+   /* Call hooks */
 #if 0 /* FIXME */
-  if (co_HOOK_CallHooks(WH_CBT, HCBT_DESTROYWND, (WPARAM) hwnd, 0, TRUE))
-    {
-    return FALSE;
-    }
+
+   if (co_HOOK_CallHooks(WH_CBT, HCBT_DESTROYWND, (WPARAM) hwnd, 0, TRUE))
+   {
+      return FALSE;
+   }
 #endif
 
-  IntEngWindowChanged(Window, WOC_DELETE);
-  isChild = (0 != (Window->Style & WS_CHILD));
+   IntEngWindowChanged(Window, WOC_DELETE);
+   isChild = (0 != (Window->Style & WS_CHILD));
 
 #if 0 /* FIXME */
-  if (isChild)
-    {
+
+   if (isChild)
+   {
       if (! USER_IsExitingThread(GetCurrentThreadId()))
-       {
-         send_parent_notify(hwnd, WM_DESTROY);
-       }
-    }
-  else if (NULL != GetWindow(Wnd, GW_OWNER))
-    {
+      {
+         send_parent_notify(hwnd, WM_DESTROY);
+      }
+   }
+   else if (NULL != GetWindow(Wnd, GW_OWNER))
+   {
       co_HOOK_CallHooks( WH_SHELL, HSHELL_WINDOWDESTROYED, (WPARAM)hwnd, 0L, TRUE );
       /* FIXME: clean up palette - see "Internals" p.352 */
-    }
+   }
 #endif
 
-  if (!IntIsWindow(Window->hSelf))
-    {
-    return TRUE;
-    }
+   if (!IntIsWindow(Window->hSelf))
+   {
+      return TRUE;
+   }
 
-  /* Recursively destroy owned windows */
-  if (! isChild)
-    {
+   /* Recursively destroy owned windows */
+   if (! isChild)
+   {
       for (;;)
-       {
-         BOOL GotOne = FALSE;
-         HWND *Children;
-         HWND *ChildHandle;
-         PWINDOW_OBJECT Child, Desktop;
-
-         Desktop = IntGetWindowObject(IntGetDesktopWindow());
-         Children = IntWinListChildren(Desktop);
-         IntReleaseWindowObject(Desktop);
-         if (Children)
-           {
-             for (ChildHandle = Children; *ChildHandle; ++ChildHandle)
-               {
-                 Child = IntGetWindowObject(*ChildHandle);
-                 if (Child == NULL)
-                   continue;
-                 if (Child->hOwner != Window->hSelf)
-                   {
-                     IntReleaseWindowObject(Child);
-                     continue;
-                   }
-
-                 if (IntWndBelongsToThread(Child, PsGetWin32Thread()))
-                   {
-            co_UserDestroyWindow(Child);
-            IntReleaseWindowObject(Child);
-                     GotOne = TRUE;
-                     continue;
-                   }
-
-                 if (Child->hOwner != NULL)
-                   {
-                     Child->hOwner = NULL;
-                   }
-
-                 IntReleaseWindowObject(Child);
-               }
-             ExFreePool(Children);
-           }
-         if (! GotOne)
-           {
-             break;
-           }
-       }
-    }
-
-  if (!IntIsWindow(Window->hSelf))
-    {
+      {
+         BOOL GotOne = FALSE;
+         HWND *Children;
+         HWND *ChildHandle;
+         PWINDOW_OBJECT Child, Desktop;
+
+         Desktop = IntGetWindowObject(IntGetDesktopWindow());
+         Children = IntWinListChildren(Desktop);
+         IntReleaseWindowObject(Desktop);
+         if (Children)
+         {
+            for (ChildHandle = Children; *ChildHandle; ++ChildHandle)
+            {
+               Child = IntGetWindowObject(*ChildHandle);
+               if (Child == NULL)
+                  continue;
+               if (Child->hOwner != Window->hSelf)
+               {
+                  IntReleaseWindowObject(Child);
+                  continue;
+               }
+
+               if (IntWndBelongsToThread(Child, PsGetWin32Thread()))
+               {
+                  co_UserDestroyWindow(Child);
+                  IntReleaseWindowObject(Child);
+                  GotOne = TRUE;
+                  continue;
+               }
+
+               if (Child->hOwner != NULL)
+               {
+                  Child->hOwner = NULL;
+               }
+
+               IntReleaseWindowObject(Child);
+            }
+            ExFreePool(Children);
+         }
+         if (! GotOne)
+         {
+            break;
+         }
+      }
+   }
+
+   if (!IntIsWindow(Window->hSelf))
+   {
       return TRUE;
-    }
+   }
 
-  /* Destroy the window storage */
-  co_IntDestroyWindow(Window, PsGetWin32Process(), PsGetWin32Thread(), TRUE);
+   /* Destroy the window storage */
+   co_IntDestroyWindow(Window, PsGetWin32Process(), PsGetWin32Thread(), TRUE);
 
-  return TRUE;
+   return TRUE;
 }
 
 
@@ -2224,24 +2259,24 @@ BOOLEAN FASTCALL co_UserDestroyWindow(PWINDOW_OBJECT Window)
 BOOLEAN STDCALL
 NtUserDestroyWindow(HWND Wnd)
 {
-  PWINDOW_OBJECT Window;
-  DECLARE_RETURN(BOOLEAN);
+   PWINDOW_OBJECT Window;
+   DECLARE_RETURN(BOOLEAN);
 
-  DPRINT("Enter NtUserDestroyWindow\n");
-  UserEnterExclusive();
+   DPRINT("Enter NtUserDestroyWindow\n");
+   UserEnterExclusive();
 
-  Window = IntGetWindowObject(Wnd);
-  if (Window == NULL)
-    {
+   Window = IntGetWindowObject(Wnd);
+   if (Window == NULL)
+   {
       RETURN(FALSE);
-    }
-  
-  RETURN(co_UserDestroyWindow(Window));
+   }
+
+   RETURN(co_UserDestroyWindow(Window));
 
 CLEANUP:
-  DPRINT("Leave NtUserDestroyWindow, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserDestroyWindow, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -2252,15 +2287,15 @@ CLEANUP:
 DWORD
 STDCALL
 NtUserDrawMenuBarTemp(
-  HWND hWnd,
-  HDC hDC,
-  PRECT hRect,
-  HMENU hMenu,
-  HFONT hFont)
+   HWND hWnd,
+   HDC hDC,
+   PRECT hRect,
+   HMENU hMenu,
+   HFONT hFont)
 {
-  /* we'll use this function just for caching the menu bar */
-  UNIMPLEMENTED
-  return 0;
+   /* we'll use this function just for caching the menu bar */
+   UNIMPLEMENTED
+   return 0;
 }
 
 
@@ -2269,11 +2304,11 @@ NtUserDrawMenuBarTemp(
  */
 DWORD STDCALL
 NtUserEndDeferWindowPosEx(DWORD Unknown0,
-                         DWORD Unknown1)
+                          DWORD Unknown1)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
@@ -2282,13 +2317,13 @@ NtUserEndDeferWindowPosEx(DWORD Unknown0,
  */
 DWORD STDCALL
 NtUserFillWindow(DWORD Unknown0,
-                DWORD Unknown1,
-                DWORD Unknown2,
-                DWORD Unknown3)
+                 DWORD Unknown1,
+                 DWORD Unknown2,
+                 DWORD Unknown3)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
@@ -2298,280 +2333,283 @@ IntFindWindow(PWINDOW_OBJECT Parent,
               RTL_ATOM ClassAtom,
               PUNICODE_STRING WindowName)
 {
-  BOOL CheckWindowName;
-  HWND *List, *phWnd;
-  HWND Ret = NULL;
-
-  ASSERT(Parent);
-
-  CheckWindowName = (WindowName && (WindowName->Length > 0));
-
-  if((List = IntWinListChildren(Parent)))
-  {
-    phWnd = List;
-    if(ChildAfter)
-    {
-      /* skip handles before and including ChildAfter */
-      while(*phWnd && (*(phWnd++) != ChildAfter->hSelf));
-    }
-
-    /* search children */
-    while(*phWnd)
-    {
-      PWINDOW_OBJECT Child;
-      if(!(Child = IntGetWindowObject(*(phWnd++))))
+   BOOL CheckWindowName;
+   HWND *List, *phWnd;
+   HWND Ret = NULL;
+
+   ASSERT(Parent);
+
+   CheckWindowName = (WindowName && (WindowName->Length > 0));
+
+   if((List = IntWinListChildren(Parent)))
+   {
+      phWnd = List;
+      if(ChildAfter)
+      {
+         /* skip handles before and including ChildAfter */
+         while(*phWnd && (*(phWnd++) != ChildAfter->hSelf))
+            ;
+      }
+
+      /* search children */
+      while(*phWnd)
+      {
+         PWINDOW_OBJECT Child;
+         if(!(Child = IntGetWindowObject(*(phWnd++))))
+         {
+            continue;
+         }
+
+         /* Do not send WM_GETTEXT messages in the kernel mode version!
+            The user mode version however calls GetWindowText() which will
+            send WM_GETTEXT messages to windows belonging to its processes */
+         if((!CheckWindowName || !RtlCompareUnicodeString(WindowName, &(Child->WindowName), FALSE)) &&
+               (!ClassAtom || Child->Class->Atom == ClassAtom))
+         {
+            Ret = Child->hSelf;
+            IntReleaseWindowObject(Child);
+            break;
+         }
+
+         IntReleaseWindowObject(Child);
+      }
+      ExFreePool(List);
+   }
+
+   return Ret;
+}
+
+/*
+ * FUNCTION:
+ *   Searches a window's children for a window with the specified
+ *   class and name
+ * ARGUMENTS:
+ *   hwndParent     = The window whose childs are to be searched.
+ *       NULL = desktop
+ *       HWND_MESSAGE = message-only windows
+ *
+ *   hwndChildAfter = Search starts after this child window.
+ *       NULL = start from beginning
+ *
+ *   ucClassName    = Class name to search for
+ *       Reguired parameter.
+ *
+ *   ucWindowName   = Window name
+ *       ->Buffer == NULL = don't care
+ *
+ * RETURNS:
+ *   The HWND of the window if it was found, otherwise NULL
+ */
+/*
+ * @implemented
+ */
+HWND STDCALL
+NtUserFindWindowEx(HWND hwndParent,
+                   HWND hwndChildAfter,
+                   PUNICODE_STRING ucClassName,
+                   PUNICODE_STRING ucWindowName)
+{
+   PWINDOW_OBJECT Parent, ChildAfter;
+   UNICODE_STRING ClassName, WindowName;
+   NTSTATUS Status;
+   HWND Desktop, Ret = NULL;
+   RTL_ATOM ClassAtom;
+   DECLARE_RETURN(HWND);
+
+   DPRINT("Enter NtUserFindWindowEx\n");
+   UserEnterShared();
+
+   Desktop = IntGetCurrentThreadDesktopWindow();
+
+   if(hwndParent == NULL)
+      hwndParent = Desktop;
+   /* FIXME
+   else if(hwndParent == HWND_MESSAGE)
+   {
+     hwndParent = IntGetMessageWindow();
+   }
+   */
+
+   if(!(Parent = IntGetWindowObject(hwndParent)))
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      RETURN( NULL);
+   }
+
+   ChildAfter = NULL;
+   if(hwndChildAfter && !(ChildAfter = IntGetWindowObject(hwndChildAfter)))
+   {
+      IntReleaseWindowObject(Parent);
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      RETURN( NULL);
+   }
+
+   /* copy the window name */
+   Status = IntSafeCopyUnicodeString(&WindowName, ucWindowName);
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      goto Cleanup3;
+   }
+
+   /* safely copy the class name */
+   Status = MmCopyFromCaller(&ClassName, ucClassName, sizeof(UNICODE_STRING));
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      goto Cleanup2;
+   }
+   if(ClassName.Length > 0 && ClassName.Buffer)
+   {
+      WCHAR *buf;
+      /* safely copy the class name string (NULL terminated because class-lookup
+         depends on it... */
+      buf = ExAllocatePoolWithTag(PagedPool, ClassName.Length + sizeof(WCHAR), TAG_STRING);
+      if(!buf)
       {
-        continue;
+         SetLastWin32Error(STATUS_INSUFFICIENT_RESOURCES);
+         goto Cleanup2;
       }
-
-      /* Do not send WM_GETTEXT messages in the kernel mode version!
-         The user mode version however calls GetWindowText() which will
-         send WM_GETTEXT messages to windows belonging to its processes */
-      if((!CheckWindowName || !RtlCompareUnicodeString(WindowName, &(Child->WindowName), FALSE)) &&
-         (!ClassAtom || Child->Class->Atom == ClassAtom))
+      Status = MmCopyFromCaller(buf, ClassName.Buffer, ClassName.Length);
+      if(!NT_SUCCESS(Status))
       {
-        Ret = Child->hSelf;
-        IntReleaseWindowObject(Child);
-        break;
+         ExFreePool(buf);
+         SetLastNtError(Status);
+         goto Cleanup2;
       }
+      ClassName.Buffer = buf;
+      /* make sure the string is null-terminated */
+      buf += ClassName.Length / sizeof(WCHAR);
+      *buf = L'\0';
+   }
 
-      IntReleaseWindowObject(Child);
-    }
-    ExFreePool(List);
-  }
-
-  return Ret;
-}
-
-/*
- * FUNCTION:
- *   Searches a window's children for a window with the specified
- *   class and name
- * ARGUMENTS:
- *   hwndParent            = The window whose childs are to be searched.
- *                                       NULL = desktop
- *                                       HWND_MESSAGE = message-only windows
- *
- *   hwndChildAfter = Search starts after this child window.
- *                                       NULL = start from beginning
- *
- *   ucClassName    = Class name to search for
- *                                       Reguired parameter.
- *
- *   ucWindowName   = Window name
- *                                       ->Buffer == NULL = don't care
- *
- * RETURNS:
- *   The HWND of the window if it was found, otherwise NULL
- */
-/*
- * @implemented
- */
-HWND STDCALL
-NtUserFindWindowEx(HWND hwndParent,
-                  HWND hwndChildAfter,
-                  PUNICODE_STRING ucClassName,
-                  PUNICODE_STRING ucWindowName)
-{
-  PWINDOW_OBJECT Parent, ChildAfter;
-  UNICODE_STRING ClassName, WindowName;
-  NTSTATUS Status;
-  HWND Desktop, Ret = NULL;
-  RTL_ATOM ClassAtom;
-  DECLARE_RETURN(HWND);
-
-  DPRINT("Enter NtUserFindWindowEx\n");
-  UserEnterShared();
-
-  Desktop = IntGetCurrentThreadDesktopWindow();
-
-  if(hwndParent == NULL)
-    hwndParent = Desktop;
-  /* FIXME
-  else if(hwndParent == HWND_MESSAGE)
-  {
-    hwndParent = IntGetMessageWindow();
-  }
-  */
-
-  if(!(Parent = IntGetWindowObject(hwndParent)))
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    RETURN( NULL);
-  }
-
-  ChildAfter = NULL;
-  if(hwndChildAfter && !(ChildAfter = IntGetWindowObject(hwndChildAfter)))
-  {
-    IntReleaseWindowObject(Parent);
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    RETURN( NULL);
-  }
-
-  /* copy the window name */
-  Status = IntSafeCopyUnicodeString(&WindowName, ucWindowName);
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    goto Cleanup3;
-  }
-
-  /* safely copy the class name */
-  Status = MmCopyFromCaller(&ClassName, ucClassName, sizeof(UNICODE_STRING));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    goto Cleanup2;
-  }
-  if(ClassName.Length > 0 && ClassName.Buffer)
-  {
-    WCHAR *buf;
-    /* safely copy the class name string (NULL terminated because class-lookup
-       depends on it... */
-    buf = ExAllocatePoolWithTag(PagedPool, ClassName.Length + sizeof(WCHAR), TAG_STRING);
-    if(!buf)
-    {
-      SetLastWin32Error(STATUS_INSUFFICIENT_RESOURCES);
-      goto Cleanup2;
-    }
-    Status = MmCopyFromCaller(buf, ClassName.Buffer, ClassName.Length);
-    if(!NT_SUCCESS(Status))
-    {
-      ExFreePool(buf);
-      SetLastNtError(Status);
-      goto Cleanup2;
-    }
-    ClassName.Buffer = buf;
-    /* make sure the string is null-terminated */
-    buf += ClassName.Length / sizeof(WCHAR);
-    *buf = L'\0';
-  }
-
-  /* find the class object */
-  if(ClassName.Buffer)
-    {
+   /* find the class object */
+   if(ClassName.Buffer)
+   {
       PWINSTATION_OBJECT WinStaObject;
 
       if (PsGetWin32Thread()->Desktop == NULL)
-        {
-          SetLastWin32Error(ERROR_INVALID_HANDLE);
-          goto Cleanup;
-        }
+      {
+         SetLastWin32Error(ERROR_INVALID_HANDLE);
+         goto Cleanup;
+      }
 
       WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
 
       Status = RtlLookupAtomInAtomTable(
-         WinStaObject->AtomTable,
-         ClassName.Buffer,
-         &ClassAtom);
+                  WinStaObject->AtomTable,
+                  ClassName.Buffer,
+                  &ClassAtom);
 
       if (!NT_SUCCESS(Status))
-        {
-          DPRINT1("Failed to lookup class atom!\n");
-          SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST);
-          goto Cleanup;
-        }
-  }
-
-  if(Parent->hSelf == Desktop)
-  {
-    HWND *List, *phWnd;
-    PWINDOW_OBJECT TopLevelWindow;
-    BOOLEAN CheckWindowName;
-    BOOLEAN CheckClassName;
-    BOOLEAN WindowMatches;
-    BOOLEAN ClassMatches;
-
-    /* windows searches through all top-level windows if the parent is the desktop
-       window */
-
-    if((List = IntWinListChildren(Parent)))
-    {
-      phWnd = List;
-
-      if(ChildAfter)
       {
-        /* skip handles before and including ChildAfter */
-        while(*phWnd && (*(phWnd++) != ChildAfter->hSelf));
+         DPRINT1("Failed to lookup class atom!\n");
+         SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST);
+         goto Cleanup;
       }
+   }
+
+   if(Parent->hSelf == Desktop)
+   {
+      HWND *List, *phWnd;
+      PWINDOW_OBJECT TopLevelWindow;
+      BOOLEAN CheckWindowName;
+      BOOLEAN CheckClassName;
+      BOOLEAN WindowMatches;
+      BOOLEAN ClassMatches;
 
-      CheckWindowName = WindowName.Length > 0;
-      CheckClassName = ClassName.Buffer != NULL;
+      /* windows searches through all top-level windows if the parent is the desktop
+         window */
 
-      /* search children */
-      while(*phWnd)
+      if((List = IntWinListChildren(Parent)))
       {
-        if(!(TopLevelWindow = IntGetWindowObject(*(phWnd++))))
-        {
-          continue;
-        }
-
-        /* Do not send WM_GETTEXT messages in the kernel mode version!
-           The user mode version however calls GetWindowText() which will
-           send WM_GETTEXT messages to windows belonging to its processes */
-        WindowMatches = !CheckWindowName || !RtlCompareUnicodeString(
-                        &WindowName, &TopLevelWindow->WindowName, FALSE);
-        ClassMatches = !CheckClassName ||
-                       ClassAtom == TopLevelWindow->Class->Atom;
-
-        if (WindowMatches && ClassMatches)
-        {
-          Ret = TopLevelWindow->hSelf;
-          IntReleaseWindowObject(TopLevelWindow);
-          break;
-        }
-
-        if (IntFindWindow(TopLevelWindow, NULL, ClassAtom, &WindowName))
-        {
-          /* window returns the handle of the top-level window, in case it found
-             the child window */
-          Ret = TopLevelWindow->hSelf;
-          IntReleaseWindowObject(TopLevelWindow);
-          break;
-        }
-
-        IntReleaseWindowObject(TopLevelWindow);
+         phWnd = List;
+
+         if(ChildAfter)
+         {
+            /* skip handles before and including ChildAfter */
+            while(*phWnd && (*(phWnd++) != ChildAfter->hSelf))
+               ;
+         }
+
+         CheckWindowName = WindowName.Length > 0;
+         CheckClassName = ClassName.Buffer != NULL;
+
+         /* search children */
+         while(*phWnd)
+         {
+            if(!(TopLevelWindow = IntGetWindowObject(*(phWnd++))))
+            {
+               continue;
+            }
+
+            /* Do not send WM_GETTEXT messages in the kernel mode version!
+               The user mode version however calls GetWindowText() which will
+               send WM_GETTEXT messages to windows belonging to its processes */
+            WindowMatches = !CheckWindowName || !RtlCompareUnicodeString(
+                               &WindowName, &TopLevelWindow->WindowName, FALSE);
+            ClassMatches = !CheckClassName ||
+                           ClassAtom == TopLevelWindow->Class->Atom;
+
+            if (WindowMatches && ClassMatches)
+            {
+               Ret = TopLevelWindow->hSelf;
+               IntReleaseWindowObject(TopLevelWindow);
+               break;
+            }
+
+            if (IntFindWindow(TopLevelWindow, NULL, ClassAtom, &WindowName))
+            {
+               /* window returns the handle of the top-level window, in case it found
+                  the child window */
+               Ret = TopLevelWindow->hSelf;
+               IntReleaseWindowObject(TopLevelWindow);
+               break;
+            }
+
+            IntReleaseWindowObject(TopLevelWindow);
+         }
+         ExFreePool(List);
       }
-      ExFreePool(List);
-    }
-  }
-  else
-    Ret = IntFindWindow(Parent, ChildAfter, ClassAtom, &WindowName);
+   }
+   else
+      Ret = IntFindWindow(Parent, ChildAfter, ClassAtom, &WindowName);
 
 #if 0
-  if(Ret == NULL && hwndParent == NULL && hwndChildAfter == NULL)
-  {
-    /* FIXME - if both hwndParent and hwndChildAfter are NULL, we also should
-               search the message-only windows. Should this also be done if
-               Parent is the desktop window??? */
-    PWINDOW_OBJECT MsgWindows;
-
-    if((MsgWindows = IntGetWindowObject(IntGetMessageWindow())))
-    {
-      Ret = IntFindWindow(MsgWindows, ChildAfter, ClassAtom, &WindowName);
-      IntReleaseWindowObject(MsgWindows);
-    }
-  }
+
+   if(Ret == NULL && hwndParent == NULL && hwndChildAfter == NULL)
+   {
+      /* FIXME - if both hwndParent and hwndChildAfter are NULL, we also should
+                 search the message-only windows. Should this also be done if
+                 Parent is the desktop window??? */
+      PWINDOW_OBJECT MsgWindows;
+
+      if((MsgWindows = IntGetWindowObject(IntGetMessageWindow())))
+      {
+         Ret = IntFindWindow(MsgWindows, ChildAfter, ClassAtom, &WindowName);
+         IntReleaseWindowObject(MsgWindows);
+      }
+   }
 #endif
 
-  Cleanup:
-  if(ClassName.Length > 0 && ClassName.Buffer)
-    ExFreePool(ClassName.Buffer);
+Cleanup:
+   if(ClassName.Length > 0 && ClassName.Buffer)
+      ExFreePool(ClassName.Buffer);
+
+Cleanup2:
+   RtlFreeUnicodeString(&WindowName);
 
-  Cleanup2:
-  RtlFreeUnicodeString(&WindowName);
+Cleanup3:
+   if(ChildAfter)
+      IntReleaseWindowObject(ChildAfter);
+   IntReleaseWindowObject(Parent);
 
-  Cleanup3:
-  if(ChildAfter)
-    IntReleaseWindowObject(ChildAfter);
-  IntReleaseWindowObject(Parent);
+   RETURN( Ret);
 
-  RETURN( Ret);
-  
 CLEANUP:
-  DPRINT("Leave NtUserFindWindowEx, ret %i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserFindWindowEx, ret %i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -2581,9 +2619,9 @@ CLEANUP:
 DWORD STDCALL
 NtUserFlashWindowEx(DWORD Unknown0)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
@@ -2609,67 +2647,67 @@ HWND FASTCALL UserGetAncestor(HWND hWnd, UINT Type)
    switch (Type)
    {
       case GA_PARENT:
-      {
-         WndAncestor = IntGetParentObject(Wnd);
-         break;
-      }
+         {
+            WndAncestor = IntGetParentObject(Wnd);
+            break;
+         }
 
       case GA_ROOT:
-      {
-         PWINDOW_OBJECT tmp;
-         WndAncestor = Wnd;
-         Parent = NULL;
-
-         for(;;)
          {
-           tmp = Parent;
-           if(!(Parent = IntGetParentObject(WndAncestor)))
-           {
-             break;
-           }
-           if(IntIsDesktopWindow(Parent))
-           {
-             IntReleaseWindowObject(Parent);
-             break;
-           }
-           if(tmp)
-             IntReleaseWindowObject(tmp);
-           WndAncestor = Parent;
+            PWINDOW_OBJECT tmp;
+            WndAncestor = Wnd;
+            Parent = NULL;
+
+            for(;;)
+            {
+               tmp = Parent;
+               if(!(Parent = IntGetParentObject(WndAncestor)))
+               {
+                  break;
+               }
+               if(IntIsDesktopWindow(Parent))
+               {
+                  IntReleaseWindowObject(Parent);
+                  break;
+               }
+               if(tmp)
+                  IntReleaseWindowObject(tmp);
+               WndAncestor = Parent;
+            }
+            break;
          }
-         break;
-      }
 
       case GA_ROOTOWNER:
-      {
-         WndAncestor = Wnd;
-         IntReferenceWindowObject(WndAncestor);
-         for (;;)
          {
-            PWINDOW_OBJECT Old;
-            Old = WndAncestor;
-            Parent = IntGetParent(WndAncestor);
-            IntReleaseWindowObject(Old);
-            if (!Parent)
+            WndAncestor = Wnd;
+            IntReferenceWindowObject(WndAncestor);
+            for (;;)
             {
-              break;
+               PWINDOW_OBJECT Old;
+               Old = WndAncestor;
+               Parent = IntGetParent(WndAncestor);
+               IntReleaseWindowObject(Old);
+               if (!Parent)
+               {
+                  break;
+               }
+               WndAncestor = Parent;
             }
-            WndAncestor = Parent;
+            break;
          }
-         break;
-      }
 
       default:
-      {
-         IntReleaseWindowObject(Wnd);
-         return NULL;
-      }
+         {
+            IntReleaseWindowObject(Wnd);
+            return NULL;
+         }
    }
 
    hWndAncestor = (WndAncestor ? WndAncestor->hSelf : NULL);
    IntReleaseWindowObject(Wnd);
 
    if(WndAncestor && (WndAncestor != Wnd))
-     IntReleaseWindowObject(WndAncestor);
+      IntReleaseWindowObject(WndAncestor);
 
    return hWndAncestor;
 }
@@ -2698,8 +2736,8 @@ CLEANUP:
 /*!
  * Returns client window rectangle relative to the upper-left corner of client area.
  *
- * \param      hWnd    window handle.
- * \param      Rect    pointer to the buffer where the coordinates are returned.
+ * \param hWnd window handle.
+ * \param Rect pointer to the buffer where the coordinates are returned.
  *
 */
 /*
@@ -2708,32 +2746,32 @@ CLEANUP:
 BOOL STDCALL
 NtUserGetClientRect(HWND hWnd, LPRECT Rect)
 {
-  PWINDOW_OBJECT Window;
-  RECT SafeRect;
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserGetClientRect\n");
-  UserEnterShared();
-
-  if(!(Window = IntGetWindowObject(hWnd)))
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    RETURN( FALSE);
-  }
-
-  IntGetClientRect(Window, &SafeRect);
-  IntReleaseWindowObject(Window);
-
-  if(!NT_SUCCESS(MmCopyToCaller(Rect, &SafeRect, sizeof(RECT))))
-  {
-    RETURN( FALSE);
-  }
-  RETURN( TRUE);
-  
+   PWINDOW_OBJECT Window;
+   RECT SafeRect;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserGetClientRect\n");
+   UserEnterShared();
+
+   if(!(Window = IntGetWindowObject(hWnd)))
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      RETURN( FALSE);
+   }
+
+   IntGetClientRect(Window, &SafeRect);
+   IntReleaseWindowObject(Window);
+
+   if(!NT_SUCCESS(MmCopyToCaller(Rect, &SafeRect, sizeof(RECT))))
+   {
+      RETURN( FALSE);
+   }
+   RETURN( TRUE);
+
 CLEANUP:
-  DPRINT("Leave NtUserGetClientRect, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetClientRect, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -2747,9 +2785,9 @@ NtUserGetDesktopWindow()
 
    DPRINT("Enter NtUserGetDesktopWindow\n");
    UserEnterShared();
-   
+
    RETURN( IntGetDesktopWindow());
-   
+
 CLEANUP:
    DPRINT("Leave NtUserGetDesktopWindow, ret=%i\n",_ret_);
    UserLeave();
@@ -2762,12 +2800,12 @@ CLEANUP:
  */
 DWORD STDCALL
 NtUserGetInternalWindowPos(DWORD Unknown0,
-                          DWORD Unknown1,
-                          DWORD Unknown2)
+                           DWORD Unknown1,
+                           DWORD Unknown2)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
@@ -2777,30 +2815,31 @@ NtUserGetInternalWindowPos(DWORD Unknown0,
 HWND STDCALL
 NtUserGetLastActivePopup(HWND hWnd)
 {
-/*
- * This code can't work, because hWndLastPopup member of WINDOW_OBJECT is
- * not changed anywhere.
- * -- Filip, 01/nov/2003
- */
+   /*
   * This code can't work, because hWndLastPopup member of WINDOW_OBJECT is
   * not changed anywhere.
   * -- Filip, 01/nov/2003
   */
 #if 0
-  PWINDOW_OBJECT Wnd;
-  HWND hWndLastPopup;
+   PWINDOW_OBJECT Wnd;
+   HWND hWndLastPopup;
 
-  IntAcquireWinLockShared();
+   IntAcquireWinLockShared();
 
-  if (!(Wnd = IntGetWindowObject(hWnd)))
-  {
-    IntReleaseWinLock();
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return NULL;
-  }
+   if (!(Wnd = IntGetWindowObject(hWnd)))
+   {
+      IntReleaseWinLock();
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      return NULL;
+   }
 
-  hWndLastPopup = Wnd->hWndLastPopup;
+   hWndLastPopup = Wnd->hWndLastPopup;
 
-  IntReleaseWinLock();
+   IntReleaseWinLock();
 
-  return hWndLastPopup;
+   return hWndLastPopup;
 #else
+
    return NULL;
 #endif
 }
@@ -2845,7 +2884,7 @@ NtUserGetParent(HWND hWnd)
    IntReleaseWindowObject(Wnd);
 
    RETURN( hWndParent);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserGetParent, ret=%i\n",_ret_);
    UserLeave();
@@ -2939,7 +2978,7 @@ NtUserSetParent(HWND hWndChild, HWND hWndNewParent)
    UserEnterExclusive();
 
    RETURN( co_UserSetParent(hWndChild, hWndNewParent));
-   
+
 CLEANUP:
    DPRINT("Leave NtUserSetParent, ret=%i\n",_ret_);
    UserLeave();
@@ -2951,24 +2990,24 @@ CLEANUP:
 
 HWND FASTCALL UserGetShellWindow()
 {
-  PWINSTATION_OBJECT WinStaObject;
-  HWND Ret;
+   PWINSTATION_OBJECT WinStaObject;
+   HWND Ret;
 
-  NTSTATUS Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
-                   KernelMode,
-                   0,
-                   &WinStaObject);
+   NTSTATUS Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
+                     KernelMode,
+                     0,
+                     &WinStaObject);
 
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return( (HWND)0);
-  }
+   if (!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      return( (HWND)0);
+   }
 
-  Ret = (HWND)WinStaObject->ShellWindow;
+   Ret = (HWND)WinStaObject->ShellWindow;
 
-  ObDereferenceObject(WinStaObject);
-  return( Ret);
+   ObDereferenceObject(WinStaObject);
+   return( Ret);
 }
 
 
@@ -2984,17 +3023,17 @@ HWND FASTCALL UserGetShellWindow()
 HWND STDCALL
 NtUserGetShellWindow()
 {
-  DECLARE_RETURN(HWND);
+   DECLARE_RETURN(HWND);
+
+   DPRINT("Enter NtUserGetShellWindow\n");
+   UserEnterShared();
 
-  DPRINT("Enter NtUserGetShellWindow\n");
-  UserEnterShared();
+   RETURN( UserGetShellWindow() );
 
-  RETURN( UserGetShellWindow() );
-  
 CLEANUP:
-  DPRINT("Leave NtUserGetShellWindow, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetShellWindow, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 /*
@@ -3010,28 +3049,28 @@ CLEANUP:
 BOOL STDCALL
 NtUserSetShellWindowEx(HWND hwndShell, HWND hwndListView)
 {
-  PWINSTATION_OBJECT WinStaObject;
-  PWINDOW_OBJECT WndShell;
-  DECLARE_RETURN(BOOL);
+   PWINSTATION_OBJECT WinStaObject;
+   PWINDOW_OBJECT WndShell;
+   DECLARE_RETURN(BOOL);
 
-  DPRINT("Enter NtUserSetShellWindowEx\n");
-  UserEnterExclusive();
+   DPRINT("Enter NtUserSetShellWindowEx\n");
+   UserEnterExclusive();
 
-  if (!(WndShell = UserGetWindowObject(hwndShell)))
-  {
-     RETURN(FALSE);
-  }
+   if (!(WndShell = UserGetWindowObject(hwndShell)))
+   {
+      RETURN(FALSE);
+   }
 
-  NTSTATUS Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
-                                      KernelMode,
-                                      0,
-                                      &WinStaObject);
+   NTSTATUS Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
+                     KernelMode,
+                     0,
+                     &WinStaObject);
 
-  if (!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    RETURN( FALSE);
-  }
+   if (!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      RETURN( FALSE);
+   }
 
    /*
     * Test if we are permitted to change the shell window.
@@ -3047,12 +3086,12 @@ NtUserSetShellWindowEx(HWND hwndShell, HWND hwndListView)
     */
    if (hwndListView && hwndListView != hwndShell)
    {
-/*
- * Disabled for now to get Explorer working.
- * -- Filip, 01/nov/2003
- */
+      /*
      * Disabled for now to get Explorer working.
      * -- Filip, 01/nov/2003
      */
 #if 0
-       co_WinPosSetWindowPos(hwndListView, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+      co_WinPosSetWindowPos(hwndListView, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
 #endif
 
       if (UserGetWindowLong(hwndListView, GWL_EXSTYLE, FALSE) & WS_EX_TOPMOST)
@@ -3078,11 +3117,11 @@ NtUserSetShellWindowEx(HWND hwndShell, HWND hwndListView)
 
    ObDereferenceObject(WinStaObject);
    RETURN( TRUE);
-   
+
 CLEANUP:
-  DPRINT("Leave NtUserSetShellWindowEx, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserSetShellWindowEx, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 /*
@@ -3133,7 +3172,7 @@ NtUserGetSystemMenu(HWND hWnd, BOOL bRevert)
    }
 
    RETURN(Menu->MenuInfo.Self);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserGetSystemMenu, ret=%i\n",_ret_);
    UserLeave();
@@ -3185,7 +3224,7 @@ NtUserSetSystemMenu(HWND hWnd, HMENU hMenu)
    IntReleaseWindowObject(Window);
 
    RETURN( Result);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserSetSystemMenu, ret=%i\n",_ret_);
    UserLeave();
@@ -3201,23 +3240,24 @@ UserGetWindow(HWND hWnd, UINT Relationship)
    PWINDOW_OBJECT Parent, Window;
    HWND hWndResult = NULL;
 
-   if (!(Window = UserGetWindowObject(hWnd))) return NULL;
+   if (!(Window = UserGetWindowObject(hWnd)))
+      return NULL;
 
    switch (Relationship)
    {
       case GW_HWNDFIRST:
          if((Parent = Window->Parent))
          {
-           if (Parent->FirstChild)
-              hWndResult = Parent->FirstChild->hSelf;
+            if (Parent->FirstChild)
+               hWndResult = Parent->FirstChild->hSelf;
          }
          break;
 
       case GW_HWNDLAST:
          if((Parent = Window->Parent))
          {
-           if (Parent->LastChild)
-              hWndResult = Parent->LastChild->hSelf;
+            if (Parent->LastChild)
+               hWndResult = Parent->LastChild->hSelf;
          }
          break;
 
@@ -3234,8 +3274,8 @@ UserGetWindow(HWND hWnd, UINT Relationship)
       case GW_OWNER:
          if((Parent = IntGetWindowObject(Window->hOwner)))
          {
-           hWndResult = Parent->hSelf;
-           IntReleaseWindowObject(Parent);
+            hWndResult = Parent->hSelf;
+            IntReleaseWindowObject(Parent);
          }
          break;
       case GW_CHILD:
@@ -3263,12 +3303,12 @@ HWND STDCALL
 NtUserGetWindow(HWND hWnd, UINT Relationship)
 {
    DECLARE_RETURN(HWND);
-   
+
    DPRINT("Enter NtUserGetWindow\n");
    UserEnterShared();
-   
+
    RETURN(UserGetWindow(hWnd, Relationship));
-   
+
 CLEANUP:
    DPRINT("Leave NtUserGetWindow, ret=%i\n",_ret_);
    UserLeave();
@@ -3307,7 +3347,7 @@ UserGetWindowLong(HWND hWnd, DWORD Index, BOOL Ansi)
     * WndProc is only available to the owner process
     */
    if (GWL_WNDPROC == Index
-       && Window->OwnerThread->ThreadsProcess != PsGetCurrentProcess())
+         && Window->OwnerThread->ThreadsProcess != PsGetCurrentProcess())
    {
       SetLastWin32Error(ERROR_ACCESS_DENIED);
       return 0;
@@ -3349,10 +3389,10 @@ UserGetWindowLong(HWND hWnd, DWORD Index, BOOL Ansi)
             Parent = Window->Parent;
             if(Parent)
             {
-              if (Parent && Parent->hSelf == IntGetDesktopWindow())
-                 Result = (LONG) UserGetWindow(Window->hSelf, GW_OWNER);
-              else
-                 Result = (LONG) Parent->hSelf;
+               if (Parent && Parent->hSelf == IntGetDesktopWindow())
+                  Result = (LONG) UserGetWindow(Window->hSelf, GW_OWNER);
+               else
+                  Result = (LONG) Parent->hSelf;
             }
             break;
 
@@ -3456,8 +3496,8 @@ co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
             WindowStation = Window->OwnerThread->Tcb.Win32Thread->Desktop->WindowStation;
             if(WindowStation)
             {
-              if (hWnd == WindowStation->ShellWindow || hWnd == WindowStation->ShellListView)
-                 Style.styleNew &= ~WS_EX_TOPMOST;
+               if (hWnd == WindowStation->ShellWindow || hWnd == WindowStation->ShellListView)
+                  Style.styleNew &= ~WS_EX_TOPMOST;
             }
 
             co_IntSendMessage(hWnd, WM_STYLECHANGING, GWL_EXSTYLE, (LPARAM) &Style);
@@ -3504,7 +3544,7 @@ co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
             else
                OldValue = (LONG) co_UserSetParent(Window->hSelf, (HWND) NewValue);
             if(Parent)
-              IntReleaseWindowObject(Parent);
+               IntReleaseWindowObject(Parent);
             break;
 
          case GWL_ID:
@@ -3552,7 +3592,7 @@ NtUserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
    UserEnterExclusive();
 
    RETURN( co_UserSetWindowLong(hWnd, Index, NewValue, Ansi));
-   
+
 CLEANUP:
    DPRINT("Leave NtUserSetWindowLong, ret=%i\n",_ret_);
    UserLeave();
@@ -3574,7 +3614,7 @@ NtUserSetWindowWord(HWND hWnd, INT Index, WORD NewValue)
    PWINDOW_OBJECT Window;
    WORD OldValue;
    DECLARE_RETURN(WORD);
-   
+
    DPRINT("Enter NtUserSetWindowWord\n");
    UserEnterExclusive();
 
@@ -3611,11 +3651,11 @@ NtUserSetWindowWord(HWND hWnd, INT Index, WORD NewValue)
    IntReleaseWindowObject(Window);
 
    RETURN( OldValue);
-   
+
 CLEANUP:
-  DPRINT("Leave NtUserSetWindowWord, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserSetWindowWord, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 /*
@@ -3623,78 +3663,78 @@ CLEANUP:
  */
 BOOL STDCALL
 NtUserGetWindowPlacement(HWND hWnd,
-                        WINDOWPLACEMENT *lpwndpl)
+                         WINDOWPLACEMENT *lpwndpl)
 {
-  PWINDOW_OBJECT Window;
-  PINTERNALPOS InternalPos;
-  POINT Size;
-  WINDOWPLACEMENT Safepl;
-  NTSTATUS Status;
-  DECLARE_RETURN(BOOL);
-   
-  DPRINT("Enter NtUserGetWindowPlacement\n");
-  UserEnterShared();
-
-  if (!(Window = IntGetWindowObject(hWnd)))
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    RETURN( FALSE);
-  }
-
-  Status = MmCopyFromCaller(&Safepl, lpwndpl, sizeof(WINDOWPLACEMENT));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    IntReleaseWindowObject(Window);
-    RETURN( FALSE);
-  }
-  if(Safepl.length != sizeof(WINDOWPLACEMENT))
-  {
-    IntReleaseWindowObject(Window);
-    RETURN( FALSE);
-  }
-
-  Safepl.flags = 0;
-  Safepl.showCmd = ((Window->Flags & WINDOWOBJECT_RESTOREMAX) ? SW_MAXIMIZE : SW_SHOWNORMAL);
-
-  Size.x = Window->WindowRect.left;
-  Size.y = Window->WindowRect.top;
-  InternalPos = WinPosInitInternalPos(Window, &Size,
-                                     &Window->WindowRect);
-  if (InternalPos)
-  {
-    Safepl.rcNormalPosition = InternalPos->NormalRect;
-    Safepl.ptMinPosition = InternalPos->IconPos;
-    Safepl.ptMaxPosition = InternalPos->MaxPos;
-  }
-  else
-  {
-    IntReleaseWindowObject(Window);
-    RETURN( FALSE);
-  }
-
-  Status = MmCopyToCaller(lpwndpl, &Safepl, sizeof(WINDOWPLACEMENT));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    IntReleaseWindowObject(Window);
-    RETURN( FALSE);
-  }
-
-  IntReleaseWindowObject(Window);
-  RETURN( TRUE);
-  
+   PWINDOW_OBJECT Window;
+   PINTERNALPOS InternalPos;
+   POINT Size;
+   WINDOWPLACEMENT Safepl;
+   NTSTATUS Status;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserGetWindowPlacement\n");
+   UserEnterShared();
+
+   if (!(Window = IntGetWindowObject(hWnd)))
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      RETURN( FALSE);
+   }
+
+   Status = MmCopyFromCaller(&Safepl, lpwndpl, sizeof(WINDOWPLACEMENT));
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      IntReleaseWindowObject(Window);
+      RETURN( FALSE);
+   }
+   if(Safepl.length != sizeof(WINDOWPLACEMENT))
+   {
+      IntReleaseWindowObject(Window);
+      RETURN( FALSE);
+   }
+
+   Safepl.flags = 0;
+   Safepl.showCmd = ((Window->Flags & WINDOWOBJECT_RESTOREMAX) ? SW_MAXIMIZE : SW_SHOWNORMAL);
+
+   Size.x = Window->WindowRect.left;
+   Size.y = Window->WindowRect.top;
+   InternalPos = WinPosInitInternalPos(Window, &Size,
+                                       &Window->WindowRect);
+   if (InternalPos)
+   {
+      Safepl.rcNormalPosition = InternalPos->NormalRect;
+      Safepl.ptMinPosition = InternalPos->IconPos;
+      Safepl.ptMaxPosition = InternalPos->MaxPos;
+   }
+   else
+   {
+      IntReleaseWindowObject(Window);
+      RETURN( FALSE);
+   }
+
+   Status = MmCopyToCaller(lpwndpl, &Safepl, sizeof(WINDOWPLACEMENT));
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      IntReleaseWindowObject(Window);
+      RETURN( FALSE);
+   }
+
+   IntReleaseWindowObject(Window);
+   RETURN( TRUE);
+
 CLEANUP:
-  DPRINT("Leave NtUserGetWindowPlacement, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetWindowPlacement, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
 /*!
  * Return the dimension of the window in the screen coordinates.
- * \param      hWnd    window handle.
- * \param      Rect    pointer to the buffer where the coordinates are returned.
+ * \param hWnd window handle.
+ * \param Rect pointer to the buffer where the coordinates are returned.
 */
 /*
  * @implemented
@@ -3702,33 +3742,33 @@ CLEANUP:
 BOOL STDCALL
 NtUserGetWindowRect(HWND hWnd, LPRECT Rect)
 {
-  PWINDOW_OBJECT Wnd;
-  NTSTATUS Status;
-  DECLARE_RETURN(BOOL);
-   
-  DPRINT("Enter NtUserGetWindowRect\n");
-  UserEnterShared();
-
-  if (!(Wnd = IntGetWindowObject(hWnd)))
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    RETURN(FALSE);
-  }
-  Status = MmCopyToCaller(Rect, &Wnd->WindowRect, sizeof(RECT));
-  if (!NT_SUCCESS(Status))
-  {
-    IntReleaseWindowObject(Wnd);
-    SetLastNtError(Status);
-    RETURN( FALSE);
-  }
-
-  IntReleaseWindowObject(Wnd);
-  RETURN( TRUE);
-  
+   PWINDOW_OBJECT Wnd;
+   NTSTATUS Status;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserGetWindowRect\n");
+   UserEnterShared();
+
+   if (!(Wnd = IntGetWindowObject(hWnd)))
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      RETURN(FALSE);
+   }
+   Status = MmCopyToCaller(Rect, &Wnd->WindowRect, sizeof(RECT));
+   if (!NT_SUCCESS(Status))
+   {
+      IntReleaseWindowObject(Wnd);
+      SetLastNtError(Status);
+      RETURN( FALSE);
+   }
+
+   IntReleaseWindowObject(Wnd);
+   RETURN( TRUE);
+
 CLEANUP:
-  DPRINT("Leave NtUserGetWindowRect, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetWindowRect, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -3741,7 +3781,7 @@ NtUserGetWindowThreadProcessId(HWND hWnd, LPDWORD UnsafePid)
    PWINDOW_OBJECT Wnd;
    DWORD tid, pid;
    DECLARE_RETURN(DWORD);
-   
+
    DPRINT("Enter NtUserGetWindowThreadProcessId\n");
    UserEnterShared();
 
@@ -3754,10 +3794,11 @@ NtUserGetWindowThreadProcessId(HWND hWnd, LPDWORD UnsafePid)
    tid = (DWORD)IntGetWndThreadId(Wnd);
    pid = (DWORD)IntGetWndProcessId(Wnd);
 
-   if (UnsafePid) MmCopyToCaller(UnsafePid, &pid, sizeof(DWORD));
+   if (UnsafePid)
+      MmCopyToCaller(UnsafePid, &pid, sizeof(DWORD));
 
    RETURN( tid);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserGetWindowThreadProcessId, ret=%i\n",_ret_);
    UserLeave();
@@ -3771,9 +3812,9 @@ CLEANUP:
 DWORD STDCALL
 NtUserLockWindowUpdate(DWORD Unknown0)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
@@ -3782,26 +3823,26 @@ NtUserLockWindowUpdate(DWORD Unknown0)
  */
 BOOL STDCALL
 NtUserMoveWindow(
-    HWND hWnd,
-    int X,
-    int Y,
-    int nWidth,
-    int nHeight,
-    BOOL bRepaint)
+   HWND hWnd,
+   int X,
+   int Y,
+   int nWidth,
+   int nHeight,
+   BOOL bRepaint)
 {
-       return NtUserSetWindowPos(hWnd, 0, X, Y, nWidth, nHeight,
-                              (bRepaint ? SWP_NOZORDER | SWP_NOACTIVATE :
-                               SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW));
+   return NtUserSetWindowPos(hWnd, 0, X, Y, nWidth, nHeight,
+                             (bRepaint ? SWP_NOZORDER | SWP_NOACTIVATE :
+                              SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW));
 }
 
 /*
      QueryWindow based on KJK::Hyperion and James Tabor.
-
      0 = QWUniqueProcessId
      1 = QWUniqueThreadId
      4 = QWIsHung            Implements IsHungAppWindow found
+ QueryWindow based on KJK::Hyperion and James Tabor.
+ 0 = QWUniqueProcessId
+ 1 = QWUniqueThreadId
+ 4 = QWIsHung            Implements IsHungAppWindow found
                                 by KJK::Hyperion.
-
         9 = QWKillWindow        When I called this with hWnd ==
                                 DesktopWindow, it shutdown the system
                                 and rebooted.
@@ -3815,7 +3856,7 @@ NtUserQueryWindow(HWND hWnd, DWORD Index)
    PWINDOW_OBJECT Window = IntGetWindowObject(hWnd);
    DWORD Result;
    DECLARE_RETURN(UINT);
-   
+
    DPRINT("Enter NtUserQueryWindow\n");
    UserEnterShared();
 
@@ -3847,8 +3888,8 @@ NtUserQueryWindow(HWND hWnd, DWORD Index)
    IntReleaseWindowObject(Window);
 
    RETURN( Result);
-   
-  
+
+
 CLEANUP:
    DPRINT("Leave NtUserQueryWindow, ret=%i\n",_ret_);
    UserLeave();
@@ -3861,51 +3902,51 @@ CLEANUP:
  */
 DWORD STDCALL
 NtUserRealChildWindowFromPoint(DWORD Unknown0,
-                              DWORD Unknown1,
-                              DWORD Unknown2)
+                               DWORD Unknown1,
+                               DWORD Unknown2)
+{
+   UNIMPLEMENTED
+
+   return 0;
+}
+
+
+/*
+ * @implemented
+ */
+UINT STDCALL
+NtUserRegisterWindowMessage(PUNICODE_STRING MessageNameUnsafe)
 {
-  UNIMPLEMENTED
+   UNICODE_STRING SafeMessageName;
+   NTSTATUS Status;
+   UINT Ret;
+   DECLARE_RETURN(UINT);
+
+   DPRINT("Enter NtUserRegisterWindowMessage\n");
+   UserEnterExclusive();
+
+   if(MessageNameUnsafe == NULL)
+   {
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      RETURN( 0);
+   }
+
+   Status = IntSafeCopyUnicodeStringTerminateNULL(&SafeMessageName, MessageNameUnsafe);
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      RETURN( 0);
+   }
 
-  return 0;
-}
+   Ret = (UINT)IntAddAtom(SafeMessageName.Buffer);
 
+   RtlFreeUnicodeString(&SafeMessageName);
+   RETURN( Ret);
 
-/*
- * @implemented
- */
-UINT STDCALL
-NtUserRegisterWindowMessage(PUNICODE_STRING MessageNameUnsafe)
-{
-  UNICODE_STRING SafeMessageName;
-  NTSTATUS Status;
-  UINT Ret;
-  DECLARE_RETURN(UINT);
-   
-  DPRINT("Enter NtUserRegisterWindowMessage\n");
-  UserEnterExclusive();
-
-  if(MessageNameUnsafe == NULL)
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    RETURN( 0);
-  }
-
-  Status = IntSafeCopyUnicodeStringTerminateNULL(&SafeMessageName, MessageNameUnsafe);
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    RETURN( 0);
-  }
-
-  Ret = (UINT)IntAddAtom(SafeMessageName.Buffer);
-
-  RtlFreeUnicodeString(&SafeMessageName);
-  RETURN( Ret);
-  
 CLEANUP:
-  DPRINT("Leave NtUserRegisterWindowMessage, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserRegisterWindowMessage, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -3914,11 +3955,11 @@ CLEANUP:
  */
 DWORD STDCALL
 NtUserSetImeOwnerWindow(DWORD Unknown0,
-                       DWORD Unknown1)
+                        DWORD Unknown1)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
@@ -3927,13 +3968,13 @@ NtUserSetImeOwnerWindow(DWORD Unknown0,
  */
 DWORD STDCALL
 NtUserSetInternalWindowPos(DWORD Unknown0,
-                          DWORD Unknown1,
-                          DWORD Unknown2,
-                          DWORD Unknown3)
+                           DWORD Unknown1,
+                           DWORD Unknown2,
+                           DWORD Unknown3)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 
 }
 
@@ -3943,13 +3984,13 @@ NtUserSetInternalWindowPos(DWORD Unknown0,
  */
 DWORD STDCALL
 NtUserSetLayeredWindowAttributes(DWORD Unknown0,
-                                DWORD Unknown1,
-                                DWORD Unknown2,
-                                DWORD Unknown3)
+                                 DWORD Unknown1,
+                                 DWORD Unknown2,
+                                 DWORD Unknown3)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
@@ -3959,9 +4000,9 @@ NtUserSetLayeredWindowAttributes(DWORD Unknown0,
 DWORD STDCALL
 NtUserSetLogonNotifyWindow(DWORD Unknown0)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
@@ -3974,38 +4015,38 @@ NtUserSetMenu(
    HMENU Menu,
    BOOL Repaint)
 {
-  PWINDOW_OBJECT Window;
-  BOOL Changed;
-  DECLARE_RETURN(BOOL);
-   
-  DPRINT("Enter NtUserSetMenu\n");
-  UserEnterExclusive();
-
-  if (!(Window = UserGetWindowObject(hWnd)))
-    {
+   PWINDOW_OBJECT Window;
+   BOOL Changed;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserSetMenu\n");
+   UserEnterExclusive();
+
+   if (!(Window = UserGetWindowObject(hWnd)))
+   {
       RETURN( FALSE);
-    }
+   }
 
-  if (! IntSetMenu(Window, Menu, &Changed))
-    {
+   if (! IntSetMenu(Window, Menu, &Changed))
+   {
       RETURN( FALSE);
-    }
+   }
 
-  if (Changed && Repaint)
-    {
-      UserRefObjectCo(Window); 
+   if (Changed && Repaint)
+   {
+      UserRefObjectCo(Window);
       co_WinPosSetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
-                         SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED);
-                         
-      UserDerefObjectCo(Window);                         
-    }
+                            SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED);
+
+      UserDerefObjectCo(Window);
+   }
+
+   RETURN( TRUE);
 
-  RETURN( TRUE);
-  
 CLEANUP:
-  DPRINT("Leave NtUserSetMenu, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserSetMenu, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -4014,11 +4055,11 @@ CLEANUP:
  */
 DWORD STDCALL
 NtUserSetWindowFNID(DWORD Unknown0,
-                   DWORD Unknown1)
+                    DWORD Unknown1)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
@@ -4028,59 +4069,59 @@ NtUserSetWindowFNID(DWORD Unknown0,
  */
 BOOL STDCALL
 NtUserSetWindowPlacement(HWND hWnd,
-                        WINDOWPLACEMENT *lpwndpl)
+                         WINDOWPLACEMENT *lpwndpl)
 {
-  PWINDOW_OBJECT Window;
-  WINDOWPLACEMENT Safepl;
-  NTSTATUS Status;
-  DECLARE_RETURN(BOOL);
-   
-  DPRINT("Enter NtUserSetWindowPlacement\n");
-  UserEnterExclusive();
-
-  if (!(Window = IntGetWindowObject(hWnd)))
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    RETURN( FALSE);
-  }
-  Status = MmCopyFromCaller(&Safepl, lpwndpl, sizeof(WINDOWPLACEMENT));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    IntReleaseWindowObject(Window);
-    RETURN( FALSE);
-  }
-  if(Safepl.length != sizeof(WINDOWPLACEMENT))
-  {
-    IntReleaseWindowObject(Window);
-    RETURN( FALSE);
-  }
-
-  if ((Window->Style & (WS_MAXIMIZE | WS_MINIMIZE)) == 0)
-  {
-     co_WinPosSetWindowPos(Window, NULL,
-        Safepl.rcNormalPosition.left, Safepl.rcNormalPosition.top,
-        Safepl.rcNormalPosition.right - Safepl.rcNormalPosition.left,
-        Safepl.rcNormalPosition.bottom - Safepl.rcNormalPosition.top,
-        SWP_NOZORDER | SWP_NOACTIVATE);
-  }
-
-  /* FIXME - change window status */
-  co_WinPosShowWindow(Window, Safepl.showCmd);
-
-  if (Window->InternalPos == NULL)
-     Window->InternalPos = ExAllocatePoolWithTag(PagedPool, sizeof(INTERNALPOS), TAG_WININTLIST);
-  Window->InternalPos->NormalRect = Safepl.rcNormalPosition;
-  Window->InternalPos->IconPos = Safepl.ptMinPosition;
-  Window->InternalPos->MaxPos = Safepl.ptMaxPosition;
-
-  IntReleaseWindowObject(Window);
-  RETURN( TRUE);
-  
+   PWINDOW_OBJECT Window;
+   WINDOWPLACEMENT Safepl;
+   NTSTATUS Status;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserSetWindowPlacement\n");
+   UserEnterExclusive();
+
+   if (!(Window = IntGetWindowObject(hWnd)))
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      RETURN( FALSE);
+   }
+   Status = MmCopyFromCaller(&Safepl, lpwndpl, sizeof(WINDOWPLACEMENT));
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      IntReleaseWindowObject(Window);
+      RETURN( FALSE);
+   }
+   if(Safepl.length != sizeof(WINDOWPLACEMENT))
+   {
+      IntReleaseWindowObject(Window);
+      RETURN( FALSE);
+   }
+
+   if ((Window->Style & (WS_MAXIMIZE | WS_MINIMIZE)) == 0)
+   {
+      co_WinPosSetWindowPos(Window, NULL,
+                            Safepl.rcNormalPosition.left, Safepl.rcNormalPosition.top,
+                            Safepl.rcNormalPosition.right - Safepl.rcNormalPosition.left,
+                            Safepl.rcNormalPosition.bottom - Safepl.rcNormalPosition.top,
+                            SWP_NOZORDER | SWP_NOACTIVATE);
+   }
+
+   /* FIXME - change window status */
+   co_WinPosShowWindow(Window, Safepl.showCmd);
+
+   if (Window->InternalPos == NULL)
+      Window->InternalPos = ExAllocatePoolWithTag(PagedPool, sizeof(INTERNALPOS), TAG_WININTLIST);
+   Window->InternalPos->NormalRect = Safepl.rcNormalPosition;
+   Window->InternalPos->IconPos = Safepl.ptMinPosition;
+   Window->InternalPos->MaxPos = Safepl.ptMaxPosition;
+
+   IntReleaseWindowObject(Window);
+   RETURN( TRUE);
+
 CLEANUP:
-  DPRINT("Leave NtUserSetWindowPlacement, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserSetWindowPlacement, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -4089,32 +4130,32 @@ CLEANUP:
  */
 BOOL STDCALL
 NtUserSetWindowPos(
-    HWND hWnd,
-    HWND hWndInsertAfter,
-    int X,
-    int Y,
-    int cx,
-    int cy,
-    UINT uFlags)
+   HWND hWnd,
+   HWND hWndInsertAfter,
+   int X,
+   int Y,
+   int cx,
+   int cy,
+   UINT uFlags)
 {
    DECLARE_RETURN(BOOL);
    PWINDOW_OBJECT Window;
    BOOL ret;
-   
+
    DPRINT("Enter NtUserSetWindowPos\n");
    UserEnterExclusive();
-   
+
    if (!(Window = UserGetWindowObject(hWnd)))
    {
       RETURN(FALSE);
    }
-   
+
    UserRefObjectCo(Window);
    ret = co_WinPosSetWindowPos(Window, hWndInsertAfter, X, Y, cx, cy, uFlags);
    UserDerefObjectCo(Window);
-   
+
    RETURN(ret);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserSetWindowPos, ret=%i\n",_ret_);
    UserLeave();
@@ -4125,84 +4166,84 @@ CLEANUP:
 INT FASTCALL
 IntGetWindowRgn(HWND hWnd, HRGN hRgn)
 {
-  INT Ret;
-  PWINDOW_OBJECT Window;
-  HRGN VisRgn;
-  ROSRGNDATA *pRgn;
-
-  if(!(Window = IntGetWindowObject(hWnd)))
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return ERROR;
-  }
-  if(!hRgn)
-  {
-    IntReleaseWindowObject(Window);
-    return ERROR;
-  }
-
-  /* Create a new window region using the window rectangle */
-  VisRgn = UnsafeIntCreateRectRgnIndirect(&Window->WindowRect);
-  NtGdiOffsetRgn(VisRgn, -Window->WindowRect.left, -Window->WindowRect.top);
-  /* if there's a region assigned to the window, combine them both */
-  if(Window->WindowRegion && !(Window->Style & WS_MINIMIZE))
-    NtGdiCombineRgn(VisRgn, VisRgn, Window->WindowRegion, RGN_AND);
-  /* Copy the region into hRgn */
-  NtGdiCombineRgn(hRgn, VisRgn, NULL, RGN_COPY);
-
-  if((pRgn = RGNDATA_LockRgn(hRgn)))
-  {
-    Ret = pRgn->rdh.iType;
-    RGNDATA_UnlockRgn(pRgn);
-  }
-  else
-    Ret = ERROR;
-
-  NtGdiDeleteObject(VisRgn);
-
-  IntReleaseWindowObject(Window);
-  return Ret;
+   INT Ret;
+   PWINDOW_OBJECT Window;
+   HRGN VisRgn;
+   ROSRGNDATA *pRgn;
+
+   if(!(Window = IntGetWindowObject(hWnd)))
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      return ERROR;
+   }
+   if(!hRgn)
+   {
+      IntReleaseWindowObject(Window);
+      return ERROR;
+   }
+
+   /* Create a new window region using the window rectangle */
+   VisRgn = UnsafeIntCreateRectRgnIndirect(&Window->WindowRect);
+   NtGdiOffsetRgn(VisRgn, -Window->WindowRect.left, -Window->WindowRect.top);
+   /* if there's a region assigned to the window, combine them both */
+   if(Window->WindowRegion && !(Window->Style & WS_MINIMIZE))
+      NtGdiCombineRgn(VisRgn, VisRgn, Window->WindowRegion, RGN_AND);
+   /* Copy the region into hRgn */
+   NtGdiCombineRgn(hRgn, VisRgn, NULL, RGN_COPY);
+
+   if((pRgn = RGNDATA_LockRgn(hRgn)))
+   {
+      Ret = pRgn->rdh.iType;
+      RGNDATA_UnlockRgn(pRgn);
+   }
+   else
+      Ret = ERROR;
+
+   NtGdiDeleteObject(VisRgn);
+
+   IntReleaseWindowObject(Window);
+   return Ret;
 }
 
 INT FASTCALL
 IntGetWindowRgnBox(HWND hWnd, RECT *Rect)
 {
-  INT Ret;
-  PWINDOW_OBJECT Window;
-  HRGN VisRgn;
-  ROSRGNDATA *pRgn;
-
-  if(!(Window = IntGetWindowObject(hWnd)))
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return ERROR;
-  }
-  if(!Rect)
-  {
-    IntReleaseWindowObject(Window);
-    return ERROR;
-  }
-
-  /* Create a new window region using the window rectangle */
-  VisRgn = UnsafeIntCreateRectRgnIndirect(&Window->WindowRect);
-  NtGdiOffsetRgn(VisRgn, -Window->WindowRect.left, -Window->WindowRect.top);
-  /* if there's a region assigned to the window, combine them both */
-  if(Window->WindowRegion && !(Window->Style & WS_MINIMIZE))
-    NtGdiCombineRgn(VisRgn, VisRgn, Window->WindowRegion, RGN_AND);
-
-  if((pRgn = RGNDATA_LockRgn(VisRgn)))
-  {
-    Ret = pRgn->rdh.iType;
-    *Rect = pRgn->rdh.rcBound;
-    RGNDATA_UnlockRgn(pRgn);
-  }
-  else
-    Ret = ERROR;
-
-  NtGdiDeleteObject(VisRgn);
-
-  IntReleaseWindowObject(Window);
-  return Ret;
+   INT Ret;
+   PWINDOW_OBJECT Window;
+   HRGN VisRgn;
+   ROSRGNDATA *pRgn;
+
+   if(!(Window = IntGetWindowObject(hWnd)))
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      return ERROR;
+   }
+   if(!Rect)
+   {
+      IntReleaseWindowObject(Window);
+      return ERROR;
+   }
+
+   /* Create a new window region using the window rectangle */
+   VisRgn = UnsafeIntCreateRectRgnIndirect(&Window->WindowRect);
+   NtGdiOffsetRgn(VisRgn, -Window->WindowRect.left, -Window->WindowRect.top);
+   /* if there's a region assigned to the window, combine them both */
+   if(Window->WindowRegion && !(Window->Style & WS_MINIMIZE))
+      NtGdiCombineRgn(VisRgn, VisRgn, Window->WindowRegion, RGN_AND);
+
+   if((pRgn = RGNDATA_LockRgn(VisRgn)))
+   {
+      Ret = pRgn->rdh.iType;
+      *Rect = pRgn->rdh.rcBound;
+      RGNDATA_UnlockRgn(pRgn);
+   }
+   else
+      Ret = ERROR;
+
+   NtGdiDeleteObject(VisRgn);
+
+   IntReleaseWindowObject(Window);
+   return Ret;
 }
 
 
@@ -4211,46 +4252,46 @@ IntGetWindowRgnBox(HWND hWnd, RECT *Rect)
  */
 INT STDCALL
 NtUserSetWindowRgn(
-  HWND hWnd,
-  HRGN hRgn,
-  BOOL bRedraw)
+   HWND hWnd,
+   HRGN hRgn,
+   BOOL bRedraw)
 {
-  PWINDOW_OBJECT Window;
-  DECLARE_RETURN(INT);
-  
-  DPRINT("Enter NtUserSetWindowRgn\n");
-  UserEnterExclusive();
-  
-  if (!(Window = IntGetWindowObject(hWnd)))
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    RETURN( 0);
-  }
-
-  /* FIXME - Verify if hRgn is a valid handle!!!!
-             Propably make this operation thread-safe, but maybe it's not necessary */
-
-  if(Window->WindowRegion)
-  {
-    /* Delete no longer needed region handle */
-    NtGdiDeleteObject(Window->WindowRegion);
-  }
-  Window->WindowRegion = hRgn;
-
-  /* FIXME - send WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED messages to the window */
-
-  if(bRedraw)
-  {
-    co_UserRedrawWindow(Window, NULL, NULL, RDW_INVALIDATE);
-  }
-
-  IntReleaseWindowObject(Window);
-  RETURN( (INT)hRgn);
-  
+   PWINDOW_OBJECT Window;
+   DECLARE_RETURN(INT);
+
+   DPRINT("Enter NtUserSetWindowRgn\n");
+   UserEnterExclusive();
+
+   if (!(Window = IntGetWindowObject(hWnd)))
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      RETURN( 0);
+   }
+
+   /* FIXME - Verify if hRgn is a valid handle!!!!
+              Propably make this operation thread-safe, but maybe it's not necessary */
+
+   if(Window->WindowRegion)
+   {
+      /* Delete no longer needed region handle */
+      NtGdiDeleteObject(Window->WindowRegion);
+   }
+   Window->WindowRegion = hRgn;
+
+   /* FIXME - send WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED messages to the window */
+
+   if(bRedraw)
+   {
+      co_UserRedrawWindow(Window, NULL, NULL, RDW_INVALIDATE);
+   }
+
+   IntReleaseWindowObject(Window);
+   RETURN( (INT)hRgn);
+
 CLEANUP:
-  DPRINT("Leave NtUserSystemParametersInfo, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserSystemParametersInfo, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -4260,28 +4301,28 @@ CLEANUP:
 BOOL STDCALL
 NtUserShowWindow(HWND hWnd, LONG nCmdShow)
 {
-  PWINDOW_OBJECT Window;
-  BOOL ret;
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserShowWindow\n");
-  UserEnterExclusive();
-  
-  if (!(Window = UserGetWindowObject(hWnd)))
-  {
-     RETURN(FALSE);
-  }
-  
-  UserRefObjectCo(Window);
-  ret = co_WinPosShowWindow(Window, nCmdShow);
-  UserDerefObjectCo(Window);
-  
-  RETURN(ret);
-   
+   PWINDOW_OBJECT Window;
+   BOOL ret;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserShowWindow\n");
+   UserEnterExclusive();
+
+   if (!(Window = UserGetWindowObject(hWnd)))
+   {
+      RETURN(FALSE);
+   }
+
+   UserRefObjectCo(Window);
+   ret = co_WinPosShowWindow(Window, nCmdShow);
+   UserDerefObjectCo(Window);
+
+   RETURN(ret);
+
 CLEANUP:
-  DPRINT("Leave NtUserShowWindow, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserShowWindow, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 
@@ -4290,11 +4331,11 @@ CLEANUP:
  */
 DWORD STDCALL
 NtUserShowWindowAsync(DWORD Unknown0,
-                     DWORD Unknown1)
+                      DWORD Unknown1)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
@@ -4303,18 +4344,18 @@ NtUserShowWindowAsync(DWORD Unknown0,
  */
 DWORD STDCALL
 NtUserUpdateLayeredWindow(DWORD Unknown0,
-                         DWORD Unknown1,
-                         DWORD Unknown2,
-                         DWORD Unknown3,
-                         DWORD Unknown4,
-                         DWORD Unknown5,
-                         DWORD Unknown6,
-                         DWORD Unknown7,
-                         DWORD Unknown8)
+                          DWORD Unknown1,
+                          DWORD Unknown2,
+                          DWORD Unknown3,
+                          DWORD Unknown4,
+                          DWORD Unknown5,
+                          DWORD Unknown6,
+                          DWORD Unknown7,
+                          DWORD Unknown8)
 {
-  UNIMPLEMENTED
+   UNIMPLEMENTED
 
-  return 0;
+   return 0;
 }
 
 
@@ -4324,7 +4365,7 @@ NtUserUpdateLayeredWindow(DWORD Unknown0,
 VOID STDCALL
 NtUserValidateRect(HWND hWnd, const RECT* Rect)
 {
-  return (VOID)NtUserRedrawWindow(hWnd, Rect, 0, RDW_VALIDATE | RDW_NOCHILDREN);
+   return (VOID)NtUserRedrawWindow(hWnd, Rect, 0, RDW_VALIDATE | RDW_NOCHILDREN);
 }
 
 
@@ -4353,22 +4394,22 @@ NtUserWindowFromPoint(LONG X, LONG Y)
 
       if(Window)
       {
-        Ret = Window->hSelf;
-        IntReleaseWindowObject(Window);
-        IntReleaseWindowObject(DesktopWindow);
-        RETURN( Ret);
+         Ret = Window->hSelf;
+         IntReleaseWindowObject(Window);
+         IntReleaseWindowObject(DesktopWindow);
+         RETURN( Ret);
       }
 
       IntReleaseWindowObject(DesktopWindow);
    }
 
    RETURN( NULL);
-   
+
 CLEANUP:
    DPRINT("Leave NtUserWindowFromPoint, ret=%i\n",_ret_);
    UserLeave();
    END_CLEANUP;
-   
+
 }
 
 
@@ -4385,67 +4426,67 @@ CLEANUP:
 BOOL STDCALL
 NtUserDefSetText(HWND hWnd, PUNICODE_STRING WindowText)
 {
-  PWINDOW_OBJECT Window, Parent, Owner;
-  UNICODE_STRING SafeText;
-  NTSTATUS Status;
-  DECLARE_RETURN(INT);
-   
-  DPRINT("Enter NtUserDefSetText\n");
-  UserEnterExclusive();
-
-  if(!(Window = IntGetWindowObject(hWnd)))
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    RETURN( FALSE);
-  }
-
-  if(WindowText)
-  {
-    Status = IntSafeCopyUnicodeString(&SafeText, WindowText);
-    if(!NT_SUCCESS(Status))
-    {
-      SetLastNtError(Status);
-      IntReleaseWindowObject(Window);
+   PWINDOW_OBJECT Window, Parent, Owner;
+   UNICODE_STRING SafeText;
+   NTSTATUS Status;
+   DECLARE_RETURN(INT);
+
+   DPRINT("Enter NtUserDefSetText\n");
+   UserEnterExclusive();
+
+   if(!(Window = IntGetWindowObject(hWnd)))
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
       RETURN( FALSE);
-    }
-  }
-  else
-  {
-    RtlInitUnicodeString(&SafeText, NULL);
-  }
+   }
+
+   if(WindowText)
+   {
+      Status = IntSafeCopyUnicodeString(&SafeText, WindowText);
+      if(!NT_SUCCESS(Status))
+      {
+         SetLastNtError(Status);
+         IntReleaseWindowObject(Window);
+         RETURN( FALSE);
+      }
+   }
+   else
+   {
+      RtlInitUnicodeString(&SafeText, NULL);
+   }
 
-  /* FIXME - do this thread-safe! otherwise one could crash here! */
-  RtlFreeUnicodeString(&Window->WindowName);
+   /* FIXME - do this thread-safe! otherwise one could crash here! */
+   RtlFreeUnicodeString(&Window->WindowName);
 
-  Window->WindowName = SafeText;
+   Window->WindowName = SafeText;
 
-  /* Send shell notifications */
+   /* Send shell notifications */
 
-  Owner = IntGetOwner(Window);
-  Parent = IntGetParent(Window);
+   Owner = IntGetOwner(Window);
+   Parent = IntGetParent(Window);
 
-  if ((!Owner) && (!Parent))
-  {
-    co_IntShellHookNotify(HSHELL_REDRAW, (LPARAM) hWnd);
-  }
+   if ((!Owner) && (!Parent))
+   {
+      co_IntShellHookNotify(HSHELL_REDRAW, (LPARAM) hWnd);
+   }
+
+   if (Owner)
+   {
+      IntReleaseWindowObject(Owner);
+   }
 
-  if (Owner)
-  {
-    IntReleaseWindowObject(Owner);
-  }
+   if (Parent)
+   {
+      IntReleaseWindowObject(Parent);
+   }
 
-  if (Parent)
-  {
-    IntReleaseWindowObject(Parent);
-  }
+   IntReleaseWindowObject(Window);
+   RETURN( TRUE);
 
-  IntReleaseWindowObject(Window);
-  RETURN( TRUE);
-  
 CLEANUP:
-  DPRINT("Leave NtUserDefSetText, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserDefSetText, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 /*
@@ -4458,156 +4499,158 @@ CLEANUP:
 INT STDCALL
 NtUserInternalGetWindowText(HWND hWnd, LPWSTR lpString, INT nMaxCount)
 {
-  PWINDOW_OBJECT Window;
-  NTSTATUS Status;
-  INT Result;
-  DECLARE_RETURN(INT);
-   
-  DPRINT("Enter NtUserInternalGetWindowText\n");
-  UserEnterShared();
-
-  if(lpString && (nMaxCount <= 1))
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    RETURN( 0);
-  }
-
-  if(!(Window = IntGetWindowObject(hWnd)))
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    RETURN( 0);
-  }
-
-  /* FIXME - do this thread-safe! otherwise one could crash here! */
-  Result = Window->WindowName.Length / sizeof(WCHAR);
-  if(lpString)
-  {
-    const WCHAR Terminator = L'\0';
-    INT Copy;
-    WCHAR *Buffer = (WCHAR*)lpString;
-
-    Copy = min(nMaxCount - 1, Result);
-    if(Copy > 0)
-    {
-      Status = MmCopyToCaller(Buffer, Window->WindowName.Buffer, Copy * sizeof(WCHAR));
+   PWINDOW_OBJECT Window;
+   NTSTATUS Status;
+   INT Result;
+   DECLARE_RETURN(INT);
+
+   DPRINT("Enter NtUserInternalGetWindowText\n");
+   UserEnterShared();
+
+   if(lpString && (nMaxCount <= 1))
+   {
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      RETURN( 0);
+   }
+
+   if(!(Window = IntGetWindowObject(hWnd)))
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      RETURN( 0);
+   }
+
+   /* FIXME - do this thread-safe! otherwise one could crash here! */
+   Result = Window->WindowName.Length / sizeof(WCHAR);
+   if(lpString)
+   {
+      const WCHAR Terminator = L'\0';
+      INT Copy;
+      WCHAR *Buffer = (WCHAR*)lpString;
+
+      Copy = min(nMaxCount - 1, Result);
+      if(Copy > 0)
+      {
+         Status = MmCopyToCaller(Buffer, Window->WindowName.Buffer, Copy * sizeof(WCHAR));
+         if(!NT_SUCCESS(Status))
+         {
+            SetLastNtError(Status);
+            IntReleaseWindowObject(Window);
+            RETURN( 0);
+         }
+         Buffer += Copy;
+      }
+
+      Status = MmCopyToCaller(Buffer, &Terminator, sizeof(WCHAR));
       if(!NT_SUCCESS(Status))
       {
-        SetLastNtError(Status);
-        IntReleaseWindowObject(Window);
-        RETURN( 0);
+         SetLastNtError(Status);
+         IntReleaseWindowObject(Window);
+         RETURN( 0);
       }
-      Buffer += Copy;
-    }
 
-    Status = MmCopyToCaller(Buffer, &Terminator, sizeof(WCHAR));
-    if(!NT_SUCCESS(Status))
-    {
-      SetLastNtError(Status);
-      IntReleaseWindowObject(Window);
-      RETURN( 0);
-    }
+      Result = Copy;
+   }
 
-    Result = Copy;
-  }
+   IntReleaseWindowObject(Window);
+   RETURN( Result);
 
-  IntReleaseWindowObject(Window);
-  RETURN( Result);
-  
 CLEANUP:
-  DPRINT("Leave NtUserInternalGetWindowText, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserInternalGetWindowText, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 DWORD STDCALL
 NtUserDereferenceWndProcHandle(WNDPROC wpHandle, WndProcHandle *Data)
 {
    DECLARE_RETURN(DWORD);
-   
+
    DPRINT("Enter NtUserDereferenceWndProcHandle\n");
    UserEnterShared();
-   
-       WndProcHandle Entry;
-       if (((DWORD)wpHandle & 0xFFFF0000) == 0xFFFF0000)
-       {
-               Entry = WndProcHandlesArray[(DWORD)wpHandle & 0x0000FFFF];
-               Data->WindowProc = Entry.WindowProc;
-               Data->IsUnicode = Entry.IsUnicode;
-               Data->ProcessID = Entry.ProcessID;
+
+   WndProcHandle Entry;
+   if (((DWORD)wpHandle & 0xFFFF0000) == 0xFFFF0000)
+   {
+      Entry = WndProcHandlesArray[(DWORD)wpHandle & 0x0000FFFF];
+      Data->WindowProc = Entry.WindowProc;
+      Data->IsUnicode = Entry.IsUnicode;
+      Data->ProcessID = Entry.ProcessID;
       RETURN(  TRUE);
-       } else {
+   }
+   else
+   {
       RETURN(  FALSE);
-       }
-       RETURN( FALSE);
-   
+   }
+   RETURN( FALSE);
+
 CLEANUP:
-  DPRINT("Leave NtUserDereferenceWndProcHandle, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserDereferenceWndProcHandle, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 DWORD
 IntAddWndProcHandle(WNDPROC WindowProc, BOOL IsUnicode)
 {
-       WORD i;
-       WORD FreeSpot = 0;
-       BOOL found;
-       WndProcHandle *OldArray;
-       WORD OldArraySize;
-       found = FALSE;
-       for (i = 0;i < WndProcHandlesArraySize;i++)
-       {
-               if (WndProcHandlesArray[i].WindowProc == NULL)
-               {
-                       FreeSpot = i;
-                       found = TRUE;
-               }
-       }
-       if (!found)
-       {
-               OldArray = WndProcHandlesArray;
-               OldArraySize = WndProcHandlesArraySize;
-        WndProcHandlesArray = ExAllocatePoolWithTag(PagedPool,(OldArraySize + WPH_SIZE) * sizeof(WndProcHandle), TAG_WINPROCLST);
-               WndProcHandlesArraySize = OldArraySize + WPH_SIZE;
-               RtlCopyMemory(WndProcHandlesArray,OldArray,OldArraySize * sizeof(WndProcHandle));
-               ExFreePool(OldArray);
-               FreeSpot = OldArraySize + 1;
-       }
-       WndProcHandlesArray[FreeSpot].WindowProc = WindowProc;
-       WndProcHandlesArray[FreeSpot].IsUnicode = IsUnicode;
-       WndProcHandlesArray[FreeSpot].ProcessID = PsGetCurrentProcessId();
-       return FreeSpot + 0xFFFF0000;
+   WORD i;
+   WORD FreeSpot = 0;
+   BOOL found;
+   WndProcHandle *OldArray;
+   WORD OldArraySize;
+   found = FALSE;
+   for (i = 0;i < WndProcHandlesArraySize;i++)
+   {
+      if (WndProcHandlesArray[i].WindowProc == NULL)
+      {
+         FreeSpot = i;
+         found = TRUE;
+      }
+   }
+   if (!found)
+   {
+      OldArray = WndProcHandlesArray;
+      OldArraySize = WndProcHandlesArraySize;
+      WndProcHandlesArray = ExAllocatePoolWithTag(PagedPool,(OldArraySize + WPH_SIZE) * sizeof(WndProcHandle), TAG_WINPROCLST);
+      WndProcHandlesArraySize = OldArraySize + WPH_SIZE;
+      RtlCopyMemory(WndProcHandlesArray,OldArray,OldArraySize * sizeof(WndProcHandle));
+      ExFreePool(OldArray);
+      FreeSpot = OldArraySize + 1;
+   }
+   WndProcHandlesArray[FreeSpot].WindowProc = WindowProc;
+   WndProcHandlesArray[FreeSpot].IsUnicode = IsUnicode;
+   WndProcHandlesArray[FreeSpot].ProcessID = PsGetCurrentProcessId();
+   return FreeSpot + 0xFFFF0000;
 }
 
 DWORD
 IntRemoveWndProcHandle(WNDPROC Handle)
 {
-       WORD position;
-       position = (DWORD)Handle & 0x0000FFFF;
-       if (position > WndProcHandlesArraySize)
-       {
-               return FALSE;
-       }
-       WndProcHandlesArray[position].WindowProc = NULL;
-       WndProcHandlesArray[position].IsUnicode = FALSE;
-       WndProcHandlesArray[position].ProcessID = NULL;
-       return TRUE;
+   WORD position;
+   position = (DWORD)Handle & 0x0000FFFF;
+   if (position > WndProcHandlesArraySize)
+   {
+      return FALSE;
+   }
+   WndProcHandlesArray[position].WindowProc = NULL;
+   WndProcHandlesArray[position].IsUnicode = FALSE;
+   WndProcHandlesArray[position].ProcessID = NULL;
+   return TRUE;
 }
 
 DWORD
 IntRemoveProcessWndProcHandles(HANDLE ProcessID)
 {
-       WORD i;
-       for (i = 0;i < WndProcHandlesArraySize;i++)
-       {
-               if (WndProcHandlesArray[i].ProcessID == ProcessID)
-               {
-                       WndProcHandlesArray[i].WindowProc = NULL;
-                       WndProcHandlesArray[i].IsUnicode = FALSE;
-                       WndProcHandlesArray[i].ProcessID = NULL;
-               }
-       }
-       return TRUE;
+   WORD i;
+   for (i = 0;i < WndProcHandlesArraySize;i++)
+   {
+      if (WndProcHandlesArray[i].ProcessID == ProcessID)
+      {
+         WndProcHandlesArray[i].WindowProc = NULL;
+         WndProcHandlesArray[i].IsUnicode = FALSE;
+         WndProcHandlesArray[i].ProcessID = NULL;
+      }
+   }
+   return TRUE;
 }
 
 #define WIN_NEEDS_SHOW_OWNEDPOPUP (0x00000040)
@@ -4616,58 +4659,62 @@ BOOL
 FASTCALL
 IntShowOwnedPopups( HWND owner, BOOL fShow )
 {
-  int count = 0;
-  PWINDOW_OBJECT Window, pWnd;
-  HWND *win_array;
-
-  if(!(Window = IntGetWindowObject(owner)))
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return FALSE;
-  }
-
-  win_array = IntWinListChildren( Window);
-  IntReleaseWindowObject(Window);
-
-  if (!win_array) return TRUE;
-
-  while (win_array[count]) count++;
-  while (--count >= 0)
-    {
-        if (UserGetWindow( win_array[count], GW_OWNER ) != owner) continue;
-        if (!(pWnd = IntGetWindowObject( win_array[count] ))) continue;
-//        if (pWnd == WND_OTHER_PROCESS) continue;
-
-        if (fShow)
-        {
-            if (pWnd->Flags & WIN_NEEDS_SHOW_OWNEDPOPUP)
-             {
-                IntReleaseWindowObject( pWnd );
-                /* In Windows, ShowOwnedPopups(TRUE) generates
-                 * WM_SHOWWINDOW messages with SW_PARENTOPENING,
-                 * regardless of the state of the owner
-                 */
-                co_IntSendMessage(win_array[count], WM_SHOWWINDOW, SW_SHOWNORMAL, SW_PARENTOPENING);
-                continue;
-            }
-        }
-        else
-        {
-            if (pWnd->Style & WS_VISIBLE)
-            {
-                IntReleaseWindowObject( pWnd );
-                /* In Windows, ShowOwnedPopups(FALSE) generates
-                 * WM_SHOWWINDOW messages with SW_PARENTCLOSING,
-                 * regardless of the state of the owner
-                 */
-                co_IntSendMessage(win_array[count], WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING);
-                continue;
-            }
-        }
-        IntReleaseWindowObject( pWnd );
-    }
-    ExFreePool( win_array );
-    return TRUE;
+   int count = 0;
+   PWINDOW_OBJECT Window, pWnd;
+   HWND *win_array;
+
+   if(!(Window = IntGetWindowObject(owner)))
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      return FALSE;
+   }
+
+   win_array = IntWinListChildren( Window);
+   IntReleaseWindowObject(Window);
+
+   if (!win_array)
+      return TRUE;
+
+   while (win_array[count])
+      count++;
+   while (--count >= 0)
+   {
+      if (UserGetWindow( win_array[count], GW_OWNER ) != owner)
+         continue;
+      if (!(pWnd = IntGetWindowObject( win_array[count] )))
+         continue;
+      //        if (pWnd == WND_OTHER_PROCESS) continue;
+
+      if (fShow)
+      {
+         if (pWnd->Flags & WIN_NEEDS_SHOW_OWNEDPOPUP)
+         {
+            IntReleaseWindowObject( pWnd );
+            /* In Windows, ShowOwnedPopups(TRUE) generates
+             * WM_SHOWWINDOW messages with SW_PARENTOPENING,
+             * regardless of the state of the owner
+             */
+            co_IntSendMessage(win_array[count], WM_SHOWWINDOW, SW_SHOWNORMAL, SW_PARENTOPENING);
+            continue;
+         }
+      }
+      else
+      {
+         if (pWnd->Style & WS_VISIBLE)
+         {
+            IntReleaseWindowObject( pWnd );
+            /* In Windows, ShowOwnedPopups(FALSE) generates
+             * WM_SHOWWINDOW messages with SW_PARENTCLOSING,
+             * regardless of the state of the owner
+             */
+            co_IntSendMessage(win_array[count], WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING);
+            continue;
+         }
+      }
+      IntReleaseWindowObject( pWnd );
+   }
+   ExFreePool( win_array );
+   return TRUE;
 }
 
 
index d6d864a..cd64644 100644 (file)
 BOOL FASTCALL
 IntGetClientOrigin(PWINDOW_OBJECT Window OPTIONAL, LPPOINT Point)
 {
-  Window = Window ? Window : UserGetWindowObject(IntGetDesktopWindow());
-  if (Window == NULL)
-    {
+   Window = Window ? Window : UserGetWindowObject(IntGetDesktopWindow());
+   if (Window == NULL)
+   {
       Point->x = Point->y = 0;
       return FALSE;
-    }
-  Point->x = Window->ClientRect.left;
-  Point->y = Window->ClientRect.top;
+   }
+   Point->x = Window->ClientRect.left;
+   Point->y = Window->ClientRect.top;
 
-  return TRUE;
+   return TRUE;
 }
 
 
@@ -70,32 +70,32 @@ IntGetClientOrigin(PWINDOW_OBJECT Window OPTIONAL, LPPOINT Point)
 BOOL FASTCALL
 UserGetClientOrigin(PWINDOW_OBJECT Window, LPPOINT Point)
 {
-  BOOL Ret;
-  POINT pt;
-  NTSTATUS Status;
-
-  if(!Point)
-  {
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    return FALSE;
-  }
-
-  Ret = IntGetClientOrigin(Window, &pt);
-
-  if(!Ret)
-  {
-    SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
-    return FALSE;
-  }
-
-  Status = MmCopyToCaller(Point, &pt, sizeof(POINT));
-  if(!NT_SUCCESS(Status))
-  {
-    SetLastNtError(Status);
-    return FALSE;
-  }
-
-  return Ret;
+   BOOL Ret;
+   POINT pt;
+   NTSTATUS Status;
+
+   if(!Point)
+   {
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      return FALSE;
+   }
+
+   Ret = IntGetClientOrigin(Window, &pt);
+
+   if(!Ret)
+   {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      return FALSE;
+   }
+
+   Status = MmCopyToCaller(Point, &pt, sizeof(POINT));
+   if(!NT_SUCCESS(Status))
+   {
+      SetLastNtError(Status);
+      return FALSE;
+   }
+
+   return Ret;
 }
 
 
@@ -103,16 +103,17 @@ UserGetClientOrigin(PWINDOW_OBJECT Window, LPPOINT Point)
 BOOL STDCALL
 NtUserGetClientOrigin(HWND hWnd, LPPOINT Point)
 {
-   DECLARE_RETURN(BOOL); 
+   DECLARE_RETURN(BOOL);
    PWINDOW_OBJECT Window;
 
    DPRINT("Enter NtUserGetClientOrigin\n");
    UserEnterShared();
-   
-   if (!(Window = UserGetWindowObject(hWnd))) RETURN(FALSE);
-   
+
+   if (!(Window = UserGetWindowObject(hWnd)))
+      RETURN(FALSE);
+
    RETURN(UserGetClientOrigin(Window, Point));
-   
+
 CLEANUP:
    DPRINT("Leave NtUserGetClientOrigin, ret=%i\n",_ret_);
    UserLeave();
@@ -127,72 +128,75 @@ CLEANUP:
 VOID FASTCALL
 co_WinPosActivateOtherWindow(PWINDOW_OBJECT Window OPTIONAL)
 {
-  PWINDOW_OBJECT Wnd, Old;
-  HWND Fg;
-   
-  if (Window) ASSERT_REFS_CO(Window);
-
-  if (!Window || IntIsDesktopWindow(Window))
-  {
-    IntSetFocusMessageQueue(NULL);
-    return;
-  }
-
-  /* If this is popup window, try to activate the owner first. */
-  if ((Window->Style & WS_POPUP) && (Wnd = IntGetOwner(Window)))
-  {
-    for(;;)
-    {
-      Old = Wnd;
-      Wnd = Wnd->Parent;
-      if(IntIsDesktopWindow(Wnd))
+   PWINDOW_OBJECT Wnd, Old;
+   HWND Fg;
+
+   if (Window)
+      ASSERT_REFS_CO(Window);
+
+   if (!Window || IntIsDesktopWindow(Window))
+   {
+      IntSetFocusMessageQueue(NULL);
+      return;
+   }
+
+   /* If this is popup window, try to activate the owner first. */
+   if ((Window->Style & WS_POPUP) && (Wnd = IntGetOwner(Window)))
+   {
+      for(;;)
       {
-        Wnd = Old;
-        break;
+         Old = Wnd;
+         Wnd = Wnd->Parent;
+         if(IntIsDesktopWindow(Wnd))
+         {
+            Wnd = Old;
+            break;
+         }
       }
-    }
-
-    if ((Wnd->Style & (WS_DISABLED | WS_VISIBLE)) == WS_VISIBLE &&
-        (Wnd->Style & (WS_POPUP | WS_CHILD)) != WS_CHILD)
-      goto done;
-  }
-
-  /* Pick a next top-level window. */
-  /* FIXME: Search for non-tooltip windows first. */
-  Wnd = Window;
-  while (Wnd != NULL)
-  {
-    if (Wnd->NextSibling == NULL)
-    {
-      Wnd = NULL;
-      break;
-    }
-    
-    Wnd = Wnd->NextSibling;
-    
-    if ((Wnd->Style & (WS_DISABLED | WS_VISIBLE)) == WS_VISIBLE &&
-        (Wnd->Style & (WS_POPUP | WS_CHILD)) != WS_CHILD)
-      break;
-  }
+
+      if ((Wnd->Style & (WS_DISABLED | WS_VISIBLE)) == WS_VISIBLE &&
+            (Wnd->Style & (WS_POPUP | WS_CHILD)) != WS_CHILD)
+         goto done;
+   }
+
+   /* Pick a next top-level window. */
+   /* FIXME: Search for non-tooltip windows first. */
+   Wnd = Window;
+   while (Wnd != NULL)
+   {
+      if (Wnd->NextSibling == NULL)
+      {
+         Wnd = NULL;
+         break;
+      }
+
+      Wnd = Wnd->NextSibling;
+
+      if ((Wnd->Style & (WS_DISABLED | WS_VISIBLE)) == WS_VISIBLE &&
+            (Wnd->Style & (WS_POPUP | WS_CHILD)) != WS_CHILD)
+         break;
+   }
 
 done:
-  
-  if (Wnd) UserRefObjectCo(Wnd);
-  
-  Fg = UserGetForegroundWindow();
-  if (Wnd && (!Fg || Window->hSelf == Fg))
-  {
-    if (co_IntSetForegroundWindow(Wnd))
-    {
-      UserDerefObjectCo(Wnd); 
-      return;
-    }
-  }
 
-  if (!co_IntSetActiveWindow(Wnd))
-    co_IntSetActiveWindow(0);
-   
-  if (Wnd) UserDerefObjectCo(Wnd); 
+   if (Wnd)
+      UserRefObjectCo(Wnd);
+
+   Fg = UserGetForegroundWindow();
+   if (Wnd && (!Fg || Window->hSelf == Fg))
+   {
+      if (co_IntSetForegroundWindow(Wnd))
+      {
+         UserDerefObjectCo(Wnd);
+         return;
+      }
+   }
+
+   if (!co_IntSetActiveWindow(Wnd))
+      co_IntSetActiveWindow(0);
+
+   if (Wnd)
+      UserDerefObjectCo(Wnd);
 }
 
 
@@ -200,86 +204,88 @@ UINT
 FASTCALL
 co_WinPosArrangeIconicWindows(PWINDOW_OBJECT parent)
 {
-    RECT rectParent;
-    HWND hwndChild;
-    INT i, x, y, xspacing, yspacing;
-    HWND *List = IntWinListChildren(parent);
-    
-    ASSERT_REFS_CO(parent);
-    
-    IntGetClientRect( parent, &rectParent );
-    x = rectParent.left;
-    y = rectParent.bottom;
-    
-    xspacing = UserGetSystemMetrics(SM_CXMINSPACING);
-    yspacing = UserGetSystemMetrics(SM_CYMINSPACING);
-
-    DPRINT("X:%d Y:%d XS:%d YS:%d\n",x,y,xspacing,yspacing);
-
-    for( i = 0; List[i]; i++)
-    {
-       PWINDOW_OBJECT WndChild;
-       
-       hwndChild = List[i];
-       
-       if (!(WndChild = UserGetWindowObject(List[i]))) continue;
-       
+   RECT rectParent;
+   HWND hwndChild;
+   INT i, x, y, xspacing, yspacing;
+   HWND *List = IntWinListChildren(parent);
+
+   ASSERT_REFS_CO(parent);
+
+   IntGetClientRect( parent, &rectParent );
+   x = rectParent.left;
+   y = rectParent.bottom;
+
+   xspacing = UserGetSystemMetrics(SM_CXMINSPACING);
+   yspacing = UserGetSystemMetrics(SM_CYMINSPACING);
+
+   DPRINT("X:%d Y:%d XS:%d YS:%d\n",x,y,xspacing,yspacing);
+
+   for( i = 0; List[i]; i++)
+   {
+      PWINDOW_OBJECT WndChild;
+
+      hwndChild = List[i];
+
+      if (!(WndChild = UserGetWindowObject(List[i])))
+         continue;
+
       if((UserGetWindowLong( hwndChild, GWL_STYLE, FALSE) & WS_MINIMIZE) != 0 )
       {
          UserRefObjectCo(WndChild);
-         
+
          co_WinPosSetWindowPos(WndChild, 0, x + UserGetSystemMetrics(SM_CXBORDER),
-                      y - yspacing - UserGetSystemMetrics(SM_CYBORDER)
-                     , 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
-                     
-         UserDerefObjectCo(WndChild);                     
-         
-         if (x <= rectParent.right - xspacing) x += xspacing;
+                               y - yspacing - UserGetSystemMetrics(SM_CYBORDER)
+                               , 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
+
+         UserDerefObjectCo(WndChild);
+
+         if (x <= rectParent.right - xspacing)
+            x += xspacing;
          else
          {
             x = rectParent.left;
             y -= yspacing;
          }
       }
-    }
-    ExFreePool(List);
-    return yspacing;
+   }
+   ExFreePool(List);
+   return yspacing;
 }
 
 
 VOID STATIC FASTCALL
 WinPosFindIconPos(PWINDOW_OBJECT Window, POINT *Pos)
 {
-  /* FIXME */
+   /* FIXME */
 }
 
 PINTERNALPOS FASTCALL
 WinPosInitInternalPos(PWINDOW_OBJECT Window, POINT *pt, PRECT RestoreRect)
 {
-  PWINDOW_OBJECT Parent;
-  UINT XInc, YInc;
+   PWINDOW_OBJECT Parent;
+   UINT XInc, YInc;
 
-  if (Window->InternalPos == NULL)
-    {
+   if (Window->InternalPos == NULL)
+   {
       RECT WorkArea;
       PDESKTOP_OBJECT Desktop = PsGetWin32Thread()->Desktop; /* Or rather get it from the window? */
 
       Parent = Window->Parent;
       if(Parent)
       {
-        if(IntIsDesktopWindow(Parent))
-          IntGetDesktopWorkArea(Desktop, &WorkArea);
-        else
-          WorkArea = Parent->ClientRect;
+         if(IntIsDesktopWindow(Parent))
+            IntGetDesktopWorkArea(Desktop, &WorkArea);
+         else
+            WorkArea = Parent->ClientRect;
       }
       else
-        IntGetDesktopWorkArea(Desktop, &WorkArea);
+         IntGetDesktopWorkArea(Desktop, &WorkArea);
 
       Window->InternalPos = ExAllocatePoolWithTag(PagedPool, sizeof(INTERNALPOS), TAG_WININTLIST);
       if(!Window->InternalPos)
       {
-        DPRINT1("Failed to allocate INTERNALPOS structure for window 0x%x\n", Window->hSelf);
-        return NULL;
+         DPRINT1("Failed to allocate INTERNALPOS structure for window 0x%x\n", Window->hSelf);
+         return NULL;
       }
       Window->InternalPos->NormalRect = Window->WindowRect;
       IntGetWindowBorderMeasures(Window, &XInc, &YInc);
@@ -287,231 +293,235 @@ WinPosInitInternalPos(PWINDOW_OBJECT Window, POINT *pt, PRECT RestoreRect)
       Window->InternalPos->MaxPos.y = WorkArea.top - YInc;
       Window->InternalPos->IconPos.x = WorkArea.left;
       Window->InternalPos->IconPos.y = WorkArea.bottom - UserGetSystemMetrics(SM_CYMINIMIZED);
-    }
-  if (Window->Style & WS_MINIMIZE)
-    {
+   }
+   if (Window->Style & WS_MINIMIZE)
+   {
       Window->InternalPos->IconPos = *pt;
-    }
-  else if (Window->Style & WS_MAXIMIZE)
-    {
+   }
+   else if (Window->Style & WS_MAXIMIZE)
+   {
       Window->InternalPos->MaxPos = *pt;
-    }
-  else if (RestoreRect != NULL)
-    {
+   }
+   else if (RestoreRect != NULL)
+   {
       Window->InternalPos->NormalRect = *RestoreRect;
-    }
-  return(Window->InternalPos);
+   }
+   return(Window->InternalPos);
 }
 
 UINT FASTCALL
 co_WinPosMinMaximize(PWINDOW_OBJECT Window, UINT ShowFlag, RECT* NewPos)
 {
-  POINT Size;
-  PINTERNALPOS InternalPos;
-  UINT SwpFlags = 0;
+   POINT Size;
+   PINTERNALPOS InternalPos;
+   UINT SwpFlags = 0;
 
-  ASSERT_REFS_CO(Window);
+   ASSERT_REFS_CO(Window);
 
-  Size.x = Window->WindowRect.left;
-  Size.y = Window->WindowRect.top;
-  InternalPos = WinPosInitInternalPos(Window, &Size, &Window->WindowRect);
+   Size.x = Window->WindowRect.left;
+   Size.y = Window->WindowRect.top;
+   InternalPos = WinPosInitInternalPos(Window, &Size, &Window->WindowRect);
 
-  if (InternalPos)
-    {
+   if (InternalPos)
+   {
       if (Window->Style & WS_MINIMIZE)
-       {
-     if (!co_IntSendMessage(Window->hSelf, WM_QUERYOPEN, 0, 0))
-           {
-             return(SWP_NOSIZE | SWP_NOMOVE);
-           }
-         SwpFlags |= SWP_NOCOPYBITS;
-       }
+      {
+         if (!co_IntSendMessage(Window->hSelf, WM_QUERYOPEN, 0, 0))
+         {
+            return(SWP_NOSIZE | SWP_NOMOVE);
+         }
+         SwpFlags |= SWP_NOCOPYBITS;
+      }
       switch (ShowFlag)
-       {
-       case SW_MINIMIZE:
-         {
-           if (Window->Style & WS_MAXIMIZE)
-             {
-               Window->Flags |= WINDOWOBJECT_RESTOREMAX;
-               Window->Style &= ~WS_MAXIMIZE;
-             }
-           else
-             {
-               Window->Flags &= ~WINDOWOBJECT_RESTOREMAX;
-             }
-       co_UserRedrawWindow(Window, NULL, 0, RDW_VALIDATE | RDW_NOERASE |
-              RDW_NOINTERNALPAINT);
-           Window->Style |= WS_MINIMIZE;
-           WinPosFindIconPos(Window, &InternalPos->IconPos);
-           IntGdiSetRect(NewPos, InternalPos->IconPos.x, InternalPos->IconPos.y,
-                         UserGetSystemMetrics(SM_CXMINIMIZED),
-                         UserGetSystemMetrics(SM_CYMINIMIZED));
-           SwpFlags |= SWP_NOCOPYBITS;
-           break;
-         }
-
-       case SW_MAXIMIZE:
-         {
-       co_WinPosGetMinMaxInfo(Window, &Size, &InternalPos->MaxPos,
-                               NULL, NULL);
-           DPRINT("Maximize: %d,%d %dx%d\n",
-              InternalPos->MaxPos.x, InternalPos->MaxPos.y, Size.x, Size.y);
-           if (Window->Style & WS_MINIMIZE)
-             {
-               Window->Style &= ~WS_MINIMIZE;
-             }
-           Window->Style |= WS_MAXIMIZE;
-           IntGdiSetRect(NewPos, InternalPos->MaxPos.x, InternalPos->MaxPos.y,
-                         Size.x, Size.y);
-           break;
-         }
-
-       case SW_RESTORE:
-         {
-           if (Window->Style & WS_MINIMIZE)
-             {
-               Window->Style &= ~WS_MINIMIZE;
-               if (Window->Flags & WINDOWOBJECT_RESTOREMAX)
-                 {
-          co_WinPosGetMinMaxInfo(Window, &Size,
-                                       &InternalPos->MaxPos, NULL, NULL);
-                   Window->Style |= WS_MAXIMIZE;
-                   IntGdiSetRect(NewPos, InternalPos->MaxPos.x,
-                                 InternalPos->MaxPos.y, Size.x, Size.y);
-                   break;
-                 }
-               else
-                 {
-                   *NewPos = InternalPos->NormalRect;
-                   NewPos->right -= NewPos->left;
-                   NewPos->bottom -= NewPos->top;
-                   break;
-                 }
-             }
-           else
-             {
-               if (!(Window->Style & WS_MAXIMIZE))
-                 {
-                   return 0;
-                 }
-               Window->Style &= ~WS_MAXIMIZE;
-               *NewPos = InternalPos->NormalRect;
-               NewPos->right -= NewPos->left;
-               NewPos->bottom -= NewPos->top;
-               break;
-             }
-         }
-       }
-    }
-  else
-    {
+      {
+         case SW_MINIMIZE:
+            {
+               if (Window->Style & WS_MAXIMIZE)
+               {
+                  Window->Flags |= WINDOWOBJECT_RESTOREMAX;
+                  Window->Style &= ~WS_MAXIMIZE;
+               }
+               else
+               {
+                  Window->Flags &= ~WINDOWOBJECT_RESTOREMAX;
+               }
+               co_UserRedrawWindow(Window, NULL, 0, RDW_VALIDATE | RDW_NOERASE |
+                                   RDW_NOINTERNALPAINT);
+               Window->Style |= WS_MINIMIZE;
+               WinPosFindIconPos(Window, &InternalPos->IconPos);
+               IntGdiSetRect(NewPos, InternalPos->IconPos.x, InternalPos->IconPos.y,
+                             UserGetSystemMetrics(SM_CXMINIMIZED),
+                             UserGetSystemMetrics(SM_CYMINIMIZED));
+               SwpFlags |= SWP_NOCOPYBITS;
+               break;
+            }
+
+         case SW_MAXIMIZE:
+            {
+               co_WinPosGetMinMaxInfo(Window, &Size, &InternalPos->MaxPos,
+                                      NULL, NULL);
+               DPRINT("Maximize: %d,%d %dx%d\n",
+                      InternalPos->MaxPos.x, InternalPos->MaxPos.y, Size.x, Size.y);
+               if (Window->Style & WS_MINIMIZE)
+               {
+                  Window->Style &= ~WS_MINIMIZE;
+               }
+               Window->Style |= WS_MAXIMIZE;
+               IntGdiSetRect(NewPos, InternalPos->MaxPos.x, InternalPos->MaxPos.y,
+                             Size.x, Size.y);
+               break;
+            }
+
+         case SW_RESTORE:
+            {
+               if (Window->Style & WS_MINIMIZE)
+               {
+                  Window->Style &= ~WS_MINIMIZE;
+                  if (Window->Flags & WINDOWOBJECT_RESTOREMAX)
+                  {
+                     co_WinPosGetMinMaxInfo(Window, &Size,
+                                            &InternalPos->MaxPos, NULL, NULL);
+                     Window->Style |= WS_MAXIMIZE;
+                     IntGdiSetRect(NewPos, InternalPos->MaxPos.x,
+                                   InternalPos->MaxPos.y, Size.x, Size.y);
+                     break;
+                  }
+                  else
+                  {
+                     *NewPos = InternalPos->NormalRect;
+                     NewPos->right -= NewPos->left;
+                     NewPos->bottom -= NewPos->top;
+                     break;
+                  }
+               }
+               else
+               {
+                  if (!(Window->Style & WS_MAXIMIZE))
+                  {
+                     return 0;
+                  }
+                  Window->Style &= ~WS_MAXIMIZE;
+                  *NewPos = InternalPos->NormalRect;
+                  NewPos->right -= NewPos->left;
+                  NewPos->bottom -= NewPos->top;
+                  break;
+               }
+            }
+      }
+   }
+   else
+   {
       SwpFlags |= SWP_NOSIZE | SWP_NOMOVE;
-    }
-  return(SwpFlags);
+   }
+   return(SwpFlags);
 }
 
 VOID FASTCALL
 WinPosFillMinMaxInfoStruct(PWINDOW_OBJECT Window, MINMAXINFO *Info)
 {
-  UINT XInc, YInc;
-  RECT WorkArea;
-  PDESKTOP_OBJECT Desktop = PsGetWin32Thread()->Desktop; /* Or rather get it from the window? */
-
-  IntGetDesktopWorkArea(Desktop, &WorkArea);
-
-  /* Get default values. */
-  Info->ptMaxSize.x = WorkArea.right - WorkArea.left;
-  Info->ptMaxSize.y = WorkArea.bottom - WorkArea.top;
-  Info->ptMinTrackSize.x = UserGetSystemMetrics(SM_CXMINTRACK);
-  Info->ptMinTrackSize.y = UserGetSystemMetrics(SM_CYMINTRACK);
-  Info->ptMaxTrackSize.x = Info->ptMaxSize.x;
-  Info->ptMaxTrackSize.y = Info->ptMaxSize.y;
-
-  IntGetWindowBorderMeasures(Window, &XInc, &YInc);
-  Info->ptMaxSize.x += 2 * XInc;
-  Info->ptMaxSize.y += 2 * YInc;
-
-  if (Window->InternalPos != NULL)
-    {
+   UINT XInc, YInc;
+   RECT WorkArea;
+   PDESKTOP_OBJECT Desktop = PsGetWin32Thread()->Desktop; /* Or rather get it from the window? */
+
+   IntGetDesktopWorkArea(Desktop, &WorkArea);
+
+   /* Get default values. */
+   Info->ptMaxSize.x = WorkArea.right - WorkArea.left;
+   Info->ptMaxSize.y = WorkArea.bottom - WorkArea.top;
+   Info->ptMinTrackSize.x = UserGetSystemMetrics(SM_CXMINTRACK);
+   Info->ptMinTrackSize.y = UserGetSystemMetrics(SM_CYMINTRACK);
+   Info->ptMaxTrackSize.x = Info->ptMaxSize.x;
+   Info->ptMaxTrackSize.y = Info->ptMaxSize.y;
+
+   IntGetWindowBorderMeasures(Window, &XInc, &YInc);
+   Info->ptMaxSize.x += 2 * XInc;
+   Info->ptMaxSize.y += 2 * YInc;
+
+   if (Window->InternalPos != NULL)
+   {
       Info->ptMaxPosition = Window->InternalPos->MaxPos;
-    }
-  else
-    {
+   }
+   else
+   {
       Info->ptMaxPosition.x -= WorkArea.left + XInc;
       Info->ptMaxPosition.y -= WorkArea.top + YInc;
-    }
+   }
 }
 
 UINT FASTCALL
 co_WinPosGetMinMaxInfo(PWINDOW_OBJECT Window, POINT* MaxSize, POINT* MaxPos,
-                   POINT* MinTrack, POINT* MaxTrack)
+                       POINT* MinTrack, POINT* MaxTrack)
 {
-  MINMAXINFO MinMax;
+   MINMAXINFO MinMax;
 
-  WinPosFillMinMaxInfoStruct(Window, &MinMax);
+   WinPosFillMinMaxInfoStruct(Window, &MinMax);
 
-  co_IntSendMessage(Window->hSelf, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax);
+   co_IntSendMessage(Window->hSelf, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax);
 
-  MinMax.ptMaxTrackSize.x = max(MinMax.ptMaxTrackSize.x,
-                               MinMax.ptMinTrackSize.x);
-  MinMax.ptMaxTrackSize.y = max(MinMax.ptMaxTrackSize.y,
-                               MinMax.ptMinTrackSize.y);
+   MinMax.ptMaxTrackSize.x = max(MinMax.ptMaxTrackSize.x,
+                                 MinMax.ptMinTrackSize.x);
+   MinMax.ptMaxTrackSize.y = max(MinMax.ptMaxTrackSize.y,
+                                 MinMax.ptMinTrackSize.y);
 
-  if (MaxSize) *MaxSize = MinMax.ptMaxSize;
-  if (MaxPos) *MaxPos = MinMax.ptMaxPosition;
-  if (MinTrack) *MinTrack = MinMax.ptMinTrackSize;
-  if (MaxTrack) *MaxTrack = MinMax.ptMaxTrackSize;
+   if (MaxSize)
+      *MaxSize = MinMax.ptMaxSize;
+   if (MaxPos)
+      *MaxPos = MinMax.ptMaxPosition;
+   if (MinTrack)
+      *MinTrack = MinMax.ptMinTrackSize;
+   if (MaxTrack)
+      *MaxTrack = MinMax.ptMaxTrackSize;
 
-  return 0; //FIXME: what does it return?
+   return 0; //FIXME: what does it return?
 }
 
 STATIC VOID FASTCALL
 FixClientRect(PRECT ClientRect, PRECT WindowRect)
 {
-  if (ClientRect->left < WindowRect->left)
-    {
+   if (ClientRect->left < WindowRect->left)
+   {
       ClientRect->left = WindowRect->left;
-    }
-  else if (WindowRect->right < ClientRect->left)
-    {
+   }
+   else if (WindowRect->right < ClientRect->left)
+   {
       ClientRect->left = WindowRect->right;
-    }
-  if (ClientRect->right < WindowRect->left)
-    {
+   }
+   if (ClientRect->right < WindowRect->left)
+   {
       ClientRect->right = WindowRect->left;
-    }
-  else if (WindowRect->right < ClientRect->right)
-    {
+   }
+   else if (WindowRect->right < ClientRect->right)
+   {
       ClientRect->right = WindowRect->right;
-    }
-  if (ClientRect->top < WindowRect->top)
-    {
+   }
+   if (ClientRect->top < WindowRect->top)
+   {
       ClientRect->top = WindowRect->top;
-    }
-  else if (WindowRect->bottom < ClientRect->top)
-    {
+   }
+   else if (WindowRect->bottom < ClientRect->top)
+   {
       ClientRect->top = WindowRect->bottom;
-    }
-  if (ClientRect->bottom < WindowRect->top)
-    {
+   }
+   if (ClientRect->bottom < WindowRect->top)
+   {
       ClientRect->bottom = WindowRect->top;
-    }
-  else if (WindowRect->bottom < ClientRect->bottom)
-    {
+   }
+   else if (WindowRect->bottom < ClientRect->bottom)
+   {
       ClientRect->bottom = WindowRect->bottom;
-    }
+   }
 }
 
 LONG STATIC FASTCALL
 co_WinPosDoNCCALCSize(PWINDOW_OBJECT Window, PWINDOWPOS WinPos,
-                  RECT* WindowRect, RECT* ClientRect)
+                      RECT* WindowRect, RECT* ClientRect)
 {
-  PWINDOW_OBJECT Parent;
-  UINT wvrFlags = 0;
+   PWINDOW_OBJECT Parent;
+   UINT wvrFlags = 0;
 
-  /* Send WM_NCCALCSIZE message to get new client area */
-  if ((WinPos->flags & (SWP_FRAMECHANGED | SWP_NOSIZE)) != SWP_NOSIZE)
-    {
+   /* Send WM_NCCALCSIZE message to get new client area */
+   if ((WinPos->flags & (SWP_FRAMECHANGED | SWP_NOSIZE)) != SWP_NOSIZE)
+   {
       NCCALCSIZE_PARAMS params;
       WINDOWPOS winposCopy;
 
@@ -520,14 +530,14 @@ co_WinPosDoNCCALCSize(PWINDOW_OBJECT Window, PWINDOWPOS WinPos,
       params.rgrc[2] = Window->ClientRect;
       Parent = Window->Parent;
       if (0 != (Window->Style & WS_CHILD) && Parent)
-       {
-         IntGdiOffsetRect(&(params.rgrc[0]), - Parent->ClientRect.left,
-                             - Parent->ClientRect.top);
-         IntGdiOffsetRect(&(params.rgrc[1]), - Parent->ClientRect.left,
-                             - Parent->ClientRect.top);
-         IntGdiOffsetRect(&(params.rgrc[2]), - Parent->ClientRect.left,
-                             - Parent->ClientRect.top);
-       }
+      {
+         IntGdiOffsetRect(&(params.rgrc[0]), - Parent->ClientRect.left,
+                          - Parent->ClientRect.top);
+         IntGdiOffsetRect(&(params.rgrc[1]), - Parent->ClientRect.left,
+                          - Parent->ClientRect.top);
+         IntGdiOffsetRect(&(params.rgrc[2]), - Parent->ClientRect.left,
+                          - Parent->ClientRect.top);
+      }
       params.lppos = &winposCopy;
       winposCopy = *WinPos;
 
@@ -535,92 +545,92 @@ co_WinPosDoNCCALCSize(PWINDOW_OBJECT Window, PWINDOWPOS WinPos,
 
       /* If the application send back garbage, ignore it */
       if (params.rgrc[0].left <= params.rgrc[0].right &&
-          params.rgrc[0].top <= params.rgrc[0].bottom)
-       {
-          *ClientRect = params.rgrc[0];
-         if ((Window->Style & WS_CHILD) && Parent)
-           {
-             IntGdiOffsetRect(ClientRect, Parent->ClientRect.left,
-                             Parent->ClientRect.top);
-           }
-          FixClientRect(ClientRect, WindowRect);
-       }
-
-       /* FIXME: WVR_ALIGNxxx */
+            params.rgrc[0].top <= params.rgrc[0].bottom)
+      {
+         *ClientRect = params.rgrc[0];
+         if ((Window->Style & WS_CHILD) && Parent)
+         {
+            IntGdiOffsetRect(ClientRect, Parent->ClientRect.left,
+                             Parent->ClientRect.top);
+         }
+         FixClientRect(ClientRect, WindowRect);
+      }
+
+      /* FIXME: WVR_ALIGNxxx */
 
       if (ClientRect->left != Window->ClientRect.left ||
-          ClientRect->top != Window->ClientRect.top)
-       {
-          WinPos->flags &= ~SWP_NOCLIENTMOVE;
-       }
+            ClientRect->top != Window->ClientRect.top)
+      {
+         WinPos->flags &= ~SWP_NOCLIENTMOVE;
+      }
 
       if ((ClientRect->right - ClientRect->left !=
-           Window->ClientRect.right - Window->ClientRect.left) ||
-          (ClientRect->bottom - ClientRect->top !=
-           Window->ClientRect.bottom - Window->ClientRect.top))
-       {
-          WinPos->flags &= ~SWP_NOCLIENTSIZE;
-       }
-    }
-  else
-    {
+            Window->ClientRect.right - Window->ClientRect.left) ||
+            (ClientRect->bottom - ClientRect->top !=
+             Window->ClientRect.bottom - Window->ClientRect.top))
+      {
+         WinPos->flags &= ~SWP_NOCLIENTSIZE;
+      }
+   }
+   else
+   {
       if (! (WinPos->flags & SWP_NOMOVE)
-          && (ClientRect->left != Window->ClientRect.left ||
-              ClientRect->top != Window->ClientRect.top))
-       {
-          WinPos->flags &= ~SWP_NOCLIENTMOVE;
-       }
-    }
-
-  return wvrFlags;
+            && (ClientRect->left != Window->ClientRect.left ||
+                ClientRect->top != Window->ClientRect.top))
+      {
+         WinPos->flags &= ~SWP_NOCLIENTMOVE;
+      }
+   }
+
+   return wvrFlags;
 }
 
 BOOL FASTCALL
 co_WinPosDoWinPosChanging(PWINDOW_OBJECT Window,
-                      PWINDOWPOS WinPos,
-                      PRECT WindowRect,
-                      PRECT ClientRect)
+                          PWINDOWPOS WinPos,
+                          PRECT WindowRect,
+                          PRECT ClientRect)
 {
-  INT X, Y;
+   INT X, Y;
 
-  if (!(WinPos->flags & SWP_NOSENDCHANGING))
-    {
+   if (!(WinPos->flags & SWP_NOSENDCHANGING))
+   {
       co_IntSendMessage(Window->hSelf, WM_WINDOWPOSCHANGING, 0, (LPARAM) WinPos);
-    }
+   }
 
-  *WindowRect = Window->WindowRect;
-  *ClientRect = Window->ClientRect;
+   *WindowRect = Window->WindowRect;
+   *ClientRect = Window->ClientRect;
 
-  if (!(WinPos->flags & SWP_NOSIZE))
-    {
+   if (!(WinPos->flags & SWP_NOSIZE))
+   {
       WindowRect->right = WindowRect->left + WinPos->cx;
       WindowRect->bottom = WindowRect->top + WinPos->cy;
-    }
+   }
 
-  if (!(WinPos->flags & SWP_NOMOVE))
-    {
+   if (!(WinPos->flags & SWP_NOMOVE))
+   {
       PWINDOW_OBJECT Parent;
       X = WinPos->x;
       Y = WinPos->y;
       Parent = Window->Parent;
       if ((0 != (Window->Style & WS_CHILD)) && Parent)
-       {
-         X += Parent->ClientRect.left;
-         Y += Parent->ClientRect.top;
-       }
+      {
+         X += Parent->ClientRect.left;
+         Y += Parent->ClientRect.top;
+      }
 
       WindowRect->left = X;
       WindowRect->top = Y;
       WindowRect->right += X - Window->WindowRect.left;
       WindowRect->bottom += Y - Window->WindowRect.top;
       IntGdiOffsetRect(ClientRect,
-        X - Window->WindowRect.left,
-        Y - Window->WindowRect.top);
-    }
+                       X - Window->WindowRect.left,
+                       Y - Window->WindowRect.top);
+   }
 
-  WinPos->flags |= SWP_NOCLIENTMOVE | SWP_NOCLIENTSIZE;
+   WinPos->flags |= SWP_NOCLIENTMOVE | SWP_NOCLIENTSIZE;
 
-  return TRUE;
+   return TRUE;
 }
 
 /*
@@ -650,22 +660,25 @@ WinPosDoOwnedPopups(HWND hWnd, HWND hWndInsertAfter)
          {
             for (i = 0; List[i]; i++)
             {
-               if (List[i] == Owner) break;
+               if (List[i] == Owner)
+                  break;
                if (HWND_TOP == hWndInsertAfter)
                {
-                 ChildObject = IntGetWindowObject(List[i]);
-                 if (NULL != ChildObject)
-                 {
-                   if (0 == (ChildObject->ExStyle & WS_EX_TOPMOST))
-                   {
+                  ChildObject = IntGetWindowObject(List[i]);
+                  if (NULL != ChildObject)
+                  {
+                     if (0 == (ChildObject->ExStyle & WS_EX_TOPMOST))
+                     {
+                        IntReleaseWindowObject(ChildObject);
+                        break;
+                     }
                      IntReleaseWindowObject(ChildObject);
-                     break;
-                   }
-                   IntReleaseWindowObject(ChildObject);
-                 }
+                  }
                }
-               if (List[i] != hWnd) hWndLocalPrev = List[i];
-               if (hWndLocalPrev == hWndInsertAfter) break;
+               if (List[i] != hWnd)
+                  hWndLocalPrev = List[i];
+               if (hWndLocalPrev == hWndInsertAfter)
+                  break;
             }
             hWndInsertAfter = hWndLocalPrev;
          }
@@ -687,22 +700,23 @@ WinPosDoOwnedPopups(HWND hWnd, HWND hWndInsertAfter)
       for (i = 0; List[i]; i++)
       {
          PWINDOW_OBJECT Wnd;
-         
+
          if (List[i] == hWnd)
             break;
-            
-         if (!(Wnd = UserGetWindowObject(List[i]))) continue;   
-            
+
+         if (!(Wnd = UserGetWindowObject(List[i])))
+            continue;
+
          if ((UserGetWindowLong(List[i], GWL_STYLE, FALSE) & WS_POPUP) &&
-             UserGetWindow(List[i], GW_OWNER) == hWnd)
+               UserGetWindow(List[i], GW_OWNER) == hWnd)
          {
             UserRefObjectCo(Wnd);
-            
+
             co_WinPosSetWindowPos(Wnd, hWndInsertAfter, 0, 0, 0, 0,
-               SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING);
-               
+                                  SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING);
+
             UserDerefObjectCo(Wnd);
-            
+
             hWndInsertAfter = List[i];
          }
       }
@@ -713,7 +727,7 @@ WinPosDoOwnedPopups(HWND hWnd, HWND hWndInsertAfter)
 }
 
 /***********************************************************************
- *          WinPosInternalMoveWindow
+ *      WinPosInternalMoveWindow
  *
  * Update WindowRect and ClientRect of Window and all of its children
  * We keep both WindowRect and ClientRect in screen coordinates internally
@@ -735,7 +749,7 @@ WinPosInternalMoveWindow(PWINDOW_OBJECT Window, INT MoveX, INT MoveY)
 
    for(Child = Window->FirstChild; Child; Child = Child->NextSibling)
    {
-     WinPosInternalMoveWindow(Child, MoveX, MoveY);
+      WinPosInternalMoveWindow(Child, MoveX, MoveY);
    }
 }
 
@@ -764,14 +778,14 @@ WinPosFixupFlags(WINDOWPOS *WinPos, PWINDOW_OBJECT Window)
 
    /* Check for right size */
    if (Window->WindowRect.right - Window->WindowRect.left == WinPos->cx &&
-       Window->WindowRect.bottom - Window->WindowRect.top == WinPos->cy)
+         Window->WindowRect.bottom - Window->WindowRect.top == WinPos->cy)
    {
       WinPos->flags |= SWP_NOSIZE;
    }
 
    /* Check for right position */
    if (Window->WindowRect.left == WinPos->x &&
-       Window->WindowRect.top == WinPos->y)
+         Window->WindowRect.top == WinPos->y)
    {
       WinPos->flags |= SWP_NOMOVE;
    }
@@ -781,17 +795,17 @@ WinPosFixupFlags(WINDOWPOS *WinPos, PWINDOW_OBJECT Window)
       WinPos->flags |= SWP_NOACTIVATE;   /* Already active */
    }
    else
-   if ((Window->Style & (WS_POPUP | WS_CHILD)) != WS_CHILD)
-   {
-      /* Bring to the top when activating */
-      if (!(WinPos->flags & SWP_NOACTIVATE))
+      if ((Window->Style & (WS_POPUP | WS_CHILD)) != WS_CHILD)
       {
-         WinPos->flags &= ~SWP_NOZORDER;
-         WinPos->hwndInsertAfter = (0 != (Window->ExStyle & WS_EX_TOPMOST) ?
-                                    HWND_TOPMOST : HWND_TOP);
-         return TRUE;
+         /* Bring to the top when activating */
+         if (!(WinPos->flags & SWP_NOACTIVATE))
+         {
+            WinPos->flags &= ~SWP_NOZORDER;
+            WinPos->hwndInsertAfter = (0 != (Window->ExStyle & WS_EX_TOPMOST) ?
+                                       HWND_TOPMOST : HWND_TOP);
+            return TRUE;
+         }
       }
-   }
 
    /* Check hwndInsertAfter */
    if (!(WinPos->flags & SWP_NOZORDER))
@@ -819,13 +833,13 @@ WinPosFixupFlags(WINDOWPOS *WinPos, PWINDOW_OBJECT Window)
 
       /* hwndInsertAfter must be a sibling of the window */
       if (HWND_TOPMOST != WinPos->hwndInsertAfter
-          && HWND_TOP != WinPos->hwndInsertAfter
-          && HWND_NOTOPMOST != WinPos->hwndInsertAfter
-          && HWND_BOTTOM != WinPos->hwndInsertAfter)
+            && HWND_TOP != WinPos->hwndInsertAfter
+            && HWND_NOTOPMOST != WinPos->hwndInsertAfter
+            && HWND_BOTTOM != WinPos->hwndInsertAfter)
       {
          PWINDOW_OBJECT Parent = Window->Parent;
          if (UserGetAncestor(WinPos->hwndInsertAfter, GA_PARENT) !=
-             (Parent ? Parent->hSelf : NULL))
+               (Parent ? Parent->hSelf : NULL))
          {
             return FALSE;
          }
@@ -837,7 +851,7 @@ WinPosFixupFlags(WINDOWPOS *WinPos, PWINDOW_OBJECT Window)
              * itself.
              */
             if ((WinPos->hwnd == WinPos->hwndInsertAfter) ||
-                (WinPos->hwnd == UserGetWindow(WinPos->hwndInsertAfter, GW_HWNDNEXT)))
+                  (WinPos->hwnd == UserGetWindow(WinPos->hwndInsertAfter, GW_HWNDNEXT)))
             {
                WinPos->flags |= SWP_NOZORDER;
             }
@@ -851,14 +865,14 @@ WinPosFixupFlags(WINDOWPOS *WinPos, PWINDOW_OBJECT Window)
 /* x and y are always screen relative */
 BOOLEAN FASTCALL
 co_WinPosSetWindowPos(
-   PWINDOW_OBJECT Window, 
-   HWND WndInsertAfter, 
-   INT x, 
-   INT y, 
+   PWINDOW_OBJECT Window,
+   HWND WndInsertAfter,
+   INT x,
+   INT y,
    INT cx,
-       INT cy, 
+   INT cy,
    UINT flags
-   )
+)
 {
    WINDOWPOS WinPos;
    RECT NewWindowRect;
@@ -884,7 +898,7 @@ co_WinPosSetWindowPos(
     * Only allow CSRSS to mess with the desktop window
     */
    if (Window->hSelf == IntGetDesktopWindow() &&
-       Window->OwnerThread->ThreadsProcess != PsGetCurrentProcess())
+         Window->OwnerThread->ThreadsProcess != PsGetCurrentProcess())
    {
       return FALSE;
    }
@@ -914,8 +928,8 @@ co_WinPosSetWindowPos(
    }
 
    if ((WinPos.flags & (SWP_NOZORDER | SWP_HIDEWINDOW | SWP_SHOWWINDOW)) !=
-       SWP_NOZORDER &&
-       UserGetAncestor(WinPos.hwnd, GA_PARENT) == IntGetDesktopWindow())
+         SWP_NOZORDER &&
+         UserGetAncestor(WinPos.hwnd, GA_PARENT) == IntGetDesktopWindow())
    {
       WinPos.hwndInsertAfter = WinPosDoOwnedPopups(WinPos.hwnd, WinPos.hwndInsertAfter);
    }
@@ -924,15 +938,15 @@ co_WinPosSetWindowPos(
    {
       /* Compute the visible region before the window position is changed */
       if (!(WinPos.flags & (SWP_NOREDRAW | SWP_SHOWWINDOW)) &&
-          (WinPos.flags & (SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
-                           SWP_HIDEWINDOW | SWP_FRAMECHANGED)) !=
-          (SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER))
+            (WinPos.flags & (SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
+                             SWP_HIDEWINDOW | SWP_FRAMECHANGED)) !=
+            (SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER))
       {
          VisBefore = VIS_ComputeVisibleRegion(Window, FALSE, FALSE, TRUE);
          VisRgn = NULL;
 
          if (VisBefore != NULL && (VisRgn = (PROSRGNDATA)RGNDATA_LockRgn(VisBefore)) &&
-             UnsafeIntGetRgnBox(VisRgn, &TempRect) == NULLREGION)
+               UnsafeIntGetRgnBox(VisRgn, &TempRect) == NULLREGION)
          {
             RGNDATA_UnlockRgn(VisRgn);
             NtGdiDeleteObject(VisBefore);
@@ -972,7 +986,7 @@ co_WinPosSetWindowPos(
             }
             if (NULL != InsertAfterWindow)
             {
-              IntReferenceWindowObject(InsertAfterWindow);
+               IntReferenceWindowObject(InsertAfterWindow);
             }
          }
          else if (WinPos.hwndInsertAfter == HWND_BOTTOM)
@@ -983,7 +997,7 @@ co_WinPosSetWindowPos(
                InsertAfterWindow = ParentWindow->LastChild;
             }
             else
-              InsertAfterWindow = NULL;
+               InsertAfterWindow = NULL;
          }
          else
             InsertAfterWindow = IntGetWindowObject(WinPos.hwndInsertAfter);
@@ -991,17 +1005,17 @@ co_WinPosSetWindowPos(
             the last window */
          if (InsertAfterWindow != Window)
          {
-             IntUnlinkWindow(Window);
-             IntLinkWindow(Window, ParentWindow, InsertAfterWindow);
+            IntUnlinkWindow(Window);
+            IntLinkWindow(Window, ParentWindow, InsertAfterWindow);
          }
          if (InsertAfterWindow != NULL)
             IntReleaseWindowObject(InsertAfterWindow);
          if ((HWND_TOPMOST == WinPos.hwndInsertAfter)
-             || (0 != (Window->ExStyle & WS_EX_TOPMOST)
-                 && NULL != Window->PrevSibling
-                 && 0 != (Window->PrevSibling->ExStyle & WS_EX_TOPMOST))
-             || (NULL != Window->NextSibling
-                 && 0 != (Window->NextSibling->ExStyle & WS_EX_TOPMOST)))
+               || (0 != (Window->ExStyle & WS_EX_TOPMOST)
+                   && NULL != Window->PrevSibling
+                   && 0 != (Window->PrevSibling->ExStyle & WS_EX_TOPMOST))
+               || (NULL != Window->NextSibling
+                   && 0 != (Window->NextSibling->ExStyle & WS_EX_TOPMOST)))
          {
             Window->ExStyle |= WS_EX_TOPMOST;
          }
@@ -1018,13 +1032,13 @@ co_WinPosSetWindowPos(
    OldClientRect = Window->ClientRect;
 
    if (OldClientRect.bottom - OldClientRect.top ==
-       NewClientRect.bottom - NewClientRect.top)
+         NewClientRect.bottom - NewClientRect.top)
    {
       WvrFlags &= ~WVR_VREDRAW;
    }
 
    if (OldClientRect.right - OldClientRect.left ==
-       NewClientRect.right - NewClientRect.left)
+         NewClientRect.right - NewClientRect.left)
    {
       WvrFlags &= ~WVR_HREDRAW;
    }
@@ -1032,7 +1046,7 @@ co_WinPosSetWindowPos(
    /* FIXME: Actually do something with WVR_VALIDRECTS */
 
    if (NewClientRect.left != OldClientRect.left ||
-       NewClientRect.top != OldClientRect.top)
+         NewClientRect.top != OldClientRect.top)
    {
       WinPosInternalMoveWindow(Window,
                                NewClientRect.left - OldClientRect.left,
@@ -1046,7 +1060,7 @@ co_WinPosSetWindowPos(
    {
       /* Clear the update region */
       co_UserRedrawWindow(Window, NULL, 0, RDW_VALIDATE | RDW_NOFRAME |
-                      RDW_NOERASE | RDW_NOINTERNALPAINT | RDW_ALLCHILDREN);
+                          RDW_NOERASE | RDW_NOINTERNALPAINT | RDW_ALLCHILDREN);
       Window->Style &= ~WS_VISIBLE;
    }
    else if (WinPos.flags & SWP_SHOWWINDOW)
@@ -1063,7 +1077,7 @@ co_WinPosSetWindowPos(
       VisRgn = NULL;
 
       if (VisAfter != NULL && (VisRgn = (PROSRGNDATA)RGNDATA_LockRgn(VisAfter)) &&
-          UnsafeIntGetRgnBox(VisRgn, &TempRect) == NULLREGION)
+            UnsafeIntGetRgnBox(VisRgn, &TempRect) == NULLREGION)
       {
          RGNDATA_UnlockRgn(VisRgn);
          NtGdiDeleteObject(VisAfter);
@@ -1082,7 +1096,7 @@ co_WinPosSetWindowPos(
        * change.
        */
       if (VisBefore != NULL && VisAfter != NULL && !(WinPos.flags & SWP_NOCOPYBITS) &&
-          ((WinPos.flags & SWP_NOSIZE) || !(WvrFlags & WVR_REDRAW)))
+            ((WinPos.flags & SWP_NOSIZE) || !(WvrFlags & WVR_REDRAW)))
       {
          CopyRgn = NtGdiCreateRectRgn(0, 0, 0, 0);
          RgnType = NtGdiCombineRgn(CopyRgn, VisAfter, VisBefore, RGN_AND);
@@ -1096,7 +1110,7 @@ co_WinPosSetWindowPos(
           * region...)
           */
          if (!(WinPos.flags & SWP_NOSIZE) && RgnType != ERROR &&
-             RgnType != NULLREGION)
+               RgnType != NULLREGION)
          {
             RECT ORect = OldClientRect;
             RECT NRect = NewClientRect;
@@ -1122,7 +1136,7 @@ co_WinPosSetWindowPos(
           * themselves.
           */
          if ((VisRgn = (PROSRGNDATA)RGNDATA_LockRgn(CopyRgn)) &&
-             UnsafeIntGetRgnBox(VisRgn, &CopyRect) == NULLREGION)
+               UnsafeIntGetRgnBox(VisRgn, &CopyRect) == NULLREGION)
          {
             /* Nothing to copy, clean up */
             RGNDATA_UnlockRgn(VisRgn);
@@ -1149,12 +1163,12 @@ co_WinPosSetWindowPos(
 
             NtGdiCombineRgn(ClipRgn, CopyRgn, NULL, RGN_COPY);
             Dc = UserGetDCEx(Window, ClipRgn, DCX_WINDOW | DCX_CACHE |
-               DCX_INTERSECTRGN | DCX_CLIPSIBLINGS);
+                             DCX_INTERSECTRGN | DCX_CLIPSIBLINGS);
             NtGdiBitBlt(Dc,
-               CopyRect.left, CopyRect.top, CopyRect.right - CopyRect.left,
-               CopyRect.bottom - CopyRect.top, Dc,
-               CopyRect.left + (OldWindowRect.left - NewWindowRect.left),
-               CopyRect.top + (OldWindowRect.top - NewWindowRect.top), SRCCOPY);
+                        CopyRect.left, CopyRect.top, CopyRect.right - CopyRect.left,
+                        CopyRect.bottom - CopyRect.top, Dc,
+                        CopyRect.left + (OldWindowRect.left - NewWindowRect.left),
+                        CopyRect.top + (OldWindowRect.top - NewWindowRect.top), SRCCOPY);
             UserReleaseDC(Window, Dc);
             IntValidateParent(Window, CopyRgn);
          }
@@ -1183,10 +1197,10 @@ co_WinPosSetWindowPos(
          if (RgnType != ERROR && RgnType != NULLREGION)
          {
             NtGdiOffsetRgn(DirtyRgn,
-               Window->WindowRect.left - Window->ClientRect.left,
-               Window->WindowRect.top - Window->ClientRect.top);
+                           Window->WindowRect.left - Window->ClientRect.left,
+                           Window->WindowRect.top - Window->ClientRect.top);
             co_UserRedrawWindow(Window, NULL, DirtyRgn,
-               RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
+                                RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
          }
          NtGdiDeleteObject(DirtyRgn);
       }
@@ -1243,189 +1257,189 @@ co_WinPosSetWindowPos(
 LRESULT FASTCALL
 co_WinPosGetNonClientSize(HWND Wnd, RECT* WindowRect, RECT* ClientRect)
 {
-  LRESULT Result;
+   LRESULT Result;
 
-  *ClientRect = *WindowRect;
-  Result = co_IntSendMessage(Wnd, WM_NCCALCSIZE, FALSE, (LPARAM) ClientRect);
+   *ClientRect = *WindowRect;
+   Result = co_IntSendMessage(Wnd, WM_NCCALCSIZE, FALSE, (LPARAM) ClientRect);
 
-  FixClientRect(ClientRect, WindowRect);
+   FixClientRect(ClientRect, WindowRect);
 
-  return Result;
+   return Result;
 }
 
 BOOLEAN FASTCALL
 co_WinPosShowWindow(PWINDOW_OBJECT Window, INT Cmd)
 {
-  BOOLEAN WasVisible;
-  UINT Swp = 0;
-  RECT NewPos;
-  BOOLEAN ShowFlag;
-//  HRGN VisibleRgn;
+   BOOLEAN WasVisible;
+   UINT Swp = 0;
+   RECT NewPos;
+   BOOLEAN ShowFlag;
+   //  HRGN VisibleRgn;
 
-  ASSERT_REFS_CO(Window); 
+   ASSERT_REFS_CO(Window);
 
-  WasVisible = (Window->Style & WS_VISIBLE) != 0;
+   WasVisible = (Window->Style & WS_VISIBLE) != 0;
 
-  switch (Cmd)
-    {
-    case SW_HIDE:
-      {
-       if (!WasVisible)
-         {
-           return(FALSE);
-         }
-       Swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE;
-       if (Window->hSelf != UserGetActiveWindow())
-           Swp |= SWP_NOACTIVATE | SWP_NOZORDER;
-       break;
-      }
+   switch (Cmd)
+   {
+      case SW_HIDE:
+         {
+            if (!WasVisible)
+            {
+               return(FALSE);
+            }
+            Swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE;
+            if (Window->hSelf != UserGetActiveWindow())
+               Swp |= SWP_NOACTIVATE | SWP_NOZORDER;
+            break;
+         }
 
-    case SW_SHOWMINNOACTIVE:
-      Swp |= SWP_NOACTIVATE | SWP_NOZORDER;
-      /* Fall through. */
-    case SW_SHOWMINIMIZED:
-      Swp |= SWP_SHOWWINDOW;
-      /* Fall through. */
-    case SW_MINIMIZE:
-      {
-       Swp |= SWP_FRAMECHANGED | SWP_NOACTIVATE;
-       if (!(Window->Style & WS_MINIMIZE))
-         {
-           Swp |= co_WinPosMinMaximize(Window, SW_MINIMIZE, &NewPos);
-         }
-       else
-         {
-           Swp |= SWP_NOSIZE | SWP_NOMOVE;
-         }
-       break;
-      }
+      case SW_SHOWMINNOACTIVE:
+         Swp |= SWP_NOACTIVATE | SWP_NOZORDER;
+         /* Fall through. */
+      case SW_SHOWMINIMIZED:
+         Swp |= SWP_SHOWWINDOW;
+         /* Fall through. */
+      case SW_MINIMIZE:
+         {
+            Swp |= SWP_FRAMECHANGED | SWP_NOACTIVATE;
+            if (!(Window->Style & WS_MINIMIZE))
+            {
+               Swp |= co_WinPosMinMaximize(Window, SW_MINIMIZE, &NewPos);
+            }
+            else
+            {
+               Swp |= SWP_NOSIZE | SWP_NOMOVE;
+            }
+            break;
+         }
 
-    case SW_SHOWMAXIMIZED:
-      {
-       Swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
-       if (!(Window->Style & WS_MAXIMIZE))
-         {
-       Swp |= co_WinPosMinMaximize(Window, SW_MAXIMIZE, &NewPos);
-         }
-       else
-         {
-           Swp |= SWP_NOSIZE | SWP_NOMOVE;
-         }
-       break;
-      }
+      case SW_SHOWMAXIMIZED:
+         {
+            Swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
+            if (!(Window->Style & WS_MAXIMIZE))
+            {
+               Swp |= co_WinPosMinMaximize(Window, SW_MAXIMIZE, &NewPos);
+            }
+            else
+            {
+               Swp |= SWP_NOSIZE | SWP_NOMOVE;
+            }
+            break;
+         }
 
-    case SW_SHOWNA:
-      Swp |= SWP_NOACTIVATE | SWP_NOZORDER;
-      /* Fall through. */
-    case SW_SHOW:
-      Swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
-      /* Don't activate the topmost window. */
-      break;
-
-    case SW_SHOWNOACTIVATE:
-      Swp |= SWP_NOZORDER;
-      /* Fall through. */
-    case SW_SHOWNORMAL:
-    case SW_SHOWDEFAULT:
-    case SW_RESTORE:
-      Swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
-      if (Window->Style & (WS_MINIMIZE | WS_MAXIMIZE))
-       {
-     Swp |= co_WinPosMinMaximize(Window, SW_RESTORE, &NewPos);
-       }
-      else
-       {
-         Swp |= SWP_NOSIZE | SWP_NOMOVE;
-       }
-      break;
-    }
-
-  ShowFlag = (Cmd != SW_HIDE);
-  if (ShowFlag != WasVisible)
-    {
+      case SW_SHOWNA:
+         Swp |= SWP_NOACTIVATE | SWP_NOZORDER;
+         /* Fall through. */
+      case SW_SHOW:
+         Swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
+         /* Don't activate the topmost window. */
+         break;
+
+      case SW_SHOWNOACTIVATE:
+         Swp |= SWP_NOZORDER;
+         /* Fall through. */
+      case SW_SHOWNORMAL:
+      case SW_SHOWDEFAULT:
+      case SW_RESTORE:
+         Swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
+         if (Window->Style & (WS_MINIMIZE | WS_MAXIMIZE))
+         {
+            Swp |= co_WinPosMinMaximize(Window, SW_RESTORE, &NewPos);
+         }
+         else
+         {
+            Swp |= SWP_NOSIZE | SWP_NOMOVE;
+         }
+         break;
+   }
+
+   ShowFlag = (Cmd != SW_HIDE);
+   if (ShowFlag != WasVisible)
+   {
       co_IntSendMessage(Window->hSelf, WM_SHOWWINDOW, ShowFlag, 0);
       /*
        * FIXME: Need to check the window wasn't destroyed during the
        * window procedure.
        */
       if (!(Window->Parent))
-        {
-          co_IntShellHookNotify(HSHELL_WINDOWCREATED, (LPARAM)Window->hSelf);
-        }
-    }
-
-  /* We can't activate a child window */
-  if ((Window->Style & WS_CHILD) &&
-      !(Window->ExStyle & WS_EX_MDICHILD))
-    {
+      {
+         co_IntShellHookNotify(HSHELL_WINDOWCREATED, (LPARAM)Window->hSelf);
+      }
+   }
+
+   /* We can't activate a child window */
+   if ((Window->Style & WS_CHILD) &&
+         !(Window->ExStyle & WS_EX_MDICHILD))
+   {
       Swp |= SWP_NOACTIVATE | SWP_NOZORDER;
-    }
+   }
 
-  co_WinPosSetWindowPos(Window, 0 != (Window->ExStyle & WS_EX_TOPMOST)
-                                   ? HWND_TOPMOST : HWND_TOP,
-                     NewPos.left, NewPos.top, NewPos.right, NewPos.bottom, LOWORD(Swp));
+   co_WinPosSetWindowPos(Window, 0 != (Window->ExStyle & WS_EX_TOPMOST)
+                         ? HWND_TOPMOST : HWND_TOP,
+                         NewPos.left, NewPos.top, NewPos.right, NewPos.bottom, LOWORD(Swp));
 
-  if (Cmd == SW_HIDE)
-    {
+   if (Cmd == SW_HIDE)
+   {
       /* FIXME: This will cause the window to be activated irrespective
        * of whether it is owned by the same thread. Has to be done
        * asynchronously.
        */
 
       if (Window->hSelf == UserGetActiveWindow())
-        {
-          co_WinPosActivateOtherWindow(Window);
-        }
+      {
+         co_WinPosActivateOtherWindow(Window);
+      }
 
       /* Revert focus to parent */
       if (Window->hSelf == IntGetThreadFocusWindow() ||
-          IntIsChildWindow(Window->hSelf, IntGetThreadFocusWindow()))
-        {
-          UserSetFocus(Window->Parent->hSelf);
-        }
+            IntIsChildWindow(Window->hSelf, IntGetThreadFocusWindow()))
+      {
+         UserSetFocus(Window->Parent->hSelf);
+      }
 
       if (!(Window->Parent))
-        {
-          co_IntShellHookNotify(HSHELL_WINDOWDESTROYED, (LPARAM)Window->hSelf);
-        }
-    }
+      {
+         co_IntShellHookNotify(HSHELL_WINDOWDESTROYED, (LPARAM)Window->hSelf);
+      }
+   }
 
-  /* FIXME: Check for window destruction. */
+   /* FIXME: Check for window destruction. */
 
-  if ((Window->Flags & WINDOWOBJECT_NEED_SIZE) &&
-      !(Window->Status & WINDOWSTATUS_DESTROYING))
-    {
+   if ((Window->Flags & WINDOWOBJECT_NEED_SIZE) &&
+         !(Window->Status & WINDOWSTATUS_DESTROYING))
+   {
       WPARAM wParam = SIZE_RESTORED;
 
       Window->Flags &= ~WINDOWOBJECT_NEED_SIZE;
       if (Window->Style & WS_MAXIMIZE)
-       {
-         wParam = SIZE_MAXIMIZED;
-       }
+      {
+         wParam = SIZE_MAXIMIZED;
+      }
       else if (Window->Style & WS_MINIMIZE)
-       {
-         wParam = SIZE_MINIMIZED;
-       }
+      {
+         wParam = SIZE_MINIMIZED;
+      }
 
       co_IntSendMessage(Window->hSelf, WM_SIZE, wParam,
-                     MAKELONG(Window->ClientRect.right -
-                              Window->ClientRect.left,
-                              Window->ClientRect.bottom -
-                              Window->ClientRect.top));
+                        MAKELONG(Window->ClientRect.right -
+                                 Window->ClientRect.left,
+                                 Window->ClientRect.bottom -
+                                 Window->ClientRect.top));
       co_IntSendMessage(Window->hSelf, WM_MOVE, 0,
-                     MAKELONG(Window->ClientRect.left,
-                              Window->ClientRect.top));
+                        MAKELONG(Window->ClientRect.left,
+                                 Window->ClientRect.top));
       IntEngWindowChanged(Window, WOC_RGN_CLIENT);
-    }
+   }
 
-  /* Activate the window if activation is not requested and the window is not minimized */
-/*
-  if (!(Swp & (SWP_NOACTIVATE | SWP_HIDEWINDOW)) && !(Window->Style & WS_MINIMIZE))
-    {
-      WinPosChangeActiveWindow(Wnd, FALSE);
-    }
-*/
-  return(WasVisible);
+   /* Activate the window if activation is not requested and the window is not minimized */
+   /*
+     if (!(Swp & (SWP_NOACTIVATE | SWP_HIDEWINDOW)) && !(Window->Style & WS_MINIMIZE))
+       {
+         WinPosChangeActiveWindow(Wnd, FALSE);
+       }
+   */
+   return(WasVisible);
 }
 
 STATIC VOID FASTCALL
@@ -1448,11 +1462,11 @@ co_WinPosSearchChildren(
          if (!(Current->Style & WS_VISIBLE))
          {
             IntReleaseWindowObject(Current);
-           continue;
+            continue;
          }
 
          if ((Current->Style & (WS_POPUP | WS_CHILD | WS_DISABLED)) ==
-             (WS_CHILD | WS_DISABLED))
+               (WS_CHILD | WS_DISABLED))
          {
             IntReleaseWindowObject(Current);
             continue;
@@ -1465,7 +1479,7 @@ co_WinPosSearchChildren(
          }
 
          if (*Window)
-           IntReleaseWindowObject(*Window);
+            IntReleaseWindowObject(*Window);
          *Window = Current;
 
          if (Current->Style & WS_MINIMIZE)
@@ -1483,7 +1497,7 @@ co_WinPosSearchChildren(
          if (OnlyHitTests && (Current->MessageQueue == OnlyHitTests))
          {
             *HitTest = co_IntSendMessage(Current->hSelf, WM_NCHITTEST, 0,
-                                      MAKELONG(Point->x, Point->y));
+                                         MAKELONG(Point->x, Point->y));
             if ((*HitTest) == (USHORT)HTTRANSPARENT)
                continue;
          }
@@ -1491,9 +1505,9 @@ co_WinPosSearchChildren(
             *HitTest = HTCLIENT;
 
          if (Point->x >= Current->ClientRect.left &&
-             Point->x < Current->ClientRect.right &&
-             Point->y >= Current->ClientRect.top &&
-             Point->y < Current->ClientRect.bottom)
+               Point->x < Current->ClientRect.right &&
+               Point->y >= Current->ClientRect.top &&
+               Point->y < Current->ClientRect.bottom)
          {
             co_WinPosSearchChildren(Current, OnlyHitTests, Point, Window, HitTest);
          }
@@ -1506,102 +1520,103 @@ co_WinPosSearchChildren(
 
 USHORT FASTCALL
 co_WinPosWindowFromPoint(PWINDOW_OBJECT ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTests, POINT *WinPoint,
-                     PWINDOW_OBJECT* Window)
+                         PWINDOW_OBJECT* Window)
 {
-  HWND DesktopWindowHandle;
-  PWINDOW_OBJECT DesktopWindow;
-  POINT Point = *WinPoint;
-  USHORT HitTest;
+   HWND DesktopWindowHandle;
+   PWINDOW_OBJECT DesktopWindow;
+   POINT Point = *WinPoint;
+   USHORT HitTest;
 
-  ASSERT_REFS_CO(ScopeWin); 
+   ASSERT_REFS_CO(ScopeWin);
 
-  *Window = NULL;
+   *Window = NULL;
 
-  if(!ScopeWin)
-  {
-    DPRINT1("WinPosWindowFromPoint(): ScopeWin == NULL!\n");
-    return(HTERROR);
-  }
+   if(!ScopeWin)
+   {
+      DPRINT1("WinPosWindowFromPoint(): ScopeWin == NULL!\n");
+      return(HTERROR);
+   }
 
-  if (ScopeWin->Style & WS_DISABLED)
-    {
+   if (ScopeWin->Style & WS_DISABLED)
+   {
       return(HTERROR);
-    }
+   }
 
-  /* Translate the point to the space of the scope window. */
-  DesktopWindowHandle = IntGetDesktopWindow();
-  if((DesktopWindowHandle != ScopeWin->hSelf) &&
-     (DesktopWindow = IntGetWindowObject(DesktopWindowHandle)))
-  {
-    Point.x += ScopeWin->ClientRect.left - DesktopWindow->ClientRect.left;
-    Point.y += ScopeWin->ClientRect.top - DesktopWindow->ClientRect.top;
-    IntReleaseWindowObject(DesktopWindow);
-  }
+   /* Translate the point to the space of the scope window. */
+   DesktopWindowHandle = IntGetDesktopWindow();
+   if((DesktopWindowHandle != ScopeWin->hSelf) &&
+         (DesktopWindow = IntGetWindowObject(DesktopWindowHandle)))
+   {
+      Point.x += ScopeWin->ClientRect.left - DesktopWindow->ClientRect.left;
+      Point.y += ScopeWin->ClientRect.top - DesktopWindow->ClientRect.top;
+      IntReleaseWindowObject(DesktopWindow);
+   }
 
-  HitTest = HTNOWHERE;
+   HitTest = HTNOWHERE;
 
-  co_WinPosSearchChildren(ScopeWin, OnlyHitTests, &Point, Window, &HitTest);
+   co_WinPosSearchChildren(ScopeWin, OnlyHitTests, &Point, Window, &HitTest);
 
-  return ((*Window) ? HitTest : HTNOWHERE);
+   return ((*Window) ? HitTest : HTNOWHERE);
 }
 
 BOOL
 STDCALL
 NtUserGetMinMaxInfo(
-  HWND hWnd,
-  MINMAXINFO *MinMaxInfo,
-  BOOL SendMessage)
+   HWND hWnd,
+   MINMAXINFO *MinMaxInfo,
+   BOOL SendMessage)
 {
-  POINT Size;
-  PINTERNALPOS InternalPos;
-  PWINDOW_OBJECT Window = NULL;
-  MINMAXINFO SafeMinMax;
-  NTSTATUS Status;
-  DECLARE_RETURN(BOOL);
-
-  DPRINT("Enter NtUserGetMinMaxInfo\n");
-  UserEnterExclusive();
-
-  if(!(Window = UserGetWindowObject(hWnd)))
-  {
-    RETURN( FALSE);
-  }
-  
-  UserRefObjectCo(Window); 
-
-  Size.x = Window->WindowRect.left;
-  Size.y = Window->WindowRect.top;
-  InternalPos = WinPosInitInternalPos(Window, &Size,
-                                     &Window->WindowRect);
-  if(InternalPos)
-  {
-    if(SendMessage)
-    {
-      co_WinPosGetMinMaxInfo(Window, &SafeMinMax.ptMaxSize, &SafeMinMax.ptMaxPosition,
-                          &SafeMinMax.ptMinTrackSize, &SafeMinMax.ptMaxTrackSize);
-    }
-    else
-    {
-      WinPosFillMinMaxInfoStruct(Window, &SafeMinMax);
-    }
-    Status = MmCopyToCaller(MinMaxInfo, &SafeMinMax, sizeof(MINMAXINFO));
-    if(!NT_SUCCESS(Status))
-    {
-      SetLastNtError(Status);
+   POINT Size;
+   PINTERNALPOS InternalPos;
+   PWINDOW_OBJECT Window = NULL;
+   MINMAXINFO SafeMinMax;
+   NTSTATUS Status;
+   DECLARE_RETURN(BOOL);
+
+   DPRINT("Enter NtUserGetMinMaxInfo\n");
+   UserEnterExclusive();
+
+   if(!(Window = UserGetWindowObject(hWnd)))
+   {
       RETURN( FALSE);
-    }
+   }
+
+   UserRefObjectCo(Window);
+
+   Size.x = Window->WindowRect.left;
+   Size.y = Window->WindowRect.top;
+   InternalPos = WinPosInitInternalPos(Window, &Size,
+                                       &Window->WindowRect);
+   if(InternalPos)
+   {
+      if(SendMessage)
+      {
+         co_WinPosGetMinMaxInfo(Window, &SafeMinMax.ptMaxSize, &SafeMinMax.ptMaxPosition,
+                                &SafeMinMax.ptMinTrackSize, &SafeMinMax.ptMaxTrackSize);
+      }
+      else
+      {
+         WinPosFillMinMaxInfoStruct(Window, &SafeMinMax);
+      }
+      Status = MmCopyToCaller(MinMaxInfo, &SafeMinMax, sizeof(MINMAXINFO));
+      if(!NT_SUCCESS(Status))
+      {
+         SetLastNtError(Status);
+         RETURN( FALSE);
+      }
 
-    RETURN( TRUE);
-  }
+      RETURN( TRUE);
+   }
+
+   RETURN( FALSE);
 
-  RETURN( FALSE);
-  
 CLEANUP:
-  if (Window) UserDerefObjectCo(Window); 
+   if (Window)
+      UserDerefObjectCo(Window);
 
-  DPRINT("Leave NtUserGetMinMaxInfo, ret=%i\n",_ret_);
-  UserLeave();
-  END_CLEANUP;
+   DPRINT("Leave NtUserGetMinMaxInfo, ret=%i\n",_ret_);
+   UserLeave();
+   END_CLEANUP;
 }
 
 /* EOF */
index d46b82b..6a68e13 100644 (file)
@@ -48,14 +48,14 @@ PWINSTATION_OBJECT InputWindowStation = NULL;
 /* INITALIZATION FUNCTIONS ****************************************************/
 
 static GENERIC_MAPPING IntWindowStationMapping =
-{
-   STANDARD_RIGHTS_READ     | WINSTA_ENUMDESKTOPS      | WINSTA_ENUMERATE         | WINSTA_READATTRIBUTES | WINSTA_READSCREEN,
-   STANDARD_RIGHTS_WRITE    | WINSTA_ACCESSCLIPBOARD   | WINSTA_CREATEDESKTOP     | WINSTA_WRITEATTRIBUTES,
-   STANDARD_RIGHTS_EXECUTE  | WINSTA_ACCESSGLOBALATOMS | WINSTA_EXITWINDOWS,
-   STANDARD_RIGHTS_REQUIRED | WINSTA_ACCESSCLIPBOARD   | WINSTA_ACCESSGLOBALATOMS | WINSTA_CREATEDESKTOP  |
-                              WINSTA_ENUMDESKTOPS      | WINSTA_ENUMERATE         | WINSTA_EXITWINDOWS    |
-                              WINSTA_READATTRIBUTES    | WINSTA_READSCREEN        | WINSTA_WRITEATTRIBUTES
-};
+   {
+      STANDARD_RIGHTS_READ     | WINSTA_ENUMDESKTOPS      | WINSTA_ENUMERATE         | WINSTA_READATTRIBUTES | WINSTA_READSCREEN,
+      STANDARD_RIGHTS_WRITE    | WINSTA_ACCESSCLIPBOARD   | WINSTA_CREATEDESKTOP     | WINSTA_WRITEATTRIBUTES,
+      STANDARD_RIGHTS_EXECUTE  | WINSTA_ACCESSGLOBALATOMS | WINSTA_EXITWINDOWS,
+      STANDARD_RIGHTS_REQUIRED | WINSTA_ACCESSCLIPBOARD   | WINSTA_ACCESSGLOBALATOMS | WINSTA_CREATEDESKTOP  |
+      WINSTA_ENUMDESKTOPS      | WINSTA_ENUMERATE         | WINSTA_EXITWINDOWS    |
+      WINSTA_READATTRIBUTES    | WINSTA_READSCREEN        | WINSTA_WRITEATTRIBUTES
+   };
 
 NTSTATUS FASTCALL
 InitWindowStationImpl(VOID)
@@ -71,20 +71,20 @@ InitWindowStationImpl(VOID)
 
    RtlInitUnicodeString(&UnicodeString, WINSTA_ROOT_NAME);
    InitializeObjectAttributes(&ObjectAttributes, &UnicodeString,
-      0, NULL, NULL);
+                              0, NULL, NULL);
    Status = ZwCreateDirectoryObject(&WindowStationsDirectory, 0,
-      &ObjectAttributes);
+                                    &ObjectAttributes);
    if (!NT_SUCCESS(Status))
    {
       DPRINT("Could not create \\Windows\\WindowStations directory "
-            "(Status 0x%X)\n", Status);
+             "(Status 0x%X)\n", Status);
       return Status;
    }
-   
+
    /* Set Winsta Object Attributes */
    ExWindowStationObjectType->TypeInfo.DefaultNonPagedPoolCharge = sizeof(WINSTATION_OBJECT);
    ExWindowStationObjectType->TypeInfo.GenericMapping = IntWindowStationMapping;
-   
+
    return STATUS_SUCCESS;
 }
 
@@ -104,11 +104,11 @@ IntWinStaObjectOpen(OB_OPEN_REASON Reason,
                     ULONG HandleCount,
                     ACCESS_MASK GrantedAccess)
 {
-  PWINSTATION_OBJECT WinSta = (PWINSTATION_OBJECT)ObjectBody;
-  NTSTATUS Status;
+   PWINSTATION_OBJECT WinSta = (PWINSTATION_OBJECT)ObjectBody;
+   NTSTATUS Status;
 
-  if (Reason == ObCreateHandle)
-  {
+   if (Reason == ObCreateHandle)
+   {
       DPRINT("Creating window station (0x%X)\n", WinSta);
 
       KeInitializeSpinLock(&WinSta->Lock);
@@ -122,66 +122,66 @@ IntWinStaObjectOpen(OB_OPEN_REASON Reason,
       WinSta->SystemMenuTemplate = (HANDLE)0;
 
       DPRINT("Window station successfully created.\n");
-    }
+   }
 
-  return STATUS_SUCCESS;
+   return STATUS_SUCCESS;
 }
 
 VOID STDCALL
 IntWinStaObjectDelete(PVOID DeletedObject)
 {
-  PWINSTATION_OBJECT WinSta = (PWINSTATION_OBJECT)DeletedObject;
+   PWINSTATION_OBJECT WinSta = (PWINSTATION_OBJECT)DeletedObject;
 
-  DPRINT("Deleting window station (0x%X)\n", WinSta);
+   DPRINT("Deleting window station (0x%X)\n", WinSta);
 
-  RtlDestroyAtomTable(WinSta->AtomTable);
+   RtlDestroyAtomTable(WinSta->AtomTable);
 
-  RtlFreeUnicodeString(&WinSta->Name);
+   RtlFreeUnicodeString(&WinSta->Name);
 }
 
 PVOID STDCALL
 IntWinStaObjectFind(PVOID Object,
-                   PWSTR Name,
-                   ULONG Attributes)
+                    PWSTR Name,
+                    ULONG Attributes)
 {
-  PLIST_ENTRY Current;
-  PDESKTOP_OBJECT CurrentObject;
-  PWINSTATION_OBJECT WinStaObject = (PWINSTATION_OBJECT)Object;
-
-  DPRINT("WinStaObject (0x%X)  Name (%wS)\n", WinStaObject, Name);
-
-  if (Name[0] == 0)
-  {
-    return NULL;
-  }
-
-  Current = WinStaObject->DesktopListHead.Flink;
-  while (Current != &WinStaObject->DesktopListHead)
-  {
-    CurrentObject = CONTAINING_RECORD(Current, DESKTOP_OBJECT, ListEntry);
-    DPRINT("Scanning %wZ for %wS\n", &CurrentObject->Name, Name);
-    if (Attributes & OBJ_CASE_INSENSITIVE)
-    {
-      if (_wcsicmp(CurrentObject->Name.Buffer, Name) == 0)
+   PLIST_ENTRY Current;
+   PDESKTOP_OBJECT CurrentObject;
+   PWINSTATION_OBJECT WinStaObject = (PWINSTATION_OBJECT)Object;
+
+   DPRINT("WinStaObject (0x%X)  Name (%wS)\n", WinStaObject, Name);
+
+   if (Name[0] == 0)
+   {
+      return NULL;
+   }
+
+   Current = WinStaObject->DesktopListHead.Flink;
+   while (Current != &WinStaObject->DesktopListHead)
+   {
+      CurrentObject = CONTAINING_RECORD(Current, DESKTOP_OBJECT, ListEntry);
+      DPRINT("Scanning %wZ for %wS\n", &CurrentObject->Name, Name);
+      if (Attributes & OBJ_CASE_INSENSITIVE)
       {
-        DPRINT("Found desktop at (0x%X)\n", CurrentObject);
-        return CurrentObject;
+         if (_wcsicmp(CurrentObject->Name.Buffer, Name) == 0)
+         {
+            DPRINT("Found desktop at (0x%X)\n", CurrentObject);
+            return CurrentObject;
+         }
       }
-    }
-    else
-    {
-      if (wcscmp(CurrentObject->Name.Buffer, Name) == 0)
+      else
       {
-        DPRINT("Found desktop at (0x%X)\n", CurrentObject);
-        return CurrentObject;
+         if (wcscmp(CurrentObject->Name.Buffer, Name) == 0)
+         {
+            DPRINT("Found desktop at (0x%X)\n", CurrentObject);
+            return CurrentObject;
+         }
       }
-    }
-    Current = Current->Flink;
-  }
+      Current = Current->Flink;
+   }
 
-  DPRINT("Returning NULL\n");
+   DPRINT("Returning NULL\n");
 
-  return NULL;
+   return NULL;
 }
 
 NTSTATUS
@@ -192,43 +192,43 @@ IntWinStaObjectParse(PVOID Object,
                      PWSTR *Path,
                      ULONG Attributes)
 {
-  PVOID FoundObject;
-  NTSTATUS Status;
-  PWSTR End;
-
-  DPRINT("Object (0x%X)  Path (0x%X)  *Path (%wS)\n", Object, Path, *Path);
-
-  *NextObject = NULL;
-
-  if ((Path == NULL) || ((*Path) == NULL))
-  {
-    return STATUS_SUCCESS;
-  }
-
-  End = wcschr((*Path) + 1, '\\');
-  if (End != NULL)
-  {
-    DPRINT("Name contains illegal characters\n");
-    return STATUS_UNSUCCESSFUL;
-  }
-
-  FoundObject = IntWinStaObjectFind(Object, (*Path) + 1, Attributes);
-  if (FoundObject == NULL)
-  {
-    DPRINT("Name was not found\n");
-    return STATUS_UNSUCCESSFUL;
-  }
-
-  Status = ObReferenceObjectByPointer(
-    FoundObject,
-    STANDARD_RIGHTS_REQUIRED,
-    NULL,
-    UserMode);
-
-  *NextObject = FoundObject;
-  *Path = NULL;
-
-  return Status;
+   PVOID FoundObject;
+   NTSTATUS Status;
+   PWSTR End;
+
+   DPRINT("Object (0x%X)  Path (0x%X)  *Path (%wS)\n", Object, Path, *Path);
+
+   *NextObject = NULL;
+
+   if ((Path == NULL) || ((*Path) == NULL))
+   {
+      return STATUS_SUCCESS;
+   }
+
+   End = wcschr((*Path) + 1, '\\');
+   if (End != NULL)
+   {
+      DPRINT("Name contains illegal characters\n");
+      return STATUS_UNSUCCESSFUL;
+   }
+
+   FoundObject = IntWinStaObjectFind(Object, (*Path) + 1, Attributes);
+   if (FoundObject == NULL)
+   {
+      DPRINT("Name was not found\n");
+      return STATUS_UNSUCCESSFUL;
+   }
+
+   Status = ObReferenceObjectByPointer(
+               FoundObject,
+               STANDARD_RIGHTS_REQUIRED,
+               NULL,
+               UserMode);
+
+   *NextObject = FoundObject;
+   *Path = NULL;
+
+   return Status;
 }
 
 /* PRIVATE FUNCTIONS **********************************************************/
@@ -305,18 +305,18 @@ IntValidateWindowStationHandle(
 
    if (WindowStation == NULL)
    {
-//      DPRINT1("Invalid window station handle\n");
+      //      DPRINT1("Invalid window station handle\n");
       SetLastWin32Error(ERROR_INVALID_HANDLE);
       return STATUS_INVALID_HANDLE;
    }
 
    Status = ObReferenceObjectByHandle(
-      WindowStation,
-      DesiredAccess,
-      ExWindowStationObjectType,
-      AccessMode,
-      (PVOID*)Object,
-      NULL);
+               WindowStation,
+               DesiredAccess,
+               ExWindowStationObjectType,
+               AccessMode,
+               (PVOID*)Object,
+               NULL);
 
    if (!NT_SUCCESS(Status))
       SetLastNtError(Status);
@@ -330,10 +330,10 @@ IntGetWindowStationObject(PWINSTATION_OBJECT Object)
    NTSTATUS Status;
 
    Status = ObReferenceObjectByPointer(
-      Object,
-      KernelMode,
-      ExWindowStationObjectType,
-      0);
+               Object,
+               KernelMode,
+               ExWindowStationObjectType,
+               0);
 
    return NT_SUCCESS(Status);
 }
@@ -341,40 +341,40 @@ IntGetWindowStationObject(PWINSTATION_OBJECT Object)
 BOOL FASTCALL
 co_IntInitializeDesktopGraphics(VOID)
 {
-  UNICODE_STRING DriverName;
-  if (! IntCreatePrimarySurface())
-    {
+   UNICODE_STRING DriverName;
+   if (! IntCreatePrimarySurface())
+   {
       return FALSE;
-    }
-  RtlInitUnicodeString(&DriverName, L"DISPLAY");
-  ScreenDeviceContext = IntGdiCreateDC(&DriverName, NULL, NULL, NULL, FALSE);
-  if (NULL == ScreenDeviceContext)
-    {
+   }
+   RtlInitUnicodeString(&DriverName, L"DISPLAY");
+   ScreenDeviceContext = IntGdiCreateDC(&DriverName, NULL, NULL, NULL, FALSE);
+   if (NULL == ScreenDeviceContext)
+   {
       IntDestroyPrimarySurface();
       return FALSE;
-    }
-  DC_SetOwnership(ScreenDeviceContext, NULL);
+   }
+   DC_SetOwnership(ScreenDeviceContext, NULL);
 
-  UserAcquireOrReleaseInputOwnership(FALSE);
+   UserAcquireOrReleaseInputOwnership(FALSE);
 
-  /* Setup the cursor */
-  co_IntLoadDefaultCursors();
+   /* Setup the cursor */
+   co_IntLoadDefaultCursors();
 
-  return TRUE;
+   return TRUE;
 }
 
 VOID FASTCALL
 IntEndDesktopGraphics(VOID)
 {
-  UserAcquireOrReleaseInputOwnership(TRUE);
-  if (NULL != ScreenDeviceContext)
-    {
+   UserAcquireOrReleaseInputOwnership(TRUE);
+   if (NULL != ScreenDeviceContext)
+   {
       DC_SetOwnership(ScreenDeviceContext, PsGetCurrentProcess());
       NtGdiDeleteDC(ScreenDeviceContext);
       ScreenDeviceContext = NULL;
-    }
-  IntHideDesktop(IntGetActiveDesktop());
-  IntDestroyPrimarySurface();
+   }
+   IntHideDesktop(IntGetActiveDesktop());
+   IntDestroyPrimarySurface();
 }
 
 HDC FASTCALL
@@ -442,7 +442,7 @@ NtUserCreateWindowStation(
     */
 
    if (!IntGetFullWindowStationName(&WindowStationName, lpszWindowStationName,
-       NULL))
+                                    NULL))
    {
       SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
       return 0;
@@ -463,13 +463,13 @@ NtUserCreateWindowStation(
       NULL);
 
    Status = ObOpenObjectByName(
-      &ObjectAttributes,
-      ExWindowStationObjectType,
-      NULL,
-      KernelMode,
-      dwDesiredAccess,
-      NULL,
-      (PVOID*)&WindowStation);
+               &ObjectAttributes,
+               ExWindowStationObjectType,
+               NULL,
+               KernelMode,
+               dwDesiredAccess,
+               NULL,
+               (PVOID*)&WindowStation);
 
    if (NT_SUCCESS(Status))
    {
@@ -485,15 +485,15 @@ NtUserCreateWindowStation(
    DPRINT("Creating window station (%wZ)\n", &WindowStationName);
 
    Status = ObCreateObject(
-      KernelMode,
-      ExWindowStationObjectType,
-      &ObjectAttributes,
-      ExGetPreviousMode(),
-      NULL,
-      sizeof(WINSTATION_OBJECT),
-      0,
-      0,
-      (PVOID*)&WindowStationObject);
+               KernelMode,
+               ExWindowStationObjectType,
+               &ObjectAttributes,
+               ExGetPreviousMode(),
+               NULL,
+               sizeof(WINSTATION_OBJECT),
+               0,
+               0,
+               (PVOID*)&WindowStationObject);
 
    if (!NT_SUCCESS(Status))
    {
@@ -502,16 +502,16 @@ NtUserCreateWindowStation(
       SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
       return 0;
    }
-   
+
    WindowStationObject->Name = *lpszWindowStationName;
 
    Status = ObInsertObject(
-      (PVOID)WindowStationObject,
-      NULL,
-      STANDARD_RIGHTS_REQUIRED,
-      0,
-      NULL,
-      (PVOID*)&WindowStation);
+               (PVOID)WindowStationObject,
+               NULL,
+               STANDARD_RIGHTS_REQUIRED,
+               0,
+               NULL,
+               (PVOID*)&WindowStation);
 
    if (!NT_SUCCESS(Status))
    {
@@ -528,11 +528,11 @@ NtUserCreateWindowStation(
 
    if(!(CurInfo = ExAllocatePool(PagedPool, sizeof(SYSTEM_CURSORINFO))))
    {
-     ExFreePool(WindowStationName.Buffer);
-     /* FIXME - Delete window station object */
-     ObDereferenceObject(WindowStationObject);
-     SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
-     return 0;
+      ExFreePool(WindowStationName.Buffer);
+      /* FIXME - Delete window station object */
+      ObDereferenceObject(WindowStationObject);
+      SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
+      return 0;
    }
 
    InitHotKeys(WindowStationObject);
@@ -554,8 +554,8 @@ NtUserCreateWindowStation(
 
    if (!IntSetupCurIconHandles(WindowStationObject))
    {
-       DPRINT1("Setting up the Cursor/Icon Handle table failed!\n");
-       /* FIXME: Complain more loudly? */
+      DPRINT1("Setting up the Cursor/Icon Handle table failed!\n");
+      /* FIXME: Complain more loudly? */
    }
 
    DPRINT("Window station successfully created (%wZ)\n", lpszWindowStationName);
@@ -602,7 +602,7 @@ NtUserOpenWindowStation(
     */
 
    if (!IntGetFullWindowStationName(&WindowStationName, lpszWindowStationName,
-       NULL))
+                                    NULL))
    {
       SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
       return 0;
@@ -619,13 +619,13 @@ NtUserOpenWindowStation(
       NULL);
 
    Status = ObOpenObjectByName(
-      &ObjectAttributes,
-      ExWindowStationObjectType,
-      NULL,
-      UserMode,
-      dwDesiredAccess,
-      NULL,
-      (PVOID*)&WindowStation);
+               &ObjectAttributes,
+               ExWindowStationObjectType,
+               NULL,
+               UserMode,
+               dwDesiredAccess,
+               NULL,
+               (PVOID*)&WindowStation);
 
    if (!NT_SUCCESS(Status))
    {
@@ -672,10 +672,10 @@ NtUserCloseWindowStation(
    DPRINT("About to close window station handle (0x%X)\n", hWinSta);
 
    Status = IntValidateWindowStationHandle(
-      hWinSta,
-      KernelMode,
-      0,
-      &Object);
+               hWinSta,
+               KernelMode,
+               0,
+               &Object);
 
    if (!NT_SUCCESS(Status))
    {
@@ -683,11 +683,11 @@ NtUserCloseWindowStation(
       return FALSE;
    }
 
-   #if 0
+#if 0
    /* FIXME - free the cursor information when actually deleting the object!! */
    ASSERT(Object->SystemCursor);
    ExFreePool(Object->SystemCursor);
-   #endif
+#endif
 
    ObDereferenceObject(Object);
 
@@ -760,10 +760,10 @@ NtUserGetObjectInformation(
    /* try windowstation */
    DPRINT("Trying to open window station 0x%x\n", hObject);
    Status = IntValidateWindowStationHandle(
-      hObject,
-      UserMode,/*ExGetPreviousMode(),*/
-      GENERIC_READ, /* FIXME: is this ok? */
-      &WinStaObject);
+               hObject,
+               UserMode,/*ExGetPreviousMode(),*/
+               GENERIC_READ, /* FIXME: is this ok? */
+               &WinStaObject);
 
 
    if (!NT_SUCCESS(Status) && Status != STATUS_OBJECT_TYPE_MISMATCH)
@@ -778,10 +778,10 @@ NtUserGetObjectInformation(
       /* try desktop */
       DPRINT("Trying to open desktop 0x%x\n", hObject);
       Status = IntValidateDesktopHandle(
-         hObject,
-         UserMode,/*ExGetPreviousMode(),*/
-         GENERIC_READ, /* FIXME: is this ok? */
-         &DesktopObject);
+                  hObject,
+                  UserMode,/*ExGetPreviousMode(),*/
+                  GENERIC_READ, /* FIXME: is this ok? */
+                  &DesktopObject);
       if (!NT_SUCCESS(Status))
       {
          DPRINT("Failed: 0x%x\n", Status);
@@ -794,53 +794,53 @@ NtUserGetObjectInformation(
    /* get data */
    switch (nIndex)
    {
-   case UOI_FLAGS:
-      Status = STATUS_NOT_IMPLEMENTED;
-      DPRINT1("UOI_FLAGS unimplemented!\n");
-      break;
+      case UOI_FLAGS:
+         Status = STATUS_NOT_IMPLEMENTED;
+         DPRINT1("UOI_FLAGS unimplemented!\n");
+         break;
 
-   case UOI_NAME:
-      if (WinStaObject != NULL)
-      {
-         pvData = WinStaObject->Name.Buffer;
-         nDataSize = WinStaObject->Name.Length+2;
-         Status = STATUS_SUCCESS;
-      }
-      else if (DesktopObject != NULL)
-      {
-         pvData = DesktopObject->Name.Buffer;
-         nDataSize = DesktopObject->Name.Length+2;
-         Status = STATUS_SUCCESS;
-      }
-      else
-         Status = STATUS_INVALID_PARAMETER;
-      break;
+      case UOI_NAME:
+         if (WinStaObject != NULL)
+         {
+            pvData = WinStaObject->Name.Buffer;
+            nDataSize = WinStaObject->Name.Length+2;
+            Status = STATUS_SUCCESS;
+         }
+         else if (DesktopObject != NULL)
+         {
+            pvData = DesktopObject->Name.Buffer;
+            nDataSize = DesktopObject->Name.Length+2;
+            Status = STATUS_SUCCESS;
+         }
+         else
+            Status = STATUS_INVALID_PARAMETER;
+         break;
 
-   case UOI_TYPE:
-      if (WinStaObject != NULL)
-      {
-         pvData = L"WindowStation";
-         nDataSize = (wcslen(pvData) + 1) * sizeof(WCHAR);
-         Status = STATUS_SUCCESS;
-      }
-      else if (DesktopObject != NULL)
-      {
-         pvData = L"Desktop";
-         nDataSize = (wcslen(pvData) + 1) * sizeof(WCHAR);
-         Status = STATUS_SUCCESS;
-      }
-      else
-         Status = STATUS_INVALID_PARAMETER;
-      break;
+      case UOI_TYPE:
+         if (WinStaObject != NULL)
+         {
+            pvData = L"WindowStation";
+            nDataSize = (wcslen(pvData) + 1) * sizeof(WCHAR);
+            Status = STATUS_SUCCESS;
+         }
+         else if (DesktopObject != NULL)
+         {
+            pvData = L"Desktop";
+            nDataSize = (wcslen(pvData) + 1) * sizeof(WCHAR);
+            Status = STATUS_SUCCESS;
+         }
+         else
+            Status = STATUS_INVALID_PARAMETER;
+         break;
 
-   case UOI_USER_SID:
-      Status = STATUS_NOT_IMPLEMENTED;
-      DPRINT1("UOI_USER_SID unimplemented!\n");
-      break;
+      case UOI_USER_SID:
+         Status = STATUS_NOT_IMPLEMENTED;
+         DPRINT1("UOI_USER_SID unimplemented!\n");
+         break;
 
-   default:
-      Status = STATUS_INVALID_PARAMETER;
-      break;
+      default:
+         Status = STATUS_INVALID_PARAMETER;
+         break;
    }
 
    /* try to copy data to caller */
@@ -916,15 +916,15 @@ UserGetProcessWindowStation(VOID)
 {
    if(PsGetCurrentProcess() != CsrProcess)
    {
-     return PsGetCurrentProcess()->Win32WindowStation;
+      return PsGetCurrentProcess()->Win32WindowStation;
    }
    else
    {
-     /* FIXME - get the pointer to the window station by querying the parent of
-                the desktop of the calling thread (which is a window station),
-                then use ObFindHandleForObject() to find a suitable handle */
-     DPRINT1("CSRSS called NtUserGetProcessWindowStation()!!! returned NULL!\n");
-     return NULL;
+      /* FIXME - get the pointer to the window station by querying the parent of
+                 the desktop of the calling thread (which is a window station),
+                 then use ObFindHandleForObject() to find a suitable handle */
+      DPRINT1("CSRSS called NtUserGetProcessWindowStation()!!! returned NULL!\n");
+      return NULL;
    }
 }
 
@@ -952,35 +952,35 @@ NtUserGetProcessWindowStation(VOID)
 PWINSTATION_OBJECT FASTCALL
 IntGetWinStaObj(VOID)
 {
-  PWINSTATION_OBJECT WinStaObj;
-
-  /*
-   * just a temporary hack, this will be gone soon
-   */
-
-  if(PsGetWin32Thread() != NULL && PsGetWin32Thread()->Desktop != NULL)
-  {
-    WinStaObj = PsGetWin32Thread()->Desktop->WindowStation;
-    ObReferenceObjectByPointer(WinStaObj, KernelMode, ExWindowStationObjectType, 0);
-  }
-  else if(PsGetCurrentProcess() != CsrProcess)
-  {
-    NTSTATUS Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
-                                                     KernelMode,
-                                                     0,
-                                                     &WinStaObj);
-    if(!NT_SUCCESS(Status))
-    {
-      SetLastNtError(Status);
-      return NULL;
-    }
-  }
-  else
-  {
-    WinStaObj = NULL;
-  }
-
-  return WinStaObj;
+   PWINSTATION_OBJECT WinStaObj;
+
+   /*
+    * just a temporary hack, this will be gone soon
+    */
+
+   if(PsGetWin32Thread() != NULL && PsGetWin32Thread()->Desktop != NULL)
+   {
+      WinStaObj = PsGetWin32Thread()->Desktop->WindowStation;
+      ObReferenceObjectByPointer(WinStaObj, KernelMode, ExWindowStationObjectType, 0);
+   }
+   else if(PsGetCurrentProcess() != CsrProcess)
+   {
+      NTSTATUS Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
+                        KernelMode,
+                        0,
+                        &WinStaObj);
+      if(!NT_SUCCESS(Status))
+      {
+         SetLastNtError(Status);
+         return NULL;
+      }
+   }
+   else
+   {
+      WinStaObj = NULL;
+   }
+
+   return WinStaObj;
 }
 
 /*
@@ -1007,25 +1007,25 @@ NtUserSetProcessWindowStation(HWINSTA hWindowStation)
    NTSTATUS Status;
 
    DPRINT("About to set process window station with handle (0x%X)\n",
-      hWindowStation);
+          hWindowStation);
 
    if(PsGetCurrentProcess() == CsrProcess)
    {
-     DPRINT1("CSRSS is not allowed to change it's window station!!!\n");
-     SetLastWin32Error(ERROR_ACCESS_DENIED);
-     return FALSE;
+      DPRINT1("CSRSS is not allowed to change it's window station!!!\n");
+      SetLastWin32Error(ERROR_ACCESS_DENIED);
+      return FALSE;
    }
 
    Status = IntValidateWindowStationHandle(
-      hWindowStation,
-      KernelMode,
-      0,
-      &NewWinSta);
+               hWindowStation,
+               KernelMode,
+               0,
+               &NewWinSta);
 
    if (!NT_SUCCESS(Status))
    {
       DPRINT("Validation of window station handle (0x%X) failed\n",
-         hWindowStation);
+             hWindowStation);
       SetLastNtError(Status);
       return FALSE;
    }
@@ -1038,7 +1038,7 @@ NtUserSetProcessWindowStation(HWINSTA hWindowStation)
    hOld = InterlockedExchangePointer(&PsGetCurrentProcess()->Win32WindowStation, hWindowStation);
 
    DPRINT("PsGetCurrentProcess()->Win32WindowStation 0x%X\n",
-      PsGetCurrentProcess()->Win32WindowStation);
+          PsGetCurrentProcess()->Win32WindowStation);
 
    return TRUE;
 }
@@ -1059,24 +1059,24 @@ NtUserLockWindowStation(HWINSTA hWindowStation)
    NTSTATUS Status;
 
    DPRINT("About to set process window station with handle (0x%X)\n",
-      hWindowStation);
+          hWindowStation);
 
    if(PsGetWin32Process() != LogonProcess)
    {
-     DPRINT1("Unauthorized process attempted to lock the window station!\n");
-     SetLastWin32Error(ERROR_ACCESS_DENIED);
-     return FALSE;
+      DPRINT1("Unauthorized process attempted to lock the window station!\n");
+      SetLastWin32Error(ERROR_ACCESS_DENIED);
+      return FALSE;
    }
 
    Status = IntValidateWindowStationHandle(
-      hWindowStation,
-      KernelMode,
-      0,
-      &Object);
+               hWindowStation,
+               KernelMode,
+               0,
+               &Object);
    if (!NT_SUCCESS(Status))
    {
       DPRINT("Validation of window station handle (0x%X) failed\n",
-         hWindowStation);
+             hWindowStation);
       SetLastNtError(Status);
       return FALSE;
    }
@@ -1104,24 +1104,24 @@ NtUserUnlockWindowStation(HWINSTA hWindowStation)
    BOOL Ret;
 
    DPRINT("About to set process window station with handle (0x%X)\n",
-      hWindowStation);
+          hWindowStation);
 
    if(PsGetWin32Process() != LogonProcess)
    {
-     DPRINT1("Unauthorized process attempted to unlock the window station!\n");
-     SetLastWin32Error(ERROR_ACCESS_DENIED);
-     return FALSE;
+      DPRINT1("Unauthorized process attempted to unlock the window station!\n");
+      SetLastWin32Error(ERROR_ACCESS_DENIED);
+      return FALSE;
    }
 
    Status = IntValidateWindowStationHandle(
-      hWindowStation,
-      KernelMode,
-      0,
-      &Object);
+               hWindowStation,
+               KernelMode,
+               0,
+               &Object);
    if (!NT_SUCCESS(Status))
    {
       DPRINT("Validation of window station handle (0x%X) failed\n",
-         hWindowStation);
+             hWindowStation);
       SetLastNtError(Status);
       return FALSE;
    }
@@ -1187,9 +1187,9 @@ BuildWindowStationNameList(
       NULL);
 
    Status = ZwOpenDirectoryObject(
-      &DirectoryHandle,
-      DIRECTORY_QUERY,
-      &ObjectAttributes);
+               &DirectoryHandle,
+               DIRECTORY_QUERY,
+               &ObjectAttributes);
 
    ExFreePool(DirectoryName.Buffer);
 
@@ -1206,7 +1206,7 @@ BuildWindowStationNameList(
    if (NT_SUCCESS(Status))
    {
       if (STATUS_NO_MORE_ENTRIES == ZwQueryDirectoryObject(DirectoryHandle, NULL, 0, FALSE,
-                                                           FALSE, &Context, NULL))
+            FALSE, &Context, NULL))
       {
          /* Our fixed-size buffer is large enough */
          Buffer = InitialBuffer;
@@ -1233,8 +1233,8 @@ BuildWindowStationNameList(
          Status = ZwQueryDirectoryObject(DirectoryHandle, Buffer, BufferSize,
                                          FALSE, TRUE, &Context, &ReturnLength);
          if (! NT_SUCCESS(Status) ||
-             STATUS_NO_MORE_ENTRIES != ZwQueryDirectoryObject(DirectoryHandle, NULL, 0, FALSE,
-                                                              FALSE, &Context, NULL))
+               STATUS_NO_MORE_ENTRIES != ZwQueryDirectoryObject(DirectoryHandle, NULL, 0, FALSE,
+                     FALSE, &Context, NULL))
          {
             /* Something went wrong, maybe someone added a directory entry? Just give up. */
             ExFreePool(Buffer);
@@ -1252,7 +1252,7 @@ BuildWindowStationNameList(
    ReturnLength = sizeof(DWORD);
    EntryCount = 0;
    for (DirEntry = (POBJECT_DIRECTORY_INFORMATION) Buffer; 0 != DirEntry->ObjectName.Length;
-        DirEntry++)
+         DirEntry++)
    {
       ReturnLength += DirEntry->ObjectName.Length + sizeof(WCHAR);
       EntryCount++;
@@ -1299,7 +1299,7 @@ BuildWindowStationNameList(
 
    NullWchar = L'\0';
    for (DirEntry = (POBJECT_DIRECTORY_INFORMATION) Buffer; 0 != DirEntry->ObjectName.Length;
-        DirEntry++)
+         DirEntry++)
    {
       Status = MmCopyToCaller(lpBuffer, DirEntry->ObjectName.Buffer, DirEntry->ObjectName.Length);
       if (! NT_SUCCESS(Status))
@@ -1367,8 +1367,8 @@ BuildDesktopNameList(
    ReturnLength = sizeof(DWORD);
    EntryCount = 0;
    for (DesktopEntry = WindowStation->DesktopListHead.Flink;
-        DesktopEntry != &WindowStation->DesktopListHead;
-        DesktopEntry = DesktopEntry->Flink)
+         DesktopEntry != &WindowStation->DesktopListHead;
+         DesktopEntry = DesktopEntry->Flink)
    {
       DesktopObject = CONTAINING_RECORD(DesktopEntry, DESKTOP_OBJECT, ListEntry);
       ReturnLength += DesktopObject->Name.Length + sizeof(WCHAR);
@@ -1410,8 +1410,8 @@ BuildDesktopNameList(
 
    NullWchar = L'\0';
    for (DesktopEntry = WindowStation->DesktopListHead.Flink;
-        DesktopEntry != &WindowStation->DesktopListHead;
-        DesktopEntry = DesktopEntry->Flink)
+         DesktopEntry != &WindowStation->DesktopListHead;
+         DesktopEntry = DesktopEntry->Flink)
    {
       DesktopObject = CONTAINING_RECORD(DesktopEntry, DESKTOP_OBJECT, ListEntry);
       Status = MmCopyToCaller(lpBuffer, DesktopObject->Name.Buffer, DesktopObject->Name.Length);
@@ -1477,7 +1477,7 @@ NtUserBuildNameList(
    /* The WindowStation name list and desktop name list are build in completely
       different ways. Call the appropriate function */
    return NULL == hWindowStation ? BuildWindowStationNameList(dwSize, lpBuffer, pRequiredSize) :
-                                   BuildDesktopNameList(hWindowStation, dwSize, lpBuffer, pRequiredSize);
+          BuildDesktopNameList(hWindowStation, dwSize, lpBuffer, pRequiredSize);
 }
 
 /* EOF */