[KERNEL32][CONSRV]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 8 Mar 2014 15:31:05 +0000 (15:31 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 8 Mar 2014 15:31:05 +0000 (15:31 +0000)
Make kernel32 / winsrv console CSR structures Win2k3-compliant.
The aim is to be able to put our kernel32.dll or winsrv.dll on win2k3, and vice-versa.

Most of the changes consist in:
- adding a HANDLE ConsoleHandle; to the structures, representing the console handle of the current application;
- reorganizing the order of the members in the different structures;
- few structures need to hold a event handle because it appears that some APIs create a event handle to perform some sort of synchronization with the console server (this is totally unused at the moment).
- Since CsrClientCallServer returns the value of ApiMessage.Status, then just use ApiMessage.Status instead of declaring another Status variable for querying the return value of CsrClientCallServer.

Part 1/X

Aside:
The VerifyConsoleIoHandle winetest problem is solved here (see CORE-7941 for more details).
CORE-7941 #resolved #comment Fixed in revision 62460, thanks :)

CORE-7931

svn path=/trunk/; revision=62460

15 files changed:
reactos/dll/win32/kernel32/client/console/console.c
reactos/include/psdk/wincon.h
reactos/include/reactos/subsys/win/conmsg.h
reactos/win32ss/user/winsrv/consrv/condrv/console.c
reactos/win32ss/user/winsrv/consrv/condrv/dummyfrontend.c
reactos/win32ss/user/winsrv/consrv/condrv/text.c
reactos/win32ss/user/winsrv/consrv/conoutput.c
reactos/win32ss/user/winsrv/consrv/console.c
reactos/win32ss/user/winsrv/consrv/frontendctl.c
reactos/win32ss/user/winsrv/consrv/frontends/gui/guisettings.h
reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
reactos/win32ss/user/winsrv/consrv/frontends/tui/tuiterm.c
reactos/win32ss/user/winsrv/consrv/handle.c
reactos/win32ss/user/winsrv/consrv/include/conio.h
reactos/win32ss/user/winsrv/consrv/include/term.h

index 12d820c..e4a3367 100644 (file)
@@ -252,17 +252,18 @@ ConsoleMenuControl(HANDLE hConsoleOutput,
     CONSOLE_API_MESSAGE ApiMessage;
     PCONSOLE_MENUCONTROL MenuControlRequest = &ApiMessage.Data.MenuControlRequest;
 
-    MenuControlRequest->OutputHandle = hConsoleOutput;
-    MenuControlRequest->dwCmdIdLow   = dwCmdIdLow;
-    MenuControlRequest->dwCmdIdHigh  = dwCmdIdHigh;
-    MenuControlRequest->hMenu        = NULL;
+    MenuControlRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+    MenuControlRequest->OutputHandle  = hConsoleOutput;
+    MenuControlRequest->CmdIdLow      = dwCmdIdLow;
+    MenuControlRequest->CmdIdHigh     = dwCmdIdHigh;
+    MenuControlRequest->MenuHandle    = NULL;
 
     CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
                         NULL,
                         CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepMenuControl),
-                        sizeof(CONSOLE_MENUCONTROL));
+                        sizeof(*MenuControlRequest));
 
-    return MenuControlRequest->hMenu;
+    return MenuControlRequest->MenuHandle;
 }
 
 
@@ -314,7 +315,6 @@ BOOL
 WINAPI
 GetConsoleDisplayMode(LPDWORD lpModeFlags)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
     PCONSOLE_GETDISPLAYMODE GetDisplayModeRequest = &ApiMessage.Data.GetDisplayModeRequest;
 
@@ -324,19 +324,19 @@ GetConsoleDisplayMode(LPDWORD lpModeFlags)
         return FALSE;
     }
 
-    // GetDisplayModeRequest->OutputHandle = hConsoleOutput;
+    GetDisplayModeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
 
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 NULL,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetDisplayMode),
-                                 sizeof(CONSOLE_GETDISPLAYMODE));
-    if (!NT_SUCCESS(Status))
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        NULL,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetDisplayMode),
+                        sizeof(*GetDisplayModeRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
     {
-        BaseSetLastNTError(Status);
+        BaseSetLastNTError(ApiMessage.Status);
         return FALSE;
     }
 
-    *lpModeFlags = GetDisplayModeRequest->DisplayMode;
+    *lpModeFlags = GetDisplayModeRequest->DisplayMode; // ModeFlags
     return TRUE;
 }
 
@@ -378,33 +378,34 @@ GetConsoleFontSize(HANDLE hConsoleOutput,
 BOOL
 WINAPI
 GetConsoleHardwareState(HANDLE hConsoleOutput,
-                        DWORD Flags,
+                        PDWORD Flags,
                         PDWORD State)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
     PCONSOLE_GETSETHWSTATE HardwareStateRequest = &ApiMessage.Data.HardwareStateRequest;
 
     DPRINT1("GetConsoleHardwareState(%lu, 0x%p) UNIMPLEMENTED!\n", Flags, State);
 
-    if (State == NULL)
+    if (Flags == NULL || State == NULL)
     {
         SetLastError(ERROR_INVALID_PARAMETER);
         return FALSE;
     }
 
-    HardwareStateRequest->OutputHandle = hConsoleOutput;
+    HardwareStateRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+    HardwareStateRequest->OutputHandle  = hConsoleOutput;
 
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 NULL,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetHardwareState),
-                                 sizeof(CONSOLE_GETSETHWSTATE));
-    if (!NT_SUCCESS(Status))
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        NULL,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetHardwareState),
+                        sizeof(*HardwareStateRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
     {
-        BaseSetLastNTError(Status);
+        BaseSetLastNTError(ApiMessage.Status);
         return FALSE;
     }
 
+    *Flags = HardwareStateRequest->Flags;
     *State = HardwareStateRequest->State;
     return TRUE;
 }
@@ -458,7 +459,6 @@ WINAPI
 InvalidateConsoleDIBits(IN HANDLE hConsoleOutput,
                         IN PSMALL_RECT lpRect)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
     PCONSOLE_INVALIDATEDIBITS InvalidateDIBitsRequest = &ApiMessage.Data.InvalidateDIBitsRequest;
 
@@ -468,16 +468,17 @@ InvalidateConsoleDIBits(IN HANDLE hConsoleOutput,
         return FALSE;
     }
 
-    InvalidateDIBitsRequest->OutputHandle = hConsoleOutput;
-    InvalidateDIBitsRequest->Region       = *lpRect;
+    InvalidateDIBitsRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+    InvalidateDIBitsRequest->OutputHandle  = hConsoleOutput;
+    InvalidateDIBitsRequest->Region        = *lpRect;
 
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 NULL,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepInvalidateBitMapRect),
-                                 sizeof(CONSOLE_INVALIDATEDIBITS));
-    if (!NT_SUCCESS(Status))
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        NULL,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepInvalidateBitMapRect),
+                        sizeof(*InvalidateDIBitsRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
     {
-        BaseSetLastNTError(Status);
+        BaseSetLastNTError(ApiMessage.Status);
         return FALSE;
     }
 
@@ -546,23 +547,23 @@ OpenConsoleW(LPCWSTR wsName,
  */
 BOOL
 WINAPI
-SetConsoleCursor(HANDLE hConsoleOutput,
+SetConsoleCursor(HANDLE  hConsoleOutput,
                  HCURSOR hCursor)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
     PCONSOLE_SETCURSOR SetCursorRequest = &ApiMessage.Data.SetCursorRequest;
 
-    SetCursorRequest->OutputHandle = hConsoleOutput;
-    SetCursorRequest->hCursor      = hCursor;
+    SetCursorRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+    SetCursorRequest->OutputHandle  = hConsoleOutput;
+    SetCursorRequest->CursorHandle  = hCursor;
 
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 NULL,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetCursor),
-                                 sizeof(CONSOLE_SETCURSOR));
-    if (!NT_SUCCESS(Status))
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        NULL,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetCursor),
+                        sizeof(*SetCursorRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
     {
-        BaseSetLastNTError(Status);
+        BaseSetLastNTError(ApiMessage.Status);
         return FALSE;
     }
 
@@ -576,25 +577,26 @@ SetConsoleCursor(HANDLE hConsoleOutput,
 BOOL
 WINAPI
 SetConsoleDisplayMode(HANDLE hConsoleOutput,
-                      DWORD dwFlags,
+                      DWORD  dwFlags, // dwModeFlags
                       PCOORD lpNewScreenBufferDimensions)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
     PCONSOLE_SETDISPLAYMODE SetDisplayModeRequest = &ApiMessage.Data.SetDisplayModeRequest;
 
-    SetDisplayModeRequest->OutputHandle = hConsoleOutput;
-    SetDisplayModeRequest->DisplayMode  = dwFlags;
-    SetDisplayModeRequest->NewSBDim.X   = 0;
-    SetDisplayModeRequest->NewSBDim.Y   = 0;
+    SetDisplayModeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+    SetDisplayModeRequest->OutputHandle  = hConsoleOutput;
+    SetDisplayModeRequest->DisplayMode   = dwFlags; // ModeFlags ; dwModeFlags
+    SetDisplayModeRequest->NewSBDim.X    = 0;
+    SetDisplayModeRequest->NewSBDim.Y    = 0;
+    /* SetDisplayModeRequest->EventHandle; */
 
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 NULL,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetDisplayMode),
-                                 sizeof(CONSOLE_SETDISPLAYMODE));
-    if (!NT_SUCCESS(Status))
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        NULL,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetDisplayMode),
+                        sizeof(*SetDisplayModeRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
     {
-        BaseSetLastNTError(Status);
+        BaseSetLastNTError(ApiMessage.Status);
         return FALSE;
     }
 
@@ -628,22 +630,23 @@ SetConsoleHardwareState(HANDLE hConsoleOutput,
                         DWORD Flags,
                         DWORD State)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
     PCONSOLE_GETSETHWSTATE HardwareStateRequest = &ApiMessage.Data.HardwareStateRequest;
 
     DPRINT1("SetConsoleHardwareState(%lu, %lu) UNIMPLEMENTED!\n", Flags, State);
 
-    HardwareStateRequest->OutputHandle = hConsoleOutput;
-    HardwareStateRequest->State = State;
+    HardwareStateRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+    HardwareStateRequest->OutputHandle  = hConsoleOutput;
+    HardwareStateRequest->Flags         = Flags;
+    HardwareStateRequest->State         = State;
 
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 NULL,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetHardwareState),
-                                 sizeof(CONSOLE_GETSETHWSTATE));
-    if (!NT_SUCCESS(Status))
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        NULL,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetHardwareState),
+                        sizeof(*HardwareStateRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
     {
-        BaseSetLastNTError(Status);
+        BaseSetLastNTError(ApiMessage.Status);
         return FALSE;
     }
 
@@ -690,19 +693,19 @@ BOOL
 WINAPI
 SetConsoleMenuClose(BOOL bEnable)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
     PCONSOLE_SETMENUCLOSE SetMenuCloseRequest = &ApiMessage.Data.SetMenuCloseRequest;
 
-    SetMenuCloseRequest->Enable = bEnable;
+    SetMenuCloseRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+    SetMenuCloseRequest->Enable        = bEnable;
 
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 NULL,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetMenuClose),
-                                 sizeof(CONSOLE_SETMENUCLOSE));
-    if (!NT_SUCCESS(Status))
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        NULL,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetMenuClose),
+                        sizeof(*SetMenuCloseRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
     {
-        BaseSetLastNTError(Status);
+        BaseSetLastNTError(ApiMessage.Status);
         return FALSE;
     }
 
@@ -721,21 +724,21 @@ SetConsolePalette(HANDLE hConsoleOutput,
                   HPALETTE hPalette,
                   UINT dwUsage)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
     PCONSOLE_SETPALETTE SetPaletteRequest = &ApiMessage.Data.SetPaletteRequest;
 
+    SetPaletteRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
     SetPaletteRequest->OutputHandle  = hConsoleOutput;
     SetPaletteRequest->PaletteHandle = hPalette;
     SetPaletteRequest->Usage         = dwUsage;
 
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 NULL,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetPalette),
-                                 sizeof(CONSOLE_SETPALETTE));
-    if (!NT_SUCCESS(Status))
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        NULL,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetPalette),
+                        sizeof(*SetPaletteRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
     {
-        BaseSetLastNTError(Status);
+        BaseSetLastNTError(ApiMessage.Status);
         return FALSE;
     }
 
@@ -754,14 +757,15 @@ ShowConsoleCursor(HANDLE hConsoleOutput,
     CONSOLE_API_MESSAGE ApiMessage;
     PCONSOLE_SHOWCURSOR ShowCursorRequest = &ApiMessage.Data.ShowCursorRequest;
 
-    ShowCursorRequest->OutputHandle = hConsoleOutput;
-    ShowCursorRequest->Show         = bShow;
-    ShowCursorRequest->RefCount     = 0;
+    ShowCursorRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+    ShowCursorRequest->OutputHandle  = hConsoleOutput;
+    ShowCursorRequest->Show          = bShow;
+    ShowCursorRequest->RefCount      = 0;
 
     CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
                         NULL,
                         CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepShowCursor),
-                        sizeof(CONSOLE_SHOWCURSOR));
+                        sizeof(*ShowCursorRequest));
 
     return ShowCursorRequest->RefCount;
 }
@@ -771,10 +775,10 @@ ShowConsoleCursor(HANDLE hConsoleOutput,
  * FUNCTION: Checks whether the given handle is a valid console handle.
  *
  * ARGUMENTS:
- *      Handle - Handle to be checked
+ *      hIoHandle - Handle to be checked.
  *
  * RETURNS:
- *      TRUE: Handle is a valid console handle
+ *      TRUE : Handle is a valid console handle.
  *      FALSE: Handle is not a valid console handle.
  *
  * STATUS: Officially undocumented
@@ -783,24 +787,29 @@ ShowConsoleCursor(HANDLE hConsoleOutput,
  */
 BOOL
 WINAPI
-VerifyConsoleIoHandle(HANDLE Handle)
+VerifyConsoleIoHandle(HANDLE hIoHandle)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
+    PCONSOLE_VERIFYHANDLE VerifyHandleRequest = &ApiMessage.Data.VerifyHandleRequest;
 
-    ApiMessage.Data.VerifyHandleRequest.ConsoleHandle = Handle;
+    VerifyHandleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+    VerifyHandleRequest->Handle        = hIoHandle;
+    VerifyHandleRequest->IsValid       = FALSE;
 
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 NULL,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepVerifyIoHandle),
-                                 sizeof(CONSOLE_VERIFYHANDLE));
-    if (!NT_SUCCESS(Status))
+    /* If the process is not attached to a console, return invalid handle */
+    if (VerifyHandleRequest->ConsoleHandle == NULL) return FALSE;
+
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        NULL,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepVerifyIoHandle),
+                        sizeof(*VerifyHandleRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
     {
-        BaseSetLastNTError(Status);
+        BaseSetLastNTError(ApiMessage.Status);
         return FALSE;
     }
 
-    return TRUE;
+    return VerifyHandleRequest->IsValid;
 }
 
 
@@ -809,20 +818,21 @@ VerifyConsoleIoHandle(HANDLE Handle)
  */
 BOOL
 WINAPI
-CloseConsoleHandle(HANDLE Handle)
+CloseConsoleHandle(HANDLE hHandle)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
+    PCONSOLE_CLOSEHANDLE CloseHandleRequest = &ApiMessage.Data.CloseHandleRequest;
 
