diff --git a/reactos/ntoskrnl/io/iomgr/driver.c b/reactos/ntoskrnl/io/iomgr/driver.c index 1264454e04b..c162bdb08dd 100644 --- a/reactos/ntoskrnl/io/iomgr/driver.c +++ b/reactos/ntoskrnl/io/iomgr/driver.c @@ -1403,9 +1403,19 @@ try_again: /* Loop all Major Functions */ for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) { - /* Set each function that was set to NULL to internal routine */ + /* + * Make sure the driver didn't set any dispatch entry point to NULL! + * Doing so is illegal; drivers shouldn't touch entry points they + * do not implement. + */ + ASSERT(DriverObject->MajorFunction[i] != NULL); + + /* Check if it did so anyway */ if (!DriverObject->MajorFunction[i]) + { + /* Fix it up */ DriverObject->MajorFunction[i] = IopInvalidDeviceRequest; + } } /* Return the Status */ diff --git a/reactos/ntoskrnl/io/iomgr/iomdl.c b/reactos/ntoskrnl/io/iomgr/iomdl.c index a5fcf71d814..c6ca981a8ac 100644 --- a/reactos/ntoskrnl/io/iomgr/iomdl.c +++ b/reactos/ntoskrnl/io/iomgr/iomdl.c @@ -29,6 +29,9 @@ IoAllocateMdl(IN PVOID VirtualAddress, ULONG Flags = 0; ULONG Size; + /* Make sure we got a valid length */ + ASSERT(Length != 0); + /* Fail if allocation is over 2GB */ if (Length & 0x80000000) return NULL; diff --git a/reactos/ntoskrnl/io/iomgr/irp.c b/reactos/ntoskrnl/io/iomgr/irp.c index 1e81e205f84..e7e0fb1fe20 100644 --- a/reactos/ntoskrnl/io/iomgr/irp.c +++ b/reactos/ntoskrnl/io/iomgr/irp.c @@ -1134,6 +1134,9 @@ IofCallDriver(IN PDEVICE_OBJECT DeviceObject, PDRIVER_OBJECT DriverObject; PIO_STACK_LOCATION StackPtr; + /* Make sure this is a valid IRP */ + ASSERT(Irp->Type == IO_TYPE_IRP); + /* Get the Driver Object */ DriverObject = DeviceObject->DriverObject; diff --git a/reactos/ntoskrnl/mm/ARM3/contmem.c b/reactos/ntoskrnl/mm/ARM3/contmem.c index bc1a18eb3da..c5565d2d8ec 100644 --- a/reactos/ntoskrnl/mm/ARM3/contmem.c +++ b/reactos/ntoskrnl/mm/ARM3/contmem.c @@ -173,8 +173,13 @@ MiAllocateContiguousMemory(IN SIZE_T NumberOfBytes, { PVOID BaseAddress; PFN_NUMBER SizeInPages; - MI_PFN_CACHE_ATTRIBUTE CacheAttribute; + MI_PFN_CACHE_ATTRIBUTE CacheAttribute; + + // + // Verify count and cache type + // ASSERT(NumberOfBytes != 0); + ASSERT(CacheType <= MmWriteCombined); // // Compute size requested @@ -352,7 +357,12 @@ MmAllocateContiguousMemorySpecifyCache(IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType OPTIONAL) { PFN_NUMBER LowestPfn, HighestPfn, BoundaryPfn; - ASSERT (NumberOfBytes != 0); + + // + // Verify count and cache type + // + ASSERT(NumberOfBytes != 0); + ASSERT(CacheType <= MmWriteCombined); // // Convert the lowest address into a PFN @@ -396,7 +406,12 @@ MmAllocateContiguousMemory(IN ULONG NumberOfBytes, IN PHYSICAL_ADDRESS HighestAcceptableAddress) { PFN_NUMBER HighestPfn; - + + // + // Verify byte count + // + ASSERT(NumberOfBytes != 0); + // // Convert and normalize the highest address into a PFN // diff --git a/reactos/ntoskrnl/mm/ARM3/iosup.c b/reactos/ntoskrnl/mm/ARM3/iosup.c index 5d3452b2ad4..7ea829711c3 100644 --- a/reactos/ntoskrnl/mm/ARM3/iosup.c +++ b/reactos/ntoskrnl/mm/ARM3/iosup.c @@ -57,7 +57,22 @@ MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, PMMPFN Pfn1 = NULL; MI_PFN_CACHE_ATTRIBUTE CacheAttribute; BOOLEAN IsIoMapping; - + + // + // Must be called with a non-zero count + // + ASSERT(NumberOfBytes != 0); + + // + // Make sure the upper bits are 0 if this system + // can't describe more than 4 GB of physical memory. + // FIXME: This doesn't respect PAE, but we currently don't + // define a PAE build flag since there is no such build. + // +#if !defined(_M_AMD64) + ASSERT(PhysicalAddress.HighPart == 0); +#endif + // // Normalize and validate the caching attributes // diff --git a/reactos/ntoskrnl/mm/ARM3/mdlsup.c b/reactos/ntoskrnl/mm/ARM3/mdlsup.c index 596fef88afb..0076759380f 100644 --- a/reactos/ntoskrnl/mm/ARM3/mdlsup.c +++ b/reactos/ntoskrnl/mm/ARM3/mdlsup.c @@ -507,8 +507,13 @@ MmUnmapLockedPages(IN PVOID BaseAddress, // Get the PTE // PointerPte = MiAddressToPte(BaseAddress); + + // + // This should be a resident system PTE + // ASSERT(PointerPte >= MmSystemPtesStart[SystemPteSpace]); ASSERT(PointerPte <= MmSystemPtesEnd[SystemPteSpace]); + ASSERT(PointerPte->u.Hard.Valid == 1); // // Check if the caller wants us to free advanced pages @@ -715,7 +720,7 @@ MmProbeAndLockPages(IN PMDL Mdl, // // Sanity check // - ASSERT(MdlPages = (PPFN_NUMBER)(Mdl + 1)); + ASSERT(MdlPages == (PPFN_NUMBER)(Mdl + 1)); // // Check what kind of operation this is