6 modified files
reactos/ntoskrnl/cc
diff -u -r1.24 -r1.25
--- copy.c 19 Jun 2004 05:04:33 -0000 1.24
+++ copy.c 19 Jun 2004 08:53:35 -0000 1.25
@@ -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
* PROJECT: ReactOS kernel
@@ -139,7 +139,12 @@
/*
* 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);
current2 = current;
offset = 0;
@@ -222,8 +227,14 @@
{
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);
Mdl->MdlFlags |= MDL_IO_PAGE_READ;
KeInitializeEvent(&Event, NotificationEvent, FALSE);
@@ -264,8 +275,14 @@
{
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);
Mdl->MdlFlags |= MDL_IO_PAGE_READ;
KeInitializeEvent(&Event, NotificationEvent, FALSE);
reactos/ntoskrnl/io
diff -u -r1.39 -r1.40
--- buildirp.c 4 Mar 2004 00:07:00 -0000 1.39
+++ buildirp.c 19 Jun 2004 08:53:35 -0000 1.40
@@ -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
* PROJECT: ReactOS kernel
@@ -56,6 +56,10 @@
DPRINT("Doing direct i/o\n");
Irp->MdlAddress = MmCreateMdl(NULL,Buffer,Length);
+ if(Irp->MdlAddress == NULL) {
+ DPRINT("MmCreateMdl: Out of memory!");
+ return(STATUS_NO_MEMORY);
+ }
if (MajorFunction == IRP_MJ_READ)
{
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
@@ -298,6 +302,10 @@
FALSE,
FALSE,
Irp);
+ if(Irp->MdlAddress == NULL) {
+ IoFreeIrp(Irp);
+ return(NULL);
+ }
MmProbeAndLockPages (Irp->MdlAddress,UserMode,IoReadAccess);
}
break;
reactos/ntoskrnl/mm
diff -u -r1.47 -r1.48
--- pagefile.c 6 Jun 2004 09:13:21 -0000 1.47
+++ pagefile.c 19 Jun 2004 08:53:35 -0000 1.48
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* 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
* FILE: ntoskrnl/mm/pagefile.c
@@ -376,18 +376,13 @@
{
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);
@@ -403,6 +398,12 @@
i = FILE_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);
if (PagingFileList[i] == NULL)
@@ -410,9 +411,9 @@
KEBUGCHECK(0);
}
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]->UsedPages--;
@@ -685,6 +686,12 @@
FALSE,
&Event,
&Iosb);
+ if(Irp == NULL)
+ {
+ ObDereferenceObject(PageFile);
+ return(STATUS_NO_MEMORY);// tMk - is this correct return code ???
+ }
+
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->FileObject = PageFile;
StackPtr->DeviceObject = PageFileDevice;
reactos/ntoskrnl/mm
diff -u -r1.75 -r1.76
--- virtual.c 13 Jun 2004 10:35:52 -0000 1.75
+++ virtual.c 19 Jun 2004 08:53:35 -0000 1.76
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* 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
* FILE: ntoskrnl/mm/virtual.c
@@ -59,6 +59,12 @@
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
NtLockVirtualMemory(HANDLE ProcessHandle,
PVOID BaseAddress,
@@ -82,7 +88,7 @@
UserMode,
(PVOID*)(&Process),
NULL);
- if (Status != STATUS_SUCCESS)
+ if (!NT_SUCCESS(Status))
{
return(Status);
}
@@ -90,6 +96,11 @@
Mdl = MmCreateMdl(NULL,
BaseAddress,
NumberOfBytesToLock);
+ if(Mdl == NULL)
+ {
+ ObDereferenceObject(Process);
+ return(STATUS_NO_MEMORY);
+ }
MmProbeAndLockPages(Mdl,
UserMode,
IoWriteAccess);
@@ -102,7 +113,13 @@
return(STATUS_SUCCESS);
}
-NTSTATUS STDCALL
+
+/* (tMk 2004.II.4)
+ * FUNCTION:
+ * Called from VirtualQueryEx (lib\kernel32\mem\virtual.c)
+ *
+ */
+NTSTATUS STDCALL
NtQueryVirtualMemory (IN HANDLE ProcessHandle,
IN PVOID Address,
IN CINT VirtualMemoryInformationClass,
@@ -204,6 +221,12 @@
return(Status);
}
+
+/* (tMk 2004.II.5)
+ * FUNCTION:
+ * Called from VirtualProtectEx (lib\kernel32\mem\virtual.c)
+ *
+ */
NTSTATUS STDCALL
NtProtectVirtualMemory(IN HANDLE ProcessHandle,
IN PVOID *UnsafeBaseAddress,
@@ -226,6 +249,13 @@
if (!NT_SUCCESS(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 =
PAGE_ROUND_UP(BaseAddress + NumberOfBytesToProtect) -
PAGE_ROUND_DOWN(BaseAddress);
@@ -279,6 +309,13 @@
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
NtReadVirtualMemory(IN HANDLE ProcessHandle,
IN PVOID BaseAddress,
@@ -301,7 +338,7 @@
UserMode,
(PVOID*)(&Process),
NULL);
- if (Status != STATUS_SUCCESS)
+ if (!NT_SUCCESS(Status))
{
return(Status);
}
@@ -309,6 +346,11 @@
Mdl = MmCreateMdl(NULL,
Buffer,
NumberOfBytesToRead);
+ if(Mdl == NULL)
+ {
+ ObDereferenceObject(Process);
+ return(STATUS_NO_MEMORY);
+ }
MmProbeAndLockPages(Mdl,
UserMode,
IoWriteAccess);
@@ -331,10 +373,13 @@
if (NumberOfBytesRead)
*NumberOfBytesRead = NumberOfBytesToRead;
-
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
NtUnlockVirtualMemory(HANDLE ProcessHandle,
PVOID BaseAddress,
@@ -358,7 +403,7 @@
UserMode,
(PVOID*)(&Process),
NULL);
- if (Status != STATUS_SUCCESS)
+ if (!NT_SUCCESS(Status))
{
return(Status);
}
@@ -366,6 +411,11 @@
Mdl = MmCreateMdl(NULL,
BaseAddress,
NumberOfBytesToUnlock);
+ if(Mdl == NULL)
+ {
+ ObDereferenceObject(Process);
+ return(STATUS_NO_MEMORY);
+ }
ObDereferenceObject(Process);
@@ -382,6 +432,12 @@
}
+/* (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
NtWriteVirtualMemory(IN HANDLE ProcessHandle,
IN PVOID BaseAddress,
@@ -404,7 +460,7 @@
UserMode,
(PVOID*)(&Process),
NULL);
- if (Status != STATUS_SUCCESS)
+ if (!NT_SUCCESS(Status))
{
return(Status);
}
@@ -415,7 +471,11 @@
MmProbeAndLockPages(Mdl,
UserMode,
IoReadAccess);
-
+ if(Mdl == NULL)
+ {
+ ObDereferenceObject(Process);
+ return(STATUS_NO_MEMORY);
+ }
KeAttachProcess(Process);
SystemAddress = MmGetSystemAddressForMdl(Mdl);
@@ -437,7 +497,8 @@
return(STATUS_SUCCESS);
}
-/*
+/* FUNCTION:
+ * Called from EngSecureMem (subsys\win32k\eng\mem.c)
* @unimplemented
*/
PVOID STDCALL
@@ -457,7 +518,8 @@
}
-/*
+/* FUNCTION:
+ * Called from EngUnsecureMem (subsys\win32k\eng\mem.c)
* @unimplemented
*/
VOID STDCALL
reactos/ntoskrnl/nt
diff -u -r1.15 -r1.16
--- profile.c 30 Dec 2003 18:52:05 -0000 1.15
+++ profile.c 19 Jun 2004 08:53:35 -0000 1.16
@@ -482,6 +482,10 @@
Profile->Size = ImageSize;
Profile->BucketShift = Granularity;
Profile->BufferMdl = MmCreateMdl(NULL, Buffer, BufferSize);
+ if(Profile->BufferMdl == NULL) {
+ DPRINT("MmCreateMdl: Out of memory!");
+ return(STATUS_NO_MEMORY);
+ }
MmProbeAndLockPages(Profile->BufferMdl, UserMode, IoWriteAccess);
Profile->Buffer = MmGetSystemAddressForMdl(Profile->BufferMdl);
Profile->BufferSize = BufferSize;
reactos/ntoskrnl/ps
diff -u -r1.24 -r1.25
--- idle.c 18 Apr 2004 00:50:53 -0000 1.24
+++ idle.c 19 Jun 2004 08:53:35 -0000 1.25
@@ -26,6 +26,9 @@
/* FUNCTIONS *****************************************************************/
+/** System idle thread procedure
+ *
+ */
VOID STDCALL
PsIdleThreadMain(PVOID Context)
{
@@ -50,28 +53,46 @@
}
}
+
+/** Initialization of system idle thread
+ *
+ */
VOID INIT_FUNCTION
PsInitIdleThread(VOID)
{
KPRIORITY Priority;
ULONG Affinity;
-
- PsCreateSystemThread(&PsIdleThreadHandle,
+ NTSTATUS Status;
+
+ Status = PsCreateSystemThread(&PsIdleThreadHandle,
THREAD_ALL_ACCESS,
NULL,
NULL,
NULL,
PsIdleThreadMain,
NULL);
-
+ if(!NT_SUCCESS(Status)) {
+ DPRINT("Couldn't create Idle System Thread!");
+ KEBUGCHECK(0);
+ return;
+ }
+
Priority = LOW_PRIORITY;
- NtSetInformationThread(PsIdleThreadHandle,
+ Status = NtSetInformationThread(PsIdleThreadHandle,
ThreadPriority,
&Priority,
sizeof(Priority));
+ if(!NT_SUCCESS(Status)) {
+ DPRINT("Couldn't set Priority to Idle System Thread!");
+ return;
+ }
+
Affinity = 1 << 0;
- NtSetInformationThread(PsIdleThreadHandle,
+ Status = NtSetInformationThread(PsIdleThreadHandle,
ThreadAffinityMask,
&Affinity,
sizeof(Affinity));
+ if(!NT_SUCCESS(Status)) {
+ DPRINT("Couldn't set Affinity Mask to Idle System Thread!");
+ }
}
CVSspam 0.2.8