-    ApiMessage.Data.CloseHandleRequest.ConsoleHandle = Handle;
+    CloseHandleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+    CloseHandleRequest->Handle        = hHandle;
 
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 NULL,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepCloseHandle),
-                                 sizeof(CONSOLE_CLOSEHANDLE));
-    if (!NT_SUCCESS(Status))
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        NULL,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepCloseHandle),
+                        sizeof(*CloseHandleRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
     {
-        BaseSetLastNTError(Status);
+        BaseSetLastNTError(ApiMessage.Status);
         return FALSE;
     }
 
@@ -848,21 +858,27 @@ GetStdHandle(DWORD nStdHandle)
  */
 {
     PRTL_USER_PROCESS_PARAMETERS Ppb = NtCurrentPeb()->ProcessParameters;
+    HANDLE Handle = INVALID_HANDLE_VALUE;
 
     switch (nStdHandle)
     {
         case STD_INPUT_HANDLE:
-            return Ppb->StandardInput;
+            Handle = Ppb->StandardInput;
+            break;
 
         case STD_OUTPUT_HANDLE:
-            return Ppb->StandardOutput;
+            Handle = Ppb->StandardOutput;
+            break;
 
         case STD_ERROR_HANDLE:
-            return Ppb->StandardError;
+            Handle = Ppb->StandardError;
+            break;
     }
 
-    SetLastError(ERROR_INVALID_HANDLE);
-    return INVALID_HANDLE_VALUE;
+    /* If the returned handle is invalid, set last error */
+    if (Handle == INVALID_HANDLE_VALUE) SetLastError(ERROR_INVALID_HANDLE);
+
+    return Handle;
 }
 
 
@@ -871,7 +887,7 @@ GetStdHandle(DWORD nStdHandle)
  */
 BOOL
 WINAPI
-SetStdHandle(DWORD nStdHandle,
+SetStdHandle(DWORD  nStdHandle,
              HANDLE hHandle)
 /*
  * FUNCTION: Set the handle for the standard input, standard output or
@@ -886,7 +902,7 @@ SetStdHandle(DWORD nStdHandle,
 {
     PRTL_USER_PROCESS_PARAMETERS Ppb = NtCurrentPeb()->ProcessParameters;
 
-    /* no need to check if hHandle == INVALID_HANDLE_VALUE */
+    /* No need to check if hHandle == INVALID_HANDLE_VALUE */
 
     switch (nStdHandle)
     {
@@ -903,7 +919,7 @@ SetStdHandle(DWORD nStdHandle,
             return TRUE;
     }
 
-    /* Windows for whatever reason sets the last error to ERROR_INVALID_HANDLE here */
+    /* nStdHandle was invalid, bail out */
     SetLastError(ERROR_INVALID_HANDLE);
     return FALSE;
 }
@@ -1021,8 +1037,8 @@ WINAPI
 GetConsoleScreenBufferInfo(HANDLE hConsoleOutput,
                            PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
+    PCONSOLE_GETSCREENBUFFERINFO ScreenBufferInfoRequest = &ApiMessage.Data.ScreenBufferInfoRequest;
 
     if (lpConsoleScreenBufferInfo == NULL)
     {
@@ -1030,19 +1046,27 @@ GetConsoleScreenBufferInfo(HANDLE hConsoleOutput,
         return FALSE;
     }
 
-    ApiMessage.Data.ScreenBufferInfoRequest.OutputHandle = hConsoleOutput;
+    ScreenBufferInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+    ScreenBufferInfoRequest->OutputHandle  = hConsoleOutput;
 
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 NULL,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetScreenBufferInfo),
-                                 sizeof(CONSOLE_GETSCREENBUFFERINFO));
-    if (!NT_SUCCESS(Status))
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        NULL,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetScreenBufferInfo),
+                        sizeof(*ScreenBufferInfoRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
     {
-        BaseSetLastNTError(Status);
+        BaseSetLastNTError(ApiMessage.Status);
         return FALSE;
     }
 
-    *lpConsoleScreenBufferInfo = ApiMessage.Data.ScreenBufferInfoRequest.Info;
+    lpConsoleScreenBufferInfo->dwSize              = ScreenBufferInfoRequest->ScreenBufferSize;
+    lpConsoleScreenBufferInfo->dwCursorPosition    = ScreenBufferInfoRequest->CursorPosition;
+    lpConsoleScreenBufferInfo->wAttributes         = ScreenBufferInfoRequest->Attributes;
+    lpConsoleScreenBufferInfo->srWindow.Left       = ScreenBufferInfoRequest->ViewOrigin.X;
+    lpConsoleScreenBufferInfo->srWindow.Top        = ScreenBufferInfoRequest->ViewOrigin.Y;
+    lpConsoleScreenBufferInfo->srWindow.Right      = ScreenBufferInfoRequest->ViewOrigin.X + ScreenBufferInfoRequest->ViewSize.X - 1;
+    lpConsoleScreenBufferInfo->srWindow.Bottom     = ScreenBufferInfoRequest->ViewOrigin.Y + ScreenBufferInfoRequest->ViewSize.Y - 1;
+    lpConsoleScreenBufferInfo->dwMaximumWindowSize = ScreenBufferInfoRequest->MaximumViewSize;
 
     return TRUE;
 }
@@ -1932,21 +1956,24 @@ UINT
 WINAPI
 GetConsoleCP(VOID)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
+    PCONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest = &ApiMessage.Data.GetConsoleCPRequest;
 
     /* Get the Input Code Page */
-    ApiMessage.Data.ConsoleCPRequest.InputCP  = TRUE;
-    ApiMessage.Data.ConsoleCPRequest.CodePage = 0;
-
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 NULL,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetCP),
-                                 sizeof(CONSOLE_GETSETINPUTOUTPUTCP));
+    GetConsoleCPRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+    GetConsoleCPRequest->OutputCP      = FALSE;
 
-    if (!NT_SUCCESS(Status)) BaseSetLastNTError(Status);
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        NULL,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetCP),
+                        sizeof(*GetConsoleCPRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
+    {
+        BaseSetLastNTError(ApiMessage.Status);
+        return 0;
+    }
 
-    return ApiMessage.Data.ConsoleCPRequest.CodePage;
+    return GetConsoleCPRequest->CodePage;
 }
 
 
@@ -1959,21 +1986,26 @@ BOOL
 WINAPI
 SetConsoleCP(UINT wCodePageID)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
+    PCONSOLE_SETINPUTOUTPUTCP SetConsoleCPRequest = &ApiMessage.Data.SetConsoleCPRequest;
 
     /* Set the Input Code Page */
-    ApiMessage.Data.ConsoleCPRequest.InputCP  = TRUE;
-    ApiMessage.Data.ConsoleCPRequest.CodePage = wCodePageID;
+    SetConsoleCPRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+    SetConsoleCPRequest->CodePage      = wCodePageID;
+    SetConsoleCPRequest->OutputCP      = FALSE;
+    /* SetConsoleCPRequest->EventHandle; */
 
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 NULL,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetCP),
-                                 sizeof(CONSOLE_GETSETINPUTOUTPUTCP));
-
-    if (!NT_SUCCESS(Status)) BaseSetLastNTError(Status);
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        NULL,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetCP),
+                        sizeof(*SetConsoleCPRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
+    {
+        BaseSetLastNTError(ApiMessage.Status);
+        return FALSE;
+    }
 
-    return NT_SUCCESS(Status);
+    return TRUE;
 }
 
 
@@ -1986,21 +2018,24 @@ UINT
 WINAPI
 GetConsoleOutputCP(VOID)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
+    PCONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest = &ApiMessage.Data.GetConsoleCPRequest;
 
     /* Get the Output Code Page */
