mirror of
https://github.com/reactos/reactos.git
synced 2025-01-02 12:32:47 +00:00
patch by Tom (tmkpl@poczta.onet.pl)
to clean up return val checking of some mdl calls svn path=/trunk/; revision=9725
This commit is contained in:
parent
5d2036782e
commit
4444a6885d
6 changed files with 155 additions and 36 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: copy.c,v 1.24 2004/06/19 05:04:33 sedwards Exp $
|
/* $Id: copy.c,v 1.25 2004/06/19 08:53:35 vizzini Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -139,7 +139,12 @@ ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length,
|
||||||
/*
|
/*
|
||||||
* Create an MDL which contains all their pages.
|
* Create an MDL which contains all their pages.
|
||||||
*/
|
*/
|
||||||
MmInitializeMdl(Mdl, NULL, current_size);
|
Mdl = MmCreateMdl(NULL, NULL, current_size);
|
||||||
|
if(Mdl == NULL) {
|
||||||
|
DPRINT("MmCreateMdl: Out of memory!");
|
||||||
|
return(STATUS_NO_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
Mdl->MdlFlags |= (MDL_PAGES_LOCKED | MDL_IO_PAGE_READ);
|
Mdl->MdlFlags |= (MDL_PAGES_LOCKED | MDL_IO_PAGE_READ);
|
||||||
current2 = current;
|
current2 = current;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
@ -222,8 +227,14 @@ ReadCacheSegment(PCACHE_SEGMENT CacheSeg)
|
||||||
{
|
{
|
||||||
Size = CacheSeg->Bcb->CacheSegmentSize;
|
Size = CacheSeg->Bcb->CacheSegmentSize;
|
||||||
}
|
}
|
||||||
Mdl = alloca(MmSizeOfMdl(CacheSeg->BaseAddress, Size));
|
|
||||||
MmInitializeMdl(Mdl, CacheSeg->BaseAddress, Size);
|
Mdl = MmCreateMdl(NULL, CacheSeg->BaseAddress, Size);
|
||||||
|
if(Mdl == NULL)
|
||||||
|
{
|
||||||
|
DPRINT("MmCreateMdl: Out of memory!");
|
||||||
|
return(STATUS_NO_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
MmBuildMdlForNonPagedPool(Mdl);
|
MmBuildMdlForNonPagedPool(Mdl);
|
||||||
Mdl->MdlFlags |= MDL_IO_PAGE_READ;
|
Mdl->MdlFlags |= MDL_IO_PAGE_READ;
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||||
|
@ -264,8 +275,14 @@ WriteCacheSegment(PCACHE_SEGMENT CacheSeg)
|
||||||
{
|
{
|
||||||
Size = CacheSeg->Bcb->CacheSegmentSize;
|
Size = CacheSeg->Bcb->CacheSegmentSize;
|
||||||
}
|
}
|
||||||
Mdl = alloca(MmSizeOfMdl(CacheSeg->BaseAddress, Size));
|
|
||||||
MmInitializeMdl(Mdl, CacheSeg->BaseAddress, Size);
|
Mdl = MmCreateMdl(NULL, CacheSeg->BaseAddress, Size);
|
||||||
|
if(Mdl == NULL)
|
||||||
|
{
|
||||||
|
DPRINT("MmCreateMdl: Out of memory!");
|
||||||
|
return(STATUS_NO_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
MmBuildMdlForNonPagedPool(Mdl);
|
MmBuildMdlForNonPagedPool(Mdl);
|
||||||
Mdl->MdlFlags |= MDL_IO_PAGE_READ;
|
Mdl->MdlFlags |= MDL_IO_PAGE_READ;
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: buildirp.c,v 1.39 2004/03/04 00:07:00 navaraf Exp $
|
/* $Id: buildirp.c,v 1.40 2004/06/19 08:53:35 vizzini Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -56,6 +56,10 @@ NTSTATUS IoPrepareIrpBuffer(PIRP Irp,
|
||||||
DPRINT("Doing direct i/o\n");
|
DPRINT("Doing direct i/o\n");
|
||||||
|
|
||||||
Irp->MdlAddress = MmCreateMdl(NULL,Buffer,Length);
|
Irp->MdlAddress = MmCreateMdl(NULL,Buffer,Length);
|
||||||
|
if(Irp->MdlAddress == NULL) {
|
||||||
|
DPRINT("MmCreateMdl: Out of memory!");
|
||||||
|
return(STATUS_NO_MEMORY);
|
||||||
|
}
|
||||||
if (MajorFunction == IRP_MJ_READ)
|
if (MajorFunction == IRP_MJ_READ)
|
||||||
{
|
{
|
||||||
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
|
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
|
||||||
|
@ -298,6 +302,10 @@ IoBuildDeviceIoControlRequest(ULONG IoControlCode,
|
||||||
FALSE,
|
FALSE,
|
||||||
FALSE,
|
FALSE,
|
||||||
Irp);
|
Irp);
|
||||||
|
if(Irp->MdlAddress == NULL) {
|
||||||
|
IoFreeIrp(Irp);
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
MmProbeAndLockPages (Irp->MdlAddress,UserMode,IoReadAccess);
|
MmProbeAndLockPages (Irp->MdlAddress,UserMode,IoReadAccess);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -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: pagefile.c,v 1.47 2004/06/06 09:13:21 hbirr Exp $
|
/* $Id: pagefile.c,v 1.48 2004/06/19 08:53:35 vizzini Exp $
|
||||||
*
|
*
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/mm/pagefile.c
|
* FILE: ntoskrnl/mm/pagefile.c
|
||||||
|
@ -376,18 +376,13 @@ MiAllocPageFromPagingFile(PPAGINGFILE PagingFile)
|
||||||
{
|
{
|
||||||
if (!(PagingFile->AllocMap[i] & (1 << j)))
|
if (!(PagingFile->AllocMap[i] & (1 << j)))
|
||||||
{
|
{
|
||||||
break;
|
PagingFile->AllocMap[i] |= (1 << j);
|
||||||
|
PagingFile->UsedPages++;
|
||||||
|
PagingFile->FreePages--;
|
||||||
|
KeReleaseSpinLock(&PagingFile->AllocMapLock, oldIrql);
|
||||||
|
return((i * 32) + j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (j == 32)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
PagingFile->AllocMap[i] |= (1 << j);
|
|
||||||
PagingFile->UsedPages++;
|
|
||||||
PagingFile->FreePages--;
|
|
||||||
KeReleaseSpinLock(&PagingFile->AllocMapLock, oldIrql);
|
|
||||||
return((i * 32) + j);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KeReleaseSpinLock(&PagingFile->AllocMapLock, oldIrql);
|
KeReleaseSpinLock(&PagingFile->AllocMapLock, oldIrql);
|
||||||
|
@ -403,6 +398,12 @@ MmFreeSwapPage(SWAPENTRY Entry)
|
||||||
|
|
||||||
i = FILE_FROM_ENTRY(Entry);
|
i = FILE_FROM_ENTRY(Entry);
|
||||||
off = OFFSET_FROM_ENTRY(Entry);
|
off = OFFSET_FROM_ENTRY(Entry);
|
||||||
|
|
||||||
|
if (i >= MAX_PAGING_FILES)
|
||||||
|
{
|
||||||
|
DPRINT1("Bad swap entry 0x%.8X\n", Entry);
|
||||||
|
KEBUGCHECK(0);
|
||||||
|
}
|
||||||
|
|
||||||
KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
|
KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
|
||||||
if (PagingFileList[i] == NULL)
|
if (PagingFileList[i] == NULL)
|
||||||
|
@ -410,9 +411,9 @@ MmFreeSwapPage(SWAPENTRY Entry)
|
||||||
KEBUGCHECK(0);
|
KEBUGCHECK(0);
|
||||||
}
|
}
|
||||||
KeAcquireSpinLockAtDpcLevel(&PagingFileList[i]->AllocMapLock);
|
KeAcquireSpinLockAtDpcLevel(&PagingFileList[i]->AllocMapLock);
|
||||||
|
|
||||||
PagingFileList[i]->AllocMap[off / 32] &= (~(1 << (off % 32)));
|
PagingFileList[i]->AllocMap[off >> 5] &= (~(1 << (off % 32)));
|
||||||
|
|
||||||
PagingFileList[i]->FreePages++;
|
PagingFileList[i]->FreePages++;
|
||||||
PagingFileList[i]->UsedPages--;
|
PagingFileList[i]->UsedPages--;
|
||||||
|
|
||||||
|
@ -685,6 +686,12 @@ MmInitializeCrashDump(HANDLE PageFileHandle, ULONG PageFileNum)
|
||||||
FALSE,
|
FALSE,
|
||||||
&Event,
|
&Event,
|
||||||
&Iosb);
|
&Iosb);
|
||||||
|
if(Irp == NULL)
|
||||||
|
{
|
||||||
|
ObDereferenceObject(PageFile);
|
||||||
|
return(STATUS_NO_MEMORY);// tMk - is this correct return code ???
|
||||||
|
}
|
||||||
|
|
||||||
StackPtr = IoGetNextIrpStackLocation(Irp);
|
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||||
StackPtr->FileObject = PageFile;
|
StackPtr->FileObject = PageFile;
|
||||||
StackPtr->DeviceObject = PageFileDevice;
|
StackPtr->DeviceObject = PageFileDevice;
|
||||||
|
|
|
@ -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: virtual.c,v 1.75 2004/06/13 10:35:52 navaraf Exp $
|
/* $Id: virtual.c,v 1.76 2004/06/19 08:53:35 vizzini Exp $
|
||||||
*
|
*
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/mm/virtual.c
|
* FILE: ntoskrnl/mm/virtual.c
|
||||||
|
@ -59,6 +59,12 @@ NtFlushVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
return(STATUS_NOT_IMPLEMENTED);
|
return(STATUS_NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (tMk 2004.II.4)
|
||||||
|
* FUNCTION: Locks range of process virtual memory.
|
||||||
|
* Called from VirtualLock (lib\kernel32\mem\virtual.c)
|
||||||
|
*
|
||||||
|
* NOTE: This function will be correct if MmProbeAndLockPages() would be fully IMPLEMENTED.
|
||||||
|
*/
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
NtLockVirtualMemory(HANDLE ProcessHandle,
|
NtLockVirtualMemory(HANDLE ProcessHandle,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
|
@ -82,7 +88,7 @@ NtLockVirtualMemory(HANDLE ProcessHandle,
|
||||||
UserMode,
|
UserMode,
|
||||||
(PVOID*)(&Process),
|
(PVOID*)(&Process),
|
||||||
NULL);
|
NULL);
|
||||||
if (Status != STATUS_SUCCESS)
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
@ -90,6 +96,11 @@ NtLockVirtualMemory(HANDLE ProcessHandle,
|
||||||
Mdl = MmCreateMdl(NULL,
|
Mdl = MmCreateMdl(NULL,
|
||||||
BaseAddress,
|
BaseAddress,
|
||||||
NumberOfBytesToLock);
|
NumberOfBytesToLock);
|
||||||
|
if(Mdl == NULL)
|
||||||
|
{
|
||||||
|
ObDereferenceObject(Process);
|
||||||
|
return(STATUS_NO_MEMORY);
|
||||||
|
}
|
||||||
MmProbeAndLockPages(Mdl,
|
MmProbeAndLockPages(Mdl,
|
||||||
UserMode,
|
UserMode,
|
||||||
IoWriteAccess);
|
IoWriteAccess);
|
||||||
|
@ -102,7 +113,13 @@ NtLockVirtualMemory(HANDLE ProcessHandle,
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
|
||||||
|
/* (tMk 2004.II.4)
|
||||||
|
* FUNCTION:
|
||||||
|
* Called from VirtualQueryEx (lib\kernel32\mem\virtual.c)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL
|
||||||
NtQueryVirtualMemory (IN HANDLE ProcessHandle,
|
NtQueryVirtualMemory (IN HANDLE ProcessHandle,
|
||||||
IN PVOID Address,
|
IN PVOID Address,
|
||||||
IN CINT VirtualMemoryInformationClass,
|
IN CINT VirtualMemoryInformationClass,
|
||||||
|
@ -204,6 +221,12 @@ NtQueryVirtualMemory (IN HANDLE ProcessHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (tMk 2004.II.5)
|
||||||
|
* FUNCTION:
|
||||||
|
* Called from VirtualProtectEx (lib\kernel32\mem\virtual.c)
|
||||||
|
*
|
||||||
|
*/
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
NtProtectVirtualMemory(IN HANDLE ProcessHandle,
|
NtProtectVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
IN PVOID *UnsafeBaseAddress,
|
IN PVOID *UnsafeBaseAddress,
|
||||||
|
@ -226,6 +249,13 @@ NtProtectVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
return Status;
|
return Status;
|
||||||
|
|
||||||
|
// (tMk 2004.II.5) in Microsoft SDK I read:
|
||||||
|
// 'if this parameter is NULL or does not point to a valid variable, the function fails'
|
||||||
|
if(UnsafeOldAccessProtection == NULL)
|
||||||
|
{
|
||||||
|
return(STATUS_INVALID_PARAMETER);
|
||||||
|
}
|
||||||
|
|
||||||
NumberOfBytesToProtect =
|
NumberOfBytesToProtect =
|
||||||
PAGE_ROUND_UP(BaseAddress + NumberOfBytesToProtect) -
|
PAGE_ROUND_UP(BaseAddress + NumberOfBytesToProtect) -
|
||||||
PAGE_ROUND_DOWN(BaseAddress);
|
PAGE_ROUND_DOWN(BaseAddress);
|
||||||
|
@ -279,6 +309,13 @@ NtProtectVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (tMk 2004.II.05)
|
||||||
|
* FUNCTION:
|
||||||
|
* Called from ReadProcessMemory (lib\kernel32\mem\procmem.c) and KlInitPeb(lib\kernel32\process\create.c)
|
||||||
|
*
|
||||||
|
* NOTE: This function will be correct if MmProbeAndLockPages() would be fully IMPLEMENTED.
|
||||||
|
*/
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
NtReadVirtualMemory(IN HANDLE ProcessHandle,
|
NtReadVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
IN PVOID BaseAddress,
|
IN PVOID BaseAddress,
|
||||||
|
@ -301,7 +338,7 @@ NtReadVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
UserMode,
|
UserMode,
|
||||||
(PVOID*)(&Process),
|
(PVOID*)(&Process),
|
||||||
NULL);
|
NULL);
|
||||||
if (Status != STATUS_SUCCESS)
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
@ -309,6 +346,11 @@ NtReadVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
Mdl = MmCreateMdl(NULL,
|
Mdl = MmCreateMdl(NULL,
|
||||||
Buffer,
|
Buffer,
|
||||||
NumberOfBytesToRead);
|
NumberOfBytesToRead);
|
||||||
|
if(Mdl == NULL)
|
||||||
|
{
|
||||||
|
ObDereferenceObject(Process);
|
||||||
|
return(STATUS_NO_MEMORY);
|
||||||
|
}
|
||||||
MmProbeAndLockPages(Mdl,
|
MmProbeAndLockPages(Mdl,
|
||||||
UserMode,
|
UserMode,
|
||||||
IoWriteAccess);
|
IoWriteAccess);
|
||||||
|
@ -331,10 +373,13 @@ NtReadVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
|
|
||||||
if (NumberOfBytesRead)
|
if (NumberOfBytesRead)
|
||||||
*NumberOfBytesRead = NumberOfBytesToRead;
|
*NumberOfBytesRead = NumberOfBytesToRead;
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (tMk 2004.II.05)
|
||||||
|
* FUNCTION: THIS function doesn't make a sense...
|
||||||
|
* Called from VirtualUnlock (lib\kernel32\mem\virtual.c)
|
||||||
|
*/
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
NtUnlockVirtualMemory(HANDLE ProcessHandle,
|
NtUnlockVirtualMemory(HANDLE ProcessHandle,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
|
@ -358,7 +403,7 @@ NtUnlockVirtualMemory(HANDLE ProcessHandle,
|
||||||
UserMode,
|
UserMode,
|
||||||
(PVOID*)(&Process),
|
(PVOID*)(&Process),
|
||||||
NULL);
|
NULL);
|
||||||
if (Status != STATUS_SUCCESS)
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
@ -366,6 +411,11 @@ NtUnlockVirtualMemory(HANDLE ProcessHandle,
|
||||||
Mdl = MmCreateMdl(NULL,
|
Mdl = MmCreateMdl(NULL,
|
||||||
BaseAddress,
|
BaseAddress,
|
||||||
NumberOfBytesToUnlock);
|
NumberOfBytesToUnlock);
|
||||||
|
if(Mdl == NULL)
|
||||||
|
{
|
||||||
|
ObDereferenceObject(Process);
|
||||||
|
return(STATUS_NO_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
|
|
||||||
|
@ -382,6 +432,12 @@ NtUnlockVirtualMemory(HANDLE ProcessHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (tMk 2004.II.05)
|
||||||
|
* FUNCTION:
|
||||||
|
* Called from WriteProcessMemory (lib\kernel32\mem\procmem.c) and KlInitPeb(lib\kernel32\process\create.c)
|
||||||
|
*
|
||||||
|
* NOTE: This function will be correct if MmProbeAndLockPages() would be fully IMPLEMENTED.
|
||||||
|
*/
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
NtWriteVirtualMemory(IN HANDLE ProcessHandle,
|
NtWriteVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
IN PVOID BaseAddress,
|
IN PVOID BaseAddress,
|
||||||
|
@ -404,7 +460,7 @@ NtWriteVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
UserMode,
|
UserMode,
|
||||||
(PVOID*)(&Process),
|
(PVOID*)(&Process),
|
||||||
NULL);
|
NULL);
|
||||||
if (Status != STATUS_SUCCESS)
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
@ -415,7 +471,11 @@ NtWriteVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
MmProbeAndLockPages(Mdl,
|
MmProbeAndLockPages(Mdl,
|
||||||
UserMode,
|
UserMode,
|
||||||
IoReadAccess);
|
IoReadAccess);
|
||||||
|
if(Mdl == NULL)
|
||||||
|
{
|
||||||
|
ObDereferenceObject(Process);
|
||||||
|
return(STATUS_NO_MEMORY);
|
||||||
|
}
|
||||||
KeAttachProcess(Process);
|
KeAttachProcess(Process);
|
||||||
|
|
||||||
SystemAddress = MmGetSystemAddressForMdl(Mdl);
|
SystemAddress = MmGetSystemAddressForMdl(Mdl);
|
||||||
|
@ -437,7 +497,8 @@ NtWriteVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* FUNCTION:
|
||||||
|
* Called from EngSecureMem (subsys\win32k\eng\mem.c)
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
PVOID STDCALL
|
PVOID STDCALL
|
||||||
|
@ -457,7 +518,8 @@ MmSecureVirtualMemory (PVOID Address,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/* FUNCTION:
|
||||||
|
* Called from EngUnsecureMem (subsys\win32k\eng\mem.c)
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
|
|
|
@ -482,6 +482,10 @@ NtCreateProfile(OUT PHANDLE UnsafeProfileHandle,
|
||||||
Profile->Size = ImageSize;
|
Profile->Size = ImageSize;
|
||||||
Profile->BucketShift = Granularity;
|
Profile->BucketShift = Granularity;
|
||||||
Profile->BufferMdl = MmCreateMdl(NULL, Buffer, BufferSize);
|
Profile->BufferMdl = MmCreateMdl(NULL, Buffer, BufferSize);
|
||||||
|
if(Profile->BufferMdl == NULL) {
|
||||||
|
DPRINT("MmCreateMdl: Out of memory!");
|
||||||
|
return(STATUS_NO_MEMORY);
|
||||||
|
}
|
||||||
MmProbeAndLockPages(Profile->BufferMdl, UserMode, IoWriteAccess);
|
MmProbeAndLockPages(Profile->BufferMdl, UserMode, IoWriteAccess);
|
||||||
Profile->Buffer = MmGetSystemAddressForMdl(Profile->BufferMdl);
|
Profile->Buffer = MmGetSystemAddressForMdl(Profile->BufferMdl);
|
||||||
Profile->BufferSize = BufferSize;
|
Profile->BufferSize = BufferSize;
|
||||||
|
|
|
@ -26,6 +26,9 @@ extern CHAR KiTimerSystemAuditing;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
/** System idle thread procedure
|
||||||
|
*
|
||||||
|
*/
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
PsIdleThreadMain(PVOID Context)
|
PsIdleThreadMain(PVOID Context)
|
||||||
{
|
{
|
||||||
|
@ -50,28 +53,46 @@ PsIdleThreadMain(PVOID Context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Initialization of system idle thread
|
||||||
|
*
|
||||||
|
*/
|
||||||
VOID INIT_FUNCTION
|
VOID INIT_FUNCTION
|
||||||
PsInitIdleThread(VOID)
|
PsInitIdleThread(VOID)
|
||||||
{
|
{
|
||||||
KPRIORITY Priority;
|
KPRIORITY Priority;
|
||||||
ULONG Affinity;
|
ULONG Affinity;
|
||||||
|
NTSTATUS Status;
|
||||||
PsCreateSystemThread(&PsIdleThreadHandle,
|
|
||||||
|
Status = PsCreateSystemThread(&PsIdleThreadHandle,
|
||||||
THREAD_ALL_ACCESS,
|
THREAD_ALL_ACCESS,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
PsIdleThreadMain,
|
PsIdleThreadMain,
|
||||||
NULL);
|
NULL);
|
||||||
|
if(!NT_SUCCESS(Status)) {
|
||||||
|
DPRINT("Couldn't create Idle System Thread!");
|
||||||
|
KEBUGCHECK(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Priority = LOW_PRIORITY;
|
Priority = LOW_PRIORITY;
|
||||||
NtSetInformationThread(PsIdleThreadHandle,
|
Status = NtSetInformationThread(PsIdleThreadHandle,
|
||||||
ThreadPriority,
|
ThreadPriority,
|
||||||
&Priority,
|
&Priority,
|
||||||
sizeof(Priority));
|
sizeof(Priority));
|
||||||
|
if(!NT_SUCCESS(Status)) {
|
||||||
|
DPRINT("Couldn't set Priority to Idle System Thread!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Affinity = 1 << 0;
|
Affinity = 1 << 0;
|
||||||
NtSetInformationThread(PsIdleThreadHandle,
|
Status = NtSetInformationThread(PsIdleThreadHandle,
|
||||||
ThreadAffinityMask,
|
ThreadAffinityMask,
|
||||||
&Affinity,
|
&Affinity,
|
||||||
sizeof(Affinity));
|
sizeof(Affinity));
|
||||||
|
if(!NT_SUCCESS(Status)) {
|
||||||
|
DPRINT("Couldn't set Affinity Mask to Idle System Thread!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue