mirror of
https://github.com/reactos/reactos.git
synced 2025-05-25 12:14:32 +00:00
Implemented LPC sections
Changed WriteConsoleOutput to pass data in the section svn path=/trunk/; revision=2413
This commit is contained in:
parent
b7f6ddaf9a
commit
7a15ff20db
26 changed files with 1112 additions and 600 deletions
|
@ -11,6 +11,7 @@
|
||||||
#define CSR_PRIORITY_CLASS_HIGH (0x40)
|
#define CSR_PRIORITY_CLASS_HIGH (0x40)
|
||||||
#define CSR_PRIORITY_CLASS_REALTIME (0x80)
|
#define CSR_PRIORITY_CLASS_REALTIME (0x80)
|
||||||
|
|
||||||
|
#define CSR_CSRSS_SECTION_SIZE (65536)
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -222,7 +223,7 @@ typedef struct
|
||||||
COORD BufferSize;
|
COORD BufferSize;
|
||||||
COORD BufferCoord;
|
COORD BufferCoord;
|
||||||
SMALL_RECT WriteRegion;
|
SMALL_RECT WriteRegion;
|
||||||
CHAR_INFO CharInfo[0];
|
CHAR_INFO* CharInfo;
|
||||||
} CSRSS_WRITE_CONSOLE_OUTPUT_REQUEST, *PCSRSS_WRITE_CONSOLE_OUTPUT_REQUEST;
|
} CSRSS_WRITE_CONSOLE_OUTPUT_REQUEST, *PCSRSS_WRITE_CONSOLE_OUTPUT_REQUEST;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: csr.h,v 1.6 2001/06/17 20:05:09 ea Exp $
|
/* $Id: csr.h,v 1.7 2001/12/02 23:34:39 dwelch Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -25,6 +25,13 @@ VOID STDCALL CsrProbeForRead(IN CONST PVOID Address,
|
||||||
VOID STDCALL CsrProbeForWrite(IN CONST PVOID Address,
|
VOID STDCALL CsrProbeForWrite(IN CONST PVOID Address,
|
||||||
IN ULONG Length,
|
IN ULONG Length,
|
||||||
IN ULONG Alignment);
|
IN ULONG Alignment);
|
||||||
|
NTSTATUS STDCALL
|
||||||
|
CsrCaptureParameterBuffer(PVOID ParameterBuffer,
|
||||||
|
ULONG ParameterBufferSize,
|
||||||
|
PVOID* ClientAddress,
|
||||||
|
PVOID* ServerAddress);
|
||||||
|
NTSTATUS STDCALL
|
||||||
|
CsrReleaseParameterBuffer(PVOID ClientAddress);
|
||||||
|
|
||||||
#endif /* __INCLUDE_NTDLL_CSR_H */
|
#endif /* __INCLUDE_NTDLL_CSR_H */
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,6 @@
|
||||||
#define HEAP_ZERO_MEMORY (8)
|
#define HEAP_ZERO_MEMORY (8)
|
||||||
#define HEAP_REALLOC_IN_PLACE_ONLY (16)
|
#define HEAP_REALLOC_IN_PLACE_ONLY (16)
|
||||||
#define HEAP_GROWABLE (32)
|
#define HEAP_GROWABLE (32)
|
||||||
|
#define HEAP_NO_VALLOC (64)
|
||||||
|
|
||||||
#endif /* __INCLUDE_HEAP_H */
|
#endif /* __INCLUDE_HEAP_H */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: console.c,v 1.37 2001/11/25 15:21:09 dwelch Exp $
|
/* $Id: console.c,v 1.38 2001/12/02 23:34:40 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -1153,52 +1153,23 @@ WriteConsoleOutputA(HANDLE hConsoleOutput,
|
||||||
ULONG Size;
|
ULONG Size;
|
||||||
BOOLEAN Result;
|
BOOLEAN Result;
|
||||||
ULONG i, j;
|
ULONG i, j;
|
||||||
|
PVOID BufferBase;
|
||||||
|
PVOID BufferTargetBase;
|
||||||
|
|
||||||
Size = dwBufferSize.Y * dwBufferSize.X * sizeof(CHAR_INFO);
|
Size = dwBufferSize.Y * dwBufferSize.X * sizeof(CHAR_INFO);
|
||||||
|
|
||||||
if ((sizeof(CSRSS_API_REQUEST) + Size) >
|
Status = CsrCaptureParameterBuffer((PVOID)lpBuffer,
|
||||||
(sizeof(LPC_MESSAGE) + MAX_MESSAGE_DATA))
|
Size,
|
||||||
|
&BufferBase,
|
||||||
|
&BufferTargetBase);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
COORD FragDim, FragCoord;
|
SetLastErrorByStatus(Status);
|
||||||
SMALL_RECT FragRegion;
|
return(FALSE);
|
||||||
DWORD SizeX, SizeY;
|
|
||||||
CONST CHAR_INFO* lpFragBuffer;
|
|
||||||
|
|
||||||
SizeX = min(dwBufferSize.X - dwBufferCoord.X,
|
|
||||||
lpWriteRegion->Right - lpWriteRegion->Left);
|
|
||||||
SizeY = min(dwBufferSize.Y - dwBufferCoord.Y,
|
|
||||||
lpWriteRegion->Bottom - lpWriteRegion->Top);
|
|
||||||
|
|
||||||
for (i = dwBufferCoord.Y; i < (dwBufferCoord.Y + SizeY); i++)
|
|
||||||
{
|
|
||||||
for (j = dwBufferCoord.X; j < (dwBufferCoord.X + SizeX); j++)
|
|
||||||
{
|
|
||||||
FragDim.X = 1;
|
|
||||||
FragDim.Y = 1;
|
|
||||||
FragCoord.X = 0;
|
|
||||||
FragCoord.Y = 0;
|
|
||||||
FragRegion.Left = lpWriteRegion->Left + j;
|
|
||||||
FragRegion.Right = lpWriteRegion->Left + j + 1;
|
|
||||||
FragRegion.Top = lpWriteRegion->Top + i;
|
|
||||||
FragRegion.Bottom = lpWriteRegion->Bottom + i + 1;
|
|
||||||
|
|
||||||
lpFragBuffer = lpBuffer + (i * dwBufferSize.X) + j;
|
|
||||||
Result = WriteConsoleOutputA(hConsoleOutput,
|
|
||||||
lpFragBuffer,
|
|
||||||
FragDim,
|
|
||||||
FragCoord,
|
|
||||||
&FragRegion);
|
|
||||||
if (!Result)
|
|
||||||
{
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Request = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
Request = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
||||||
sizeof(CSRSS_API_REQUEST) + Size);
|
sizeof(CSRSS_API_REQUEST));
|
||||||
if (Request == NULL)
|
if (Request == NULL)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_OUTOFMEMORY);
|
SetLastError(ERROR_OUTOFMEMORY);
|
||||||
|
@ -1209,11 +1180,11 @@ WriteConsoleOutputA(HANDLE hConsoleOutput,
|
||||||
Request->Data.WriteConsoleOutputRequest.BufferSize = dwBufferSize;
|
Request->Data.WriteConsoleOutputRequest.BufferSize = dwBufferSize;
|
||||||
Request->Data.WriteConsoleOutputRequest.BufferCoord = dwBufferCoord;
|
Request->Data.WriteConsoleOutputRequest.BufferCoord = dwBufferCoord;
|
||||||
Request->Data.WriteConsoleOutputRequest.WriteRegion = *lpWriteRegion;
|
Request->Data.WriteConsoleOutputRequest.WriteRegion = *lpWriteRegion;
|
||||||
RtlCopyMemory(&Request->Data.WriteConsoleOutputRequest.CharInfo, lpBuffer,
|
Request->Data.WriteConsoleOutputRequest.CharInfo =
|
||||||
Size);
|
(CHAR_INFO*)BufferTargetBase;
|
||||||
|
|
||||||
Status = CsrClientCallServer(Request, &Reply,
|
Status = CsrClientCallServer(Request, &Reply,
|
||||||
sizeof(CSRSS_API_REQUEST) + Size,
|
sizeof(CSRSS_API_REQUEST),
|
||||||
sizeof(CSRSS_API_REPLY));
|
sizeof(CSRSS_API_REPLY));
|
||||||
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Reply.Status))
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Reply.Status))
|
||||||
{
|
{
|
||||||
|
@ -1224,6 +1195,7 @@ WriteConsoleOutputA(HANDLE hConsoleOutput,
|
||||||
|
|
||||||
*lpWriteRegion = Reply.Data.WriteConsoleOutputReply.WriteRegion;
|
*lpWriteRegion = Reply.Data.WriteConsoleOutputReply.WriteRegion;
|
||||||
RtlFreeHeap(GetProcessHeap(), 0, Request);
|
RtlFreeHeap(GetProcessHeap(), 0, Request);
|
||||||
|
CsrReleaseParameterBuffer(BufferBase);
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: lpc.c,v 1.3 2001/11/25 15:21:09 dwelch Exp $
|
/* $Id: lpc.c,v 1.4 2001/12/02 23:34:40 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -25,6 +25,11 @@
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
HANDLE WindowsApiPort = INVALID_HANDLE_VALUE;
|
HANDLE WindowsApiPort = INVALID_HANDLE_VALUE;
|
||||||
|
static PVOID CsrSectionMapBase = NULL;
|
||||||
|
static PVOID CsrSectionMapServerBase = NULL;
|
||||||
|
static HANDLE CsrCommHeap = NULL;
|
||||||
|
|
||||||
|
#define CSR_CONTROL_HEAP_SIZE (65536)
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
@ -51,6 +56,33 @@ Request is the family of PCSRSS_XXX_REQUEST objects.
|
||||||
XXX_REQUEST depend on the CsrApiNumber.Index.
|
XXX_REQUEST depend on the CsrApiNumber.Index.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
NTSTATUS STDCALL
|
||||||
|
CsrCaptureParameterBuffer(PVOID ParameterBuffer,
|
||||||
|
ULONG ParameterBufferSize,
|
||||||
|
PVOID* ClientAddress,
|
||||||
|
PVOID* ServerAddress)
|
||||||
|
{
|
||||||
|
PVOID Block;
|
||||||
|
|
||||||
|
Block = RtlAllocateHeap(CsrCommHeap, 0, ParameterBufferSize);
|
||||||
|
if (Block == NULL)
|
||||||
|
{
|
||||||
|
return(STATUS_NO_MEMORY);
|
||||||
|
}
|
||||||
|
memcpy(Block, ParameterBuffer, ParameterBufferSize);
|
||||||
|
*ClientAddress = Block;
|
||||||
|
*ServerAddress = Block - CsrSectionMapBase + CsrSectionMapServerBase;
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL
|
||||||
|
CsrReleaseParameterBuffer(PVOID ClientAddress)
|
||||||
|
{
|
||||||
|
RtlFreeHeap(CsrCommHeap, 0, ClientAddress);
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
CsrClientCallServer(PCSRSS_API_REQUEST Request,
|
CsrClientCallServer(PCSRSS_API_REQUEST Request,
|
||||||
PCSRSS_API_REPLY Reply OPTIONAL,
|
PCSRSS_API_REPLY Reply OPTIONAL,
|
||||||
|
@ -83,13 +115,32 @@ CsrClientConnectToServer(VOID)
|
||||||
ULONG ConnectInfoLength;
|
ULONG ConnectInfoLength;
|
||||||
CSRSS_API_REQUEST Request;
|
CSRSS_API_REQUEST Request;
|
||||||
CSRSS_API_REPLY Reply;
|
CSRSS_API_REPLY Reply;
|
||||||
|
LPC_SECTION_WRITE LpcWrite;
|
||||||
|
HANDLE CsrSectionHandle;
|
||||||
|
ULONG CsrSectionViewSize;
|
||||||
|
|
||||||
|
CsrSectionViewSize = CSR_CSRSS_SECTION_SIZE;
|
||||||
|
Status = NtCreateSection(&CsrSectionHandle,
|
||||||
|
SECTION_ALL_ACCESS,
|
||||||
|
NULL,
|
||||||
|
&CsrSectionViewSize,
|
||||||
|
PAGE_READWRITE,
|
||||||
|
SEC_COMMIT,
|
||||||
|
NULL);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
RtlInitUnicodeString(&PortName, L"\\Windows\\ApiPort");
|
RtlInitUnicodeString(&PortName, L"\\Windows\\ApiPort");
|
||||||
ConnectInfoLength = 0;
|
ConnectInfoLength = 0;
|
||||||
|
LpcWrite.Length = sizeof(LPC_SECTION_WRITE);
|
||||||
|
LpcWrite.SectionHandle = CsrSectionHandle;
|
||||||
|
LpcWrite.SectionOffset = 0;
|
||||||
|
LpcWrite.ViewSize = CsrSectionViewSize;
|
||||||
Status = NtConnectPort(&WindowsApiPort,
|
Status = NtConnectPort(&WindowsApiPort,
|
||||||
&PortName,
|
&PortName,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
&LpcWrite,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -99,6 +150,22 @@ CsrClientConnectToServer(VOID)
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NtClose(CsrSectionHandle);
|
||||||
|
CsrSectionMapBase = LpcWrite.ViewBase;
|
||||||
|
CsrSectionMapServerBase = LpcWrite.TargetViewBase;
|
||||||
|
|
||||||
|
/* Create the heap for communication for csrss. */
|
||||||
|
CsrCommHeap = RtlCreateHeap(HEAP_NO_VALLOC,
|
||||||
|
CsrSectionMapBase,
|
||||||
|
CsrSectionViewSize,
|
||||||
|
CsrSectionViewSize,
|
||||||
|
0,
|
||||||
|
NULL);
|
||||||
|
if (CsrCommHeap == NULL)
|
||||||
|
{
|
||||||
|
return(STATUS_NO_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
Request.Type = CSRSS_CONNECT_PROCESS;
|
Request.Type = CSRSS_CONNECT_PROCESS;
|
||||||
Status = CsrClientCallServer(&Request,
|
Status = CsrClientCallServer(&Request,
|
||||||
&Reply,
|
&Reply,
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
; $Id: ntdll.def,v 1.81 2001/11/21 22:31:18 ekohl Exp $
|
; $Id: ntdll.def,v 1.82 2001/12/02 23:34:41 dwelch Exp $
|
||||||
;
|
;
|
||||||
; ReactOS Operating System
|
; ReactOS Operating System
|
||||||
;
|
;
|
||||||
LIBRARY ntdll.dll
|
LIBRARY ntdll.dll
|
||||||
|
|
||||||
EXPORTS
|
EXPORTS
|
||||||
|
CsrCaptureParameterBuffer@16
|
||||||
|
CsrReleaseParameterBuffer@4
|
||||||
CsrAllocateCaptureBuffer@12
|
CsrAllocateCaptureBuffer@12
|
||||||
CsrAllocateCapturePointer@12
|
CsrAllocateCapturePointer@12
|
||||||
CsrAllocateMessagePointer@12
|
CsrAllocateMessagePointer@12
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
; $Id: ntdll.edf,v 1.70 2001/11/21 22:31:18 ekohl Exp $
|
; $Id: ntdll.edf,v 1.71 2001/12/02 23:34:41 dwelch Exp $
|
||||||
;
|
;
|
||||||
; ReactOS Operating System
|
; ReactOS Operating System
|
||||||
;
|
;
|
||||||
LIBRARY ntdll.dll
|
LIBRARY ntdll.dll
|
||||||
|
|
||||||
EXPORTS
|
EXPORTS
|
||||||
|
CsrCaptureParameterBuffer=CsrCaptureParameterBuffer@16
|
||||||
|
CsrReleaseParameterBuffer=CsrReleaseParameterBuffer@4
|
||||||
CsrAllocateCaptureBuffer=CsrAllocateCaptureBuffer@12
|
CsrAllocateCaptureBuffer=CsrAllocateCaptureBuffer@12
|
||||||
CsrAllocateCapturePointer=CsrAllocateCapturePointer@12
|
CsrAllocateCapturePointer=CsrAllocateCapturePointer@12
|
||||||
CsrAllocateMessagePointer=CsrAllocateMessagePointer@12
|
CsrAllocateMessagePointer=CsrAllocateMessagePointer@12
|
||||||
|
|
|
@ -282,7 +282,8 @@ HEAP_FindSubHeap(HEAP *heap, /* [in] Heap pointer */
|
||||||
*/
|
*/
|
||||||
static inline BOOL
|
static inline BOOL
|
||||||
HEAP_Commit(SUBHEAP *subheap,
|
HEAP_Commit(SUBHEAP *subheap,
|
||||||
void *ptr)
|
void *ptr,
|
||||||
|
DWORD flags)
|
||||||
{
|
{
|
||||||
DWORD size = (DWORD)((char *)ptr - (char *)subheap);
|
DWORD size = (DWORD)((char *)ptr - (char *)subheap);
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -296,20 +297,23 @@ HEAP_Commit(SUBHEAP *subheap,
|
||||||
address = (PVOID)((char *)subheap + subheap->commitSize);
|
address = (PVOID)((char *)subheap + subheap->commitSize);
|
||||||
commitsize = size - subheap->commitSize;
|
commitsize = size - subheap->commitSize;
|
||||||
|
|
||||||
Status = NtAllocateVirtualMemory(NtCurrentProcess(),
|
if (!(flags & HEAP_NO_VALLOC))
|
||||||
&address,
|
{
|
||||||
0,
|
Status = NtAllocateVirtualMemory(NtCurrentProcess(),
|
||||||
&commitsize,
|
&address,
|
||||||
MEM_COMMIT,
|
0,
|
||||||
PAGE_EXECUTE_READWRITE);
|
&commitsize,
|
||||||
if (!NT_SUCCESS(Status))
|
MEM_COMMIT,
|
||||||
{
|
PAGE_EXECUTE_READWRITE);
|
||||||
WARN("Could not commit %08lx bytes at %08lx for heap %08lx\n",
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
WARN("Could not commit %08lx bytes at %08lx for heap %08lx\n",
|
||||||
size - subheap->commitSize,
|
size - subheap->commitSize,
|
||||||
(DWORD)((char *)subheap + subheap->commitSize),
|
(DWORD)((char *)subheap + subheap->commitSize),
|
||||||
(DWORD)subheap->heap );
|
(DWORD)subheap->heap );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
subheap->commitSize = size;
|
subheap->commitSize = size;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -320,7 +324,7 @@ HEAP_Commit(SUBHEAP *subheap,
|
||||||
*
|
*
|
||||||
* If possible, decommit the heap storage from (including) 'ptr'.
|
* If possible, decommit the heap storage from (including) 'ptr'.
|
||||||
*/
|
*/
|
||||||
static inline BOOL HEAP_Decommit( SUBHEAP *subheap, void *ptr )
|
static inline BOOL HEAP_Decommit( SUBHEAP *subheap, void *ptr, DWORD flags )
|
||||||
{
|
{
|
||||||
DWORD size = (DWORD)((char *)ptr - (char *)subheap);
|
DWORD size = (DWORD)((char *)ptr - (char *)subheap);
|
||||||
PVOID address;
|
PVOID address;
|
||||||
|
@ -333,18 +337,21 @@ static inline BOOL HEAP_Decommit( SUBHEAP *subheap, void *ptr )
|
||||||
address = (PVOID)((char *)subheap + size);
|
address = (PVOID)((char *)subheap + size);
|
||||||
decommitsize = subheap->commitSize - size;
|
decommitsize = subheap->commitSize - size;
|
||||||
|
|
||||||
Status = ZwFreeVirtualMemory(NtCurrentProcess(),
|
if (!(flags & HEAP_NO_VALLOC))
|
||||||
&address,
|
{
|
||||||
&decommitsize,
|
Status = ZwFreeVirtualMemory(NtCurrentProcess(),
|
||||||
MEM_DECOMMIT);
|
&address,
|
||||||
if (!NT_SUCCESS(Status));
|
&decommitsize,
|
||||||
{
|
MEM_DECOMMIT);
|
||||||
WARN("Could not decommit %08lx bytes at %08lx for heap %08lx\n",
|
if (!NT_SUCCESS(Status));
|
||||||
subheap->commitSize - size,
|
{
|
||||||
(DWORD)((char *)subheap + size),
|
WARN("Could not decommit %08lx bytes at %08lx for heap %08lx\n",
|
||||||
(DWORD)subheap->heap );
|
subheap->commitSize - size,
|
||||||
return FALSE;
|
(DWORD)((char *)subheap + size),
|
||||||
}
|
(DWORD)subheap->heap );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
subheap->commitSize = size;
|
subheap->commitSize = size;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -413,7 +420,8 @@ static void HEAP_CreateFreeBlock( SUBHEAP *subheap, void *ptr, DWORD size )
|
||||||
* Turn an in-use block into a free block. Can also decommit the end of
|
* Turn an in-use block into a free block. Can also decommit the end of
|
||||||
* the heap, and possibly even free the sub-heap altogether.
|
* the heap, and possibly even free the sub-heap altogether.
|
||||||
*/
|
*/
|
||||||
static void HEAP_MakeInUseBlockFree( SUBHEAP *subheap, ARENA_INUSE *pArena )
|
static void HEAP_MakeInUseBlockFree( SUBHEAP *subheap, ARENA_INUSE *pArena,
|
||||||
|
DWORD flags)
|
||||||
{
|
{
|
||||||
ARENA_FREE *pFree;
|
ARENA_FREE *pFree;
|
||||||
DWORD size = (pArena->size & ARENA_SIZE_MASK) + sizeof(*pArena);
|
DWORD size = (pArena->size & ARENA_SIZE_MASK) + sizeof(*pArena);
|
||||||
|
@ -451,10 +459,13 @@ static void HEAP_MakeInUseBlockFree( SUBHEAP *subheap, ARENA_INUSE *pArena )
|
||||||
if (pPrev) pPrev->next = subheap->next;
|
if (pPrev) pPrev->next = subheap->next;
|
||||||
/* Free the memory */
|
/* Free the memory */
|
||||||
subheap->magic = 0;
|
subheap->magic = 0;
|
||||||
ZwFreeVirtualMemory(NtCurrentProcess(),
|
if (!(flags & HEAP_NO_VALLOC))
|
||||||
(PVOID*)&subheap,
|
{
|
||||||
0,
|
ZwFreeVirtualMemory(NtCurrentProcess(),
|
||||||
MEM_RELEASE);
|
(PVOID*)&subheap,
|
||||||
|
0,
|
||||||
|
MEM_RELEASE);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,19 +508,21 @@ static BOOL HEAP_InitSubHeap( HEAP *heap, LPVOID address, DWORD flags,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
/* Commit memory */
|
/* Commit memory */
|
||||||
|
if (!(flags & HEAP_NO_VALLOC))
|
||||||
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
|
{
|
||||||
&address,
|
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
|
||||||
0,
|
&address,
|
||||||
(PULONG)&commitSize,
|
0,
|
||||||
MEM_COMMIT,
|
(PULONG)&commitSize,
|
||||||
PAGE_EXECUTE_READWRITE);
|
MEM_COMMIT,
|
||||||
if (!NT_SUCCESS(Status))
|
PAGE_EXECUTE_READWRITE);
|
||||||
{
|
if (!NT_SUCCESS(Status))
|
||||||
WARN("Could not commit %08lx bytes for sub-heap %08lx\n",
|
{
|
||||||
commitSize, (DWORD)address );
|
WARN("Could not commit %08lx bytes for sub-heap %08lx\n",
|
||||||
return FALSE;
|
commitSize, (DWORD)address );
|
||||||
}
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Fill the sub-heap structure */
|
/* Fill the sub-heap structure */
|
||||||
|
|
||||||
|
@ -585,31 +598,36 @@ static SUBHEAP *HEAP_CreateSubHeap(PVOID BaseAddress,
|
||||||
if (totalSize < commitSize) totalSize = commitSize;
|
if (totalSize < commitSize) totalSize = commitSize;
|
||||||
|
|
||||||
/* Allocate the memory block */
|
/* Allocate the memory block */
|
||||||
|
|
||||||
address = BaseAddress;
|
address = BaseAddress;
|
||||||
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
|
if (!(flags & HEAP_NO_VALLOC))
|
||||||
&address,
|
{
|
||||||
0,
|
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
|
||||||
(PULONG)&totalSize,
|
&address,
|
||||||
MEM_RESERVE | MEM_COMMIT,
|
0,
|
||||||
PAGE_EXECUTE_READWRITE);
|
(PULONG)&totalSize,
|
||||||
if (!NT_SUCCESS(Status))
|
MEM_RESERVE | MEM_COMMIT,
|
||||||
{
|
PAGE_EXECUTE_READWRITE);
|
||||||
WARN("Could not VirtualAlloc %08lx bytes\n",
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
WARN("Could not VirtualAlloc %08lx bytes\n",
|
||||||
totalSize );
|
totalSize );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize subheap */
|
/* Initialize subheap */
|
||||||
|
|
||||||
if (!HEAP_InitSubHeap( heap? heap : (HEAP *)address,
|
if (!HEAP_InitSubHeap( heap? heap : (HEAP *)address,
|
||||||
address, flags, commitSize, totalSize ))
|
address, flags, commitSize, totalSize ))
|
||||||
{
|
{
|
||||||
ZwFreeVirtualMemory(NtCurrentProcess(),
|
if (!(flags & HEAP_NO_VALLOC))
|
||||||
address,
|
{
|
||||||
0,
|
ZwFreeVirtualMemory(NtCurrentProcess(),
|
||||||
MEM_RELEASE);
|
address,
|
||||||
return NULL;
|
0,
|
||||||
|
MEM_RELEASE);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (SUBHEAP *)address;
|
return (SUBHEAP *)address;
|
||||||
|
@ -639,7 +657,8 @@ static ARENA_FREE *HEAP_FindFreeBlock( HEAP *heap, DWORD size,
|
||||||
{
|
{
|
||||||
subheap = HEAP_FindSubHeap( heap, pArena );
|
subheap = HEAP_FindSubHeap( heap, pArena );
|
||||||
if (!HEAP_Commit( subheap, (char *)pArena + sizeof(ARENA_INUSE)
|
if (!HEAP_Commit( subheap, (char *)pArena + sizeof(ARENA_INUSE)
|
||||||
+ size + HEAP_MIN_BLOCK_SIZE))
|
+ size + HEAP_MIN_BLOCK_SIZE,
|
||||||
|
heap->flags))
|
||||||
return NULL;
|
return NULL;
|
||||||
*ppSubHeap = subheap;
|
*ppSubHeap = subheap;
|
||||||
return pArena;
|
return pArena;
|
||||||
|
@ -1043,11 +1062,13 @@ RtlDestroyHeap(HANDLE heap) /* [in] Handle of heap */
|
||||||
{
|
{
|
||||||
SUBHEAP *next = subheap->next;
|
SUBHEAP *next = subheap->next;
|
||||||
|
|
||||||
ZwFreeVirtualMemory(NtCurrentProcess(),
|
if (!(heapPtr->flags & HEAP_NO_VALLOC))
|
||||||
(PVOID*)&subheap,
|
{
|
||||||
0,
|
ZwFreeVirtualMemory(NtCurrentProcess(),
|
||||||
MEM_RELEASE);
|
(PVOID*)&subheap,
|
||||||
|
0,
|
||||||
|
MEM_RELEASE);
|
||||||
|
}
|
||||||
subheap = next;
|
subheap = next;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1160,7 +1181,7 @@ BOOLEAN STDCALL RtlFreeHeap(
|
||||||
|
|
||||||
pInUse = (ARENA_INUSE *)ptr - 1;
|
pInUse = (ARENA_INUSE *)ptr - 1;
|
||||||
subheap = HEAP_FindSubHeap( heapPtr, pInUse );
|
subheap = HEAP_FindSubHeap( heapPtr, pInUse );
|
||||||
HEAP_MakeInUseBlockFree( subheap, pInUse );
|
HEAP_MakeInUseBlockFree( subheap, pInUse, heapPtr->flags );
|
||||||
|
|
||||||
if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection );
|
if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection );
|
||||||
|
|
||||||
|
@ -1227,7 +1248,8 @@ LPVOID STDCALL RtlReAllocateHeap(
|
||||||
pFree->prev->next = pFree->next;
|
pFree->prev->next = pFree->next;
|
||||||
pArena->size += (pFree->size & ARENA_SIZE_MASK) + sizeof(*pFree);
|
pArena->size += (pFree->size & ARENA_SIZE_MASK) + sizeof(*pFree);
|
||||||
if (!HEAP_Commit( subheap, (char *)pArena + sizeof(ARENA_INUSE)
|
if (!HEAP_Commit( subheap, (char *)pArena + sizeof(ARENA_INUSE)
|
||||||
+ size + HEAP_MIN_BLOCK_SIZE))
|
+ size + HEAP_MIN_BLOCK_SIZE,
|
||||||
|
heapPtr->flags))
|
||||||
{
|
{
|
||||||
if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection );
|
if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection );
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1261,7 +1283,7 @@ LPVOID STDCALL RtlReAllocateHeap(
|
||||||
|
|
||||||
/* Free the previous block */
|
/* Free the previous block */
|
||||||
|
|
||||||
HEAP_MakeInUseBlockFree( subheap, pArena );
|
HEAP_MakeInUseBlockFree( subheap, pArena, flags );
|
||||||
subheap = newsubheap;
|
subheap = newsubheap;
|
||||||
pArena = pInUse;
|
pArena = pInUse;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
#include <internal/ntoskrnl.h>
|
#include <internal/ntoskrnl.h>
|
||||||
#include <roscfg.h>
|
#include <roscfg.h>
|
||||||
#include <internal/dbg.h>
|
|
||||||
|
|
||||||
#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
|
#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,28 @@ typedef struct _EPORT_TERMINATION_REQUEST
|
||||||
} EPORT_TERMINATION_REQUEST, *PEPORT_TERMINATION_REQUEST;
|
} EPORT_TERMINATION_REQUEST, *PEPORT_TERMINATION_REQUEST;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _EPORT_CONNECT_REQUEST_MESSAGE
|
||||||
|
{
|
||||||
|
LPC_MESSAGE_HEADER MessageHeader;
|
||||||
|
PEPROCESS ConnectingProcess;
|
||||||
|
struct _SECTION_OBJECT* SendSectionObject;
|
||||||
|
LARGE_INTEGER SendSectionOffset;
|
||||||
|
ULONG SendViewSize;
|
||||||
|
ULONG ConnectDataLength;
|
||||||
|
UCHAR ConnectData[0];
|
||||||
|
} EPORT_CONNECT_REQUEST_MESSAGE, *PEPORT_CONNECT_REQUEST_MESSAGE;
|
||||||
|
|
||||||
|
typedef struct _EPORT_CONNECT_REPLY_MESSAGE
|
||||||
|
{
|
||||||
|
LPC_MESSAGE_HEADER MessageHeader;
|
||||||
|
PVOID SendServerViewBase;
|
||||||
|
ULONG ReceiveClientViewSize;
|
||||||
|
PVOID ReceiveClientViewBase;
|
||||||
|
ULONG MaximumMessageSize;
|
||||||
|
ULONG ConnectDataLength;
|
||||||
|
UCHAR ConnectData[0];
|
||||||
|
} EPORT_CONNECT_REPLY_MESSAGE, *PEPORT_CONNECT_REPLY_MESSAGE;
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
LpcRequestPort (PEPORT Port,
|
LpcRequestPort (PEPORT Port,
|
||||||
PLPC_MESSAGE LpcMessage);
|
PLPC_MESSAGE LpcMessage);
|
||||||
|
@ -52,88 +74,62 @@ LpcSendTerminationPort (PEPORT Port,
|
||||||
|
|
||||||
typedef struct _QUEUEDMESSAGE
|
typedef struct _QUEUEDMESSAGE
|
||||||
{
|
{
|
||||||
PEPORT Sender;
|
PEPORT Sender;
|
||||||
LIST_ENTRY QueueListEntry;
|
LIST_ENTRY QueueListEntry;
|
||||||
LPC_MESSAGE Message;
|
LPC_MESSAGE Message;
|
||||||
UCHAR MessageData [MAX_MESSAGE_DATA];
|
UCHAR MessageData [MAX_MESSAGE_DATA];
|
||||||
} QUEUEDMESSAGE, *PQUEUEDMESSAGE;
|
} QUEUEDMESSAGE, *PQUEUEDMESSAGE;
|
||||||
|
|
||||||
/* Code in ntoskrnl/lpc/close.h */
|
/* Code in ntoskrnl/lpc/close.h */
|
||||||
|
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
NiClosePort (
|
NiClosePort (PVOID ObjectBody,
|
||||||
PVOID ObjectBody,
|
ULONG HandleCount);
|
||||||
ULONG HandleCount
|
|
||||||
);
|
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
NiDeletePort (
|
NiDeletePort (IN PVOID ObjectBody);
|
||||||
IN PVOID ObjectBody
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/* Code in ntoskrnl/lpc/queue.c */
|
/* Code in ntoskrnl/lpc/queue.c */
|
||||||
|
|
||||||
VOID
|
VOID STDCALL
|
||||||
STDCALL
|
EiEnqueueConnectMessagePort (IN OUT PEPORT Port,
|
||||||
EiEnqueueConnectMessagePort (
|
IN PQUEUEDMESSAGE Message);
|
||||||
IN OUT PEPORT Port,
|
VOID STDCALL
|
||||||
IN PQUEUEDMESSAGE Message
|
EiEnqueueMessagePort (IN OUT PEPORT Port,
|
||||||
);
|
IN PQUEUEDMESSAGE Message);
|
||||||
VOID
|
|
||||||
STDCALL
|
|
||||||
EiEnqueueMessagePort (
|
|
||||||
IN OUT PEPORT Port,
|
|
||||||
IN PQUEUEDMESSAGE Message
|
|
||||||
);
|
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
EiEnqueueMessageAtHeadPort (IN OUT PEPORT Port,
|
EiEnqueueMessageAtHeadPort (IN OUT PEPORT Port,
|
||||||
IN PQUEUEDMESSAGE Message);
|
IN PQUEUEDMESSAGE Message);
|
||||||
PQUEUEDMESSAGE
|
PQUEUEDMESSAGE
|
||||||
STDCALL
|
STDCALL
|
||||||
EiDequeueConnectMessagePort (
|
EiDequeueConnectMessagePort (IN OUT PEPORT Port);
|
||||||
IN OUT PEPORT Port
|
PQUEUEDMESSAGE STDCALL
|
||||||
);
|
EiDequeueMessagePort (IN OUT PEPORT Port);
|
||||||
PQUEUEDMESSAGE
|
|
||||||
STDCALL
|
|
||||||
EiDequeueMessagePort (
|
|
||||||
IN OUT PEPORT Port
|
|
||||||
);
|
|
||||||
|
|
||||||
/* Code in ntoskrnl/lpc/create.c */
|
/* Code in ntoskrnl/lpc/create.c */
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
NiCreatePort (
|
NiCreatePort (PVOID ObjectBody,
|
||||||
PVOID ObjectBody,
|
PVOID Parent,
|
||||||
PVOID Parent,
|
PWSTR RemainingPath,
|
||||||
PWSTR RemainingPath,
|
POBJECT_ATTRIBUTES ObjectAttributes);
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes
|
|
||||||
);
|
|
||||||
|
|
||||||
/* Code in ntoskrnl/lpc/port.c */
|
/* Code in ntoskrnl/lpc/port.c */
|
||||||
|
|
||||||
|
NTSTATUS STDCALL
|
||||||
|
NiInitializePort (IN OUT PEPORT Port);
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
NiInitPort (VOID);
|
||||||
NiInitializePort (
|
|
||||||
IN OUT PEPORT Port
|
|
||||||
);
|
|
||||||
NTSTATUS
|
|
||||||
NiInitPort (
|
|
||||||
VOID
|
|
||||||
);
|
|
||||||
|
|
||||||
extern POBJECT_TYPE ExPortType;
|
extern POBJECT_TYPE ExPortType;
|
||||||
extern ULONG EiNextLpcMessageId;
|
extern ULONG EiNextLpcMessageId;
|
||||||
|
|
||||||
/* Code in ntoskrnl/lpc/reply.c */
|
/* Code in ntoskrnl/lpc/reply.c */
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL
|
||||||
STDCALL
|
EiReplyOrRequestPort (IN PEPORT Port,
|
||||||
EiReplyOrRequestPort (
|
IN PLPC_MESSAGE LpcReply,
|
||||||
IN PEPORT Port,
|
IN ULONG MessageType,
|
||||||
IN PLPC_MESSAGE LpcReply,
|
IN PEPORT Sender);
|
||||||
IN ULONG MessageType,
|
|
||||||
IN PEPORT Sender
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __INCLUDE_INTERNAL_PORT_H */
|
#endif /* __INCLUDE_INTERNAL_PORT_H */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: loader.c,v 1.90 2001/09/16 13:19:32 chorns Exp $
|
/* $Id: loader.c,v 1.91 2001/12/02 23:34:41 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -932,7 +932,7 @@ VOID LdrLoadAutoConfigDrivers (VOID)
|
||||||
/*
|
/*
|
||||||
* Networking
|
* Networking
|
||||||
*/
|
*/
|
||||||
#if 1
|
#if 0
|
||||||
/*
|
/*
|
||||||
* NDIS library
|
* NDIS library
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: close.c,v 1.6 2001/08/26 17:28:00 ekohl Exp $
|
/* $Id: close.c,v 1.7 2001/12/02 23:34:42 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -19,6 +19,7 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* NAME
|
* NAME
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: complete.c,v 1.4 2001/06/23 19:13:33 phreak Exp $
|
/* $Id: complete.c,v 1.5 2001/12/02 23:34:42 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <internal/ob.h>
|
#include <internal/ob.h>
|
||||||
|
@ -19,6 +19,7 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* NAME EXPORTED
|
* NAME EXPORTED
|
||||||
|
@ -47,7 +48,8 @@ NtCompleteConnectPort (HANDLE PortHandle)
|
||||||
|
|
||||||
OurPort->State = EPORT_CONNECTED_SERVER;
|
OurPort->State = EPORT_CONNECTED_SERVER;
|
||||||
|
|
||||||
KeReleaseSemaphore( &OurPort->OtherPort->Semaphore, IO_NO_INCREMENT, 1, FALSE );
|
KeReleaseSemaphore(&OurPort->OtherPort->Semaphore, IO_NO_INCREMENT, 1,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
ObDereferenceObject (OurPort);
|
ObDereferenceObject (OurPort);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: connect.c,v 1.7 2001/06/23 19:13:33 phreak Exp $
|
/* $Id: connect.c,v 1.8 2001/12/02 23:34:42 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -16,6 +16,8 @@
|
||||||
#include <internal/port.h>
|
#include <internal/port.h>
|
||||||
#include <internal/dbg.h>
|
#include <internal/dbg.h>
|
||||||
#include <internal/pool.h>
|
#include <internal/pool.h>
|
||||||
|
#include <internal/mm.h>
|
||||||
|
#include <internal/safe.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
@ -26,6 +28,190 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
NTSTATUS STDCALL
|
||||||
|
EiConnectPort(IN PEPORT* ConnectedPort,
|
||||||
|
IN PEPORT NamedPort,
|
||||||
|
IN PSECTION_OBJECT Section,
|
||||||
|
IN LARGE_INTEGER SectionOffset,
|
||||||
|
IN ULONG ViewSize,
|
||||||
|
OUT PVOID* ClientSendViewBase,
|
||||||
|
OUT PVOID* ServerSendViewBase,
|
||||||
|
OUT PULONG ReceiveViewSize,
|
||||||
|
OUT PVOID* ReceiveViewBase,
|
||||||
|
OUT PULONG MaximumMessageSize,
|
||||||
|
IN OUT PVOID ConnectData,
|
||||||
|
IN OUT PULONG ConnectDataLength)
|
||||||
|
{
|
||||||
|
PEPORT_CONNECT_REQUEST_MESSAGE RequestMessage;
|
||||||
|
ULONG RequestConnectDataLength;
|
||||||
|
PEPORT OurPort;
|
||||||
|
PQUEUEDMESSAGE Reply;
|
||||||
|
PEPORT_CONNECT_REPLY_MESSAGE CReply;
|
||||||
|
NTSTATUS Status;
|
||||||
|
KIRQL oldIrql;
|
||||||
|
|
||||||
|
if (ConnectDataLength == NULL)
|
||||||
|
{
|
||||||
|
RequestConnectDataLength = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RequestConnectDataLength = *ConnectDataLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a port to represent our side of the connection
|
||||||
|
*/
|
||||||
|
Status = ObCreateObject (NULL,
|
||||||
|
PORT_ALL_ACCESS,
|
||||||
|
NULL,
|
||||||
|
ExPortType,
|
||||||
|
(PVOID*)&OurPort);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return (Status);
|
||||||
|
}
|
||||||
|
NiInitializePort(OurPort);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate a request message.
|
||||||
|
*/
|
||||||
|
RequestMessage = ExAllocatePool(NonPagedPool,
|
||||||
|
sizeof(EPORT_CONNECT_REQUEST_MESSAGE) +
|
||||||
|
RequestConnectDataLength);
|
||||||
|
if (RequestMessage == NULL)
|
||||||
|
{
|
||||||
|
ObDereferenceObject(OurPort);
|
||||||
|
return(STATUS_NO_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize the request message.
|
||||||
|
*/
|
||||||
|
RequestMessage->MessageHeader.DataSize =
|
||||||
|
sizeof(EPORT_CONNECT_REQUEST_MESSAGE) + RequestConnectDataLength -
|
||||||
|
sizeof(LPC_MESSAGE_HEADER);
|
||||||
|
RequestMessage->MessageHeader.MessageSize =
|
||||||
|
sizeof(EPORT_CONNECT_REQUEST_MESSAGE) + RequestConnectDataLength;
|
||||||
|
DPRINT("RequestMessageSize %d\n",
|
||||||
|
RequestMessage->MessageHeader.MessageSize);
|
||||||
|
RequestMessage->MessageHeader.SharedSectionSize = 0;
|
||||||
|
RequestMessage->ConnectingProcess = PsGetCurrentProcess();
|
||||||
|
ObReferenceObjectByPointer(RequestMessage->ConnectingProcess,
|
||||||
|
PROCESS_VM_OPERATION,
|
||||||
|
NULL,
|
||||||
|
KernelMode);
|
||||||
|
RequestMessage->SendSectionObject = (struct _SECTION_OBJECT*)Section;
|
||||||
|
RequestMessage->SendSectionOffset = SectionOffset;
|
||||||
|
RequestMessage->SendViewSize = ViewSize;
|
||||||
|
RequestMessage->ConnectDataLength = RequestConnectDataLength;
|
||||||
|
if (RequestConnectDataLength > 0)
|
||||||
|
{
|
||||||
|
memcpy(RequestMessage->ConnectData, ConnectData,
|
||||||
|
RequestConnectDataLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Queue the message to the named port
|
||||||
|
*/
|
||||||
|
EiReplyOrRequestPort(NamedPort,
|
||||||
|
&RequestMessage->MessageHeader,
|
||||||
|
LPC_CONNECTION_REQUEST,
|
||||||
|
OurPort);
|
||||||
|
KeReleaseSemaphore(&NamedPort->Semaphore, IO_NO_INCREMENT, 1, FALSE);
|
||||||
|
ExFreePool(RequestMessage);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wait for them to accept our connection
|
||||||
|
*/
|
||||||
|
KeWaitForSingleObject(&OurPort->Semaphore,
|
||||||
|
UserRequest,
|
||||||
|
UserMode,
|
||||||
|
FALSE,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Dequeue the response
|
||||||
|
*/
|
||||||
|
KeAcquireSpinLock (&OurPort->Lock, &oldIrql);
|
||||||
|
Reply = EiDequeueMessagePort (OurPort);
|
||||||
|
KeReleaseSpinLock (&OurPort->Lock, oldIrql);
|
||||||
|
CReply = (PEPORT_CONNECT_REPLY_MESSAGE)&Reply->Message;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Do some initial cleanup.
|
||||||
|
*/
|
||||||
|
ObDereferenceObject(PsGetCurrentProcess());
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check for connection refusal.
|
||||||
|
*/
|
||||||
|
if (CReply->MessageHeader.MessageType == LPC_CONNECTION_REFUSED)
|
||||||
|
{
|
||||||
|
ObDereferenceObject(OurPort);
|
||||||
|
ExFreePool(Reply);
|
||||||
|
/*
|
||||||
|
* FIXME: Check what NT does here. Giving the user data back on
|
||||||
|
* connect failure sounds reasonable; it probably wouldn't break
|
||||||
|
* anything anyway.
|
||||||
|
*/
|
||||||
|
if (ConnectDataLength != NULL)
|
||||||
|
{
|
||||||
|
*ConnectDataLength = CReply->ConnectDataLength;
|
||||||
|
memcpy(ConnectData, CReply->ConnectData, CReply->ConnectDataLength);
|
||||||
|
}
|
||||||
|
return(STATUS_PORT_CONNECTION_REFUSED);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Otherwise we are connected. Copy data back to the client.
|
||||||
|
*/
|
||||||
|
*ServerSendViewBase = CReply->SendServerViewBase;
|
||||||
|
*ReceiveViewSize = CReply->ReceiveClientViewSize;
|
||||||
|
*ReceiveViewBase = CReply->ReceiveClientViewBase;
|
||||||
|
*MaximumMessageSize = CReply->MaximumMessageSize;
|
||||||
|
if (ConnectDataLength != NULL)
|
||||||
|
{
|
||||||
|
*ConnectDataLength = CReply->ConnectDataLength;
|
||||||
|
memcpy(ConnectData, CReply->ConnectData, CReply->ConnectDataLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create our view of the send section object.
|
||||||
|
*/
|
||||||
|
if (Section != NULL)
|
||||||
|
{
|
||||||
|
*ClientSendViewBase = 0;
|
||||||
|
Status = MmMapViewOfSection(Section,
|
||||||
|
PsGetCurrentProcess(),
|
||||||
|
ClientSendViewBase,
|
||||||
|
0,
|
||||||
|
ViewSize,
|
||||||
|
&SectionOffset,
|
||||||
|
&ViewSize,
|
||||||
|
ViewUnmap,
|
||||||
|
0 /* MEM_TOP_DOWN? */,
|
||||||
|
PAGE_READWRITE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* FIXME: Cleanup here. */
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Do the final initialization of our port.
|
||||||
|
*/
|
||||||
|
OurPort->State = EPORT_CONNECTED_CLIENT;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Cleanup.
|
||||||
|
*/
|
||||||
|
ExFreePool(Reply);
|
||||||
|
*ConnectedPort = OurPort;
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* NAME EXPORTED
|
* NAME EXPORTED
|
||||||
* NtConnectPort@32
|
* NtConnectPort@32
|
||||||
|
@ -48,126 +234,254 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
NtConnectPort (PHANDLE ConnectedPort,
|
NtConnectPort (PHANDLE UnsafeConnectedPortHandle,
|
||||||
PUNICODE_STRING PortName,
|
PUNICODE_STRING PortName,
|
||||||
PSECURITY_QUALITY_OF_SERVICE Qos,
|
PSECURITY_QUALITY_OF_SERVICE Qos,
|
||||||
PLPC_SECTION_WRITE WriteMap,
|
PLPC_SECTION_WRITE UnsafeWriteMap,
|
||||||
PLPC_SECTION_READ ReadMap,
|
PLPC_SECTION_READ UnsafeReadMap,
|
||||||
PULONG MaxMessageSize,
|
PULONG UnsafeMaximumMessageSize,
|
||||||
PVOID ConnectInfo,
|
PVOID UnsafeConnectData,
|
||||||
PULONG UserConnectInfoLength)
|
PULONG UnsafeConnectDataLength)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
HANDLE ConnectedPortHandle;
|
||||||
PEPORT NamedPort;
|
LPC_SECTION_WRITE WriteMap;
|
||||||
PEPORT OurPort;
|
LPC_SECTION_READ ReadMap;
|
||||||
HANDLE OurPortHandle;
|
ULONG MaximumMessageSize;
|
||||||
PLPC_MESSAGE Request;
|
PVOID ConnectData;
|
||||||
PQUEUEDMESSAGE Reply;
|
ULONG ConnectDataLength;
|
||||||
ULONG ConnectInfoLength;
|
PSECTION_OBJECT SectionObject;
|
||||||
KIRQL oldIrql;
|
LARGE_INTEGER SectionOffset;
|
||||||
|
PEPORT ConnectedPort;
|
||||||
DPRINT("PortName %x\n", PortName);
|
NTSTATUS Status;
|
||||||
DPRINT("NtConnectPort(PortName %S)\n", PortName->Buffer);
|
PEPORT NamedPort;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy in user parameters
|
* Copy in write map and partially validate.
|
||||||
*/
|
*/
|
||||||
memcpy (&ConnectInfoLength, UserConnectInfoLength,
|
if (UnsafeWriteMap != NULL)
|
||||||
sizeof (*UserConnectInfoLength));
|
{
|
||||||
|
Status = MmCopyFromCaller(&WriteMap, UnsafeWriteMap,
|
||||||
|
sizeof(LPC_SECTION_WRITE));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
if (WriteMap.Length != sizeof(LPC_SECTION_WRITE))
|
||||||
|
{
|
||||||
|
return(STATUS_INVALID_PARAMETER_4);
|
||||||
|
}
|
||||||
|
SectionOffset.QuadPart = WriteMap.SectionOffset;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WriteMap.SectionHandle = INVALID_HANDLE_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get access to the port
|
* Handle connection data.
|
||||||
|
*/
|
||||||
|
if (UnsafeConnectData == NULL)
|
||||||
|
{
|
||||||
|
ConnectDataLength = 0;
|
||||||
|
ConnectData = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ExGetPreviousMode() == KernelMode)
|
||||||
|
{
|
||||||
|
ConnectDataLength = *UnsafeConnectDataLength;
|
||||||
|
ConnectData = UnsafeConnectData;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = MmCopyFromCaller(&ConnectDataLength,
|
||||||
|
UnsafeConnectDataLength,
|
||||||
|
sizeof(ULONG));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
ConnectData = ExAllocatePool(NonPagedPool, ConnectDataLength);
|
||||||
|
if (ConnectData == NULL && ConnectDataLength != 0)
|
||||||
|
{
|
||||||
|
return(STATUS_NO_MEMORY);
|
||||||
|
}
|
||||||
|
Status = MmCopyFromCaller(ConnectData,
|
||||||
|
UnsafeConnectData,
|
||||||
|
ConnectDataLength);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ExFreePool(ConnectData);
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reference the named port.
|
||||||
*/
|
*/
|
||||||
Status = ObReferenceObjectByName (PortName,
|
Status = ObReferenceObjectByName (PortName,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
PORT_ALL_ACCESS, /* DesiredAccess */
|
PORT_ALL_ACCESS, /* DesiredAccess */
|
||||||
ExPortType,
|
ExPortType,
|
||||||
UserMode,
|
UserMode,
|
||||||
NULL,
|
NULL,
|
||||||
(PVOID*)&NamedPort);
|
(PVOID*)&NamedPort);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Failed to reference named port (status %x)\n", Status);
|
if (KeGetPreviousMode() != KernelMode)
|
||||||
return (Status);
|
{
|
||||||
|
ExFreePool(ConnectData);
|
||||||
|
}
|
||||||
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a port to represent our side of the connection
|
* Reference the send section object.
|
||||||
*/
|
*/
|
||||||
Status = ObCreateObject (&OurPortHandle,
|
if (WriteMap.SectionHandle != INVALID_HANDLE_VALUE)
|
||||||
PORT_ALL_ACCESS,
|
{
|
||||||
NULL,
|
Status = ObReferenceObjectByHandle(WriteMap.SectionHandle,
|
||||||
ExPortType,
|
SECTION_MAP_READ | SECTION_MAP_WRITE,
|
||||||
(PVOID*)&OurPort);
|
MmSectionObjectType,
|
||||||
|
UserMode,
|
||||||
|
(PVOID*)&SectionObject,
|
||||||
|
NULL);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ObDereferenceObject(NamedPort);
|
||||||
|
if (KeGetPreviousMode() != KernelMode)
|
||||||
|
{
|
||||||
|
ExFreePool(ConnectData);
|
||||||
|
}
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SectionObject = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Do the connection establishment.
|
||||||
|
*/
|
||||||
|
Status = EiConnectPort(&ConnectedPort,
|
||||||
|
NamedPort,
|
||||||
|
SectionObject,
|
||||||
|
SectionOffset,
|
||||||
|
WriteMap.ViewSize,
|
||||||
|
&WriteMap.ViewBase,
|
||||||
|
&WriteMap.TargetViewBase,
|
||||||
|
&ReadMap.ViewSize,
|
||||||
|
&ReadMap.ViewBase,
|
||||||
|
&MaximumMessageSize,
|
||||||
|
ConnectData,
|
||||||
|
&ConnectDataLength);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Failed to create port object (status %x)\n", Status);
|
/* FIXME: Again, check what NT does here. */
|
||||||
return (Status);
|
if (UnsafeConnectDataLength != NULL)
|
||||||
|
{
|
||||||
|
if (ExGetPreviousMode() != KernelMode)
|
||||||
|
{
|
||||||
|
MmCopyToCaller(UnsafeConnectData, ConnectData,
|
||||||
|
ConnectDataLength);
|
||||||
|
ExFreePool(ConnectData);
|
||||||
|
}
|
||||||
|
MmCopyToCaller(UnsafeConnectDataLength, &ConnectDataLength,
|
||||||
|
sizeof(ULONG));
|
||||||
|
}
|
||||||
|
return(Status);
|
||||||
}
|
}
|
||||||
NiInitializePort(OurPort);
|
|
||||||
/*
|
/*
|
||||||
* Create a request message
|
* Do some initial cleanup.
|
||||||
*/
|
*/
|
||||||
DPRINT("Creating request message\n");
|
if (SectionObject != NULL)
|
||||||
|
|
||||||
Request = ExAllocatePoolWithTag (NonPagedPool,
|
|
||||||
(sizeof (LPC_MESSAGE) + ConnectInfoLength),
|
|
||||||
TAG_LPC_CONNECT_MESSAGE);
|
|
||||||
|
|
||||||
Request->DataSize = ConnectInfoLength;
|
|
||||||
Request->MessageSize = sizeof(LPC_MESSAGE) + ConnectInfoLength;
|
|
||||||
Request->SharedSectionSize = 0;
|
|
||||||
if ((ConnectInfo != NULL) && (ConnectInfoLength > 0))
|
|
||||||
{
|
{
|
||||||
memcpy ((PVOID) (Request + 1), ConnectInfo, ConnectInfoLength);
|
ObDereferenceObject(SectionObject);
|
||||||
|
SectionObject = NULL;
|
||||||
}
|
}
|
||||||
/*
|
ObDereferenceObject(NamedPort);
|
||||||
* Queue the message to the named port
|
NamedPort = NULL;
|
||||||
*/
|
|
||||||
DPRINT("Queuing message\n");
|
|
||||||
|
|
||||||
EiReplyOrRequestPort (NamedPort,
|
|
||||||
Request,
|
|
||||||
LPC_CONNECTION_REQUEST,
|
|
||||||
OurPort);
|
|
||||||
KeReleaseSemaphore( &NamedPort->Semaphore, IO_NO_INCREMENT, 1, FALSE );
|
|
||||||
|
|
||||||
DPRINT("Waiting for connection completion\n");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wait for them to accept our connection
|
* Copy the data back to the caller.
|
||||||
*/
|
*/
|
||||||
KeWaitForSingleObject (&OurPort->Semaphore,
|
if (ExGetPreviousMode() != KernelMode)
|
||||||
UserRequest,
|
|
||||||
UserMode,
|
|
||||||
FALSE,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
DPRINT("Received connection completion\n");
|
|
||||||
KeAcquireSpinLock (&OurPort->Lock, &oldIrql);
|
|
||||||
Reply = EiDequeueMessagePort (OurPort);
|
|
||||||
KeReleaseSpinLock (&OurPort->Lock, oldIrql);
|
|
||||||
memcpy (ConnectInfo, Reply->MessageData, Reply->Message.DataSize);
|
|
||||||
*UserConnectInfoLength = Reply->Message.DataSize;
|
|
||||||
|
|
||||||
if (Reply->Message.MessageType == LPC_CONNECTION_REFUSED)
|
|
||||||
{
|
{
|
||||||
ObDereferenceObject (NamedPort);
|
if (UnsafeConnectDataLength != NULL)
|
||||||
ObDereferenceObject (OurPort);
|
{
|
||||||
ZwClose (OurPortHandle);
|
if (ExGetPreviousMode() != KernelMode)
|
||||||
ExFreePool (Request);
|
{
|
||||||
ExFreePool (Reply);
|
Status = MmCopyToCaller(UnsafeConnectData, ConnectData,
|
||||||
return (STATUS_UNSUCCESSFUL);
|
ConnectDataLength);
|
||||||
|
ExFreePool(ConnectData);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Status = MmCopyToCaller(UnsafeConnectDataLength, &ConnectDataLength,
|
||||||
|
sizeof(ULONG));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Status = ObInsertObject(ConnectedPort,
|
||||||
|
NULL,
|
||||||
|
PORT_ALL_ACCESS,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
&ConnectedPortHandle);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
Status = MmCopyToCaller(UnsafeConnectedPortHandle, &ConnectedPortHandle,
|
||||||
|
sizeof(HANDLE));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
if (UnsafeWriteMap != NULL)
|
||||||
|
{
|
||||||
|
Status = MmCopyToCaller(UnsafeWriteMap, &WriteMap,
|
||||||
|
sizeof(LPC_SECTION_WRITE));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (UnsafeReadMap != NULL)
|
||||||
|
{
|
||||||
|
Status = MmCopyToCaller(UnsafeReadMap, &ReadMap,
|
||||||
|
sizeof(LPC_SECTION_READ));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (UnsafeMaximumMessageSize != NULL)
|
||||||
|
{
|
||||||
|
Status = MmCopyToCaller(UnsafeMaximumMessageSize,
|
||||||
|
&MaximumMessageSize,
|
||||||
|
sizeof(LPC_SECTION_WRITE));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OurPort->State = EPORT_CONNECTED_CLIENT;
|
/*
|
||||||
*ConnectedPort = OurPortHandle;
|
* All done.
|
||||||
ExFreePool (Reply);
|
*/
|
||||||
ExFreePool (Request);
|
ObDereferenceObject(ConnectedPort);
|
||||||
|
|
||||||
DPRINT("Exited successfully\n");
|
return(STATUS_SUCCESS);
|
||||||
|
|
||||||
return (STATUS_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -201,17 +515,28 @@ NtAcceptConnectPort (PHANDLE ServerPortHandle,
|
||||||
PEPORT OurPort = NULL;
|
PEPORT OurPort = NULL;
|
||||||
PQUEUEDMESSAGE ConnectionRequest;
|
PQUEUEDMESSAGE ConnectionRequest;
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
|
PEPORT_CONNECT_REQUEST_MESSAGE CRequest;
|
||||||
|
PEPORT_CONNECT_REPLY_MESSAGE CReply;
|
||||||
|
|
||||||
Status = ObReferenceObjectByHandle (NamedPortHandle,
|
CReply = ExAllocatePool(NonPagedPool,
|
||||||
PORT_ALL_ACCESS,
|
sizeof(EPORT_CONNECT_REPLY_MESSAGE) + LpcMessage->DataSize);
|
||||||
ExPortType,
|
if (CReply == NULL)
|
||||||
UserMode,
|
{
|
||||||
(PVOID*)&NamedPort,
|
return(STATUS_NO_MEMORY);
|
||||||
NULL);
|
}
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByHandle(NamedPortHandle,
|
||||||
|
PORT_ALL_ACCESS,
|
||||||
|
ExPortType,
|
||||||
|
UserMode,
|
||||||
|
(PVOID*)&NamedPort,
|
||||||
|
NULL);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
ExFreePool(CReply);
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a port object for our side of the connection
|
* Create a port object for our side of the connection
|
||||||
*/
|
*/
|
||||||
|
@ -229,41 +554,162 @@ NtAcceptConnectPort (PHANDLE ServerPortHandle,
|
||||||
}
|
}
|
||||||
NiInitializePort(OurPort);
|
NiInitializePort(OurPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dequeue the connection request
|
* Dequeue the connection request
|
||||||
*/
|
*/
|
||||||
KeAcquireSpinLock (&NamedPort->Lock, & oldIrql);
|
KeAcquireSpinLock(&NamedPort->Lock, &oldIrql);
|
||||||
ConnectionRequest = EiDequeueConnectMessagePort (NamedPort);
|
ConnectionRequest = EiDequeueConnectMessagePort (NamedPort);
|
||||||
KeReleaseSpinLock (&NamedPort->Lock, oldIrql);
|
KeReleaseSpinLock(&NamedPort->Lock, oldIrql);
|
||||||
|
CRequest = (PEPORT_CONNECT_REQUEST_MESSAGE)(&ConnectionRequest->Message);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prepare the reply.
|
||||||
|
*/
|
||||||
|
if (LpcMessage != NULL)
|
||||||
|
{
|
||||||
|
memcpy(&CReply->MessageHeader, LpcMessage, sizeof(LPC_MESSAGE_HEADER));
|
||||||
|
memcpy(&CReply->ConnectData, (PVOID)(LpcMessage + 1),
|
||||||
|
LpcMessage->DataSize);
|
||||||
|
CReply->MessageHeader.MessageSize =
|
||||||
|
sizeof(EPORT_CONNECT_REPLY_MESSAGE) + LpcMessage->DataSize;
|
||||||
|
CReply->MessageHeader.DataSize = CReply->MessageHeader.MessageSize -
|
||||||
|
sizeof(LPC_MESSAGE_HEADER);
|
||||||
|
CReply->ConnectDataLength = LpcMessage->DataSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CReply->MessageHeader.MessageSize = sizeof(EPORT_CONNECT_REPLY_MESSAGE);
|
||||||
|
CReply->MessageHeader.DataSize = sizeof(EPORT_CONNECT_REPLY_MESSAGE) -
|
||||||
|
sizeof(LPC_MESSAGE_HEADER);
|
||||||
|
CReply->ConnectDataLength = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (AcceptIt != 1)
|
if (AcceptIt != 1)
|
||||||
{
|
{
|
||||||
EiReplyOrRequestPort (ConnectionRequest->Sender,
|
EiReplyOrRequestPort(ConnectionRequest->Sender,
|
||||||
LpcMessage,
|
&CReply->MessageHeader,
|
||||||
LPC_CONNECTION_REFUSED,
|
LPC_CONNECTION_REFUSED,
|
||||||
NamedPort);
|
NamedPort);
|
||||||
KeReleaseSemaphore( &ConnectionRequest->Sender->Semaphore,
|
KeReleaseSemaphore(&ConnectionRequest->Sender->Semaphore,
|
||||||
IO_NO_INCREMENT,
|
IO_NO_INCREMENT,
|
||||||
1,
|
1,
|
||||||
FALSE);
|
FALSE);
|
||||||
ObDereferenceObject (ConnectionRequest->Sender);
|
ObDereferenceObject(ConnectionRequest->Sender);
|
||||||
ExFreePool (ConnectionRequest);
|
ExFreePool(ConnectionRequest);
|
||||||
ObDereferenceObject (NamedPort);
|
ExFreePool(CReply);
|
||||||
|
ObDereferenceObject(NamedPort);
|
||||||
return (STATUS_SUCCESS);
|
return (STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prepare the connection.
|
||||||
|
*/
|
||||||
|
if (WriteMap != NULL)
|
||||||
|
{
|
||||||
|
PSECTION_OBJECT SectionObject;
|
||||||
|
LARGE_INTEGER SectionOffset;
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByHandle(WriteMap->SectionHandle,
|
||||||
|
SECTION_MAP_READ | SECTION_MAP_WRITE,
|
||||||
|
MmSectionObjectType,
|
||||||
|
UserMode,
|
||||||
|
(PVOID*)&SectionObject,
|
||||||
|
NULL);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
SectionOffset.QuadPart = WriteMap->SectionOffset;
|
||||||
|
WriteMap->TargetViewBase = 0;
|
||||||
|
CReply->ReceiveClientViewSize = WriteMap->ViewSize;
|
||||||
|
Status = MmMapViewOfSection(SectionObject,
|
||||||
|
CRequest->ConnectingProcess,
|
||||||
|
&WriteMap->TargetViewBase,
|
||||||
|
0,
|
||||||
|
CReply->ReceiveClientViewSize,
|
||||||
|
&SectionOffset,
|
||||||
|
&CReply->ReceiveClientViewSize,
|
||||||
|
ViewUnmap,
|
||||||
|
0 /* MEM_TOP_DOWN? */,
|
||||||
|
PAGE_READWRITE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
WriteMap->ViewBase = 0;
|
||||||
|
Status = MmMapViewOfSection(SectionObject,
|
||||||
|
PsGetCurrentProcess(),
|
||||||
|
&WriteMap->ViewBase,
|
||||||
|
0,
|
||||||
|
WriteMap->ViewSize,
|
||||||
|
&SectionOffset,
|
||||||
|
&WriteMap->ViewSize,
|
||||||
|
ViewUnmap,
|
||||||
|
0 /* MEM_TOP_DOWN? */,
|
||||||
|
PAGE_READWRITE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
ObDereferenceObject(SectionObject);
|
||||||
|
}
|
||||||
|
if (ReadMap != NULL && CRequest->SendSectionObject != NULL)
|
||||||
|
{
|
||||||
|
LARGE_INTEGER SectionOffset;
|
||||||
|
|
||||||
|
SectionOffset = CRequest->SendSectionOffset;
|
||||||
|
ReadMap->ViewSize = CRequest->SendViewSize;
|
||||||
|
ReadMap->ViewBase = 0;
|
||||||
|
Status = MmMapViewOfSection(CRequest->SendSectionObject,
|
||||||
|
PsGetCurrentProcess(),
|
||||||
|
&ReadMap->ViewBase,
|
||||||
|
0,
|
||||||
|
CRequest->SendViewSize,
|
||||||
|
&SectionOffset,
|
||||||
|
&CRequest->SendViewSize,
|
||||||
|
ViewUnmap,
|
||||||
|
0 /* MEM_TOP_DOWN? */,
|
||||||
|
PAGE_READWRITE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Finish the reply.
|
||||||
|
*/
|
||||||
|
if (ReadMap != NULL)
|
||||||
|
{
|
||||||
|
CReply->SendServerViewBase = ReadMap->ViewBase;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CReply->SendServerViewBase = 0;
|
||||||
|
}
|
||||||
|
if (WriteMap != NULL)
|
||||||
|
{
|
||||||
|
CReply->ReceiveClientViewBase = WriteMap->TargetViewBase;
|
||||||
|
}
|
||||||
|
CReply->MaximumMessageSize = 0x148;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Connect the two ports
|
* Connect the two ports
|
||||||
*/
|
*/
|
||||||
OurPort->OtherPort = ConnectionRequest->Sender;
|
OurPort->OtherPort = ConnectionRequest->Sender;
|
||||||
OurPort->OtherPort->OtherPort = OurPort;
|
OurPort->OtherPort->OtherPort = OurPort;
|
||||||
EiReplyOrRequestPort (ConnectionRequest->Sender,
|
EiReplyOrRequestPort(ConnectionRequest->Sender,
|
||||||
LpcMessage,
|
LpcMessage,
|
||||||
LPC_REPLY,
|
LPC_REPLY,
|
||||||
OurPort);
|
OurPort);
|
||||||
ExFreePool (ConnectionRequest);
|
ExFreePool(ConnectionRequest);
|
||||||
|
|
||||||
ObDereferenceObject (OurPort);
|
ObDereferenceObject(OurPort);
|
||||||
ObDereferenceObject (NamedPort);
|
ObDereferenceObject(NamedPort);
|
||||||
|
|
||||||
return (STATUS_SUCCESS);
|
return (STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: create.c,v 1.5 2001/08/26 17:28:00 ekohl Exp $
|
/* $Id: create.c,v 1.6 2001/12/02 23:34:42 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -19,85 +19,75 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
static
|
STATIC NTSTATUS STDCALL
|
||||||
NTSTATUS STDCALL VerifyCreateParameters (
|
VerifyCreateParameters (IN PHANDLE PortHandle,
|
||||||
IN PHANDLE PortHandle,
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
IN ULONG MaxConnectInfoLength,
|
||||||
IN ULONG MaxConnectInfoLength,
|
IN ULONG MaxDataLength,
|
||||||
IN ULONG MaxDataLength,
|
IN ULONG Reserved)
|
||||||
IN ULONG Reserved
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (NULL == PortHandle)
|
if (NULL == PortHandle)
|
||||||
{
|
{
|
||||||
return (STATUS_INVALID_PARAMETER_1);
|
return (STATUS_INVALID_PARAMETER_1);
|
||||||
}
|
}
|
||||||
if (NULL == ObjectAttributes)
|
if (NULL == ObjectAttributes)
|
||||||
{
|
{
|
||||||
return (STATUS_INVALID_PARAMETER_2);
|
return (STATUS_INVALID_PARAMETER_2);
|
||||||
}
|
}
|
||||||
if ( (ObjectAttributes->Attributes & OBJ_OPENLINK)
|
if ((ObjectAttributes->Attributes & OBJ_OPENLINK)
|
||||||
|| (ObjectAttributes->Attributes & OBJ_OPENIF)
|
|| (ObjectAttributes->Attributes & OBJ_OPENIF)
|
||||||
|| (ObjectAttributes->Attributes & OBJ_EXCLUSIVE)
|
|| (ObjectAttributes->Attributes & OBJ_EXCLUSIVE)
|
||||||
|| (ObjectAttributes->Attributes & OBJ_PERMANENT)
|
|| (ObjectAttributes->Attributes & OBJ_PERMANENT)
|
||||||
|| (ObjectAttributes->Attributes & OBJ_INHERIT)
|
|| (ObjectAttributes->Attributes & OBJ_INHERIT))
|
||||||
// || (ObjectAttributes->Attributes & OBJ_KERNEL_HANDLE)
|
{
|
||||||
)
|
return (STATUS_INVALID_PORT_ATTRIBUTES);
|
||||||
{
|
}
|
||||||
return (STATUS_INVALID_PORT_ATTRIBUTES);
|
if (MaxConnectInfoLength > 0x104) /* FIXME: use a macro! */
|
||||||
}
|
{
|
||||||
if (MaxConnectInfoLength > 0x104) /* FIXME: use a macro! */
|
return (STATUS_INVALID_PARAMETER_3);
|
||||||
{
|
}
|
||||||
return (STATUS_INVALID_PARAMETER_3);
|
if (MaxDataLength > 0x148) /* FIXME: use a macro! */
|
||||||
}
|
{
|
||||||
if (MaxDataLength > 0x148) /* FIXME: use a macro! */
|
return (STATUS_INVALID_PARAMETER_4);
|
||||||
{
|
}
|
||||||
return (STATUS_INVALID_PARAMETER_4);
|
/* FIXME: some checking is done also on Reserved */
|
||||||
}
|
return (STATUS_SUCCESS);
|
||||||
/* FIXME: some checking is done also on Reserved */
|
|
||||||
return (STATUS_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
NiCreatePort (
|
NiCreatePort (PVOID ObjectBody,
|
||||||
PVOID ObjectBody,
|
PVOID Parent,
|
||||||
PVOID Parent,
|
PWSTR RemainingPath,
|
||||||
PWSTR RemainingPath,
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
if (RemainingPath == NULL)
|
if (RemainingPath == NULL)
|
||||||
{
|
{
|
||||||
return (STATUS_SUCCESS);
|
return (STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wcschr(RemainingPath+1, '\\') != NULL)
|
if (wcschr(RemainingPath+1, '\\') != NULL)
|
||||||
{
|
{
|
||||||
return (STATUS_UNSUCCESSFUL);
|
return (STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = ObReferenceObjectByPointer (
|
Status = ObReferenceObjectByPointer (Parent,
|
||||||
Parent,
|
STANDARD_RIGHTS_REQUIRED,
|
||||||
STANDARD_RIGHTS_REQUIRED,
|
ObDirectoryType,
|
||||||
ObDirectoryType,
|
UserMode);
|
||||||
UserMode
|
if (!NT_SUCCESS(Status))
|
||||||
);
|
{
|
||||||
if (!NT_SUCCESS(Status))
|
return (Status);
|
||||||
{
|
}
|
||||||
return (Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
ObAddEntryDirectory (
|
ObAddEntryDirectory (Parent,
|
||||||
Parent,
|
ObjectBody,
|
||||||
ObjectBody,
|
(RemainingPath + 1));
|
||||||
(RemainingPath + 1)
|
ObDereferenceObject (Parent);
|
||||||
);
|
|
||||||
ObDereferenceObject (Parent);
|
|
||||||
|
|
||||||
return (STATUS_SUCCESS);
|
return (STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,54 +107,46 @@ NiCreatePort (
|
||||||
* RETURN VALUE
|
* RETURN VALUE
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
EXPORTED
|
EXPORTED NTSTATUS STDCALL
|
||||||
NTSTATUS
|
NtCreatePort (PHANDLE PortHandle,
|
||||||
STDCALL
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
NtCreatePort (
|
ULONG MaxConnectInfoLength,
|
||||||
PHANDLE PortHandle,
|
ULONG MaxDataLength,
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes,
|
ULONG Reserved)
|
||||||
ULONG MaxConnectInfoLength,
|
|
||||||
ULONG MaxDataLength,
|
|
||||||
ULONG Reserved
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
PEPORT Port;
|
PEPORT Port;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("NtCreatePort() Name %x\n", ObjectAttributes->ObjectName->Buffer);
|
DPRINT("NtCreatePort() Name %x\n", ObjectAttributes->ObjectName->Buffer);
|
||||||
|
|
||||||
/* Verify parameters */
|
/* Verify parameters */
|
||||||
Status = VerifyCreateParameters (
|
Status = VerifyCreateParameters (PortHandle,
|
||||||
PortHandle,
|
ObjectAttributes,
|
||||||
ObjectAttributes,
|
MaxConnectInfoLength,
|
||||||
MaxConnectInfoLength,
|
MaxDataLength,
|
||||||
MaxDataLength,
|
Reserved);
|
||||||
Reserved
|
if (!NT_SUCCESS(Status))
|
||||||
);
|
{
|
||||||
if (!NT_SUCCESS(Status))
|
return (Status);
|
||||||
{
|
}
|
||||||
return (Status);
|
/* Ask Ob to create the object */
|
||||||
}
|
Status = ObCreateObject (PortHandle,
|
||||||
/* Ask Ob to create the object */
|
PORT_ALL_ACCESS,
|
||||||
Status = ObCreateObject (
|
ObjectAttributes,
|
||||||
PortHandle,
|
ExPortType,
|
||||||
PORT_ALL_ACCESS,
|
(PVOID*)&Port);
|
||||||
ObjectAttributes,
|
if (!NT_SUCCESS(Status))
|
||||||
ExPortType,
|
{
|
||||||
(PVOID*)&Port
|
return (Status);
|
||||||
);
|
}
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return (Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = NiInitializePort (Port);
|
Status = NiInitializePort (Port);
|
||||||
Port->MaxConnectInfoLength = 260; /* FIXME: use a macro! */
|
Port->MaxConnectInfoLength = 260; /* FIXME: use a macro! */
|
||||||
Port->MaxDataLength = 328; /* FIXME: use a macro! */
|
Port->MaxDataLength = 328; /* FIXME: use a macro! */
|
||||||
|
|
||||||
ObDereferenceObject (Port);
|
ObDereferenceObject (Port);
|
||||||
|
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
@ -187,33 +169,27 @@ NtCreatePort (
|
||||||
* RETURN VALUE
|
* RETURN VALUE
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
EXPORTED
|
EXPORTED NTSTATUS STDCALL
|
||||||
NTSTATUS
|
NtCreateWaitablePort (OUT PHANDLE PortHandle,
|
||||||
STDCALL
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
NtCreateWaitablePort (
|
IN ULONG MaxConnectInfoLength,
|
||||||
OUT PHANDLE PortHandle,
|
IN ULONG MaxDataLength,
|
||||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
IN ULONG Reserved)
|
||||||
IN ULONG MaxConnectInfoLength,
|
|
||||||
IN ULONG MaxDataLength,
|
|
||||||
IN ULONG Reserved
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
/* Verify parameters */
|
/* Verify parameters */
|
||||||
Status = VerifyCreateParameters (
|
Status = VerifyCreateParameters (PortHandle,
|
||||||
PortHandle,
|
ObjectAttributes,
|
||||||
ObjectAttributes,
|
MaxConnectInfoLength,
|
||||||
MaxConnectInfoLength,
|
MaxDataLength,
|
||||||
MaxDataLength,
|
Reserved);
|
||||||
Reserved
|
if (STATUS_SUCCESS != Status)
|
||||||
);
|
{
|
||||||
if (STATUS_SUCCESS != Status)
|
return (Status);
|
||||||
{
|
}
|
||||||
return (Status);
|
/* TODO */
|
||||||
}
|
return (STATUS_NOT_IMPLEMENTED);
|
||||||
/* TODO */
|
|
||||||
return (STATUS_NOT_IMPLEMENTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: listen.c,v 1.2 2000/10/22 16:36:51 ekohl Exp $
|
/* $Id: listen.c,v 1.3 2001/12/02 23:34:42 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <internal/ob.h>
|
#include <internal/ob.h>
|
||||||
|
@ -19,6 +19,7 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* NAME EXPORTED
|
* NAME EXPORTED
|
||||||
|
@ -43,42 +44,35 @@
|
||||||
* NOTE
|
* NOTE
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
EXPORTED
|
EXPORTED NTSTATUS STDCALL
|
||||||
NTSTATUS
|
NtListenPort (IN HANDLE PortHandle,
|
||||||
STDCALL
|
IN PLPC_MESSAGE ConnectMsg)
|
||||||
NtListenPort (
|
|
||||||
IN HANDLE PortHandle,
|
|
||||||
IN PLPC_MESSAGE ConnectMsg
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wait forever for a connection request.
|
* Wait forever for a connection request.
|
||||||
*/
|
*/
|
||||||
for (;;)
|
for (;;)
|
||||||
|
{
|
||||||
|
Status = NtReplyWaitReceivePort(PortHandle,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
ConnectMsg);
|
||||||
|
/*
|
||||||
|
* Accept only LPC_CONNECTION_REQUEST requests.
|
||||||
|
* Drop any other message.
|
||||||
|
*/
|
||||||
|
if (!NT_SUCCESS(Status) ||
|
||||||
|
LPC_CONNECTION_REQUEST == ConnectMsg->MessageType)
|
||||||
{
|
{
|
||||||
Status = NtReplyWaitReceivePort (
|
DPRINT("Got message (type %x)\n", LPC_CONNECTION_REQUEST);
|
||||||
PortHandle,
|
break;
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
ConnectMsg
|
|
||||||
);
|
|
||||||
/*
|
|
||||||
* Accept only LPC_CONNECTION_REQUEST requests.
|
|
||||||
* Drop any other message.
|
|
||||||
*/
|
|
||||||
if ( !NT_SUCCESS(Status)
|
|
||||||
|| (LPC_CONNECTION_REQUEST == ConnectMsg->MessageType)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
DPRINT("Got message (type %x)\n", LPC_CONNECTION_REQUEST);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
DPRINT("Got message (type %x)\n", ConnectMsg->MessageType);
|
|
||||||
}
|
}
|
||||||
|
DPRINT("Got message (type %x)\n", ConnectMsg->MessageType);
|
||||||
|
}
|
||||||
|
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: port.c,v 1.6 2001/06/23 19:13:33 phreak Exp $
|
/* $Id: port.c,v 1.7 2001/12/02 23:34:42 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -85,23 +85,20 @@ NTSTATUS NiInitPort (VOID)
|
||||||
* STATUS_SUCCESS if initialization succedeed. An error code
|
* STATUS_SUCCESS if initialization succedeed. An error code
|
||||||
* otherwise.
|
* otherwise.
|
||||||
*/
|
*/
|
||||||
NTSTATUS
|
NTSTATUS STDCALL
|
||||||
STDCALL
|
NiInitializePort (IN OUT PEPORT Port)
|
||||||
NiInitializePort (
|
|
||||||
IN OUT PEPORT Port
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
memset (Port, 0, sizeof(EPORT));
|
memset (Port, 0, sizeof(EPORT));
|
||||||
KeInitializeSpinLock (& Port->Lock);
|
KeInitializeSpinLock (& Port->Lock);
|
||||||
KeInitializeSemaphore( &Port->Semaphore, 0, LONG_MAX );
|
KeInitializeSemaphore( &Port->Semaphore, 0, LONG_MAX );
|
||||||
Port->OtherPort = NULL;
|
Port->OtherPort = NULL;
|
||||||
Port->QueueLength = 0;
|
Port->QueueLength = 0;
|
||||||
Port->ConnectQueueLength = 0;
|
Port->ConnectQueueLength = 0;
|
||||||
Port->State = EPORT_INACTIVE;
|
Port->State = EPORT_INACTIVE;
|
||||||
InitializeListHead (& Port->QueueListHead);
|
InitializeListHead (& Port->QueueListHead);
|
||||||
InitializeListHead (& Port->ConnectQueueListHead);
|
InitializeListHead (& Port->ConnectQueueListHead);
|
||||||
|
|
||||||
return (STATUS_SUCCESS);
|
return (STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,14 +118,11 @@ NiInitializePort (
|
||||||
* RETURN VALUE
|
* RETURN VALUE
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
NTSTATUS
|
NTSTATUS STDCALL
|
||||||
STDCALL
|
NtImpersonateClientOfPort (HANDLE PortHandle,
|
||||||
NtImpersonateClientOfPort (
|
PLPC_MESSAGE ClientMessage)
|
||||||
HANDLE PortHandle,
|
|
||||||
PLPC_MESSAGE ClientMessage
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: query.c,v 1.2 2000/10/22 16:36:51 ekohl Exp $
|
/* $Id: query.c,v 1.3 2001/12/02 23:34:42 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -19,6 +19,7 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* NAME EXPORTED
|
* NAME EXPORTED
|
||||||
|
@ -41,38 +42,32 @@
|
||||||
* P. Dabak reports that this system service seems to return
|
* P. Dabak reports that this system service seems to return
|
||||||
* no information.
|
* no information.
|
||||||
*/
|
*/
|
||||||
EXPORTED
|
EXPORTED NTSTATUS STDCALL
|
||||||
NTSTATUS
|
NtQueryInformationPort (IN HANDLE PortHandle,
|
||||||
STDCALL
|
IN CINT PortInformationClass,
|
||||||
NtQueryInformationPort (
|
OUT PVOID PortInformation,
|
||||||
IN HANDLE PortHandle,
|
IN ULONG PortInformationLength,
|
||||||
IN CINT PortInformationClass,
|
OUT PULONG ReturnLength)
|
||||||
OUT PVOID PortInformation,
|
|
||||||
IN ULONG PortInformationLength,
|
|
||||||
OUT PULONG ReturnLength
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PEPORT Port;
|
PEPORT Port;
|
||||||
|
|
||||||
Status = ObReferenceObjectByHandle (
|
Status = ObReferenceObjectByHandle (PortHandle,
|
||||||
PortHandle,
|
PORT_ALL_ACCESS, /* AccessRequired */
|
||||||
PORT_ALL_ACCESS, /* AccessRequired */
|
ExPortType,
|
||||||
ExPortType,
|
UserMode,
|
||||||
UserMode,
|
(PVOID *) & Port,
|
||||||
(PVOID *) & Port,
|
NULL);
|
||||||
NULL
|
if (!NT_SUCCESS(Status))
|
||||||
);
|
{
|
||||||
if (!NT_SUCCESS(Status))
|
DPRINT("NtQueryInformationPort() = %x\n", Status);
|
||||||
{
|
return (Status);
|
||||||
DPRINT("NtQueryInformationPort() = %x\n", Status);
|
}
|
||||||
return (Status);
|
/*
|
||||||
}
|
* FIXME: NT does nothing here!
|
||||||
/*
|
*/
|
||||||
* FIXME: NT does nothing here!
|
ObDereferenceObject (Port);
|
||||||
*/
|
return STATUS_SUCCESS;
|
||||||
ObDereferenceObject (Port);
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: queue.c,v 1.4 2001/11/25 15:21:10 dwelch Exp $
|
/* $Id: queue.c,v 1.5 2001/12/02 23:34:42 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -19,6 +19,7 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
EiEnqueueMessagePort (IN OUT PEPORT Port,
|
EiEnqueueMessagePort (IN OUT PEPORT Port,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: receive.c,v 1.2 2000/10/22 16:36:51 ekohl Exp $
|
/* $Id: receive.c,v 1.3 2001/12/02 23:34:42 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -19,6 +19,7 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* NAME SYSTEM
|
* NAME SYSTEM
|
||||||
|
@ -30,16 +31,13 @@
|
||||||
* RETURN VALUE
|
* RETURN VALUE
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
NTSTATUS
|
NTSTATUS STDCALL
|
||||||
STDCALL
|
NtReadRequestData (HANDLE PortHandle,
|
||||||
NtReadRequestData (
|
PLPC_MESSAGE Message,
|
||||||
HANDLE PortHandle,
|
ULONG Index,
|
||||||
PLPC_MESSAGE Message,
|
PVOID Buffer,
|
||||||
ULONG Index,
|
ULONG BufferLength,
|
||||||
PVOID Buffer,
|
PULONG Returnlength)
|
||||||
ULONG BufferLength,
|
|
||||||
PULONG Returnlength
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: reply.c,v 1.8 2001/11/25 15:21:10 dwelch Exp $
|
/* $Id: reply.c,v 1.9 2001/12/02 23:34:42 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -112,7 +112,7 @@ NtReplyPort (IN HANDLE PortHandle,
|
||||||
LpcReply,
|
LpcReply,
|
||||||
LPC_REPLY,
|
LPC_REPLY,
|
||||||
Port);
|
Port);
|
||||||
KeReleaseSemaphore( &Port->OtherPort->Semaphore, IO_NO_INCREMENT, 1, FALSE );
|
KeReleaseSemaphore(&Port->OtherPort->Semaphore, IO_NO_INCREMENT, 1, FALSE);
|
||||||
|
|
||||||
ObDereferenceObject(Port);
|
ObDereferenceObject(Port);
|
||||||
|
|
||||||
|
@ -170,9 +170,10 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle,
|
||||||
}
|
}
|
||||||
if( Port->State == EPORT_DISCONNECTED )
|
if( Port->State == EPORT_DISCONNECTED )
|
||||||
{
|
{
|
||||||
// if the port is disconnected, force the timeout to be 0
|
/* If the port is disconnected, force the timeout to be 0
|
||||||
// so we don't wait for new messages, because there won't be
|
* so we don't wait for new messages, because there won't be
|
||||||
// any, only try to remove any existing messages
|
* any, only try to remove any existing messages
|
||||||
|
*/
|
||||||
Disconnected = TRUE;
|
Disconnected = TRUE;
|
||||||
to.QuadPart = 0;
|
to.QuadPart = 0;
|
||||||
Timeout = &to;
|
Timeout = &to;
|
||||||
|
@ -188,7 +189,8 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle,
|
||||||
LpcReply,
|
LpcReply,
|
||||||
LPC_REPLY,
|
LPC_REPLY,
|
||||||
Port);
|
Port);
|
||||||
KeReleaseSemaphore( &Port->OtherPort->Semaphore, IO_NO_INCREMENT, 1, FALSE);
|
KeReleaseSemaphore(&Port->OtherPort->Semaphore, IO_NO_INCREMENT, 1,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -208,16 +210,18 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle,
|
||||||
Timeout);
|
Timeout);
|
||||||
if( Status == STATUS_TIMEOUT )
|
if( Status == STATUS_TIMEOUT )
|
||||||
{
|
{
|
||||||
// if the port is disconnected, and there are no remaining messages,
|
/*
|
||||||
// return STATUS_PORT_DISCONNECTED
|
* if the port is disconnected, and there are no remaining messages,
|
||||||
ObDereferenceObject( Port );
|
* return STATUS_PORT_DISCONNECTED
|
||||||
return Disconnected ? STATUS_PORT_DISCONNECTED : STATUS_TIMEOUT;
|
*/
|
||||||
|
ObDereferenceObject(Port);
|
||||||
|
return(Disconnected ? STATUS_PORT_DISCONNECTED : STATUS_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("NtReplyWaitReceivePortEx() = %x\n", Status);
|
DPRINT1("NtReplyWaitReceivePortEx() = %x\n", Status);
|
||||||
ObDereferenceObject( Port );
|
ObDereferenceObject(Port);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,14 +231,34 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle,
|
||||||
KeAcquireSpinLock(&Port->Lock, &oldIrql);
|
KeAcquireSpinLock(&Port->Lock, &oldIrql);
|
||||||
Request = EiDequeueMessagePort(Port);
|
Request = EiDequeueMessagePort(Port);
|
||||||
|
|
||||||
assert( Request );
|
if (Request->Message.MessageType == LPC_CONNECTION_REQUEST)
|
||||||
Status = MmCopyToCaller(LpcMessage, &Request->Message,
|
{
|
||||||
Request->Message.MessageSize);
|
LPC_MESSAGE_HEADER Header;
|
||||||
|
PEPORT_CONNECT_REQUEST_MESSAGE CRequest;
|
||||||
|
|
||||||
|
CRequest = (PEPORT_CONNECT_REQUEST_MESSAGE)&Request->Message;
|
||||||
|
memcpy(&Header, &Request->Message, sizeof(LPC_MESSAGE_HEADER));
|
||||||
|
Header.DataSize = CRequest->ConnectDataLength;
|
||||||
|
Header.MessageSize = Header.DataSize + sizeof(LPC_MESSAGE_HEADER);
|
||||||
|
Status = MmCopyToCaller(LpcMessage, &Header, sizeof(LPC_MESSAGE));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
Status = MmCopyToCaller((PVOID)(LpcMessage + 1),
|
||||||
|
CRequest->ConnectData,
|
||||||
|
CRequest->ConnectDataLength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = MmCopyToCaller(LpcMessage, &Request->Message,
|
||||||
|
Request->Message.MessageSize);
|
||||||
|
}
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Copying the message to the caller's buffer failed so
|
* Copying the message to the caller's buffer failed so
|
||||||
* undo what we did and return.
|
* undo what we did and return.
|
||||||
|
* FIXME: Also increment semaphore.
|
||||||
*/
|
*/
|
||||||
EiEnqueueMessageAtHeadPort(Port, Request);
|
EiEnqueueMessageAtHeadPort(Port, Request);
|
||||||
KeReleaseSpinLock(&Port->Lock, oldIrql);
|
KeReleaseSpinLock(&Port->Lock, oldIrql);
|
||||||
|
@ -284,13 +308,11 @@ NtReplyWaitReceivePort (IN HANDLE PortHandle,
|
||||||
IN PLPC_MESSAGE LpcReply,
|
IN PLPC_MESSAGE LpcReply,
|
||||||
OUT PLPC_MESSAGE LpcMessage)
|
OUT PLPC_MESSAGE LpcMessage)
|
||||||
{
|
{
|
||||||
return NtReplyWaitReceivePortEx (
|
return(NtReplyWaitReceivePortEx (PortHandle,
|
||||||
PortHandle,
|
PortId,
|
||||||
PortId,
|
LpcReply,
|
||||||
LpcReply,
|
LpcMessage,
|
||||||
LpcMessage,
|
NULL));
|
||||||
NULL
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: section.c,v 1.66 2001/11/13 22:46:49 ekohl Exp $
|
/* $Id: section.c,v 1.67 2001/12/02 23:34:42 dwelch Exp $
|
||||||
*
|
*
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/mm/section.c
|
* FILE: ntoskrnl/mm/section.c
|
||||||
|
@ -376,7 +376,6 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
ULONG Entry1;
|
ULONG Entry1;
|
||||||
ULONG Attributes;
|
ULONG Attributes;
|
||||||
PMM_PAGEOP PageOp;
|
PMM_PAGEOP PageOp;
|
||||||
PVOID NewAddress;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There is a window between taking the page fault and locking the
|
* There is a window between taking the page fault and locking the
|
||||||
|
@ -525,7 +524,8 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
/*
|
/*
|
||||||
* Map anonymous memory for BSS sections
|
* Map anonymous memory for BSS sections
|
||||||
*/
|
*/
|
||||||
if (Segment->Characteristics & IMAGE_SECTION_CHAR_BSS)
|
if (Segment->Characteristics & IMAGE_SECTION_CHAR_BSS ||
|
||||||
|
Segment->Flags & MM_PAGEFILE_SECTION)
|
||||||
{
|
{
|
||||||
Page = MmAllocPage(0);
|
Page = MmAllocPage(0);
|
||||||
while (Page == NULL)
|
while (Page == NULL)
|
||||||
|
@ -540,11 +540,6 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
Page = MmAllocPage(0);
|
Page = MmAllocPage(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear the page
|
|
||||||
NewAddress = ExAllocatePageWithPhysPage((ULONG)Page);
|
|
||||||
memset(NewAddress, 0, PAGESIZE);
|
|
||||||
ExUnmapPage(NewAddress);
|
|
||||||
|
|
||||||
Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
|
Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
|
||||||
Address,
|
Address,
|
||||||
MemoryArea->Attributes,
|
MemoryArea->Attributes,
|
||||||
|
@ -1713,6 +1708,7 @@ MmMapViewOfSegment(PEPROCESS Process,
|
||||||
PMEMORY_AREA MArea;
|
PMEMORY_AREA MArea;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
|
|
||||||
MmLockAddressSpace(&Process->AddressSpace);
|
MmLockAddressSpace(&Process->AddressSpace);
|
||||||
Status = MmCreateMemoryArea(Process,
|
Status = MmCreateMemoryArea(Process,
|
||||||
&Process->AddressSpace,
|
&Process->AddressSpace,
|
||||||
|
|
|
@ -74,11 +74,13 @@ typedef struct CSRSS_CONSOLE_t
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
PCSRSS_CONSOLE Console;
|
PCSRSS_CONSOLE Console;
|
||||||
ULONG HandleTableSize;
|
ULONG HandleTableSize;
|
||||||
Object_t ** HandleTable;
|
Object_t ** HandleTable;
|
||||||
ULONG ProcessId;
|
ULONG ProcessId;
|
||||||
HANDLE ConsoleEvent;
|
HANDLE ConsoleEvent;
|
||||||
|
PVOID CsrSectionViewBase;
|
||||||
|
ULONG CsrSectionViewSize;
|
||||||
} CSRSS_PROCESS_DATA, *PCSRSS_PROCESS_DATA;
|
} CSRSS_PROCESS_DATA, *PCSRSS_PROCESS_DATA;
|
||||||
|
|
||||||
#define CSR_API(n) NTSTATUS n (\
|
#define CSR_API(n) NTSTATUS n (\
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: conio.c,v 1.26 2001/11/20 02:29:45 dwelch Exp $
|
/* $Id: conio.c,v 1.27 2001/12/02 23:34:43 dwelch Exp $
|
||||||
*
|
*
|
||||||
* reactos/subsys/csrss/api/conio.c
|
* reactos/subsys/csrss/api/conio.c
|
||||||
*
|
*
|
||||||
|
@ -1689,6 +1689,7 @@ CSR_API(CsrWriteConsoleOutput)
|
||||||
COORD BufferSize;
|
COORD BufferSize;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
DWORD Offset;
|
DWORD Offset;
|
||||||
|
DWORD PSize;
|
||||||
|
|
||||||
Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY);
|
Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY);
|
||||||
Reply->Header.DataSize = sizeof(CSRSS_API_REPLY) - sizeof(LPC_MESSAGE_HEADER);
|
Reply->Header.DataSize = sizeof(CSRSS_API_REPLY) - sizeof(LPC_MESSAGE_HEADER);
|
||||||
|
@ -1702,8 +1703,17 @@ CSR_API(CsrWriteConsoleOutput)
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferSize = Request->Data.WriteConsoleOutputRequest.BufferSize;
|
BufferSize = Request->Data.WriteConsoleOutputRequest.BufferSize;
|
||||||
|
PSize = BufferSize.X * BufferSize.Y * sizeof(CHAR_INFO);
|
||||||
BufferCoord = Request->Data.WriteConsoleOutputRequest.BufferCoord;
|
BufferCoord = Request->Data.WriteConsoleOutputRequest.BufferCoord;
|
||||||
CharInfo = (CHAR_INFO*)&Request->Data.WriteConsoleOutputRequest.CharInfo;
|
CharInfo = Request->Data.WriteConsoleOutputRequest.CharInfo;
|
||||||
|
if (((PVOID)CharInfo < ProcessData->CsrSectionViewBase) ||
|
||||||
|
(((PVOID)CharInfo + PSize) >
|
||||||
|
(ProcessData->CsrSectionViewBase + ProcessData->CsrSectionViewSize)))
|
||||||
|
{
|
||||||
|
UNLOCK;
|
||||||
|
Reply->Status = STATUS_ACCESS_VIOLATION;
|
||||||
|
return(Reply->Status);
|
||||||
|
}
|
||||||
WriteRegion = Request->Data.WriteConsoleOutputRequest.WriteRegion;
|
WriteRegion = Request->Data.WriteConsoleOutputRequest.WriteRegion;
|
||||||
|
|
||||||
SizeY = RtlMin(BufferSize.Y - BufferCoord.Y, CsrpRectHeight(WriteRegion));
|
SizeY = RtlMin(BufferSize.Y - BufferCoord.Y, CsrpRectHeight(WriteRegion));
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: wapi.c,v 1.15 2001/09/01 15:36:45 chorns Exp $
|
/* $Id: wapi.c,v 1.16 2001/12/02 23:34:43 dwelch Exp $
|
||||||
*
|
*
|
||||||
* reactos/subsys/csrss/api/wapi.c
|
* reactos/subsys/csrss/api/wapi.c
|
||||||
*
|
*
|
||||||
|
@ -113,11 +113,14 @@ void Thread_Api(PVOID PortHandle)
|
||||||
LPC_MAX_MESSAGE Request;
|
LPC_MAX_MESSAGE Request;
|
||||||
HANDLE ServerPort;
|
HANDLE ServerPort;
|
||||||
HANDLE ServerThread;
|
HANDLE ServerThread;
|
||||||
|
PCSRSS_PROCESS_DATA ProcessData;
|
||||||
|
|
||||||
CsrInitProcessData();
|
CsrInitProcessData();
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
LPC_SECTION_READ LpcRead;
|
||||||
|
|
||||||
Status = NtListenPort(PortHandle, &Request.Header);
|
Status = NtListenPort(PortHandle, &Request.Header);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -130,13 +133,17 @@ void Thread_Api(PVOID PortHandle)
|
||||||
NULL,
|
NULL,
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
NULL);
|
&LpcRead);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DisplayString(L"CSR: NtAcceptConnectPort() failed\n");
|
DisplayString(L"CSR: NtAcceptConnectPort() failed\n");
|
||||||
NtTerminateThread(NtCurrentThread(), Status);
|
NtTerminateThread(NtCurrentThread(), Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProcessData = CsrGetProcessData(Request.Header.Cid.UniqueProcess);
|
||||||
|
ProcessData->CsrSectionViewBase = LpcRead.ViewBase;
|
||||||
|
ProcessData->CsrSectionViewSize = LpcRead.ViewSize;
|
||||||
|
|
||||||
Status = NtCompleteConnectPort(ServerPort);
|
Status = NtCompleteConnectPort(ServerPort);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: init.c,v 1.26 2001/07/15 13:46:16 ekohl Exp $
|
/* $Id: init.c,v 1.27 2001/12/02 23:34:43 dwelch Exp $
|
||||||
*
|
*
|
||||||
* init.c - Session Manager initialization
|
* init.c - Session Manager initialization
|
||||||
*
|
*
|
||||||
|
@ -448,7 +448,7 @@ BOOL InitSessionManager (HANDLE Children[])
|
||||||
/* Load the kernel mode driver win32k.sys */
|
/* Load the kernel mode driver win32k.sys */
|
||||||
RtlInitUnicodeString (&CmdLineW,
|
RtlInitUnicodeString (&CmdLineW,
|
||||||
L"\\SystemRoot\\system32\\drivers\\win32k.sys");
|
L"\\SystemRoot\\system32\\drivers\\win32k.sys");
|
||||||
Status = NtLoadDriver (&CmdLineW);
|
// Status = NtLoadDriver (&CmdLineW);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
|
Loading…
Reference in a new issue