-    ApiMessage.Data.ConsoleCPRequest.InputCP  = FALSE;
-    ApiMessage.Data.ConsoleCPRequest.CodePage = 0;
+    GetConsoleCPRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+    GetConsoleCPRequest->OutputCP      = TRUE;
 
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 NULL,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetCP),
-                                 sizeof(CONSOLE_GETSETINPUTOUTPUTCP));
-
-    if (!NT_SUCCESS(Status)) BaseSetLastNTError(Status);
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        NULL,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetCP),
+                        sizeof(*GetConsoleCPRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
+    {
+        BaseSetLastNTError(ApiMessage.Status);
+        return 0;
+    }
 
-    return ApiMessage.Data.ConsoleCPRequest.CodePage;
+    return GetConsoleCPRequest->CodePage;
 }
 
 
@@ -2013,21 +2048,26 @@ BOOL
 WINAPI
 SetConsoleOutputCP(UINT wCodePageID)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
+    PCONSOLE_SETINPUTOUTPUTCP SetConsoleCPRequest = &ApiMessage.Data.SetConsoleCPRequest;
 
     /* Set the Output Code Page */
-    ApiMessage.Data.ConsoleCPRequest.InputCP  = FALSE;
-    ApiMessage.Data.ConsoleCPRequest.CodePage = wCodePageID;
+    SetConsoleCPRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+    SetConsoleCPRequest->CodePage      = wCodePageID;
+    SetConsoleCPRequest->OutputCP      = TRUE;
+    /* SetConsoleCPRequest->EventHandle; */
 
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 NULL,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetCP),
-                                 sizeof(CONSOLE_GETSETINPUTOUTPUTCP));
-
-    if (!NT_SUCCESS(Status)) BaseSetLastNTError(Status);
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        NULL,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetCP),
+                        sizeof(*SetConsoleCPRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
+    {
+        BaseSetLastNTError(ApiMessage.Status);
+        return FALSE;
+    }
 
-    return NT_SUCCESS(Status);
+    return TRUE;
 }
 
 
@@ -2041,11 +2081,10 @@ WINAPI
 GetConsoleProcessList(LPDWORD lpdwProcessList,
                       DWORD dwProcessCount)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
     PCONSOLE_GETPROCESSLIST GetProcessListRequest = &ApiMessage.Data.GetProcessListRequest;
     PCSR_CAPTURE_BUFFER CaptureBuffer;
-    ULONG nProcesses;
+    ULONG nProcesses = 0;
 
     if (lpdwProcessList == NULL || dwProcessCount == 0)
     {
@@ -2058,30 +2097,30 @@ GetConsoleProcessList(LPDWORD lpdwProcessList,
     {
         DPRINT1("CsrAllocateCaptureBuffer failed!\n");
         SetLastError(ERROR_NOT_ENOUGH_MEMORY);
-        return FALSE;
+        return 0;
     }
 
-    GetProcessListRequest->nMaxIds = dwProcessCount;
+    GetProcessListRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+    GetProcessListRequest->ProcessCount  = dwProcessCount;
 
     CsrAllocateMessagePointer(CaptureBuffer,
                               dwProcessCount * sizeof(DWORD),
-                              (PVOID*)&GetProcessListRequest->pProcessIds);
+                              (PVOID*)&GetProcessListRequest->ProcessIdsList);
 
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 CaptureBuffer,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetProcessList),
-                                 sizeof(CONSOLE_GETPROCESSLIST));
-    if (!NT_SUCCESS(Status))
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        CaptureBuffer,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetProcessList),
+                        sizeof(*GetProcessListRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
     {
-        BaseSetLastNTError (Status);
-        nProcesses = 0;
+        BaseSetLastNTError(ApiMessage.Status);
     }
     else
     {
-        nProcesses = GetProcessListRequest->nProcessIdsTotal;
+        nProcesses = GetProcessListRequest->ProcessCount;
         if (dwProcessCount >= nProcesses)
         {
-            memcpy(lpdwProcessList, GetProcessListRequest->pProcessIds, nProcesses * sizeof(DWORD));
+            memcpy(lpdwProcessList, GetProcessListRequest->ProcessIdsList, nProcesses * sizeof(DWORD));
         }
     }
 
@@ -2099,8 +2138,8 @@ BOOL
 WINAPI
 GetConsoleSelectionInfo(PCONSOLE_SELECTION_INFO lpConsoleSelectionInfo)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
+    PCONSOLE_GETSELECTIONINFO GetSelectionInfoRequest = &ApiMessage.Data.GetSelectionInfoRequest;
 
     if (lpConsoleSelectionInfo == NULL)
     {
@@ -2108,17 +2147,19 @@ GetConsoleSelectionInfo(PCONSOLE_SELECTION_INFO lpConsoleSelectionInfo)
         return FALSE;
     }
 
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 NULL,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetSelectionInfo),
-                                 sizeof(CONSOLE_GETSELECTIONINFO));
-    if (!NT_SUCCESS(Status))
+    GetSelectionInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        NULL,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetSelectionInfo),
+                        sizeof(*GetSelectionInfoRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
     {
-        BaseSetLastNTError(Status);
+        BaseSetLastNTError(ApiMessage.Status);
         return FALSE;
     }
 
-    *lpConsoleSelectionInfo = ApiMessage.Data.GetSelectionInfoRequest.Info;
+    *lpConsoleSelectionInfo = GetSelectionInfoRequest->Info;
     return TRUE;
 }
 
@@ -2183,20 +2224,22 @@ HWND
 WINAPI
 GetConsoleWindow(VOID)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
+    PCONSOLE_GETWINDOW GetWindowRequest = &ApiMessage.Data.GetWindowRequest;
 
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 NULL,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetConsoleWindow),
-                                 sizeof(CONSOLE_GETWINDOW));
-    if (!NT_SUCCESS(Status))
+    GetWindowRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        NULL,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetConsoleWindow),
+                        sizeof(*GetWindowRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
     {
-        BaseSetLastNTError(Status);
+        BaseSetLastNTError(ApiMessage.Status);
         return (HWND)NULL;
     }
 
-    return ApiMessage.Data.GetWindowRequest.WindowHandle;
+    return GetWindowRequest->WindowHandle;
 }
 
 
@@ -2207,24 +2250,25 @@ GetConsoleWindow(VOID)
  */
 BOOL
 WINAPI
-SetConsoleIcon(HICON hicon)
+SetConsoleIcon(HICON hIcon)
 {
-    NTSTATUS Status;
     CONSOLE_API_MESSAGE ApiMessage;
+    PCONSOLE_SETICON SetIconRequest = &ApiMessage.Data.SetIconRequest;
 
-    ApiMessage.Data.SetIconRequest.WindowIcon = hicon;
+    SetIconRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+    SetIconRequest->IconHandle    = hIcon;
 
-    Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
-                                 NULL,
-                                 CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetIcon),
-                                 sizeof(CONSOLE_SETICON));
-    if (!NT_SUCCESS(Status))
+    CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+                        NULL,
+                        CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetIcon),
+                        sizeof(*SetIconRequest));
+    if (!NT_SUCCESS(ApiMessage.Status))
     {
-        BaseSetLastNTError(Status);
+        BaseSetLastNTError(ApiMessage.Status);
         return FALSE;
     }
 
-    return NT_SUCCESS(Status);
+    return TRUE;
 }
 
 
