Author: hbelusca
Date: Sun Apr 20 22:40:39 2014
New Revision: 62846
URL:
http://svn.reactos.org/svn/reactos?rev=62846&view=rev
Log:
[KERNEL32][CONSRV]
Make kernel32 / winsrv console CSR structures Win2k3-compliant for
CreateConsoleScreenBuffer.
The aim is to be able to put our kernel32.dll or winsrv.dll on win2k3, and vice-versa.
Because of that, we need to introduce and use the redundant hMutex and lpBitMap in the
CONSOLE_CREATESCREENBUFFER structure, instead of the ones that are already present in its
CONSOLE_GRAPHICS_BUFFER_INFO member ...
Isn't MS dumb sometimes?
I also homogeneize some variable names wrt. equivalent ones that I use elsewhere, and I
fix a broken return value in the case the API fails.
Part 3/X
CORE-7931
Modified:
trunk/reactos/dll/win32/kernel32/client/console/console.c
trunk/reactos/include/reactos/subsys/win/conmsg.h
trunk/reactos/win32ss/user/winsrv/consrv/conoutput.c
Modified: trunk/reactos/dll/win32/kernel32/client/console/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/console/console.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/console/console.c [iso-8859-1] Sun Apr 20
22:40:39 2014
@@ -1935,11 +1935,10 @@
DWORD dwFlags,
LPVOID lpScreenBufferData)
{
- NTSTATUS Status;
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest =
&ApiMessage.Data.CreateScreenBufferRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
- PCONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo =
/*(PCONSOLE_GRAPHICS_BUFFER_INFO)*/lpScreenBufferData;
+ PCONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo = lpScreenBufferData;
if ( (dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE)) ||
(dwShareMode & ~(FILE_SHARE_READ | FILE_SHARE_WRITE)) ||
@@ -1949,15 +1948,16 @@
return INVALID_HANDLE_VALUE;
}
+ CreateScreenBufferRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ CreateScreenBufferRequest->DesiredAccess = dwDesiredAccess;
+ CreateScreenBufferRequest->InheritHandle =
+ (lpSecurityAttributes ? lpSecurityAttributes->bInheritHandle : FALSE);
+ CreateScreenBufferRequest->ShareMode = dwShareMode;
CreateScreenBufferRequest->ScreenBufferType = dwFlags;
- CreateScreenBufferRequest->Access = dwDesiredAccess;
- CreateScreenBufferRequest->ShareMode = dwShareMode;
- CreateScreenBufferRequest->Inheritable =
- (lpSecurityAttributes ? lpSecurityAttributes->bInheritHandle : FALSE);
if (dwFlags == CONSOLE_GRAPHICS_BUFFER)
{
- if (CreateScreenBufferRequest->Inheritable || GraphicsBufferInfo == NULL)
+ if (CreateScreenBufferRequest->InheritHandle || GraphicsBufferInfo == NULL)
{
SetLastError(ERROR_INVALID_PARAMETER);
return INVALID_HANDLE_VALUE;
@@ -1969,7 +1969,7 @@
if (CaptureBuffer == NULL)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return FALSE;
+ return INVALID_HANDLE_VALUE;
}
CsrCaptureMessageBuffer(CaptureBuffer,
@@ -1978,24 +1978,23 @@
(PVOID*)&CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMapInfo);
}
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- CaptureBuffer,
- CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepCreateScreenBuffer),
- sizeof(CONSOLE_CREATESCREENBUFFER));
-
- if (CaptureBuffer)
- CsrFreeCaptureBuffer(CaptureBuffer);
-
- if (!NT_SUCCESS(Status))
- {
- BaseSetLastNTError(Status);
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ CaptureBuffer,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepCreateScreenBuffer),
+ sizeof(*CreateScreenBufferRequest));
+
+ if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
+
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
return INVALID_HANDLE_VALUE;
}
if (dwFlags == CONSOLE_GRAPHICS_BUFFER && GraphicsBufferInfo)
{
- GraphicsBufferInfo->hMutex =
CreateScreenBufferRequest->GraphicsBufferInfo.hMutex ;
- GraphicsBufferInfo->lpBitMap =
CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap;
+ GraphicsBufferInfo->hMutex = CreateScreenBufferRequest->hMutex ; //
CreateScreenBufferRequest->GraphicsBufferInfo.hMutex ;
+ GraphicsBufferInfo->lpBitMap = CreateScreenBufferRequest->lpBitMap; //
CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap;
}
return CreateScreenBufferRequest->OutputHandle;
Modified: trunk/reactos/include/reactos/subsys/win/conmsg.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/subsys/win…
==============================================================================
--- trunk/reactos/include/reactos/subsys/win/conmsg.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/subsys/win/conmsg.h [iso-8859-1] Sun Apr 20 22:40:39
2014
@@ -351,17 +351,19 @@
typedef struct
{
- HANDLE OutputHandle; /* Handle to newly created screen buffer */
+ HANDLE ConsoleHandle;
+ DWORD DesiredAccess;
+ BOOL InheritHandle;
+ DWORD ShareMode;
DWORD ScreenBufferType; /* Type of the screen buffer: CONSOLE_TEXTMODE_BUFFER or
CONSOLE_GRAPHICS_BUFFER */
/*
- * If we are creating a graphics screen buffer,
- * this structure holds the initialization information.
+ * This structure holds the initialization information
+ * for graphics screen buffers.
*/
CONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo;
-
- DWORD Access;
- DWORD ShareMode;
- BOOL Inheritable;
+ HANDLE hMutex;
+ PVOID lpBitMap;
+ HANDLE OutputHandle; /* Handle to newly created screen buffer */
} CONSOLE_CREATESCREENBUFFER, *PCONSOLE_CREATESCREENBUFFER;
typedef struct
Modified: trunk/reactos/win32ss/user/winsrv/consrv/conoutput.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/conoutput.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/conoutput.c [iso-8859-1] Sun Apr 20 22:40:39
2014
@@ -232,8 +232,8 @@
/* Get infos from the graphics buffer information structure */
if (!CsrValidateMessageBuffer(ApiMessage,
(PVOID*)&CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMapInfo,
- 1,
-
CreateScreenBufferRequest->GraphicsBufferInfo.dwBitMapInfoLength))
+
CreateScreenBufferRequest->GraphicsBufferInfo.dwBitMapInfoLength,
+ sizeof(BYTE)))
{
Status = STATUS_INVALID_PARAMETER;
goto Quit;
@@ -242,11 +242,13 @@
ScreenBufferInfo = &GraphicsInfo;
/* Initialize shared variables */
- CreateScreenBufferRequest->GraphicsBufferInfo.hMutex =
GraphicsInfo.Info.hMutex = INVALID_HANDLE_VALUE;
- CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap =
GraphicsInfo.Info.lpBitMap = NULL;
+ // CreateScreenBufferRequest->GraphicsBufferInfo.hMutex
+ CreateScreenBufferRequest->hMutex = GraphicsInfo.Info.hMutex =
INVALID_HANDLE_VALUE;
+ // CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap
+ CreateScreenBufferRequest->lpBitMap = GraphicsInfo.Info.lpBitMap = NULL;
/* A graphics screen buffer is never inheritable */
- CreateScreenBufferRequest->Inheritable = FALSE;
+ CreateScreenBufferRequest->InheritHandle = FALSE;
}
Status = ConDrvCreateScreenBuffer(&Buff,
@@ -261,8 +263,8 @@
Status = ConSrvInsertObject(ProcessData,
&CreateScreenBufferRequest->OutputHandle,
&Buff->Header,
- CreateScreenBufferRequest->Access,
- CreateScreenBufferRequest->Inheritable,
+ CreateScreenBufferRequest->DesiredAccess,
+ CreateScreenBufferRequest->InheritHandle,
CreateScreenBufferRequest->ShareMode);
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
@@ -276,8 +278,10 @@
* Initialize the graphics buffer information structure
* and give it back to the client.
*/
- CreateScreenBufferRequest->GraphicsBufferInfo.hMutex =
Buffer->ClientMutex;
- CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap =
Buffer->ClientBitMap;
+ // CreateScreenBufferRequest->GraphicsBufferInfo.hMutex
+ CreateScreenBufferRequest->hMutex = Buffer->ClientMutex;
+ // CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap
+ CreateScreenBufferRequest->lpBitMap = Buffer->ClientBitMap;
}
Quit: