Author: hbelusca
Date: Sat Nov 17 23:45:14 2012
New Revision: 57726
URL:
http://svn.reactos.org/svn/reactos?rev=57726&view=rev
Log:
[KERNEL32]
- Add some NULL checks.
- Use new structures and api indices namings.
Modified:
branches/ros-csrss/dll/win32/kernel32/client/console/console.c
branches/ros-csrss/include/reactos/subsys/win/conmsg.h
Modified: branches/ros-csrss/dll/win32/kernel32/client/console/console.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
==============================================================================
--- branches/ros-csrss/dll/win32/kernel32/client/console/console.c [iso-8859-1]
(original)
+++ branches/ros-csrss/dll/win32/kernel32/client/console/console.c [iso-8859-1] Sat Nov 17
23:45:14 2012
@@ -864,6 +864,12 @@
NTSTATUS Status;
CONSOLE_API_MESSAGE ApiMessage;
+ if (lpConsoleScreenBufferInfo == NULL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
ApiMessage.Data.ScreenBufferInfoRequest.ConsoleHandle = hConsoleOutput;
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
@@ -954,8 +960,8 @@
GetNumberOfConsoleInputEvents(HANDLE hConsoleInput,
LPDWORD lpNumberOfEvents)
{
- CSR_API_MESSAGE Request;
- NTSTATUS Status;
+ NTSTATUS Status;
+ CONSOLE_API_MESSAGE ApiMessage;
if (lpNumberOfEvents == NULL)
{
@@ -963,19 +969,19 @@
return FALSE;
}
- Request.Data.GetNumInputEventsRequest.ConsoleHandle = hConsoleInput;
-
- Status = CsrClientCallServer(&Request,
- NULL,
- CSR_CREATE_API_NUMBER(CSR_CONSOLE,
GET_NUM_INPUT_EVENTS),
- sizeof(CSR_API_MESSAGE));
- if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
- {
- BaseSetLastNTError(Status);
- return FALSE;
- }
-
- *lpNumberOfEvents = Request.Data.GetNumInputEventsRequest.NumInputEvents;
+ ApiMessage.Data.GetNumInputEventsRequest.ConsoleHandle = hConsoleInput;
+
+ Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepGetNumberOfInputEvents),
+ sizeof(CSRSS_GET_NUM_INPUT_EVENTS));
+ if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status))
+ {
+ BaseSetLastNTError(Status);
+ return FALSE;
+ }
+
+ *lpNumberOfEvents = ApiMessage.Data.GetNumInputEventsRequest.NumInputEvents;
return TRUE;
}
@@ -1093,16 +1099,16 @@
WINAPI
SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput)
{
- CSR_API_MESSAGE Request;
- NTSTATUS Status;
-
- Request.Data.SetScreenBufferRequest.OutputHandle = hConsoleOutput;
-
- Status = CsrClientCallServer(&Request,
- NULL,
- CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_SCREEN_BUFFER),
- sizeof(CSR_API_MESSAGE));
- if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
+ NTSTATUS Status;
+ CONSOLE_API_MESSAGE ApiMessage;
+
+ ApiMessage.Data.SetScreenBufferRequest.OutputHandle = hConsoleOutput;
+
+ Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepSetActiveScreenBuffer),
+ sizeof(CSRSS_SET_SCREEN_BUFFER));
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status))
{
BaseSetLastNTError(Status);
return FALSE;
@@ -1121,16 +1127,16 @@
WINAPI
FlushConsoleInputBuffer(HANDLE hConsoleInput)
{
- CSR_API_MESSAGE Request;
- NTSTATUS Status;
-
- Request.Data.FlushInputBufferRequest.ConsoleInput = hConsoleInput;
-
- Status = CsrClientCallServer(&Request,
- NULL,
- CSR_CREATE_API_NUMBER(CSR_CONSOLE, FLUSH_INPUT_BUFFER),
- sizeof(CSR_API_MESSAGE));
- if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
+ NTSTATUS Status;
+ CONSOLE_API_MESSAGE ApiMessage;
+
+ ApiMessage.Data.FlushInputBufferRequest.ConsoleInput = hConsoleInput;
+
+ Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepFlushInputBuffer),
+ sizeof(CSRSS_FLUSH_INPUT_BUFFER));
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status))
{
BaseSetLastNTError(Status);
return FALSE;
@@ -1150,17 +1156,17 @@
SetConsoleScreenBufferSize(HANDLE hConsoleOutput,
COORD dwSize)
{
- CSR_API_MESSAGE Request;
- NTSTATUS Status;
-
- Request.Data.SetScreenBufferSize.OutputHandle = hConsoleOutput;
- Request.Data.SetScreenBufferSize.Size = dwSize;
-
- Status = CsrClientCallServer(&Request,
- NULL,
- CSR_CREATE_API_NUMBER(CSR_CONSOLE,
SET_SCREEN_BUFFER_SIZE),
- sizeof(CSR_API_MESSAGE));
- if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
+ NTSTATUS Status;
+ CONSOLE_API_MESSAGE ApiMessage;
+
+ ApiMessage.Data.SetScreenBufferSize.OutputHandle = hConsoleOutput;
+ ApiMessage.Data.SetScreenBufferSize.Size = dwSize;
+
+ Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepSetScreenBufferSize),
+ sizeof(CSRSS_SET_SCREEN_BUFFER_SIZE));
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status))
{
BaseSetLastNTError(Status);
return FALSE;
@@ -1209,32 +1215,33 @@
const CHAR_INFO *lpFill,
BOOL bUnicode)
{
- CSR_API_MESSAGE Request;
- NTSTATUS Status;
-
- Request.Data.ScrollConsoleScreenBufferRequest.ConsoleHandle = hConsoleOutput;
- Request.Data.ScrollConsoleScreenBufferRequest.Unicode = bUnicode;
- Request.Data.ScrollConsoleScreenBufferRequest.ScrollRectangle = *lpScrollRectangle;
+ NTSTATUS Status;
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCSRSS_SCROLL_CONSOLE_SCREEN_BUFFER ScrollConsoleScreenBufferRequest =
&ApiMessage.Data.ScrollConsoleScreenBufferRequest;
+
+ ScrollConsoleScreenBufferRequest->ConsoleHandle = hConsoleOutput;
+ ScrollConsoleScreenBufferRequest->Unicode = bUnicode;
+ ScrollConsoleScreenBufferRequest->ScrollRectangle = *lpScrollRectangle;
if (lpClipRectangle != NULL)
{
- Request.Data.ScrollConsoleScreenBufferRequest.UseClipRectangle = TRUE;
- Request.Data.ScrollConsoleScreenBufferRequest.ClipRectangle = *lpClipRectangle;
+ ScrollConsoleScreenBufferRequest->UseClipRectangle = TRUE;
+ ScrollConsoleScreenBufferRequest->ClipRectangle = *lpClipRectangle;
}
else
{
- Request.Data.ScrollConsoleScreenBufferRequest.UseClipRectangle = FALSE;
- }
-
- Request.Data.ScrollConsoleScreenBufferRequest.DestinationOrigin =
dwDestinationOrigin;
- Request.Data.ScrollConsoleScreenBufferRequest.Fill = *lpFill;
-
- Status = CsrClientCallServer(&Request,
- NULL,
- CSR_CREATE_API_NUMBER(CSR_CONSOLE,
SCROLL_CONSOLE_SCREEN_BUFFER),
- sizeof(CSR_API_MESSAGE));
-
- if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
+ ScrollConsoleScreenBufferRequest->UseClipRectangle = FALSE;
+ }
+
+ ScrollConsoleScreenBufferRequest->DestinationOrigin = dwDestinationOrigin;
+ ScrollConsoleScreenBufferRequest->Fill = *lpFill;
+
+ Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepScrollScreenBuffer),
+ sizeof(CSRSS_SCROLL_CONSOLE_SCREEN_BUFFER));
+
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status))
{
BaseSetLastNTError(Status);
return FALSE;
@@ -1315,17 +1322,17 @@
SetConsoleTextAttribute(HANDLE hConsoleOutput,
WORD wAttributes)
{
- CSR_API_MESSAGE Request;
- NTSTATUS Status;
-
- Request.Data.SetAttribRequest.ConsoleHandle = hConsoleOutput;
- Request.Data.SetAttribRequest.Attrib = wAttributes;
-
- Status = CsrClientCallServer(&Request,
- NULL,
- CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_ATTRIB),
- sizeof(CSR_API_MESSAGE));
- if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
+ NTSTATUS Status;
+ CONSOLE_API_MESSAGE ApiMessage;
+
+ ApiMessage.Data.SetAttribRequest.ConsoleHandle = hConsoleOutput;
+ ApiMessage.Data.SetAttribRequest.Attrib = wAttributes;
+
+ Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepSetTextAttribute),
+ sizeof(CSRSS_SET_ATTRIB));
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status))
{
BaseSetLastNTError(Status);
return FALSE;
@@ -1544,8 +1551,6 @@
/*--------------------------------------------------------------
* GetConsoleTitleA
*
- * 19990306 EA
- *
* @implemented
*/
DWORD
@@ -1604,8 +1609,6 @@
/*--------------------------------------------------------------
* SetConsoleTitleA
- *
- * 19990204 EA Added
*
* @implemented
*/
@@ -1641,32 +1644,33 @@
DWORD dwFlags,
LPVOID lpScreenBufferData)
{
- CSR_API_MESSAGE Request;
- NTSTATUS Status;
-
- if (dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE)
- || dwShareMode & ~(FILE_SHARE_READ | FILE_SHARE_WRITE)
- || dwFlags != CONSOLE_TEXTMODE_BUFFER)
+ NTSTATUS Status;
+ CONSOLE_API_MESSAGE ApiMessage;
+
+ if ( (dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE)) ||
+ (dwShareMode & ~(FILE_SHARE_READ | FILE_SHARE_WRITE)) ||
+ (dwFlags != CONSOLE_TEXTMODE_BUFFER) )
{
SetLastError(ERROR_INVALID_PARAMETER);
return INVALID_HANDLE_VALUE;
}
- Request.Data.CreateScreenBufferRequest.Access = dwDesiredAccess;
- Request.Data.CreateScreenBufferRequest.ShareMode = dwShareMode;
- Request.Data.CreateScreenBufferRequest.Inheritable =
- lpSecurityAttributes ? lpSecurityAttributes->bInheritHandle : FALSE;
-
- Status = CsrClientCallServer(&Request,
- NULL,
- CSR_CREATE_API_NUMBER(CSR_CONSOLE,
CREATE_SCREEN_BUFFER),
- sizeof(CSR_API_MESSAGE));
- if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
+ ApiMessage.Data.CreateScreenBufferRequest.Access = dwDesiredAccess;
+ ApiMessage.Data.CreateScreenBufferRequest.ShareMode = dwShareMode;
+ ApiMessage.Data.CreateScreenBufferRequest.Inheritable =
+ (lpSecurityAttributes ? lpSecurityAttributes->bInheritHandle : FALSE);
+
+ Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepCreateScreenBuffer),
+ sizeof(CSRSS_CREATE_SCREEN_BUFFER));
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status))
{
BaseSetLastNTError(Status);
return INVALID_HANDLE_VALUE;
}
- return Request.Data.CreateScreenBufferRequest.OutputHandle;
+
+ return ApiMessage.Data.CreateScreenBufferRequest.OutputHandle;
}
@@ -1842,18 +1846,26 @@
WINAPI
GetConsoleSelectionInfo(PCONSOLE_SELECTION_INFO lpConsoleSelectionInfo)
{
- CSR_API_MESSAGE Request;
- NTSTATUS Status = CsrClientCallServer(&Request,
- NULL,
- CSR_CREATE_API_NUMBER(CSR_CONSOLE,
GET_CONSOLE_SELECTION_INFO),
- sizeof(CSR_API_MESSAGE));
- if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
- {
- BaseSetLastNTError(Status);
- return FALSE;
- }
-
- *lpConsoleSelectionInfo = Request.Data.GetConsoleSelectionInfo.Info;
+ NTSTATUS Status;
+ CONSOLE_API_MESSAGE ApiMessage;
+
+ if (lpConsoleSelectionInfo == NULL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepGetSelectionInfo),
+ sizeof(CSRSS_GET_CONSOLE_SELECTION_INFO));
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status))
+ {
+ BaseSetLastNTError(Status);
+ return FALSE;
+ }
+
+ *lpConsoleSelectionInfo = ApiMessage.Data.GetConsoleSelectionInfo.Info;
return TRUE;
}
@@ -1871,6 +1883,7 @@
return TRUE;
}
+
/*--------------------------------------------------------------
* GetConsoleWindow
*
@@ -1880,20 +1893,20 @@
WINAPI
GetConsoleWindow(VOID)
{
- CSR_API_MESSAGE Request;
- NTSTATUS Status;
-
- Status = CsrClientCallServer(&Request,
- NULL,
- CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_WINDOW),
- sizeof(CSR_API_MESSAGE));
- if (!NT_SUCCESS(Status ) || !NT_SUCCESS(Status = Request.Status))
+ NTSTATUS Status;
+ CONSOLE_API_MESSAGE ApiMessage;
+
+ Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepGetConsoleWindow),
+ sizeof(CSRSS_GET_CONSOLE_WINDOW));
+ if (!NT_SUCCESS(Status ) || !NT_SUCCESS(Status = ApiMessage.Status))
{
BaseSetLastNTError(Status);
return (HWND) NULL;
}
- return Request.Data.GetConsoleWindowRequest.WindowHandle;
+ return ApiMessage.Data.GetConsoleWindowRequest.WindowHandle;
}
@@ -1906,16 +1919,16 @@
WINAPI
SetConsoleIcon(HICON hicon)
{
- CSR_API_MESSAGE Request;
- NTSTATUS Status;
-
- Request.Data.SetConsoleIconRequest.WindowIcon = hicon;
-
- Status = CsrClientCallServer(&Request,
- NULL,
- CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_CONSOLE_ICON),
- sizeof(CSR_API_MESSAGE));
- if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
+ NTSTATUS Status;
+ CONSOLE_API_MESSAGE ApiMessage;
+
+ ApiMessage.Data.SetConsoleIconRequest.WindowIcon = hicon;
+
+ Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepSetIcon),
+ sizeof(CSRSS_SET_CONSOLE_ICON));
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status))
{
BaseSetLastNTError(Status);
return FALSE;
Modified: branches/ros-csrss/include/reactos/subsys/win/conmsg.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
==============================================================================
--- branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] (original)
+++ branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] Sat Nov 17
23:45:14 2012
@@ -413,17 +413,17 @@
typedef struct
{
HANDLE ConsoleHandle;
- DWORD State;
+ DWORD State;
} CSRSS_CONSOLE_HW_STATE, *PCSRSS_CONSOLE_HW_STATE;
typedef struct
{
- HWND WindowHandle;
+ HWND WindowHandle;
} CSRSS_GET_CONSOLE_WINDOW, *PCSRSS_GET_CONSOLE_WINDOW;
typedef struct
{
- HICON WindowIcon;
+ HICON WindowIcon;
} CSRSS_SET_CONSOLE_ICON, *PCSRSS_SET_CONSOLE_ICON;