index f03a8b1..b36712c 100644 (file)
@@ -427,10 +427,10 @@ GetCurrentConsoleFont(
 #if (_WIN32_WINNT >= 0x0500)
 
 HWND WINAPI GetConsoleWindow(VOID);
-BOOL APIENTRY GetConsoleDisplayMode(_Out_ LPDWORD lpModeFlags);
+BOOL WINAPI GetConsoleDisplayMode(_Out_ LPDWORD lpModeFlags);
 
 BOOL
-APIENTRY
+WINAPI
 SetConsoleDisplayMode(
   _In_ HANDLE hConsoleOutput,
   _In_ DWORD dwFlags,
@@ -607,8 +607,16 @@ BOOL WINAPI SetConsoleMenuClose(_In_ BOOL);
 BOOL WINAPI SetConsoleCursor(_In_ HANDLE, _In_ HCURSOR);
 /* Undocumented, see http://undoc.airesoft.co.uk/kernel32.dll/ShowConsoleCursor.php */
 INT WINAPI ShowConsoleCursor(_In_ HANDLE, _In_ BOOL);
+/* Undocumented */
+BOOL WINAPI SetConsoleIcon(_In_ HICON);
 /* Undocumented, see http://comments.gmane.org/gmane.comp.lang.harbour.devel/27844 */
 BOOL WINAPI SetConsolePalette(_In_ HANDLE, _In_ HPALETTE, _In_ UINT);
+/* Undocumented */
+BOOL WINAPI CloseConsoleHandle(_In_ HANDLE);
+// HANDLE WINAPI GetStdHandle(_In_ DWORD);
+// BOOL WINAPI SetStdHandle(_In_ DWORD, _In_ HANDLE);
+/* Undocumented */
+BOOL WINAPI VerifyConsoleIoHandle(_In_ HANDLE);
 
 BOOL
 WINAPI
index 71284ce..04bb3bd 100644 (file)
@@ -197,9 +197,9 @@ C_ASSERT(sizeof(CONSRV_API_CONNECTINFO) == 0x638);
 
 typedef struct
 {
-    ULONG  nMaxIds;
-    ULONG  nProcessIdsTotal;
-    PDWORD pProcessIds;
+    HANDLE ConsoleHandle;
+    ULONG  ProcessCount;
+    PDWORD ProcessIdsList;
 } CONSOLE_GETPROCESSLIST, *PCONSOLE_GETPROCESSLIST;
 
 typedef struct
@@ -262,8 +262,14 @@ typedef struct
 
 typedef struct
 {
+    HANDLE ConsoleHandle;
     HANDLE OutputHandle;
-    CONSOLE_SCREEN_BUFFER_INFO Info;
+    COORD  ScreenBufferSize;
+    COORD  CursorPosition;
+    COORD  ViewOrigin;
+    WORD   Attributes;
+    COORD  ViewSize;
+    COORD  MaximumViewSize;
 } CONSOLE_GETSCREENBUFFERINFO, *PCONSOLE_GETSCREENBUFFERINFO;
 
 typedef struct
@@ -274,6 +280,7 @@ typedef struct
 
 typedef struct
 {
+    HANDLE ConsoleHandle;
     HANDLE OutputHandle;
     BOOL   Show;
     INT    RefCount;
@@ -281,8 +288,9 @@ typedef struct
 
 typedef struct
 {
+    HANDLE  ConsoleHandle;
     HANDLE  OutputHandle;
-    HCURSOR hCursor;
+    HCURSOR CursorHandle;
 } CONSOLE_SETCURSOR, *PCONSOLE_SETCURSOR;
 
 typedef struct
@@ -305,15 +313,17 @@ typedef struct
 
 typedef struct
 {
-    // HANDLE OutputHandle;
-    DWORD  DisplayMode;
+    HANDLE ConsoleHandle;
+    DWORD  DisplayMode; // ModeFlags
 } CONSOLE_GETDISPLAYMODE, *PCONSOLE_GETDISPLAYMODE;
 
 typedef struct
 {
+    HANDLE ConsoleHandle;
     HANDLE OutputHandle;
-    DWORD  DisplayMode;
+    DWORD  DisplayMode; // ModeFlags
     COORD  NewSBDim;
+    HANDLE EventHandle;
 } CONSOLE_SETDISPLAYMODE, *PCONSOLE_SETDISPLAYMODE;
 
 /*
@@ -324,7 +334,9 @@ typedef struct
 
 typedef struct
 {
+    HANDLE ConsoleHandle;
     HANDLE OutputHandle;
+    DWORD  Flags;
     DWORD  State;
 } CONSOLE_GETSETHWSTATE, *PCONSOLE_GETSETHWSTATE;
 
@@ -351,12 +363,14 @@ typedef struct
 
 typedef struct
 {
+    HANDLE ConsoleHandle;
     HANDLE OutputHandle;
     SMALL_RECT Region;
 } CONSOLE_INVALIDATEDIBITS, *PCONSOLE_INVALIDATEDIBITS;
 
 typedef struct
 {
+    HANDLE   ConsoleHandle;
     HANDLE   OutputHandle;
     HPALETTE PaletteHandle;
     UINT     Usage;
@@ -501,11 +515,14 @@ typedef struct
 typedef struct
 {
     HANDLE ConsoleHandle;
+    HANDLE Handle;
 } CONSOLE_CLOSEHANDLE, *PCONSOLE_CLOSEHANDLE;
 
 typedef struct
 {
+    BOOL   IsValid;
     HANDLE ConsoleHandle;
+    HANDLE Handle;
 } CONSOLE_VERIFYHANDLE, *PCONSOLE_VERIFYHANDLE;
 
 typedef struct
@@ -543,15 +560,17 @@ typedef struct
 
 typedef struct
 {
+    HANDLE ConsoleHandle;
     HANDLE OutputHandle;
-    DWORD  dwCmdIdLow;
-    DWORD  dwCmdIdHigh;
-    HMENU  hMenu;
+    DWORD  CmdIdLow;
+    DWORD  CmdIdHigh;
+    HMENU  MenuHandle;
 } CONSOLE_MENUCONTROL, *PCONSOLE_MENUCONTROL;
 
 typedef struct
 {
-    BOOL Enable;
+    HANDLE ConsoleHandle;
+    BOOL   Enable;
 } CONSOLE_SETMENUCLOSE, *PCONSOLE_SETMENUCLOSE;
 
 typedef struct
@@ -564,12 +583,14 @@ typedef struct
 
 typedef struct
 {
-    HWND WindowHandle;
+    HANDLE ConsoleHandle;
+    HWND   WindowHandle;
 } CONSOLE_GETWINDOW, *PCONSOLE_GETWINDOW;
 
 typedef struct
 {
-    HICON WindowIcon;
+    HANDLE ConsoleHandle;
+    HICON  IconHandle;
 } CONSOLE_SETICON, *PCONSOLE_SETICON;
 
 
@@ -665,14 +686,24 @@ typedef struct
 
 typedef struct
 {
+    HANDLE ConsoleHandle;
     CONSOLE_SELECTION_INFO Info;
 } CONSOLE_GETSELECTIONINFO, *PCONSOLE_GETSELECTIONINFO;
 
 typedef struct
 {
-    BOOL InputCP;   // TRUE : Input Code Page ; FALSE : Output Code Page
-    UINT CodePage;
-} CONSOLE_GETSETINPUTOUTPUTCP, *PCONSOLE_GETSETINPUTOUTPUTCP;
+    HANDLE ConsoleHandle;
+    UINT   CodePage;
+    BOOL   OutputCP;    // TRUE : Output Code Page ; FALSE : Input Code Page
+} CONSOLE_GETINPUTOUTPUTCP, *PCONSOLE_GETINPUTOUTPUTCP;
+
+typedef struct
+{
+    HANDLE ConsoleHandle;
+    UINT   CodePage;
+    BOOL   OutputCP;    // TRUE : Output Code Page ; FALSE : Input Code Page
+    HANDLE EventHandle;
+} CONSOLE_SETINPUTOUTPUTCP, *PCONSOLE_SETINPUTOUTPUTCP;
 
 typedef struct _CONSOLE_API_MESSAGE
 {
@@ -764,7 +795,8 @@ typedef struct _CONSOLE_API_MESSAGE
         CONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest;
 
         /* Input and Output Code Pages */
-        CONSOLE_GETSETINPUTOUTPUTCP ConsoleCPRequest;
+        CONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest;
+        CONSOLE_SETINPUTOUTPUTCP SetConsoleCPRequest;
     } Data;
 } CONSOLE_API_MESSAGE, *PCONSOLE_API_MESSAGE;
 
index ccc1189..338be5a 100644 (file)
@@ -1007,12 +1007,12 @@ ConDrvSetConsoleTitle(IN PCONSOLE Console,
 NTSTATUS NTAPI
 ConDrvGetConsoleCP(IN PCONSOLE Console,
                    OUT PUINT CodePage,
-                   IN BOOLEAN InputCP)
+                   IN BOOLEAN OutputCP)
 {
     if (Console == NULL || CodePage == NULL)
         return STATUS_INVALID_PARAMETER;
 
-    *CodePage = (InputCP ? Console->CodePage : Console->OutputCodePage);
+    *CodePage = (OutputCP ? Console->OutputCodePage : Console->CodePage);
 
     return STATUS_SUCCESS;
 }
@@ -1020,15 +1020,15 @@ ConDrvGetConsoleCP(IN PCONSOLE Console,
 NTSTATUS NTAPI
 ConDrvSetConsoleCP(IN PCONSOLE Console,
                    IN UINT CodePage,
-                   IN BOOLEAN InputCP)
+                   IN BOOLEAN OutputCP)
 {
     if (Console == NULL || !IsValidCodePage(CodePage))
         return STATUS_INVALID_PARAMETER;
 
-    if (InputCP)
-        Console->CodePage = CodePage;
-    else
+    if (OutputCP)
         Console->OutputCodePage = CodePage;
+    else
+        Console->CodePage = CodePage;
 
     return STATUS_SUCCESS;
 }
index 85a54be..794aae2 100644 (file)
@@ -99,7 +99,7 @@ DummyChangeTitle(IN OUT PFRONTEND This)
 
 static BOOL NTAPI
 DummyChangeIcon(IN OUT PFRONTEND This,
-                HICON hWindowIcon)
+                HICON IconHandle)
 {
     return TRUE;
 }
