Present large reads to the filesystem from CcCopyRead

svn path=/trunk/; revision=2561
This commit is contained in:
David Welch 2002-01-26 21:21:02 +00:00
parent b51e21217f
commit aebf70e07f
5 changed files with 420 additions and 201 deletions

View file

@ -1,4 +1,4 @@
/* $Id: copy.c,v 1.3 2001/12/29 14:32:21 dwelch Exp $ /* $Id: copy.c,v 1.4 2002/01/26 21:21:02 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -28,7 +28,120 @@
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
NTSTATUS ReadCacheSegment(PCACHE_SEGMENT CacheSeg) NTSTATUS
ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length,
PVOID Buffer)
{
PCACHE_SEGMENT head;
PCACHE_SEGMENT current;
PCACHE_SEGMENT previous;
IO_STATUS_BLOCK Iosb;
LARGE_INTEGER SegOffset;
NTSTATUS Status;
ULONG TempLength;
Status = CcRosGetCacheSegmentChain(Bcb, ReadOffset, Length, &head);
if (!NT_SUCCESS(Status))
{
return(Status);
}
current = head;
while (current != NULL)
{
/*
* If the current segment is valid then copy it into the
* user buffer.
*/
if (current->Valid)
{
TempLength = min(Bcb->CacheSegmentSize, Length);
memcpy(Buffer, current->BaseAddress, TempLength);
Buffer += TempLength;
Length = Length - TempLength;
previous = current;
current = current->NextInChain;
CcRosReleaseCacheSegment(Bcb, previous, TRUE, FALSE, FALSE);
}
/*
* Otherwise read in a much as we can.
*/
else
{
PCACHE_SEGMENT current2;
ULONG current_size;
PMDL Mdl;
ULONG i;
ULONG offset;
/*
* Count the maximum number of bytes we could read starting
* from the current segment.
*/
current2 = current;
current_size = 0;
while (current2 != NULL && !current2->Valid)
{
current2 = current2->NextInChain;
current_size += Bcb->CacheSegmentSize;
}
/*
* Create an MDL which contains all their pages.
*/
Mdl = MmCreateMdl(NULL, NULL, current_size);
Mdl->MdlFlags |= (MDL_PAGES_LOCKED | MDL_IO_PAGE_READ);
current2 = current;
offset = 0;
while (current2 != NULL && !current2->Valid)
{
for (i = 0; i < (Bcb->CacheSegmentSize / PAGESIZE); i++)
{
PVOID address;
ULONG page;
address = current2->BaseAddress + (i * PAGESIZE);
page = MmGetPhysicalAddressForProcess(NULL, address);
((PULONG)(Mdl + 1))[offset] = page;
offset++;
}
current2 = current2->NextInChain;
}
/*
* Read in the information.
*/
SegOffset.QuadPart = current->FileOffset;
Status = IoPageRead(Bcb->FileObject,
Mdl,
&SegOffset,
&Iosb,
TRUE);
if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE)
{
while (current != NULL)
{
previous = current;
current = current->NextInChain;
CcRosReleaseCacheSegment(Bcb, previous, FALSE, FALSE, FALSE);
}
return(Status);
}
while (current != NULL && !current->Valid)
{
previous = current;
current = current->NextInChain;
TempLength = min(Bcb->CacheSegmentSize, Length);
memcpy(Buffer, previous->BaseAddress, TempLength);
Buffer += TempLength;
Length = Length - TempLength;
CcRosReleaseCacheSegment(Bcb, previous, TRUE, FALSE, FALSE);
}
}
}
return(STATUS_SUCCESS);
}
NTSTATUS
ReadCacheSegment(PCACHE_SEGMENT CacheSeg)
{ {
ULONG Size; ULONG Size;
PMDL Mdl; PMDL Mdl;
@ -44,7 +157,8 @@ NTSTATUS ReadCacheSegment(PCACHE_SEGMENT CacheSeg)
} }
Mdl = MmCreateMdl(NULL, CacheSeg->BaseAddress, Size); Mdl = MmCreateMdl(NULL, CacheSeg->BaseAddress, Size);
MmBuildMdlForNonPagedPool(Mdl); MmBuildMdlForNonPagedPool(Mdl);
Status = IoPageRead(CacheSeg->Bcb->FileObject, Mdl, &SegOffset, &IoStatus, TRUE); Status = IoPageRead(CacheSeg->Bcb->FileObject, Mdl, &SegOffset, &IoStatus,
TRUE);
if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE) if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE)
{ {
CcRosReleaseCacheSegment(CacheSeg->Bcb, CacheSeg, FALSE, FALSE, FALSE); CcRosReleaseCacheSegment(CacheSeg->Bcb, CacheSeg, FALSE, FALSE, FALSE);
@ -53,7 +167,8 @@ NTSTATUS ReadCacheSegment(PCACHE_SEGMENT CacheSeg)
} }
if (CacheSeg->Bcb->CacheSegmentSize > Size) if (CacheSeg->Bcb->CacheSegmentSize > Size)
{ {
memset (CacheSeg->BaseAddress + Size, 0, CacheSeg->Bcb->CacheSegmentSize - Size); memset (CacheSeg->BaseAddress + Size, 0,
CacheSeg->Bcb->CacheSegmentSize - Size);
} }
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -83,8 +198,7 @@ NTSTATUS WriteCacheSegment(PCACHE_SEGMENT CacheSeg)
} }
BOOLEAN STDCALL BOOLEAN STDCALL
CcCopyRead ( CcCopyRead (IN PFILE_OBJECT FileObject,
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER FileOffset,
IN ULONG Length, IN ULONG Length,
IN BOOLEAN Wait, IN BOOLEAN Wait,
@ -115,13 +229,18 @@ CcCopyRead (
(ULONG)Bcb->AllocationSize.QuadPart, (ULONG)Bcb->AllocationSize.QuadPart,
(ULONG)Bcb->FileSize.QuadPart); (ULONG)Bcb->FileSize.QuadPart);
/*
* Check for the nowait case that all the cache segments that would
* cover this read are in memory.
*/
if (!Wait) if (!Wait)
{ {
KeAcquireSpinLock(&Bcb->BcbLock, &oldirql); KeAcquireSpinLock(&Bcb->BcbLock, &oldirql);
current_entry = Bcb->BcbSegmentListHead.Flink; current_entry = Bcb->BcbSegmentListHead.Flink;
while (current_entry != &Bcb->BcbSegmentListHead) while (current_entry != &Bcb->BcbSegmentListHead)
{ {
current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, BcbSegmentListEntry); current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT,
BcbSegmentListEntry);
if (!current->Valid && current->FileOffset < ReadOffset + Length if (!current->Valid && current->FileOffset < ReadOffset + Length
&& current->FileOffset + Bcb->CacheSegmentSize > ReadOffset) && current->FileOffset + Bcb->CacheSegmentSize > ReadOffset)
{ {
@ -140,7 +259,8 @@ CcCopyRead (
{ {
TempLength = min (Length, Bcb->CacheSegmentSize - TempLength); TempLength = min (Length, Bcb->CacheSegmentSize - TempLength);
Status = CcRosRequestCacheSegment(Bcb, Status = CcRosRequestCacheSegment(Bcb,
ROUND_DOWN(ReadOffset, Bcb->CacheSegmentSize), ROUND_DOWN(ReadOffset,
Bcb->CacheSegmentSize),
&BaseAddress, &Valid, &CacheSeg); &BaseAddress, &Valid, &CacheSeg);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
@ -159,7 +279,8 @@ CcCopyRead (
return FALSE; return FALSE;
} }
} }
memcpy (Buffer, BaseAddress + ReadOffset % Bcb->CacheSegmentSize, TempLength); memcpy (Buffer, BaseAddress + ReadOffset % Bcb->CacheSegmentSize,
TempLength);
CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE); CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE);
ReadLength += TempLength; ReadLength += TempLength;
Length -= TempLength; Length -= TempLength;
@ -169,28 +290,8 @@ CcCopyRead (
while (Length > 0) while (Length > 0)
{ {
TempLength = min (Bcb->CacheSegmentSize, Length); TempLength = min(max(Bcb->CacheSegmentSize, 65536), Length);
Status = CcRosRequestCacheSegment(Bcb, ReadOffset, ReadCacheSegmentChain(Bcb, ReadOffset, TempLength, Buffer);
&BaseAddress, &Valid, &CacheSeg);
if (!NT_SUCCESS(Status))
{
IoStatus->Information = 0;
IoStatus->Status = Status;
DPRINT("CcRosRequestCacheSegment faild, Status %x\n", Status);
return FALSE;
}
if (!Valid)
{
Status = ReadCacheSegment(CacheSeg);
if (!NT_SUCCESS(Status))
{
IoStatus->Information = 0;
IoStatus->Status = Status;
return FALSE;
}
}
memcpy (Buffer, BaseAddress, TempLength);
CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE);
ReadLength += TempLength; ReadLength += TempLength;
Length -= TempLength; Length -= TempLength;
ReadOffset += TempLength; ReadOffset += TempLength;

View file

@ -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: view.c,v 1.35 2002/01/08 00:49:00 dwelch Exp $ /* $Id: view.c,v 1.36 2002/01/26 21:21:02 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -98,7 +98,8 @@ CcRosTrimCache(ULONG Target, ULONG Priority, PULONG NrFreed)
current_entry = CacheSegmentLRUListHead.Flink; current_entry = CacheSegmentLRUListHead.Flink;
while (current_entry != &CacheSegmentLRUListHead && Target > 0) while (current_entry != &CacheSegmentLRUListHead && Target > 0)
{ {
current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, CacheSegmentLRUListEntry); current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT,
CacheSegmentLRUListEntry);
current_entry = current_entry->Flink; current_entry = current_entry->Flink;
Locked = ExTryToAcquireFastMutex(&current->Lock); Locked = ExTryToAcquireFastMutex(&current->Lock);
if (!Locked) if (!Locked)
@ -229,52 +230,17 @@ CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty)
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
NTSTATUS NTSTATUS STATIC
CcRosGetCacheSegment(PBCB Bcb, CcRosCreateCacheSegment(PBCB Bcb,
ULONG FileOffset, ULONG FileOffset,
PULONG BaseOffset, PCACHE_SEGMENT* CacheSeg,
PVOID* BaseAddress, BOOLEAN Lock)
PBOOLEAN UptoDate,
PCACHE_SEGMENT* CacheSeg)
{ {
PCACHE_SEGMENT current;
ULONG i; ULONG i;
PCACHE_SEGMENT current;
NTSTATUS Status; NTSTATUS Status;
KIRQL oldIrql; KIRQL oldIrql;
/*
* Acquire the global lock.
*/
ExAcquireFastMutex(&ViewLock);
/*
* Look for a cache segment already mapping the same data.
*/
current = CcRosLookupCacheSegment(Bcb, FileOffset);
if (current != NULL)
{
/*
* Make sure the cache segment can't go away outside of our control.
*/
current->ReferenceCount++;
/*
* Release the global lock and lock the cache segment.
*/
ExReleaseFastMutex(&ViewLock);
ExAcquireFastMutex(&current->Lock);
/*
* Return information about the segment to the caller.
*/
*UptoDate = current->Valid;
*BaseAddress = current->BaseAddress;
*CacheSeg = current;
*BaseOffset = current->FileOffset;
return(STATUS_SUCCESS);
}
/*
* Otherwise create a new segment.
*/
current = ExAllocatePoolWithTag(NonPagedPool, sizeof(CACHE_SEGMENT), current = ExAllocatePoolWithTag(NonPagedPool, sizeof(CACHE_SEGMENT),
TAG_CSEG); TAG_CSEG);
@ -305,14 +271,15 @@ CcRosGetCacheSegment(PBCB Bcb,
InsertTailList(&Bcb->BcbSegmentListHead, &current->BcbSegmentListEntry); InsertTailList(&Bcb->BcbSegmentListHead, &current->BcbSegmentListEntry);
KeReleaseSpinLock(&Bcb->BcbLock, oldIrql); KeReleaseSpinLock(&Bcb->BcbLock, oldIrql);
InsertTailList(&CacheSegmentListHead, &current->CacheSegmentListEntry); InsertTailList(&CacheSegmentListHead, &current->CacheSegmentListEntry);
InsertTailList(&CacheSegmentLRUListHead, &current->CacheSegmentLRUListEntry); InsertTailList(&CacheSegmentLRUListHead,
current->DirtySegmentListEntry.Flink = current->DirtySegmentListEntry.Blink = NULL; &current->CacheSegmentLRUListEntry);
current->DirtySegmentListEntry.Flink =
current->DirtySegmentListEntry.Blink = NULL;
if (Lock)
{
ExAcquireFastMutex(&current->Lock); ExAcquireFastMutex(&current->Lock);
}
ExReleaseFastMutex(&ViewLock); ExReleaseFastMutex(&ViewLock);
*UptoDate = current->Valid;
*BaseAddress = current->BaseAddress;
*CacheSeg = current;
*BaseOffset = current->FileOffset;
for (i = 0; i < (Bcb->CacheSegmentSize / PAGESIZE); i++) for (i = 0; i < (Bcb->CacheSegmentSize / PAGESIZE); i++)
{ {
PVOID Page; PVOID Page;
@ -333,6 +300,126 @@ CcRosGetCacheSegment(PBCB Bcb,
KeBugCheck(0); KeBugCheck(0);
} }
} }
*CacheSeg = current;
return(STATUS_SUCCESS);
}
NTSTATUS
CcRosGetCacheSegmentChain(PBCB Bcb,
ULONG FileOffset,
ULONG Length,
PCACHE_SEGMENT* CacheSeg)
{
PCACHE_SEGMENT current;
ULONG i;
PCACHE_SEGMENT* CacheSegList;
PCACHE_SEGMENT Previous;
Length = ROUND_UP(Length, Bcb->CacheSegmentSize);
CacheSegList = alloca(sizeof(PCACHE_SEGMENT) *
(Length / Bcb->CacheSegmentSize));
/*
* Acquire the global lock.
*/
ExAcquireFastMutex(&ViewLock);
/*
* Look for a cache segment already mapping the same data.
*/
for (i = 0; i < (Length / Bcb->CacheSegmentSize); i++)
{
ULONG CurrentOffset = FileOffset + (i * Bcb->CacheSegmentSize);
current = CcRosLookupCacheSegment(Bcb, CurrentOffset);
if (current != NULL)
{
/*
* Make sure the cache segment can't go away outside of our control.
*/
current->ReferenceCount++;
CacheSegList[i] = current;
}
else
{
CcRosCreateCacheSegment(Bcb, CurrentOffset, &current, FALSE);
CacheSegList[i] = current;
ExAcquireFastMutex(&ViewLock);
}
}
ExReleaseFastMutex(&ViewLock);
for (i = 0; i < (Length / Bcb->CacheSegmentSize); i++)
{
ExAcquireFastMutex(&CacheSegList[i]->Lock);
if (i == 0)
{
*CacheSeg = CacheSegList[i];
Previous = CacheSegList[i];
}
else
{
Previous->NextInChain = CacheSegList[i];
Previous = CacheSegList[i];
}
}
Previous->NextInChain = NULL;
return(STATUS_SUCCESS);
}
NTSTATUS
CcRosGetCacheSegment(PBCB Bcb,
ULONG FileOffset,
PULONG BaseOffset,
PVOID* BaseAddress,
PBOOLEAN UptoDate,
PCACHE_SEGMENT* CacheSeg)
{
PCACHE_SEGMENT current;
NTSTATUS Status;
/*
* Acquire the global lock.
*/
ExAcquireFastMutex(&ViewLock);
/*
* Look for a cache segment already mapping the same data.
*/
current = CcRosLookupCacheSegment(Bcb, FileOffset);
if (current != NULL)
{
/*
* Make sure the cache segment can't go away outside of our control.
*/
current->ReferenceCount++;
/*
* Release the global lock and lock the cache segment.
*/
ExReleaseFastMutex(&ViewLock);
ExAcquireFastMutex(&current->Lock);
/*
* Return information about the segment to the caller.
*/
*UptoDate = current->Valid;
*BaseAddress = current->BaseAddress;
DPRINT("*BaseAddress 0x%.8X\n", *BaseAddress);
*CacheSeg = current;
*BaseOffset = current->FileOffset;
return(STATUS_SUCCESS);
}
/*
* Otherwise create a new segment.
*/
Status = CcRosCreateCacheSegment(Bcb, FileOffset, &current, TRUE);
*UptoDate = current->Valid;
*BaseAddress = current->BaseAddress;
DPRINT("*BaseAddress 0x%.8X\n", *BaseAddress);
*CacheSeg = current;
*BaseOffset = current->FileOffset;
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -364,8 +451,8 @@ CcRosRequestCacheSegment(PBCB Bcb,
} }
STATIC VOID STATIC VOID
CcFreeCachePage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address, ULONG PhysAddr, CcFreeCachePage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
SWAPENTRY SwapEntry, BOOLEAN Dirty) ULONG PhysAddr, SWAPENTRY SwapEntry, BOOLEAN Dirty)
{ {
assert(SwapEntry == 0); assert(SwapEntry == 0);
if (PhysAddr != 0) if (PhysAddr != 0)
@ -414,7 +501,8 @@ CcRosReleaseFileCache(PFILE_OBJECT FileObject, PBCB Bcb)
PLIST_ENTRY current_entry; PLIST_ENTRY current_entry;
PCACHE_SEGMENT current; PCACHE_SEGMENT current;
DPRINT("CcRosReleaseFileCache(FileObject %x, Bcb %x)\n", Bcb->FileObject, Bcb); DPRINT("CcRosReleaseFileCache(FileObject %x, Bcb %x)\n", Bcb->FileObject,
Bcb);
MmFreeSectionSegments(Bcb->FileObject); MmFreeSectionSegments(Bcb->FileObject);
@ -460,7 +548,8 @@ CcRosInitializeFileCache(PFILE_OBJECT FileObject,
{ {
(*Bcb)->AllocationSize = (*Bcb)->AllocationSize =
((REACTOS_COMMON_FCB_HEADER*)FileObject->FsContext)->AllocationSize; ((REACTOS_COMMON_FCB_HEADER*)FileObject->FsContext)->AllocationSize;
(*Bcb)->FileSize = ((REACTOS_COMMON_FCB_HEADER*)FileObject->FsContext)->FileSize; (*Bcb)->FileSize =
((REACTOS_COMMON_FCB_HEADER*)FileObject->FsContext)->FileSize;
} }
KeInitializeSpinLock(&(*Bcb)->BcbLock); KeInitializeSpinLock(&(*Bcb)->BcbLock);
InitializeListHead(&(*Bcb)->BcbSegmentListHead); InitializeListHead(&(*Bcb)->BcbSegmentListHead);

View file

@ -1,6 +1,6 @@
#ifndef __INCLUDE_INTERNAL_CC_H #ifndef __INCLUDE_INTERNAL_CC_H
#define __INCLUDE_INTERNAL_CC_H #define __INCLUDE_INTERNAL_CC_H
/* $Id: cc.h,v 1.9 2001/12/31 01:53:44 dwelch Exp $ */ /* $Id: cc.h,v 1.10 2002/01/26 21:21:02 dwelch Exp $ */
#include <ddk/ntifs.h> #include <ddk/ntifs.h>
typedef struct _BCB typedef struct _BCB
@ -17,7 +17,10 @@ typedef struct _CACHE_SEGMENT
{ {
/* Base address of the region where the cache segment data is mapped. */ /* Base address of the region where the cache segment data is mapped. */
PVOID BaseAddress; PVOID BaseAddress;
/* Memory area representing the region where the cache segment data is mapped. */ /*
* Memory area representing the region where the cache segment data is
* mapped.
*/
struct _MEMORY_AREA* MemoryArea; struct _MEMORY_AREA* MemoryArea;
/* Are the contents of the cache segment data valid. */ /* Are the contents of the cache segment data valid. */
BOOLEAN Valid; BOOLEAN Valid;
@ -39,6 +42,8 @@ typedef struct _CACHE_SEGMENT
ULONG ReferenceCount; ULONG ReferenceCount;
/* Pointer to the BCB for the file which this cache segment maps data for. */ /* Pointer to the BCB for the file which this cache segment maps data for. */
PBCB Bcb; PBCB Bcb;
/* Pointer to the next cache segment in a chain. */
struct _CACHE_SEGMENT* NextInChain;
} CACHE_SEGMENT; } CACHE_SEGMENT;
VOID STDCALL VOID STDCALL
@ -66,5 +71,9 @@ NTSTATUS
CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty); CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty);
NTSTATUS NTSTATUS
CcRosSuggestFreeCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty); CcRosSuggestFreeCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty);
NTSTATUS
CcRosGetCacheSegmentChain(PBCB Bcb,
ULONG FileOffset,
ULONG Length,
PCACHE_SEGMENT* CacheSeg);
#endif #endif

View file

@ -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: ps.h,v 1.28 2002/01/15 02:51:32 dwelch Exp $ /* $Id: ps.h,v 1.29 2002/01/26 21:21:02 dwelch Exp $
* *
* FILE: ntoskrnl/ke/kthread.c * FILE: ntoskrnl/ke/kthread.c
* PURPOSE: Process manager definitions * PURPOSE: Process manager definitions
@ -285,7 +285,7 @@ typedef struct _ETHREAD
*/ */
struct _EPROCESS* OldProcess; /* 240/26C */ struct _EPROCESS* OldProcess; /* 240/26C */
PW32THREAD Win32Thread; struct _W32THREAD* Win32Thread;
} __attribute__((packed)) ETHREAD, *PETHREAD; } __attribute__((packed)) ETHREAD, *PETHREAD;
@ -354,12 +354,6 @@ typedef struct _KPROCESS
UCHAR DisableBoost; /* 067 */ UCHAR DisableBoost; /* 067 */
} KPROCESS, *PKPROCESS; } KPROCESS, *PKPROCESS;
typedef struct _W32PROCESS
{
} __attribute__((packed)) W32PROCESS, *PW32PROCESS;
struct _EPROCESS struct _EPROCESS
{ {
/* Microkernel specific process state. */ /* Microkernel specific process state. */
@ -459,7 +453,7 @@ struct _EPROCESS
UCHAR SubSystemMinorVersion; UCHAR SubSystemMinorVersion;
UCHAR SubSystemMajorVersion; UCHAR SubSystemMajorVersion;
USHORT SubSystemVersion; USHORT SubSystemVersion;
PW32PROCESS Win32Process; struct _W32PROCESS* Win32Process;
HANDLE Win32WindowStation; HANDLE Win32WindowStation;
/* /*

View file

@ -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: win32.c,v 1.2 2002/01/13 22:52:07 dwelch Exp $ /* $Id: win32.c,v 1.3 2002/01/26 21:21:02 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -31,12 +31,14 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/ps.h> #include <internal/ps.h>
#include <napi/win32.h>
/* TYPES *******************************************************************/ /* TYPES *******************************************************************/
/* GLOBALS ******************************************************************/ /* GLOBALS ******************************************************************/
static ULONG PspWin32ProcessSize = 0; static ULONG PspWin32ProcessSize = 0;
static ULONG PspWin32ThreadSize = 0;
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
@ -46,6 +48,29 @@ PsGetWin32Thread(VOID)
return(PsGetCurrentThread()->Win32Thread); return(PsGetCurrentThread()->Win32Thread);
} }
NTSTATUS STDCALL
PsCreateWin32Thread(PETHREAD Thread)
{
if (Thread->Win32Thread != NULL)
return(STATUS_SUCCESS);
Thread->Win32Thread = ExAllocatePool(NonPagedPool,
PspWin32ThreadSize);
if (Thread->Win32Thread == NULL)
return(STATUS_NO_MEMORY);
RtlZeroMemory(Thread->Win32Thread,
PspWin32ThreadSize);
return(STATUS_SUCCESS);
}
PW32PROCESS STDCALL
PsGetWin32Process(VOID)
{
return(PsGetCurrentProcess()->Win32Process);
}
NTSTATUS STDCALL NTSTATUS STDCALL
PsCreateWin32Process(PEPROCESS Process) PsCreateWin32Process(PEPROCESS Process)
{ {
@ -69,10 +94,11 @@ PsEstablishWin32Callouts(PVOID Param1,
PVOID Param2, PVOID Param2,
PVOID Param3, PVOID Param3,
PVOID Param4, PVOID Param4,
PVOID Param5, ULONG W32ThreadSize,
ULONG W32ProcessSize) ULONG W32ProcessSize)
{ {
PspWin32ProcessSize = W32ProcessSize; PspWin32ProcessSize = W32ProcessSize;
PspWin32ThreadSize = W32ThreadSize;
} }
/* EOF */ /* EOF */