@@ -146,15 +146,15 @@ DummyShowMouseCursor(IN OUT PFRONTEND This,
 
 static BOOL NTAPI
 DummySetMouseCursor(IN OUT PFRONTEND This,
-                    HCURSOR hCursor)
+                    HCURSOR CursorHandle)
 {
     return TRUE;
 }
 
 static HMENU NTAPI
 DummyMenuControl(IN OUT PFRONTEND This,
-                 UINT cmdIdLow,
-                 UINT cmdIdHigh)
+                 UINT CmdIdLow,
+                 UINT CmdIdHigh)
 {
     return NULL;
 }
index 7c44235..5c1ab10 100644 (file)
@@ -1153,26 +1153,33 @@ ConDrvFillConsoleOutput(IN PCONSOLE Console,
 }
 
 NTSTATUS NTAPI
-ConDrvGetConsoleScreenBufferInfo(IN PCONSOLE Console,
-                                 IN PTEXTMODE_SCREEN_BUFFER Buffer,
-                                 OUT PCONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo)
+ConDrvGetConsoleScreenBufferInfo(IN  PCONSOLE Console,
+                                 IN  PTEXTMODE_SCREEN_BUFFER Buffer,
+                                 OUT PCOORD ScreenBufferSize,
+                                 OUT PCOORD CursorPosition,
+                                 OUT PCOORD ViewOrigin,
+                                 OUT PCOORD ViewSize,
+                                 OUT PCOORD MaximumViewSize,
+                                 OUT PWORD  Attributes)
 {
-    if (Console == NULL || Buffer == NULL || ScreenBufferInfo == NULL)
+    if (Console == NULL || Buffer == NULL || ScreenBufferSize == NULL ||
+        CursorPosition  == NULL || ViewOrigin == NULL || ViewSize == NULL ||
+        MaximumViewSize == NULL || Attributes == NULL)
+    {
         return STATUS_INVALID_PARAMETER;
+    }
 
     /* Validity check */
     ASSERT(Console == Buffer->Header.Console);
 
-    ScreenBufferInfo->dwSize              = Buffer->ScreenBufferSize;
-    ScreenBufferInfo->dwCursorPosition    = Buffer->CursorPosition;
-    ScreenBufferInfo->wAttributes         = Buffer->ScreenDefaultAttrib;
-    ScreenBufferInfo->srWindow.Left       = Buffer->ViewOrigin.X;
-    ScreenBufferInfo->srWindow.Top        = Buffer->ViewOrigin.Y;
-    ScreenBufferInfo->srWindow.Right      = Buffer->ViewOrigin.X + Buffer->ViewSize.X - 1;
-    ScreenBufferInfo->srWindow.Bottom     = Buffer->ViewOrigin.Y + Buffer->ViewSize.Y - 1;
+    *ScreenBufferSize = Buffer->ScreenBufferSize;
+    *CursorPosition   = Buffer->CursorPosition;
+    *ViewOrigin       = Buffer->ViewOrigin;
+    *ViewSize         = Buffer->ViewSize;
+    *Attributes       = Buffer->ScreenDefaultAttrib;
 
     // FIXME: Refine the computation
-    ScreenBufferInfo->dwMaximumWindowSize = Buffer->ScreenBufferSize;
+    *MaximumViewSize  = Buffer->ScreenBufferSize;
 
     return STATUS_SUCCESS;
 }
index d2571b1..fe04b8b 100644 (file)
@@ -683,9 +683,14 @@ CSR_API(SrvFillConsoleOutput)
 }
 
 NTSTATUS NTAPI
-ConDrvGetConsoleScreenBufferInfo(IN PCONSOLE Console,
-                                 IN PTEXTMODE_SCREEN_BUFFER Buffer,
-                                 OUT PCONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo);
+ConDrvGetConsoleScreenBufferInfo(IN  PCONSOLE Console,
+                                 IN  PTEXTMODE_SCREEN_BUFFER Buffer,
+                                 OUT PCOORD ScreenBufferSize,
+                                 OUT PCOORD CursorPosition,
+                                 OUT PCOORD ViewOrigin,
+                                 OUT PCOORD ViewSize,
+                                 OUT PCOORD MaximumViewSize,
+                                 OUT PWORD  Attributes);
 CSR_API(SrvGetConsoleScreenBufferInfo)
 {
     NTSTATUS Status;
@@ -701,7 +706,12 @@ CSR_API(SrvGetConsoleScreenBufferInfo)
 
     Status = ConDrvGetConsoleScreenBufferInfo(Buffer->Header.Console,
                                               Buffer,
-                                              &ScreenBufferInfoRequest->Info);
+                                              &ScreenBufferInfoRequest->ScreenBufferSize,
+                                              &ScreenBufferInfoRequest->CursorPosition,
+                                              &ScreenBufferInfoRequest->ViewOrigin,
+                                              &ScreenBufferInfoRequest->ViewSize,
+                                              &ScreenBufferInfoRequest->MaximumViewSize,
+                                              &ScreenBufferInfoRequest->Attributes);
 
     ConSrvReleaseScreenBuffer(Buffer, TRUE);
     return Status;
index f9152e0..8cc401a 100644 (file)
@@ -543,22 +543,22 @@ CSR_API(SrvSetConsoleTitle)
 NTSTATUS NTAPI
 ConDrvGetConsoleCP(IN PCONSOLE Console,
                    OUT PUINT CodePage,
-                   IN BOOLEAN InputCP);
+                   IN BOOLEAN OutputCP);
 CSR_API(SrvGetConsoleCP)
 {
     NTSTATUS Status;
-    PCONSOLE_GETSETINPUTOUTPUTCP ConsoleCPRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleCPRequest;
+    PCONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetConsoleCPRequest;
     PCONSOLE Console;
 
     DPRINT("SrvGetConsoleCP, getting %s Code Page\n",
-            ConsoleCPRequest->InputCP ? "Input" : "Output");
+            GetConsoleCPRequest->OutputCP ? "Output" : "Input");
 
     Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
     if (!NT_SUCCESS(Status)) return Status;
 
     Status = ConDrvGetConsoleCP(Console,
-                                &ConsoleCPRequest->CodePage,
-                                ConsoleCPRequest->InputCP);
+                                &GetConsoleCPRequest->CodePage,
+                                GetConsoleCPRequest->OutputCP);
 
     ConSrvReleaseConsole(Console, TRUE);
     return Status;
@@ -567,22 +567,22 @@ CSR_API(SrvGetConsoleCP)
 NTSTATUS NTAPI
 ConDrvSetConsoleCP(IN PCONSOLE Console,
                    IN UINT CodePage,
-                   IN BOOLEAN InputCP);
+                   IN BOOLEAN OutputCP);
 CSR_API(SrvSetConsoleCP)
 {
     NTSTATUS Status = STATUS_INVALID_PARAMETER;
-    PCONSOLE_GETSETINPUTOUTPUTCP ConsoleCPRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleCPRequest;
+    PCONSOLE_SETINPUTOUTPUTCP SetConsoleCPRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetConsoleCPRequest;
     PCONSOLE Console;
 
     DPRINT("SrvSetConsoleCP, setting %s Code Page\n",
-            ConsoleCPRequest->InputCP ? "Input" : "Output");
+            SetConsoleCPRequest->OutputCP ? "Output" : "Input");
 
     Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
     if (!NT_SUCCESS(Status)) return Status;
 
     Status = ConDrvSetConsoleCP(Console,
-                                ConsoleCPRequest->CodePage,
-                                ConsoleCPRequest->InputCP);
+                                SetConsoleCPRequest->CodePage,
+                                SetConsoleCPRequest->OutputCP);
 
     ConSrvReleaseConsole(Console, TRUE);
     return Status;
@@ -600,8 +600,8 @@ CSR_API(SrvGetConsoleProcessList)
     PCONSOLE Console;
 
     if (!CsrValidateMessageBuffer(ApiMessage,
-                                  (PVOID)&GetProcessListRequest->pProcessIds,
-                                  GetProcessListRequest->nMaxIds,
+                                  (PVOID)&GetProcessListRequest->ProcessIdsList,
+                                  GetProcessListRequest->ProcessCount,
                                   sizeof(DWORD)))
     {
         return STATUS_INVALID_PARAMETER;
@@ -611,9 +611,9 @@ CSR_API(SrvGetConsoleProcessList)
     if (!NT_SUCCESS(Status)) return Status;
 
     Status = ConDrvGetConsoleProcessList(Console,
-                                         GetProcessListRequest->pProcessIds,
-                                         GetProcessListRequest->nMaxIds,
-                                         &GetProcessListRequest->nProcessIdsTotal);
+                                         GetProcessListRequest->ProcessIdsList,
+                                         GetProcessListRequest->ProcessCount,
+                                         &GetProcessListRequest->ProcessCount);
 
     ConSrvReleaseConsole(Console, TRUE);
     return Status;
index 5d175b4..7294fa7 100644 (file)
@@ -222,7 +222,7 @@ CSR_API(SrvSetConsoleCursor)
 
     Console = Buff->Header.Console;
 
-    Success = TermSetMouseCursor(Console, SetCursorRequest->hCursor);
+    Success = TermSetMouseCursor(Console, SetCursorRequest->CursorHandle);
 
     ConSrvReleaseScreenBuffer(Buff, TRUE);
     return (Success ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL);
@@ -244,9 +244,9 @@ CSR_API(SrvConsoleMenuControl)
 
     Console = Buff->Header.Console;
 
-    MenuControlRequest->hMenu = TermMenuControl(Console,
-                                                MenuControlRequest->dwCmdIdLow,
-                                                MenuControlRequest->dwCmdIdHigh);
+    MenuControlRequest->MenuHandle = TermMenuControl(Console,
+                                                     MenuControlRequest->CmdIdLow,
+                                                     MenuControlRequest->CmdIdHigh);
 
     ConSrvReleaseScreenBuffer(Buff, TRUE);
     return STATUS_SUCCESS;
@@ -293,7 +293,7 @@ CSR_API(SrvSetConsoleIcon)
     Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
     if (!NT_SUCCESS(Status)) return Status;
 
-    Status = (TermChangeIcon(Console, SetIconRequest->WindowIcon)
+    Status = (TermChangeIcon(Console, SetIconRequest->IconHandle)
                 ? STATUS_SUCCESS
                 : STATUS_UNSUCCESSFUL);
 
index 9851a36..5041dad 100644 (file)
@@ -64,8 +64,8 @@ typedef struct _GUI_CONSOLE_DATA
     BOOL IgnoreNextMouseSignal; /* Used in cases where we don't want to treat a mouse signal */
 
     BOOL IsCloseButtonEnabled;  /* TRUE if the Close button and the corresponding system menu item are enabled (default), FALSE otherwise */
-    UINT cmdIdLow ;             /* Lowest menu id of the user-reserved menu id range */
-    UINT cmdIdHigh;             /* Highest menu id of the user-reserved menu id range */
+    UINT CmdIdLow ;             /* Lowest menu id of the user-reserved menu id range */
+    UINT CmdIdHigh;             /* Highest menu id of the user-reserved menu id range */
 
 //  COLORREF Colors[16];
 
index 7db806c..bffeeca 100644 (file)
@@ -231,6 +231,7 @@ GuiSendMenuEvent(PCONSOLE Console, UINT CmdId)
     er.EventType = MENU_EVENT;
     er.Event.MenuEvent.dwCommandId = CmdId;
 
+    DPRINT1("Menu item ID: %d\n", CmdId);
     ConioProcessInputEvent(Console, &er);
 }
 
@@ -265,7 +266,7 @@ GuiConsoleHandleSysMenuCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM
      * send to him a menu event and return directly. The user must handle those
      * reserved menu commands...
      */
-    if (GuiData->cmdIdLow <= (UINT)wParam && (UINT)wParam <= GuiData->cmdIdHigh)
+    if (GuiData->CmdIdLow <= (UINT)wParam && (UINT)wParam <= GuiData->CmdIdHigh)
     {
         GuiSendMenuEvent(Console, (UINT)wParam);
         goto Unlock_Quit;
@@ -2462,7 +2463,7 @@ GuiInitFrontEnd(IN OUT PFRONTEND This,
     GuiData->IsCloseButtonEnabled = TRUE;
 
     /* There is no user-reserved menu id range by default */
-    GuiData->cmdIdLow = GuiData->cmdIdHigh = 0;
+    GuiData->CmdIdLow = GuiData->CmdIdHigh = 0;
 
     /*
      * We need to wait until the GUI has been fully initialized
@@ -2747,7 +2748,7 @@ GuiProcessKeyCallback(IN OUT PFRONTEND This,
 
 static BOOL NTAPI
 GuiSetMouseCursor(IN OUT PFRONTEND This,
-                  HCURSOR hCursor);
+                  HCURSOR CursorHandle);
 
 static VOID NTAPI
 GuiRefreshInternalInfo(IN OUT PFRONTEND This)
@@ -2781,20 +2782,20 @@ GuiChangeTitle(IN OUT PFRONTEND This)
 
 static BOOL NTAPI
 GuiChangeIcon(IN OUT PFRONTEND This,
-              HICON hWindowIcon)
+              HICON IconHandle)
 {
     PGUI_CONSOLE_DATA GuiData = This->Data;
     HICON hIcon, hIconSm;
 
-    if (hWindowIcon == NULL)
+    if (IconHandle == NULL)
     {
         hIcon   = ghDefaultIcon;
         hIconSm = ghDefaultIconSm;
     }
     else
     {
-        hIcon   = CopyIcon(hWindowIcon);
-        hIconSm = CopyIcon(hWindowIcon);
+        hIcon   = CopyIcon(IconHandle);
+        hIconSm = CopyIcon(IconHandle);
     }
 
     if (hIcon == NULL)
@@ -2953,7 +2954,7 @@ GuiShowMouseCursor(IN OUT PFRONTEND This,
 
 static BOOL NTAPI
 GuiSetMouseCursor(IN OUT PFRONTEND This,
-                  HCURSOR hCursor)
+                  HCURSOR CursorHandle)
 {
     PGUI_CONSOLE_DATA GuiData = This->Data;
 
@@ -2961,7 +2962,7 @@ GuiSetMouseCursor(IN OUT PFRONTEND This,
      * Set the cursor's handle. If the given handle is NULL,
      * then restore the default cursor.
      */
-    GuiData->hCursor = (hCursor ? hCursor : ghDefaultCursor);
+    GuiData->hCursor = (CursorHandle ? CursorHandle : ghDefaultCursor);
 
     /* Effectively modify the shape of the cursor (use special values for (w|l)Param) */
     PostMessageW(GuiData->hWindow, WM_SETCURSOR, -1, -1);
@@ -2971,13 +2972,13 @@ GuiSetMouseCursor(IN OUT PFRONTEND This,
 
 static HMENU NTAPI
 GuiMenuControl(IN OUT PFRONTEND This,
-               UINT cmdIdLow,
-               UINT cmdIdHigh)
+               UINT CmdIdLow,
+               UINT CmdIdHigh)
 {
     PGUI_CONSOLE_DATA GuiData = This->Data;
 
-    GuiData->cmdIdLow  = cmdIdLow ;
-    GuiData->cmdIdHigh = cmdIdHigh;
+    GuiData->CmdIdLow  = CmdIdLow ;
+    GuiData->CmdIdHigh = CmdIdHigh;
 
     return GetSystemMenu(GuiData->hWindow, FALSE);
 }
index 4586f7d..0f3a8da 100644 (file)
@@ -726,7 +726,7 @@ TuiChangeTitle(IN OUT PFRONTEND This)
 
 static BOOL NTAPI
 TuiChangeIcon(IN OUT PFRONTEND This,
-              HICON hWindowIcon)
+              HICON IconHandle)
 {
     return TRUE;
 }
@@ -778,15 +778,15 @@ TuiShowMouseCursor(IN OUT PFRONTEND This,
 
 static BOOL NTAPI
 TuiSetMouseCursor(IN OUT PFRONTEND This,
-                  HCURSOR hCursor)
+                  HCURSOR CursorHandle)
 {
     return TRUE;
 }
 
 static HMENU NTAPI
 TuiMenuControl(IN OUT PFRONTEND This,
-               UINT cmdIdLow,
-               UINT cmdIdHigh)
+               UINT CmdIdLow,
+               UINT CmdIdHigh)
 {
     return NULL;
 }
index e51479d..9f268d2 100644 (file)
@@ -836,7 +836,7 @@ CSR_API(SrvCloseHandle)
         return Status;
     }
 
-    Status = ConSrvRemoveObject(ProcessData, CloseHandleRequest->ConsoleHandle);
+    Status = ConSrvRemoveObject(ProcessData, CloseHandleRequest->Handle);
 
     ConSrvReleaseConsole(Console, TRUE);
     return Status;
@@ -849,8 +849,10 @@ CSR_API(SrvVerifyConsoleIoHandle)
     PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
     PCONSOLE Console;
 
-    HANDLE ConsoleHandle = VerifyHandleRequest->ConsoleHandle;
-    ULONG Index = HandleToULong(ConsoleHandle) >> 2;
+    HANDLE IoHandle = VerifyHandleRequest->Handle;
+    ULONG Index = HandleToULong(IoHandle) >> 2;
+
+    VerifyHandleRequest->IsValid = FALSE;
 
     Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
     if (!NT_SUCCESS(Status))
@@ -864,18 +866,21 @@ CSR_API(SrvVerifyConsoleIoHandle)
     // ASSERT( (ProcessData->HandleTable == NULL && ProcessData->HandleTableSize == 0) ||
     //         (ProcessData->HandleTable != NULL && ProcessData->HandleTableSize != 0) );
 
-    if (!IsConsoleHandle(ConsoleHandle)    ||
+    if (!IsConsoleHandle(IoHandle)            ||
         Index >= ProcessData->HandleTableSize ||
         ProcessData->HandleTable[Index].Object == NULL)
     {
         DPRINT("SrvVerifyConsoleIoHandle failed\n");
-        Status = STATUS_INVALID_HANDLE;
+    }
+    else
+    {
+        VerifyHandleRequest->IsValid = TRUE;
     }
 
     RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
 
     ConSrvReleaseConsole(Console, TRUE);
-    return Status;
+    return STATUS_SUCCESS;
 }
 
 /* EOF */
index c54dab7..a60e95f 100644 (file)
@@ -224,7 +224,7 @@ typedef struct _FRONTEND_VTBL
      */
     VOID (NTAPI *ChangeTitle)(IN OUT PFRONTEND This);
     BOOL (NTAPI *ChangeIcon)(IN OUT PFRONTEND This,
-                             HICON hWindowIcon);
+                             HICON IconHandle);
     HWND (NTAPI *GetConsoleWindowHandle)(IN OUT PFRONTEND This);
     VOID (NTAPI *GetLargestConsoleWindowSize)(IN OUT PFRONTEND This,
                                               PCOORD pSize);
@@ -237,10 +237,10 @@ typedef struct _FRONTEND_VTBL
     INT   (NTAPI *ShowMouseCursor)(IN OUT PFRONTEND This,
                                    BOOL Show);
     BOOL  (NTAPI *SetMouseCursor)(IN OUT PFRONTEND This,
-                                  HCURSOR hCursor);
+                                  HCURSOR CursorHandle);
     HMENU (NTAPI *MenuControl)(IN OUT PFRONTEND This,
-                               UINT cmdIdLow,
-                               UINT cmdIdHigh);
+                               UINT CmdIdLow,
+                               UINT CmdIdHigh);
     BOOL  (NTAPI *SetMenuClose)(IN OUT PFRONTEND This,
                                 BOOL Enable);
 
index f82025f..c8c68ae 100644 (file)
@@ -32,8 +32,8 @@
 
 #define TermChangeTitle(Console) \
     (Console)->TermIFace.Vtbl->ChangeTitle(&(Console)->TermIFace)
-#define TermChangeIcon(Console, hWindowIcon) \
-    (Console)->TermIFace.Vtbl->ChangeIcon(&(Console)->TermIFace, (hWindowIcon))
+#define TermChangeIcon(Console, IconHandle) \
+    (Console)->TermIFace.Vtbl->ChangeIcon(&(Console)->TermIFace, (IconHandle))
 #define TermGetConsoleWindowHandle(Console) \
     (Console)->TermIFace.Vtbl->GetConsoleWindowHandle(&(Console)->TermIFace)
 #define TermGetLargestConsoleWindowSize(Console, pSize) \
@@ -46,8 +46,8 @@
     (Console)->TermIFace.Vtbl->SetDisplayMode(&(Console)->TermIFace, (NewMode))
 #define TermShowMouseCursor(Console, Show) \
     (Console)->TermIFace.Vtbl->ShowMouseCursor(&(Console)->TermIFace, (Show))
-#define TermSetMouseCursor(Console, hCursor) \
-    (Console)->TermIFace.Vtbl->SetMouseCursor(&(Console)->TermIFace, (hCursor))
+#define TermSetMouseCursor(Console, CursorHandle) \
+    (Console)->TermIFace.Vtbl->SetMouseCursor(&(Console)->TermIFace, (CursorHandle))
 #define TermMenuControl(Console, CmdIdLow, CmdIdHigh) \
     (Console)->TermIFace.Vtbl->MenuControl(&(Console)->TermIFace, (CmdIdLow), (CmdIdHigh))
 #define TermSetMenuClose(Console, Enable) \