diff --git a/reactos/ntoskrnl/cc/cacheman.c b/reactos/ntoskrnl/cc/cacheman.c index 945d0e03921..389bf79c905 100644 --- a/reactos/ntoskrnl/cc/cacheman.c +++ b/reactos/ntoskrnl/cc/cacheman.c @@ -1,5 +1,5 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/cc/cacheman.c @@ -31,7 +31,7 @@ CcGetFlushedValidData ( IN BOOLEAN BcbListHeld ) { - LARGE_INTEGER i; + LARGE_INTEGER i; UNIMPLEMENTED; diff --git a/reactos/ntoskrnl/cc/copy.c b/reactos/ntoskrnl/cc/copy.c index 5a6ac44a295..bedb0176ed6 100644 --- a/reactos/ntoskrnl/cc/copy.c +++ b/reactos/ntoskrnl/cc/copy.c @@ -40,7 +40,7 @@ ULONG CcFastReadResourceMiss; /* FUNCTIONS *****************************************************************/ -VOID +VOID CcInitCacheZeroPage(VOID) { NTSTATUS Status; @@ -100,7 +100,7 @@ ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length, Buffer = pTemp; } #endif - Length = Length - TempLength; + Length = Length - TempLength; previous = current; current = current->NextInChain; CcRosReleaseCacheSegment(Bcb, previous, TRUE, FALSE, FALSE); @@ -126,7 +126,7 @@ ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length, current2 = current2->NextInChain; current_size += Bcb->CacheSegmentSize; } - + /* * Create an MDL which contains all their pages. */ @@ -191,7 +191,7 @@ ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length, Buffer = pTemp; } #endif - Length = Length - TempLength; + Length = Length - TempLength; CcRosReleaseCacheSegment(Bcb, previous, TRUE, FALSE, FALSE); current_size += Bcb->CacheSegmentSize; } @@ -200,7 +200,7 @@ ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length, return(STATUS_SUCCESS); } -NTSTATUS +NTSTATUS ReadCacheSegment(PCACHE_SEGMENT CacheSeg) { ULONG Size; @@ -221,7 +221,7 @@ ReadCacheSegment(PCACHE_SEGMENT CacheSeg) MmBuildMdlForNonPagedPool(Mdl); Mdl->MdlFlags |= MDL_IO_PAGE_READ; KeInitializeEvent(&Event, NotificationEvent, FALSE); - Status = IoPageRead(CacheSeg->Bcb->FileObject, Mdl, &SegOffset, & Event, &IoStatus); + Status = IoPageRead(CacheSeg->Bcb->FileObject, Mdl, &SegOffset, & Event, &IoStatus); if (Status == STATUS_PENDING) { KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); @@ -235,13 +235,13 @@ ReadCacheSegment(PCACHE_SEGMENT CacheSeg) } if (CacheSeg->Bcb->CacheSegmentSize > Size) { - memset ((char*)CacheSeg->BaseAddress + Size, 0, + memset ((char*)CacheSeg->BaseAddress + Size, 0, CacheSeg->Bcb->CacheSegmentSize - Size); } return STATUS_SUCCESS; } -NTSTATUS +NTSTATUS WriteCacheSegment(PCACHE_SEGMENT CacheSeg) { ULONG Size; @@ -316,7 +316,7 @@ CcCopyRead (IN PFILE_OBJECT FileObject, KIRQL oldirql; PLIST_ENTRY current_entry; PCACHE_SEGMENT current; - + DPRINT("CcCopyRead(FileObject %x, FileOffset %x, " "Length %d, Wait %d, Buffer %x, IoStatus %x)\n", FileObject, (ULONG)FileOffset->QuadPart, Length, Wait, @@ -324,7 +324,7 @@ CcCopyRead (IN PFILE_OBJECT FileObject, Bcb = FileObject->SectionObjectPointer->SharedCacheMap; ReadOffset = (ULONG)FileOffset->QuadPart; - + DPRINT("AllocationSize %d, FileSize %d\n", (ULONG)Bcb->AllocationSize.QuadPart, (ULONG)Bcb->FileSize.QuadPart); @@ -339,7 +339,7 @@ CcCopyRead (IN PFILE_OBJECT FileObject, current_entry = Bcb->BcbSegmentListHead.Flink; while (current_entry != &Bcb->BcbSegmentListHead) { - current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, + current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, BcbSegmentListEntry); if (!current->Valid && current->FileOffset < ReadOffset + Length && current->FileOffset + Bcb->CacheSegmentSize > ReadOffset) @@ -359,7 +359,7 @@ CcCopyRead (IN PFILE_OBJECT FileObject, { TempLength = min (Length, Bcb->CacheSegmentSize - TempLength); Status = CcRosRequestCacheSegment(Bcb, - ROUND_DOWN(ReadOffset, + ROUND_DOWN(ReadOffset, Bcb->CacheSegmentSize), &BaseAddress, &Valid, &CacheSeg); if (!NT_SUCCESS(Status)) @@ -380,14 +380,14 @@ CcCopyRead (IN PFILE_OBJECT FileObject, return FALSE; } } - memcpy (Buffer, (char*)BaseAddress + ReadOffset % Bcb->CacheSegmentSize, + memcpy (Buffer, (char*)BaseAddress + ReadOffset % Bcb->CacheSegmentSize, TempLength); CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE); ReadLength += TempLength; Length -= TempLength; ReadOffset += TempLength; Buffer = (PVOID)((char*)Buffer + TempLength); - } + } while (Length > 0) { TempLength = min(max(Bcb->CacheSegmentSize, MAX_RW_LENGTH), Length); @@ -445,14 +445,14 @@ CcCopyWrite (IN PFILE_OBJECT FileObject, current_entry = Bcb->BcbSegmentListHead.Flink; while (current_entry != &Bcb->BcbSegmentListHead) { - CacheSeg = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, + CacheSeg = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, BcbSegmentListEntry); if (!CacheSeg->Valid) { - if ((WriteOffset >= CacheSeg->FileOffset && + if ((WriteOffset >= CacheSeg->FileOffset && WriteOffset < CacheSeg->FileOffset + Bcb->CacheSegmentSize) - || (WriteOffset + Length > CacheSeg->FileOffset && - WriteOffset + Length <= CacheSeg->FileOffset + + || (WriteOffset + Length > CacheSeg->FileOffset && + WriteOffset + Length <= CacheSeg->FileOffset + Bcb->CacheSegmentSize)) { KeReleaseSpinLock(&Bcb->BcbLock, oldirql); @@ -484,10 +484,10 @@ CcCopyWrite (IN PFILE_OBJECT FileObject, return(FALSE); } } - memcpy ((char*)BaseAddress + WriteOffset % Bcb->CacheSegmentSize, + memcpy ((char*)BaseAddress + WriteOffset % Bcb->CacheSegmentSize, Buffer, TempLength); CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, TRUE, FALSE); - + Length -= TempLength; WriteOffset += TempLength; #if defined(__GNUC__) @@ -500,7 +500,7 @@ CcCopyWrite (IN PFILE_OBJECT FileObject, } #endif } - + while (Length > 0) { TempLength = min (Bcb->CacheSegmentSize, Length); @@ -612,11 +612,11 @@ CcZeroData (IN PFILE_OBJECT FileObject, ULONG i; IO_STATUS_BLOCK Iosb; KEVENT Event; - + DPRINT("CcZeroData(FileObject %x, StartOffset %I64x, EndOffset %I64x, " - "Wait %d)\n", FileObject, StartOffset->QuadPart, EndOffset->QuadPart, + "Wait %d)\n", FileObject, StartOffset->QuadPart, EndOffset->QuadPart, Wait); - + Length = EndOffset->u.LowPart - StartOffset->u.LowPart; WriteOffset.QuadPart = StartOffset->QuadPart; @@ -625,7 +625,7 @@ CcZeroData (IN PFILE_OBJECT FileObject, /* File is not cached */ Mdl = alloca(MmSizeOfMdl(NULL, MAX_ZERO_LENGTH)); - + while (Length > 0) { if (Length + WriteOffset.u.LowPart % PAGE_SIZE > MAX_ZERO_LENGTH) @@ -649,7 +649,7 @@ CcZeroData (IN PFILE_OBJECT FileObject, KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); Status = Iosb.Status; } - MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl); + MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl); if (!NT_SUCCESS(Status)) { return(FALSE); @@ -675,14 +675,14 @@ CcZeroData (IN PFILE_OBJECT FileObject, current_entry = Bcb->BcbSegmentListHead.Flink; while (current_entry != &Bcb->BcbSegmentListHead) { - CacheSeg = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, + CacheSeg = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, BcbSegmentListEntry); if (!CacheSeg->Valid) { - if ((WriteOffset.u.LowPart >= CacheSeg->FileOffset && + if ((WriteOffset.u.LowPart >= CacheSeg->FileOffset && WriteOffset.u.LowPart < CacheSeg->FileOffset + Bcb->CacheSegmentSize) - || (WriteOffset.u.LowPart + Length > CacheSeg->FileOffset && - WriteOffset.u.LowPart + Length <= + || (WriteOffset.u.LowPart + Length > CacheSeg->FileOffset && + WriteOffset.u.LowPart + Length <= CacheSeg->FileOffset + Bcb->CacheSegmentSize)) { KeReleaseSpinLock(&Bcb->BcbLock, oldirql); @@ -726,7 +726,7 @@ CcZeroData (IN PFILE_OBJECT FileObject, Status = ReadCacheSegment(current); if (!NT_SUCCESS(Status)) { - DPRINT1("ReadCacheSegment failed, status %x\n", + DPRINT1("ReadCacheSegment failed, status %x\n", Status); } } @@ -743,7 +743,7 @@ CcZeroData (IN PFILE_OBJECT FileObject, Length -= TempLength; current = current->NextInChain; - } + } current = CacheSeg; while (current != NULL) diff --git a/reactos/ntoskrnl/cc/fs.c b/reactos/ntoskrnl/cc/fs.c index 5a54a2575dc..170f0616374 100644 --- a/reactos/ntoskrnl/cc/fs.c +++ b/reactos/ntoskrnl/cc/fs.c @@ -1,4 +1,4 @@ -/* $Id:$ +/* $Id$ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -17,7 +17,7 @@ #ifndef VACB_MAPPING_GRANULARITY #define VACB_MAPPING_GRANULARITY (256 * 1024) #endif - + /* GLOBALS *****************************************************************/ extern FAST_MUTEX ViewLock; @@ -41,7 +41,7 @@ CcGetDirtyPages ( { UNIMPLEMENTED; - LARGE_INTEGER i; + LARGE_INTEGER i; i.QuadPart = 0; return i; } @@ -71,7 +71,7 @@ CcGetLsnForFileObject ( { UNIMPLEMENTED; - LARGE_INTEGER i; + LARGE_INTEGER i; i.QuadPart = 0; return i; } @@ -136,7 +136,7 @@ CcSetFileSizes (IN PFILE_OBJECT FileObject, LIST_ENTRY FreeListHead; NTSTATUS Status; - DPRINT("CcSetFileSizes(FileObject %x, FileSizes %x)\n", + DPRINT("CcSetFileSizes(FileObject %x, FileSizes %x)\n", FileObject, FileSizes); DPRINT("AllocationSize %d, FileSize %d, ValidDataLength %d\n", (ULONG)FileSizes->AllocationSize.QuadPart, @@ -151,7 +151,7 @@ CcSetFileSizes (IN PFILE_OBJECT FileObject, */ if (Bcb == NULL) return; - + if (FileSizes->AllocationSize.QuadPart < Bcb->AllocationSize.QuadPart) { InitializeListHead(&FreeListHead); @@ -184,7 +184,7 @@ CcSetFileSizes (IN PFILE_OBJECT FileObject, } } } - + Bcb->AllocationSize = FileSizes->AllocationSize; Bcb->FileSize = FileSizes->FileSize; KeReleaseSpinLock(&Bcb->BcbLock, oldirql); diff --git a/reactos/ntoskrnl/cc/mdl.c b/reactos/ntoskrnl/cc/mdl.c index 620129d30c4..7e91d707c4a 100644 --- a/reactos/ntoskrnl/cc/mdl.c +++ b/reactos/ntoskrnl/cc/mdl.c @@ -1,5 +1,5 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/cc/fs.c @@ -49,13 +49,13 @@ CcMdlRead( * Used by CcMdlReadComplete@8 and FsRtl * */ -VOID +VOID STDCALL CcMdlReadCompleteDev(IN PMDL MdlChain, IN PFILE_OBJECT FileObject) { PMDL Mdl; - + /* Free MDLs */ while ((Mdl = MdlChain)) { @@ -88,11 +88,11 @@ CcMdlReadComplete(IN PFILE_OBJECT FileObject, { PDEVICE_OBJECT DeviceObject = NULL; PFAST_IO_DISPATCH FastDispatch; - + /* Get Fast Dispatch Data */ DeviceObject = IoGetRelatedDeviceObject(FileObject); FastDispatch = DeviceObject->DriverObject->FastIoDispatch; - + /* Check if we support Fast Calls, and check this one */ if (FastDispatch && FastDispatch->MdlReadComplete) { @@ -101,7 +101,7 @@ CcMdlReadComplete(IN PFILE_OBJECT FileObject, MdlChain, DeviceObject); } - + /* Use slow path */ CcMdlReadCompleteDev(MdlChain, FileObject); } @@ -117,11 +117,11 @@ CcMdlWriteComplete(IN PFILE_OBJECT FileObject, { PDEVICE_OBJECT DeviceObject = NULL; PFAST_IO_DISPATCH FastDispatch; - + /* Get Fast Dispatch Data */ DeviceObject = IoGetRelatedDeviceObject(FileObject); FastDispatch = DeviceObject->DriverObject->FastIoDispatch; - + /* Check if we support Fast Calls, and check this one */ if (FastDispatch && FastDispatch->MdlWriteComplete) { @@ -131,7 +131,7 @@ CcMdlWriteComplete(IN PFILE_OBJECT FileObject, MdlChain, DeviceObject); } - + /* Use slow path */ CcMdlWriteCompleteDev(FileOffset, MdlChain, FileObject); } diff --git a/reactos/ntoskrnl/cc/pin.c b/reactos/ntoskrnl/cc/pin.c index 1b51b243e6a..f196e1b9f9b 100644 --- a/reactos/ntoskrnl/cc/pin.c +++ b/reactos/ntoskrnl/cc/pin.c @@ -40,11 +40,11 @@ CcMapData (IN PFILE_OBJECT FileObject, NTSTATUS Status; PINTERNAL_BCB iBcb; ULONG ROffset; - + DPRINT("CcMapData(FileObject %x, FileOffset %d, Length %d, Wait %d," " pBcb %x, pBuffer %x)\n", FileObject, (ULONG)FileOffset->QuadPart, Length, Wait, pBcb, pBuffer); - + ReadOffset = (ULONG)FileOffset->QuadPart; Bcb = FileObject->SectionObjectPointer->SharedCacheMap; ASSERT(Bcb); @@ -52,7 +52,7 @@ CcMapData (IN PFILE_OBJECT FileObject, DPRINT("AllocationSize %d, FileSize %d\n", (ULONG)Bcb->AllocationSize.QuadPart, (ULONG)Bcb->FileSize.QuadPart); - + if (ReadOffset % Bcb->CacheSegmentSize + Length > Bcb->CacheSegmentSize) { return(FALSE); @@ -193,7 +193,7 @@ VOID STDCALL CcUnpinData (IN PVOID Bcb) { PINTERNAL_BCB iBcb = Bcb; - CcRosReleaseCacheSegment(iBcb->CacheSegment->Bcb, iBcb->CacheSegment, TRUE, + CcRosReleaseCacheSegment(iBcb->CacheSegment->Bcb, iBcb->CacheSegment, TRUE, iBcb->Dirty, FALSE); if (--iBcb->RefCount == 0) { diff --git a/reactos/ntoskrnl/cc/view.c b/reactos/ntoskrnl/cc/view.c index 9162b84766b..172f5f4269c 100644 --- a/reactos/ntoskrnl/cc/view.c +++ b/reactos/ntoskrnl/cc/view.c @@ -10,24 +10,24 @@ /* NOTES ********************************************************************** * - * This is not the NT implementation of a file cache nor anything much like - * it. + * This is not the NT implementation of a file cache nor anything much like + * it. * - * The general procedure for a filesystem to implement a read or write + * The general procedure for a filesystem to implement a read or write * dispatch routine is as follows - * + * * (1) If caching for the FCB hasn't been initiated then so do by calling * CcInitializeFileCache. - * - * (2) For each 4k region which is being read or written obtain a cache page - * by calling CcRequestCachePage. * - * (3) If either the page is being read or not completely written, and it is + * (2) For each 4k region which is being read or written obtain a cache page + * by calling CcRequestCachePage. + * + * (3) If either the page is being read or not completely written, and it is * not up to date then read its data from the underlying medium. If the read - * fails then call CcReleaseCachePage with VALID as FALSE and return a error. - * + * fails then call CcReleaseCachePage with VALID as FALSE and return a error. + * * (4) Copy the data into or out of the page as necessary. - * + * * (5) Release the cache page */ /* INCLUDES ******************************************************************/ @@ -39,9 +39,9 @@ /* GLOBALS *******************************************************************/ /* - * If CACHE_BITMAP is defined, the cache manager uses one large memory region - * within the kernel address space and allocate/deallocate space from this block - * over a bitmap. If CACHE_BITMAP is used, the size of the mdl mapping region + * If CACHE_BITMAP is defined, the cache manager uses one large memory region + * within the kernel address space and allocate/deallocate space from this block + * over a bitmap. If CACHE_BITMAP is used, the size of the mdl mapping region * must be reduced (ntoskrnl\mm\mdl.c, MI_MDLMAPPING_REGION_SIZE). */ //#define CACHE_BITMAP @@ -148,7 +148,7 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count) } NewTarget = WriteCount[0]; - + Target = max(NewTarget, Target); current_entry = DirtySegmentListHead.Flink; @@ -158,7 +158,7 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count) } while (current_entry != &DirtySegmentListHead && Target > 0) { - current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, + current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, DirtySegmentListEntry); current_entry = current_entry->Flink; Locked = ExTryToAcquireFastMutex(¤t->Lock); @@ -174,7 +174,7 @@ CcRosFlushDirtyPages(ULONG Target, PULONG Count) } ExReleaseFastMutex(&ViewLock); PagesPerSegment = current->Bcb->CacheSegmentSize / PAGE_SIZE; - Status = CcRosFlushCacheSegment(current); + Status = CcRosFlushCacheSegment(current); ExReleaseFastMutex(¤t->Lock); if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE)) { @@ -205,7 +205,7 @@ CcRosTrimCache(ULONG Target, ULONG Priority, PULONG NrFreed) * ARGUMENTS: * Target - The number of pages to be freed. * Priority - The priority of free (currently unused). - * NrFreed - Points to a variable where the number of pages + * NrFreed - Points to a variable where the number of pages * actually freed is returned. */ { @@ -219,17 +219,17 @@ CcRosTrimCache(ULONG Target, ULONG Priority, PULONG NrFreed) DPRINT("CcRosTrimCache(Target %d)\n", Target); *NrFreed = 0; - + InitializeListHead(&FreeList); - + ExAcquireFastMutex(&ViewLock); current_entry = CacheSegmentLRUListHead.Flink; while (current_entry != &CacheSegmentLRUListHead && Target > 0) { - current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, + current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, CacheSegmentLRUListEntry); current_entry = current_entry->Flink; - + KeAcquireSpinLock(¤t->Bcb->BcbLock, &oldIrql); if (current->ReferenceCount == 0) { @@ -249,7 +249,7 @@ CcRosTrimCache(ULONG Target, ULONG Priority, PULONG NrFreed) { ULONG i; NTSTATUS Status; - + current->ReferenceCount++; last = current; current->PageOut = TRUE; @@ -281,7 +281,7 @@ CcRosTrimCache(ULONG Target, ULONG Priority, PULONG NrFreed) while (!IsListEmpty(&FreeList)) { current_entry = RemoveHeadList(&FreeList); - current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, + current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, BcbSegmentListEntry); CcRosInternalFreeCacheSegment(current); } @@ -290,7 +290,7 @@ CcRosTrimCache(ULONG Target, ULONG Priority, PULONG NrFreed) return(STATUS_SUCCESS); } -NTSTATUS +NTSTATUS CcRosReleaseCacheSegment(PBCB Bcb, PCACHE_SEGMENT CacheSeg, BOOLEAN Valid, @@ -334,11 +334,11 @@ CcRosReleaseCacheSegment(PBCB Bcb, KeReleaseSpinLock(&Bcb->BcbLock, oldIrql); ExReleaseFastMutex(&ViewLock); ExReleaseFastMutex(&CacheSeg->Lock); - + return(STATUS_SUCCESS); } -PCACHE_SEGMENT +PCACHE_SEGMENT CcRosLookupCacheSegment(PBCB Bcb, ULONG FileOffset) { PLIST_ENTRY current_entry; @@ -353,7 +353,7 @@ CcRosLookupCacheSegment(PBCB Bcb, ULONG FileOffset) current_entry = Bcb->BcbSegmentListHead.Flink; while (current_entry != &Bcb->BcbSegmentListHead) { - current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, + current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, BcbSegmentListEntry); if (current->FileOffset <= FileOffset && (current->FileOffset + Bcb->CacheSegmentSize) > FileOffset) @@ -499,14 +499,14 @@ CcRosCreateCacheSegment(PBCB Bcb, /* There is window between the call to CcRosLookupCacheSegment * and CcRosCreateCacheSegment. We must check if a segment on * the fileoffset exist. If there exist a segment, we release - * our new created segment and return the existing one. + * our new created segment and return the existing one. */ KeAcquireSpinLock(&Bcb->BcbLock, &oldIrql); current_entry = Bcb->BcbSegmentListHead.Flink; previous = NULL; while (current_entry != &Bcb->BcbSegmentListHead) { - current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, + current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, BcbSegmentListEntry); if (current->FileOffset <= FileOffset && (current->FileOffset + Bcb->CacheSegmentSize) > FileOffset) @@ -554,7 +554,7 @@ CcRosCreateCacheSegment(PBCB Bcb, KeAcquireSpinLock(&CiCacheSegMappingRegionLock, &oldIrql); StartingOffset = RtlFindClearBitsAndSet(&CiCacheSegMappingRegionAllocMap, Bcb->CacheSegmentSize / PAGE_SIZE, CiCacheSegMappingRegionHint); - + if (StartingOffset == 0xffffffff) { DPRINT1("Out of CacheSeg mapping space\n"); @@ -565,7 +565,7 @@ CcRosCreateCacheSegment(PBCB Bcb, if (CiCacheSegMappingRegionHint == StartingOffset) { - CiCacheSegMappingRegionHint += Bcb->CacheSegmentSize / PAGE_SIZE; + CiCacheSegMappingRegionHint += Bcb->CacheSegmentSize / PAGE_SIZE; } KeReleaseSpinLock(&CiCacheSegMappingRegionLock, oldIrql); @@ -627,10 +627,10 @@ CcRosGetCacheSegmentChain(PBCB Bcb, Length = ROUND_UP(Length, Bcb->CacheSegmentSize); #if defined(__GNUC__) - CacheSegList = alloca(sizeof(PCACHE_SEGMENT) * + CacheSegList = alloca(sizeof(PCACHE_SEGMENT) * (Length / Bcb->CacheSegmentSize)); #elif defined(_MSC_VER) - CacheSegList = _alloca(sizeof(PCACHE_SEGMENT) * + CacheSegList = _alloca(sizeof(PCACHE_SEGMENT) * (Length / Bcb->CacheSegmentSize)); #else #error Unknown compiler for alloca intrinsic stack allocation "function" @@ -668,7 +668,7 @@ CcRosGetCacheSegmentChain(PBCB Bcb, } } Previous->NextInChain = NULL; - + return(STATUS_SUCCESS); } @@ -713,7 +713,7 @@ CcRosGetCacheSegment(PBCB Bcb, return(STATUS_SUCCESS); } -NTSTATUS STDCALL +NTSTATUS STDCALL CcRosRequestCacheSegment(PBCB Bcb, ULONG FileOffset, PVOID* BaseAddress, @@ -743,8 +743,8 @@ CcRosRequestCacheSegment(PBCB Bcb, } #ifdef CACHE_BITMAP #else -STATIC VOID -CcFreeCachePage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address, +STATIC VOID +CcFreeCachePage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address, PFN_TYPE Page, SWAPENTRY SwapEntry, BOOLEAN Dirty) { ASSERT(SwapEntry == 0); @@ -754,7 +754,7 @@ CcFreeCachePage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address, } } #endif -NTSTATUS +NTSTATUS CcRosInternalFreeCacheSegment(PCACHE_SEGMENT CacheSeg) /* * FUNCTION: Releases a cache segment associated with a BCB @@ -774,7 +774,7 @@ CcRosInternalFreeCacheSegment(PCACHE_SEGMENT CacheSeg) /* Unmap all the pages. */ for (i = 0; i < RegionSize; i++) { - MmDeleteVirtualMapping(NULL, + MmDeleteVirtualMapping(NULL, CacheSeg->BaseAddress + (i * PAGE_SIZE), FALSE, NULL, @@ -785,7 +785,7 @@ CcRosInternalFreeCacheSegment(PCACHE_SEGMENT CacheSeg) KeAcquireSpinLock(&CiCacheSegMappingRegionLock, &oldIrql); /* Deallocate all the pages used. */ Base = (ULONG)(CacheSeg->BaseAddress - CiCacheSegMappingRegionBase) / PAGE_SIZE; - + RtlClearBits(&CiCacheSegMappingRegionAllocMap, Base, RegionSize); CiCacheSegMappingRegionHint = min (CiCacheSegMappingRegionHint, Base); @@ -858,12 +858,12 @@ CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointers, { Offset = *FileOffset; } - else + else { Offset.QuadPart = (LONGLONG)0; Length = Bcb->FileSize.u.LowPart; } - + if (IoStatus) { IoStatus->Status = STATUS_SUCCESS; @@ -909,7 +909,7 @@ CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointers, } } -NTSTATUS +NTSTATUS CcRosDeleteFileCache(PFILE_OBJECT FileObject, PBCB Bcb) /* * FUNCTION: Releases the BCB associated with a file object @@ -938,7 +938,7 @@ CcRosDeleteFileCache(PFILE_OBJECT FileObject, PBCB Bcb) Bcb->BcbRemoveListEntry.Flink = NULL; } - FileObject->SectionObjectPointer->SharedCacheMap = NULL; + FileObject->SectionObjectPointer->SharedCacheMap = NULL; /* * Release all cache segments. @@ -960,7 +960,7 @@ CcRosDeleteFileCache(PFILE_OBJECT FileObject, PBCB Bcb) } InsertHeadList(&FreeList, ¤t->BcbSegmentListEntry); } - KeReleaseSpinLock(&Bcb->BcbLock, oldIrql); + KeReleaseSpinLock(&Bcb->BcbLock, oldIrql); ExReleaseFastMutex(&ViewLock); ObDereferenceObject (Bcb->FileObject); @@ -971,7 +971,7 @@ CcRosDeleteFileCache(PFILE_OBJECT FileObject, PBCB Bcb) current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, BcbSegmentListEntry); Status = CcRosInternalFreeCacheSegment(current); } - ExFreeToNPagedLookasideList(&BcbLookasideList, Bcb); + ExFreeToNPagedLookasideList(&BcbLookasideList, Bcb); ExAcquireFastMutex(&ViewLock); } return(STATUS_SUCCESS); @@ -1042,7 +1042,7 @@ VOID CcRosDereferenceCache(PFILE_OBJECT FileObject) ExReleaseFastMutex(&ViewLock); } -NTSTATUS STDCALL +NTSTATUS STDCALL CcRosReleaseFileCache(PFILE_OBJECT FileObject) /* * FUNCTION: Called by the file system when a handle to a file object @@ -1082,7 +1082,7 @@ CcRosReleaseFileCache(PFILE_OBJECT FileObject) return(STATUS_SUCCESS); } -NTSTATUS +NTSTATUS CcTryToInitializeFileCache(PFILE_OBJECT FileObject) { PBCB Bcb; @@ -1115,7 +1115,7 @@ CcTryToInitializeFileCache(PFILE_OBJECT FileObject) } -NTSTATUS STDCALL +NTSTATUS STDCALL CcRosInitializeFileCache(PFILE_OBJECT FileObject, ULONG CacheSegmentSize) /* @@ -1146,9 +1146,9 @@ CcRosInitializeFileCache(PFILE_OBJECT FileObject, Bcb->CacheSegmentSize = CacheSegmentSize; if (FileObject->FsContext) { - Bcb->AllocationSize = + Bcb->AllocationSize = ((PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext)->AllocationSize; - Bcb->FileSize = + Bcb->FileSize = ((PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext)->FileSize; } KeInitializeSpinLock(&Bcb->BcbLock); @@ -1219,7 +1219,7 @@ CmLazyCloseThreadMain(PVOID Ignored) DbgPrint("LazyCloseThread: Terminating\n"); break; } - + ExAcquireFastMutex(&ViewLock); CcTimeStamp++; if (CcTimeStamp >= 30) @@ -1250,7 +1250,7 @@ CcInitView(VOID) #endif NTSTATUS Status; KPRIORITY Priority; - + DPRINT("CcInitView()\n"); #ifdef CACHE_BITMAP BoundaryAddressMultiple.QuadPart = 0; @@ -1281,7 +1281,7 @@ CcInitView(VOID) RtlClearAllBits(&CiCacheSegMappingRegionAllocMap); KeInitializeSpinLock(&CiCacheSegMappingRegionLock); -#endif +#endif InitializeListHead(&CacheSegmentListHead); InitializeListHead(&DirtySegmentListHead); InitializeListHead(&CacheSegmentLRUListHead); @@ -1310,10 +1310,10 @@ CcInitView(VOID) 20); MmInitializeMemoryConsumer(MC_CACHE, CcRosTrimCache); - + CcInitCacheZeroPage(); - CcTimeStamp = 0; + CcTimeStamp = 0; LazyCloseThreadShouldTerminate = FALSE; KeInitializeEvent (&LazyCloseThreadEvent, SynchronizationEvent, FALSE); Status = PsCreateSystemThread(&LazyCloseThreadHandle, diff --git a/reactos/ntoskrnl/cm/cm.h b/reactos/ntoskrnl/cm/cm.h index 952b6c8a5c5..ff2f45033d5 100644 --- a/reactos/ntoskrnl/cm/cm.h +++ b/reactos/ntoskrnl/cm/cm.h @@ -356,7 +356,7 @@ typedef struct _KEY_OBJECT /* List entry into the global key object list */ LIST_ENTRY ListEntry; - + /* Time stamp for the last access by the parse routine */ ULONG TimeStamp; } KEY_OBJECT, *PKEY_OBJECT; diff --git a/reactos/ntoskrnl/cm/ntfunc.c b/reactos/ntoskrnl/cm/ntfunc.c index 53388c6602f..ea3de91a9f7 100644 --- a/reactos/ntoskrnl/cm/ntfunc.c +++ b/reactos/ntoskrnl/cm/ntfunc.c @@ -1,5 +1,5 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/cm/ntfunc.c @@ -39,11 +39,11 @@ CmRegisterCallback(IN PEX_CALLBACK_FUNCTION Function, IN OUT PLARGE_INTEGER Cookie) { PREGISTRY_CALLBACK Callback; - + PAGED_CODE(); - + ASSERT(Function && Cookie); - + Callback = ExAllocatePoolWithTag(PagedPool, sizeof(REGISTRY_CALLBACK), TAG('C', 'M', 'c', 'b')); @@ -54,7 +54,7 @@ CmRegisterCallback(IN PEX_CALLBACK_FUNCTION Function, Callback->Function = Function; Callback->Context = Context; Callback->PendingDelete = FALSE; - + /* add it to the callback list and receive a cookie for the callback */ ExAcquireFastMutex(&CmiCallbackLock); /* FIXME - to receive a unique cookie we'll just return the pointer to the @@ -63,7 +63,7 @@ CmRegisterCallback(IN PEX_CALLBACK_FUNCTION Function, InsertTailList(&CmiCallbackHead, &Callback->ListEntry); ExReleaseFastMutex(&CmiCallbackLock); - + *Cookie = Callback->Cookie; return STATUS_SUCCESS; } @@ -79,7 +79,7 @@ NTSTATUS STDCALL CmUnRegisterCallback(IN LARGE_INTEGER Cookie) { PLIST_ENTRY CurrentEntry; - + PAGED_CODE(); ExAcquireFastMutex(&CmiCallbackLock); @@ -121,7 +121,7 @@ CmUnRegisterCallback(IN LARGE_INTEGER Cookie) } } } - + ExReleaseFastMutex(&CmiCallbackLock); return STATUS_UNSUCCESSFUL; @@ -133,9 +133,9 @@ CmiCallRegisteredCallbacks(IN REG_NOTIFY_CLASS Argument1, IN PVOID Argument2) { PLIST_ENTRY CurrentEntry; - + PAGED_CODE(); - + ExAcquireFastMutex(&CmiCallbackLock); for(CurrentEntry = CmiCallbackHead.Flink; @@ -149,10 +149,10 @@ CmiCallRegisteredCallbacks(IN REG_NOTIFY_CLASS Argument1, ExAcquireRundownProtectionEx(&CurrentCallback->RundownRef, 1)) { NTSTATUS Status; - + /* don't hold locks during the callbacks! */ ExReleaseFastMutex(&CmiCallbackLock); - + Status = CurrentCallback->Function(CurrentCallback->Context, Argument1, Argument2); @@ -169,9 +169,9 @@ CmiCallRegisteredCallbacks(IN REG_NOTIFY_CLASS Argument1, ExReleaseRundownProtectionEx(&CurrentCallback->RundownRef, 1); } } - + ExReleaseFastMutex(&CmiCallbackLock); - + return STATUS_SUCCESS; } @@ -191,7 +191,7 @@ NtCreateKey(OUT PHANDLE KeyHandle, PVOID Object; PWSTR Start; unsigned i; - + PAGED_CODE(); DPRINT("NtCreateKey (Name %wZ KeyHandle %x Root %x)\n", @@ -358,7 +358,7 @@ NtCreateKey(OUT PHANDLE KeyHandle, ExReleaseResourceLite(&CmiRegistryLock); KeLeaveCriticalRegion(); - + ObDereferenceObject(Object); if (Disposition) @@ -376,11 +376,11 @@ NtDeleteKey(IN HANDLE KeyHandle) KPROCESSOR_MODE PreviousMode; PKEY_OBJECT KeyObject; NTSTATUS Status; - + PAGED_CODE(); DPRINT1("NtDeleteKey(KeyHandle %x) called\n", KeyHandle); - + PreviousMode = ExGetPreviousMode(); /* Verify that the handle is valid and is a registry key */ @@ -462,9 +462,9 @@ NtEnumerateKey(IN HANDLE KeyHandle, ULONG NameSize, ClassSize; KPROCESSOR_MODE PreviousMode; NTSTATUS Status; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); DPRINT("KH %x I %d KIC %x KI %x L %d RL %x\n", @@ -687,10 +687,10 @@ NtEnumerateKey(IN HANDLE KeyHandle, Status = STATUS_BUFFER_OVERFLOW; CHECKPOINT; } - else if (Length - FIELD_OFFSET(KEY_NODE_INFORMATION, Name[0]) - + else if (Length - FIELD_OFFSET(KEY_NODE_INFORMATION, Name[0]) - NameSize < ClassSize) { - ClassSize = Length - FIELD_OFFSET(KEY_NODE_INFORMATION, Name[0]) - + ClassSize = Length - FIELD_OFFSET(KEY_NODE_INFORMATION, Name[0]) - NameSize; Status = STATUS_BUFFER_OVERFLOW; CHECKPOINT; @@ -812,7 +812,7 @@ NtEnumerateValueKey(IN HANDLE KeyHandle, PKEY_VALUE_BASIC_INFORMATION ValueBasicInformation; PKEY_VALUE_PARTIAL_INFORMATION ValuePartialInformation; PKEY_VALUE_FULL_INFORMATION ValueFullInformation; - + PAGED_CODE(); DPRINT("KH %x I %d KVIC %x KVI %x L %d RL %x\n", @@ -879,7 +879,7 @@ NtEnumerateValueKey(IN HANDLE KeyHandle, } else { - ValueBasicInformation = (PKEY_VALUE_BASIC_INFORMATION) + ValueBasicInformation = (PKEY_VALUE_BASIC_INFORMATION) KeyValueInformation; ValueBasicInformation->TitleIndex = 0; ValueBasicInformation->Type = ValueCell->DataType; @@ -911,7 +911,7 @@ NtEnumerateValueKey(IN HANDLE KeyHandle, case KeyValuePartialInformation: DataSize = ValueCell->DataSize & REG_DATA_SIZE_MASK; - *ResultLength = FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[0]) + + *ResultLength = FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[0]) + DataSize; if (Length < FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[0])) @@ -933,18 +933,18 @@ NtEnumerateValueKey(IN HANDLE KeyHandle, Status = STATUS_BUFFER_OVERFLOW; CHECKPOINT; } - + if (!(ValueCell->DataSize & REG_DATA_IN_OFFSET)) { DataCell = CmiGetCell (RegistryHive, ValueCell->DataOffset, NULL); - RtlCopyMemory(ValuePartialInformation->Data, + RtlCopyMemory(ValuePartialInformation->Data, DataCell->Data, DataSize); } else { - RtlCopyMemory(ValuePartialInformation->Data, - &ValueCell->DataOffset, + RtlCopyMemory(ValuePartialInformation->Data, + &ValueCell->DataOffset, DataSize); } } @@ -967,19 +967,19 @@ NtEnumerateValueKey(IN HANDLE KeyHandle, } else { - ValueFullInformation = (PKEY_VALUE_FULL_INFORMATION) + ValueFullInformation = (PKEY_VALUE_FULL_INFORMATION) KeyValueInformation; ValueFullInformation->TitleIndex = 0; ValueFullInformation->Type = ValueCell->DataType; ValueFullInformation->NameLength = NameSize; - ValueFullInformation->DataOffset = + ValueFullInformation->DataOffset = (ULONG_PTR)ValueFullInformation->Name - (ULONG_PTR)ValueFullInformation + ValueFullInformation->NameLength; ValueFullInformation->DataOffset = ROUND_UP(ValueFullInformation->DataOffset, sizeof(PVOID)); ValueFullInformation->DataLength = ValueCell->DataSize & REG_DATA_SIZE_MASK; - + if (Length - FIELD_OFFSET(KEY_VALUE_FULL_INFORMATION, Name[0]) < NameSize) { @@ -1050,11 +1050,11 @@ NtFlushKey(IN HANDLE KeyHandle) PKEY_OBJECT KeyObject; PREGISTRY_HIVE RegistryHive; KPROCESSOR_MODE PreviousMode; - + PAGED_CODE(); DPRINT("NtFlushKey (KeyHandle %lx) called\n", KeyHandle); - + PreviousMode = ExGetPreviousMode(); /* Verify that the handle is valid and is a registry key */ @@ -1106,7 +1106,7 @@ NtOpenKey(OUT PHANDLE KeyHandle, PVOID Object; HANDLE hKey; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); DPRINT("NtOpenKey(KH %x DA %x OA %x OA->ON '%wZ'\n", @@ -1134,7 +1134,7 @@ NtOpenKey(OUT PHANDLE KeyHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -1223,7 +1223,7 @@ NtQueryKey(IN HANDLE KeyHandle, PKEY_CELL KeyCell; ULONG NameSize, ClassSize; NTSTATUS Status; - + PAGED_CODE(); DPRINT("NtQueryKey(KH %x KIC %x KI %x L %d RL %x)\n", @@ -1322,10 +1322,10 @@ NtQueryKey(IN HANDLE KeyHandle, Status = STATUS_BUFFER_OVERFLOW; CHECKPOINT; } - else if (Length - FIELD_OFFSET(KEY_NODE_INFORMATION, Name[0]) - + else if (Length - FIELD_OFFSET(KEY_NODE_INFORMATION, Name[0]) - NameSize < ClassSize) { - ClassSize = Length - FIELD_OFFSET(KEY_NODE_INFORMATION, Name[0]) - + ClassSize = Length - FIELD_OFFSET(KEY_NODE_INFORMATION, Name[0]) - NameSize; Status = STATUS_BUFFER_OVERFLOW; CHECKPOINT; @@ -1382,7 +1382,7 @@ NtQueryKey(IN HANDLE KeyHandle, Status = STATUS_BUFFER_OVERFLOW; CHECKPOINT; } - + if (ClassSize) { ClassCell = CmiGetCell (KeyObject->RegistryHive, @@ -1433,7 +1433,7 @@ NtQueryValueKey(IN HANDLE KeyHandle, PKEY_VALUE_BASIC_INFORMATION ValueBasicInformation; PKEY_VALUE_PARTIAL_INFORMATION ValuePartialInformation; PKEY_VALUE_FULL_INFORMATION ValueFullInformation; - + PAGED_CODE(); DPRINT("NtQueryValueKey(KeyHandle %x ValueName %S Length %x)\n", @@ -1494,7 +1494,7 @@ NtQueryValueKey(IN HANDLE KeyHandle, } else { - ValueBasicInformation = (PKEY_VALUE_BASIC_INFORMATION) + ValueBasicInformation = (PKEY_VALUE_BASIC_INFORMATION) KeyValueInformation; ValueBasicInformation->TitleIndex = 0; ValueBasicInformation->Type = ValueCell->DataType; @@ -1587,7 +1587,7 @@ NtQueryValueKey(IN HANDLE KeyHandle, ValueFullInformation->TitleIndex = 0; ValueFullInformation->Type = ValueCell->DataType; ValueFullInformation->NameLength = NameSize; - ValueFullInformation->DataOffset = + ValueFullInformation->DataOffset = (ULONG_PTR)ValueFullInformation->Name - (ULONG_PTR)ValueFullInformation + ValueFullInformation->NameLength; @@ -1675,7 +1675,7 @@ NtSetValueKey(IN HANDLE KeyHandle, PDATA_CELL NewDataCell; PHBIN pBin; ULONG DesiredAccess; - + PAGED_CODE(); DPRINT("NtSetValueKey(KeyHandle %x ValueName '%wZ' Type %d)\n", @@ -1830,7 +1830,7 @@ NtDeleteValueKey (IN HANDLE KeyHandle, { PKEY_OBJECT KeyObject; NTSTATUS Status; - + PAGED_CODE(); /* Verify that the handle is valid and is a registry key */ @@ -1903,7 +1903,7 @@ NtLoadKey2 (IN POBJECT_ATTRIBUTES KeyObjectAttributes, ULONG BufferSize; ULONG Length; NTSTATUS Status; - + PAGED_CODE(); DPRINT ("NtLoadKey2() called\n"); @@ -2038,7 +2038,7 @@ NtNotifyChangeKey (IN HANDLE KeyHandle, IN ULONG Length, IN BOOLEAN Asynchronous) { - return NtNotifyChangeMultipleKeys(KeyHandle, + return NtNotifyChangeMultipleKeys(KeyHandle, 0, NULL, Event, @@ -2071,7 +2071,7 @@ NtQueryMultipleValueKey (IN HANDLE KeyHandle, NTSTATUS Status; PUCHAR DataPtr; ULONG i; - + PAGED_CODE(); /* Verify that the handle is valid and is a registry key */ @@ -2201,7 +2201,7 @@ NtSaveKey (IN HANDLE KeyHandle, PREGISTRY_HIVE TempHive; PKEY_OBJECT KeyObject; NTSTATUS Status; - + PAGED_CODE(); DPRINT ("NtSaveKey() called\n"); @@ -2305,7 +2305,7 @@ NtSetInformationKey (IN HANDLE KeyHandle, { PKEY_OBJECT KeyObject; NTSTATUS Status; - + PAGED_CODE(); if (KeyInformationClass != KeyWriteTimeInformation) @@ -2363,7 +2363,7 @@ NtUnloadKey (IN POBJECT_ATTRIBUTES KeyObjectAttributes) { PREGISTRY_HIVE RegistryHive; NTSTATUS Status; - + PAGED_CODE(); DPRINT ("NtUnloadKey() called\n"); @@ -2411,7 +2411,7 @@ NTSTATUS STDCALL NtInitializeRegistry (IN BOOLEAN SetUpBoot) { NTSTATUS Status; - + PAGED_CODE(); if (CmiRegistryInitialized == TRUE) diff --git a/reactos/ntoskrnl/cm/regfile.c b/reactos/ntoskrnl/cm/regfile.c index eb340933fdb..5a8c75751fd 100644 --- a/reactos/ntoskrnl/cm/regfile.c +++ b/reactos/ntoskrnl/cm/regfile.c @@ -1,5 +1,5 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/cm/regfile.c @@ -105,7 +105,7 @@ CmiVerifyBinHeader(PHBIN BinHeader) //BinHeader->DateModified.dwHighDateTime - + if (BinHeader->BinSize != REG_BLOCK_SIZE) { DbgPrint("BinSize is %.08x (should be a multiple of %.08x)\n", @@ -2873,7 +2873,7 @@ CmiAddValueToKey(IN PREGISTRY_HIVE RegistryHive, CmiMarkBlockDirty(RegistryHive, KeyCellOffset); CmiMarkBlockDirty(RegistryHive, ValueListCellOffset); } - else if (KeyCell->NumberOfValues >= + else if (KeyCell->NumberOfValues >= (((ULONG)ABS_VALUE(ValueListCell->CellSize) - sizeof(VALUE_LIST_CELL)) / sizeof(BLOCK_OFFSET))) { #if 0 @@ -3023,7 +3023,7 @@ CmiAllocateHashTableCell (IN PREGISTRY_HIVE RegistryHive, Status = STATUS_SUCCESS; *HashBlock = NULL; - NewHashSize = sizeof(HASH_TABLE_CELL) + + NewHashSize = sizeof(HASH_TABLE_CELL) + (SubKeyCount * sizeof(HASH_RECORD)); Status = CmiAllocateCell (RegistryHive, NewHashSize, diff --git a/reactos/ntoskrnl/cm/registry.c b/reactos/ntoskrnl/cm/registry.c index 671afd06bae..a11f1da1de3 100644 --- a/reactos/ntoskrnl/cm/registry.c +++ b/reactos/ntoskrnl/cm/registry.c @@ -255,10 +255,10 @@ CmiWorkerThread(PVOID Param) while (1) { - Status = KeWaitForSingleObject(&CmiWorkerTimer, - Executive, - KernelMode, - FALSE, + Status = KeWaitForSingleObject(&CmiWorkerTimer, + Executive, + KernelMode, + FALSE, NULL); if (Status == STATUS_SUCCESS) { @@ -311,25 +311,25 @@ STDCALL CmInitHives(BOOLEAN SetupBoot) { PCHAR BaseAddress; - + /* Load Registry Hives. This one can be missing. */ if (CachedModules[SystemRegistry]) { BaseAddress = (PCHAR)CachedModules[SystemRegistry]->ModStart; CmImportSystemHive(BaseAddress, CachedModules[SystemRegistry]->ModEnd - (ULONG_PTR)BaseAddress); } - + BaseAddress = (PCHAR)CachedModules[HardwareRegistry]->ModStart; CmImportHardwareHive(BaseAddress, CachedModules[HardwareRegistry]->ModEnd - (ULONG_PTR)BaseAddress); - + /* Create dummy keys if no hardware hive was found */ CmImportHardwareHive (NULL, 0); /* Initialize volatile registry settings */ if (SetupBoot == FALSE) CmInit2((PCHAR)KeLoaderBlock.CommandLine); -} +} VOID INIT_FUNCTION CmInitializeRegistry(VOID) @@ -397,14 +397,14 @@ CmInitializeRegistry(VOID) KEBUGCHECK(0); } - /* Start the timer */ + /* Start the timer */ DueTime.QuadPart = -1; KeSetTimerEx(&CmiWorkerTimer, DueTime, 5000, NULL); /* 5sec */ /* Build volatile registry store */ Status = CmiCreateVolatileHive (&CmiVolatileHive); ASSERT(NT_SUCCESS(Status)); - + InitializeListHead(&CmiCallbackHead); ExInitializeFastMutex(&CmiCallbackLock); @@ -548,7 +548,7 @@ CmInit2(PCHAR CommandLine) MiniNT = TRUE; else if (!_strnicmp(CommandLine, "DEBUGPORT=PICE", 14)) PiceStart = 1; - + /* Add a space between the options */ if (Position != 0) SystemStartOptions[Position++] = L' '; @@ -884,7 +884,7 @@ CmiDisconnectHive (IN POBJECT_ATTRIBUTES KeyObjectAttributes, { DPRINT1 ("Hive is still in use (hc %d, rc %d)\n", ObGetObjectHandleCount (KeyObject), ObGetObjectPointerCount (KeyObject)); ObDereferenceObject (KeyObject); - + /* Release registry lock */ ExReleaseResourceLite (&CmiRegistryLock); KeLeaveCriticalRegion(); diff --git a/reactos/ntoskrnl/cm/regobj.c b/reactos/ntoskrnl/cm/regobj.c index 4a5ffa8bc04..97d2ec75c55 100644 --- a/reactos/ntoskrnl/cm/regobj.c +++ b/reactos/ntoskrnl/cm/regobj.c @@ -1,5 +1,5 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/cm/regobj.c @@ -203,7 +203,7 @@ CmiObjectParse(PVOID ParsedObject, if (NT_SUCCESS(Status)) { DPRINT("LinkPath '%wZ'\n", &LinkPath); - + ExReleaseResourceLite(&CmiRegistryLock); KeLeaveCriticalRegion(); @@ -627,7 +627,7 @@ CmiRemoveKeyFromList(PKEY_OBJECT KeyToRemove) ParentKey->NumberOfSubKeys--; DPRINT("Dereference parent key: 0x%x\n", ParentKey); - + ObDereferenceObject(ParentKey); return STATUS_SUCCESS; } @@ -645,7 +645,7 @@ CmiScanKeyList(PKEY_OBJECT Parent, { PKEY_OBJECT CurKey; ULONG Index; - + DPRINT("Scanning key list for: %wZ (Parent: %wZ)\n", KeyName, &Parent->Name); @@ -670,7 +670,7 @@ CmiScanKeyList(PKEY_OBJECT Parent, } } } - + if (Index < Parent->NumberOfSubKeys) { if (CurKey->Flags & KO_MARKED_FOR_DELETE) diff --git a/reactos/ntoskrnl/dbgk/dbgkutil.c b/reactos/ntoskrnl/dbgk/dbgkutil.c index 0d3fc793996..d9ed8aba6e7 100644 --- a/reactos/ntoskrnl/dbgk/dbgkutil.c +++ b/reactos/ntoskrnl/dbgk/dbgkutil.c @@ -30,17 +30,17 @@ DbgkCreateThread(PVOID StartAddress) } Message.Header.MessageSize = sizeof(LPC_DBG_MESSAGE); - Message.Header.DataSize = sizeof(LPC_DBG_MESSAGE) - + Message.Header.DataSize = sizeof(LPC_DBG_MESSAGE) - sizeof(LPC_MESSAGE); Message.Type = DBG_EVENT_CREATE_THREAD; Message.Status = STATUS_SUCCESS; Message.Data.CreateThread.Reserved = 0; Message.Data.CreateThread.StartAddress = StartAddress; - + /* FIXME: Freeze all threads in process */ /* Send the message to the process's debug port and wait for a reply */ - Status = + Status = LpcSendDebugMessagePort(PsGetCurrentThread()->ThreadsProcess->DebugPort, &Message, &Reply); diff --git a/reactos/ntoskrnl/dbgk/debug.c b/reactos/ntoskrnl/dbgk/debug.c index 3a53a9665b0..732535e602b 100644 --- a/reactos/ntoskrnl/dbgk/debug.c +++ b/reactos/ntoskrnl/dbgk/debug.c @@ -16,8 +16,8 @@ POBJECT_TYPE DbgkDebugObjectType; /* FUNCTIONS *****************************************************************/ -NTSTATUS -STDCALL +NTSTATUS +STDCALL NtCreateDebugObject(OUT PHANDLE DebugHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, @@ -27,27 +27,27 @@ NtCreateDebugObject(OUT PHANDLE DebugHandle, PDBGK_DEBUG_OBJECT DebugObject; HANDLE hDebug; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); DPRINT("NtCreateDebugObject(0x%x, 0x%x, 0x%x)\n", DebugHandle, DesiredAccess, ObjectAttributes); - + /* Check Output Safety */ if(PreviousMode != KernelMode) { - + _SEH_TRY { - + ProbeForWrite(DebugHandle, sizeof(HANDLE), sizeof(ULONG)); } _SEH_HANDLE { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; - + if(!NT_SUCCESS(Status)) return Status; } - + /* Create the Object */ Status = ObCreateObject(PreviousMode, DbgkDebugObjectType, @@ -58,22 +58,22 @@ NtCreateDebugObject(OUT PHANDLE DebugHandle, 0, 0, (PVOID*)&DebugObject); - + /* Check for Success */ if(NT_SUCCESS(Status)) { - + /* Initialize the Debug Object's Fast Mutex */ ExInitializeFastMutex(&DebugObject->Mutex); - + /* Initialize the State Event List */ InitializeListHead(&DebugObject->StateEventListEntry); - + /* Initialize the Debug Object's Wait Event */ KeInitializeEvent(&DebugObject->Event, NotificationEvent, 0); - + /* Set the Flags */ DebugObject->KillProcessOnExit = KillProcessOnExit; - + /* Insert it */ Status = ObInsertObject((PVOID)DebugObject, NULL, @@ -82,18 +82,18 @@ NtCreateDebugObject(OUT PHANDLE DebugHandle, NULL, &hDebug); ObDereferenceObject(DebugObject); - + /* Check for success and return handle */ if(NT_SUCCESS(Status)) { - + _SEH_TRY { - + *DebugHandle = hDebug; - + } _SEH_HANDLE { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } } @@ -111,7 +111,7 @@ NtWaitForDebugEvent(IN HANDLE DebugObject, // Debug object handle must grant DEB { UNIMPLEMENTED; - + return STATUS_NOT_IMPLEMENTED; } @@ -123,7 +123,7 @@ NtDebugContinue(IN HANDLE DebugObject, // Debug object handle must grant DEBU { UNIMPLEMENTED; - + return STATUS_NOT_IMPLEMENTED; } @@ -134,7 +134,7 @@ NtDebugActiveProcess(IN HANDLE Process, // Process handle must grant PROCESS { UNIMPLEMENTED; - + return STATUS_NOT_IMPLEMENTED; } @@ -145,7 +145,7 @@ NtRemoveProcessDebug(IN HANDLE Process, // Process handle must grant PROCESS { UNIMPLEMENTED; - + return STATUS_NOT_IMPLEMENTED; } @@ -158,7 +158,7 @@ NtSetInformationDebugObject(IN HANDLE DebugObject, // Debug object handle need n OUT PULONG ReturnLength OPTIONAL) { UNIMPLEMENTED; - + return STATUS_NOT_IMPLEMENTED; } /* EOF */ diff --git a/reactos/ntoskrnl/ex/callback.c b/reactos/ntoskrnl/ex/callback.c index 918d766ffb7..a9eadb94a70 100644 --- a/reactos/ntoskrnl/ex/callback.c +++ b/reactos/ntoskrnl/ex/callback.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/callback.c * PURPOSE: Executive callbacks - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) * Alex Ionescu (alex@relsoft.net) */ @@ -171,7 +171,7 @@ ExCreateCallback( PINT_CALLBACK_OBJECT Callback; NTSTATUS Status; HANDLE Handle; - + PAGED_CODE(); /* Open a handle to the callback if it exists */ @@ -323,7 +323,7 @@ ExNotifyCallback( * ExRegisterCallback * * FUNCTION: - * Allows a function to associate a callback pointer (Function) + * Allows a function to associate a callback pointer (Function) * to a created Callback object * * ARGUMENTS: @@ -348,7 +348,7 @@ ExRegisterCallback( PINT_CALLBACK_OBJECT CallbackObject = (PINT_CALLBACK_OBJECT)OpaqueCallbackObject; PCALLBACK_REGISTRATION CallbackRegistration = NULL; KIRQL OldIrql; - + PAGED_CODE(); /* Create reference to Callback Object */ @@ -415,7 +415,7 @@ ExUnregisterCallback( PCALLBACK_REGISTRATION CallbackRegistration; PINT_CALLBACK_OBJECT CallbackObject; KIRQL OldIrql; - + PAGED_CODE(); /* Convert Handle to valid Structure Pointer */ diff --git a/reactos/ntoskrnl/ex/dbgctrl.c b/reactos/ntoskrnl/ex/dbgctrl.c index 84865b3a800..c29e65daa22 100644 --- a/reactos/ntoskrnl/ex/dbgctrl.c +++ b/reactos/ntoskrnl/ex/dbgctrl.c @@ -15,8 +15,8 @@ /* FUNCTIONS *****************************************************************/ -NTSTATUS -STDCALL +NTSTATUS +STDCALL NtSystemDebugControl(DEBUG_CONTROL_CODE ControlCode, PVOID InputBuffer, ULONG InputBufferLength, @@ -24,7 +24,7 @@ NtSystemDebugControl(DEBUG_CONTROL_CODE ControlCode, ULONG OutputBufferLength, PULONG ReturnLength) { - switch (ControlCode) + switch (ControlCode) { case DebugGetTraceInformation: case DebugSetInternalBreakpoint: @@ -33,14 +33,14 @@ NtSystemDebugControl(DEBUG_CONTROL_CODE ControlCode, case DebugQuerySpecialCalls: case DebugDbgBreakPoint: break; - + case DebugDbgLoadSymbols: KDB_LOADUSERMODULE_HOOK((PLDR_MODULE) InputBuffer); break; - + default: break; } - + return STATUS_SUCCESS; } diff --git a/reactos/ntoskrnl/ex/error.c b/reactos/ntoskrnl/ex/error.c index 77575551c39..de2b5580e2b 100644 --- a/reactos/ntoskrnl/ex/error.c +++ b/reactos/ntoskrnl/ex/error.c @@ -24,7 +24,7 @@ PEPROCESS ExpDefaultErrorPortProcess = NULL; /* * @implemented */ -VOID +VOID STDCALL ExRaiseAccessViolation(VOID) { @@ -46,7 +46,7 @@ ExRaiseDatatypeMisalignment (VOID) /* * @implemented */ -VOID +VOID STDCALL ExRaiseStatus(IN NTSTATUS Status) { @@ -59,7 +59,7 @@ ExRaiseStatus(IN NTSTATUS Status) ExceptionRecord.NumberParameters = 0; ExceptionRecord.ExceptionCode = Status; ExceptionRecord.ExceptionFlags = 0; - + /* Call the Rtl Function */ RtlRaiseException(&ExceptionRecord); } @@ -91,17 +91,17 @@ ExSystemExceptionFilter(VOID) VOID STDCALL ExRaiseHardError(IN NTSTATUS ErrorStatus, - IN ULONG NumberOfParameters, + IN ULONG NumberOfParameters, IN PUNICODE_STRING UnicodeStringParameterMask OPTIONAL, - IN PVOID *Parameters, - IN HARDERROR_RESPONSE_OPTION ResponseOption, + IN PVOID *Parameters, + IN HARDERROR_RESPONSE_OPTION ResponseOption, OUT PHARDERROR_RESPONSE Response) { UNIMPLEMENTED; } -NTSTATUS -STDCALL +NTSTATUS +STDCALL NtRaiseHardError(IN NTSTATUS ErrorStatus, IN ULONG NumberOfParameters, IN PUNICODE_STRING UnicodeStringParameterMask OPTIONAL, @@ -110,7 +110,7 @@ NtRaiseHardError(IN NTSTATUS ErrorStatus, OUT PHARDERROR_RESPONSE Response) { DPRINT1("Hard error %x\n", ErrorStatus); - + /* Call the Executive Function (WE SHOULD PUT SEH HERE/CAPTURE!) */ ExRaiseHardError(ErrorStatus, NumberOfParameters, @@ -118,45 +118,45 @@ NtRaiseHardError(IN NTSTATUS ErrorStatus, Parameters, ResponseOption, Response); - + /* Return Success */ return STATUS_SUCCESS; } -NTSTATUS -STDCALL +NTSTATUS +STDCALL NtSetDefaultHardErrorPort(IN HANDLE PortHandle) { - + KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_UNSUCCESSFUL; - + /* Check if we have the Privilege */ if(!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode)) { - + DPRINT1("NtSetDefaultHardErrorPort: Caller requires the SeTcbPrivilege privilege!\n"); return STATUS_PRIVILEGE_NOT_HELD; } - + /* Only called once during bootup, make sure we weren't called yet */ if(!ExReadyForErrors) { - + Status = ObReferenceObjectByHandle(PortHandle, 0, LpcPortObjectType, PreviousMode, (PVOID*)&ExpDefaultErrorPort, NULL); - + /* Check for Success */ if(NT_SUCCESS(Status)) { - + /* Save the data */ ExpDefaultErrorPortProcess = PsGetCurrentProcess(); ExReadyForErrors = TRUE; } } - + return Status; } diff --git a/reactos/ntoskrnl/ex/event.c b/reactos/ntoskrnl/ex/event.c index 5685ee181d0..b5011bba773 100644 --- a/reactos/ntoskrnl/ex/event.c +++ b/reactos/ntoskrnl/ex/event.c @@ -1,9 +1,9 @@ -/* +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/nt/event.c * PURPOSE: Named event support - * + * * PROGRAMMERS: Alex Ionescu(alex@relsoft.net) - Fixed bugs/commented * Philip Susi and David Welch */ @@ -25,14 +25,14 @@ static GENERIC_MAPPING ExpEventMapping = { EVENT_ALL_ACCESS}; static const INFORMATION_CLASS_INFO ExEventInfoClass[] = { - + /* EventBasicInformation */ ICI_SQ_SAME( sizeof(EVENT_BASIC_INFORMATION), sizeof(ULONG), ICIF_QUERY), }; /* FUNCTIONS *****************************************************************/ -VOID +VOID INIT_FUNCTION ExpInitializeEventImplementation(VOID) { @@ -63,15 +63,15 @@ ExpInitializeEventImplementation(VOID) /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtClearEvent(IN HANDLE EventHandle) { PKEVENT Event; NTSTATUS Status; - + PAGED_CODE(); - + /* Reference the Object */ Status = ObReferenceObjectByHandle(EventHandle, EVENT_MODIFY_STATE, @@ -79,15 +79,15 @@ NtClearEvent(IN HANDLE EventHandle) ExGetPreviousMode(), (PVOID*)&Event, NULL); - + /* Check for Success */ if(NT_SUCCESS(Status)) { - + /* Clear the Event and Dereference */ KeClearEvent(Event); ObDereferenceObject(Event); } - + /* Return Status */ return Status; } @@ -96,7 +96,7 @@ NtClearEvent(IN HANDLE EventHandle) /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtCreateEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, @@ -108,27 +108,27 @@ NtCreateEvent(OUT PHANDLE EventHandle, PKEVENT Event; HANDLE hEvent; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); DPRINT("NtCreateEvent(0x%x, 0x%x, 0x%x)\n", EventHandle, DesiredAccess, ObjectAttributes); - + /* Check Output Safety */ if(PreviousMode != KernelMode) { - + _SEH_TRY { - + ProbeForWrite(EventHandle, sizeof(HANDLE), sizeof(ULONG)); } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; - + if(!NT_SUCCESS(Status)) return Status; } - + /* Create the Object */ Status = ObCreateObject(PreviousMode, ExEventObjectType, @@ -139,15 +139,15 @@ NtCreateEvent(OUT PHANDLE EventHandle, 0, 0, (PVOID*)&Event); - + /* Check for Success */ if(NT_SUCCESS(Status)) { - + /* Initalize the Event */ KeInitializeEvent(Event, EventType, InitialState); - + /* Insert it */ Status = ObInsertObject((PVOID)Event, NULL, @@ -156,18 +156,18 @@ NtCreateEvent(OUT PHANDLE EventHandle, NULL, &hEvent); ObDereferenceObject(Event); - + /* Check for success and return handle */ if(NT_SUCCESS(Status)) { - + _SEH_TRY { - + *EventHandle = hEvent; - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } } @@ -179,7 +179,7 @@ NtCreateEvent(OUT PHANDLE EventHandle, /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtOpenEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, @@ -188,27 +188,27 @@ NtOpenEvent(OUT PHANDLE EventHandle, HANDLE hEvent; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; - - PAGED_CODE(); + + PAGED_CODE(); DPRINT("NtOpenEvent(0x%x, 0x%x, 0x%x)\n", EventHandle, DesiredAccess, ObjectAttributes); /* Check Output Safety */ if(PreviousMode != KernelMode) { - + _SEH_TRY { - + ProbeForWrite(EventHandle, sizeof(HANDLE), sizeof(ULONG)); } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; - + if(!NT_SUCCESS(Status)) return Status; } - + /* Open the Object */ Status = ObOpenObjectByName(ObjectAttributes, ExEventObjectType, @@ -217,21 +217,21 @@ NtOpenEvent(OUT PHANDLE EventHandle, DesiredAccess, NULL, &hEvent); - + /* Check for success and return handle */ if(NT_SUCCESS(Status)) { - + _SEH_TRY { - + *EventHandle = hEvent; - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } - + /* Return status */ return Status; } @@ -239,7 +239,7 @@ NtOpenEvent(OUT PHANDLE EventHandle, /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtPulseEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL) @@ -247,28 +247,28 @@ NtPulseEvent(IN HANDLE EventHandle, PKEVENT Event; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); DPRINT("NtPulseEvent(EventHandle 0%x PreviousState 0%x)\n", EventHandle, PreviousState); /* Check buffer validity */ if(PreviousState && PreviousMode == UserMode) { - + _SEH_TRY { - + ProbeForWrite(PreviousState, sizeof(LONG), sizeof(ULONG)); } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; if(!NT_SUCCESS(Status)) return Status; } - + /* Open the Object */ Status = ObReferenceObjectByHandle(EventHandle, EVENT_MODIFY_STATE, @@ -276,25 +276,25 @@ NtPulseEvent(IN HANDLE EventHandle, PreviousMode, (PVOID*)&Event, NULL); - + /* Check for success */ if(NT_SUCCESS(Status)) { - + /* Pulse the Event */ LONG Prev = KePulseEvent(Event, EVENT_INCREMENT, FALSE); ObDereferenceObject(Event); - - /* Return it */ + + /* Return it */ if(PreviousState) { - + _SEH_TRY { - + *PreviousState = Prev; - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } } @@ -307,7 +307,7 @@ NtPulseEvent(IN HANDLE EventHandle, /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtQueryEvent(IN HANDLE EventHandle, IN EVENT_INFORMATION_CLASS EventInformationClass, @@ -319,10 +319,10 @@ NtQueryEvent(IN HANDLE EventHandle, KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; PEVENT_BASIC_INFORMATION BasicInfo = (PEVENT_BASIC_INFORMATION)EventInformation; - + PAGED_CODE(); DPRINT("NtQueryEvent(0x%x, 0x%x, 0x%x)\n", EventHandle, EventInformationClass); - + /* Check buffers and class validity */ DefaultQueryInfoBufferCheck(EventInformationClass, ExEventInfoClass, @@ -332,12 +332,12 @@ NtQueryEvent(IN HANDLE EventHandle, PreviousMode, &Status); if(!NT_SUCCESS(Status)) { - + /* Invalid buffers */ DPRINT("NtQuerySemaphore() failed, Status: 0x%x\n", Status); return Status; } - + /* Get the Object */ Status = ObReferenceObjectByHandle(EventHandle, EVENT_QUERY_STATE, @@ -345,23 +345,23 @@ NtQueryEvent(IN HANDLE EventHandle, PreviousMode, (PVOID*)&Event, NULL); - + /* Check for success */ if(NT_SUCCESS(Status)) { _SEH_TRY { - + /* Return Event Type and State */ BasicInfo->EventType = Event->Header.Type; BasicInfo->EventState = KeReadStateEvent(Event); /* Return length */ if(ReturnLength) *ReturnLength = sizeof(EVENT_BASIC_INFORMATION); - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; /* Dereference the Object */ @@ -375,7 +375,7 @@ NtQueryEvent(IN HANDLE EventHandle, /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtResetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL) @@ -383,23 +383,23 @@ NtResetEvent(IN HANDLE EventHandle, PKEVENT Event; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); DPRINT("NtResetEvent(EventHandle 0%x PreviousState 0%x)\n", EventHandle, PreviousState); /* Check buffer validity */ if(PreviousState && PreviousMode == UserMode) { - + _SEH_TRY { - + ProbeForWrite(PreviousState, sizeof(LONG), sizeof(ULONG)); } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; if(!NT_SUCCESS(Status)) return Status; @@ -412,25 +412,25 @@ NtResetEvent(IN HANDLE EventHandle, PreviousMode, (PVOID*)&Event, NULL); - + /* Check for success */ if(NT_SUCCESS(Status)) { - + /* Reset the Event */ LONG Prev = KeResetEvent(Event); ObDereferenceObject(Event); - - /* Return it */ + + /* Return it */ if(PreviousState) { - + _SEH_TRY { - + *PreviousState = Prev; - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } } @@ -442,7 +442,7 @@ NtResetEvent(IN HANDLE EventHandle, /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL) @@ -450,23 +450,23 @@ NtSetEvent(IN HANDLE EventHandle, PKEVENT Event; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); DPRINT("NtSetEvent(EventHandle 0%x PreviousState 0%x)\n", EventHandle, PreviousState); /* Check buffer validity */ if(PreviousState != NULL && PreviousMode == UserMode) { - + _SEH_TRY { - + ProbeForWrite(PreviousState, sizeof(LONG), sizeof(ULONG)); } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; if(!NT_SUCCESS(Status)) return Status; @@ -479,7 +479,7 @@ NtSetEvent(IN HANDLE EventHandle, PreviousMode, (PVOID*)&Event, NULL); - + /* Check for success */ if(NT_SUCCESS(Status)) { @@ -487,17 +487,17 @@ NtSetEvent(IN HANDLE EventHandle, LONG Prev = KeSetEvent(Event, EVENT_INCREMENT, FALSE); ObDereferenceObject(Event); - /* Return it */ + /* Return it */ if(PreviousState) { - + _SEH_TRY { - + *PreviousState = Prev; - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } } diff --git a/reactos/ntoskrnl/ex/evtpair.c b/reactos/ntoskrnl/ex/evtpair.c index 5ce3316219e..a7af0db2b32 100644 --- a/reactos/ntoskrnl/ex/evtpair.c +++ b/reactos/ntoskrnl/ex/evtpair.c @@ -67,27 +67,27 @@ NtCreateEventPair(OUT PHANDLE EventPairHandle, HANDLE hEventPair; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); DPRINT("NtCreateEventPair: %x\n", EventPairHandle); - + /* Check Output Safety */ if(PreviousMode == UserMode) { - + _SEH_TRY { - + ProbeForWrite(EventPairHandle, sizeof(HANDLE), sizeof(ULONG)); } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; - + if(!NT_SUCCESS(Status)) return Status; } - + /* Create the Object */ DPRINT("Creating EventPair\n"); Status = ObCreateObject(PreviousMode, @@ -99,14 +99,14 @@ NtCreateEventPair(OUT PHANDLE EventPairHandle, 0, 0, (PVOID*)&EventPair); - + /* Check for Success */ if(NT_SUCCESS(Status)) { - + /* Initalize the Event */ DPRINT("Initializing EventPair\n"); KeInitializeEventPair(EventPair); - + /* Insert it */ Status = ObInsertObject((PVOID)EventPair, NULL, @@ -115,18 +115,18 @@ NtCreateEventPair(OUT PHANDLE EventPairHandle, NULL, &hEventPair); ObDereferenceObject(EventPair); - + /* Check for success and return handle */ if(NT_SUCCESS(Status)) { - + _SEH_TRY { - + *EventPairHandle = hEventPair; - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } } @@ -135,7 +135,7 @@ NtCreateEventPair(OUT PHANDLE EventPairHandle, return Status; } -NTSTATUS +NTSTATUS STDCALL NtOpenEventPair(OUT PHANDLE EventPairHandle, IN ACCESS_MASK DesiredAccess, @@ -144,26 +144,26 @@ NtOpenEventPair(OUT PHANDLE EventPairHandle, HANDLE hEventPair; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + /* Check Output Safety */ if(PreviousMode == UserMode) { - + _SEH_TRY { - + ProbeForWrite(EventPairHandle, sizeof(HANDLE), sizeof(ULONG)); } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; - + if(!NT_SUCCESS(Status)) return Status; } - + /* Open the Object */ Status = ObOpenObjectByName(ObjectAttributes, ExEventPairObjectType, @@ -172,21 +172,21 @@ NtOpenEventPair(OUT PHANDLE EventPairHandle, DesiredAccess, NULL, &hEventPair); - + /* Check for success and return handle */ if(NT_SUCCESS(Status)) { - + _SEH_TRY { - + *EventPairHandle = hEventPair; - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } - + /* Return status */ return Status; } @@ -199,10 +199,10 @@ NtSetHighEventPair(IN HANDLE EventPairHandle) PKEVENT_PAIR EventPair; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status; - + PAGED_CODE(); DPRINT("NtSetHighEventPair(EventPairHandle %x)\n", EventPairHandle); - + /* Open the Object */ Status = ObReferenceObjectByHandle(EventPairHandle, SYNCHRONIZE, @@ -210,17 +210,17 @@ NtSetHighEventPair(IN HANDLE EventPairHandle) PreviousMode, (PVOID*)&EventPair, NULL); - + /* Check for Success */ if(NT_SUCCESS(Status)) { - + /* Set the Event */ KeSetEvent(&EventPair->HighEvent, EVENT_INCREMENT, FALSE); /* Dereference Object */ ObDereferenceObject(EventPair); } - + /* Return status */ return Status; } @@ -232,10 +232,10 @@ NtSetHighWaitLowEventPair(IN HANDLE EventPairHandle) PKEVENT_PAIR EventPair; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status; - + PAGED_CODE(); DPRINT("NtSetHighWaitLowEventPair(EventPairHandle %x)\n", EventPairHandle); - + /* Open the Object */ Status = ObReferenceObjectByHandle(EventPairHandle, SYNCHRONIZE, @@ -243,13 +243,13 @@ NtSetHighWaitLowEventPair(IN HANDLE EventPairHandle) PreviousMode, (PVOID*)&EventPair, NULL); - + /* Check for Success */ if(NT_SUCCESS(Status)) { - + /* Set the Event */ KeSetEvent(&EventPair->HighEvent, EVENT_INCREMENT, FALSE); - + /* Wait for the Other one */ KeWaitForSingleObject(&EventPair->LowEvent, WrEventPair, @@ -260,25 +260,25 @@ NtSetHighWaitLowEventPair(IN HANDLE EventPairHandle) /* Dereference Object */ ObDereferenceObject(EventPair); } - + /* Return status */ return Status; } -NTSTATUS +NTSTATUS STDCALL NtSetLowEventPair(IN HANDLE EventPairHandle) { PKEVENT_PAIR EventPair; KPROCESSOR_MODE PreviousMode; NTSTATUS Status; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); DPRINT1("NtSetHighEventPair(EventPairHandle %x)\n", EventPairHandle); - + /* Open the Object */ Status = ObReferenceObjectByHandle(EventPairHandle, SYNCHRONIZE, @@ -286,17 +286,17 @@ NtSetLowEventPair(IN HANDLE EventPairHandle) PreviousMode, (PVOID*)&EventPair, NULL); - + /* Check for Success */ if(NT_SUCCESS(Status)) { - + /* Set the Event */ KeSetEvent(&EventPair->LowEvent, EVENT_INCREMENT, FALSE); /* Dereference Object */ ObDereferenceObject(EventPair); } - + /* Return status */ return Status; } @@ -308,10 +308,10 @@ NtSetLowWaitHighEventPair(IN HANDLE EventPairHandle) PKEVENT_PAIR EventPair; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status; - + PAGED_CODE(); DPRINT("NtSetHighWaitLowEventPair(EventPairHandle %x)\n", EventPairHandle); - + /* Open the Object */ Status = ObReferenceObjectByHandle(EventPairHandle, SYNCHRONIZE, @@ -319,13 +319,13 @@ NtSetLowWaitHighEventPair(IN HANDLE EventPairHandle) PreviousMode, (PVOID*)&EventPair, NULL); - + /* Check for Success */ if(NT_SUCCESS(Status)) { - + /* Set the Event */ KeSetEvent(&EventPair->LowEvent, EVENT_INCREMENT, FALSE); - + /* Wait for the Other one */ KeWaitForSingleObject(&EventPair->HighEvent, WrEventPair, @@ -336,23 +336,23 @@ NtSetLowWaitHighEventPair(IN HANDLE EventPairHandle) /* Dereference Object */ ObDereferenceObject(EventPair); } - + /* Return status */ return Status; } -NTSTATUS +NTSTATUS STDCALL NtWaitLowEventPair(IN HANDLE EventPairHandle) { PKEVENT_PAIR EventPair; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status; - + PAGED_CODE(); DPRINT("NtSetHighWaitLowEventPair(EventPairHandle %x)\n", EventPairHandle); - + /* Open the Object */ Status = ObReferenceObjectByHandle(EventPairHandle, SYNCHRONIZE, @@ -360,10 +360,10 @@ NtWaitLowEventPair(IN HANDLE EventPairHandle) PreviousMode, (PVOID*)&EventPair, NULL); - + /* Check for Success */ if(NT_SUCCESS(Status)) { - + /* Wait for the Event */ KeWaitForSingleObject(&EventPair->LowEvent, WrEventPair, @@ -374,22 +374,22 @@ NtWaitLowEventPair(IN HANDLE EventPairHandle) /* Dereference Object */ ObDereferenceObject(EventPair); } - + /* Return status */ return Status; } -NTSTATUS +NTSTATUS STDCALL NtWaitHighEventPair(IN HANDLE EventPairHandle) { PKEVENT_PAIR EventPair; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status; - + PAGED_CODE(); DPRINT("NtSetHighWaitLowEventPair(EventPairHandle %x)\n", EventPairHandle); - + /* Open the Object */ Status = ObReferenceObjectByHandle(EventPairHandle, SYNCHRONIZE, @@ -400,7 +400,7 @@ NtWaitHighEventPair(IN HANDLE EventPairHandle) /* Check for Success */ if(NT_SUCCESS(Status)) { - + /* Wait for the Event */ KeWaitForSingleObject(&EventPair->HighEvent, WrEventPair, @@ -411,7 +411,7 @@ NtWaitHighEventPair(IN HANDLE EventPairHandle) /* Dereference Object */ ObDereferenceObject(EventPair); } - + /* Return status */ return Status; } diff --git a/reactos/ntoskrnl/ex/fmutex.c b/reactos/ntoskrnl/ex/fmutex.c index 8bb01b4015d..9f905d793c8 100644 --- a/reactos/ntoskrnl/ex/fmutex.c +++ b/reactos/ntoskrnl/ex/fmutex.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/fmutex.c * PURPOSE: Implements fast mutexes - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ diff --git a/reactos/ntoskrnl/ex/handle.c b/reactos/ntoskrnl/ex/handle.c index 1c0d9d39445..5b291781e91 100644 --- a/reactos/ntoskrnl/ex/handle.c +++ b/reactos/ntoskrnl/ex/handle.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/handle.c * PURPOSE: Generic Executive Handle Tables - * + * * PROGRAMMERS: Thomas Weidenmueller * * TODO: @@ -95,14 +95,14 @@ PHANDLE_TABLE ExCreateHandleTable(IN PEPROCESS QuotaProcess OPTIONAL) { PHANDLE_TABLE HandleTable; - + PAGED_CODE(); - + if(!ExpInitialized) { KEBUGCHECK(0); } - + if(QuotaProcess != NULL) { /* FIXME - Charge process quota before allocating the handle table! */ @@ -154,7 +154,7 @@ ExCreateHandleTable(IN PEPROCESS QuotaProcess OPTIONAL) { /* FIXME - return the quota to the process */ } - + return HandleTable; } @@ -215,29 +215,29 @@ ExDestroyHandleTable(IN PHANDLE_TABLE HandleTable, { PHANDLE_TABLE_ENTRY **tlp, **lasttlp, *mlp, *lastmlp; PEPROCESS QuotaProcess; - + PAGED_CODE(); - + ASSERT(HandleTable); - + KeEnterCriticalRegion(); - + /* ensure there's no other operations going by acquiring an exclusive lock */ ExAcquireHandleTableLockExclusive(HandleTable); - + ASSERT(!(HandleTable->Flags & EX_HANDLE_TABLE_CLOSING)); - + HandleTable->Flags |= EX_HANDLE_TABLE_CLOSING; - + KePulseEvent(&HandleTable->HandleContentionEvent, EVENT_INCREMENT, FALSE); - + /* remove the handle table from the global handle table list */ ExAcquireHandleTableListLock(); RemoveEntryList(&HandleTable->HandleTableList); ExReleaseHandleTableListLock(); - + /* call the callback function to cleanup the objects associated with the handle table */ if(DestroyHandleCallback != NULL) @@ -255,7 +255,7 @@ ExDestroyHandleTable(IN PHANDLE_TABLE HandleTable, if((*mlp) != NULL) { PHANDLE_TABLE_ENTRY curee, laste; - + for(curee = *mlp, laste = *mlp + N_SUBHANDLE_ENTRIES; curee != laste; curee++) @@ -271,9 +271,9 @@ ExDestroyHandleTable(IN PHANDLE_TABLE HandleTable, } } } - + QuotaProcess = HandleTable->QuotaProcess; - + /* free the tables */ for(tlp = HandleTable->Table, lasttlp = HandleTable->Table + N_TOPLEVEL_POINTERS; tlp != lasttlp; @@ -288,7 +288,7 @@ ExDestroyHandleTable(IN PHANDLE_TABLE HandleTable, if((*mlp) != NULL) { ExFreePool(*mlp); - + if(QuotaProcess != NULL) { /* FIXME - return the quota to the process */ @@ -297,22 +297,22 @@ ExDestroyHandleTable(IN PHANDLE_TABLE HandleTable, } ExFreePool(*tlp); - + if(QuotaProcess != NULL) { /* FIXME - return the quota to the process */ } } } - + ExReleaseHandleTableLock(HandleTable); - + KeLeaveCriticalRegion(); - + /* free the handle table */ ExDeleteResource(&HandleTable->HandleTableLock); ExFreePool(HandleTable); - + if(QuotaProcess != NULL) { /* FIXME - return the quota to the process */ @@ -326,9 +326,9 @@ ExDupHandleTable(IN PEPROCESS QuotaProcess OPTIONAL, IN PHANDLE_TABLE SourceHandleTable) { PHANDLE_TABLE HandleTable; - + PAGED_CODE(); - + ASSERT(SourceHandleTable); HandleTable = ExCreateHandleTable(QuotaProcess); @@ -336,12 +336,12 @@ ExDupHandleTable(IN PEPROCESS QuotaProcess OPTIONAL, { PHANDLE_TABLE_ENTRY **tlp, **srctlp, **etlp, *mlp, *srcmlp, *emlp, stbl, srcstbl, estbl; LONG tli, mli, eli; - + tli = mli = eli = 0; - + /* make sure the other handle table isn't being changed during the duplication */ ExAcquireHandleTableLockShared(SourceHandleTable); - + /* allocate enough tables */ etlp = SourceHandleTable->Table + N_TOPLEVEL_POINTERS; for(srctlp = SourceHandleTable->Table, tlp = HandleTable->Table; @@ -355,16 +355,16 @@ ExDupHandleTable(IN PEPROCESS QuotaProcess OPTIONAL, { /* FIXME - Charge process quota before allocating the handle table! */ } - + *tlp = ExAllocatePoolWithTag(PagedPool, N_MIDDLELEVEL_POINTERS * sizeof(PHANDLE_TABLE_ENTRY), TAG('E', 'x', 'H', 't')); if(*tlp != NULL) { RtlZeroMemory(*tlp, N_MIDDLELEVEL_POINTERS * sizeof(PHANDLE_TABLE_ENTRY)); - + KeMemoryBarrier(); - + emlp = *srctlp + N_MIDDLELEVEL_POINTERS; for(srcmlp = *srctlp, mlp = *tlp; srcmlp != emlp; @@ -402,7 +402,7 @@ freehandletable: DPRINT1("Failed to duplicate handle table 0x%x\n", SourceHandleTable); ExReleaseHandleTableLock(SourceHandleTable); - + ExDestroyHandleTable(HandleTable, NULL, NULL); @@ -481,11 +481,11 @@ freehandletable: } } } - + /* release the source handle table */ ExReleaseHandleTableLock(SourceHandleTable); } - + return HandleTable; } @@ -494,39 +494,39 @@ ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable, OUT PLONG Handle) { PHANDLE_TABLE_ENTRY Entry = NULL; - + PAGED_CODE(); - + ASSERT(HandleTable); ASSERT(Handle); ASSERT(KeGetCurrentThread() != NULL); - + DPRINT("HT[0x%x]: HandleCount: %d\n", HandleTable, HandleTable->HandleCount); - + if(HandleTable->HandleCount < EX_MAX_HANDLES) { ULONG tli, mli, eli; - + if(HandleTable->FirstFreeTableEntry != -1) { /* there's a free handle entry we can just grab and use */ tli = TLI_FROM_HANDLE(HandleTable->FirstFreeTableEntry); mli = MLI_FROM_HANDLE(HandleTable->FirstFreeTableEntry); eli = ELI_FROM_HANDLE(HandleTable->FirstFreeTableEntry); - + /* the pointer should be valid in any way!!! */ ASSERT(HandleTable->Table[tli]); ASSERT(HandleTable->Table[tli][mli]); - + Entry = &HandleTable->Table[tli][mli][eli]; - + *Handle = HandleTable->FirstFreeTableEntry; - + /* save the index to the next free handle (if available) */ HandleTable->FirstFreeTableEntry = Entry->u2.NextFreeTableEntry; Entry->u2.NextFreeTableEntry = 0; Entry->u1.Object = NULL; - + HandleTable->HandleCount++; } else @@ -537,7 +537,7 @@ ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable, BOOLEAN AllocatedMtbl; ASSERT(HandleTable->NextIndexNeedingPool <= N_MAX_HANDLE); - + /* the index of the next table to be allocated was saved in NextIndexNeedingPool the last time a handle entry was allocated and the subhandle entry list was full. the subhandle entry index of @@ -550,7 +550,7 @@ ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable, ASSERT(ELI_FROM_HANDLE(HandleTable->NextIndexNeedingPool) == 0); DPRINT("HandleTable->Table[%d] == 0x%x\n", tli, HandleTable->Table[tli]); - + /* allocate a middle level entry list if required */ nmtbl = HandleTable->Table[tli]; if(nmtbl == NULL) @@ -559,7 +559,7 @@ ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable, { /* FIXME - Charge process quota before allocating the handle table! */ } - + nmtbl = ExAllocatePoolWithTag(PagedPool, N_MIDDLELEVEL_POINTERS * sizeof(PHANDLE_TABLE_ENTRY), TAG('E', 'x', 'H', 't')); @@ -569,16 +569,16 @@ ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable, { /* FIXME - return the quota to the process */ } - + return NULL; } - + /* clear the middle level entry list */ RtlZeroMemory(nmtbl, N_MIDDLELEVEL_POINTERS * sizeof(PHANDLE_TABLE_ENTRY)); - + /* make sure the table was zeroed before we set one item */ KeMemoryBarrier(); - + /* note, don't set the the pointer in the top level list yet because we might screw up lookups if allocating a subhandle entry table failed and this newly allocated table might get freed again */ @@ -587,7 +587,7 @@ ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable, else { AllocatedMtbl = FALSE; - + /* allocate a subhandle entry table in any case! */ ASSERT(nmtbl[mli] == NULL); } @@ -608,31 +608,31 @@ ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable, { /* FIXME - Return process quota charged */ } - + /* free the middle level entry list, if allocated, because it's empty and unused */ if(AllocatedMtbl) { ExFreePool(nmtbl); - + if(HandleTable->QuotaProcess != NULL) { /* FIXME - Return process quota charged */ } } - + return NULL; } - + /* let's just use the very first entry */ Entry = ntbl; Entry->u1.ObAttributes = EX_HANDLE_ENTRY_LOCKED; Entry->u2.NextFreeTableEntry = 0; - + *Handle = HandleTable->NextIndexNeedingPool; - + HandleTable->HandleCount++; - + /* set the FirstFreeTableEntry member to the second entry and chain the free entries */ HandleTable->FirstFreeTableEntry = HandleTable->NextIndexNeedingPool + 1; @@ -652,7 +652,7 @@ ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable, { InterlockedExchangePointer(&HandleTable->Table[tli], nmtbl); } - + /* increment the NextIndexNeedingPool to the next index where we need to allocate new memory */ HandleTable->NextIndexNeedingPool += N_SUBHANDLE_ENTRIES; @@ -662,7 +662,7 @@ ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable, { DPRINT1("Can't allocate any more handles in handle table 0x%x!\n", HandleTable); } - + return Entry; } @@ -672,20 +672,20 @@ ExpFreeHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN LONG Handle) { PAGED_CODE(); - + ASSERT(HandleTable); ASSERT(Entry); ASSERT(IS_VALID_EX_HANDLE(Handle)); - + DPRINT("ExpFreeHandleTableEntry HT:0x%x Entry:0x%x\n", HandleTable, Entry); - + /* automatically unlock the entry if currently locked. We however don't notify anyone who waited on the handle because we're holding an exclusive lock after all and these locks will fail then */ InterlockedExchangePointer(&Entry->u1.Object, NULL); Entry->u2.NextFreeTableEntry = HandleTable->FirstFreeTableEntry; HandleTable->FirstFreeTableEntry = Handle; - + HandleTable->HandleCount--; } @@ -694,20 +694,20 @@ ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN LONG Handle) { PHANDLE_TABLE_ENTRY Entry = NULL; - + PAGED_CODE(); - + ASSERT(HandleTable); - + if(IS_VALID_EX_HANDLE(Handle)) { ULONG tli, mli, eli; PHANDLE_TABLE_ENTRY *mlp; - + tli = TLI_FROM_HANDLE(Handle); mli = MLI_FROM_HANDLE(Handle); eli = ELI_FROM_HANDLE(Handle); - + mlp = HandleTable->Table[tli]; if(Handle < HandleTable->NextIndexNeedingPool && mlp != NULL && mlp[mli] != NULL && mlp[mli][eli].u1.Object != NULL) @@ -720,7 +720,7 @@ ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, { DPRINT("Looking up invalid handle 0x%x\n", Handle); } - + return Entry; } @@ -731,22 +731,22 @@ ExLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, ULONG_PTR Current, New; PAGED_CODE(); - + DPRINT("Entering handle table entry 0x%x lock...\n", Entry); - + ASSERT(HandleTable); ASSERT(Entry); - + for(;;) { Current = (volatile ULONG_PTR)Entry->u1.Object; - + if(!Current || (HandleTable->Flags & EX_HANDLE_TABLE_CLOSING)) { DPRINT("Attempted to lock empty handle table entry 0x%x or handle table shut down\n", Entry); break; } - + if(!(Current & EX_HANDLE_ENTRY_LOCKED)) { New = Current | EX_HANDLE_ENTRY_LOCKED; @@ -779,20 +779,20 @@ ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY Entry) { ULONG_PTR Current, New; - + PAGED_CODE(); - + ASSERT(HandleTable); ASSERT(Entry); - + DPRINT("ExUnlockHandleTableEntry HT:0x%x Entry:0x%x\n", HandleTable, Entry); - + Current = (volatile ULONG_PTR)Entry->u1.Object; ASSERT(Current & EX_HANDLE_ENTRY_LOCKED); - + New = Current & ~EX_HANDLE_ENTRY_LOCKED; - + InterlockedExchangePointer(&Entry->u1.Object, (PVOID)New); @@ -809,26 +809,26 @@ ExCreateHandle(IN PHANDLE_TABLE HandleTable, { PHANDLE_TABLE_ENTRY NewHandleTableEntry; LONG Handle = EX_INVALID_HANDLE; - + PAGED_CODE(); - + ASSERT(HandleTable); ASSERT(Entry); - + /* The highest bit in Entry->u1.Object has to be 1 so we make sure it's a pointer to kmode memory. It will cleared though because it also indicates the lock */ ASSERT((ULONG_PTR)Entry->u1.Object & EX_HANDLE_ENTRY_LOCKED); - + KeEnterCriticalRegion(); ExAcquireHandleTableLockExclusive(HandleTable); - + NewHandleTableEntry = ExpAllocateHandleTableEntry(HandleTable, &Handle); if(NewHandleTableEntry != NULL) { *NewHandleTableEntry = *Entry; - + ExUnlockHandleTableEntry(HandleTable, NewHandleTableEntry); } @@ -845,17 +845,17 @@ ExDestroyHandle(IN PHANDLE_TABLE HandleTable, { PHANDLE_TABLE_ENTRY HandleTableEntry; BOOLEAN Ret = FALSE; - + PAGED_CODE(); - + ASSERT(HandleTable); - + KeEnterCriticalRegion(); ExAcquireHandleTableLockExclusive(HandleTable); - + HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, Handle); - + if(HandleTableEntry != NULL && ExLockHandleTableEntry(HandleTable, HandleTableEntry)) { /* free and automatically unlock the handle. However we don't need to pulse @@ -865,10 +865,10 @@ ExDestroyHandle(IN PHANDLE_TABLE HandleTable, Handle); Ret = TRUE; } - + ExReleaseHandleTableLock(HandleTable); KeLeaveCriticalRegion(); - + return Ret; } @@ -881,10 +881,10 @@ ExDestroyHandleByEntry(IN PHANDLE_TABLE HandleTable, ASSERT(HandleTable); ASSERT(Entry); - + /* This routine requires the entry to be locked */ ASSERT((ULONG_PTR)Entry->u1.Object & EX_HANDLE_ENTRY_LOCKED); - + DPRINT("DestroyHandleByEntry HT:0x%x Entry:0x%x\n", HandleTable, Entry); KeEnterCriticalRegion(); @@ -909,7 +909,7 @@ ExMapHandleToPointer(IN PHANDLE_TABLE HandleTable, PAGED_CODE(); ASSERT(HandleTable); - + HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, Handle); if (HandleTableEntry != NULL && ExLockHandleTableEntry(HandleTable, HandleTableEntry)) @@ -917,7 +917,7 @@ ExMapHandleToPointer(IN PHANDLE_TABLE HandleTable, DPRINT("ExMapHandleToPointer HT:0x%x Entry:0x%x locked\n", HandleTable, HandleTableEntry); return HandleTableEntry; } - + return NULL; } @@ -936,7 +936,7 @@ ExChangeHandle(IN PHANDLE_TABLE HandleTable, ASSERT(ChangeHandleCallback); KeEnterCriticalRegion(); - + HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, Handle); @@ -949,7 +949,7 @@ ExChangeHandle(IN PHANDLE_TABLE HandleTable, ExUnlockHandleTableEntry(HandleTable, HandleTableEntry); } - + KeLeaveCriticalRegion(); return Ret; diff --git a/reactos/ntoskrnl/ex/i386/interlck.c b/reactos/ntoskrnl/ex/i386/interlck.c index 3704c365efc..8bcf00e4fa4 100644 --- a/reactos/ntoskrnl/ex/i386/interlck.c +++ b/reactos/ntoskrnl/ex/i386/interlck.c @@ -1,5 +1,5 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/i386/interlck.c @@ -27,7 +27,7 @@ #ifdef CONFIG_SMP #define LOCK lock #else -#define LOCK +#define LOCK #endif #endif @@ -248,7 +248,7 @@ Exi386InterlockedExchangeUlong(IN PULONG Target, LONG FASTCALL InterlockedIncrement(PLONG Addend); /* - * FUNCTION: Increments a caller supplied variable of type LONG as an + * FUNCTION: Increments a caller supplied variable of type LONG as an * atomic operation * ARGUMENTS: * Addend = Points to a variable whose value is to be increment diff --git a/reactos/ntoskrnl/ex/init.c b/reactos/ntoskrnl/ex/init.c index a5bc7acccdd..11124e10acd 100644 --- a/reactos/ntoskrnl/ex/init.c +++ b/reactos/ntoskrnl/ex/init.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/init.c * PURPOSE: Executive initalization - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) - Added ExpInitializeExecutive * and optimized/cleaned it. * Eric Kohl (ekohl@abo.rhein-zeitung.de) @@ -34,8 +34,8 @@ VOID PspPostInitSystemProcess(VOID); /* FUNCTIONS ****************************************************************/ -static -VOID +static +VOID INIT_FUNCTION InitSystemSharedUserPage (PCSZ ParameterLine) { @@ -61,13 +61,13 @@ InitSystemSharedUserPage (PCSZ ParameterLine) * There is NO need to do this again. */ Ki386SetProcessorFeatures(); - + /* Set the Version Data */ SharedUserData->NtProductType = NtProductWinNt; SharedUserData->ProductTypeIsValid = TRUE; SharedUserData->NtMajorVersion = 5; SharedUserData->NtMinorVersion = 0; - + /* * Retrieve the current dos system path * (e.g.: C:\reactos) from the given arc path @@ -88,18 +88,18 @@ InitSystemSharedUserPage (PCSZ ParameterLine) /* Extract path */ p = strchr (ParamBuffer, '\\'); if (p) { - + DPRINT("Boot path: %s\n", p); RtlCreateUnicodeStringFromAsciiz (&BootPath, p); *p = 0; - + } else { - + DPRINT("Boot path: %s\n", "\\"); RtlCreateUnicodeStringFromAsciiz (&BootPath, "\\"); } DPRINT("Arc name: %s\n", ParamBuffer); - + /* Only ARC Name left - Build full ARC Name */ ArcNameBuffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR)); swprintf (ArcNameBuffer, L"\\ArcName\\%S", ParamBuffer); @@ -123,29 +123,29 @@ InitSystemSharedUserPage (PCSZ ParameterLine) Status = NtOpenSymbolicLinkObject(&Handle, SYMBOLIC_LINK_ALL_ACCESS, &ObjectAttributes); - + /* Free the String */ ExFreePool(ArcName.Buffer); - + /* Check for Success */ if (!NT_SUCCESS(Status)) { - + /* Free the Strings */ RtlFreeUnicodeString(&BootPath); ExFreePool(ArcDeviceName.Buffer); CPRINT("NtOpenSymbolicLinkObject() failed (Status %x)\n", Status); KEBUGCHECK(0); } - + /* Query the Link */ Status = NtQuerySymbolicLinkObject(Handle, &ArcDeviceName, &Length); NtClose (Handle); - + /* Check for Success */ if (!NT_SUCCESS(Status)) { - + /* Free the Strings */ RtlFreeUnicodeString(&BootPath); ExFreePool(ArcDeviceName.Buffer); @@ -161,12 +161,12 @@ InitSystemSharedUserPage (PCSZ ParameterLine) /* Loop Drives */ for (i = 0; i < 26; i++) { - + /* Setup the String */ swprintf (DriveNameBuffer, L"\\??\\%C:", 'A' + i); RtlInitUnicodeString(&DriveName, DriveNameBuffer); - + /* Open the Symbolic Link */ InitializeObjectAttributes(&ObjectAttributes, &DriveName, @@ -176,18 +176,18 @@ InitSystemSharedUserPage (PCSZ ParameterLine) Status = NtOpenSymbolicLinkObject(&Handle, SYMBOLIC_LINK_ALL_ACCESS, &ObjectAttributes); - + /* If it failed, skip to the next drive */ if (!NT_SUCCESS(Status)) { DPRINT("Failed to open link %wZ\n", &DriveName); continue; } - + /* Query it */ Status = NtQuerySymbolicLinkObject(Handle, &DriveDeviceName, &Length); - + /* If it failed, skip to the next drive */ if (!NT_SUCCESS(Status)) { DPRINT("Failed to query link %wZ\n", &DriveName); @@ -197,7 +197,7 @@ InitSystemSharedUserPage (PCSZ ParameterLine) /* See if we've found the boot drive */ if (!RtlCompareUnicodeString (&ArcDeviceName, &DriveDeviceName, FALSE)) { - + DPRINT("DOS Boot path: %c:%wZ\n", 'A' + i, &BootPath); swprintf(SharedUserData->NtSystemRoot, L"%C:%wZ", 'A' + i, &BootPath); BootDriveFound = TRUE; @@ -206,7 +206,7 @@ InitSystemSharedUserPage (PCSZ ParameterLine) /* Close this Link */ NtClose (Handle); } - + /* Free all the Strings we have in memory */ RtlFreeUnicodeString (&BootPath); ExFreePool(DriveDeviceName.Buffer); @@ -214,7 +214,7 @@ InitSystemSharedUserPage (PCSZ ParameterLine) /* Make sure we found the Boot Drive */ if (BootDriveFound == FALSE) { - + DbgPrint("No system drive found!\n"); KEBUGCHECK (NO_BOOT_DEVICE); } @@ -247,7 +247,7 @@ ExecuteRuntimeAsserts(VOID) ASSERT(FIELD_OFFSET(KV86M_TRAP_FRAME, orig_ebp) == TF_ORIG_EBP); ASSERT(FIELD_OFFSET(KPCR, Tib.ExceptionList) == KPCR_EXCEPTION_LIST); ASSERT(FIELD_OFFSET(KPCR, Self) == KPCR_SELF); - ASSERT(FIELD_OFFSET(KPCR, PrcbData) + FIELD_OFFSET(KPRCB, CurrentThread) == KPCR_CURRENT_THREAD); + ASSERT(FIELD_OFFSET(KPCR, PrcbData) + FIELD_OFFSET(KPRCB, CurrentThread) == KPCR_CURRENT_THREAD); ASSERT(FIELD_OFFSET(KPCR, PrcbData) + FIELD_OFFSET(KPRCB, NpxThread) == KPCR_NPX_THREAD); ASSERT(FIELD_OFFSET(KTSS, Esp0) == KTSS_ESP0); ASSERT(FIELD_OFFSET(KTSS, Eflags) == KTSS_EFLAGS); @@ -262,115 +262,115 @@ ParseAndCacheLoadedModules(PBOOLEAN SetupBoot) { ULONG i; PCHAR Name; - + /* Loop the Module List and get the modules we want */ for (i = 1; i < KeLoaderBlock.ModsCount; i++) { - + /* Get the Name of this Module */ if (!(Name = strrchr((PCHAR)KeLoaderModules[i].String, '\\'))) { - + /* Save the name */ Name = (PCHAR)KeLoaderModules[i].String; - + } else { - + /* No name, skip */ Name++; } - + /* Now check for any of the modules we will need later */ if (!_stricmp(Name, "ansi.nls")) { - + CachedModules[AnsiCodepage] = &KeLoaderModules[i]; - + } else if (!_stricmp(Name, "oem.nls")) { - + CachedModules[OemCodepage] = &KeLoaderModules[i]; - + } else if (!_stricmp(Name, "casemap.nls")) { - + CachedModules[UnicodeCasemap] = &KeLoaderModules[i]; - + } else if (!_stricmp(Name, "system") || !_stricmp(Name, "system.hiv")) { - + CachedModules[SystemRegistry] = &KeLoaderModules[i]; *SetupBoot = FALSE; - + } else if (!_stricmp(Name, "hardware") || !_stricmp(Name, "hardware.hiv")) { - + CachedModules[HardwareRegistry] = &KeLoaderModules[i]; } - } + } } inline VOID STDCALL -ParseCommandLine(PULONG MaxMem, - PBOOLEAN NoGuiBoot, - PBOOLEAN BootLog, +ParseCommandLine(PULONG MaxMem, + PBOOLEAN NoGuiBoot, + PBOOLEAN BootLog, PBOOLEAN ForceAcpiDisable) { - PCHAR p1, p2; - + PCHAR p1, p2; + p1 = (PCHAR)KeLoaderBlock.CommandLine; while(*p1 && (p2 = strchr(p1, '/'))) { - + p2++; if (!_strnicmp(p2, "MAXMEM", 6)) { - + p2 += 6; while (isspace(*p2)) p2++; - + if (*p2 == '=') { - + p2++; - + while(isspace(*p2)) p2++; - + if (isdigit(*p2)) { while (isdigit(*p2)) { *MaxMem = *MaxMem * 10 + *p2 - '0'; p2++; - } + } break; } } } else if (!_strnicmp(p2, "NOGUIBOOT", 9)) { - + p2 += 9; *NoGuiBoot = TRUE; - + } else if (!_strnicmp(p2, "CRASHDUMP", 9)) { - + p2 += 9; if (*p2 == ':') { - + p2++; if (!_strnicmp(p2, "FULL", 4)) { - + MmCoreDumpType = MM_CORE_DUMP_TYPE_FULL; - + } else { - + MmCoreDumpType = MM_CORE_DUMP_TYPE_NONE; } } } else if (!_strnicmp(p2, "BOOTLOG", 7)) { - + p2 += 7; *BootLog = TRUE; } else if (!_strnicmp(p2, "NOACPI", 6)) { - + p2 += 6; *ForceAcpiDisable = TRUE; } - + p1 = p2; } } -VOID +VOID INIT_FUNCTION STDCALL ExpInitializeExecutive(VOID) @@ -391,19 +391,19 @@ ExpInitializeExecutive(VOID) /* Check if the structures match the ASM offset constants */ ExecuteRuntimeAsserts(); - + /* Sets up the Text Sections of the Kernel and HAL for debugging */ LdrInit1(); - + /* Lower the IRQL to Dispatch Level */ KeLowerIrql(DISPATCH_LEVEL); - + /* Sets up the VDM Data */ NtEarlyInitVdm(); /* Parse Command Line Settings */ ParseCommandLine(&MaxMem, &NoGuiBoot, &BootLog, &ForceAcpiDisable); - + /* Initialize Kernel Memory Address Space */ MmInit1(FirstKrnlPhysAddr, LastKrnlPhysAddr, @@ -414,30 +414,30 @@ ExpInitializeExecutive(VOID) /* Parse the Loaded Modules (by FreeLoader) and cache the ones we'll need */ ParseAndCacheLoadedModules(&SetupBoot); - + /* Initialize the kernel debugger parameters */ KdInitSystem(0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); - + /* Initialize the Dispatcher, Clock and Bug Check Mechanisms. */ KeInit2(); /* Bring back the IRQL to Passive */ KeLowerIrql(PASSIVE_LEVEL); - + /* Initialize Profiling */ InitializeListHead(&KiProfileListHead); InitializeListHead(&KiProfileSourceListHead); KeInitializeSpinLock(&KiProfileLock); - + /* Load basic Security for other Managers */ if (!SeInit1()) KEBUGCHECK(SECURITY_INITIALIZATION_FAILED); /* Create the Basic Object Manager Types to allow new Object Types */ ObInit(); - + /* Initialize Lookaside Lists */ ExInit2(); - + /* Set up Region Maps, Sections and the Paging File */ MmInit2(); @@ -446,7 +446,7 @@ ExpInitializeExecutive(VOID) /* Set 1 CPU for now, we'll increment this later */ KeNumberProcessors = 1; - + /* Initalize the Process Manager */ PiInitProcessManager(); @@ -455,7 +455,7 @@ ExpInitializeExecutive(VOID) /* Initialize all processors */ while (!HalAllProcessorsStarted()) { - + PVOID ProcessorStack; /* Set up the Kernel and Process Manager for this CPU */ @@ -472,10 +472,10 @@ ExpInitializeExecutive(VOID) /* Do Phase 1 HAL Initalization */ HalInitSystem(1, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); - + /* Initialize Basic System Objects and Worker Threads */ ExInit3(); - + /* Create the system handle table, assign it to the system process, create the client id table and assign a PID for the system process. This needs to be done before the worker threads are initialized so the system @@ -484,33 +484,33 @@ ExpInitializeExecutive(VOID) /* initialize the worker threads */ ExpInitializeWorkerThreads(); - + /* initialize callbacks */ ExpInitializeCallbacks(); - + /* Call KD Providers at Phase 1 */ KdInitSystem(1, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); - + /* Initialize I/O Objects, Filesystems, Error Logging and Shutdown */ IoInit(); - + /* TBD */ PoInit((PLOADER_PARAMETER_BLOCK)&KeLoaderBlock, ForceAcpiDisable); - + /* Initialize the Registry (Hives are NOT yet loaded!) */ CmInitializeRegistry(); - + /* Unmap Low memory, initialize the Page Zeroing and the Balancer Thread */ MmInit3(); - + /* Initialize Cache Views */ CcInit(); - + /* Initialize File Locking */ FsRtlpInitFileLockingImplementation(); /* Report all resources used by hal */ - HalReportResourceUsage(); + HalReportResourceUsage(); /* Clear the screen to blue */ HalInitSystem(2, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); @@ -522,7 +522,7 @@ ExpInitializeExecutive(VOID) HalDisplayString("\n\nReactOS is free software, covered by the GNU General " "Public License, and you\n"); HalDisplayString("are welcome to change it and/or distribute copies of it " - "under certain\n"); + "under certain\n"); HalDisplayString("conditions. There is absolutely no warranty for " "ReactOS.\n\n"); @@ -541,10 +541,10 @@ ExpInitializeExecutive(VOID) /* Import and Load Registry Hives */ CmInitHives(SetupBoot); - + /* Initialize the time zone information from the registry */ ExpInitTimeZoneInfo(); - + /* Enter the kernel debugger before starting up the boot drivers */ KdbEnter(); @@ -553,16 +553,16 @@ ExpInitializeExecutive(VOID) /* Display the boot screen image if not disabled */ if (!NoGuiBoot) InbvEnableBootDriver(TRUE); - + /* Create ARC Names, SystemRoot SymLink, Load Drivers and Assign Letters */ IoInit3(); - + /* Load the System DLL and its Entrypoints */ LdrpInitializeSystemDll(); - + /* Initialize the Default Locale */ PiInitDefaultLocale(); - + /* Initialize shared user page. Set dos system path, dos device map, etc. */ InitSystemSharedUserPage ((PCHAR)KeLoaderBlock.CommandLine); @@ -578,10 +578,10 @@ ExpInitializeExecutive(VOID) &ObjectAttributes, SynchronizationEvent, FALSE); - + /* Check for Success */ if (!NT_SUCCESS(Status)) { - + DPRINT1("Failed to create 'ReactOSInitDone' event (Status 0x%x)\n", Status); InitDoneEventHandle = INVALID_HANDLE_VALUE; } @@ -589,10 +589,10 @@ ExpInitializeExecutive(VOID) /* Launch initial process */ Status = LdrLoadInitialProcess(&ProcessHandle, &ThreadHandle); - + /* Check for success, Bugcheck if we failed */ if (!NT_SUCCESS(Status)) { - + KEBUGCHECKEX(SESSION4_INITIALIZATION_FAILED, Status, 0, 0, 0); } @@ -613,15 +613,15 @@ ExpInitializeExecutive(VOID) FALSE, &Timeout); if (!NT_SUCCESS(Status)) { - + DPRINT1("NtWaitForMultipleObjects failed with status 0x%x!\n", Status); - + } else if (Status == STATUS_TIMEOUT) { - + DPRINT1("WARNING: System not initialized after 120 seconds.\n"); - + } else if (Status == STATUS_WAIT_0 + 1) { - + /* Crash the system if the initial process was terminated. */ KEBUGCHECKEX(SESSION5_INITIALIZATION_FAILED, Status, 0, 0, 0); } @@ -632,9 +632,9 @@ ExpInitializeExecutive(VOID) /* Signal the Event and close the handle */ ZwSetEvent(InitDoneEventHandle, NULL); ZwClose(InitDoneEventHandle); - + } else { - + /* On failure to create 'ReactOSInitDone' event, go to text mode ASAP */ if (!NoGuiBoot) InbvEnableBootDriver(FALSE); @@ -643,11 +643,11 @@ ExpInitializeExecutive(VOID) Status = ZwWaitForSingleObject(ProcessHandle, FALSE, &Timeout); - + /* Check for timeout, crash if the initial process didn't initalize */ if (Status != STATUS_TIMEOUT) KEBUGCHECKEX(SESSION5_INITIALIZATION_FAILED, Status, 1, 0, 0); } - + /* Enable the Clock, close remaining handles */ KiTimerSystemAuditing = 1; ZwClose(ThreadHandle); diff --git a/reactos/ntoskrnl/ex/interlck.c b/reactos/ntoskrnl/ex/interlck.c index e7863fd1ef5..49edcde2d22 100644 --- a/reactos/ntoskrnl/ex/interlck.c +++ b/reactos/ntoskrnl/ex/interlck.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/interlck.c * PURPOSE: Implements interlocked functions - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -80,16 +80,16 @@ ExInterlockedAddUlong (PULONG Addend, /* * ExInterlockedAddUlong adds an unsigned long value to a given unsigned * integer as an atomic operation. - * + * * ADDEND = Points to an unsigned long integer whose value is to be adjusted * by the Increment value. - * + * * INCREMENT = Is an unsigned long integer to be added. - * + * * LOCK = Points to a spinlock to be used to synchronize access to ADDEND. - * - * Returns: - * + * + * Returns: + * * The original value of the unsigned integer pointed to by ADDEND. */ { @@ -115,15 +115,15 @@ ExInterlockedAddLargeInteger (PLARGE_INTEGER Addend, PKSPIN_LOCK Lock) /* * Adds two large integer values as an atomic operation. - * + * * ADDEND = Pointer to a large integer value that will have INCREMENT added. - * + * * INCREMENT = Value to be added. - * + * * LOCK = Spinlock used to synchronize access to ADDEND. - * + * * Returns: - * + * * The original value of the large integer pointed to by ADDEND. */ { @@ -218,16 +218,16 @@ ExfInterlockedAddUlong(PULONG Addend, /* * ExInterlockedAddUlong adds an unsigned long value to a given unsigned * integer as an atomic operation. - * + * * ADDEND = Points to an unsigned long integer whose value is to be adjusted * by the Increment value. - * + * * INCREMENT = Is an unsigned long integer to be added. - * + * * LOCK = Points to a spinlock to be used to synchronize access to ADDEND. - * - * Returns: - * + * + * Returns: + * * The original value of the unsigned integer pointed to by ADDEND. */ { diff --git a/reactos/ntoskrnl/ex/list.c b/reactos/ntoskrnl/ex/list.c index 24746a0794f..e77e4a8f7d1 100644 --- a/reactos/ntoskrnl/ex/list.c +++ b/reactos/ntoskrnl/ex/list.c @@ -446,7 +446,7 @@ InterlockedPopEntrySList(IN PSLIST_HEADER ListHead) { SLIST_HEADER newslh, oldslh; PSLIST_ENTRY le; - + do { oldslh = *(volatile SLIST_HEADER *)ListHead; @@ -476,9 +476,9 @@ InterlockedPushEntrySList(IN PSLIST_HEADER ListHead, IN PSLIST_ENTRY ListEntry) { SLIST_HEADER newslh, oldslh; - + newslh.Next.Next = ListEntry; - + do { oldslh = *(volatile SLIST_HEADER *)ListHead; diff --git a/reactos/ntoskrnl/ex/lookas.c b/reactos/ntoskrnl/ex/lookas.c index 1bd2a64050e..a65d99d2e1d 100644 --- a/reactos/ntoskrnl/ex/lookas.c +++ b/reactos/ntoskrnl/ex/lookas.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/lookas.c * PURPOSE: Lookaside lists - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) * Casper S. Hornstrup (chorns@users.sourceforge.net) */ diff --git a/reactos/ntoskrnl/ex/mutant.c b/reactos/ntoskrnl/ex/mutant.c index 700c0c2c404..5431b11a32d 100644 --- a/reactos/ntoskrnl/ex/mutant.c +++ b/reactos/ntoskrnl/ex/mutant.c @@ -1,9 +1,9 @@ -/* +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/mutant.c * PURPOSE: Executive Management of Mutants - * + * * PROGRAMMERS: Alex Ionescu - Fix tab/space mismatching, tiny fixes to query function and * add more debug output. * David Welch (welch@cwcom.net) @@ -24,14 +24,14 @@ static GENERIC_MAPPING ExpMutantMapping = { MUTANT_ALL_ACCESS}; static const INFORMATION_CLASS_INFO ExMutantInfoClass[] = { - + /* MutantBasicInformation */ ICI_SQ_SAME( sizeof(MUTANT_BASIC_INFORMATION), sizeof(ULONG), ICIF_QUERY ), }; /* FUNCTIONS *****************************************************************/ -VOID +VOID STDCALL ExpDeleteMutant(PVOID ObjectBody) { @@ -45,7 +45,7 @@ ExpDeleteMutant(PVOID ObjectBody) FALSE); } -VOID +VOID INIT_FUNCTION ExpInitializeMutantImplementation(VOID) { @@ -79,7 +79,7 @@ ExpInitializeMutantImplementation(VOID) /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtCreateMutant(OUT PHANDLE MutantHandle, IN ACCESS_MASK DesiredAccess, @@ -90,27 +90,27 @@ NtCreateMutant(OUT PHANDLE MutantHandle, HANDLE hMutant; PKMUTANT Mutant; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); DPRINT("NtCreateMutant(0x%x, 0x%x, 0x%x)\n", MutantHandle, DesiredAccess, ObjectAttributes); - + /* Check Output Safety */ if(PreviousMode == UserMode) { - + _SEH_TRY { - + ProbeForWrite(MutantHandle, sizeof(HANDLE), sizeof(ULONG)); } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; if(!NT_SUCCESS(Status)) return Status; } - + /* Create the Mutant Object*/ Status = ObCreateObject(PreviousMode, ExMutantObjectType, @@ -121,10 +121,10 @@ NtCreateMutant(OUT PHANDLE MutantHandle, 0, 0, (PVOID*)&Mutant); - + /* Check for success */ if(NT_SUCCESS(Status)) { - + /* Initalize the Kernel Mutant */ DPRINT("Initializing the Mutant\n"); KeInitializeMutant(Mutant, InitialOwner); @@ -137,18 +137,18 @@ NtCreateMutant(OUT PHANDLE MutantHandle, NULL, &hMutant); ObDereferenceObject(Mutant); - + /* Check for success and return handle */ if(NT_SUCCESS(Status)) { - + _SEH_TRY { - + *MutantHandle = hMutant; - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } } @@ -160,7 +160,7 @@ NtCreateMutant(OUT PHANDLE MutantHandle, /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtOpenMutant(OUT PHANDLE MutantHandle, IN ACCESS_MASK DesiredAccess, @@ -169,27 +169,27 @@ NtOpenMutant(OUT PHANDLE MutantHandle, HANDLE hMutant; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); DPRINT("NtOpenMutant(0x%x, 0x%x, 0x%x)\n", MutantHandle, DesiredAccess, ObjectAttributes); /* Check Output Safety */ if(PreviousMode == UserMode) { - + _SEH_TRY { - + ProbeForWrite(MutantHandle, sizeof(HANDLE), sizeof(ULONG)); } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; - + if(!NT_SUCCESS(Status)) return Status; } - + /* Open the Object */ Status = ObOpenObjectByName(ObjectAttributes, ExMutantObjectType, @@ -201,15 +201,15 @@ NtOpenMutant(OUT PHANDLE MutantHandle, /* Check for success and return handle */ if(NT_SUCCESS(Status)) { - + _SEH_TRY { - + *MutantHandle = hMutant; - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } @@ -220,7 +220,7 @@ NtOpenMutant(OUT PHANDLE MutantHandle, /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtQueryMutant(IN HANDLE MutantHandle, IN MUTANT_INFORMATION_CLASS MutantInformationClass, @@ -232,9 +232,9 @@ NtQueryMutant(IN HANDLE MutantHandle, KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; PMUTANT_BASIC_INFORMATION BasicInfo = (PMUTANT_BASIC_INFORMATION)MutantInformation; - + PAGED_CODE(); - + /* Check buffers and parameters */ DefaultQueryInfoBufferCheck(MutantInformationClass, ExMutantInfoClass, @@ -244,7 +244,7 @@ NtQueryMutant(IN HANDLE MutantHandle, PreviousMode, &Status); if(!NT_SUCCESS(Status)) { - + DPRINT("NtQueryMutant() failed, Status: 0x%x\n", Status); return Status; } @@ -260,7 +260,7 @@ NtQueryMutant(IN HANDLE MutantHandle, if(NT_SUCCESS(Status)) { _SEH_TRY { - + /* Fill out the Basic Information Requested */ DPRINT("Returning Mutant Information\n"); BasicInfo->CurrentCount = KeReadStateMutant(Mutant); @@ -269,17 +269,17 @@ NtQueryMutant(IN HANDLE MutantHandle, /* Return the Result Length if requested */ if(ResultLength) *ResultLength = sizeof(MUTANT_BASIC_INFORMATION); - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; /* Release the Object */ ObDereferenceObject(Mutant); } - + /* Return Status */ return Status; } @@ -288,7 +288,7 @@ NtQueryMutant(IN HANDLE MutantHandle, /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtReleaseMutant(IN HANDLE MutantHandle, IN PLONG PreviousCount OPTIONAL) @@ -296,31 +296,31 @@ NtReleaseMutant(IN HANDLE MutantHandle, PKMUTANT Mutant; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); - - DPRINT("NtReleaseMutant(MutantHandle 0%x PreviousCount 0%x)\n", - MutantHandle, + + DPRINT("NtReleaseMutant(MutantHandle 0%x PreviousCount 0%x)\n", + MutantHandle, PreviousCount); /* Check Output Safety */ if(PreviousMode != KernelMode && PreviousCount) { - + _SEH_TRY { - + ProbeForWrite(PreviousCount, sizeof(LONG), sizeof(ULONG)); } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; - + if(!NT_SUCCESS(Status)) return Status; - } + } /* Open the Object */ Status = ObReferenceObjectByHandle(MutantHandle, @@ -329,12 +329,12 @@ NtReleaseMutant(IN HANDLE MutantHandle, PreviousMode, (PVOID*)&Mutant, NULL); - + /* Check for Success and release if such */ if(NT_SUCCESS(Status)) { - + LONG Prev = 0; - + /* release the mutant. doing so might raise an exception which we're required to catch! */ _SEH_TRY { @@ -346,7 +346,7 @@ NtReleaseMutant(IN HANDLE MutantHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + ObDereferenceObject(Mutant); if(NT_SUCCESS(Status)) { @@ -359,7 +359,7 @@ NtReleaseMutant(IN HANDLE MutantHandle, *PreviousCount = Prev; } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); } _SEH_END; diff --git a/reactos/ntoskrnl/ex/power.c b/reactos/ntoskrnl/ex/power.c index d68f98e11de..8e655fafdee 100644 --- a/reactos/ntoskrnl/ex/power.c +++ b/reactos/ntoskrnl/ex/power.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/power.c * PURPOSE: Power managment - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -39,7 +39,7 @@ KiHaltProcessorDpcRoutine(IN PKDPC Dpc, VOID STDCALL ShutdownThreadMain(PVOID Context) { - SHUTDOWN_ACTION Action = (SHUTDOWN_ACTION)Context; + SHUTDOWN_ACTION Action = (SHUTDOWN_ACTION)Context; LARGE_INTEGER Waittime; /* Run the thread on the boot processor */ @@ -51,7 +51,7 @@ ShutdownThreadMain(PVOID Context) PiShutdownProcessManager(); MiShutdownMemoryManager(); - + Waittime.QuadPart = (LONGLONG)-10000000; /* 1sec */ KeDelayExecutionThread(KernelMode, FALSE, &Waittime); @@ -105,7 +105,7 @@ ShutdownThreadMain(PVOID Context) } -NTSTATUS STDCALL +NTSTATUS STDCALL NtSetSystemPowerState(IN POWER_ACTION SystemAction, IN SYSTEM_POWER_STATE MinSystemState, IN ULONG Flags) @@ -117,7 +117,7 @@ NtSetSystemPowerState(IN POWER_ACTION SystemAction, /* * @implemented */ -NTSTATUS STDCALL +NTSTATUS STDCALL NtShutdownSystem(IN SHUTDOWN_ACTION Action) { NTSTATUS Status; diff --git a/reactos/ntoskrnl/ex/profile.c b/reactos/ntoskrnl/ex/profile.c index 337cb1faaae..7ef0cb74a7f 100644 --- a/reactos/ntoskrnl/ex/profile.c +++ b/reactos/ntoskrnl/ex/profile.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/profile.c * PURPOSE: Support for Executive Profile Objects - * + * * PROGRAMMERS: Alex Ionescu */ @@ -41,7 +41,7 @@ static GENERIC_MAPPING ExpProfileMapping = { STANDARD_RIGHTS_EXECUTE | PROFILE_CONTROL, STANDARD_RIGHTS_ALL}; -VOID +VOID STDCALL ExpDeleteProfile(PVOID ObjectBody) { @@ -49,35 +49,35 @@ ExpDeleteProfile(PVOID ObjectBody) /* Typecast the Object */ Profile = (PEPROFILE)ObjectBody; - + /* Check if there if the Profile was started */ if (Profile->LockedBuffer) { - + /* Stop the Profile */ KeStopProfile(Profile->KeProfile); - + /* Unmap the Locked Buffer */ MmUnmapLockedPages(Profile->LockedBuffer, Profile->Mdl); MmUnlockPages(Profile->Mdl); ExFreePool(Profile->Mdl); } - + /* Check if a Process is associated */ if (Profile->Process != NULL) { - + /* Dereference it */ ObDereferenceObject(Profile->Process); Profile->Process = NULL; } } -VOID +VOID INIT_FUNCTION ExpInitializeProfileImplementation(VOID) { /* Initialize the Mutex to lock the States */ KeInitializeMutex(&ExpProfileMutex, 0x40); - + /* Create the Object Type */ ExProfileObjectType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE)); RtlInitUnicodeString(&ExProfileObjectType->TypeName, L"Profile"); @@ -101,12 +101,12 @@ ExpInitializeProfileImplementation(VOID) ObpCreateTypeObject(ExProfileObjectType); } -NTSTATUS -STDCALL +NTSTATUS +STDCALL NtCreateProfile(OUT PHANDLE ProfileHandle, IN HANDLE Process OPTIONAL, - IN PVOID ImageBase, - IN ULONG ImageSize, + IN PVOID ImageBase, + IN ULONG ImageSize, IN ULONG BucketSize, IN PVOID Buffer, IN ULONG BufferSize, @@ -119,7 +119,7 @@ NtCreateProfile(OUT PHANDLE ProfileHandle, KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); OBJECT_ATTRIBUTES ObjectAttributes; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); /* Easy way out */ @@ -127,27 +127,27 @@ NtCreateProfile(OUT PHANDLE ProfileHandle, /* Check the Parameters for validity */ if(PreviousMode != KernelMode) { - + _SEH_TRY { - + ProbeForWrite(ProfileHandle, sizeof(HANDLE), sizeof(ULONG)); - + ProbeForWrite(Buffer, BufferSize, sizeof(ULONG)); } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) return Status; } /* Check if a process was specified */ if (Process) { - + /* Reference it */ Status = ObReferenceObjectByHandle(Process, PROCESS_QUERY_INFORMATION, @@ -156,15 +156,15 @@ NtCreateProfile(OUT PHANDLE ProfileHandle, (PVOID*)&pProcess, NULL); if (!NT_SUCCESS(Status)) return(Status); - + } else { - + /* No process was specified, which means a System-Wide Profile */ pProcess = NULL; - + /* For this, we need to check the Privilege */ if(!SeSinglePrivilegeCheck(SeSystemProfilePrivilege, PreviousMode)) { - + DPRINT1("NtCreateProfile: Caller requires the SeSystemProfilePrivilege privilege!\n"); return STATUS_PRIVILEGE_NOT_HELD; } @@ -196,7 +196,7 @@ NtCreateProfile(OUT PHANDLE ProfileHandle, Profile->LockedBuffer = NULL; Profile->Affinity = Affinity; Profile->Process = pProcess; - + /* Insert into the Object Tree */ Status = ObInsertObject ((PVOID)Profile, NULL, @@ -205,22 +205,22 @@ NtCreateProfile(OUT PHANDLE ProfileHandle, NULL, &hProfile); ObDereferenceObject(Profile); - + /* Check for Success */ if (!NT_SUCCESS(Status)) { - + /* Dereference Process on failure */ if (pProcess) ObDereferenceObject(pProcess); return Status; } - + /* Copy the created handle back to the caller*/ _SEH_TRY { - + *ProfileHandle = hProfile; - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); } _SEH_END; @@ -228,7 +228,7 @@ NtCreateProfile(OUT PHANDLE ProfileHandle, return Status; } -NTSTATUS +NTSTATUS STDCALL NtQueryPerformanceCounter(OUT PLARGE_INTEGER PerformanceCounter, OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL) @@ -236,48 +236,48 @@ NtQueryPerformanceCounter(OUT PLARGE_INTEGER PerformanceCounter, KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); LARGE_INTEGER PerfFrequency; NTSTATUS Status = STATUS_SUCCESS; - + /* Check the Parameters for validity */ if(PreviousMode != KernelMode) { - + _SEH_TRY { - + ProbeForWrite(PerformanceCounter, sizeof(LARGE_INTEGER), sizeof(ULONG)); - + ProbeForWrite(PerformanceFrequency, sizeof(LARGE_INTEGER), sizeof(ULONG)); } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) return Status; } _SEH_TRY { - + /* Query the Kernel */ *PerformanceCounter = KeQueryPerformanceCounter(&PerfFrequency); - + /* Return Frequency if requested */ if(PerformanceFrequency) { - + *PerformanceFrequency = PerfFrequency; } } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; return Status; } -NTSTATUS -STDCALL +NTSTATUS +STDCALL NtStartProfile(IN HANDLE ProfileHandle) { PEPROFILE Profile; @@ -285,7 +285,7 @@ NtStartProfile(IN HANDLE ProfileHandle) KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); PVOID TempLockedBuffer; NTSTATUS Status; - + PAGED_CODE(); /* Get the Object */ @@ -296,37 +296,37 @@ NtStartProfile(IN HANDLE ProfileHandle) (PVOID*)&Profile, NULL); if (!NT_SUCCESS(Status)) return(Status); - + /* To avoid a Race, wait on the Mutex */ - KeWaitForSingleObject(&ExpProfileMutex, + KeWaitForSingleObject(&ExpProfileMutex, Executive, KernelMode, FALSE, NULL); - + /* The Profile can still be enabled though, so handle that */ if (Profile->LockedBuffer) { - + /* Release our lock, dereference and return */ KeReleaseMutex(&ExpProfileMutex, FALSE); ObDereferenceObject(Profile); return STATUS_PROFILING_NOT_STOPPED; } - + /* Allocate a Kernel Profile Object. */ - KeProfile = ExAllocatePoolWithTag(NonPagedPool, + KeProfile = ExAllocatePoolWithTag(NonPagedPool, sizeof(EPROFILE), TAG('P', 'r', 'o', 'f')); - + /* Allocate the Mdl Structure */ Profile->Mdl = MmCreateMdl(NULL, Profile->Buffer, Profile->BufferSize); - + /* Probe and Lock for Write Access */ MmProbeAndLockPages(Profile->Mdl, PreviousMode, IoWriteAccess); - + /* Map the pages */ TempLockedBuffer = MmMapLockedPages(Profile->Mdl, KernelMode); - + /* Initialize the Kernel Profile Object */ Profile->KeProfile = KeProfile; KeInitializeProfile(KeProfile, @@ -336,13 +336,13 @@ NtStartProfile(IN HANDLE ProfileHandle) Profile->BucketSize, Profile->ProfileSource, Profile->Affinity); - + /* Start the Profiling */ KeStartProfile(KeProfile, TempLockedBuffer); - + /* Now it's safe to save this */ Profile->LockedBuffer = TempLockedBuffer; - + /* Release mutex, dereference and return */ KeReleaseMutex(&ExpProfileMutex, FALSE); ObDereferenceObject(Profile); @@ -350,13 +350,13 @@ NtStartProfile(IN HANDLE ProfileHandle) } NTSTATUS -STDCALL +STDCALL NtStopProfile(IN HANDLE ProfileHandle) { PEPROFILE Profile; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status; - + PAGED_CODE(); /* Get the Object */ @@ -367,32 +367,32 @@ NtStopProfile(IN HANDLE ProfileHandle) (PVOID*)&Profile, NULL); if (!NT_SUCCESS(Status)) return(Status); - + /* Get the Mutex */ - KeWaitForSingleObject(&ExpProfileMutex, + KeWaitForSingleObject(&ExpProfileMutex, Executive, KernelMode, FALSE, NULL); - + /* Make sure the Profile Object is really Started */ if (!Profile->LockedBuffer) { - + Status = STATUS_PROFILING_NOT_STARTED; goto Exit; } - + /* Stop the Profile */ KeStopProfile(Profile->KeProfile); - + /* Unlock the Buffer */ MmUnmapLockedPages(Profile->LockedBuffer, Profile->Mdl); MmUnlockPages(Profile->Mdl); ExFreePool(Profile->KeProfile); - + /* Clear the Locked Buffer pointer, meaning the Object is Stopped */ Profile->LockedBuffer = NULL; - + Exit: /* Release Mutex, Dereference and Return */ KeReleaseMutex(&ExpProfileMutex, FALSE); @@ -400,60 +400,60 @@ Exit: return Status; } -NTSTATUS -STDCALL +NTSTATUS +STDCALL NtQueryIntervalProfile(IN KPROFILE_SOURCE ProfileSource, OUT PULONG Interval) { KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); ULONG ReturnInterval; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + /* Check the Parameters for validity */ if(PreviousMode != KernelMode) { - + _SEH_TRY { - + ProbeForWrite(Interval, sizeof(ULONG), sizeof(ULONG)); - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) return Status; } - + /* Query the Interval */ ReturnInterval = KeQueryIntervalProfile(ProfileSource); /* Return the data */ _SEH_TRY { - + *Interval = ReturnInterval; - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; - - /* Return Success */ + + /* Return Success */ return STATUS_SUCCESS; } -NTSTATUS -STDCALL +NTSTATUS +STDCALL NtSetIntervalProfile(IN ULONG Interval, IN KPROFILE_SOURCE Source) { /* Let the Kernel do the job */ KeSetIntervalProfile(Interval, Source); - + /* Nothing can go wrong */ return STATUS_SUCCESS; } diff --git a/reactos/ntoskrnl/ex/resource.c b/reactos/ntoskrnl/ex/resource.c index 2da0c9752b0..ac33636e4e1 100644 --- a/reactos/ntoskrnl/ex/resource.c +++ b/reactos/ntoskrnl/ex/resource.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/resource.c * PURPOSE: Resource synchronization construct - * + * * PROGRAMMERS: No programmer listed. */ @@ -105,18 +105,18 @@ ExAcquireResourceExclusiveLite ( */ { KIRQL oldIrql; - + DPRINT("ExAcquireResourceExclusiveLite(Resource %x, Wait %d)\n", Resource, Wait); - + ASSERT_IRQL_LESS(DISPATCH_LEVEL); - + /* undefed for now, since cdfs must be fixed first */ -#if 0 - /* At least regular kmode APC's must be disabled +#if 0 + /* At least regular kmode APC's must be disabled * Note that this requirement is missing in old DDK's */ ASSERT(KeGetCurrentThread() == NULL || /* <-Early in the boot process the current thread is obseved to be NULL */ - KeGetCurrentThread()->KernelApcDisable || + KeGetCurrentThread()->KernelApcDisable || KeGetCurrentIrql() == APC_LEVEL); #endif @@ -139,17 +139,17 @@ ExAcquireResourceExclusiveLite ( DPRINT("ExAcquireResourceExclusiveLite() = FALSE\n"); return(FALSE); } - - /* + + /* * This is slightly better than it looks because other exclusive * threads who are waiting won't be woken up but there is a race * with new threads trying to grab the resource so we must have * the spinlock, still normally this loop will only be executed * once - * NOTE: We might want to set a timeout to detect deadlock + * NOTE: We might want to set a timeout to detect deadlock * (10 minutes?) */ - while (Resource->ActiveCount) + while (Resource->ActiveCount) { Resource->NumberOfExclusiveWaiters++; KeReleaseSpinLock(&Resource->SpinLock, oldIrql); @@ -181,7 +181,7 @@ static BOOLEAN EiRemoveSharedOwner(PERESOURCE Resource, */ { ULONG i; - + if (Resource->OwnerThreads[1].OwnerThread == ResourceThreadId) { Resource->OwnerThreads[1].OwnerCount--; @@ -192,13 +192,13 @@ static BOOLEAN EiRemoveSharedOwner(PERESOURCE Resource, } return(TRUE); } - - if (Resource->OwnerThreads[1].OwnerThread) + + if (Resource->OwnerThreads[1].OwnerThread) { /* Oh dear, the caller didn't own the resource after all */ - return(FALSE);; + return(FALSE); } - + for (i=0; iOwnerThreads[1].TableSize; i++) { if (Resource->OwnerTable[i].OwnerThread == ResourceThreadId) @@ -227,10 +227,10 @@ static BOOLEAN EiAddSharedOwner(PERESOURCE Resource) ERESOURCE_THREAD CurrentThread = ExGetCurrentResourceThread(); POWNER_ENTRY freeEntry; ULONG i = 0; - + DPRINT("EiAddSharedOwner(Resource %x)\n", Resource); - - if (Resource->ActiveCount == 0) + + if (Resource->ActiveCount == 0) { /* no owner, it's easy */ Resource->OwnerThreads[1].OwnerThread = ExGetCurrentResourceThread(); @@ -244,19 +244,19 @@ static BOOLEAN EiAddSharedOwner(PERESOURCE Resource) DPRINT("EiAddSharedOwner() = TRUE\n"); return(TRUE); } - - /* - * now, we must search if this thread has already acquired this resource - * then increase ownercount if found, else create new entry or reuse free + + /* + * now, we must search if this thread has already acquired this resource + * then increase ownercount if found, else create new entry or reuse free * entry */ if (Resource->OwnerTable == NULL) { DPRINT("Creating owner table\n"); - + /* allocate ownertable,memset to 0, initialize first entry */ - Resource->OwnerTable = - ExAllocatePoolWithTag(NonPagedPool, sizeof(OWNER_ENTRY)*3, + Resource->OwnerTable = + ExAllocatePoolWithTag(NonPagedPool, sizeof(OWNER_ENTRY)*3, TAG_OWNER_TABLE); if (Resource->OwnerTable == NULL) { @@ -266,22 +266,22 @@ static BOOLEAN EiAddSharedOwner(PERESOURCE Resource) memset(Resource->OwnerTable,0,sizeof(OWNER_ENTRY)*3); memcpy(&Resource->OwnerTable[0], &Resource->OwnerThreads[1], sizeof(OWNER_ENTRY)); - + Resource->OwnerThreads[1].OwnerThread = 0; Resource->OwnerThreads[1].TableSize = 3; - + Resource->OwnerTable[1].OwnerThread = CurrentThread; Resource->OwnerTable[1].OwnerCount = 1; Resource->ActiveCount++; - + return(TRUE); } - + DPRINT("Search free entries\n"); - - DPRINT("Number of entries %d\n", + + DPRINT("Number of entries %d\n", Resource->OwnerThreads[1].TableSize); - + freeEntry = NULL; for (i=0; iOwnerThreads[1].TableSize; i++) { @@ -297,15 +297,15 @@ static BOOLEAN EiAddSharedOwner(PERESOURCE Resource) break; } } - + DPRINT("Found free entry %x\n", freeEntry); - + if (!freeEntry) { DPRINT("Allocating new entry\n"); - + /* reallocate ownertable with one more entry */ - freeEntry = + freeEntry = ExAllocatePoolWithTag(NonPagedPool, sizeof(OWNER_ENTRY)* (Resource->OwnerThreads[1].TableSize+1), @@ -351,51 +351,51 @@ ExAcquireResourceSharedLite ( */ { KIRQL oldIrql; - + DPRINT("ExAcquireResourceSharedLite(Resource %x, Wait %d)\n", Resource, Wait); ASSERT_IRQL_LESS(DISPATCH_LEVEL); - + /* undefed for now, since cdfs must be fixed first */ -#if 0 - /* At least regular kmode APC's must be disabled - * Note that this requirement is missing in old DDK's +#if 0 + /* At least regular kmode APC's must be disabled + * Note that this requirement is missing in old DDK's */ ASSERT(KeGetCurrentThread() == NULL || /* <-Early in the boot process the current thread is obseved to be NULL */ - KeGetCurrentThread()->KernelApcDisable || + KeGetCurrentThread()->KernelApcDisable || KeGetCurrentIrql() == APC_LEVEL); #endif KeAcquireSpinLock(&Resource->SpinLock, &oldIrql); - + /* first, resolve trivial cases */ - if (Resource->ActiveCount == 0) + if (Resource->ActiveCount == 0) { EiAddSharedOwner(Resource); KeReleaseSpinLock(&Resource->SpinLock, oldIrql); DPRINT("ExAcquireResourceSharedLite() = TRUE\n"); return(TRUE); } - + if ((Resource->Flag & ResourceOwnedExclusive) && Resource->OwnerThreads[0].OwnerThread==ExGetCurrentResourceThread()) { /* exclusive, but by same thread : it's ok */ - /* - * NOTE: Is this correct? Seems the same as ExConvertExclusiveToShared + /* + * NOTE: Is this correct? Seems the same as ExConvertExclusiveToShared */ Resource->OwnerThreads[0].OwnerCount++; KeReleaseSpinLock(&Resource->SpinLock, oldIrql); DPRINT("ExAcquireResourceSharedLite() = TRUE\n"); return(TRUE); } - + if ((Resource->Flag & ResourceOwnedExclusive) || Resource->NumberOfExclusiveWaiters) - { + { /* exclusive by another thread , or thread waiting for exclusive */ - if (!Wait) + if (!Wait) { KeReleaseSpinLock(&Resource->SpinLock, oldIrql); DPRINT("ExAcquireResourceSharedLite() = FALSE\n"); @@ -417,7 +417,7 @@ ExAcquireResourceSharedLite ( Resource->NumberOfSharedWaiters--; } } - + EiAddSharedOwner(Resource); KeReleaseSpinLock(&Resource->SpinLock, oldIrql); DPRINT("ExAcquireResourceSharedLite() = TRUE\n"); @@ -443,13 +443,13 @@ ExConvertExclusiveToSharedLite ( { ULONG oldWaiters; KIRQL oldIrql; - + DPRINT("ExConvertExclusiveToSharedLite(Resource %x)\n", Resource); - + KeAcquireSpinLock(&Resource->SpinLock, &oldIrql); - + oldWaiters = Resource->NumberOfSharedWaiters; - + if (!(Resource->Flag & ResourceOwnedExclusive)) { /* Might not be what the caller expects, better bug check */ @@ -457,7 +457,7 @@ ExConvertExclusiveToSharedLite ( KeReleaseSpinLock(&Resource->SpinLock, oldIrql); return; } - + //transfer infos from entry 0 to entry 1 and erase entry 0 Resource->OwnerThreads[1].OwnerThread=Resource->OwnerThreads[0].OwnerThread; Resource->OwnerThreads[1].OwnerCount=Resource->OwnerThreads[0].OwnerCount; @@ -466,7 +466,7 @@ ExConvertExclusiveToSharedLite ( /* erase exclusive flag */ Resource->Flag &= (~ResourceOwnedExclusive); /* if no shared waiters, that's all */ - if (!oldWaiters) + if (!oldWaiters) { KeReleaseSpinLock(&Resource->SpinLock, oldIrql); return; @@ -524,14 +524,14 @@ ExAcquireSharedStarveExclusive ( */ { KIRQL oldIrql; - + DPRINT("ExAcquireSharedStarveExclusive(Resource %x, Wait %d)\n", Resource, Wait); - + KeAcquireSpinLock(&Resource->SpinLock, &oldIrql); - + /* no owner, it's easy */ - if (Resource->ActiveCount == 0) + if (Resource->ActiveCount == 0) { Resource->OwnerThreads[1].OwnerThread=ExGetCurrentResourceThread(); Resource->OwnerThreads[1].OwnerCount=1; @@ -540,21 +540,21 @@ ExAcquireSharedStarveExclusive ( DPRINT("ExAcquireSharedStarveExclusive() = TRUE\n"); return(TRUE); } - + if ((Resource->Flag & ResourceOwnedExclusive) && Resource->OwnerThreads[0].OwnerThread==ExGetCurrentResourceThread()) - { + { /* exclusive, but by same thread : it's ok */ Resource->OwnerThreads[0].OwnerCount++; KeReleaseSpinLock(&Resource->SpinLock, oldIrql); DPRINT("ExAcquireSharedStarveExclusive() = TRUE\n"); return(TRUE); } - + if (Resource->Flag & ResourceOwnedExclusive) - { + { /* exclusive by another thread */ - if (!Wait) + if (!Wait) { KeReleaseSpinLock(&Resource->SpinLock, oldIrql); DPRINT("ExAcquireSharedStarveExclusive() = FALSE\n"); @@ -620,7 +620,7 @@ ExDeleteResourceLite ( if (Resource->OwnerTable) ExFreePool(Resource->OwnerTable); if (Resource->SharedWaiters) ExFreePool(Resource->SharedWaiters); if (Resource->ExclusiveWaiters) ExFreePool(Resource->ExclusiveWaiters); - return(STATUS_SUCCESS);; + return(STATUS_SUCCESS); } /* @@ -664,12 +664,12 @@ ExInitializeResourceLite (PERESOURCE Resource) Resource->NumberOfExclusiveWaiters = 0; KeInitializeSpinLock(&Resource->SpinLock); Resource->Flag = 0; - Resource->ExclusiveWaiters = + Resource->ExclusiveWaiters = ExAllocatePoolWithTag(NonPagedPool, sizeof(KEVENT), TAG_EXCLUSIVE_LOCK); KeInitializeEvent(Resource->ExclusiveWaiters, SynchronizationEvent, FALSE); - Resource->SharedWaiters = + Resource->SharedWaiters = ExAllocatePoolWithTag(NonPagedPool ,sizeof(KSEMAPHORE), TAG_SHARED_SEM); KeInitializeSemaphore(Resource->SharedWaiters,0,0x7fffffff); Resource->ActiveCount = 0; @@ -707,8 +707,8 @@ ExIsResourceAcquiredExclusiveLite ( /* * @implemented */ - - + + //NTOSAPI //DDKAPI USHORT STDCALL @@ -721,7 +721,7 @@ ExIsResourceAcquiredSharedLite( * Resource = Points to the resource to be queried * RETURNS: The number of times the caller has acquired shared access to the * given resource - */ + */ { ULONG i; if (Resource->OwnerThreads[0].OwnerThread == ExGetCurrentResourceThread()) @@ -732,7 +732,7 @@ ExIsResourceAcquiredSharedLite( { return (USHORT)(Resource->OwnerThreads[1].OwnerCount); } - if (!Resource->OwnerThreads[1].TableSize) + if (!Resource->OwnerThreads[1].TableSize) { return(0); } @@ -763,7 +763,7 @@ ExReinitializeResourceLite ( FALSE); KeInitializeSemaphore(Resource->SharedWaiters,0,0x7fffffff); Resource->ActiveCount = 0; - if (Resource->OwnerTable) + if (Resource->OwnerTable) { ExFreePool(Resource->OwnerTable); } @@ -827,18 +827,18 @@ ExReleaseResourceForThreadLite ( */ { KIRQL oldIrql; - + DPRINT("ExReleaseResourceForThreadLite(Resource %x, ResourceThreadId %x)\n", Resource, ResourceThreadId); - + ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL); - + KeAcquireSpinLock(&Resource->SpinLock, &oldIrql); - + if (Resource->Flag & ResourceOwnedExclusive) { DPRINT("Releasing from exclusive access\n"); - + Resource->OwnerThreads[0].OwnerCount--; if (Resource->OwnerThreads[0].OwnerCount > 0) { @@ -846,7 +846,7 @@ ExReleaseResourceForThreadLite ( DPRINT("ExReleaseResourceForThreadLite() finished\n"); return; } - + Resource->OwnerThreads[0].OwnerThread = 0; Resource->ActiveCount--; Resource->Flag &=(~ResourceOwnedExclusive); @@ -856,8 +856,8 @@ ExReleaseResourceForThreadLite ( if (Resource->NumberOfExclusiveWaiters) { /* get resource to first exclusive waiter */ - KeSetEvent(Resource->ExclusiveWaiters, - IO_NO_INCREMENT, + KeSetEvent(Resource->ExclusiveWaiters, + IO_NO_INCREMENT, FALSE); KeReleaseSpinLock(&Resource->SpinLock, oldIrql); DPRINT("ExReleaseResourceForThreadLite() finished\n"); @@ -877,20 +877,20 @@ ExReleaseResourceForThreadLite ( DPRINT("ExReleaseResourceForThreadLite() finished\n"); return; } - + EiRemoveSharedOwner(Resource, ResourceThreadId); - + if (Resource->ActiveCount == 0) { if (Resource->NumberOfExclusiveWaiters) - { + { /* get resource to first exclusive waiter */ KeSetEvent(Resource->ExclusiveWaiters, IO_NO_INCREMENT, FALSE); } } - + KeReleaseSpinLock(&Resource->SpinLock, oldIrql); DPRINT("ExReleaseResourceForThreadLite() finished\n"); } @@ -909,52 +909,52 @@ ExSetResourceOwnerPointer ( PKTHREAD CurrentThread; KIRQL OldIrql; POWNER_ENTRY OwnerEntry; - + CurrentThread = KeGetCurrentThread(); - + /* Lock the resource */ KeAcquireSpinLock(&Resource->SpinLock, &OldIrql); - + /* Check if it's exclusive */ if (Resource->Flag & ResourceOwnedExclusive) { - + /* If it's exclusive, set the first entry no matter what */ Resource->OwnerThreads[0].OwnerThread = (ULONG_PTR)OwnerPointer; - + } else { - + /* Check both entries and see which one matches the current thread */ if (Resource->OwnerThreads[0].OwnerThread == (ULONG_PTR)CurrentThread) { - + Resource->OwnerThreads[0].OwnerThread = (ULONG_PTR)OwnerPointer; - + } else if (Resource->OwnerThreads[1].OwnerThread == (ULONG_PTR)CurrentThread) { - + Resource->OwnerThreads[1].OwnerThread = (ULONG_PTR)OwnerPointer; - + } else { /* None of the entries match, so we need to do a lookup */ - + /* Get the first Entry */ OwnerEntry = Resource->OwnerTable; - + /* Check if the Current Thread is in the Resource Table Entry */ - if ((CurrentThread->ResourceIndex >= OwnerEntry->TableSize) || + if ((CurrentThread->ResourceIndex >= OwnerEntry->TableSize) || (OwnerEntry[CurrentThread->ResourceIndex].OwnerThread != (ULONG_PTR)CurrentThread)) { - + /* Loop until we find the current thread in an entry */ for (;OwnerEntry->OwnerThread == (ULONG_PTR)CurrentThread;OwnerEntry++); - + } else { - + /* It's in the current RTE, so set it */ OwnerEntry = &OwnerEntry[CurrentThread->ResourceIndex]; } - - /* Now that we went to the right entry, set the Owner Pointer */ + + /* Now that we went to the right entry, set the Owner Pointer */ OwnerEntry->OwnerThread = (ULONG_PTR)OwnerPointer; } } - + /* Release the resource */ KeReleaseSpinLock(&Resource->SpinLock, OldIrql); } diff --git a/reactos/ntoskrnl/ex/rundown.c b/reactos/ntoskrnl/ex/rundown.c index 580d9bb4e4e..4b5a54eb41f 100644 --- a/reactos/ntoskrnl/ex/rundown.c +++ b/reactos/ntoskrnl/ex/rundown.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/rundown.c * PURPOSE: Rundown Protection Functions - * + * * PROGRAMMERS: Alex Ionescu & Thomas Weidenmueller - Implementation */ @@ -39,16 +39,16 @@ ExAcquireRundownProtectionEx ( ) { ULONG_PTR PrevCount, Current; - + PAGED_CODE(); - + Count <<= EX_RUNDOWN_COUNT_SHIFT; - + /* Loop until successfully incremented the counter */ do { Current = RunRef->Count; - + /* Make sure a rundown is not active */ if (Current & EX_RUNDOWN_ACTIVE) { @@ -76,7 +76,7 @@ ExInitializeRundownProtection ( ) { PAGED_CODE(); - + /* Set the count to zero */ RunRef->Count = 0; } @@ -91,7 +91,7 @@ ExReInitializeRundownProtection ( ) { PAGED_CODE(); - + /* Reset the count */ #ifdef _WIN64 InterlockedExchangeAdd64((LONGLONG*)&RunRef->Count, 0LL); @@ -114,23 +114,23 @@ ExReleaseRundownProtectionEx ( PAGED_CODE(); Count <<= EX_RUNDOWN_COUNT_SHIFT; - + for (;;) { ULONG_PTR Current = RunRef->Count; - + /* Check if Rundown is active */ if (Current & EX_RUNDOWN_ACTIVE) { /* Get Pointer */ PRUNDOWN_DESCRIPTOR RundownDescriptor = (PRUNDOWN_DESCRIPTOR)(Current & ~EX_RUNDOWN_ACTIVE); - + if (RundownDescriptor == NULL) { /* the rundown was completed and there's no one to notify */ break; } - + Current = RundownDescriptor->References; /* Decrease RundownDescriptor->References by Count references */ @@ -162,10 +162,10 @@ ExReleaseRundownProtectionEx ( /* Successfully decremented the counter, so bail! */ break; } - + Current = PrevCount; } - + break; } else @@ -208,7 +208,7 @@ ExRundownCompleted ( ) { PAGED_CODE(); - + /* mark the counter as active */ #ifdef _WIN64 InterlockedExchange64((LONGLONG*)&RunRef->Count, (LONGLONG)EX_RUNDOWN_ACTIVE); @@ -228,11 +228,11 @@ ExWaitForRundownProtectionRelease ( { ULONG_PTR PrevCount, NewPtr, PrevPtr; RUNDOWN_DESCRIPTOR RundownDescriptor; - + PAGED_CODE(); - + PrevCount = RunRef->Count; - + if (PrevCount != 0 && !(PrevCount & EX_RUNDOWN_ACTIVE)) { /* save the reference counter */ @@ -240,11 +240,11 @@ ExWaitForRundownProtectionRelease ( /* Pending references... wait on them to be closed with an event */ KeInitializeEvent(&RundownDescriptor.RundownEvent, NotificationEvent, FALSE); - + ASSERT(!((ULONG_PTR)&RundownDescriptor & EX_RUNDOWN_ACTIVE)); - + NewPtr = (ULONG_PTR)&RundownDescriptor | EX_RUNDOWN_ACTIVE; - + for (;;) { #ifdef _WIN64 @@ -263,9 +263,9 @@ ExWaitForRundownProtectionRelease ( /* some one else was faster, let's just bail */ break; } - + PrevCount = PrevPtr; - + /* save the changed reference counter and try again */ RundownDescriptor.References = PrevCount >> EX_RUNDOWN_COUNT_SHIFT; } diff --git a/reactos/ntoskrnl/ex/sem.c b/reactos/ntoskrnl/ex/sem.c index 548616077a0..c8d5ece3d70 100644 --- a/reactos/ntoskrnl/ex/sem.c +++ b/reactos/ntoskrnl/ex/sem.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/sem.c * PURPOSE: Synchronization primitives - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)- Reformatting, bug fixes. * David Welch (welch@mcmail.com) */ @@ -25,16 +25,16 @@ static GENERIC_MAPPING ExSemaphoreMapping = { SEMAPHORE_ALL_ACCESS}; static const INFORMATION_CLASS_INFO ExSemaphoreInfoClass[] = { - + /* SemaphoreBasicInformation */ ICI_SQ_SAME( sizeof(SEMAPHORE_BASIC_INFORMATION), sizeof(ULONG), ICIF_QUERY ), }; -VOID +VOID INIT_FUNCTION ExpInitializeSemaphoreImplementation(VOID) { - + /* Create the Semaphore Object */ ExSemaphoreObjectType = ExAllocatePool(NonPagedPool, sizeof(OBJECT_TYPE)); RtlInitUnicodeString(&ExSemaphoreObjectType->TypeName, L"Semaphore"); @@ -62,7 +62,7 @@ ExpInitializeSemaphoreImplementation(VOID) /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtCreateSemaphore(OUT PHANDLE SemaphoreHandle, IN ACCESS_MASK DesiredAccess, @@ -74,29 +74,29 @@ NtCreateSemaphore(OUT PHANDLE SemaphoreHandle, HANDLE hSemaphore; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); /* Check Output Safety */ if(PreviousMode != KernelMode) { - + _SEH_TRY { - + ProbeForWrite(SemaphoreHandle, sizeof(HANDLE), sizeof(ULONG)); } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; - + if(!NT_SUCCESS(Status)) return Status; } - + /* Make sure the counts make sense */ if (!MaximumCount || InitialCount < 0 || InitialCount > MaximumCount) { - + DPRINT("Invalid Count Data!\n"); return STATUS_INVALID_PARAMETER; } @@ -111,15 +111,15 @@ NtCreateSemaphore(OUT PHANDLE SemaphoreHandle, 0, 0, (PVOID*)&Semaphore); - + /* Check for Success */ if (NT_SUCCESS(Status)) { - + /* Initialize it */ KeInitializeSemaphore(Semaphore, InitialCount, MaximumCount); - + /* Insert it into the Object Tree */ Status = ObInsertObject((PVOID)Semaphore, NULL, @@ -131,15 +131,15 @@ NtCreateSemaphore(OUT PHANDLE SemaphoreHandle, /* Check for success and return handle */ if(NT_SUCCESS(Status)) { - + _SEH_TRY { - + *SemaphoreHandle = hSemaphore; - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } } @@ -151,7 +151,7 @@ NtCreateSemaphore(OUT PHANDLE SemaphoreHandle, /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtOpenSemaphore(OUT PHANDLE SemaphoreHandle, IN ACCESS_MASK DesiredAccess, @@ -160,26 +160,26 @@ NtOpenSemaphore(OUT PHANDLE SemaphoreHandle, HANDLE hSemaphore; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); /* Check Output Safety */ if(PreviousMode == UserMode) { - + _SEH_TRY { - + ProbeForWrite(SemaphoreHandle, sizeof(HANDLE), sizeof(ULONG)); } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; - + if(!NT_SUCCESS(Status)) return Status; } - + /* Open the Object */ Status = ObOpenObjectByName(ObjectAttributes, ExSemaphoreObjectType, @@ -188,18 +188,18 @@ NtOpenSemaphore(OUT PHANDLE SemaphoreHandle, DesiredAccess, NULL, &hSemaphore); - + /* Check for success and return handle */ if(NT_SUCCESS(Status)) { - + _SEH_TRY { - + *SemaphoreHandle = hSemaphore; - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } @@ -233,12 +233,12 @@ NtQuerySemaphore(IN HANDLE SemaphoreHandle, PreviousMode, &Status); if(!NT_SUCCESS(Status)) { - + /* Invalid buffers */ DPRINT("NtQuerySemaphore() failed, Status: 0x%x\n", Status); return Status; } - + /* Get the Object */ Status = ObReferenceObjectByHandle(SemaphoreHandle, SEMAPHORE_QUERY_STATE, @@ -246,27 +246,27 @@ NtQuerySemaphore(IN HANDLE SemaphoreHandle, PreviousMode, (PVOID*)&Semaphore, NULL); - + /* Check for success */ if(NT_SUCCESS(Status)) { - + _SEH_TRY { - + PSEMAPHORE_BASIC_INFORMATION BasicInfo = (PSEMAPHORE_BASIC_INFORMATION)SemaphoreInformation; - + /* Return the basic information */ BasicInfo->CurrentCount = KeReadStateSemaphore(Semaphore); BasicInfo->MaximumCount = Semaphore->Limit; /* Return length */ if(ReturnLength) *ReturnLength = sizeof(SEMAPHORE_BASIC_INFORMATION); - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; - + /* Dereference the Object */ ObDereferenceObject(Semaphore); } @@ -278,7 +278,7 @@ NtQuerySemaphore(IN HANDLE SemaphoreHandle, /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtReleaseSemaphore(IN HANDLE SemaphoreHandle, IN LONG ReleaseCount, @@ -286,34 +286,34 @@ NtReleaseSemaphore(IN HANDLE SemaphoreHandle, { KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); PKSEMAPHORE Semaphore; - NTSTATUS Status = STATUS_SUCCESS; - + NTSTATUS Status = STATUS_SUCCESS; + PAGED_CODE(); - + /* Check buffer validity */ if(PreviousCount != NULL && PreviousMode == UserMode) { - + _SEH_TRY { - + ProbeForWrite(PreviousCount, sizeof(LONG), sizeof(ULONG)); } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; if(!NT_SUCCESS(Status)) return Status; } - + /* Make sure count makes sense */ if (!ReleaseCount) { - + DPRINT("Invalid Release Count\n"); return STATUS_INVALID_PARAMETER; } - + /* Get the Object */ Status = ObReferenceObjectByHandle(SemaphoreHandle, SEMAPHORE_MODIFY_STATE, @@ -321,28 +321,28 @@ NtReleaseSemaphore(IN HANDLE SemaphoreHandle, PreviousMode, (PVOID*)&Semaphore, NULL); - + /* Check for success */ if (NT_SUCCESS(Status)) { - + /* Release the semaphore */ LONG PrevCount = KeReleaseSemaphore(Semaphore, IO_NO_INCREMENT, ReleaseCount, FALSE); ObDereferenceObject(Semaphore); - - /* Return it */ + + /* Return it */ if(PreviousCount) { - + _SEH_TRY { - + *PreviousCount = PrevCount; - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } } diff --git a/reactos/ntoskrnl/ex/synch.c b/reactos/ntoskrnl/ex/synch.c index ade25c7f34d..f74d7b175a9 100644 --- a/reactos/ntoskrnl/ex/synch.c +++ b/reactos/ntoskrnl/ex/synch.c @@ -1,5 +1,5 @@ -/* $Id:$ - * +/* $Id$ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/synch.c diff --git a/reactos/ntoskrnl/ex/sysinfo.c b/reactos/ntoskrnl/ex/sysinfo.c index 514cff7190d..6ee4693ba13 100644 --- a/reactos/ntoskrnl/ex/sysinfo.c +++ b/reactos/ntoskrnl/ex/sysinfo.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/sysinfo.c * PURPOSE: System information functions - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) * Aleksey Bragin (aleksey@studiocerebral.com) */ @@ -84,7 +84,7 @@ ExGetCurrentProcessorCounts ( /* * @implemented */ -BOOLEAN +BOOLEAN STDCALL ExIsProcessorFeaturePresent(IN ULONG ProcessorFeature) { @@ -109,11 +109,11 @@ NtQuerySystemEnvironmentValue (IN PUNICODE_STRING VariableName, UNICODE_STRING WValue; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); - + if(PreviousMode != KernelMode) { _SEH_TRY @@ -136,7 +136,7 @@ NtQuerySystemEnvironmentValue (IN PUNICODE_STRING VariableName, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -165,7 +165,7 @@ NtQuerySystemEnvironmentValue (IN PUNICODE_STRING VariableName, DPRINT1("NtQuerySystemEnvironmentValue: Caller requires the SeSystemEnvironmentPrivilege privilege!\n"); return STATUS_PRIVILEGE_NOT_HELD; } - + /* * convert the value name to ansi */ @@ -177,7 +177,7 @@ NtQuerySystemEnvironmentValue (IN PUNICODE_STRING VariableName, { return Status; } - + /* * Create a temporary buffer for the value */ @@ -187,7 +187,7 @@ NtQuerySystemEnvironmentValue (IN PUNICODE_STRING VariableName, RtlFreeAnsiString(&AName); return STATUS_INSUFFICIENT_RESOURCES; } - + /* * Get the environment variable */ @@ -198,7 +198,7 @@ NtQuerySystemEnvironmentValue (IN PUNICODE_STRING VariableName, ExFreePool(Value); return STATUS_UNSUCCESSFUL; } - + /* * Convert the result to UNICODE, protect with SEH in case the value buffer * isn't NULL-terminated! @@ -236,7 +236,7 @@ NtQuerySystemEnvironmentValue (IN PUNICODE_STRING VariableName, } _SEH_END; } - + /* * Cleanup allocated resources. */ @@ -256,11 +256,11 @@ NtSetSystemEnvironmentValue (IN PUNICODE_STRING VariableName, ANSI_STRING AName, AValue; KPROCESSOR_MODE PreviousMode; NTSTATUS Status; - + PAGED_CODE(); PreviousMode = ExGetPreviousMode(); - + /* * Copy the strings to kernel space if necessary */ @@ -309,7 +309,7 @@ NtSetSystemEnvironmentValue (IN PUNICODE_STRING VariableName, DPRINT1("NtSetSystemEnvironmentValue: Caller requires the SeSystemEnvironmentPrivilege privilege!\n"); Status = STATUS_PRIVILEGE_NOT_HELD; } - + RtlReleaseCapturedUnicodeString(&CapturedValue, PreviousMode, FALSE); @@ -319,7 +319,7 @@ NtSetSystemEnvironmentValue (IN PUNICODE_STRING VariableName, PreviousMode, FALSE); } - + return Status; } @@ -342,12 +342,12 @@ static NTSTATUS SSI_USE(n) (PVOID Buffer, ULONG Size) /* Class 0 - Basic Information */ QSI_DEF(SystemBasicInformation) { - PSYSTEM_BASIC_INFORMATION Sbi + PSYSTEM_BASIC_INFORMATION Sbi = (PSYSTEM_BASIC_INFORMATION) Buffer; *ReqSize = sizeof (SYSTEM_BASIC_INFORMATION); /* - * Check user buffer's size + * Check user buffer's size */ if (Size < sizeof (SYSTEM_BASIC_INFORMATION)) { @@ -357,7 +357,7 @@ QSI_DEF(SystemBasicInformation) Sbi->MaximumIncrement = KeMaximumIncrement; Sbi->PhysicalPageSize = PAGE_SIZE; Sbi->NumberOfPhysicalPages = MmStats.NrTotalPages; - Sbi->LowestPhysicalPage = 0; /* FIXME */ + Sbi->LowestPhysicalPage = 0; /* FIXME */ Sbi->HighestPhysicalPage = MmStats.NrTotalPages; /* FIXME */ Sbi->AllocationGranularity = MM_VIRTMEM_GRANULARITY; /* hard coded on Intel? */ Sbi->LowestUserAddress = 0x10000; /* Top of 64k */ @@ -370,12 +370,12 @@ QSI_DEF(SystemBasicInformation) /* Class 1 - Processor Information */ QSI_DEF(SystemProcessorInformation) { - PSYSTEM_PROCESSOR_INFORMATION Spi + PSYSTEM_PROCESSOR_INFORMATION Spi = (PSYSTEM_PROCESSOR_INFORMATION) Buffer; PKPRCB Prcb; *ReqSize = sizeof (SYSTEM_PROCESSOR_INFORMATION); /* - * Check user buffer's size + * Check user buffer's size */ if (Size < sizeof (SYSTEM_PROCESSOR_INFORMATION)) { @@ -397,22 +397,22 @@ QSI_DEF(SystemProcessorInformation) /* Class 2 - Performance Information */ QSI_DEF(SystemPerformanceInformation) { - PSYSTEM_PERFORMANCE_INFORMATION Spi + PSYSTEM_PERFORMANCE_INFORMATION Spi = (PSYSTEM_PERFORMANCE_INFORMATION) Buffer; PEPROCESS TheIdleProcess; - + *ReqSize = sizeof (SYSTEM_PERFORMANCE_INFORMATION); /* - * Check user buffer's size + * Check user buffer's size */ if (Size < sizeof (SYSTEM_PERFORMANCE_INFORMATION)) { return (STATUS_INFO_LENGTH_MISMATCH); } - + TheIdleProcess = PsIdleProcess; - + Spi->IdleTime.QuadPart = TheIdleProcess->Pcb.KernelTime * 100000LL; Spi->ReadTransferCount.QuadPart = IoReadTransferCount; @@ -463,9 +463,9 @@ QSI_DEF(SystemPerformanceInformation) Spi->NonPagedPoolFrees = 0; /* FIXME */ Spi->TotalFreeSystemPtes = 0; /* FIXME */ - + Spi->SystemCodePage = MmStats.NrSystemPages; /* FIXME */ - + Spi->TotalSystemDriverPages = 0; /* FIXME */ Spi->TotalSystemCodePages = 0; /* FIXME */ Spi->SmallNonPagedLookasideListAllocateHits = 0; /* FIXME */ @@ -571,7 +571,7 @@ QSI_DEF(SystemProcessInformation) { return (STATUS_INFO_LENGTH_MISMATCH); // in case buffer size is too small } - + syspr = PsGetNextProcess(NULL); pr = syspr; pCur = (unsigned char *)Spi; @@ -611,7 +611,7 @@ QSI_DEF(SystemProcessInformation) SpiCur->NextEntryOffset = curSize+inLen; // relative offset to the beginnnig of the next structure SpiCur->NumberOfThreads = nThreads; SpiCur->CreateTime = pr->CreateTime; - SpiCur->UserTime.QuadPart = pr->Pcb.UserTime * 100000LL; + SpiCur->UserTime.QuadPart = pr->Pcb.UserTime * 100000LL; SpiCur->KernelTime.QuadPart = pr->Pcb.KernelTime * 100000LL; SpiCur->ImageName.Length = strlen(pr->ImageFileName) * sizeof(WCHAR); SpiCur->ImageName.MaximumLength = inLen; @@ -665,7 +665,7 @@ QSI_DEF(SystemProcessInformation) i++; current_entry = current_entry->Flink; } - + pr = PsGetNextProcess(pr); nThreads = 0; if ((pr == syspr) || (pr == NULL)) @@ -676,7 +676,7 @@ QSI_DEF(SystemProcessInformation) else pCur = pCur + curSize + inLen; } while ((pr != syspr) && (pr != NULL)); - + if(pr != NULL) { ObDereferenceObject(pr); @@ -697,13 +697,13 @@ QSI_DEF(SystemCallCountInformation) /* Class 7 - Device Information */ QSI_DEF(SystemDeviceInformation) { - PSYSTEM_DEVICE_INFORMATION Sdi + PSYSTEM_DEVICE_INFORMATION Sdi = (PSYSTEM_DEVICE_INFORMATION) Buffer; PCONFIGURATION_INFORMATION ConfigInfo; *ReqSize = sizeof (SYSTEM_DEVICE_INFORMATION); /* - * Check user buffer's size + * Check user buffer's size */ if (Size < sizeof (SYSTEM_DEVICE_INFORMATION)) { @@ -734,7 +734,7 @@ QSI_DEF(SystemProcessorPerformanceInformation) *ReqSize = KeNumberProcessors * sizeof (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION); /* - * Check user buffer's size + * Check user buffer's size */ if (Size < KeNumberProcessors * sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION)) { @@ -754,7 +754,7 @@ QSI_DEF(SystemProcessorPerformanceInformation) Spi++; Prcb = (PKPRCB)((ULONG_PTR)Prcb + PAGE_SIZE); } - + return (STATUS_SUCCESS); } @@ -835,7 +835,7 @@ ObpGetNextHandleByProcessCount(PSYSTEM_HANDLE_TABLE_ENTRY_INFO pshi, /* Class 16 - Handle Information */ QSI_DEF(SystemHandleInformation) { - PSYSTEM_HANDLE_INFORMATION Shi = + PSYSTEM_HANDLE_INFORMATION Shi = (PSYSTEM_HANDLE_INFORMATION) Buffer; DPRINT("NtQuerySystemInformation - SystemHandleInformation\n"); @@ -851,7 +851,7 @@ QSI_DEF(SystemHandleInformation) PEPROCESS pr, syspr; int curSize, i = 0; ULONG hCount = 0; - + /* First Calc Size from Count. */ syspr = PsGetNextProcess(NULL); pr = syspr; @@ -864,7 +864,7 @@ QSI_DEF(SystemHandleInformation) if ((pr == syspr) || (pr == NULL)) break; } while ((pr != syspr) && (pr != NULL)); - + if(pr != NULL) { ObDereferenceObject(pr); @@ -873,7 +873,7 @@ QSI_DEF(SystemHandleInformation) DPRINT("SystemHandleInformation 2\n"); curSize = sizeof(SYSTEM_HANDLE_INFORMATION)+ - ( (sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO) * hCount) - + ( (sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO) * hCount) - (sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO) )); Shi->NumberOfHandles = hCount; @@ -921,7 +921,7 @@ QSI_DEF(SystemHandleInformation) /* SSI_DEF(SystemHandleInformation) { - + return (STATUS_SUCCESS); } */ @@ -985,9 +985,9 @@ QSI_DEF(SystemFileCacheInformation) return (STATUS_INFO_LENGTH_MISMATCH); } /* Return the Byte size not the page size. */ - Sci->CurrentSize = + Sci->CurrentSize = MiMemoryConsumers[MC_CACHE].PagesUsed * PAGE_SIZE; - Sci->PeakSize = + Sci->PeakSize = MiMemoryConsumers[MC_CACHE].PagesUsed * PAGE_SIZE; /* FIXME */ Sci->PageFaultCount = 0; /* FIXME */ @@ -1025,14 +1025,14 @@ QSI_DEF(SystemInterruptInformation) UINT i; ULONG ti; PSYSTEM_INTERRUPT_INFORMATION sii = (PSYSTEM_INTERRUPT_INFORMATION)Buffer; - + if(Size < KeNumberProcessors * sizeof(SYSTEM_INTERRUPT_INFORMATION)) { return (STATUS_INFO_LENGTH_MISMATCH); } - + ti = KeQueryTimeIncrement(); - + Prcb = ((PKPCR)KPCR_BASE)->Prcb; for (i = 0; i < KeNumberProcessors; i++) { @@ -1045,7 +1045,7 @@ QSI_DEF(SystemInterruptInformation) sii++; Prcb = (PKPRCB)((ULONG_PTR)Prcb + PAGE_SIZE); } - + return STATUS_SUCCESS; } @@ -1090,7 +1090,7 @@ QSI_DEF(SystemFullMemoryInformation) #ifndef NDEBUG MmPrintMemoryStatistic(); #endif - + *Spi = MiMemoryConsumers[MC_USER].PagesUsed; return (STATUS_SUCCESS); @@ -1506,7 +1506,7 @@ NtQuerySystemInformation (IN SYSTEM_INFORMATION_CLASS SystemInformationClass, PVOID SystemInformation; NTSTATUS Status; NTSTATUS FStatus; - + PAGED_CODE(); /* DPRINT("NtQuerySystemInformation Start. Class:%d\n", @@ -1524,14 +1524,14 @@ NtQuerySystemInformation (IN SYSTEM_INFORMATION_CLASS SystemInformationClass, return(STATUS_NO_MEMORY); } }*/ - + /* Clear user buffer. */ RtlZeroMemory(SystemInformation, Length); /* * Check the request is valid. */ - if ((SystemInformationClass >= SystemInformationClassMin) && + if ((SystemInformationClass >= SystemInformationClassMin) && (SystemInformationClass < SystemInformationClassMax)) { if (NULL != CallQS [SystemInformationClass].Query) @@ -1544,7 +1544,7 @@ NtQuerySystemInformation (IN SYSTEM_INFORMATION_CLASS SystemInformationClass, &ResultLength); /*if (ExGetPreviousMode() != KernelMode) { - Status = MmCopyToCaller(UnsafeSystemInformation, + Status = MmCopyToCaller(UnsafeSystemInformation, SystemInformation, Length); ExFreePool(SystemInformation); @@ -1586,9 +1586,9 @@ NtSetSystemInformation ( ) { PAGED_CODE(); - + /* - * If called from user mode, check + * If called from user mode, check * possible unsafe arguments. */ #if 0 @@ -1636,7 +1636,7 @@ NtFlushInstructionCache ( ) { PAGED_CODE(); - + __asm__("wbinvd\n"); return STATUS_SUCCESS; } diff --git a/reactos/ntoskrnl/ex/time.c b/reactos/ntoskrnl/ex/time.c index 5adb246547d..89f5ad98c1a 100644 --- a/reactos/ntoskrnl/ex/time.c +++ b/reactos/ntoskrnl/ex/time.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/time.c * PURPOSE: Time - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -150,11 +150,11 @@ NtSetSystemTime(IN PLARGE_INTEGER SystemTime, TIME_FIELDS TimeFields; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); - + if(PreviousMode != KernelMode) { _SEH_TRY @@ -175,7 +175,7 @@ NtSetSystemTime(IN PLARGE_INTEGER SystemTime, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -185,14 +185,14 @@ NtSetSystemTime(IN PLARGE_INTEGER SystemTime, { NewSystemTime = *SystemTime; } - + if(!SeSinglePrivilegeCheck(SeSystemtimePrivilege, PreviousMode)) { DPRINT1("NtSetSystemTime: Caller requires the SeSystemtimePrivilege privilege!\n"); return STATUS_PRIVILEGE_NOT_HELD; } - + if(PreviousTime != NULL) { KeQuerySystemTime(&OldSystemTime); @@ -235,7 +235,7 @@ NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime) { KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); PreviousMode = ExGetPreviousMode(); @@ -263,7 +263,7 @@ NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime) { KeQuerySystemTime(SystemTime); } - + return Status; } diff --git a/reactos/ntoskrnl/ex/timer.c b/reactos/ntoskrnl/ex/timer.c index 7f2f9afcf25..67cdadb157e 100644 --- a/reactos/ntoskrnl/ex/timer.c +++ b/reactos/ntoskrnl/ex/timer.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/timer.c * PURPOSE: User-mode timers - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) - Reimplemented * David Welch (welch@mcmail.com) */ @@ -47,7 +47,7 @@ static GENERIC_MAPPING ExpTimerMapping = { /* Timer Information Classes */ static const INFORMATION_CLASS_INFO ExTimerInfoClass[] = { - + /* TimerBasicInformation */ ICI_SQ_SAME( sizeof(TIMER_BASIC_INFORMATION), sizeof(ULONG), ICIF_QUERY ), }; @@ -62,47 +62,47 @@ ExTimerRundown(VOID) KIRQL OldIrql; PLIST_ENTRY CurrentEntry; PETIMER Timer; - + /* Lock the Thread's Active Timer List*/ KeAcquireSpinLock(&Thread->ActiveTimerListLock, &OldIrql); - - while (!IsListEmpty(&Thread->ActiveTimerListHead)) + + while (!IsListEmpty(&Thread->ActiveTimerListHead)) { - + /* Remove a Timer */ CurrentEntry = RemoveTailList(&Thread->ActiveTimerListHead); /* Get the Timer */ Timer = CONTAINING_RECORD(CurrentEntry, ETIMER, ActiveTimerListEntry); - + ASSERT (Timer->ApcAssociated); - Timer->ApcAssociated = FALSE; - + Timer->ApcAssociated = FALSE; + DPRINT("Timer, ThreadList: %x, %x\n", Timer, Thread); - + /* Unlock the list */ KeReleaseSpinLockFromDpcLevel(&Thread->ActiveTimerListLock); - + /* Lock the Timer */ KeAcquireSpinLockAtDpcLevel(&Timer->Lock); - + ASSERT (&Thread->Tcb == Timer->TimerApc.Thread); - + KeCancelTimer(&Timer->KeTimer); KeRemoveQueueDpc(&Timer->TimerDpc); - KeRemoveQueueApc(&Timer->TimerApc); - - + KeRemoveQueueApc(&Timer->TimerApc); + + /* Unlock the Timer */ KeReleaseSpinLock(&Timer->Lock, OldIrql); - + /* Dereference it, if needed */ ObDereferenceObject(Timer); - + /* Loop again */ KeAcquireSpinLock(&Thread->ActiveTimerListLock, &OldIrql); - } - + } + KeReleaseSpinLock(&Thread->ActiveTimerListLock, OldIrql); } @@ -117,16 +117,16 @@ ExpDeleteTimer(PVOID ObjectBody) /* Lock the Wake List */ KeAcquireSpinLock(&ExpWakeListLock, &OldIrql); - + /* Check if it has a Wait List */ if (Timer->WakeTimer) { - + /* Remove it from the Wait List */ DPRINT("Removing wake list\n"); RemoveEntryList(&Timer->WakeTimerListEntry); Timer->WakeTimer = FALSE; } - + /* Release the Wake List */ KeReleaseSpinLock(&ExpWakeListLock, OldIrql); @@ -135,7 +135,7 @@ ExpDeleteTimer(PVOID ObjectBody) KeCancelTimer(&Timer->KeTimer); } -VOID +VOID STDCALL ExpTimerDpcRoutine(PKDPC Dpc, PVOID DeferredContext, @@ -152,17 +152,17 @@ ExpTimerDpcRoutine(PKDPC Dpc, /* Lock the Timer */ KeAcquireSpinLock(&Timer->Lock, &OldIrql); - + /* Queue the APC */ if(Timer->ApcAssociated) { - + DPRINT("Queuing APC\n"); KeInsertQueueApc(&Timer->TimerApc, SystemArgument1, SystemArgument2, IO_NO_INCREMENT); } - + /* Release the Timer */ KeReleaseSpinLock(&Timer->Lock, OldIrql); } @@ -183,37 +183,37 @@ ExpTimerApcKernelRoutine(PKAPC Apc, /* We need to find out which Timer we are */ Timer = CONTAINING_RECORD(Apc, ETIMER, TimerApc); DPRINT("ExpTimerApcKernelRoutine(Apc: %x. Timer: %x)\n", Apc, Timer); - + /* Lock the Timer */ KeAcquireSpinLock(&Timer->Lock, &OldIrql); - + /* Lock the Thread's Active Timer List*/ KeAcquireSpinLockAtDpcLevel(&CurrentThread->ActiveTimerListLock); - - /* - * Make sure that the Timer is still valid, and that it belongs to this thread + + /* + * Make sure that the Timer is still valid, and that it belongs to this thread * Remove it if it's not periodic */ - if ((Timer->ApcAssociated) && - (&CurrentThread->Tcb == Timer->TimerApc.Thread) && + if ((Timer->ApcAssociated) && + (&CurrentThread->Tcb == Timer->TimerApc.Thread) && (!Timer->KeTimer.Period)) { /* Remove it from the Active Timers List */ DPRINT("Removing Timer\n"); RemoveEntryList(&Timer->ActiveTimerListEntry); - + /* Disable it */ Timer->ApcAssociated = FALSE; - + /* Release spinlocks */ KeReleaseSpinLockFromDpcLevel(&CurrentThread->ActiveTimerListLock); KeReleaseSpinLock(&Timer->Lock, OldIrql); - + /* Dereference the Timer Object */ ObDereferenceObject(Timer); return; } - + /* Release spinlocks */ KeReleaseSpinLockFromDpcLevel(&CurrentThread->ActiveTimerListLock); KeReleaseSpinLock(&Timer->Lock, OldIrql); @@ -224,7 +224,7 @@ INIT_FUNCTION ExpInitializeTimerImplementation(VOID) { DPRINT("ExpInitializeTimerImplementation()\n"); - + /* Allocate Memory for the Timer */ ExTimerType = ExAllocatePool(NonPagedPool, sizeof(OBJECT_TYPE)); @@ -249,14 +249,14 @@ ExpInitializeTimerImplementation(VOID) ExTimerType->Create = NULL; ExTimerType->DuplicationNotify = NULL; ObpCreateTypeObject(ExTimerType); - + /* Initialize the Wait List and Lock */ KeInitializeSpinLock(&ExpWakeListLock); InitializeListHead(&ExpWakeList); } -NTSTATUS +NTSTATUS STDCALL NtCancelTimer(IN HANDLE TimerHandle, OUT PBOOLEAN CurrentState OPTIONAL) @@ -268,10 +268,10 @@ NtCancelTimer(IN HANDLE TimerHandle, PETHREAD TimerThread; BOOLEAN KillTimer = FALSE; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); DPRINT("NtCancelTimer(0x%x, 0x%x)\n", TimerHandle, CurrentState); - + /* Check Parameter Validity */ if(CurrentState != NULL && PreviousMode != KernelMode) { _SEH_TRY { @@ -281,7 +281,7 @@ NtCancelTimer(IN HANDLE TimerHandle, } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; } @@ -294,72 +294,72 @@ NtCancelTimer(IN HANDLE TimerHandle, PreviousMode, (PVOID*)&Timer, NULL); - + /* Check for success */ if(NT_SUCCESS(Status)) { - + DPRINT("Timer Referencced: %x\n", Timer); - + /* Lock the Timer */ KeAcquireSpinLock(&Timer->Lock, &OldIrql); - + /* Check if it's enabled */ if (Timer->ApcAssociated) { - - /* - * First, remove it from the Thread's Active List + + /* + * First, remove it from the Thread's Active List * Get the Thread. */ TimerThread = CONTAINING_RECORD(Timer->TimerApc.Thread, ETHREAD, Tcb); DPRINT("Removing from Thread: %x\n", TimerThread); - + /* Lock its active list */ KeAcquireSpinLockAtDpcLevel(&TimerThread->ActiveTimerListLock); - + /* Remove it */ RemoveEntryList(&TimerThread->ActiveTimerListHead); - + /* Unlock the list */ KeReleaseSpinLockFromDpcLevel(&TimerThread->ActiveTimerListLock); - + /* Cancel the Timer */ KeCancelTimer(&Timer->KeTimer); KeRemoveQueueDpc(&Timer->TimerDpc); KeRemoveQueueApc(&Timer->TimerApc); Timer->ApcAssociated = FALSE; KillTimer = TRUE; - + } else { - + /* If timer was disabled, we still need to cancel it */ DPRINT("APC was not Associated. Cancelling Timer\n"); KeCancelTimer(&Timer->KeTimer); } - + /* Read the old State */ State = KeReadStateTimer(&Timer->KeTimer); - + /* Dereference the Object */ ObDereferenceObject(Timer); - + /* Unlock the Timer */ KeReleaseSpinLock(&Timer->Lock, OldIrql); - + /* Dereference if it was previously enabled */ if (KillTimer) ObDereferenceObject(Timer); DPRINT1("Timer disabled\n"); /* Make sure it's safe to write to the handle */ if(CurrentState != NULL) { - + _SEH_TRY { - + *CurrentState = State; - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } } @@ -369,7 +369,7 @@ NtCancelTimer(IN HANDLE TimerHandle, } -NTSTATUS +NTSTATUS STDCALL NtCreateTimer(OUT PHANDLE TimerHandle, IN ACCESS_MASK DesiredAccess, @@ -380,28 +380,28 @@ NtCreateTimer(OUT PHANDLE TimerHandle, HANDLE hTimer; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); DPRINT("NtCreateTimer(Handle: %x, Type: %d)\n", TimerHandle, TimerType); /* Check Parameter Validity */ if (PreviousMode != KernelMode) { - + _SEH_TRY { - + ProbeForWrite(TimerHandle, sizeof(HANDLE), sizeof(ULONG)); } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; - + if(!NT_SUCCESS(Status)) return Status; } - - /* Create the Object */ + + /* Create the Object */ Status = ObCreateObject(PreviousMode, ExTimerType, ObjectAttributes, @@ -411,24 +411,24 @@ NtCreateTimer(OUT PHANDLE TimerHandle, 0, 0, (PVOID*)&Timer); - + /* Check for Success */ if(NT_SUCCESS(Status)) { - + /* Initialize the Kernel Timer */ DPRINT("Initializing Timer: %x\n", Timer); KeInitializeTimerEx(&Timer->KeTimer, TimerType); /* Initialize the Timer Lock */ KeInitializeSpinLock(&Timer->Lock); - + /* Initialize the DPC */ KeInitializeDpc(&Timer->TimerDpc, ExpTimerDpcRoutine, Timer); /* Set Initial State */ Timer->ApcAssociated = FALSE; Timer->WakeTimer = FALSE; - + /* Insert the Timer */ Status = ObInsertObject((PVOID)Timer, NULL, @@ -438,16 +438,16 @@ NtCreateTimer(OUT PHANDLE TimerHandle, &hTimer); DPRINT("Timer Inserted\n"); - + /* Make sure it's safe to write to the handle */ _SEH_TRY { - + *TimerHandle = hTimer; - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } @@ -456,7 +456,7 @@ NtCreateTimer(OUT PHANDLE TimerHandle, } -NTSTATUS +NTSTATUS STDCALL NtOpenTimer(OUT PHANDLE TimerHandle, IN ACCESS_MASK DesiredAccess, @@ -465,25 +465,25 @@ NtOpenTimer(OUT PHANDLE TimerHandle, HANDLE hTimer; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); DPRINT("NtOpenTimer(TimerHandle: %x)\n", TimerHandle); /* Check Parameter Validity */ if (PreviousMode != KernelMode) { - + _SEH_TRY { - + ProbeForWrite(TimerHandle, sizeof(HANDLE), sizeof(ULONG)); - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; - + if(!NT_SUCCESS(Status)) return Status; } @@ -495,19 +495,19 @@ NtOpenTimer(OUT PHANDLE TimerHandle, DesiredAccess, NULL, &hTimer); - + /* Check for success */ if(NT_SUCCESS(Status)) { - + /* Make sure it's safe to write to the handle */ _SEH_TRY { - + *TimerHandle = hTimer; - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } @@ -516,7 +516,7 @@ NtOpenTimer(OUT PHANDLE TimerHandle, } -NTSTATUS +NTSTATUS STDCALL NtQueryTimer(IN HANDLE TimerHandle, IN TIMER_INFORMATION_CLASS TimerInformationClass, @@ -528,7 +528,7 @@ NtQueryTimer(IN HANDLE TimerHandle, KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; PTIMER_BASIC_INFORMATION BasicInfo = (PTIMER_BASIC_INFORMATION)TimerInformation; - + PAGED_CODE(); DPRINT("NtQueryTimer(TimerHandle: %x, Class: %d)\n", TimerHandle, TimerInformationClass); @@ -541,7 +541,7 @@ NtQueryTimer(IN HANDLE TimerHandle, PreviousMode, &Status); if(!NT_SUCCESS(Status)) { - + DPRINT1("NtQueryTimer() failed, Status: 0x%x\n", Status); return Status; } @@ -550,16 +550,16 @@ NtQueryTimer(IN HANDLE TimerHandle, Status = ObReferenceObjectByHandle(TimerHandle, TIMER_QUERY_STATE, ExTimerType, - PreviousMode, + PreviousMode, (PVOID*)&Timer, NULL); - + /* Check for Success */ if(NT_SUCCESS(Status)) { /* Return the Basic Information */ _SEH_TRY { - + /* FIXME: Interrupt correction based on Interrupt Time */ DPRINT("Returning Information for Timer: %x. Time Remaining: %d\n", Timer, Timer->KeTimer.DueTime.QuadPart); BasicInfo->TimeRemaining.QuadPart = Timer->KeTimer.DueTime.QuadPart; @@ -568,20 +568,20 @@ NtQueryTimer(IN HANDLE TimerHandle, if(ReturnLength != NULL) *ReturnLength = sizeof(TIMER_BASIC_INFORMATION); } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; - + /* Dereference Object */ ObDereferenceObject(Timer); } - + /* Return Status */ return Status; } -NTSTATUS +NTSTATUS STDCALL NtSetTimer(IN HANDLE TimerHandle, IN PLARGE_INTEGER DueTime, @@ -600,84 +600,84 @@ NtSetTimer(IN HANDLE TimerHandle, PETHREAD TimerThread; BOOLEAN KillTimer = FALSE; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); DPRINT("NtSetTimer(TimerHandle: %x, DueTime: %d, Apc: %x, Period: %d)\n", TimerHandle, DueTime->QuadPart, TimerApcRoutine, Period); /* Check Parameter Validity */ if (PreviousMode != KernelMode) { - + _SEH_TRY { - + ProbeForRead(DueTime, sizeof(LARGE_INTEGER), sizeof(ULONG)); TimerDueTime = *DueTime; - + if(PreviousState != NULL) { - + ProbeForWrite(PreviousState, sizeof(BOOLEAN), sizeof(BOOLEAN)); } - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; - - if(!NT_SUCCESS(Status)) return Status; + + if(!NT_SUCCESS(Status)) return Status; } - - /* Get the Timer Object */ + + /* Get the Timer Object */ Status = ObReferenceObjectByHandle(TimerHandle, TIMER_ALL_ACCESS, ExTimerType, PreviousMode, (PVOID*)&Timer, NULL); - + /* Check status */ if (NT_SUCCESS(Status)) { - + /* Lock the Timer */ DPRINT("Timer Referencced: %x\n", Timer); KeAcquireSpinLock(&Timer->Lock, &OldIrql); - + /* Cancel Running Timer */ if (Timer->ApcAssociated) { - - /* - * First, remove it from the Thread's Active List + + /* + * First, remove it from the Thread's Active List * Get the Thread. */ TimerThread = CONTAINING_RECORD(Timer->TimerApc.Thread, ETHREAD, Tcb); DPRINT("Thread already running. Removing from Thread: %x\n", TimerThread); - + /* Lock its active list */ KeAcquireSpinLockAtDpcLevel(&TimerThread->ActiveTimerListLock); - + /* Remove it */ RemoveEntryList(&TimerThread->ActiveTimerListHead); - + /* Unlock the list */ KeReleaseSpinLockFromDpcLevel(&TimerThread->ActiveTimerListLock); - + /* Cancel the Timer */ KeCancelTimer(&Timer->KeTimer); KeRemoveQueueDpc(&Timer->TimerDpc); KeRemoveQueueApc(&Timer->TimerApc); Timer->ApcAssociated = FALSE; KillTimer = TRUE; - + } else { - + /* If timer was disabled, we still need to cancel it */ DPRINT("No APCs. Simply cancelling\n"); KeCancelTimer(&Timer->KeTimer); } - + /* Read the State */ State = KeReadStateTimer(&Timer->KeTimer); @@ -685,21 +685,21 @@ NtSetTimer(IN HANDLE TimerHandle, DPRINT("Doing Wake Semantics\n"); KeAcquireSpinLockAtDpcLevel(&ExpWakeListLock); if (WakeTimer && !Timer->WakeTimer) { - + /* Insert it into the list */ Timer->WakeTimer = TRUE; InsertTailList(&ExpWakeList, &Timer->WakeTimerListEntry); } else if (!WakeTimer && Timer->WakeTimer) { - + /* Remove it from the list */ RemoveEntryList(&Timer->WakeTimerListEntry); Timer->WakeTimer = FALSE; } KeReleaseSpinLockFromDpcLevel(&ExpWakeListLock); - + /* Set up the APC Routine if specified */ if (TimerApcRoutine) { - + /* Initialize the APC */ DPRINT("Initializing APC: %x\n", Timer->TimerApc); KeInitializeApc(&Timer->TimerApc, @@ -710,13 +710,13 @@ NtSetTimer(IN HANDLE TimerHandle, (PKNORMAL_ROUTINE)TimerApcRoutine, PreviousMode, TimerContext); - + /* Lock the Thread's Active List and Insert */ KeAcquireSpinLockAtDpcLevel(&CurrentThread->ActiveTimerListLock); InsertTailList(&CurrentThread->ActiveTimerListHead, &Timer->ActiveTimerListEntry); KeReleaseSpinLockFromDpcLevel(&CurrentThread->ActiveTimerListLock); - + } /* Enable and Set the Timer */ @@ -726,13 +726,13 @@ NtSetTimer(IN HANDLE TimerHandle, Period, TimerApcRoutine ? &Timer->TimerDpc : 0); Timer->ApcAssociated = TimerApcRoutine ? TRUE : FALSE; - + /* Unlock the Timer */ KeReleaseSpinLock(&Timer->Lock, OldIrql); /* Dereference the Object */ ObDereferenceObject(Timer); - + /* Dereference if it was previously enabled */ if (!TimerApcRoutine) ObDereferenceObject(Timer); if (KillTimer) ObDereferenceObject(Timer); @@ -740,15 +740,15 @@ NtSetTimer(IN HANDLE TimerHandle, /* Make sure it's safe to write to the handle */ if(PreviousState != NULL) { - + _SEH_TRY { - + *PreviousState = State; - + } _SEH_EXCEPT(_SEH_ExSystemExceptionFilter) { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } } diff --git a/reactos/ntoskrnl/ex/util.c b/reactos/ntoskrnl/ex/util.c index 08758e66ad6..8b502cccdde 100644 --- a/reactos/ntoskrnl/ex/util.c +++ b/reactos/ntoskrnl/ex/util.c @@ -1,5 +1,5 @@ -/* $Id:$ - * +/* $Id$ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/misc.c diff --git a/reactos/ntoskrnl/ex/uuid.c b/reactos/ntoskrnl/ex/uuid.c index 1db7a2a123b..368b52b8eef 100644 --- a/reactos/ntoskrnl/ex/uuid.c +++ b/reactos/ntoskrnl/ex/uuid.c @@ -223,7 +223,7 @@ NtAllocateUuids(OUT PULARGE_INTEGER Time, ULARGE_INTEGER IntTime; ULONG IntRange; NTSTATUS Status; - + PAGED_CODE(); ExAcquireFastMutex(&UuidMutex); @@ -281,7 +281,7 @@ NTSTATUS STDCALL NtSetUuidSeed(IN PUCHAR Seed) { PAGED_CODE(); - + RtlCopyMemory(UuidSeed, Seed, SEED_BUFFER_SIZE); diff --git a/reactos/ntoskrnl/ex/win32k.c b/reactos/ntoskrnl/ex/win32k.c index 6a93e857465..4de1504836f 100644 --- a/reactos/ntoskrnl/ex/win32k.c +++ b/reactos/ntoskrnl/ex/win32k.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/win32k.c * PURPOSE: Executive Win32 subsystem support - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) - Moved callbacks to win32k and cleanup. * Casper S. Hornstrup (chorns@users.sourceforge.net) */ @@ -19,7 +19,7 @@ POBJECT_TYPE EXPORTED ExWindowStationObjectType = NULL; POBJECT_TYPE EXPORTED ExDesktopObjectType = NULL; static GENERIC_MAPPING ExpWindowStationMapping = { - + STANDARD_RIGHTS_READ | WINSTA_ENUMDESKTOPS | WINSTA_ENUMERATE | WINSTA_READATTRIBUTES | WINSTA_READSCREEN, STANDARD_RIGHTS_WRITE | WINSTA_ACCESSCLIPBOARD | WINSTA_CREATEDESKTOP | WINSTA_WRITEATTRIBUTES, STANDARD_RIGHTS_EXECUTE | WINSTA_ACCESSGLOBALATOMS | WINSTA_EXITWINDOWS, @@ -29,7 +29,7 @@ static GENERIC_MAPPING ExpWindowStationMapping = { }; static GENERIC_MAPPING ExpDesktopMapping = { - + STANDARD_RIGHTS_READ | DESKTOP_ENUMERATE | DESKTOP_READOBJECTS, STANDARD_RIGHTS_WRITE | DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | DESKTOP_HOOKCONTROL | DESKTOP_JOURNALPLAYBACK | DESKTOP_JOURNALRECORD | DESKTOP_WRITEOBJECTS, @@ -48,7 +48,7 @@ OBJECT_DELETE_ROUTINE ExpDesktopObjectDelete = NULL; /* FUNCTIONS ****************************************************************/ -NTSTATUS +NTSTATUS STDCALL ExpWinStaObjectCreate(PVOID ObjectBody, PVOID Parent, @@ -56,13 +56,13 @@ ExpWinStaObjectCreate(PVOID ObjectBody, struct _OBJECT_ATTRIBUTES* ObjectAttributes) { /* Call the Registered Callback */ - return ExpWindowStationObjectCreate(ObjectBody, - Parent, - RemainingPath, + return ExpWindowStationObjectCreate(ObjectBody, + Parent, + RemainingPath, ObjectAttributes); } -VOID +VOID STDCALL ExpWinStaObjectDelete(PVOID DeletedObject) { @@ -77,12 +77,12 @@ ExpWinStaObjectFind(PWINSTATION_OBJECT WinStaObject, ULONG Attributes) { /* Call the Registered Callback */ - return ExpWindowStationObjectFind(WinStaObject, - Name, + return ExpWindowStationObjectFind(WinStaObject, + Name, Attributes); } -NTSTATUS +NTSTATUS STDCALL ExpWinStaObjectParse(PVOID Object, PVOID *NextObject, @@ -91,14 +91,14 @@ ExpWinStaObjectParse(PVOID Object, ULONG Attributes) { /* Call the Registered Callback */ - return ExpWindowStationObjectParse(Object, - NextObject, - FullPath, + return ExpWindowStationObjectParse(Object, + NextObject, + FullPath, Path, Attributes); } -NTSTATUS +NTSTATUS STDCALL ExpDesktopCreate(PVOID ObjectBody, PVOID Parent, @@ -106,13 +106,13 @@ ExpDesktopCreate(PVOID ObjectBody, struct _OBJECT_ATTRIBUTES* ObjectAttributes) { /* Call the Registered Callback */ - return ExpDesktopObjectCreate(ObjectBody, - Parent, - RemainingPath, + return ExpDesktopObjectCreate(ObjectBody, + Parent, + RemainingPath, ObjectAttributes); } -VOID +VOID STDCALL ExpDesktopDelete(PVOID DeletedObject) { @@ -120,7 +120,7 @@ ExpDesktopDelete(PVOID DeletedObject) ExpDesktopObjectDelete(DeletedObject); } -VOID +VOID INIT_FUNCTION ExpWin32kInit(VOID) { diff --git a/reactos/ntoskrnl/ex/work.c b/reactos/ntoskrnl/ex/work.c index 844c5a34177..90608d161f5 100644 --- a/reactos/ntoskrnl/ex/work.c +++ b/reactos/ntoskrnl/ex/work.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ex/work.c * PURPOSE: Manage system work queues - * + * * PROGRAMMERS: Alex Ionescu - Used correct work queue array and added some fixes and checks. * Gunnar Dalsnes - Implemented */ @@ -38,7 +38,7 @@ EX_WORK_QUEUE ExWorkerQueue[MaximumWorkQueue]; * calls PsTerminateSystemThread */ static -VOID +VOID STDCALL ExpWorkerThreadEntryPoint(IN PVOID Context) { @@ -46,53 +46,53 @@ ExpWorkerThreadEntryPoint(IN PVOID Context) PLIST_ENTRY QueueEntry; WORK_QUEUE_TYPE WorkQueueType; PEX_WORK_QUEUE WorkQueue; - + /* Get Queue Type and Worker Queue */ WorkQueueType = (WORK_QUEUE_TYPE)Context; WorkQueue = &ExWorkerQueue[WorkQueueType]; - + /* Loop forever */ while (TRUE) { - + /* Wait for Something to Happen on the Queue */ QueueEntry = KeRemoveQueue(&WorkQueue->WorkerQueue, KernelMode, NULL); - + /* Can't happen since we do a KernelMode wait (and we're a system thread) */ ASSERT((NTSTATUS)QueueEntry != STATUS_USER_APC); - + /* this should never happen either, since we wait with NULL timeout, * but there's a slight possibility that STATUS_TIMEOUT is returned * at queue rundown in NT (unlikely) -Gunnar */ ASSERT((NTSTATUS)QueueEntry != STATUS_TIMEOUT); - + /* Increment Processed Work Items */ InterlockedIncrement((PLONG)&WorkQueue->WorkItemsProcessed); /* Get the Work Item */ WorkItem = CONTAINING_RECORD(QueueEntry, WORK_QUEUE_ITEM, List); - + /* Call the Worker Routine */ WorkItem->WorkerRoutine(WorkItem->Parameter); - + /* Make sure it returned at right IRQL */ if (KeGetCurrentIrql() != PASSIVE_LEVEL) { - + /* FIXME: Make this an Ex */ KEBUGCHECK(WORKER_THREAD_RETURNED_AT_BAD_IRQL); } - + /* Make sure it returned with Impersionation Disabled */ if (PsGetCurrentThread()->ActiveImpersonationInfo) { - + /* FIXME: Make this an Ex */ KEBUGCHECK(IMPERSONATING_WORKER_THREAD); } } } -static -VOID +static +VOID STDCALL ExpInitializeWorkQueue(WORK_QUEUE_TYPE WorkQueueType, KPRIORITY Priority) @@ -100,10 +100,10 @@ ExpInitializeWorkQueue(WORK_QUEUE_TYPE WorkQueueType, ULONG i; PETHREAD Thread; HANDLE hThread; - + /* Loop through how many threads we need to create */ for (i = 0; i < NUMBER_OF_WORKER_THREADS; i++) { - + /* Create the System Thread */ PsCreateSystemThread(&hThread, THREAD_ALL_ACCESS, @@ -112,7 +112,7 @@ ExpInitializeWorkQueue(WORK_QUEUE_TYPE WorkQueueType, NULL, ExpWorkerThreadEntryPoint, (PVOID)WorkQueueType); - + /* Get the Thread */ ObReferenceObjectByHandle(hThread, THREAD_SET_INFORMATION, @@ -120,29 +120,29 @@ ExpInitializeWorkQueue(WORK_QUEUE_TYPE WorkQueueType, KernelMode, (PVOID*)&Thread, NULL); - + /* Set the Priority */ KeSetPriorityThread(&Thread->Tcb, Priority); - + /* Dereference and close handle */ ObDereferenceObject(Thread); ZwClose(hThread); } } -VOID +VOID INIT_FUNCTION ExpInitializeWorkerThreads(VOID) { ULONG WorkQueueType; - + /* Initialize the Array */ for (WorkQueueType = 0; WorkQueueType < MaximumWorkQueue; WorkQueueType++) { - + RtlZeroMemory(&ExWorkerQueue[WorkQueueType], sizeof(EX_WORK_QUEUE)); KeInitializeQueue(&ExWorkerQueue[WorkQueueType].WorkerQueue, 0); } - + /* Create the built-in worker threads for each work queue */ ExpInitializeWorkQueue(CriticalWorkQueue, LOW_REALTIME_PRIORITY); ExpInitializeWorkQueue(DelayedWorkQueue, LOW_PRIORITY); @@ -158,7 +158,7 @@ ExpInitializeWorkerThreads(VOID) * WorkItem = Item to insert * QueueType = Queue to insert it in */ -VOID +VOID STDCALL ExQueueWorkItem(PWORK_QUEUE_ITEM WorkItem, WORK_QUEUE_TYPE QueueType) @@ -166,7 +166,7 @@ ExQueueWorkItem(PWORK_QUEUE_ITEM WorkItem, ASSERT(WorkItem!=NULL); ASSERT_IRQL(DISPATCH_LEVEL); ASSERT(WorkItem->List.Flink == NULL); - + /* Insert the Queue */ KeInsertQueue(&ExWorkerQueue[QueueType].WorkerQueue, &WorkItem->List); } diff --git a/reactos/ntoskrnl/ex/zone.c b/reactos/ntoskrnl/ex/zone.c index c606d6afe75..e70f3c3f7ac 100644 --- a/reactos/ntoskrnl/ex/zone.c +++ b/reactos/ntoskrnl/ex/zone.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/zone.c * PURPOSE: Implements zone buffers - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -37,18 +37,18 @@ ExExtendZone ( PZONE_SEGMENT_HEADER entry; PZONE_SEGMENT_HEADER seg; unsigned int i; - + seg = (PZONE_SEGMENT_HEADER)Segment; seg->Reserved = (PVOID) SegmentSize; - + PushEntryList(&Zone->SegmentList,&seg->SegmentList); - + entry = (PZONE_SEGMENT_HEADER)( ((char*)seg) + sizeof(ZONE_SEGMENT_HEADER) ); - + for (i=0;i<(SegmentSize / Zone->BlockSize);i++) { PushEntryList(&Zone->FreeList,&entry->SegmentList); - entry = (PZONE_SEGMENT_HEADER)(((char*)entry) + sizeof(PZONE_SEGMENT_HEADER) + + entry = (PZONE_SEGMENT_HEADER)(((char*)entry) + sizeof(PZONE_SEGMENT_HEADER) + Zone->BlockSize); } return(STATUS_SUCCESS); @@ -69,7 +69,7 @@ ExInterlockedExtendZone ( { NTSTATUS ret; KIRQL oldlvl; - + KeAcquireSpinLock(Lock,&oldlvl); ret = ExExtendZone(Zone,Segment,SegmentSize); KeReleaseSpinLock(Lock,oldlvl); @@ -93,7 +93,7 @@ ExInitializeZone ( * ARGUMENTS: * Zone = zone header to be initialized * BlockSize = Size (in bytes) of the allocation size of the zone - * InitialSegment = Initial segment of storage allocated by the + * InitialSegment = Initial segment of storage allocated by the * caller * InitialSegmentSize = Initial size of the segment */ @@ -101,19 +101,19 @@ ExInitializeZone ( unsigned int i; PZONE_SEGMENT_HEADER seg; PZONE_SEGMENT_HEADER entry; - + Zone->FreeList.Next=NULL; Zone->SegmentList.Next=NULL; Zone->BlockSize=BlockSize; Zone->TotalSegmentSize = InitialSegmentSize; - + seg = (PZONE_SEGMENT_HEADER)InitialSegment; seg->Reserved = (PVOID*) InitialSegmentSize; - + PushEntryList(&Zone->SegmentList,&seg->SegmentList); - + entry = (PZONE_SEGMENT_HEADER)( ((char*)seg) + sizeof(ZONE_SEGMENT_HEADER) ); - + for (i=0;i<(InitialSegmentSize / BlockSize);i++) { PushEntryList(&Zone->FreeList,&entry->SegmentList); diff --git a/reactos/ntoskrnl/fs/fastio.c b/reactos/ntoskrnl/fs/fastio.c index bbdae43617a..71fe6d28e7a 100644 --- a/reactos/ntoskrnl/fs/fastio.c +++ b/reactos/ntoskrnl/fs/fastio.c @@ -72,7 +72,7 @@ FsRtlIncrementCcFastReadNoWait( VOID ) * * NOTE * From Bo Branten's ntifs.h v12. - * + * * @unimplemented */ BOOLEAN @@ -99,7 +99,7 @@ FsRtlCopyRead(IN PFILE_OBJECT FileObject, * ARGUMENTS * * RETURN VALUE - * + * * NOTE * From Bo Branten's ntifs.h v12. * @@ -129,7 +129,7 @@ FsRtlCopyWrite(IN PFILE_OBJECT FileObject, * ARGUMENTS * * RETURN VALUE - * + * * @implemented */ NTSTATUS @@ -143,16 +143,16 @@ FsRtlGetFileSize(IN PFILE_OBJECT FileObject, ULONG Length; PDEVICE_OBJECT DeviceObject; PFAST_IO_DISPATCH FastDispatch; - + /* Get Device Object and Fast Calls */ DeviceObject = IoGetRelatedDeviceObject(FileObject); FastDispatch = DeviceObject->DriverObject->FastIoDispatch; - + /* Check if we support Fast Calls, and check this one */ - if (FastDispatch && FastDispatch->FastIoQueryStandardInfo) + if (FastDispatch && FastDispatch->FastIoQueryStandardInfo) { /* Fast Path */ - FastDispatch->FastIoQueryStandardInfo(FileObject, + FastDispatch->FastIoQueryStandardInfo(FileObject, TRUE, &Info, &IoStatusBlock, @@ -168,7 +168,7 @@ FsRtlGetFileSize(IN PFILE_OBJECT FileObject, &Info, &Length); } - + /* Check success */ if (NT_SUCCESS(Status)) { @@ -202,11 +202,11 @@ FsRtlMdlRead(IN PFILE_OBJECT FileObject, { PDEVICE_OBJECT DeviceObject, BaseDeviceObject; PFAST_IO_DISPATCH FastDispatch; - + /* Get Device Object and Fast Calls */ DeviceObject = IoGetRelatedDeviceObject(FileObject); FastDispatch = DeviceObject->DriverObject->FastIoDispatch; - + /* Check if we support Fast Calls, and check this one */ if (FastDispatch && FastDispatch->MdlRead) { @@ -219,18 +219,18 @@ FsRtlMdlRead(IN PFILE_OBJECT FileObject, IoStatus, DeviceObject); } - + /* Get the Base File System (Volume) and Fast Calls */ BaseDeviceObject = IoGetBaseFileSystemDeviceObject(FileObject); FastDispatch = BaseDeviceObject->DriverObject->FastIoDispatch; - + /* If the Base Device Object has its own FastDispatch Routine, fail */ - if (FastDispatch && FastDispatch->MdlRead && + if (FastDispatch && FastDispatch->MdlRead && BaseDeviceObject != DeviceObject) { return FALSE; } - + /* No fast path, use slow path */ return FsRtlMdlReadDev(FileObject, FileOffset, @@ -253,18 +253,18 @@ FsRtlMdlRead(IN PFILE_OBJECT FileObject, * * @implemented */ -BOOLEAN +BOOLEAN STDCALL FsRtlMdlReadComplete(IN PFILE_OBJECT FileObject, IN OUT PMDL MdlChain) { PDEVICE_OBJECT DeviceObject, BaseDeviceObject; PFAST_IO_DISPATCH FastDispatch; - + /* Get Device Object and Fast Calls */ DeviceObject = IoGetRelatedDeviceObject(FileObject); FastDispatch = DeviceObject->DriverObject->FastIoDispatch; - + /* Check if we support Fast Calls, and check this one */ if (FastDispatch && FastDispatch->MdlReadComplete) { @@ -273,18 +273,18 @@ FsRtlMdlReadComplete(IN PFILE_OBJECT FileObject, MdlChain, DeviceObject); } - + /* Get the Base File System (Volume) and Fast Calls */ BaseDeviceObject = IoGetBaseFileSystemDeviceObject(FileObject); FastDispatch = BaseDeviceObject->DriverObject->FastIoDispatch; - + /* If the Base Device Object has its own FastDispatch Routine, fail */ - if (FastDispatch && FastDispatch->MdlReadComplete && + if (FastDispatch && FastDispatch->MdlReadComplete && BaseDeviceObject != DeviceObject) { return FALSE; } - + /* No fast path, use slow path */ return FsRtlMdlReadCompleteDev(FileObject, MdlChain, DeviceObject); } @@ -364,11 +364,11 @@ FsRtlMdlWriteComplete(IN PFILE_OBJECT FileObject, { PDEVICE_OBJECT DeviceObject, BaseDeviceObject; PFAST_IO_DISPATCH FastDispatch; - + /* Get Device Object and Fast Calls */ DeviceObject = IoGetRelatedDeviceObject(FileObject); FastDispatch = DeviceObject->DriverObject->FastIoDispatch; - + /* Check if we support Fast Calls, and check this one */ if (FastDispatch && FastDispatch->MdlWriteComplete) { @@ -378,22 +378,22 @@ FsRtlMdlWriteComplete(IN PFILE_OBJECT FileObject, MdlChain, DeviceObject); } - + /* Get the Base File System (Volume) and Fast Calls */ BaseDeviceObject = IoGetBaseFileSystemDeviceObject(FileObject); FastDispatch = BaseDeviceObject->DriverObject->FastIoDispatch; - + /* If the Base Device Object has its own FastDispatch Routine, fail */ - if (FastDispatch && FastDispatch->MdlWriteComplete && + if (FastDispatch && FastDispatch->MdlWriteComplete && BaseDeviceObject != DeviceObject) { return FALSE; } - + /* No fast path, use slow path */ - return FsRtlMdlWriteCompleteDev(FileObject, - FileOffset, - MdlChain, + return FsRtlMdlWriteCompleteDev(FileObject, + FileOffset, + MdlChain, DeviceObject); } @@ -402,7 +402,7 @@ FsRtlMdlWriteComplete(IN PFILE_OBJECT FileObject, * FsRtlMdlWriteCompleteDev@16 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -445,11 +445,11 @@ FsRtlPrepareMdlWrite(IN PFILE_OBJECT FileObject, { PDEVICE_OBJECT DeviceObject, BaseDeviceObject; PFAST_IO_DISPATCH FastDispatch; - + /* Get Device Object and Fast Calls */ DeviceObject = IoGetRelatedDeviceObject(FileObject); FastDispatch = DeviceObject->DriverObject->FastIoDispatch; - + /* Check if we support Fast Calls, and check this one */ if (FastDispatch && FastDispatch->PrepareMdlWrite) { @@ -462,18 +462,18 @@ FsRtlPrepareMdlWrite(IN PFILE_OBJECT FileObject, IoStatus, DeviceObject); } - + /* Get the Base File System (Volume) and Fast Calls */ BaseDeviceObject = IoGetBaseFileSystemDeviceObject(FileObject); FastDispatch = BaseDeviceObject->DriverObject->FastIoDispatch; - + /* If the Base Device Object has its own FastDispatch Routine, fail */ - if (FastDispatch && FastDispatch->PrepareMdlWrite && + if (FastDispatch && FastDispatch->PrepareMdlWrite && BaseDeviceObject != DeviceObject) { return FALSE; } - + /* No fast path, use slow path */ return FsRtlPrepareMdlWriteDev(FileObject, FileOffset, @@ -489,7 +489,7 @@ FsRtlPrepareMdlWrite(IN PFILE_OBJECT FileObject, * FsRtlPrepareMdlWriteDev@28 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE diff --git a/reactos/ntoskrnl/fs/filelock.c b/reactos/ntoskrnl/fs/filelock.c index be9e2108fbf..577f2f88fcb 100644 --- a/reactos/ntoskrnl/fs/filelock.c +++ b/reactos/ntoskrnl/fs/filelock.c @@ -27,7 +27,7 @@ PAGED_LOOKASIDE_LIST LockLookaside; -inline BOOLEAN +inline BOOLEAN IsOverlappingLock( PFILE_LOCK_INFO Lock, PLARGE_INTEGER StartOffset, @@ -36,32 +36,32 @@ IsOverlappingLock( { if ((ULONGLONG)StartOffset->QuadPart > (ULONGLONG)Lock->EndingByte.QuadPart) { - return FALSE; + return FALSE; } - + if ((ULONGLONG)EndOffset->QuadPart < (ULONGLONG)Lock->StartingByte.QuadPart) { - return FALSE; + return FALSE; } - - return TRUE; + + return TRUE; } -inline BOOLEAN +inline BOOLEAN IsSurroundingLock( PFILE_LOCK_INFO Lock, PLARGE_INTEGER StartOffset, PLARGE_INTEGER EndOffset ) { - if ((ULONGLONG)StartOffset->QuadPart >= (ULONGLONG)Lock->StartingByte.QuadPart && + if ((ULONGLONG)StartOffset->QuadPart >= (ULONGLONG)Lock->StartingByte.QuadPart && (ULONGLONG)EndOffset->QuadPart <= (ULONGLONG)Lock->EndingByte.QuadPart) { - return TRUE; + return TRUE; } - - return FALSE; + + return FALSE; } @@ -102,7 +102,7 @@ FsRtlpInitFileLockingImplementation(VOID) ); ExInitializeFastMutex(&LockTocMutex); - + } /********************************************************************** @@ -111,9 +111,9 @@ FsRtlpInitFileLockingImplementation(VOID) * */ VOID -STDCALL +STDCALL FsRtlpFileLockCancelRoutine( - IN PDEVICE_OBJECT DeviceObject, + IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ) { @@ -121,28 +121,28 @@ FsRtlpFileLockCancelRoutine( PKSPIN_LOCK SpinLock; //don't need this since we have our own sync. protecting irp cancellation - IoReleaseCancelSpinLock(Irp->CancelIrql); + IoReleaseCancelSpinLock(Irp->CancelIrql); SpinLock = Irp->Tail.Overlay.DriverContext[3]; KeAcquireSpinLock(SpinLock, &oldIrql); - + RemoveEntryList(&Irp->Tail.Overlay.ListEntry); - + KeReleaseSpinLock(SpinLock, oldIrql); Irp->IoStatus.Status = STATUS_CANCELLED; Irp->IoStatus.Information = 0; IoCompleteRequest(Irp, IO_NO_INCREMENT); - + } /********************************************************************** * NAME PRIVATE * FsRtlpCheckLockForReadOrWriteAccess * - * Return: + * Return: * TRUE: can read/write * FALSE: can't read/write */ @@ -163,12 +163,12 @@ FsRtlpCheckLockForReadOrWriteAccess( PFILE_LOCK_GRANTED Granted; PLIST_ENTRY EnumEntry; LARGE_INTEGER EndOffset; - + ASSERT(FileLock); - + LockToc = FileLock->LockInformation; - if (LockToc == NULL || Length->QuadPart == 0) + if (LockToc == NULL || Length->QuadPart == 0) { return TRUE; } @@ -180,17 +180,17 @@ FsRtlpCheckLockForReadOrWriteAccess( LIST_FOR_EACH(EnumEntry, &LockToc->GrantedListHead) { Granted = CONTAINING_RECORD(EnumEntry, FILE_LOCK_GRANTED, ListEntry); - + //if overlapping - if(IsOverlappingLock(&Granted->Lock, FileOffset, &EndOffset)) + if(IsOverlappingLock(&Granted->Lock, FileOffset, &EndOffset)) { //No read conflict if (shared lock) OR (exclusive + our lock) //No write conflict if exclusive lock AND our lock if ((Read && !Granted->Lock.ExclusiveLock) || - (Granted->Lock.ExclusiveLock && + (Granted->Lock.ExclusiveLock && Granted->Lock.Process == Process && Granted->Lock.FileObject == FileObject && - Granted->Lock.Key == Key ) ) + Granted->Lock.Key == Key ) ) { //AND if lock surround request region, stop searching and grant if (IsSurroundingLock(&Granted->Lock, FileOffset, &EndOffset) ) @@ -198,7 +198,7 @@ FsRtlpCheckLockForReadOrWriteAccess( KeReleaseSpinLock(&LockToc->SpinLock, oldirql); return TRUE; } - + //else continue searching for conflicts continue; } @@ -376,10 +376,10 @@ FsRtlpFastUnlockAllByKey( InitializeListHead(&UnlockedListHead); GotUnlockRoutine = FileLock->UnlockRoutine != NULL; KeAcquireSpinLock(&LockToc->SpinLock, &oldirql); - + LIST_FOR_EACH_SAFE(EnumEntry, &LockToc->GrantedListHead, Granted, FILE_LOCK_GRANTED, ListEntry) { - + if (Granted->Lock.Process == Process && Granted->Lock.FileObject == FileObject && (!UseKey || (UseKey && Granted->Lock.Key == Key)) ) @@ -387,7 +387,7 @@ FsRtlpFastUnlockAllByKey( RemoveEntryList(&Granted->ListEntry); Unlock = TRUE; - if (GotUnlockRoutine) + if (GotUnlockRoutine) { /* Put on unlocked list and call unlock routine for them afterwards. @@ -395,23 +395,23 @@ FsRtlpFastUnlockAllByKey( */ InsertHeadList(&UnlockedListHead,&Granted->ListEntry); } - else + else { - ExFreeToNPagedLookasideList(&GrantedLookaside,Granted); + ExFreeToNPagedLookasideList(&GrantedLookaside,Granted); } } } KeReleaseSpinLock(&LockToc->SpinLock, oldirql); - + if (Unlock) { //call unlock routine for each unlocked lock (if any) - while (!IsListEmpty(&UnlockedListHead)) + while (!IsListEmpty(&UnlockedListHead)) { EnumEntry = RemoveTailList(&UnlockedListHead); Granted = CONTAINING_RECORD(EnumEntry,FILE_LOCK_GRANTED, ListEntry); - + FileLock->UnlockRoutine(Granted->UnlockContext, &Granted->Lock); ExFreeToNPagedLookasideList(&GrantedLookaside,Granted); } @@ -420,7 +420,7 @@ FsRtlpFastUnlockAllByKey( KeAcquireSpinLock(&LockToc->SpinLock, &oldirql); FsRtlpCompletePendingLocks(FileLock, LockToc, &oldirql, Context); - if (IsListEmpty(&LockToc->GrantedListHead)) + if (IsListEmpty(&LockToc->GrantedListHead)) { KeReleaseSpinLock(&LockToc->SpinLock, oldirql); FsRtlAreThereCurrentFileLocks(FileLock) = FALSE; @@ -429,7 +429,7 @@ FsRtlpFastUnlockAllByKey( { KeReleaseSpinLock(&LockToc->SpinLock, oldirql); } - + return STATUS_SUCCESS; } @@ -456,7 +456,7 @@ FsRtlFastUnlockAll /*ByProcess*/ ( Process, 0, /* Key is ignored */ FALSE, /* Do NOT use Key */ - Context + Context ); } @@ -481,7 +481,7 @@ FsRtlFastUnlockAllByKey ( Process, Key, TRUE, /* Use Key */ - Context + Context ); } @@ -509,20 +509,20 @@ FsRtlpAddLock( PLIST_ENTRY EnumEntry; PFILE_LOCK_GRANTED Granted; LARGE_INTEGER EndOffset; - + EndOffset.QuadPart = FileOffset->QuadPart + Length->QuadPart - 1; //loop and try to find conflicking locks LIST_FOR_EACH(EnumEntry, &LockToc->GrantedListHead) { Granted = CONTAINING_RECORD(EnumEntry,FILE_LOCK_GRANTED, ListEntry); - + if (IsOverlappingLock(&Granted->Lock, FileOffset, &EndOffset)) { //we found a locks that overlap with the new lock - + //if both locks are shared, we might have a fast path outa here... - if (!Granted->Lock.ExclusiveLock && !ExclusiveLock) + if (!Granted->Lock.ExclusiveLock && !ExclusiveLock) { //if existing lock surround new lock, we know that no other exclusive lock //may overlap with our new lock;-D @@ -530,12 +530,12 @@ FsRtlpAddLock( { break; } - + //else keep locking for conflicts continue; } - - //we found a conflict: + + //we found a conflict: //we want shared access to an excl. lock OR exlc. access to a shared lock return FALSE; } @@ -581,10 +581,10 @@ FsRtlpCompletePendingLocks( PIRP Irp; PIO_STACK_LOCATION Stack; LIST_ENTRY CompletedListHead; - + InitializeListHead(&CompletedListHead); - - LIST_FOR_EACH_SAFE(EnumEntry, &LockToc->PendingListHead, Irp, IRP, Tail.Overlay.ListEntry) + + LIST_FOR_EACH_SAFE(EnumEntry, &LockToc->PendingListHead, Irp, IRP, Tail.Overlay.ListEntry) { Stack = IoGetCurrentIrpStackLocation(Irp); if (FsRtlpAddLock(LockToc, @@ -595,7 +595,7 @@ FsRtlpCompletePendingLocks( Stack->Parameters.LockControl.Key, Stack->Flags & SL_EXCLUSIVE_LOCK, Irp->Tail.Overlay.DriverContext[2] //Context - ) ) + ) ) { RemoveEntryList(&Irp->Tail.Overlay.ListEntry); @@ -615,12 +615,12 @@ FsRtlpCompletePendingLocks( } KeReleaseSpinLock(&LockToc->SpinLock, *oldirql); - + //complete irp's (if any) - while (!IsListEmpty(&CompletedListHead)) + while (!IsListEmpty(&CompletedListHead)) { EnumEntry = RemoveTailList(&CompletedListHead); - + Irp = CONTAINING_RECORD(EnumEntry, IRP, Tail.Overlay.ListEntry); Irp->IoStatus.Status = STATUS_SUCCESS; @@ -631,8 +631,8 @@ FsRtlpCompletePendingLocks( if (FileLock->CompleteLockIrpRoutine(Context, Irp)!=STATUS_SUCCESS) { Stack = IoGetCurrentIrpStackLocation(Irp); - - //revert + + //revert FsRtlpUnlockSingle ( FileLock, Stack->FileObject, &Stack->Parameters.LockControl.ByteOffset, @@ -689,15 +689,15 @@ FsRtlpUnlockSingle( KeAcquireSpinLock(&LockToc->SpinLock, &oldirql ); - LIST_FOR_EACH_SAFE(EnumEntry, &LockToc->GrantedListHead, Granted,FILE_LOCK_GRANTED,ListEntry) + LIST_FOR_EACH_SAFE(EnumEntry, &LockToc->GrantedListHead, Granted,FILE_LOCK_GRANTED,ListEntry) { - + //must be exact match if (FileOffset->QuadPart == Granted->Lock.StartingByte.QuadPart && Length->QuadPart == Granted->Lock.Length.QuadPart && Granted->Lock.Process == Process && Granted->Lock.FileObject == FileObject && - Granted->Lock.Key == Key) + Granted->Lock.Key == Key) { RemoveEntryList(&Granted->ListEntry); FsRtlpCompletePendingLocks(FileLock, LockToc, &oldirql, Context); @@ -705,7 +705,7 @@ FsRtlpUnlockSingle( if (IsListEmpty(&LockToc->GrantedListHead)) { KeReleaseSpinLock(&LockToc->SpinLock, oldirql); - + FsRtlAreThereCurrentFileLocks(FileLock) = FALSE; //paged data } else @@ -784,7 +784,7 @@ FsRtlpDumpFileLocks( ASSERT(FileLock); LockToc = FileLock->LockInformation; - if (LockToc == NULL) + if (LockToc == NULL) { DPRINT1("No file locks\n"); return; @@ -797,7 +797,7 @@ FsRtlpDumpFileLocks( LIST_FOR_EACH(EnumEntry, &LockToc->GrantedListHead) { Granted = CONTAINING_RECORD(EnumEntry, FILE_LOCK_GRANTED , ListEntry); - + DPRINT1("%s, start: %i, len: %i, end: %i, key: %i, proc: 0x%X, fob: 0x%X\n", Granted->Lock.ExclusiveLock ? "EXCL" : "SHRD", Granted->Lock.StartingByte.QuadPart, @@ -852,7 +852,7 @@ FsRtlGetNextFileLock ( { /* Messy enumeration of granted locks. - What our last ptr. in LastReturnedLock points at, might have been freed between + What our last ptr. in LastReturnedLock points at, might have been freed between calls, so we have to scan thru the list every time, searching for our last lock. If it's not there anymore, restart the enumeration... */ @@ -892,7 +892,7 @@ restart:; FileLock->LastReturnedLock = EnumEntry; return &FileLock->LastReturnedLockInfo; } - else + else { KeReleaseSpinLock(&LockToc->SpinLock,oldirql); return NULL; @@ -900,10 +900,10 @@ restart:; } //else: continue enum - while (EnumEntry != &LockToc->GrantedListHead) + while (EnumEntry != &LockToc->GrantedListHead) { //found previous lock? - if (EnumEntry == LocalLastReturnedLock) + if (EnumEntry == LocalLastReturnedLock) { FoundPrevious = TRUE; //get next @@ -923,7 +923,7 @@ restart:; EnumEntry = EnumEntry->Flink; } - if (!FoundPrevious) + if (!FoundPrevious) { //got here? uh no, didn't find our last lock..must have been freed...restart Restart = TRUE; @@ -989,7 +989,7 @@ FsRtlPrivateLock ( KIRQL oldirql; ASSERT(FileLock); - if (FileLock->LockInformation == NULL) + if (FileLock->LockInformation == NULL) { ExAcquireFastMutex(&LockTocMutex); //still NULL? @@ -1015,24 +1015,24 @@ FsRtlPrivateLock ( Process, Key, ExclusiveLock, - Context - ) ) + Context + ) ) { IoStatus->Status = STATUS_SUCCESS; } - else if (Irp && !FailImmediately) - { + else if (Irp && !FailImmediately) + { //failed + irp + no fail = make. pending Irp->Tail.Overlay.DriverContext[3] = &LockToc->SpinLock; Irp->Tail.Overlay.DriverContext[2] = Context; - + IoSetCancelRoutine(Irp, FsRtlpFileLockCancelRoutine); if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL)) - { + { //irp was canceled KeReleaseSpinLock(&LockToc->SpinLock, oldirql); - + Irp->IoStatus.Status = STATUS_CANCELLED; Irp->IoStatus.Information = 0; IoCompleteRequest(Irp, IO_NO_INCREMENT); @@ -1046,7 +1046,7 @@ FsRtlPrivateLock ( InsertHeadList(&LockToc->PendingListHead,&Irp->Tail.Overlay.ListEntry); } - else + else { IoStatus->Status = STATUS_LOCK_NOT_GRANTED; } @@ -1056,20 +1056,20 @@ FsRtlPrivateLock ( //never pending if no irp;-) ASSERT(!(IoStatus->Status == STATUS_PENDING && !Irp)); - if (IoStatus->Status != STATUS_PENDING) + if (IoStatus->Status != STATUS_PENDING) { - if (IoStatus->Status == STATUS_SUCCESS) + if (IoStatus->Status == STATUS_SUCCESS) { FsRtlAreThereCurrentFileLocks(FileLock) = TRUE; } - if (Irp) + if (Irp) { Irp->IoStatus.Status = IoStatus->Status; Irp->IoStatus.Information = 0; - if (FileLock->CompleteLockIrpRoutine) + if (FileLock->CompleteLockIrpRoutine) { - if (FileLock->CompleteLockIrpRoutine(Context,Irp)!=STATUS_SUCCESS) + if (FileLock->CompleteLockIrpRoutine(Context,Irp)!=STATUS_SUCCESS) { //CompleteLockIrpRoutine complain: revert changes FsRtlpUnlockSingle( FileLock, @@ -1083,7 +1083,7 @@ FsRtlPrivateLock ( ); } } - else + else { IoCompleteRequest(Irp, IO_NO_INCREMENT); } @@ -1145,7 +1145,7 @@ FsRtlProcessFileLock ( Stack->Parameters.LockControl.Length, IoGetRequestorProcess(Irp), Stack->Parameters.LockControl.Key, - Context, + Context, FALSE); break; @@ -1174,7 +1174,7 @@ FsRtlProcessFileLock ( Irp->IoStatus.Status = Status; Irp->IoStatus.Information = 0; - + IoCompleteRequest(Irp,IO_NO_INCREMENT); return Status; @@ -1210,7 +1210,7 @@ FsRtlUninitializeFileLock ( KeAcquireSpinLock(&LockToc->SpinLock, &oldirql); //remove and free granted locks - while (!IsListEmpty(&LockToc->GrantedListHead)) + while (!IsListEmpty(&LockToc->GrantedListHead)) { EnumEntry = RemoveTailList(&LockToc->GrantedListHead); Granted = CONTAINING_RECORD(EnumEntry, FILE_LOCK_GRANTED, ListEntry); @@ -1218,13 +1218,13 @@ FsRtlUninitializeFileLock ( } //remove, complete and free all pending locks - while (!IsListEmpty(&LockToc->PendingListHead)) + while (!IsListEmpty(&LockToc->PendingListHead)) { EnumEntry = RemoveTailList(&LockToc->PendingListHead); Irp = CONTAINING_RECORD(EnumEntry, IRP, Tail.Overlay.ListEntry); if (!IoSetCancelRoutine(Irp, NULL)) - { + { //The cancel routine will be called. When we release the lock it will complete the irp. InitializeListHead(&Irp->Tail.Overlay.ListEntry); continue; @@ -1313,10 +1313,10 @@ FsRtlAcquireFileExclusive( PFAST_IO_DISPATCH FastDispatch; PDEVICE_OBJECT DeviceObject; PFSRTL_COMMON_FCB_HEADER FcbHeader; - + /* Get the Device Object */ DeviceObject = IoGetBaseFileSystemDeviceObject(FileObject); - + /* Check if we have to do a Fast I/O Dispatch */ if ((FastDispatch = DeviceObject->DriverObject->FastIoDispatch)) { @@ -1324,19 +1324,19 @@ FsRtlAcquireFileExclusive( if (FastDispatch->AcquireFileForNtCreateSection) { FastDispatch->AcquireFileForNtCreateSection(FileObject); } - + return; } - + /* Do a normal acquire */ if ((FcbHeader = (PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext)) { - + /* Use a Resource Acquire */ ExAcquireResourceExclusive(FcbHeader->Resource, TRUE); - + return; } - + /* Return...is there some kind of failure we should raise?? */ return; } @@ -1353,30 +1353,30 @@ FsRtlReleaseFile( PFAST_IO_DISPATCH FastDispatch; PDEVICE_OBJECT DeviceObject; PFSRTL_COMMON_FCB_HEADER FcbHeader; - + /* Get the Device Object */ DeviceObject = IoGetBaseFileSystemDeviceObject(FileObject); - + /* Check if we have to do a Fast I/O Dispatch */ if ((FastDispatch = DeviceObject->DriverObject->FastIoDispatch)) { - + /* Use Fast I/O */ if (FastDispatch->ReleaseFileForNtCreateSection) { FastDispatch->ReleaseFileForNtCreateSection(FileObject); } - + return; } - + /* Do a normal acquire */ if ((FcbHeader = (PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext)) { - + /* Use a Resource Release */ ExReleaseResource(FcbHeader->Resource); - + return; } - + /* Return...is there some kind of failure we should raise?? */ return; } diff --git a/reactos/ntoskrnl/fs/mcb.c b/reactos/ntoskrnl/fs/mcb.c index 430d747447f..dd972908505 100644 --- a/reactos/ntoskrnl/fs/mcb.c +++ b/reactos/ntoskrnl/fs/mcb.c @@ -15,7 +15,7 @@ * NAME EXPORTED * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -87,12 +87,12 @@ FsRtlGetNextMcbEntry (IN PMCB Mcb, &llVbn, &llLbn, &llSectorCount); - + /* Return everything typecasted */ *Vbn = (ULONG)llVbn; *Lbn = (ULONG)llLbn; *SectorCount = (ULONG)llSectorCount; - + /* And return the original value */ return(Return); } @@ -212,11 +212,11 @@ FsRtlLookupLastMcbEntry(IN PMCB Mcb, Return = FsRtlLookupLastLargeMcbEntry(&Mcb->LargeMcb, &llVbn, &llLbn); - + /* Return everything typecasted */ *Vbn = (ULONG)llVbn; *Lbn = (ULONG)llLbn; - + /* And return the original value */ return(Return); } @@ -244,11 +244,11 @@ FsRtlLookupMcbEntry(IN PMCB Mcb, NULL, NULL, Index); - + /* Return everything typecasted */ *Lbn = (ULONG)llLbn; if (SectorCount) *SectorCount = (ULONG)llSectorCount; - + /* And return the original value */ return(Return); } diff --git a/reactos/ntoskrnl/fs/name.c b/reactos/ntoskrnl/fs/name.c index 14538bfd056..821c1d3fab1 100644 --- a/reactos/ntoskrnl/fs/name.c +++ b/reactos/ntoskrnl/fs/name.c @@ -168,7 +168,7 @@ PUCHAR EXPORTED FsRtlLegalAnsiCharacterArray = LegalAnsiCharacterArray; * * @implemented */ -BOOLEAN +BOOLEAN STDCALL FsRtlAreNamesEqual(IN PUNICODE_STRING Name1, IN PUNICODE_STRING Name2, @@ -178,13 +178,13 @@ FsRtlAreNamesEqual(IN PUNICODE_STRING Name1, UNICODE_STRING UpcaseName1; UNICODE_STRING UpcaseName2; BOOLEAN StringsAreEqual; - + /* Well, first check their size */ if (Name1->Length != Name2->Length) { /* Not equal! */ return FALSE; } - + /* Turn them into Upcase if we don't have a table */ if (IgnoreCase && !UpcaseTable) { RtlUpcaseUnicodeString(&UpcaseName1, Name1, TRUE); @@ -192,42 +192,42 @@ FsRtlAreNamesEqual(IN PUNICODE_STRING Name1, Name1 = &UpcaseName1; Name2 = &UpcaseName2; - goto ManualCase; + goto ManualCase; } - + /* Do a case-sensitive search */ if (!IgnoreCase) { - + ManualCase: /* Use a raw memory compare */ StringsAreEqual = RtlEqualMemory(Name1->Buffer, Name2->Buffer, Name1->Length); - + /* Clear the strings if we need to */ if (IgnoreCase) { RtlFreeUnicodeString(&UpcaseName1); RtlFreeUnicodeString(&UpcaseName2); } - + /* Return the equality */ return StringsAreEqual; - + } else { - + /* Case in-sensitive search */ - + LONG i; - + for (i = Name1->Length / sizeof(WCHAR) - 1; i >= 0; i--) { - + if (UpcaseTable[Name1->Buffer[i]] != UpcaseTable[Name2->Buffer[i]]) { - + /* Non-match found! */ return FALSE; } - } - + } + /* We finished the loop so we are equal */ return TRUE; } @@ -261,7 +261,7 @@ ManualCase: * * @implemented */ -VOID +VOID STDCALL FsRtlDissectDbcs(IN ANSI_STRING Name, OUT PANSI_STRING FirstPart, @@ -269,39 +269,39 @@ FsRtlDissectDbcs(IN ANSI_STRING Name, { ULONG i; ULONG FirstLoop; - + /* Initialize the Outputs */ RtlZeroMemory(&FirstPart, sizeof(ANSI_STRING)); RtlZeroMemory(&RemainingPart, sizeof(ANSI_STRING)); - + /* Bail out if empty */ if (!Name.Length) return; - + /* Ignore backslash */ if (Name.Buffer[0] == '\\') { i = 1; } else { i = 0; } - + /* Loop until we find a backslash */ for (FirstLoop = i;i < Name.Length;i++) { if (Name.Buffer[i] != '\\') break; if (FsRtlIsLeadDbcsCharacter(Name.Buffer[i])) i++; } - + /* Now we have the First Part */ FirstPart->Length = (i-FirstLoop); FirstPart->MaximumLength = FirstPart->Length; /* +2?? */ FirstPart->Buffer = &Name.Buffer[FirstLoop]; - + /* Make the second part if something is still left */ if (iLength = (Name.Length - (i+1)); RemainingPart->MaximumLength = RemainingPart->Length; /* +2?? */ RemainingPart->Buffer = &Name.Buffer[i+1]; } - + return; } @@ -334,7 +334,7 @@ FsRtlDissectDbcs(IN ANSI_STRING Name, * * @implemented */ -VOID +VOID STDCALL FsRtlDissectName(IN UNICODE_STRING Name, OUT PUNICODE_STRING FirstPart, @@ -368,7 +368,7 @@ FsRtlDissectName(IN UNICODE_STRING Name, NameLength++; } - FirstPart->Length = + FirstPart->Length = FirstPart->MaximumLength = NameLength * sizeof(WCHAR); FirstPart->Buffer = &Name.Buffer[NameOffset]; @@ -393,15 +393,15 @@ FsRtlDissectName(IN UNICODE_STRING Name, * * @implemented */ -BOOLEAN +BOOLEAN STDCALL FsRtlDoesDbcsContainWildCards(IN PANSI_STRING Name) { ULONG i; - + /* Check every character */ for (i=0;i < Name->Length;i++) { - + /* First make sure it's not the Lead DBCS */ if (FsRtlIsLeadDbcsCharacter(Name->Buffer[i])) { i++; @@ -410,7 +410,7 @@ FsRtlDoesDbcsContainWildCards(IN PANSI_STRING Name) return TRUE; } } - + /* We didn't return above...so none found */ return FALSE; } @@ -430,7 +430,7 @@ FsRtlDoesDbcsContainWildCards(IN PANSI_STRING Name) * * @implemented */ -BOOLEAN +BOOLEAN STDCALL FsRtlDoesNameContainWildCards(IN PUNICODE_STRING Name) { @@ -457,14 +457,14 @@ FsRtlDoesNameContainWildCards(IN PUNICODE_STRING Name) * FsRtlIsDbcsInExpression@8 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE * * @unimplemented */ -BOOLEAN +BOOLEAN STDCALL FsRtlIsDbcsInExpression(IN PANSI_STRING Expression, IN PANSI_STRING Name) @@ -486,10 +486,10 @@ FsRtlIsDbcsInExpression(IN PANSI_STRING Expression, */ BOOLEAN STDCALL -FsRtlIsFatDbcsLegal(IN ANSI_STRING DbcsName, - IN BOOLEAN WildCardsPermissible, - IN BOOLEAN PathNamePermissible, - IN BOOLEAN LeadingBackslashPermissible) +FsRtlIsFatDbcsLegal(IN ANSI_STRING DbcsName, + IN BOOLEAN WildCardsPermissible, + IN BOOLEAN PathNamePermissible, + IN BOOLEAN LeadingBackslashPermissible) { return FALSE; } @@ -499,19 +499,19 @@ FsRtlIsFatDbcsLegal(IN ANSI_STRING DbcsName, * FsRtlIsHpfsDbcsLegal@20 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE * * @unimplemented */ -BOOLEAN +BOOLEAN STDCALL -FsRtlIsHpfsDbcsLegal(IN ANSI_STRING DbcsName, - IN BOOLEAN WildCardsPermissible, - IN BOOLEAN PathNamePermissible, - IN BOOLEAN LeadingBackslashPermissible) +FsRtlIsHpfsDbcsLegal(IN ANSI_STRING DbcsName, + IN BOOLEAN WildCardsPermissible, + IN BOOLEAN PathNamePermissible, + IN BOOLEAN LeadingBackslashPermissible) { return FALSE; } @@ -533,7 +533,7 @@ FsRtlIsHpfsDbcsLegal(IN ANSI_STRING DbcsName, * * @implemented */ -BOOLEAN +BOOLEAN STDCALL FsRtlIsNameInExpression(IN PUNICODE_STRING Expression, IN PUNICODE_STRING Name, diff --git a/reactos/ntoskrnl/fs/notify.c b/reactos/ntoskrnl/fs/notify.c index 8a84e77bd9d..2b02721a5ca 100644 --- a/reactos/ntoskrnl/fs/notify.c +++ b/reactos/ntoskrnl/fs/notify.c @@ -33,8 +33,8 @@ typedef struct _NOTIFY_ENTRY BOOLEAN Unicode; BOOLEAN BufferExhausted; PVOID Buffer; /* Buffer == NULL equals IgnoreBuffer == TRUE */ - ULONG BufferSize; - ULONG NextEntryOffset; + ULONG BufferSize; + ULONG NextEntryOffset; PFILE_NOTIFY_INFORMATION PrevEntry; } NOTIFY_ENTRY, *PNOTIFY_ENTRY; @@ -57,7 +57,7 @@ FsRtlpInitNotifyImplementation(VOID) 0 ); - + } @@ -70,11 +70,11 @@ FsRtlpIsUnicodePath( ) { ASSERT(Path->Length); - - if (Path->Length == 1) return FALSE; - + + if (Path->Length == 1) return FALSE; + if (*(WCHAR*)Path->Buffer == '\\') return TRUE; - + return FALSE; } @@ -86,30 +86,30 @@ FsRtlpIsUnicodePath( */ static VOID -STDCALL +STDCALL FsRtlpNotifyCancelRoutine( - IN PDEVICE_OBJECT DeviceObject, + IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ) { PFAST_MUTEX Lock; //don't need this since we have our own sync. protecting irp cancellation - IoReleaseCancelSpinLock(Irp->CancelIrql); + IoReleaseCancelSpinLock(Irp->CancelIrql); Lock = (PFAST_MUTEX)Irp->Tail.Overlay.DriverContext[3]; ExAcquireFastMutex(Lock ); - + RemoveEntryList(&Irp->Tail.Overlay.ListEntry); - + ExReleaseFastMutex(Lock); Irp->IoStatus.Status = STATUS_CANCELLED; Irp->IoStatus.Information = 0; IoCompleteRequest(Irp, IO_NO_INCREMENT); - + } @@ -124,18 +124,18 @@ FsRtlpFindNotifyEntry( { PLIST_ENTRY EnumEntry; PNOTIFY_ENTRY NotifyEntry; - + LIST_FOR_EACH(EnumEntry, NotifyList) { NotifyEntry = CONTAINING_RECORD(EnumEntry, NOTIFY_ENTRY, ListEntry); - + if (NotifyEntry->FsContext == FsContext) { return NotifyEntry; } } - return NULL; + return NULL; } /********************************************************************** @@ -143,7 +143,7 @@ FsRtlpFindNotifyEntry( * FsRtlNotifyChangeDirectory@28 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -203,13 +203,13 @@ FsRtlNotifyCleanup ( LIST_ENTRY CompletedListHead; PLIST_ENTRY TmpEntry; PIRP Irp; - + InitializeListHead(&CompletedListHead); - - ExAcquireFastMutex((PFAST_MUTEX)NotifySync); - + + ExAcquireFastMutex((PFAST_MUTEX)NotifySync); + NotifyEntry = FsRtlpFindNotifyEntry(NotifyList, FsContext); - + if (NotifyEntry) { /* free buffered changes */ @@ -226,7 +226,7 @@ FsRtlNotifyCleanup ( /* irp cancelation bolilerplate */ if (!IoSetCancelRoutine(Irp, NULL)) - { + { //The cancel routine will be called. When we release the lock it will complete the irp. InitializeListHead(&Irp->Tail.Overlay.ListEntry); continue; @@ -238,22 +238,22 @@ FsRtlNotifyCleanup ( /* avoid holding lock while completing irp */ InsertTailList(&CompletedListHead, &Irp->Tail.Overlay.ListEntry); } - + /* Unlink and free the NotifyStruct */ RemoveEntryList(&NotifyEntry->ListEntry); ExFreeToPagedLookasideList(&NotifyEntryLookaside, NotifyEntry); } - + ExReleaseFastMutex((PFAST_MUTEX)NotifySync); - + /* complete defered irps */ - while (!IsListEmpty(&CompletedListHead)) + while (!IsListEmpty(&CompletedListHead)) { TmpEntry = RemoveHeadList(&CompletedListHead); Irp = CONTAINING_RECORD(TmpEntry , IRP, Tail.Overlay.ListEntry); - IoCompleteRequest(Irp, IO_NO_INCREMENT); + IoCompleteRequest(Irp, IO_NO_INCREMENT); } - + } @@ -315,23 +315,23 @@ FsRtlpWatchedDirectoryWasDeleted( PLIST_ENTRY EnumEntry, TmpEntry; PNOTIFY_ENTRY NotifyEntry; PIRP Irp; - + InitializeListHead(&CompletedListHead); - + ExAcquireFastMutex((PFAST_MUTEX)NotifySync); LIST_FOR_EACH_SAFE(EnumEntry, NotifyList, NotifyEntry, NOTIFY_ENTRY, ListEntry ) { if (NotifyEntry->Fcb == Fcb) { - RemoveEntryList(&NotifyEntry->ListEntry); - + RemoveEntryList(&NotifyEntry->ListEntry); + /* free buffered changes */ if (NotifyEntry->Buffer) { ExFreePool(NotifyEntry->Buffer); } - + /* cleanup pending irps */ while (!IsListEmpty(&NotifyEntry->IrpQueue)) { @@ -340,31 +340,31 @@ FsRtlpWatchedDirectoryWasDeleted( /* irp cancelation bolilerplate */ if (!IoSetCancelRoutine(Irp, NULL)) - { + { //The cancel routine will be called. When we release the lock it will complete the irp. InitializeListHead(&Irp->Tail.Overlay.ListEntry); continue; } - + Irp->IoStatus.Status = STATUS_DELETE_PENDING; Irp->IoStatus.Information = 0; - + /* avoid holding lock while completing irp */ InsertTailList(&CompletedListHead, &Irp->Tail.Overlay.ListEntry); } } } - - ExReleaseFastMutex((PFAST_MUTEX)NotifySync); - + + ExReleaseFastMutex((PFAST_MUTEX)NotifySync); + /* complete defered irps */ - while (!IsListEmpty(&CompletedListHead)) + while (!IsListEmpty(&CompletedListHead)) { TmpEntry = RemoveHeadList(&CompletedListHead); Irp = CONTAINING_RECORD(TmpEntry , IRP, Tail.Overlay.ListEntry); - IoCompleteRequest(Irp, IO_NO_INCREMENT); + IoCompleteRequest(Irp, IO_NO_INCREMENT); } - + } @@ -377,7 +377,7 @@ FsRtlpWatchedDirectoryWasDeleted( * FsRtlNotifyFullChangeDirectory@40 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -399,49 +399,49 @@ FsRtlNotifyFullChangeDirectory ( IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL ) { - PIO_STACK_LOCATION IrpStack; + PIO_STACK_LOCATION IrpStack; PNOTIFY_ENTRY NotifyEntry; ULONG IrpBuffLen; - + if (!Irp) { /* all other params are ignored if NotifyIrp == NULL */ FsRtlpWatchedDirectoryWasDeleted(NotifySync, NotifyList, FsContext); return; } - + DPRINT("FullDirectoryName: %wZ\n", FullDirectoryName); - + ExAcquireFastMutex((PFAST_MUTEX)NotifySync); - + IrpStack = IoGetCurrentIrpStackLocation(Irp); if (IrpStack->FileObject->Flags & FO_CLEANUP_COMPLETE) { ExReleaseFastMutex((PFAST_MUTEX)NotifySync); - + Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_NOTIFY_CLEANUP; IoCompleteRequest(Irp, IO_NO_INCREMENT); - return; + return; } - + IrpBuffLen = IrpStack->Parameters.NotifyDirectory.Length; - + NotifyEntry = FsRtlpFindNotifyEntry(NotifyList, FsContext); if (!NotifyEntry) { /* No NotifyStruct for this FileObject existed */ - + /* The first request for this FileObject set the standards. * For subsequent requests, these params will be ignored. * Ref: Windows NT File System Internals page 516 */ - + NotifyEntry = ExAllocateFromPagedLookasideList(&NotifyEntryLookaside); - + RtlZeroMemory(NotifyEntry, sizeof(NOTIFY_ENTRY)); - + NotifyEntry->FsContext = FsContext; NotifyEntry->FullDirectoryName = FullDirectoryName; NotifyEntry->WatchTree = WatchTree; @@ -461,7 +461,7 @@ FsRtlNotifyFullChangeDirectory ( IrpBuffLen, FSRTL_NOTIFY_TAG ); - + NotifyEntry->BufferSize = IrpBuffLen; } _SEH_HANDLE @@ -474,24 +474,24 @@ FsRtlNotifyFullChangeDirectory ( } InitializeListHead(&NotifyEntry->IrpQueue); - + InsertTailList(NotifyList, &NotifyEntry->ListEntry); } - - - + + + if (!NotifyEntry->PendingChanges) { /* No changes are pending. Queue the irp */ /* Irp cancelation boilerplate */ - + /* save NotifySych for use in the cancel routine */ Irp->Tail.Overlay.DriverContext[3] = NotifySync; IoSetCancelRoutine(Irp, FsRtlpNotifyCancelRoutine); if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL)) - { + { //irp was canceled ExReleaseFastMutex((PFAST_MUTEX)NotifySync); @@ -506,17 +506,17 @@ FsRtlNotifyFullChangeDirectory ( //FIXME: any point in setting irp status/information before queueing? Irp->IoStatus.Status = STATUS_PENDING; - + InsertTailList(&NotifyEntry->IrpQueue, &Irp->Tail.Overlay.ListEntry); ExReleaseFastMutex((PFAST_MUTEX)NotifySync); return; } - + /* Pending changes exist */ - - if (NotifyEntry->Buffer == NULL || + + if (NotifyEntry->Buffer == NULL || NotifyEntry->BufferExhausted || IrpBuffLen < NotifyEntry->NextEntryOffset) { @@ -526,7 +526,7 @@ FsRtlNotifyFullChangeDirectory ( -Buffer were overflowed, OR -Current irp buff was not large enough */ - + Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_NOTIFY_ENUM_DIR; @@ -547,18 +547,18 @@ FsRtlNotifyFullChangeDirectory ( Irp->IoStatus.Status = STATUS_SUCCESS; } - + /* reset buffer */ NotifyEntry->PrevEntry = NULL; NotifyEntry->NextEntryOffset = 0; NotifyEntry->BufferExhausted = FALSE; - + NotifyEntry->PendingChanges = FALSE; ExReleaseFastMutex((PFAST_MUTEX)NotifySync); - + IoCompleteRequest(Irp, IO_NO_INCREMENT); - + /* caller must return STATUS_PENDING */ } @@ -570,33 +570,33 @@ FASTCALL FsRtlpGetNextIrp(PNOTIFY_ENTRY NotifyEntry) { PIRP Irp; - PLIST_ENTRY TmpEntry; - + PLIST_ENTRY TmpEntry; + /* Loop to get a non-canceled irp */ while (!IsListEmpty(&NotifyEntry->IrpQueue)) { /* If we have queued irp(s) we can't possibly have pending changes too */ ASSERT(!NotifyEntry->PendingChanges); - + TmpEntry = RemoveHeadList(&NotifyEntry->IrpQueue); Irp = CONTAINING_RECORD(TmpEntry , IRP, Tail.Overlay.ListEntry); /* irp cancelation bolilerplate */ if (!IoSetCancelRoutine(Irp, NULL)) - { + { //The cancel routine will be called. When we release the lock it will complete the irp. InitializeListHead(&Irp->Tail.Overlay.ListEntry); continue; } /* Finally we got a non-canceled irp */ - return Irp; + return Irp; } - + return NULL; } - - + + static inline VOID @@ -615,7 +615,7 @@ FsRtlpCopyName( if (StreamName) { CurrentEntry->Name[RelativeName->Length/sizeof(WCHAR)] = ':'; - memcpy(&CurrentEntry ->Name[(RelativeName->Length/sizeof(WCHAR))+1], + memcpy(&CurrentEntry ->Name[(RelativeName->Length/sizeof(WCHAR))+1], StreamName->Buffer, StreamName->Length); } @@ -633,7 +633,7 @@ FsRtlpCopyName( * FsRtlNotifyFullReportChange@36 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -663,7 +663,7 @@ FsRtlNotifyFullReportChange ( USHORT NameLenU; ULONG RecordLen; PFILE_NOTIFY_INFORMATION CurrentEntry; - + InitializeListHead(&CompletedListHead); DPRINT("FullTargetName: %wZ\n", FullTargetName); @@ -672,40 +672,40 @@ FsRtlNotifyFullReportChange ( I think FullTargetName can include/be a short file name! What the heck do i do with this? Dont think this apply to FsRtlNotifyFullChangeDirectory's FullDirectoryName. */ - - - ExAcquireFastMutex((PFAST_MUTEX)NotifySync); + + + ExAcquireFastMutex((PFAST_MUTEX)NotifySync); LIST_FOR_EACH_SAFE(EnumEntry, NotifyList, NotifyEntry, NOTIFY_ENTRY, ListEntry ) { ASSERT(NotifyEntry->Unicode == FsRtlpIsUnicodePath(FullTargetName)); - + /* rule out some easy cases */ /* FIXME: short vs. long names??? lower case/upper case/mixed case? */ if (!(FilterMatch & NotifyEntry->CompletionFilter)) continue; - + FullDirLen = TargetNameOffset - (NotifyEntry->Unicode ? sizeof(WCHAR) : sizeof(char)); if (FullDirLen == 0) { /* special case for root dir */ FullDirLen = (NotifyEntry->Unicode ? sizeof(WCHAR) : sizeof(char)); } - + if (FullDirLen < NotifyEntry->FullDirectoryName->Length) continue; - + if (!NotifyEntry->WatchTree && FullDirLen != NotifyEntry->FullDirectoryName->Length) continue; DPRINT("NotifyEntry->FullDirectoryName: %wZ\n", NotifyEntry->FullDirectoryName); - - /* FIXME: short vs. long names??? lower case/upper case/mixed case? */ - if (memcmp(NotifyEntry->FullDirectoryName->Buffer, - FullTargetName->Buffer, - NotifyEntry->FullDirectoryName->Length) != 0) continue; - - if (NotifyEntry->WatchTree && + /* FIXME: short vs. long names??? lower case/upper case/mixed case? */ + if (memcmp(NotifyEntry->FullDirectoryName->Buffer, + FullTargetName->Buffer, + NotifyEntry->FullDirectoryName->Length) != 0) continue; + + + if (NotifyEntry->WatchTree && NotifyEntry->TraverseCallback && FullDirLen != NotifyEntry->FullDirectoryName->Length) { @@ -713,25 +713,25 @@ FsRtlNotifyFullReportChange ( NTSTATUS Status = NotifyEntry->TraverseCallback(NotifyEntry->FsContext, TargetContext, NotifyEntry->SubjectContext); - + if (!NT_SUCCESS(Status)) continue; - + /* FIXME: notify-dir impl. should release and free the SubjectContext */ } DPRINT("Found match\n"); - + /* Found a valid change */ RelativeName.Buffer = FullTargetName->Buffer + TargetNameOffset; - RelativeName.MaximumLength = - RelativeName.Length = + RelativeName.MaximumLength = + RelativeName.Length = FullTargetName->Length - TargetNameOffset; - + DPRINT("RelativeName: %wZ\n",&RelativeName); - + /* calculate unicode bytes of relative-name + stream-name */ if (NotifyEntry->Unicode) { @@ -739,25 +739,25 @@ FsRtlNotifyFullReportChange ( } else { - NameLenU = RelativeName.Length * sizeof(WCHAR) + + NameLenU = RelativeName.Length * sizeof(WCHAR) + (StreamName ? ((StreamName->Length * sizeof(WCHAR)) + sizeof(WCHAR)) : 0); } - + RecordLen = FIELD_OFFSET(FILE_NOTIFY_INFORMATION, Name) + NameLenU; - + if ((Irp = FsRtlpGetNextIrp(NotifyEntry))) { PIO_STACK_LOCATION IrpStack; ULONG IrpBuffLen; - + IrpStack = IoGetCurrentIrpStackLocation(Irp); IrpBuffLen = IrpStack->Parameters.NotifyDirectory.Length; - + DPRINT("Got pending irp\n"); - + ASSERT(!NotifyEntry->PendingChanges); - - if (NotifyEntry->Buffer == NULL || /* aka. IgnoreBuffer */ + + if (NotifyEntry->Buffer == NULL || /* aka. IgnoreBuffer */ RecordLen > IrpBuffLen) { /* ignore buffer / buffer not large enough */ @@ -766,12 +766,12 @@ FsRtlNotifyFullReportChange ( } else { - CurrentEntry = (PFILE_NOTIFY_INFORMATION) + CurrentEntry = (PFILE_NOTIFY_INFORMATION) MmGetSystemAddressForMdlSafe(Irp->MdlAddress, LowPagePriority); - + if (CurrentEntry) { - CurrentEntry->Action = Action; + CurrentEntry->Action = Action; CurrentEntry->NameLength = NameLenU; CurrentEntry->NextEntryOffset = 0; @@ -781,29 +781,29 @@ FsRtlNotifyFullReportChange ( &RelativeName, StreamName ); - + Irp->IoStatus.Information = RecordLen; } else { Irp->IoStatus.Information = 0; } - + Irp->IoStatus.Status = STATUS_SUCCESS; } - + /* avoid holding lock while completing irp */ InsertTailList(&CompletedListHead, &Irp->Tail.Overlay.ListEntry); } else { DPRINT("No irp\n"); - + NotifyEntry->PendingChanges = TRUE; if (NotifyEntry->Buffer == NULL || NotifyEntry->BufferExhausted) continue; - + if (RecordLen > NotifyEntry->BufferSize - NotifyEntry->NextEntryOffset) { /* overflow. drop these changes and stop buffering any other changes too */ @@ -814,10 +814,10 @@ FsRtlNotifyFullReportChange ( /* The buffer has enough room for the changes. * Copy data to buffer. */ - + CurrentEntry = (PFILE_NOTIFY_INFORMATION)NotifyEntry->Buffer; - - CurrentEntry->Action = Action; + + CurrentEntry->Action = Action; CurrentEntry->NameLength = NameLenU; CurrentEntry->NextEntryOffset = 0; @@ -826,14 +826,14 @@ FsRtlNotifyFullReportChange ( &RelativeName, StreamName ); - + if (NotifyEntry->PrevEntry) { NotifyEntry->PrevEntry->NextEntryOffset = (char*)CurrentEntry - (char*)NotifyEntry->PrevEntry; } NotifyEntry->PrevEntry = CurrentEntry; NotifyEntry->NextEntryOffset += RecordLen; - + // { // UNICODE_STRING TmpStr; @@ -841,22 +841,22 @@ FsRtlNotifyFullReportChange ( // TmpStr.MaximumLength = TmpStr.Length = BufferedChange->NameLen; // DPRINT("BufferedChange->RelativeName: %wZ\n", &TmpStr); // } - + } } ExReleaseFastMutex((PFAST_MUTEX)NotifySync); - + /* complete defered irps */ - while (!IsListEmpty(&CompletedListHead)) + while (!IsListEmpty(&CompletedListHead)) { EnumEntry = RemoveHeadList(&CompletedListHead); Irp = CONTAINING_RECORD(EnumEntry, IRP, Tail.Overlay.ListEntry); - - IoCompleteRequest(Irp, IO_NO_INCREMENT); + + IoCompleteRequest(Irp, IO_NO_INCREMENT); } - + } @@ -865,7 +865,7 @@ FsRtlNotifyFullReportChange ( * FsRtlNotifyInitializeSync@4 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -888,7 +888,7 @@ FsRtlNotifyInitializeSync ( * FsRtlNotifyReportChange@20 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE diff --git a/reactos/ntoskrnl/fs/oplock.c b/reactos/ntoskrnl/fs/oplock.c index c43e144f0d3..652813feed6 100644 --- a/reactos/ntoskrnl/fs/oplock.c +++ b/reactos/ntoskrnl/fs/oplock.c @@ -7,7 +7,7 @@ * * PROGRAMMERS: No programmer listed. */ - + #include @@ -16,7 +16,7 @@ * FsRtlCheckOplock@20 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -39,7 +39,7 @@ FsRtlCheckOplock(IN POPLOCK Oplock, * FsRtlCurrentBatchOplock@4 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -58,7 +58,7 @@ FsRtlCurrentBatchOplock(IN POPLOCK Oplock) * FsRtlInitializeOplock@4 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -79,7 +79,7 @@ FsRtlInitializeOplock(IN OUT POPLOCK Oplock) * FsRtlOplockFsctrl@12 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -100,7 +100,7 @@ FsRtlOplockFsctrl(IN POPLOCK Oplock, * FsRtlOplockIsFastIoPossible@4 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -119,7 +119,7 @@ FsRtlOplockIsFastIoPossible(IN POPLOCK Oplock) * FsRtlUninitializeOplock@4 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE diff --git a/reactos/ntoskrnl/fs/pool.c b/reactos/ntoskrnl/fs/pool.c index 54513102a62..0dc15b96182 100644 --- a/reactos/ntoskrnl/fs/pool.c +++ b/reactos/ntoskrnl/fs/pool.c @@ -16,7 +16,7 @@ * FsRtlAllocatePool@8 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -53,7 +53,7 @@ FsRtlAllocatePool ( * FsRtlAllocatePoolWithQuota@8 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -90,7 +90,7 @@ FsRtlAllocatePoolWithQuota ( * FsRtlAllocatePoolWithQuotaTag@12 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -125,7 +125,7 @@ FsRtlAllocatePoolWithQuotaTag ( * FsRtlAllocatePoolWithTag@12 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE diff --git a/reactos/ntoskrnl/fs/tunnel.c b/reactos/ntoskrnl/fs/tunnel.c index 908acf5b2a6..92e4dfde248 100644 --- a/reactos/ntoskrnl/fs/tunnel.c +++ b/reactos/ntoskrnl/fs/tunnel.c @@ -16,7 +16,7 @@ * FsRtlAddToTunnelCache@32 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -43,7 +43,7 @@ FsRtlAddToTunnelCache ( * FsRtlDeleteKeyFromTunnelCache@12 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -65,7 +65,7 @@ FsRtlDeleteKeyFromTunnelCache ( * FsRtlDeleteTunnelCache@4 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -86,7 +86,7 @@ FsRtlDeleteTunnelCache ( * FsRtlFindInTunnelCache@32 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -114,7 +114,7 @@ FsRtlFindInTunnelCache ( * FsRtlInitializeTunnelCache@4 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE diff --git a/reactos/ntoskrnl/fs/unc.c b/reactos/ntoskrnl/fs/unc.c index 11da3c74e4d..d1ad29c5f35 100644 --- a/reactos/ntoskrnl/fs/unc.c +++ b/reactos/ntoskrnl/fs/unc.c @@ -16,7 +16,7 @@ * FsRtlDeregisterUncProvider@4 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE @@ -34,7 +34,7 @@ FsRtlDeregisterUncProvider(IN HANDLE Handle) * FsRtlRegisterUncProvider@12 * * DESCRIPTION - * + * * ARGUMENTS * * RETURN VALUE diff --git a/reactos/ntoskrnl/fs/util.c b/reactos/ntoskrnl/fs/util.c index 820c96040e7..3eaa7ca7718 100644 --- a/reactos/ntoskrnl/fs/util.c +++ b/reactos/ntoskrnl/fs/util.c @@ -14,7 +14,7 @@ #define FSRTL_MAX_RESOURCES 16 -#define FTTYPE ((ULONG)'f') +#define FTTYPE ((ULONG)'f') #define FT_BALANCED_READ_MODE \ CTL_CODE(FTTYPE, 6, METHOD_NEITHER, FILE_ANY_ACCESS) @@ -32,11 +32,11 @@ INIT_FUNCTION RtlpInitializeResources(VOID) { ULONG i; - + /* Allocate the Resource Buffer */ - FsRtlpResources = FsRtlAllocatePool(NonPagedPool, + FsRtlpResources = FsRtlAllocatePool(NonPagedPool, FSRTL_MAX_RESOURCES*sizeof(ERESOURCE)); - + /* Initialize the Resources */ for (i = 0; i < FSRTL_MAX_RESOURCES; i++) { @@ -47,7 +47,7 @@ RtlpInitializeResources(VOID) /* FUNCTIONS *****************************************************************/ /*++ - * @name FsRtlIsTotalDeviceFailure + * @name FsRtlIsTotalDeviceFailure * @implemented NT 4.0 * * The FsRtlIsTotalDeviceFailure routine checks if an NTSTATUS error code @@ -65,13 +65,13 @@ BOOLEAN STDCALL FsRtlIsTotalDeviceFailure(IN NTSTATUS NtStatus) { - return((NT_SUCCESS(NtStatus)) || + return((NT_SUCCESS(NtStatus)) || (STATUS_CRC_ERROR == NtStatus) || (STATUS_DEVICE_DATA_ERROR == NtStatus) ? FALSE : TRUE); } /*++ - * @name FsRtlIsNtstatusExpected + * @name FsRtlIsNtstatusExpected * @implemented NT 4.0 * * The FsRtlIsNtstatusExpected routine checks if an NTSTATUS error code @@ -90,13 +90,13 @@ STDCALL FsRtlIsNtstatusExpected(IN NTSTATUS NtStatus) { return((STATUS_DATATYPE_MISALIGNMENT == NtStatus) || - (STATUS_ACCESS_VIOLATION == NtStatus) || - (STATUS_ILLEGAL_INSTRUCTION == NtStatus) || + (STATUS_ACCESS_VIOLATION == NtStatus) || + (STATUS_ILLEGAL_INSTRUCTION == NtStatus) || (STATUS_INSTRUCTION_MISALIGNMENT == NtStatus)) ? FALSE : TRUE; } /*++ - * @name FsRtlIsPagingFile + * @name FsRtlIsPagingFile * @implemented NT 4.0 * * The FsRtlIsPagingFile routine checks if the FileObject is a Paging File. @@ -117,7 +117,7 @@ FsRtlIsPagingFile(IN PFILE_OBJECT FileObject) } /*++ - * @name FsRtlNormalizeNtstatus + * @name FsRtlNormalizeNtstatus * @implemented NT 4.0 * * The FsRtlNormalizeNtstatus routine normalizes an NTSTATUS error code. @@ -129,7 +129,7 @@ FsRtlIsPagingFile(IN PFILE_OBJECT FileObject) * The NTSTATUS error code to return if the NtStatusToNormalize is not * a proper expected error code by the File System Library. * - * @return NtStatusToNormalize if it is an expected value, otherwise + * @return NtStatusToNormalize if it is an expected value, otherwise * NormalizedNtStatus. * * @remarks None. @@ -140,12 +140,12 @@ STDCALL FsRtlNormalizeNtstatus(IN NTSTATUS NtStatusToNormalize, IN NTSTATUS NormalizedNtStatus) { - return(TRUE == FsRtlIsNtstatusExpected(NtStatusToNormalize)) ? + return(TRUE == FsRtlIsNtstatusExpected(NtStatusToNormalize)) ? NtStatusToNormalize : NormalizedNtStatus; } /*++ - * @name FsRtlAllocateResource + * @name FsRtlAllocateResource * @implemented NT 4.0 * * The FsRtlAllocateResource routine returns a pre-initialized ERESOURCE @@ -165,11 +165,11 @@ FsRtlAllocateResource(VOID) } /*++ - * @name FsRtlBalanceReads + * @name FsRtlBalanceReads * @implemented NT 4.0 * * The FsRtlBalanceReads routine sends an IRP to an FTDISK Driver - * requesting the driver to balance read requests across a mirror set. + * requesting the driver to balance read requests across a mirror set. * * @param TargetDevice * A pointer to an FTDISK Device Object. @@ -187,10 +187,10 @@ FsRtlBalanceReads(PDEVICE_OBJECT TargetDevice) KEVENT Event; IO_STATUS_BLOCK IoStatusBlock; NTSTATUS Status; - + /* Initialize the Local Event */ KeInitializeEvent(&Event, NotificationEvent, FALSE); - + /* Build the special IOCTL */ Irp = IoBuildDeviceIoControlRequest(FT_BALANCED_READ_MODE, TargetDevice, @@ -201,10 +201,10 @@ FsRtlBalanceReads(PDEVICE_OBJECT TargetDevice) FALSE, &Event, &IoStatusBlock); - + /* Send it */ Status = IoCallDriver(TargetDevice, Irp); - + /* Wait if needed */ if (Status == STATUS_PENDING) { @@ -216,38 +216,38 @@ FsRtlBalanceReads(PDEVICE_OBJECT TargetDevice) /* Return Status */ Status = IoStatusBlock.Status; } - + return Status; } /*++ - * @name FsRtlPostPagingFileStackOverflow + * @name FsRtlPostPagingFileStackOverflow * @unimplemented NT 4.0 * * The FsRtlPostPagingFileStackOverflow routine * - * @param Context + * @param Context * * @param Event - * - * @param StackOverflowRoutine * - * @return + * @param StackOverflowRoutine + * + * @return * * @remarks None. * *--*/ VOID STDCALL -FsRtlPostPagingFileStackOverflow(IN PVOID Context, - IN PKEVENT Event, - IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine) +FsRtlPostPagingFileStackOverflow(IN PVOID Context, + IN PKEVENT Event, + IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine) { UNIMPLEMENTED; } /*++ - * @name FsRtlPostStackOverflow + * @name FsRtlPostStackOverflow * @unimplemented NT 4.0 * * The FsRtlPostStackOverflow routine @@ -255,28 +255,28 @@ FsRtlPostPagingFileStackOverflow(IN PVOID Context, * @param Context * * @param Event - * - * @param StackOverflowRoutine * - * @return + * @param StackOverflowRoutine + * + * @return * * @remarks None. * *--*/ VOID STDCALL -FsRtlPostStackOverflow(IN PVOID Context, - IN PKEVENT Event, - IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine) +FsRtlPostStackOverflow(IN PVOID Context, + IN PKEVENT Event, + IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine) { UNIMPLEMENTED; } /*++ - * @name FsRtlSyncVolumes + * @name FsRtlSyncVolumes * @implemented NT 4.0 * - * The FsRtlSyncVolumes routine is deprecated. + * The FsRtlSyncVolumes routine is deprecated. * * @return Always returns STATUS_SUCCESS. * diff --git a/reactos/ntoskrnl/inbv/inbv.c b/reactos/ntoskrnl/inbv/inbv.c index c16db544afb..13af9cd893f 100755 --- a/reactos/ntoskrnl/inbv/inbv.c +++ b/reactos/ntoskrnl/inbv/inbv.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/inbv/inbv.c * PURPOSE: Boot video support - * + * * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net) */ diff --git a/reactos/ntoskrnl/include/internal/callbacks.h b/reactos/ntoskrnl/include/internal/callbacks.h index 151e7f85afa..365fc4f7c02 100644 --- a/reactos/ntoskrnl/include/internal/callbacks.h +++ b/reactos/ntoskrnl/include/internal/callbacks.h @@ -30,7 +30,7 @@ /* Tag */ #define CALLBACK_TAG TAG('C','L','B','K') - + /* ROS Callback Object */ typedef struct _INT_CALLBACK_OBJECT { KSPIN_LOCK Lock; @@ -55,7 +55,7 @@ typedef struct _CALLBACK_REGISTRATION { #define CALLBACK_READ (STANDARD_RIGHTS_READ|SYNCHRONIZE|0x0001) /* Mapping for Callback Object */ -GENERIC_MAPPING ExpCallbackMapping = +GENERIC_MAPPING ExpCallbackMapping = { CALLBACK_READ, CALLBACK_WRITE, diff --git a/reactos/ntoskrnl/include/internal/cc.h b/reactos/ntoskrnl/include/internal/cc.h index 8df88ac8512..c3e4073d584 100644 --- a/reactos/ntoskrnl/include/internal/cc.h +++ b/reactos/ntoskrnl/include/internal/cc.h @@ -23,16 +23,16 @@ typedef struct _CACHE_SEGMENT { /* Base address of the region where the cache segment data is mapped. */ 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; /* Are the contents of the cache segment data valid. */ BOOLEAN Valid; /* Are the contents of the cache segment data newer than those on disk. */ BOOLEAN Dirty; - /* Page out in progress */ + /* Page out in progress */ BOOLEAN PageOut; ULONG MappedCount; /* Entry in the list of segments for this BCB. */ @@ -62,12 +62,12 @@ typedef struct _INTERNAL_BCB CSHORT RefCount; /* (At offset 0x34 on WinNT4) */ } INTERNAL_BCB, *PINTERNAL_BCB; -VOID +VOID STDCALL CcMdlReadCompleteDev(IN PMDL MdlChain, IN PFILE_OBJECT FileObject); - -VOID + +VOID STDCALL CcMdlWriteCompleteDev(IN PLARGE_INTEGER FileOffset, IN PMDL MdlChain, @@ -86,13 +86,13 @@ CcRosGetCacheSegment(PBCB Bcb, VOID CcInitView(VOID); -NTSTATUS +NTSTATUS CcRosFreeCacheSegment(PBCB, PCACHE_SEGMENT); -NTSTATUS +NTSTATUS ReadCacheSegment(PCACHE_SEGMENT CacheSeg); -NTSTATUS +NTSTATUS WriteCacheSegment(PCACHE_SEGMENT CacheSeg); VOID CcInit(VOID); @@ -100,7 +100,7 @@ VOID CcInit(VOID); NTSTATUS CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty); -PCACHE_SEGMENT +PCACHE_SEGMENT CcRosLookupCacheSegment(PBCB Bcb, ULONG FileOffset); NTSTATUS @@ -109,7 +109,7 @@ CcRosGetCacheSegmentChain(PBCB Bcb, ULONG Length, PCACHE_SEGMENT* CacheSeg); -VOID +VOID CcInitCacheZeroPage(VOID); NTSTATUS @@ -118,13 +118,13 @@ CcRosMarkDirtyCacheSegment(PBCB Bcb, ULONG FileOffset); NTSTATUS CcRosFlushDirtyPages(ULONG Target, PULONG Count); -VOID +VOID CcRosDereferenceCache(PFILE_OBJECT FileObject); -VOID +VOID CcRosReferenceCache(PFILE_OBJECT FileObject); -VOID +VOID CcRosSetRemoveOnClose(PSECTION_OBJECT_POINTERS SectionObjectPointer); NTSTATUS @@ -141,7 +141,7 @@ CcRosRequestCacheSegment (BCB* Bcb, PBOOLEAN UptoDate, CACHE_SEGMENT** CacheSeg); -NTSTATUS +NTSTATUS CcTryToInitializeFileCache(PFILE_OBJECT FileObject); /* diff --git a/reactos/ntoskrnl/include/internal/debug.h b/reactos/ntoskrnl/include/internal/debug.h index ab41c452fb2..6a62383be8f 100644 --- a/reactos/ntoskrnl/include/internal/debug.h +++ b/reactos/ntoskrnl/include/internal/debug.h @@ -4,7 +4,7 @@ * FILE: include/internal/debug.h * PURPOSE: Useful debugging macros * PROGRAMMER: David Welch (welch@mcmail.com) - * UPDATE HISTORY: + * UPDATE HISTORY: * 28/05/98: Created */ diff --git a/reactos/ntoskrnl/include/internal/ex.h b/reactos/ntoskrnl/include/internal/ex.h index 03c4efa6f4b..fd777075581 100644 --- a/reactos/ntoskrnl/include/internal/ex.h +++ b/reactos/ntoskrnl/include/internal/ex.h @@ -185,7 +185,7 @@ static __inline _SEH_FILTER(_SEH_ExSystemExceptionFilter) /* OTHER FUNCTIONS **********************************************************/ -LONGLONG +LONGLONG FASTCALL ExfpInterlockedExchange64(LONGLONG volatile * Destination, PLONGLONG Exchange); diff --git a/reactos/ntoskrnl/include/internal/i386/hal.h b/reactos/ntoskrnl/include/internal/i386/hal.h index fb12d3471c2..7121dbc016e 100644 --- a/reactos/ntoskrnl/include/internal/i386/hal.h +++ b/reactos/ntoskrnl/include/internal/i386/hal.h @@ -1,5 +1,5 @@ /* - * + * */ #ifndef __INTERNAL_HAL_HAL_H diff --git a/reactos/ntoskrnl/include/internal/i386/ke.h b/reactos/ntoskrnl/include/internal/i386/ke.h index 94141bd2e1d..5dc9d8dad37 100644 --- a/reactos/ntoskrnl/include/internal/i386/ke.h +++ b/reactos/ntoskrnl/include/internal/i386/ke.h @@ -232,31 +232,31 @@ VOID NtEarlyInitVdm(VOID); VOID KeApplicationProcessorInitDispatcher(VOID); -VOID +VOID KeCreateApplicationProcessorIdleThread(ULONG Id); -typedef -VOID +typedef +VOID STDCALL -(*PKSYSTEM_ROUTINE)(PKSTART_ROUTINE StartRoutine, +(*PKSYSTEM_ROUTINE)(PKSTART_ROUTINE StartRoutine, PVOID StartContext); VOID STDCALL -Ke386InitThreadWithContext(PKTHREAD Thread, +Ke386InitThreadWithContext(PKTHREAD Thread, PKSYSTEM_ROUTINE SystemRoutine, PKSTART_ROUTINE StartRoutine, PVOID StartContext, PCONTEXT Context); - + VOID STDCALL -KiThreadStartup(PKSYSTEM_ROUTINE SystemRoutine, - PKSTART_ROUTINE StartRoutine, - PVOID StartContext, +KiThreadStartup(PKSYSTEM_ROUTINE SystemRoutine, + PKSTART_ROUTINE StartRoutine, + PVOID StartContext, BOOLEAN UserThread, KTRAP_FRAME TrapFrame); - + #ifdef CONFIG_SMP #define LOCK "lock ; " #else @@ -281,7 +281,7 @@ KiThreadStartup(PKSYSTEM_ROUTINE SystemRoutine, #define Ke386SetLocalDescriptorTable(X) \ __asm__("lldt %0\n\t" \ : /* no outputs */ \ - : "m" (X)); + : "m" (X)); #define Ke386SetGlobalDescriptorTable(X) \ __asm__("lgdt %0\n\t" \ : /* no outputs */ \ @@ -307,11 +307,11 @@ static inline LONG Ke386TestAndClearBit(ULONG BitPos, volatile PULONG Addr) { LONG OldBit; - __asm__ __volatile__(LOCK + __asm__ __volatile__(LOCK "btrl %2,%1\n\t" "sbbl %0,%0\n\t" :"=r" (OldBit),"=m" (*Addr) - :"Ir" (BitPos) + :"Ir" (BitPos) : "memory"); return OldBit; } @@ -324,7 +324,7 @@ static inline LONG Ke386TestAndSetBit(ULONG BitPos, volatile PULONG Addr) "btsl %2,%1\n\t" "sbbl %0,%0\n\t" :"=r" (OldBit),"=m" (*Addr) - :"Ir" (BitPos) + :"Ir" (BitPos) : "memory"); return OldBit; } diff --git a/reactos/ntoskrnl/include/internal/i386/mm.h b/reactos/ntoskrnl/include/internal/i386/mm.h index 06a06a10b48..4e1681aa6e2 100644 --- a/reactos/ntoskrnl/include/internal/i386/mm.h +++ b/reactos/ntoskrnl/include/internal/i386/mm.h @@ -10,7 +10,7 @@ * Page access attributes (or these together) */ #define PA_READ (1<<0) -#define PA_WRITE ((1<<0)+(1<<1)) +#define PA_WRITE ((1<<0)+(1<<1)) #define PA_EXECUTE PA_READ #define PA_PCD (1<<4) #define PA_PWT (1<<3) diff --git a/reactos/ntoskrnl/include/internal/i386/ps.h b/reactos/ntoskrnl/include/internal/i386/ps.h index 9882d69f110..f4b4be9a311 100644 --- a/reactos/ntoskrnl/include/internal/i386/ps.h +++ b/reactos/ntoskrnl/include/internal/i386/ps.h @@ -52,7 +52,7 @@ #define KPCR_SELF 0x1C #define KPCR_GDT 0x3C #define KPCR_TSS 0x40 -#define KPCR_CURRENT_THREAD 0x124 +#define KPCR_CURRENT_THREAD 0x124 #define KPCR_NPX_THREAD 0x2A4 #ifndef __ASM__ @@ -67,7 +67,7 @@ typedef struct _KPROCESSOR_STATE { PVOID SpecialRegisters; } KPROCESSOR_STATE; -/* ProcessoR Control Block */ +/* ProcessoR Control Block */ typedef struct _KPRCB { USHORT MinorVersion; USHORT MajorVersion; diff --git a/reactos/ntoskrnl/include/internal/ifs.h b/reactos/ntoskrnl/include/internal/ifs.h index 18543b41226..0d38543460d 100644 --- a/reactos/ntoskrnl/include/internal/ifs.h +++ b/reactos/ntoskrnl/include/internal/ifs.h @@ -18,7 +18,7 @@ FsRtlpInitFileLockingImplementation(VOID); VOID STDCALL FsRtlpFileLockCancelRoutine( - IN PDEVICE_OBJECT DeviceObject, + IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ); @@ -30,7 +30,7 @@ FsRtlpCheckLockForReadOrWriteAccess( IN ULONG Key, IN PFILE_OBJECT FileObject, IN PEPROCESS Process, - IN BOOLEAN Read + IN BOOLEAN Read ); NTSTATUS FASTCALL diff --git a/reactos/ntoskrnl/include/internal/io.h b/reactos/ntoskrnl/include/internal/io.h index b1c26b407ed..a0e5fb24b83 100644 --- a/reactos/ntoskrnl/include/internal/io.h +++ b/reactos/ntoskrnl/include/internal/io.h @@ -64,7 +64,7 @@ typedef struct _DEVOBJ_EXTENSION { ULONG StartIoFlags; struct _VPB *Vpb; } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION; - + typedef struct _PRIVATE_DRIVER_EXTENSIONS { struct _PRIVATE_DRIVER_EXTENSIONS *Link; PVOID ClientIdentificationAddress; @@ -382,7 +382,7 @@ IopCreateDevice(PVOID ObjectBody, PWSTR RemainingPath, POBJECT_ATTRIBUTES ObjectAttributes); -NTSTATUS +NTSTATUS STDCALL IopAttachVpb(PDEVICE_OBJECT DeviceObject); @@ -531,14 +531,14 @@ IopReinitializeDrivers(VOID); /* file.c */ -NTSTATUS +NTSTATUS STDCALL IopCreateFile(PVOID ObjectBody, PVOID Parent, PWSTR RemainingPath, POBJECT_ATTRIBUTES ObjectAttributes); - -VOID + +VOID STDCALL IopDeleteFile(PVOID ObjectBody); @@ -549,19 +549,19 @@ IopSecurityFile(PVOID ObjectBody, SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR SecurityDescriptor, PULONG BufferLength); - + NTSTATUS STDCALL IopQueryNameFile(PVOID ObjectBody, POBJECT_NAME_INFORMATION ObjectNameInfo, ULONG Length, PULONG ReturnLength); - -VOID + +VOID STDCALL IopCloseFile(PVOID ObjectBody, ULONG HandleCount); - + /* plugplay.c */ NTSTATUS INIT_FUNCTION diff --git a/reactos/ntoskrnl/include/internal/kbd.h b/reactos/ntoskrnl/include/internal/kbd.h index 8af64ab0c6d..501df97edae 100644 --- a/reactos/ntoskrnl/include/internal/kbd.h +++ b/reactos/ntoskrnl/include/internal/kbd.h @@ -19,7 +19,7 @@ extern "C" { WORD wMaxModBits; BYTE ModNumber[1]; } MODIFIERS, *PMODIFIERS; - + #define TYPEDEF_VK_TO_WCHARS(i) \ typedef struct _VK_TO_WCHARS ## i { \ BYTE VirtualKey; \ @@ -49,7 +49,7 @@ extern "C" { WCHAR wchComposed; USHORT uFlags; } DEADKEY, *PDEADKEY; - + typedef WCHAR *DEADKEY_LPWSTR; #define DKF_DEAD 1 @@ -106,7 +106,7 @@ typedef struct _LIGATURE ## i { \ #define CAPLOKALTGR 4 #define KANALOK 8 #define GRPSELTAP 0x80 - + #ifdef __cplusplus }; diff --git a/reactos/ntoskrnl/include/internal/kd.h b/reactos/ntoskrnl/include/internal/kd.h index c5c7f096d64..482bfaa2eff 100644 --- a/reactos/ntoskrnl/include/internal/kd.h +++ b/reactos/ntoskrnl/include/internal/kd.h @@ -42,7 +42,7 @@ VOID KdbSymInit(IN PMODULE_TEXT_SECTION NtoskrnlTextSection, IN PMODULE_TEXT_SECTION LdrHalTextSection); -BOOLEAN +BOOLEAN KdbSymPrintAddress(IN PVOID Address); VOID @@ -135,17 +135,17 @@ VOID STDCALL KdpScreenInit(struct _KD_DISPATCH_TABLE *DispatchTable, ULONG BootPhase); - + VOID STDCALL KdpSerialInit(struct _KD_DISPATCH_TABLE *DispatchTable, ULONG BootPhase); - + VOID STDCALL KdpInitDebugLog(struct _KD_DISPATCH_TABLE *DispatchTable, ULONG BootPhase); - + /* KD ROUTINES ***************************************************************/ KD_CONTINUE_TYPE @@ -156,7 +156,7 @@ KdpEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord, PKTRAP_FRAME TrapFrame, BOOLEAN FirstChance, BOOLEAN Gdb); - + ULONG STDCALL KdpPrintString(PANSI_STRING String); @@ -164,7 +164,7 @@ KdpPrintString(PANSI_STRING String); BOOLEAN STDCALL KdpDetectConflicts(PCM_RESOURCE_LIST DriverList); - + /* KD GLOBALS ***************************************************************/ /* serial debug connection */ @@ -188,13 +188,13 @@ typedef struct _KDP_DEBUG_MODE UCHAR Screen :1; UCHAR Serial :1; UCHAR File :1; - + /* Currently Supported Wrappers */ UCHAR Pice :1; UCHAR Gdb :1; UCHAR Bochs :1; }; - + /* Generic Value */ ULONG Value; }; @@ -222,7 +222,7 @@ typedef struct _KD_DISPATCH_TABLE LIST_ENTRY KdProvidersList; PKDP_INIT_ROUTINE KdpInitRoutine; PKDP_PRINT_ROUTINE KdpPrintRoutine; - PKDP_PROMPT_ROUTINE KdpPromptRoutine; + PKDP_PROMPT_ROUTINE KdpPromptRoutine; PKDP_EXCEPTION_ROUTINE KdpExceptionRoutine; } KD_DISPATCH_TABLE, *PKD_DISPATCH_TABLE; @@ -243,13 +243,13 @@ extern PKDP_INIT_ROUTINE InitRoutines[KdMax]; /* Wrapper Init Function */ extern PKDP_INIT_ROUTINE WrapperInitRoutine; - + /* Dispatch Tables for Native Providers */ extern KD_DISPATCH_TABLE DispatchTable[KdMax]; /* Dispatch Table for the Wrapper */ extern KD_DISPATCH_TABLE WrapperTable; - + /* The KD Native Provider List */ extern LIST_ENTRY KdProviders; diff --git a/reactos/ntoskrnl/include/internal/kdb.h b/reactos/ntoskrnl/include/internal/kdb.h index f323ece746d..6276011c987 100644 --- a/reactos/ntoskrnl/include/internal/kdb.h +++ b/reactos/ntoskrnl/include/internal/kdb.h @@ -89,7 +89,7 @@ LONG KdbpDisassemble( IN ULONG Address, IN ULONG IntelSyntax); - + LONG KdbpGetInstLength( IN ULONG Address); @@ -198,7 +198,7 @@ KdbpInsertBreakPoint( IN PCHAR ConditionExpression OPTIONAL, IN BOOLEAN Global, OUT PULONG BreakPointNumber OPTIONAL); - + BOOLEAN KdbpDeleteBreakPoint( IN LONG BreakPointNr OPTIONAL, diff --git a/reactos/ntoskrnl/include/internal/kdbochs.h b/reactos/ntoskrnl/include/internal/kdbochs.h index 88748bd30b4..e21eca14dd3 100644 --- a/reactos/ntoskrnl/include/internal/kdbochs.h +++ b/reactos/ntoskrnl/include/internal/kdbochs.h @@ -14,5 +14,5 @@ VOID STDCALL KdpBochsInit(struct _KD_DISPATCH_TABLE *DispatchTable, ULONG BootPhase); - + #endif /* __INCLUDE_INTERNAL_KD_BOCHS_H */ diff --git a/reactos/ntoskrnl/include/internal/kdgdb.h b/reactos/ntoskrnl/include/internal/kdgdb.h index c271cfb8514..e0127cdc55b 100644 --- a/reactos/ntoskrnl/include/internal/kdgdb.h +++ b/reactos/ntoskrnl/include/internal/kdgdb.h @@ -16,5 +16,5 @@ KdpGdbStubInit(struct _KD_DISPATCH_TABLE *DispatchTable, ULONG BootPhase); extern KD_PORT_INFORMATION GdbPortInfo; - + #endif /* __INCLUDE_INTERNAL_KD_BOCHS_H */ diff --git a/reactos/ntoskrnl/include/internal/ke.h b/reactos/ntoskrnl/include/internal/ke.h index 0e6d899d2e6..74250f46ed1 100644 --- a/reactos/ntoskrnl/include/internal/ke.h +++ b/reactos/ntoskrnl/include/internal/ke.h @@ -68,20 +68,20 @@ typedef struct _KTHREAD { /* For waiting on thread exit */ DISPATCHER_HEADER DispatcherHeader; /* 00 */ - + /* List of mutants owned by the thread */ LIST_ENTRY MutantListHead; /* 10 */ PVOID InitialStack; /* 18 */ ULONG_PTR StackLimit; /* 1C */ - + /* Pointer to the thread's environment block in user memory */ struct _TEB *Teb; /* 20 */ - + /* Pointer to the thread's TLS array */ PVOID TlsArray; /* 24 */ PVOID KernelStack; /* 28 */ UCHAR DebugActive; /* 2C */ - + /* Thread state (one of THREAD_STATE_xxx constants below) */ UCHAR State; /* 2D */ BOOLEAN Alerted[2]; /* 2E */ @@ -157,7 +157,7 @@ typedef struct _KTHREAD } KTHREAD; #include - + typedef struct _KEXECUTE_OPTIONS { UCHAR ExecuteDisable:1; @@ -176,7 +176,7 @@ typedef struct _KEXECUTE_OPTIONS * KERNEL VERSION: 5.2 * DOCUMENTATION: http://reactos.com/wiki/index.php/KPROCESS */ -typedef struct _KPROCESS +typedef struct _KPROCESS { DISPATCHER_HEADER Header; /* 000 */ LIST_ENTRY ProfileListHead; /* 010 */ @@ -187,7 +187,7 @@ typedef struct _KPROCESS UCHAR Iopl; /* 032 */ UCHAR Unused; /* 033 */ ULONG ActiveProcessors; /* 034 */ - ULONG KernelTime; /* 038 */ + ULONG KernelTime; /* 038 */ ULONG UserTime; /* 03C */ LIST_ENTRY ReadyListHead; /* 040 */ LIST_ENTRY SwapListEntry; /* 048 */ @@ -195,7 +195,7 @@ typedef struct _KPROCESS LIST_ENTRY ThreadListHead; /* 050 */ KSPIN_LOCK ProcessLock; /* 058 */ KAFFINITY Affinity; /* 05C */ - union { + union { struct { ULONG AutoAlignment:1; /* 060.0 */ ULONG DisableBoost:1; /* 060.1 */ @@ -239,7 +239,7 @@ typedef enum _KTHREAD_STATE { Ready, Running, Standby, - Terminated, + Terminated, Waiting, Transition, DeferredReady, @@ -253,7 +253,7 @@ typedef enum _KTHREAD_STATE { PKTHREAD _Thread = KeGetCurrentThread(); \ if (_Thread) _Thread->KernelApcDisable--; \ } - + #define KeLeaveCriticalRegion(X) \ { \ PKTHREAD _Thread = KeGetCurrentThread(); \ @@ -275,30 +275,30 @@ typedef enum _KTHREAD_STATE { /* Thread Scheduler Functions */ /* Readies a Thread for Execution. */ -VOID +VOID STDCALL KiDispatchThreadNoLock(ULONG NewThreadStatus); /* Readies a Thread for Execution. */ -VOID +VOID STDCALL KiDispatchThread(ULONG NewThreadStatus); /* Puts a Thread into a block state. */ VOID STDCALL -KiBlockThread(PNTSTATUS Status, - UCHAR Alertable, +KiBlockThread(PNTSTATUS Status, + UCHAR Alertable, ULONG WaitMode, UCHAR WaitReason); - -/* Removes a thread out of a block state. */ + +/* Removes a thread out of a block state. */ VOID STDCALL -KiUnblockThread(PKTHREAD Thread, - PNTSTATUS WaitStatus, +KiUnblockThread(PKTHREAD Thread, + PNTSTATUS WaitStatus, KPRIORITY Increment); - + NTSTATUS STDCALL KeSuspendThread(PKTHREAD Thread); @@ -306,7 +306,7 @@ KeSuspendThread(PKTHREAD Thread); NTSTATUS FASTCALL KiSwapContext(PKTHREAD NewThread); - + /* gmutex.c ********************************************************************/ VOID @@ -314,8 +314,8 @@ FASTCALL KiAcquireGuardedMutexContented(PKGUARDED_MUTEX GuardedMutex); /* gate.c **********************************************************************/ - -VOID + +VOID FASTCALL KeInitializeGate(PKGATE Gate); @@ -331,16 +331,16 @@ KeWaitForGate(PKGATE Gate, /* ipi.c ********************************************************************/ -BOOLEAN STDCALL -KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame, +BOOLEAN STDCALL +KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame, IN struct _KEXCEPTION_FRAME* ExceptionFrame); -VOID -KiIpiSendRequest(ULONG TargetSet, +VOID +KiIpiSendRequest(ULONG TargetSet, ULONG IpiRequest); -VOID -KeIpiGenericCall(VOID (STDCALL *WorkerRoutine)(PVOID), +VOID +KeIpiGenericCall(VOID (STDCALL *WorkerRoutine)(PVOID), PVOID Argument); /* next file ***************************************************************/ @@ -375,7 +375,7 @@ typedef enum _CACHED_MODULE_TYPE { } CACHED_MODULE_TYPE, *PCACHED_MODULE_TYPE; extern PLOADER_MODULE CachedModules[MaximumCachedModuleType]; -VOID STDCALL +VOID STDCALL DbgBreakPointNoBugCheck(VOID); STDCALL @@ -419,7 +419,7 @@ KeProfileInterruptWithSource( IN KPROFILE_SOURCE Source ); -BOOLEAN +BOOLEAN STDCALL KiRosPrintAddress(PVOID Address); @@ -435,8 +435,8 @@ VOID inline FASTCALL KeReleaseDispatcherDatabaseLockFromDpcLevel(VOID); VOID STDCALL -KeInitializeThread(struct _KPROCESS* Process, - PKTHREAD Thread, +KeInitializeThread(struct _KPROCESS* Process, + PKTHREAD Thread, PKSYSTEM_ROUTINE SystemRoutine, PKSTART_ROUTINE StartRoutine, PVOID StartContext, @@ -474,22 +474,22 @@ VOID KeDumpStackFrames(PULONG Frame); BOOLEAN KiTestAlert(VOID); VOID -FASTCALL -KiAbortWaitThread(PKTHREAD Thread, +FASTCALL +KiAbortWaitThread(PKTHREAD Thread, NTSTATUS WaitStatus, KPRIORITY Increment); - + VOID STDCALL KeInitializeProcess(struct _KPROCESS *Process, KPRIORITY Priority, KAFFINITY Affinity, LARGE_INTEGER DirectoryTableBase); - + ULONG STDCALL KeForceResumeThread(IN PKTHREAD Thread); - + BOOLEAN STDCALL KiInsertTimer(PKTIMER Timer, LARGE_INTEGER DueTime); VOID inline FASTCALL KiSatisfyObjectWait(PDISPATCHER_HEADER Object, PKTHREAD Thread); @@ -508,18 +508,18 @@ VOID STDCALL KiDeliverApc(KPROCESSOR_MODE PreviousMode, VOID STDCALL KiKernelApcDeliveryCheck(VOID); -LONG -STDCALL -KiInsertQueue(IN PKQUEUE Queue, - IN PLIST_ENTRY Entry, +LONG +STDCALL +KiInsertQueue(IN PKQUEUE Queue, + IN PLIST_ENTRY Entry, BOOLEAN Head); - + ULONG STDCALL -KeSetProcess(struct _KPROCESS* Process, +KeSetProcess(struct _KPROCESS* Process, KPRIORITY Increment); - - + + VOID STDCALL KeInitializeEventPair(PKEVENT_PAIR EventPair); VOID STDCALL KiInitializeUserApc(IN PVOID Reserved, @@ -567,7 +567,7 @@ KiMoveApcState (PKAPC_STATE OldState, VOID KiAddProfileEvent(KPROFILE_SOURCE Source, ULONG Pc); -VOID +VOID KiDispatchException(PEXCEPTION_RECORD ExceptionRecord, PCONTEXT Context, PKTRAP_FRAME Tf, diff --git a/reactos/ntoskrnl/include/internal/ldr.h b/reactos/ntoskrnl/include/internal/ldr.h index c9711e889c5..0b4e2b6431f 100644 --- a/reactos/ntoskrnl/include/internal/ldr.h +++ b/reactos/ntoskrnl/include/internal/ldr.h @@ -35,7 +35,7 @@ LdrInitModuleManagement ( NTSTATUS STDCALL -LdrpMapSystemDll(PEPROCESS Process, +LdrpMapSystemDll(PEPROCESS Process, PVOID *DllBase); NTSTATUS @@ -48,11 +48,11 @@ LdrpGetSystemDllEntryPoints(VOID); PVOID LdrpGetSystemDllEntryPoint (VOID); -PVOID +PVOID LdrpGetSystemDllApcDispatcher(VOID); -PVOID +PVOID LdrpGetSystemDllExceptionDispatcher(VOID); -PVOID +PVOID LdrpGetSystemDllCallbackDispatcher(VOID); PVOID LdrpGetSystemDllRaiseExceptionDispatcher(VOID); diff --git a/reactos/ntoskrnl/include/internal/mm.h b/reactos/ntoskrnl/include/internal/mm.h index a69c4bd72c7..18213340fae 100644 --- a/reactos/ntoskrnl/include/internal/mm.h +++ b/reactos/ntoskrnl/include/internal/mm.h @@ -301,7 +301,7 @@ extern MM_STATS MmStats; typedef struct _MM_PAGEOP { /* Type of operation. */ - ULONG OpType; + ULONG OpType; /* Number of threads interested in this operation. */ ULONG ReferenceCount; /* Event that will be set when the operation is completed. */ @@ -315,7 +315,7 @@ typedef struct _MM_PAGEOP ULONG Hash; struct _MM_PAGEOP* Next; struct _ETHREAD* Thread; - /* + /* * These fields are used to identify the operation if it is against a * virtual memory area. */ @@ -361,7 +361,7 @@ typedef struct _MM_REGION LIST_ENTRY RegionListEntry; } MM_REGION, *PMM_REGION; -typedef VOID (*PMM_FREE_PAGE_FUNC)(PVOID Context, PMEMORY_AREA MemoryArea, +typedef VOID (*PMM_FREE_PAGE_FUNC)(PVOID Context, PMEMORY_AREA MemoryArea, PVOID Address, PFN_TYPE Page, SWAPENTRY SwapEntry, BOOLEAN Dirty); @@ -404,12 +404,12 @@ MmCreateMemoryArea( PMEMORY_AREA STDCALL MmLocateMemoryAreaByAddress( - PMADDRESS_SPACE AddressSpace, + PMADDRESS_SPACE AddressSpace, PVOID Address); ULONG_PTR STDCALL MmFindGapAtAddress( - PMADDRESS_SPACE AddressSpace, + PMADDRESS_SPACE AddressSpace, PVOID Address); NTSTATUS STDCALL @@ -431,7 +431,7 @@ MmDumpMemoryAreas(PMADDRESS_SPACE AddressSpace); PMEMORY_AREA STDCALL MmLocateMemoryAreaByRegion( - PMADDRESS_SPACE AddressSpace, + PMADDRESS_SPACE AddressSpace, PVOID Address, ULONG_PTR Length); @@ -476,7 +476,7 @@ VOID MmBuildMdlFromPages(PMDL Mdl, PULONG Pages); VOID MiShutdownMemoryManager(VOID); -VOID MmInit1(ULONG_PTR FirstKernelPhysAddress, +VOID MmInit1(ULONG_PTR FirstKernelPhysAddress, ULONG_PTR LastKernelPhysAddress, ULONG_PTR LastKernelAddress, PADDRESS_RANGE BIOSMemoryMap, @@ -507,7 +507,7 @@ BOOLEAN MmReserveSwapPages(ULONG Nr); NTSTATUS MmWriteToSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page); -NTSTATUS STDCALL +NTSTATUS STDCALL MmDumpToPagingFile(ULONG BugCode, ULONG BugCodeParameter1, ULONG BugCodeParameter2, @@ -525,7 +525,7 @@ NTSTATUS STDCALL MmCreateProcessAddressSpace(IN struct _EPROCESS* Process, IN PSECTION_OBJECT Section OPTIONAL); - + NTSTATUS STDCALL MmCreatePeb(PEPROCESS Process); @@ -535,7 +535,7 @@ STDCALL MmCreateTeb(PEPROCESS Process, PCLIENT_ID ClientId, PINITIAL_TEB InitialTeb); - + VOID STDCALL MmDeleteTeb(PEPROCESS Process, @@ -562,7 +562,7 @@ NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode, /* anonmem.c *****************************************************************/ NTSTATUS MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace, - MEMORY_AREA* MemoryArea, + MEMORY_AREA* MemoryArea, PVOID Address, BOOLEAN Locked); @@ -632,12 +632,12 @@ MmCreateKernelStack(BOOLEAN GuiStack); VOID STDCALL -MmDeleteKernelStack(PVOID Stack, +MmDeleteKernelStack(PVOID Stack, BOOLEAN GuiStack); - + /* balace.c ******************************************************************/ -VOID MmInitializeMemoryConsumer(ULONG Consumer, +VOID MmInitializeMemoryConsumer(ULONG Consumer, NTSTATUS (*Trim)(ULONG Target, ULONG Priority, PULONG NrFreed)); VOID MmInitializeBalancer(ULONG NrAvailablePages, ULONG NrSystemPages); @@ -658,7 +658,7 @@ struct _MM_RMAP_ENTRY* MmGetRmapListHeadPage(PFN_TYPE Page); VOID MmInsertRmap(PFN_TYPE Page, PEPROCESS Process, PVOID Address); -VOID MmDeleteAllRmaps(PFN_TYPE Page, PVOID Context, +VOID MmDeleteAllRmaps(PFN_TYPE Page, PVOID Context, VOID (*DeleteMapping)(PVOID Context, PEPROCESS Process, PVOID Address)); VOID MmDeleteRmap(PFN_TYPE Page, PEPROCESS Process, PVOID Address); @@ -712,7 +712,7 @@ PFN_TYPE MmChangeHyperspaceMapping(PVOID Address, PFN_TYPE Page); PFN_TYPE MmDeleteHyperspaceMapping(PVOID Address); -NTSTATUS MmCreateVirtualMappingForKernel(PVOID Address, +NTSTATUS MmCreateVirtualMappingForKernel(PVOID Address, ULONG flProtect, PPFN_TYPE Pages, ULONG PageCount); @@ -720,13 +720,13 @@ NTSTATUS MmCreateVirtualMappingForKernel(PVOID Address, NTSTATUS MmCommitPagedPoolAddress(PVOID Address, BOOLEAN Locked); NTSTATUS MmCreateVirtualMapping(struct _EPROCESS* Process, - PVOID Address, + PVOID Address, ULONG flProtect, PPFN_TYPE Pages, ULONG PageCount); NTSTATUS MmCreateVirtualMappingUnsafe(struct _EPROCESS* Process, - PVOID Address, + PVOID Address, ULONG flProtect, PPFN_TYPE Pages, ULONG PageCount); @@ -737,7 +737,7 @@ VOID MmSetPageProtect(struct _EPROCESS* Process, PVOID Address, ULONG flProtect); -BOOLEAN MmIsPagePresent(struct _EPROCESS* Process, +BOOLEAN MmIsPagePresent(struct _EPROCESS* Process, PVOID Address); VOID MmInitGlobalKernelPageDirectory(VOID); @@ -793,10 +793,10 @@ VOID MmDeletePageTable(struct _EPROCESS* Process, PVOID Address); PFN_TYPE MmGetPfnForProcess(struct _EPROCESS* Process, PVOID Address); -NTSTATUS +NTSTATUS STDCALL -MmCopyMmInfo(struct _EPROCESS* Src, - struct _EPROCESS* Dest, +MmCopyMmInfo(struct _EPROCESS* Src, + struct _EPROCESS* Dest, PPHYSICAL_ADDRESS DirectoryTableBase); NTSTATUS MmReleaseMmInfo(struct _EPROCESS* Process); @@ -804,7 +804,7 @@ NTSTATUS MmReleaseMmInfo(struct _EPROCESS* Process); NTSTATUS Mmi386ReleaseMmInfo(struct _EPROCESS* Process); VOID MmDeleteVirtualMapping(struct _EPROCESS* Process, - PVOID Address, + PVOID Address, BOOL FreePage, BOOL* WasDirty, PPFN_TYPE Page); @@ -827,9 +827,9 @@ NTSTATUS MmTrimUserMemory(ULONG Target, ULONG Priority, PULONG NrFreedPages); /* region.c ************************************************************/ -NTSTATUS MmAlterRegion(PMADDRESS_SPACE AddressSpace, PVOID BaseAddress, - PLIST_ENTRY RegionListHead, PVOID StartAddress, ULONG Length, - ULONG NewType, ULONG NewProtect, +NTSTATUS MmAlterRegion(PMADDRESS_SPACE AddressSpace, PVOID BaseAddress, + PLIST_ENTRY RegionListHead, PVOID StartAddress, ULONG Length, + ULONG NewType, ULONG NewProtect, PMM_ALTER_REGION_FUNC AlterFunc); VOID MmInitialiseRegion(PLIST_ENTRY RegionListHead, ULONG Length, ULONG Type, @@ -840,7 +840,7 @@ PMM_REGION MmFindRegion(PVOID BaseAddress, PLIST_ENTRY RegionListHead, PVOID Add /* section.c *****************************************************************/ -PVOID STDCALL +PVOID STDCALL MmAllocateSection (IN ULONG Length, PVOID BaseAddress); NTSTATUS STDCALL @@ -849,7 +849,7 @@ MmQuerySectionView(PMEMORY_AREA MemoryArea, PMEMORY_BASIC_INFORMATION Info, PULONG ResultLength); -NTSTATUS +NTSTATUS MmProtectSectionView(PMADDRESS_SPACE AddressSpace, PMEMORY_AREA MemoryArea, PVOID BaseAddress, @@ -857,7 +857,7 @@ MmProtectSectionView(PMADDRESS_SPACE AddressSpace, ULONG Protect, PULONG OldProtect); -NTSTATUS +NTSTATUS MmWritePageSectionView(PMADDRESS_SPACE AddressSpace, PMEMORY_AREA MArea, PVOID Address, @@ -879,24 +879,24 @@ MmCreateSection (OUT PSECTION_OBJECT * SectionObject, IN HANDLE FileHandle OPTIONAL, IN PFILE_OBJECT File OPTIONAL); -NTSTATUS +NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, - MEMORY_AREA* MemoryArea, + MEMORY_AREA* MemoryArea, PVOID Address, BOOLEAN Locked); -NTSTATUS +NTSTATUS MmPageOutSectionView(PMADDRESS_SPACE AddressSpace, PMEMORY_AREA MemoryArea, PVOID Address, struct _MM_PAGEOP* PageOp); -NTSTATUS +NTSTATUS MmCreatePhysicalMemorySection(VOID); -NTSTATUS +NTSTATUS MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace, - MEMORY_AREA* MemoryArea, + MEMORY_AREA* MemoryArea, PVOID Address, BOOLEAN Locked); diff --git a/reactos/ntoskrnl/include/internal/ntoskrnl.h b/reactos/ntoskrnl/include/internal/ntoskrnl.h index 972b42a09e8..a124c668c14 100644 --- a/reactos/ntoskrnl/include/internal/ntoskrnl.h +++ b/reactos/ntoskrnl/include/internal/ntoskrnl.h @@ -64,7 +64,7 @@ VOID KdInitSystem(ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock); #endif /* __ASM__ */ /* - * + * */ #define MM_STACK_SIZE (3*4096) diff --git a/reactos/ntoskrnl/include/internal/ob.h b/reactos/ntoskrnl/include/internal/ob.h index 1b68c44281e..939052c639d 100644 --- a/reactos/ntoskrnl/include/internal/ob.h +++ b/reactos/ntoskrnl/include/internal/ob.h @@ -36,65 +36,65 @@ typedef struct _OBJECT_TYPE * PURPOSE: Name of the type */ UNICODE_STRING TypeName; - + /* * PURPOSE: Total number of objects of this type */ ULONG TotalObjects; - + /* * PURPOSE: Total number of handles of this type */ ULONG TotalHandles; - + /* * PURPOSE: Peak objects of this type */ ULONG PeakObjects; - + /* * PURPOSE: Peak handles of this type */ ULONG PeakHandles; - + /* * PURPOSE: Paged pool charge */ ULONG PagedPoolCharge; - + /* * PURPOSE: Nonpaged pool charge */ ULONG NonpagedPoolCharge; - + /* * PURPOSE: Mapping of generic access rights */ PGENERIC_MAPPING Mapping; - + /* * PURPOSE: Dumps the object * NOTE: To be defined */ VOID STDCALL_FUNC (*Dump)(VOID); - + /* * PURPOSE: Opens the object * NOTE: To be defined */ VOID STDCALL_FUNC (*Open)(VOID); - + /* * PURPOSE: Called to close an object if OkayToClose returns true */ VOID STDCALL_FUNC (*Close)(PVOID ObjectBody, ULONG HandleCount); - + /* * PURPOSE: Called to delete an object when the last reference is removed */ VOID STDCALL_FUNC (*Delete)(PVOID ObjectBody); - + /* * PURPOSE: Called when an open attempts to open a file apparently * residing within the object @@ -162,20 +162,20 @@ typedef struct _OBJECT_HEADER struct _DIRECTORY_OBJECT* Parent; POBJECT_TYPE ObjectType; PSECURITY_DESCRIPTOR SecurityDescriptor; - + /* * PURPOSE: Object type * NOTE: This overlaps the first member of the object body */ CSHORT Type; - + /* * PURPOSE: Object size * NOTE: This overlaps the second member of the object body */ CSHORT Size; - - + + } OBJECT_HEADER, *POBJECT_HEADER; @@ -183,7 +183,7 @@ typedef struct _DIRECTORY_OBJECT { CSHORT Type; CSHORT Size; - + /* * PURPOSE: Head of the list of our subdirectories */ @@ -204,7 +204,7 @@ typedef struct _TYPE_OBJECT { CSHORT Type; CSHORT Size; - + /* pointer to object type data */ POBJECT_TYPE ObjectType; } TYPE_OBJECT, *PTYPE_OBJECT; @@ -327,14 +327,14 @@ ObpDereferenceCachedSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescripto VOID FASTCALL -ObInitializeFastReference(IN PEX_FAST_REF FastRef, +ObInitializeFastReference(IN PEX_FAST_REF FastRef, PVOID Object); PVOID FASTCALL ObFastReplaceObject(IN PEX_FAST_REF FastRef, PVOID Object); - + PVOID FASTCALL ObFastReferenceObject(IN PEX_FAST_REF FastRef); @@ -343,7 +343,7 @@ VOID FASTCALL ObFastDereferenceObject(IN PEX_FAST_REF FastRef, PVOID Object); - + /* Secure object information functions */ typedef struct _CAPTURED_OBJECT_ATTRIBUTES diff --git a/reactos/ntoskrnl/include/internal/pool.h b/reactos/ntoskrnl/include/internal/pool.h index 888d590cea2..e688b15a850 100644 --- a/reactos/ntoskrnl/include/internal/pool.h +++ b/reactos/ntoskrnl/include/internal/pool.h @@ -1,8 +1,8 @@ #ifndef __INTERNAL_POOL_H #define __INTERNAL_POOL_H -PVOID STDCALL ExAllocateNonPagedPoolWithTag (POOL_TYPE type, - ULONG size, +PVOID STDCALL ExAllocateNonPagedPoolWithTag (POOL_TYPE type, + ULONG size, ULONG Tag, PVOID Caller); diff --git a/reactos/ntoskrnl/include/internal/port.h b/reactos/ntoskrnl/include/internal/port.h index 4491247c70f..1f2c95a682c 100644 --- a/reactos/ntoskrnl/include/internal/port.h +++ b/reactos/ntoskrnl/include/internal/port.h @@ -11,19 +11,19 @@ typedef struct _EPORT { KSPIN_LOCK Lock; KSEMAPHORE Semaphore; - + USHORT Type; USHORT State; - + struct _EPORT * RequestPort; struct _EPORT * OtherPort; - + ULONG QueueLength; LIST_ENTRY QueueListHead; - + ULONG ConnectQueueLength; LIST_ENTRY ConnectQueueListHead; - + ULONG MaxDataLength; ULONG MaxConnectInfoLength; ULONG MaxPoolUsage; /* size of NP zone */ @@ -144,8 +144,8 @@ extern FAST_MUTEX LpcpLock; /* Code in ntoskrnl/lpc/reply.c */ NTSTATUS STDCALL -EiReplyOrRequestPort (IN PEPORT Port, - IN PLPC_MESSAGE LpcReply, +EiReplyOrRequestPort (IN PEPORT Port, + IN PLPC_MESSAGE LpcReply, IN ULONG MessageType, IN PEPORT Sender); diff --git a/reactos/ntoskrnl/include/internal/powerpc/ke.h b/reactos/ntoskrnl/include/internal/powerpc/ke.h index 3bf20cd3474..e6089ce4523 100644 --- a/reactos/ntoskrnl/include/internal/powerpc/ke.h +++ b/reactos/ntoskrnl/include/internal/powerpc/ke.h @@ -69,9 +69,9 @@ static inline LONG KePPCTestAndClearBit(ULONG BitPos, volatile PULONG Addr) { ULONG OldValue, NewValue; - __asm__ __volatile__ ("lwarx %0,0,%1" + __asm__ __volatile__ ("lwarx %0,0,%1" : "=r" (OldValue), "=r" (*Addr) - : + : : "memory"); NewValue = OldValue & ~(1< /* * NAME: EPROCESS @@ -183,15 +183,15 @@ struct _EPROCESS KPROCESS Pcb; /* 000 */ EX_PUSH_LOCK ProcessLock; /* 078 */ LARGE_INTEGER CreateTime; /* 080 */ - LARGE_INTEGER ExitTime; /* 088 */ + LARGE_INTEGER ExitTime; /* 088 */ EX_RUNDOWN_REF RundownProtect; /* 090 */ - HANDLE UniqueProcessId; /* 094 */ - LIST_ENTRY ActiveProcessLinks; /* 098 */ + HANDLE UniqueProcessId; /* 094 */ + LIST_ENTRY ActiveProcessLinks; /* 098 */ ULONG QuotaUsage[3]; /* 0A0 */ ULONG QuotaPeak[3]; /* 0AC */ - ULONG CommitCharge; /* 0B8 */ - ULONG PeakVirtualSize; /* 0BC */ - ULONG VirtualSize; /* 0C0 */ + ULONG CommitCharge; /* 0B8 */ + ULONG PeakVirtualSize; /* 0BC */ + ULONG VirtualSize; /* 0C0 */ LIST_ENTRY SessionProcessLinks; /* 0C4 */ PVOID DebugPort; /* 0CC */ PVOID ExceptionPort; /* 0D0 */ @@ -284,7 +284,7 @@ struct _EPROCESS }; ULONG Flags; /* 240 */ }; - + NTSTATUS ExitStatus; /* 244 */ USHORT NextPageColor; /* 248 */ union { @@ -299,13 +299,13 @@ struct _EPROCESS ULONG Cookie; /* 270 */ /*************************************************************** - * REACTOS SPECIFIC START - ***************************************************************/ + * REACTOS SPECIFIC START + ***************************************************************/ /* FIXME WILL BE DEPRECATED WITH PUSHLOCK SUPPORT IN 0.3.0 */ KEVENT LockEvent; /* 274 */ ULONG LockCount; /* 284 */ struct _KTHREAD *LockOwner; /* 288 */ - + /* FIXME MOVE TO AVL TREES */ MADDRESS_SPACE AddressSpace; /* 28C */ }; @@ -333,7 +333,7 @@ VOID STDCALL PiDeleteThread(PVOID ObjectBody); VOID PsReapThreads(VOID); VOID PsInitializeThreadReaper(VOID); VOID PsQueueThreadReap(PETHREAD Thread); -NTSTATUS +NTSTATUS PsInitializeThread(PEPROCESS Process, PETHREAD* ThreadPtr, POBJECT_ATTRIBUTES ObjectAttributes, @@ -357,12 +357,12 @@ NTSTATUS STDCALL PspAssignPrimaryToken(PEPROCESS Process, HANDLE TokenHandle); -VOID STDCALL PsExitSpecialApc(PKAPC Apc, +VOID STDCALL PsExitSpecialApc(PKAPC Apc, PKNORMAL_ROUTINE *NormalRoutine, PVOID *NormalContext, PVOID *SystemArgument1, PVOID *SystemArgument2); - + NTSTATUS STDCALL PspInitializeProcessSecurity(PEPROCESS Process, @@ -373,7 +373,7 @@ VOID STDCALL PspSystemThreadStartup(PKSTART_ROUTINE StartRoutine, PVOID StartContext); - + NTSTATUS PsInitializeIdleOrFirstThread ( PEPROCESS Process, @@ -383,7 +383,7 @@ PsInitializeIdleOrFirstThread ( BOOLEAN First); /* * Internal thread priorities, added by Phillip Susi - * TODO: rebalence these to make use of all priorities... the ones above 16 + * TODO: rebalence these to make use of all priorities... the ones above 16 * can not all be used right now */ #define PROCESS_PRIO_IDLE 3 @@ -394,8 +394,8 @@ PsInitializeIdleOrFirstThread ( VOID STDCALL PiDeleteProcess(PVOID ObjectBody); -VOID -STDCALL +VOID +STDCALL PspReapRoutine(PVOID Context); VOID @@ -443,15 +443,15 @@ PiSuspendThreadNormalRoutine(PVOID NormalContext, PVOID SystemArgument2); VOID PsInitialiseSuspendImplementation(VOID); -NTSTATUS +NTSTATUS STDCALL PspExitProcess(PEPROCESS Process); -VOID -STDCALL +VOID +STDCALL PspDeleteProcess(PVOID ObjectBody); -VOID +VOID STDCALL PspDeleteThread(PVOID ObjectBody); diff --git a/reactos/ntoskrnl/include/internal/se.h b/reactos/ntoskrnl/include/internal/se.h index a8366313647..29f1a3e3830 100644 --- a/reactos/ntoskrnl/include/internal/se.h +++ b/reactos/ntoskrnl/include/internal/se.h @@ -111,8 +111,8 @@ BOOLEAN SepInitSDs(VOID); VOID SeDeassignPrimaryToken(struct _EPROCESS *Process); -NTSTATUS STDCALL -SepCreateImpersonationTokenDacl(PTOKEN Token, +NTSTATUS STDCALL +SepCreateImpersonationTokenDacl(PTOKEN Token, PTOKEN PrimaryToken, PACL *Dacl); @@ -156,7 +156,7 @@ SepDuplicateToken(PTOKEN Token, SECURITY_IMPERSONATION_LEVEL Level, KPROCESSOR_MODE PreviousMode, PTOKEN* NewAccessToken); - + NTSTATUS SepCaptureSecurityQualityOfService(IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN KPROCESSOR_MODE AccessMode, diff --git a/reactos/ntoskrnl/include/internal/trap.h b/reactos/ntoskrnl/include/internal/trap.h index 0733b413c5a..8aaba64ab5a 100644 --- a/reactos/ntoskrnl/include/internal/trap.h +++ b/reactos/ntoskrnl/include/internal/trap.h @@ -38,14 +38,14 @@ typedef struct _KV86M_TRAP_FRAME { KTRAP_FRAME Tf; - + ULONG SavedExceptionStack; /* * These are put on the top of the stack by the routine that entered * v86 mode so the exception handlers can find the control information */ - struct _KV86M_REGISTERS* regs; + struct _KV86M_REGISTERS* regs; ULONG orig_ebp; } KV86M_TRAP_FRAME, *PKV86M_TRAP_FRAME; diff --git a/reactos/ntoskrnl/include/internal/v86m.h b/reactos/ntoskrnl/include/internal/v86m.h index 43f80f43409..e9e5acb17ea 100644 --- a/reactos/ntoskrnl/include/internal/v86m.h +++ b/reactos/ntoskrnl/include/internal/v86m.h @@ -53,7 +53,7 @@ typedef struct _KV86M_REGISTERS ULONG Gs; /* - * Control registers + * Control registers */ ULONG Eip; ULONG Cs; @@ -66,7 +66,7 @@ typedef struct _KV86M_REGISTERS */ ULONG RecoveryAddress; UCHAR RecoveryInstruction[4]; - ULONG Vif; + ULONG Vif; ULONG Flags; PNTSTATUS PStatus; } KV86M_REGISTERS, *PKV86M_REGISTERS; diff --git a/reactos/ntoskrnl/io/adapter.c b/reactos/ntoskrnl/io/adapter.c index 59907aaf947..3193803d832 100644 --- a/reactos/ntoskrnl/io/adapter.c +++ b/reactos/ntoskrnl/io/adapter.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/adapter.c * PURPOSE: DMA handling - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ diff --git a/reactos/ntoskrnl/io/arcname.c b/reactos/ntoskrnl/io/arcname.c index 64fd609d097..a317cec0bce 100644 --- a/reactos/ntoskrnl/io/arcname.c +++ b/reactos/ntoskrnl/io/arcname.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/arcname.c * PURPOSE: Creates ARC names for boot devices - * + * * PROGRAMMERS: Eric Kohl (ekohl@rz-online.de) */ diff --git a/reactos/ntoskrnl/io/bootlog.c b/reactos/ntoskrnl/io/bootlog.c index 9324dd9f6de..ed9adaafb54 100644 --- a/reactos/ntoskrnl/io/bootlog.c +++ b/reactos/ntoskrnl/io/bootlog.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/bootlog.c * PURPOSE: Boot log file support - * + * * PROGRAMMERS: Eric Kohl */ diff --git a/reactos/ntoskrnl/io/controller.c b/reactos/ntoskrnl/io/controller.c index 7e029792061..457dc8dad12 100644 --- a/reactos/ntoskrnl/io/controller.c +++ b/reactos/ntoskrnl/io/controller.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/contrller.c * PURPOSE: Implements the controller object - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) */ @@ -45,7 +45,7 @@ IoAllocateController(PCONTROLLER_OBJECT ControllerObject, /* Initialize the Wait Context Block */ DeviceObject->Queue.Wcb.DeviceContext = Context; DeviceObject->Queue.Wcb.DeviceRoutine = ExecutionRoutine; - + /* Insert the Device Queue */ if (!KeInsertDeviceQueue(&ControllerObject->DeviceWaitQueue, &DeviceObject->Queue.Wcb.WaitQueueEntry)); @@ -53,9 +53,9 @@ IoAllocateController(PCONTROLLER_OBJECT ControllerObject, Result = ExecutionRoutine(DeviceObject, DeviceObject->CurrentIrp, NULL, - Context); + Context); } - + if (Result == DeallocateObject) { IoFreeController(ControllerObject); @@ -83,7 +83,7 @@ IoCreateController(ULONG Size) /* Initialize an empty OBA */ InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL); - + /* Create the Object */ Status = ObCreateObject(KernelMode, IoControllerObjectType, @@ -95,7 +95,7 @@ IoCreateController(ULONG Size) 0, (PVOID*)&Controller); if (!NT_SUCCESS(Status)) return NULL; - + /* Insert it */ Status = ObInsertObject(Controller, NULL, @@ -104,16 +104,16 @@ IoCreateController(ULONG Size) NULL, &Handle); if (!NT_SUCCESS(Status)) return NULL; - + /* Close the dummy handle */ NtClose(Handle); - + /* Zero the Object and set its data */ RtlZeroMemory(Controller, sizeof(CONTROLLER_OBJECT) + Size); Controller->Type = IO_TYPE_CONTROLLER; Controller->Size = sizeof(CONTROLLER_OBJECT) + Size; Controller->ControllerExtension = (Controller + 1); - + /* Initialize its Queue */ KeInitializeDeviceQueue(&Controller->DeviceWaitQueue); @@ -140,7 +140,7 @@ IoDeleteController(PCONTROLLER_OBJECT ControllerObject) /* * @implemented * - * FUNCTION: Releases a previously allocated controller object when a + * FUNCTION: Releases a previously allocated controller object when a * device has finished an I/O request * ARGUMENTS: * ControllerObject = Controller object to be released @@ -157,8 +157,8 @@ IoFreeController(PCONTROLLER_OBJECT ControllerObject) if ((QueueEntry = KeRemoveDeviceQueue(&ControllerObject->DeviceWaitQueue))) { /* Get the Device Object */ - DeviceObject = CONTAINING_RECORD(QueueEntry, - DEVICE_OBJECT, + DeviceObject = CONTAINING_RECORD(QueueEntry, + DEVICE_OBJECT, Queue.Wcb.WaitQueueEntry); /* Call the routine */ Result = DeviceObject->Queue.Wcb.DeviceRoutine(DeviceObject, diff --git a/reactos/ntoskrnl/io/device.c b/reactos/ntoskrnl/io/device.c index 17554f23704..cb4cd2ea5f0 100644 --- a/reactos/ntoskrnl/io/device.c +++ b/reactos/ntoskrnl/io/device.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS Kernel * FILE: ntoskrnl/io/device.c * PURPOSE: Device Object Management, including Notifications and Queues. - * + * * PROGRAMMERS: Alex Ionescu * David Welch (welch@cwcom.net) */ @@ -33,7 +33,7 @@ KSPIN_LOCK ShutdownListLock; /* PRIVATE FUNCTIONS **********************************************************/ -VOID +VOID IoShutdownRegisteredDevices(VOID) { PSHUTDOWN_ENTRY ShutdownEntry; @@ -75,7 +75,7 @@ IoShutdownRegisteredDevices(VOID) } } -NTSTATUS +NTSTATUS FASTCALL IopInitializeDevice(PDEVICE_NODE DeviceNode, PDRIVER_OBJECT DriverObject) @@ -180,7 +180,7 @@ IopGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, HANDLE FileHandle; NTSTATUS Status; - DPRINT("IoGetDeviceObjectPointer(ObjectName %wZ, DesiredAccess %x," + DPRINT("IoGetDeviceObjectPointer(ObjectName %wZ, DesiredAccess %x," "FileObject %p DeviceObject %p)\n", ObjectName, DesiredAccess, FileObject, DeviceObject); @@ -216,7 +216,7 @@ IopGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, *DeviceObject = IoGetRelatedDeviceObject(LocalFileObject); *FileObject = LocalFileObject; } - + /* Close the handle */ ZwClose(FileHandle); return Status; @@ -242,7 +242,7 @@ IopGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, * Status * @implemented */ -NTSTATUS +NTSTATUS STDCALL IoAttachDevice(PDEVICE_OBJECT SourceDevice, PUNICODE_STRING TargetDeviceName, @@ -251,21 +251,21 @@ IoAttachDevice(PDEVICE_OBJECT SourceDevice, NTSTATUS Status; PFILE_OBJECT FileObject; PDEVICE_OBJECT TargetDevice; - + /* Call the helper routine for an attach operation */ DPRINT("IoAttachDevice\n"); - Status = IopGetDeviceObjectPointer(TargetDeviceName, - FILE_READ_ATTRIBUTES, + Status = IopGetDeviceObjectPointer(TargetDeviceName, + FILE_READ_ATTRIBUTES, &FileObject, &TargetDevice, IO_ATTACH_DEVICE_API); - + if (!NT_SUCCESS(Status)) { DPRINT1("Failed to get Device Object\n"); return Status; } - + /* Attach the device */ IoAttachDeviceToDeviceStackSafe(SourceDevice, TargetDevice, AttachedDevice); @@ -280,7 +280,7 @@ IoAttachDevice(PDEVICE_OBJECT SourceDevice, * Status * @implemented */ -NTSTATUS +NTSTATUS STDCALL IoAttachDeviceByPointer(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice) @@ -305,20 +305,20 @@ IoAttachDeviceByPointer(IN PDEVICE_OBJECT SourceDevice, * Status * @implemented */ -PDEVICE_OBJECT +PDEVICE_OBJECT STDCALL IoAttachDeviceToDeviceStack(PDEVICE_OBJECT SourceDevice, PDEVICE_OBJECT TargetDevice) { NTSTATUS Status; PDEVICE_OBJECT LocalAttach; - + /* Attach it safely */ DPRINT("IoAttachDeviceToDeviceStack\n"); Status = IoAttachDeviceToDeviceStackSafe(SourceDevice, TargetDevice, &LocalAttach); - + /* Return it */ DPRINT("IoAttachDeviceToDeviceStack DONE: %x\n", LocalAttach); return LocalAttach; @@ -335,17 +335,17 @@ IoAttachDeviceToDeviceStackSafe(IN PDEVICE_OBJECT SourceDevice, { PDEVICE_OBJECT AttachedDevice; PDEVOBJ_EXTENSION SourceDeviceExtension; - + DPRINT("IoAttachDeviceToDeviceStack(SourceDevice %x, TargetDevice %x)\n", SourceDevice, TargetDevice); /* Get the Attached Device and source extension */ AttachedDevice = IoGetAttachedDevice(TargetDevice); SourceDeviceExtension = SourceDevice->DeviceObjectExtension; - + /* Make sure that it's in a correct state */ - if (!(AttachedDevice->DeviceObjectExtension->ExtensionFlags & - (DOE_UNLOAD_PENDING | DOE_DELETE_PENDING | + if (!(AttachedDevice->DeviceObjectExtension->ExtensionFlags & + (DOE_UNLOAD_PENDING | DOE_DELETE_PENDING | DOE_REMOVE_PENDING | DOE_REMOVE_PROCESSED))) { /* Update fields */ @@ -355,16 +355,16 @@ IoAttachDeviceToDeviceStackSafe(IN PDEVICE_OBJECT SourceDevice, SourceDevice->AlignmentRequirement = AttachedDevice->AlignmentRequirement; SourceDevice->SectorSize = AttachedDevice->SectorSize; SourceDevice->Vpb = AttachedDevice->Vpb; - + /* Set the attachment in the device extension */ SourceDeviceExtension->AttachedTo = AttachedDevice; } - else + else { /* Device was unloading or being removed */ AttachedDevice = NULL; } - + /* Return the attached device */ *AttachedToDeviceObject = AttachedDevice; return STATUS_SUCCESS; @@ -402,7 +402,7 @@ IoAttachDeviceToDeviceStackSafe(IN PDEVICE_OBJECT SourceDevice, * Status * @implemented */ -NTSTATUS +NTSTATUS STDCALL IoCreateDevice(PDRIVER_OBJECT DriverObject, ULONG DeviceExtensionSize, @@ -421,38 +421,38 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject, ULONG AlignedDeviceExtensionSize; ULONG TotalSize; HANDLE TempHandle; - + ASSERT_IRQL(PASSIVE_LEVEL); DPRINT("IoCreateDevice(DriverObject %x)\n",DriverObject); - + /* Generate a name if we have to */ if (DeviceCharacteristics & FILE_AUTOGENERATED_DEVICE_NAME) { swprintf(AutoNameBuffer, L"\\Device\\%08lx", - InterlockedIncrementUL(&IopDeviceObjectNumber)); + InterlockedIncrementUL(&IopDeviceObjectNumber)); RtlInitUnicodeString(&AutoName, AutoNameBuffer); DeviceName = &AutoName; } - + /* Initialize the Object Attributes */ InitializeObjectAttributes(&ObjectAttributes, DeviceName, 0, NULL, NULL); - + /* Honor exclusive flag */ ObjectAttributes.Attributes |= OBJ_EXCLUSIVE; - + /* Create a permanent object for named devices */ if (DeviceName != NULL) { ObjectAttributes.Attributes |= OBJ_PERMANENT; } - + /* Align the Extension Size to 8-bytes */ AlignedDeviceExtensionSize = (DeviceExtensionSize + 7) &~ 7; DPRINT("AlignedDeviceExtensionSize %x\n", AlignedDeviceExtensionSize); - + /* Total Size */ - TotalSize = AlignedDeviceExtensionSize + + TotalSize = AlignedDeviceExtensionSize + sizeof(DEVICE_OBJECT) + sizeof(DEVOBJ_EXTENSION); DPRINT("TotalSize %x\n", TotalSize); @@ -466,51 +466,51 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject, 0, 0, (PVOID*)&CreatedDeviceObject); - + if (!NT_SUCCESS(Status)) { DPRINT1("IoCreateDevice() ObCreateObject failed, status: 0x%08X\n", Status); return Status; } - + /* Clear the whole Object and extension so we don't null stuff manually */ RtlZeroMemory(CreatedDeviceObject, TotalSize); DPRINT("CreatedDeviceObject %x\n", CreatedDeviceObject); - - /* + + /* * Setup the Type and Size. Note that we don't use the aligned size, * because that's only padding for the DevObjExt and not part of the Object. */ CreatedDeviceObject->Type = IO_TYPE_DEVICE; CreatedDeviceObject->Size = sizeof(DEVICE_OBJECT) + DeviceExtensionSize; - + /* The kernel extension is after the driver internal extension */ DeviceObjectExtension = (PDEVOBJ_EXTENSION) - ((ULONG_PTR)(CreatedDeviceObject + 1) + + ((ULONG_PTR)(CreatedDeviceObject + 1) + AlignedDeviceExtensionSize); - + /* Set the Type and Size. Question: why is Size 0 on Windows? */ DPRINT("DeviceObjectExtension %x\n", DeviceObjectExtension); DeviceObjectExtension->Type = IO_TYPE_DEVICE_OBJECT_EXTENSION; DeviceObjectExtension->Size = 0; - + /* Link the Object and Extension */ DeviceObjectExtension->DeviceObject = CreatedDeviceObject; CreatedDeviceObject->DeviceObjectExtension = DeviceObjectExtension; - - /* Set Device Object Data */ + + /* Set Device Object Data */ CreatedDeviceObject->DeviceType = DeviceType; CreatedDeviceObject->Characteristics = DeviceCharacteristics; CreatedDeviceObject->DeviceExtension = CreatedDeviceObject + 1; CreatedDeviceObject->StackSize = 1; CreatedDeviceObject->AlignmentRequirement = 1; /* FIXME */ - + /* Set the Flags */ /* FIXME: After the Driver is Loaded, the flag below should be removed */ CreatedDeviceObject->Flags = DO_DEVICE_INITIALIZING; if (Exclusive) CreatedDeviceObject->Flags |= DO_EXCLUSIVE; if (DeviceName) CreatedDeviceObject->Flags |= DO_DEVICE_HAS_NAME; - + /* Attach a Vpb for Disks and Tapes, and create the Device Lock */ if (CreatedDeviceObject->DeviceType == FILE_DEVICE_DISK || CreatedDeviceObject->DeviceType == FILE_DEVICE_VIRTUAL_DISK || @@ -519,13 +519,13 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject, { /* Create Vpb */ IopAttachVpb(CreatedDeviceObject); - + /* Initialize Lock Event */ KeInitializeEvent(&CreatedDeviceObject->DeviceLock, SynchronizationEvent, TRUE); } - + /* Set the right Sector Size */ switch (DeviceType) { @@ -539,7 +539,7 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject, CreatedDeviceObject->SectorSize = 2048; break; } - + /* Create the Device Queue */ KeInitializeDeviceQueue(&CreatedDeviceObject->DeviceQueue); @@ -550,22 +550,22 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject, 0, NULL, &TempHandle); - + if (!NT_SUCCESS(Status)) { DPRINT1("Cannot insert Device Object into Handle Table\n"); *DeviceObject = NULL; return Status; } - + /* Now do the final linking */ ObReferenceObject(DriverObject); CreatedDeviceObject->DriverObject = DriverObject; CreatedDeviceObject->NextDevice = DriverObject->DeviceObject; DriverObject->DeviceObject = CreatedDeviceObject; - + NtClose(TempHandle); - + /* Return to caller */ *DeviceObject = CreatedDeviceObject; return STATUS_SUCCESS; @@ -577,7 +577,7 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject, * Status * @implemented */ -VOID +VOID STDCALL IoDeleteDevice(PDEVICE_OBJECT DeviceObject) { @@ -605,17 +605,17 @@ IoDeleteDevice(PDEVICE_OBJECT DeviceObject) Previous = Previous->NextDevice; Previous->NextDevice = DeviceObject->NextDevice; } - + /* I guess this should be removed later... but it shouldn't cause problems */ DeviceObject->DeviceObjectExtension->ExtensionFlags |= DOE_DELETE_PENDING; - + /* Make the object temporary. This should automatically remove the device from the namespace */ ObMakeTemporaryObject(DeviceObject); - + /* Dereference the driver object */ ObDereferenceObject(DeviceObject->DriverObject); - + /* Remove the keep-alive reference */ ObDereferenceObject(DeviceObject); } @@ -629,9 +629,9 @@ IoDeleteDevice(PDEVICE_OBJECT DeviceObject) VOID STDCALL IoDetachDevice(PDEVICE_OBJECT TargetDevice) -{ - DPRINT("IoDetachDevice(TargetDevice %x)\n", TargetDevice); - +{ + DPRINT("IoDetachDevice(TargetDevice %x)\n", TargetDevice); + /* Remove the attachment */ TargetDevice->AttachedDevice->DeviceObjectExtension->AttachedTo = NULL; TargetDevice->AttachedDevice = NULL; @@ -649,47 +649,47 @@ IoEnumerateDeviceObjectList(IN PDRIVER_OBJECT DriverObject, { ULONG ActualDevices = 1; PDEVICE_OBJECT CurrentDevice = DriverObject->DeviceObject; - + DPRINT1("IoEnumerateDeviceObjectList\n"); - + /* Find out how many devices we'll enumerate */ while ((CurrentDevice = CurrentDevice->NextDevice)) { ActualDevices++; } - + /* Go back to the first */ CurrentDevice = DriverObject->DeviceObject; - + /* Start by at least returning this */ *ActualNumberDeviceObjects = ActualDevices; - + /* Check if we can support so many */ if ((ActualDevices * 4) > DeviceObjectListSize) { /* Fail because the buffer was too small */ return STATUS_BUFFER_TOO_SMALL; } - + /* Check if the caller only wanted the size */ - if (DeviceObjectList) + if (DeviceObjectList) { /* Loop through all the devices */ while (ActualDevices) { /* Reference each Device */ ObReferenceObject(CurrentDevice); - + /* Add it to the list */ *DeviceObjectList = CurrentDevice; - + /* Go to the next one */ CurrentDevice = CurrentDevice->NextDevice; ActualDevices--; DeviceObjectList++; } } - + /* Return the status */ return STATUS_SUCCESS; } @@ -700,18 +700,18 @@ IoEnumerateDeviceObjectList(IN PDRIVER_OBJECT DriverObject, * Status * @implemented */ -PDEVICE_OBJECT +PDEVICE_OBJECT STDCALL IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject) { PDEVICE_OBJECT Current = DeviceObject; - + /* Get the last attached device */ - while (Current->AttachedDevice) + while (Current->AttachedDevice) { Current = Current->AttachedDevice; } - + /* Return it */ return Current; } @@ -722,12 +722,12 @@ IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject) * Status * @implemented */ -PDEVICE_OBJECT +PDEVICE_OBJECT STDCALL IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject) { PDEVICE_OBJECT Current = IoGetAttachedDevice(DeviceObject); - + /* Reference the ATtached Device */ ObReferenceObject(Current); return Current; @@ -750,7 +750,7 @@ IoGetDeviceAttachmentBaseRef(IN PDEVICE_OBJECT DeviceObject) * Status * @implemented */ -NTSTATUS +NTSTATUS STDCALL IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, @@ -758,10 +758,10 @@ IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, OUT PDEVICE_OBJECT *DeviceObject) { /* Call the helper routine for a normal operation */ - return IopGetDeviceObjectPointer(ObjectName, - DesiredAccess, - FileObject, - DeviceObject, + return IopGetDeviceObjectPointer(ObjectName, + DesiredAccess, + FileObject, + DeviceObject, 0); } @@ -776,26 +776,26 @@ IoGetDiskDeviceObject(IN PDEVICE_OBJECT FileSystemDeviceObject, PDEVOBJ_EXTENSION DeviceExtension; PVPB Vpb; KIRQL OldIrql; - + /* Make sure there's a VPB */ if (!FileSystemDeviceObject->Vpb) return STATUS_INVALID_PARAMETER; - + /* Acquire it */ IoAcquireVpbSpinLock(&OldIrql); - + /* Get the Device Extension */ DeviceExtension = FileSystemDeviceObject->DeviceObjectExtension; - + /* Make sure this one has a VPB too */ Vpb = DeviceExtension->Vpb; if (!Vpb) return STATUS_INVALID_PARAMETER; - + /* Make sure someone it's mounted */ if ((!Vpb->ReferenceCount) || (Vpb->Flags & VPB_MOUNTED)) return STATUS_VOLUME_DISMOUNTED; - + /* Return the Disk Device Object */ *DiskDeviceObject = Vpb->RealDevice; - + /* Release the lock */ IoReleaseVpbSpinLock(OldIrql); return STATUS_SUCCESS; @@ -810,16 +810,16 @@ IoGetLowerDeviceObject(IN PDEVICE_OBJECT DeviceObject) { PDEVOBJ_EXTENSION DeviceExtension = DeviceObject->DeviceObjectExtension; PDEVICE_OBJECT LowerDeviceObject = NULL; - + /* Make sure it's not getting deleted */ - if (DeviceExtension->ExtensionFlags & (DOE_UNLOAD_PENDING | + if (DeviceExtension->ExtensionFlags & (DOE_UNLOAD_PENDING | DOE_DELETE_PENDING | - DOE_REMOVE_PENDING | + DOE_REMOVE_PENDING | DOE_REMOVE_PROCESSED)) { - /* Get the Lower Device Object */ - LowerDeviceObject = DeviceExtension->AttachedTo; - + /* Get the Lower Device Object */ + LowerDeviceObject = DeviceExtension->AttachedTo; + /* Reference it */ ObReferenceObject(LowerDeviceObject); } @@ -837,12 +837,12 @@ IoGetLowerDeviceObject(IN PDEVICE_OBJECT DeviceObject) * Status * @implemented */ -PDEVICE_OBJECT +PDEVICE_OBJECT STDCALL IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject) { PDEVICE_OBJECT DeviceObject = FileObject->DeviceObject; - + /* Get logical volume mounted on a physical/virtual/logical device */ if (FileObject->Vpb && FileObject->Vpb->DeviceObject) { @@ -853,7 +853,7 @@ IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject) * Check if file object has an associated device object mounted by some * other file system. */ - if (FileObject->DeviceObject->Vpb && + if (FileObject->DeviceObject->Vpb && FileObject->DeviceObject->Vpb->DeviceObject) { DeviceObject = FileObject->DeviceObject->Vpb->DeviceObject; @@ -878,7 +878,7 @@ IoRegisterLastChanceShutdownNotification(IN PDEVICE_OBJECT DeviceObject) * @implemented */ NTSTATUS -STDCALL +STDCALL IoRegisterShutdownNotification(PDEVICE_OBJECT DeviceObject) { PSHUTDOWN_ENTRY Entry; @@ -930,10 +930,10 @@ IoStartNextPacketByKey(PDEVICE_OBJECT DeviceObject, { PKDEVICE_QUEUE_ENTRY entry; PIRP Irp; - + entry = KeRemoveByKeyDeviceQueue(&DeviceObject->DeviceQueue, Key); - + if (entry != NULL) { Irp = CONTAINING_RECORD(entry, @@ -947,7 +947,7 @@ IoStartNextPacketByKey(PDEVICE_OBJECT DeviceObject, { DPRINT("No next irp\n"); DeviceObject->CurrentIrp = NULL; - } + } } /* @@ -961,22 +961,22 @@ IoStartNextPacketByKey(PDEVICE_OBJECT DeviceObject, */ VOID STDCALL -IoStartNextPacket(PDEVICE_OBJECT DeviceObject, +IoStartNextPacket(PDEVICE_OBJECT DeviceObject, BOOLEAN Cancelable) { PKDEVICE_QUEUE_ENTRY entry; PIRP Irp; - + DPRINT("IoStartNextPacket(DeviceObject %x, Cancelable %d)\n", DeviceObject,Cancelable); - + entry = KeRemoveDeviceQueue(&DeviceObject->DeviceQueue); - + if (entry!=NULL) { Irp = CONTAINING_RECORD(entry,IRP,Tail.Overlay.DeviceQueueEntry); DeviceObject->CurrentIrp = Irp; - DeviceObject->DriverObject->DriverStartIo(DeviceObject,Irp); + DeviceObject->DriverObject->DriverStartIo(DeviceObject,Irp); } else { @@ -999,24 +999,24 @@ IoStartNextPacket(PDEVICE_OBJECT DeviceObject, VOID STDCALL IoStartPacket(PDEVICE_OBJECT DeviceObject, - PIRP Irp, - PULONG Key, + PIRP Irp, + PULONG Key, PDRIVER_CANCEL CancelFunction) { BOOLEAN stat; KIRQL oldirql; - + DPRINT("IoStartPacket(Irp %x)\n", Irp); - + ASSERT_IRQL(DISPATCH_LEVEL); - + IoAcquireCancelSpinLock(&oldirql); - + if (CancelFunction != NULL) { Irp->CancelRoutine = CancelFunction; } - + if (Key!=0) { stat = KeInsertByKeyDeviceQueue(&DeviceObject->DeviceQueue, @@ -1028,10 +1028,10 @@ IoStartPacket(PDEVICE_OBJECT DeviceObject, stat = KeInsertDeviceQueue(&DeviceObject->DeviceQueue, &Irp->Tail.Overlay.DeviceQueueEntry); } - - + + if (!stat) - { + { IoReleaseCancelSpinLock(DISPATCH_LEVEL); DeviceObject->CurrentIrp = Irp; DeviceObject->DriverObject->DriverStartIo(DeviceObject,Irp); @@ -1061,8 +1061,8 @@ IoSynchronousInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, /* * @implemented */ -VOID -STDCALL +VOID +STDCALL IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject) { PSHUTDOWN_ENTRY ShutdownEntry; diff --git a/reactos/ntoskrnl/io/deviface.c b/reactos/ntoskrnl/io/deviface.c index 17966b22e41..0d7b654d0d9 100644 --- a/reactos/ntoskrnl/io/deviface.c +++ b/reactos/ntoskrnl/io/deviface.c @@ -1,10 +1,10 @@ -/* $Id:$ - * +/* $Id$ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/deviface.c * PURPOSE: Device interface functions - * + * * PROGRAMMERS: Filip Navara (xnavara@volny.cz) * Matthew Brace (ismarc@austin.rr.com) * Hervé Poussineau (hpoussin@reactos.com) @@ -53,30 +53,30 @@ IoGetDeviceInterfaceAlias( * Returns a list of device interfaces of a particular device interface class. * * Parameters - * InterfaceClassGuid + * InterfaceClassGuid * Points to a class GUID specifying the device interface class. * - * PhysicalDeviceObject + * PhysicalDeviceObject * Points to an optional PDO that narrows the search to only the - * device interfaces of the device represented by the PDO. + * device interfaces of the device represented by the PDO. * - * Flags + * Flags * Specifies flags that modify the search for device interfaces. The * DEVICE_INTERFACE_INCLUDE_NONACTIVE flag specifies that the list of * returned symbolic links should contain also disabled device - * interfaces in addition to the enabled ones. + * interfaces in addition to the enabled ones. * - * SymbolicLinkList + * SymbolicLinkList * Points to a character pointer that is filled in on successful return * with a list of unicode strings identifying the device interfaces * that match the search criteria. The newly allocated buffer contains * a list of symbolic link names. Each unicode string in the list is * null-terminated; the end of the whole list is marked by an additional * NULL. The caller is responsible for freeing the buffer (ExFreePool) - * when it is no longer needed. + * when it is no longer needed. * If no device interfaces match the search criteria, this routine * returns STATUS_SUCCESS and the string contains a single NULL - * character. + * character. * * Status * @implemented @@ -117,7 +117,7 @@ IoGetDeviceInterfaces( ULONG i = 0; ULONG j = 0; OBJECT_ATTRIBUTES ObjectAttributes; - + Status = RtlStringFromGUID(InterfaceClassGuid, &GuidString); if (!NT_SUCCESS(Status)) { @@ -159,17 +159,17 @@ IoGetDeviceInterfaces( } DPRINT("IoGetDeviceInterfaces() called with PDO, not implemented.\n"); - return STATUS_NOT_IMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; } else - { + { InitializeObjectAttributes( &ObjectAttributes, &BaseKeyName, OBJ_CASE_INSENSITIVE, NULL, NULL); - + Status = ZwOpenKey( &InterfaceKey, KEY_READ, @@ -206,7 +206,7 @@ IoGetDeviceInterfaces( fip, Size, &Size); - + if (!NT_SUCCESS(Status)) { DPRINT("ZwQueryKey() Failed. (0x%X)\n", Status); @@ -239,7 +239,7 @@ IoGetDeviceInterfaces( bip = (PKEY_BASIC_INFORMATION)ExAllocatePool(NonPagedPool, Size); ASSERT(bip != NULL); - + Status = ZwEnumerateKey( InterfaceKey, i, @@ -247,7 +247,7 @@ IoGetDeviceInterfaces( bip, Size, &Size); - + if (!NT_SUCCESS(Status)) { DPRINT("ZwEnumerateKey() Failed.(0x%X)\n", Status); @@ -259,7 +259,7 @@ IoGetDeviceInterfaces( ZwClose(InterfaceKey); return Status; } - + SubKeyName.Length = 0; SubKeyName.MaximumLength = BaseKeyName.Length + bip->NameLength + sizeof(WCHAR); SubKeyName.Buffer = ExAllocatePool(NonPagedPool, SubKeyName.MaximumLength); @@ -323,7 +323,7 @@ IoGetDeviceInterfaces( bfip, Size, &Size); - + if (!NT_SUCCESS(Status)) { DPRINT("ZwQueryKey() Failed. (0x%X)\n", Status); @@ -334,7 +334,7 @@ IoGetDeviceInterfaces( ZwClose(InterfaceKey); return Status; } - + for(j = 0; j < bfip->SubKeys; j++) { Status = ZwEnumerateKey( @@ -387,12 +387,12 @@ IoGetDeviceInterfaces( ZwClose(InterfaceKey); return Status; } - + if (!wcsncmp(bip->Name, L"Control", bip->NameLength)) { continue; } - + SymbolicLinkKeyName.Length = 0; SymbolicLinkKeyName.MaximumLength = SubKeyName.Length + bip->NameLength + sizeof(WCHAR); SymbolicLinkKeyName.Buffer = ExAllocatePool(NonPagedPool, SymbolicLinkKeyName.MaximumLength); @@ -409,7 +409,7 @@ IoGetDeviceInterfaces( ASSERT(ControlKeyName.Buffer != NULL); RtlCopyUnicodeString(&ControlKeyName, &SymbolicLinkKeyName); RtlAppendUnicodeStringToString(&ControlKeyName, &Control); - + ExFreePool(bip); InitializeObjectAttributes( @@ -440,16 +440,16 @@ IoGetDeviceInterfaces( } Status = ZwQueryValueKey( - SymbolicLinkKey, - &SymbolicLink, + SymbolicLinkKey, + &SymbolicLink, KeyValuePartialInformation, NULL, 0, &Size); - + if (Status == STATUS_OBJECT_NAME_NOT_FOUND) continue; - + if (Status != STATUS_BUFFER_TOO_SMALL) { DPRINT("ZwQueryValueKey() Failed.(0x%X)\n", Status); @@ -497,7 +497,7 @@ IoGetDeviceInterfaces( Status = RtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE, ControlKeyName.Buffer); if (NT_SUCCESS(Status)) - { + { /* Put the name in the string here */ if (SymLinkList == NULL) { @@ -525,7 +525,7 @@ IoGetDeviceInterfaces( RtlCopyMemory(SymLinkListPtr, vpip->Data, vpip->DataLength); SymLinkListPtr[vpip->DataLength / sizeof(WCHAR)] = 0; SymLinkListPtr[1] = '?'; - } + } } RtlFreeUnicodeString(&SymbolicLinkKeyName); @@ -549,7 +549,7 @@ IoGetDeviceInterfaces( } *SymbolicLinkList = SymLinkList; - + RtlFreeUnicodeString(&BaseKeyName); ZwClose(InterfaceKey); ExFreePool(bfip); @@ -584,20 +584,20 @@ IoRegisterDeviceInterface( OBJECT_ATTRIBUTES ObjectAttributes; ULONG i; NTSTATUS Status; - + if (!(PhysicalDeviceObject->Flags & DO_BUS_ENUMERATED_DEVICE)) { DPRINT("PhysicalDeviceObject 0x%p is not a valid Pdo\n", PhysicalDeviceObject); return STATUS_INVALID_PARAMETER_1; } - + Status = RtlStringFromGUID(InterfaceClassGuid, &GuidString); if (!NT_SUCCESS(Status)) { DPRINT("RtlStringFromGUID() failed with status 0x%08lx\n", Status); return Status; } - + /* Create Pdo name: \Device\xxxxxxxx (unnamed device) */ Status = ObQueryNameString( PhysicalDeviceObject, @@ -610,7 +610,7 @@ IoRegisterDeviceInterface( return Status; } ASSERT(PdoNameInfo->Name.Length); - + /* Create base key name for this interface: HKLM\SYSTEM\CurrentControlSet\DeviceClasses\{GUID}\##?#ACPI#PNP0501#1#{GUID} */ ASSERT(PhysicalDeviceObject->DeviceObjectExtension->DeviceNode); InstancePath = &PhysicalDeviceObject->DeviceObjectExtension->DeviceNode->InstancePath; @@ -641,7 +641,7 @@ IoRegisterDeviceInterface( } RtlAppendUnicodeToString(&BaseKeyName, L"#"); RtlAppendUnicodeStringToString(&BaseKeyName, &GuidString); - + /* Create BaseKeyName key in registry */ InitializeObjectAttributes( &ObjectAttributes, @@ -649,7 +649,7 @@ IoRegisterDeviceInterface( OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE | OBJ_OPENIF, NULL, /* RootDirectory */ NULL); /* SecurityDescriptor */ - + Status = ZwCreateKey( &InterfaceKey, KEY_WRITE, @@ -658,14 +658,14 @@ IoRegisterDeviceInterface( NULL, /* Class */ REG_OPTION_VOLATILE, NULL); /* Disposition */ - + if (!NT_SUCCESS(Status)) { DPRINT("ZwCreateKey() failed with status 0x%08lx\n", Status); ExFreePool(BaseKeyName.Buffer); return Status; } - + /* Write DeviceInstance entry. Value is InstancePath */ Status = ZwSetValueKey( InterfaceKey, @@ -681,7 +681,7 @@ IoRegisterDeviceInterface( ExFreePool(BaseKeyName.Buffer); return Status; } - + /* Create subkey. Name is #ReferenceString */ SubKeyName.Length = 0; SubKeyName.MaximumLength = sizeof(WCHAR); @@ -700,7 +700,7 @@ IoRegisterDeviceInterface( RtlAppendUnicodeToString(&SubKeyName, L"#"); if (ReferenceString && ReferenceString->Length) RtlAppendUnicodeStringToString(&SubKeyName, ReferenceString); - + /* Create SubKeyName key in registry */ InitializeObjectAttributes( &ObjectAttributes, @@ -708,7 +708,7 @@ IoRegisterDeviceInterface( OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, InterfaceKey, /* RootDirectory */ NULL); /* SecurityDescriptor */ - + Status = ZwCreateKey( &SubKey, KEY_WRITE, @@ -717,7 +717,7 @@ IoRegisterDeviceInterface( NULL, /* Class */ REG_OPTION_VOLATILE, NULL); /* Disposition */ - + if (!NT_SUCCESS(Status)) { DPRINT("ZwCreateKey() failed with status 0x%08lx\n", Status); @@ -725,7 +725,7 @@ IoRegisterDeviceInterface( ExFreePool(BaseKeyName.Buffer); return Status; } - + /* Create symbolic link name: \??\ACPI#PNP0501#1#{GUID}\ReferenceString */ SymbolicLinkName->Length = 0; SymbolicLinkName->MaximumLength = SymbolicLinkName->Length @@ -764,7 +764,7 @@ IoRegisterDeviceInterface( RtlAppendUnicodeStringToString(SymbolicLinkName, ReferenceString); } SymbolicLinkName->Buffer[SymbolicLinkName->Length] = '\0'; - + /* Create symbolic link */ DPRINT("IoRegisterDeviceInterface(): creating symbolic link %wZ -> %wZ\n", SymbolicLinkName, &PdoNameInfo->Name); Status = IoCreateSymbolicLink(SymbolicLinkName, &PdoNameInfo->Name); @@ -778,7 +778,7 @@ IoRegisterDeviceInterface( ExFreePool(SymbolicLinkName->Buffer); return Status; } - + /* Write symbolic link name in registry */ Status = ZwSetValueKey( SubKey, @@ -792,12 +792,12 @@ IoRegisterDeviceInterface( DPRINT("ZwSetValueKey() failed with status 0x%08lx\n", Status); ExFreePool(SymbolicLinkName->Buffer); } - + ZwClose(InterfaceKey); ZwClose(SubKey); ExFreePool(SubKeyName.Buffer); ExFreePool(BaseKeyName.Buffer); - + return Status; } @@ -816,10 +816,10 @@ IoSetDeviceInterfaceState( PWCHAR StartPosition; PWCHAR EndPosition; NTSTATUS Status; - + if (SymbolicLinkName == NULL) return STATUS_INVALID_PARAMETER_1; - + DPRINT("IoSetDeviceInterfaceState('%wZ', %d)\n", SymbolicLinkName, Enable); Status = IoGetDeviceObjectPointer(SymbolicLinkName, 0, /* DesiredAccess */ @@ -827,7 +827,7 @@ IoSetDeviceInterfaceState( &PhysicalDeviceObject); if (!NT_SUCCESS(Status)) return Status; - + /* Symbolic link name is \??\ACPI#PNP0501#1#{GUID}\ReferenceString */ /* Get GUID from SymbolicLinkName */ StartPosition = wcschr(SymbolicLinkName->Buffer, L'{'); @@ -836,16 +836,16 @@ IoSetDeviceInterfaceState( return STATUS_INVALID_PARAMETER_1; GuidString.Buffer = StartPosition; GuidString.MaximumLength = GuidString.Length = (ULONG_PTR)(EndPosition + 1) - (ULONG_PTR)StartPosition; - + IopNotifyPlugPlayNotification( PhysicalDeviceObject, EventCategoryDeviceInterfaceChange, Enable ? (LPGUID)&GUID_DEVICE_INTERFACE_ARRIVAL : (LPGUID)&GUID_DEVICE_INTERFACE_REMOVAL, &GuidString, (PVOID)SymbolicLinkName); - + ObDereferenceObject(FileObject); - + return STATUS_SUCCESS; } diff --git a/reactos/ntoskrnl/io/disk.c b/reactos/ntoskrnl/io/disk.c index 8eded0b698d..c76f5ea07b7 100644 --- a/reactos/ntoskrnl/io/disk.c +++ b/reactos/ntoskrnl/io/disk.c @@ -1389,7 +1389,7 @@ xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject, /* Set ending CHS values */ PartitionSector->Partition[j].EndingCylinder = EndCylinder & 0xff; PartitionSector->Partition[j].EndingHead = EndHead; - PartitionSector->Partition[j].EndingSector = + PartitionSector->Partition[j].EndingSector = ((EndCylinder & 0x0300) >> 2) + (EndSector & 0x3f); /* Calculate start sector and sector count */ @@ -1433,7 +1433,7 @@ xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject, if (IsContainerPartition (PartitionBuffer->PartitionEntry[i + j].PartitionType)) { ContainerEntry = TRUE; - NextPartitionOffset = + NextPartitionOffset = PartitionBuffer->PartitionEntry[i + j].StartingOffset.QuadPart; #if defined(__GNUC__) diff --git a/reactos/ntoskrnl/io/driver.c b/reactos/ntoskrnl/io/driver.c index 7e0bffb2c1f..0123602d6d9 100644 --- a/reactos/ntoskrnl/io/driver.c +++ b/reactos/ntoskrnl/io/driver.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/driver.c * PURPOSE: Loading and unloading of drivers - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) * Filip Navara (xnavara@volny.cz) */ @@ -121,7 +121,7 @@ IopInitDriverImplementation(VOID) InitializeListHead(&DriverReinitListHead); KeInitializeSpinLock(&DriverReinitListLock); DriverReinitTailEntry = NULL; - + InitializeListHead(&DriverBootReinitListHead); KeInitializeSpinLock(&DriverBootReinitListLock); DriverBootReinitTailEntry = NULL; @@ -235,7 +235,7 @@ IopCreateDriverObject( RtlInitUnicodeString(&DriverName, NameBuffer); DPRINT("Driver name: '%wZ'\n", &DriverName); - + Buffer = (PWSTR)ExAllocatePool(NonPagedPool, DriverName.Length); /* If we don't success, it is not a problem. Our driver * object will not have associated driver name... */ @@ -548,9 +548,9 @@ IopInitializeDriverModule( UNICODE_STRING RegistryKey; PDRIVER_INITIALIZE DriverEntry; NTSTATUS Status; - + DriverEntry = ModuleObject->EntryPoint; - + if (ServiceName != NULL && ServiceName->Length != 0) { RegistryKey.Length = 0; @@ -588,9 +588,9 @@ IopInitializeDriverModule( IopMarkLastReinitializeDriver(); Status = DriverEntry(*DriverObject, &RegistryKey); - + RtlFreeUnicodeString(&RegistryKey); - + if (!NT_SUCCESS(Status)) { ObMakeTemporaryObject(*DriverObject); @@ -624,7 +624,7 @@ IopAttachFilterDriversCallback( PMODULE_OBJECT ModuleObject; PDRIVER_OBJECT DriverObject; NTSTATUS Status; - + for (Filters = ValueData; ((ULONG_PTR)Filters - (ULONG_PTR)ValueData) < ValueLength && *Filters != 0; @@ -632,7 +632,7 @@ IopAttachFilterDriversCallback( { DPRINT("Filter Driver: %S (%wZ)\n", Filters, &DeviceNode->InstancePath); ServiceName.Buffer = Filters; - ServiceName.MaximumLength = + ServiceName.MaximumLength = ServiceName.Length = wcslen(Filters) * sizeof(WCHAR); /* Load and initialize the filter driver */ @@ -694,7 +694,7 @@ IopAttachFilterDrivers( /* * First load the device filters */ - + QueryTable[0].QueryRoutine = IopAttachFilterDriversCallback; if (Lower) QueryTable[0].Name = L"LowerFilters"; @@ -706,10 +706,10 @@ IopAttachFilterDrivers( QueryTable[1].Name = NULL; KeyBuffer = ExAllocatePool( - PagedPool, + PagedPool, (49 * sizeof(WCHAR)) + DeviceNode->InstancePath.Length); wcscpy(KeyBuffer, L"\\Registry\\Machine\\System\\CurrentControlSet\\Enum\\"); - wcscat(KeyBuffer, DeviceNode->InstancePath.Buffer); + wcscat(KeyBuffer, DeviceNode->InstancePath.Buffer); RtlQueryRegistryValues( RTL_REGISTRY_ABSOLUTE, @@ -766,11 +766,11 @@ IopAttachFilterDrivers( ExFreePool(KeyBuffer); } - + return STATUS_SUCCESS; } -static NTSTATUS STDCALL +static NTSTATUS STDCALL IopGetGroupOrderList(PWSTR ValueName, ULONG ValueType, PVOID ValueData, @@ -1223,7 +1223,7 @@ IopInitializeBuiltinDriver( Status = IopInitializeDriverModule(DeviceNode, ModuleObject, &DeviceNode->ServiceName, FALSE, &DriverObject); - + if (!NT_SUCCESS(Status)) { if (ModuleDeviceNode == NULL) @@ -1244,7 +1244,7 @@ IopInitializeBuiltinDriver( * * Parameters * None - * + * * Return Value * None */ @@ -1336,20 +1336,20 @@ IopLoadDriver(PSERVICE Service) if (Service->ErrorControl == 1) { /* Log error */ - } + } else if (Service->ErrorControl == 2) { if (IsLastKnownGood == FALSE) { /* Boot last known good configuration */ } - } + } else if (Service->ErrorControl == 3) { if (IsLastKnownGood == FALSE) { /* Boot last known good configuration */ - } + } else { /* BSOD! */ @@ -1368,7 +1368,7 @@ IopLoadDriver(PSERVICE Service) * * Parameters * None - * + * * Return Value * None */ @@ -1392,7 +1392,7 @@ IopInitializeSystemDrivers(VOID) DPRINT("Group: %wZ\n", &CurrentGroup->GroupName); - /* Load all drivers with a valid tag */ + /* Load all drivers with a valid tag */ for (i = 0; i < CurrentGroup->TagCount; i++) { ServiceEntry = ServiceListHead.Flink; @@ -1456,7 +1456,7 @@ IopInitializeSystemDrivers(VOID) * Whether to unload Plug & Plug or only legacy drivers. If this * parameter is set to FALSE, the routine will unload only legacy * drivers. - * + * * Return Value * Status * @@ -1670,22 +1670,22 @@ IoCreateDriver ( UNICODE_STRING ServiceKeyName; HANDLE hDriver; ULONG i; - + /* First, create a unique name for the driver if we don't have one */ if (!DriverName) { - + /* Create a random name and set up the string*/ NameLength = swprintf(NameBuffer, L"\\Driver\\%08u", KeTickCount); LocalDriverName.Length = NameLength * sizeof(WCHAR); LocalDriverName.MaximumLength = LocalDriverName.Length + sizeof(UNICODE_NULL); LocalDriverName.Buffer = NameBuffer; - + } else { - + /* So we can avoid another code path, use a local var */ LocalDriverName = *DriverName; } - + /* Initialize the Attributes */ ObjectSize = sizeof(DRIVER_OBJECT) + sizeof(DRIVER_EXTENSION); InitializeObjectAttributes(&ObjectAttributes, @@ -1693,7 +1693,7 @@ IoCreateDriver ( OBJ_PERMANENT | OBJ_CASE_INSENSITIVE, NULL, NULL); - + /* Create the Object */ Status = ObCreateObject(KernelMode, IoDriverObjectType, @@ -1704,10 +1704,10 @@ IoCreateDriver ( 0, 0, (PVOID*)&DriverObject); - + /* Return on failure */ if (!NT_SUCCESS(Status)) return Status; - + /* Set up the Object */ RtlZeroMemory(DriverObject, ObjectSize); DriverObject->Type = IO_TYPE_DRIVER; @@ -1716,13 +1716,13 @@ IoCreateDriver ( DriverObject->DriverExtension = (PDRIVER_EXTENSION)(DriverObject + 1); DriverObject->DriverExtension->DriverObject = DriverObject; DriverObject->DriverInit = InitializationFunction; - + /* Invalidate all Major Functions */ for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) { DriverObject->MajorFunction[i] = IopInvalidDeviceRequest; } - + /* Set up the Service Key Name */ ServiceKeyName.Buffer = ExAllocatePool(PagedPool, LocalDriverName.Length + sizeof(WCHAR)); ServiceKeyName.Length = LocalDriverName.Length; @@ -1730,10 +1730,10 @@ IoCreateDriver ( RtlMoveMemory(ServiceKeyName.Buffer, LocalDriverName.Buffer, LocalDriverName.Length); ServiceKeyName.Buffer[ServiceKeyName.Length / sizeof(WCHAR)] = L'\0'; DriverObject->DriverExtension->ServiceKeyName = ServiceKeyName; - + /* Also store it in the Driver Object. This is a bit of a hack. */ RtlMoveMemory(&DriverObject->DriverName, &ServiceKeyName, sizeof(UNICODE_STRING)); - + /* Add the Object and get its handle */ Status = ObInsertObject(DriverObject, NULL, @@ -1741,10 +1741,10 @@ IoCreateDriver ( 0, NULL, &hDriver); - + /* Return on Failure */ if (!NT_SUCCESS(Status)) return Status; - + /* Now reference it */ Status = ObReferenceObjectByHandle(hDriver, 0, @@ -1753,16 +1753,16 @@ IoCreateDriver ( (PVOID*)&DriverObject, NULL); ZwClose(hDriver); - + /* Finally, call its init function */ Status = (*InitializationFunction)(DriverObject, NULL); - + if (!NT_SUCCESS(Status)) { /* If it didn't work, then kill the object */ ObMakeTemporaryObject(DriverObject); ObDereferenceObject(DriverObject); } - + /* Return the Status */ return Status; } @@ -1789,7 +1789,7 @@ IoDeleteDriver ( * Parameters * DriverServiceName * Name of the service to load (registry key). - * + * * Return Value * Status * @@ -1811,9 +1811,9 @@ NtLoadDriver(IN PUNICODE_STRING DriverServiceName) PMODULE_OBJECT ModuleObject; PDRIVER_OBJECT DriverObject; WCHAR *cur; - + PAGED_CODE(); - + PreviousMode = KeGetPreviousMode(); /* @@ -1969,7 +1969,7 @@ NtLoadDriver(IN PUNICODE_STRING DriverServiceName) } IopInitializeDevice(DeviceNode, DriverObject); - + ReleaseCapturedString: RtlReleaseCapturedUnicodeString(&CapturedDriverServiceName, PreviousMode, @@ -1986,7 +1986,7 @@ ReleaseCapturedString: * Parameters * DriverServiceName * Name of the service to unload (registry key). - * + * * Return Value * Status * @@ -2022,7 +2022,7 @@ IoRegisterDriverReinitialization( ReinitItem->DriverObject = DriverObject; ReinitItem->ReinitRoutine = ReinitRoutine; ReinitItem->Context = Context; - + DriverObject->Flags |= DRVO_REINIT_REGISTERED; ExInterlockedInsertTailList( @@ -2051,7 +2051,7 @@ IoRegisterBootDriverReinitialization( ReinitItem->DriverObject = DriverObject; ReinitItem->ReinitRoutine = DriverReinitializationRoutine; ReinitItem->Context = Context; - + DriverObject->Flags |= DRVO_BOOTREINIT_REGISTERED; ExInterlockedInsertTailList( @@ -2086,9 +2086,9 @@ IoAllocateDriverObjectExtension( if (NewDriverExtension == NULL) { - return STATUS_INSUFFICIENT_RESOURCES; + return STATUS_INSUFFICIENT_RESOURCES; } - + OldIrql = KeRaiseIrqlToDpcLevel(); NewDriverExtension->Link = DriverObject->DriverSection; @@ -2112,7 +2112,7 @@ IoAllocateDriverObjectExtension( *DriverObjectExtension = &NewDriverExtension->Extension; - return STATUS_SUCCESS; + return STATUS_SUCCESS; } /* diff --git a/reactos/ntoskrnl/io/efi.c b/reactos/ntoskrnl/io/efi.c index a02a1d40bed..913791c9a3c 100644 --- a/reactos/ntoskrnl/io/efi.c +++ b/reactos/ntoskrnl/io/efi.c @@ -1,9 +1,9 @@ -/* +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/efi.c * PURPOSE: EFI Unimplemented Function Calls - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) */ @@ -24,7 +24,7 @@ NtAddBootEntry( UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; } - + NTSTATUS STDCALL NtDeleteBootEntry( @@ -35,7 +35,7 @@ NtDeleteBootEntry( UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; } - + NTSTATUS STDCALL NtEnumerateBootEntries( @@ -46,7 +46,7 @@ NtEnumerateBootEntries( UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; } - + NTSTATUS STDCALL NtQueryBootEntryOrder( @@ -57,7 +57,7 @@ NtQueryBootEntryOrder( UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; } - + NTSTATUS STDCALL NtQueryBootOptions( @@ -68,7 +68,7 @@ NtQueryBootOptions( UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; } - + NTSTATUS STDCALL NtSetBootEntryOrder( @@ -79,22 +79,22 @@ NtSetBootEntryOrder( UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; } - -NTSTATUS -STDCALL + +NTSTATUS +STDCALL NtSetBootOptions( - ULONG Unknown1, + ULONG Unknown1, ULONG Unknown2 ) { UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; -} - -NTSTATUS -STDCALL +} + +NTSTATUS +STDCALL NtTranslateFilePath( - ULONG Unknown1, + ULONG Unknown1, ULONG Unknown2, ULONG Unknown3 ) diff --git a/reactos/ntoskrnl/io/error.c b/reactos/ntoskrnl/io/error.c index b7364da68f2..bd4c81fa29e 100644 --- a/reactos/ntoskrnl/io/error.c +++ b/reactos/ntoskrnl/io/error.c @@ -457,7 +457,7 @@ IopFreeApc(PKAPC Apc, { /* Free the APC */ ExFreePool(Apc); -} +} VOID STDCALL @@ -470,25 +470,25 @@ IopRaiseHardError(PKAPC Apc, PIRP Irp = (PIRP)NormalContext; //PVPB Vpb = (PVPB)SystemArgument1; //PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT)SystemArgument2; - + /* FIXME: UNIMPLEMENTED */ Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED; Irp->IoStatus.Information = 0; IoCompleteRequest(Irp, IO_DISK_INCREMENT); -} +} /* * @implemented */ -VOID -STDCALL +VOID +STDCALL IoRaiseHardError(PIRP Irp, PVPB Vpb, PDEVICE_OBJECT RealDeviceObject) { PETHREAD Thread = (PETHREAD)&Irp->Tail.Overlay.Thread; PKAPC ErrorApc; - + /* Don't do anything if hard errors are disabled on the thread */ if (Thread->HardErrorsAreDisabled) { @@ -497,10 +497,10 @@ IoRaiseHardError(PIRP Irp, IoCompleteRequest(Irp, IO_DISK_INCREMENT); return; } - + /* Setup an APC */ - ErrorApc = ExAllocatePoolWithTag(NonPagedPool, - sizeof(KAPC), + ErrorApc = ExAllocatePoolWithTag(NonPagedPool, + sizeof(KAPC), TAG('K', 'A', 'P', 'C')); KeInitializeApc(ErrorApc, &Thread->Tcb, @@ -510,7 +510,7 @@ IoRaiseHardError(PIRP Irp, (PKNORMAL_ROUTINE)IopRaiseHardError, KernelMode, Irp); - + /* Queue an APC to deal with the error (see osr documentation) */ KeInsertQueueApc(ErrorApc, Vpb, RealDeviceObject, 0); } @@ -518,8 +518,8 @@ IoRaiseHardError(PIRP Irp, /* * @unimplemented */ -BOOLEAN -STDCALL +BOOLEAN +STDCALL IoRaiseInformationalHardError(NTSTATUS ErrorStatus, PUNICODE_STRING String, PKTHREAD Thread) @@ -543,7 +543,7 @@ IoRaiseInformationalHardError(NTSTATUS ErrorStatus, * * @implemented */ -BOOLEAN +BOOLEAN STDCALL IoSetThreadHardErrorMode(IN BOOLEAN HardErrorEnabled) { diff --git a/reactos/ntoskrnl/io/event.c b/reactos/ntoskrnl/io/event.c index 785df0330b1..8d02bb824ab 100644 --- a/reactos/ntoskrnl/io/event.c +++ b/reactos/ntoskrnl/io/event.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/event.c * PURPOSE: Implements named events - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -68,7 +68,7 @@ IoCreateSynchronizationEvent(PUNICODE_STRING EventName, PKEVENT Event; HANDLE Handle; NTSTATUS Status; - + PreviousMode = ExGetPreviousMode(); InitializeObjectAttributes(&ObjectAttributes, diff --git a/reactos/ntoskrnl/io/file.c b/reactos/ntoskrnl/io/file.c index 3c43a8695f9..faa1d8275c4 100644 --- a/reactos/ntoskrnl/io/file.c +++ b/reactos/ntoskrnl/io/file.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/file.c * PURPOSE: I/O File Object & NT File Handle Access/Managment of Files. - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -23,8 +23,8 @@ extern GENERIC_MAPPING IopFileMapping; /* INTERNAL FUNCTIONS ********************************************************/ -static -NTSTATUS +static +NTSTATUS STDCALL IopLockFileCompletionRoutine(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, @@ -38,16 +38,16 @@ IopLockFileCompletionRoutine(IN PDEVICE_OBJECT DeviceObject, /* * NAME INTERNAL * IopCreateFile - * + * * DESCRIPTION - * + * * ARGUMENTS - * + * * RETURN VALUE * * REVISIONS */ -NTSTATUS +NTSTATUS STDCALL IopCreateFile(PVOID ObjectBody, PVOID Parent, @@ -173,7 +173,7 @@ IopCreateFile(PVOID ObjectBody, return(STATUS_SUCCESS); } -VOID +VOID STDCALL IopDeleteFile(PVOID ObjectBody) { @@ -183,11 +183,11 @@ IopDeleteFile(PVOID ObjectBody) NTSTATUS Status; KEVENT Event; PDEVICE_OBJECT DeviceObject; - + DPRINT("IopDeleteFile()\n"); if (FileObject->DeviceObject) - { + { /* Check if this is a direct open or not */ if (FileObject->Flags & FO_DIRECT_DEVICE_OPEN) { @@ -197,46 +197,46 @@ IopDeleteFile(PVOID ObjectBody) { DeviceObject = IoGetRelatedDeviceObject(FileObject); } - + /* Clear and set up Events */ KeClearEvent(&FileObject->Event); KeInitializeEvent(&Event, SynchronizationEvent, FALSE); - + /* Allocate an IRP */ Irp = IoAllocateIrp(DeviceObject->StackSize, TRUE); - + /* Set it up */ Irp->UserEvent = &Event; Irp->UserIosb = &Irp->IoStatus; Irp->Tail.Overlay.Thread = PsGetCurrentThread(); Irp->Tail.Overlay.OriginalFileObject = FileObject; Irp->Flags = IRP_CLOSE_OPERATION | IRP_SYNCHRONOUS_API; - + /* Set up Stack Pointer Data */ StackPtr = IoGetNextIrpStackLocation(Irp); StackPtr->MajorFunction = IRP_MJ_CLOSE; StackPtr->DeviceObject = DeviceObject; StackPtr->FileObject = FileObject; - + /* Call the FS Driver */ Status = IoCallDriver(DeviceObject, Irp); - + /* Wait for completion */ if (Status == STATUS_PENDING) { KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); } IoFreeIrp(Irp); - + } - /* Clear the file name */ + /* Clear the file name */ if (FileObject->FileName.Buffer) { ExFreePool(FileObject->FileName.Buffer); FileObject->FileName.Buffer = NULL; } - + /* Free the completion context */ if (FileObject->CompletionContext) { @@ -245,7 +245,7 @@ IopDeleteFile(PVOID ObjectBody) } } -static +static NTSTATUS IopSetDefaultSecurityDescriptor(SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR SecurityDescriptor, @@ -489,7 +489,7 @@ IopQueryNameFile(PVOID ObjectBody, return Status; } -VOID +VOID STDCALL IopCloseFile(PVOID ObjectBody, ULONG HandleCount) @@ -500,9 +500,9 @@ IopCloseFile(PVOID ObjectBody, PIO_STACK_LOCATION StackPtr; NTSTATUS Status; PDEVICE_OBJECT DeviceObject; - + DPRINT("IopCloseFile()\n"); - + if (HandleCount > 1 || FileObject->DeviceObject == NULL) return; /* Check if this is a direct open or not */ @@ -514,29 +514,29 @@ IopCloseFile(PVOID ObjectBody, { DeviceObject = IoGetRelatedDeviceObject(FileObject); } - + /* Clear and set up Events */ KeClearEvent(&FileObject->Event); KeInitializeEvent(&Event, SynchronizationEvent, FALSE); - + /* Allocate an IRP */ Irp = IoAllocateIrp(DeviceObject->StackSize, TRUE); - + /* Set it up */ Irp->UserEvent = &Event; Irp->UserIosb = &Irp->IoStatus; Irp->Tail.Overlay.Thread = PsGetCurrentThread(); Irp->Tail.Overlay.OriginalFileObject = FileObject; Irp->Flags = IRP_CLOSE_OPERATION | IRP_SYNCHRONOUS_API; - + /* Set up Stack Pointer Data */ StackPtr = IoGetNextIrpStackLocation(Irp); StackPtr->MajorFunction = IRP_MJ_CLEANUP; StackPtr->FileObject = FileObject; - + /* Call the FS Driver */ Status = IoCallDriver(DeviceObject, Irp); - + /* Wait for completion */ if (Status == STATUS_PENDING) { @@ -576,60 +576,60 @@ IoCheckQuotaBufferValidity(IN PFILE_QUOTA_INFORMATION QuotaBuffer, /* * NAME EXPORTED * IoCreateFile@56 - * + * * DESCRIPTION * Either causes a new file or directory to be created, or it * opens an existing file, device, directory or volume, giving * the caller a handle for the file object. This handle can be * used by subsequent calls to manipulate data within the file * or the file object's state of attributes. - * + * * ARGUMENTS * FileHandle (OUT) * Points to a variable which receives the file handle * on return; - * + * * DesiredAccess * Desired access to the file; - * + * * ObjectAttributes * Structure describing the file; - * + * * IoStatusBlock (OUT) * Receives information about the operation on return; - * + * * AllocationSize [OPTIONAL] * Initial size of the file in bytes; - * + * * FileAttributes * Attributes to create the file with; - * + * * ShareAccess * Type of shared access the caller would like to the * file; - * + * * CreateDisposition * Specifies what to do, depending on whether the * file already exists; - * + * * CreateOptions * Options for creating a new file; - * + * * EaBuffer [OPTIONAL] * Undocumented; - * + * * EaLength * Undocumented; - * + * * CreateFileType * Type of file (normal, named pipe, mailslot) to create; - * + * * ExtraCreateParameters [OPTIONAL] * Additional creation data for named pipe and mailsots; - * + * * Options * Undocumented. - * + * * RETURN VALUE * Status * @@ -637,12 +637,12 @@ IoCheckQuotaBufferValidity(IN PFILE_QUOTA_INFORMATION QuotaBuffer, * Prototype taken from Bo Branten's ntifs.h v15. * Description taken from old NtCreateFile's which is * now a wrapper of this call. - * + * * REVISIONS - * + * * @implemented */ -NTSTATUS +NTSTATUS STDCALL IoCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, @@ -670,12 +670,12 @@ IoCreateFile(OUT PHANDLE FileHandle, LARGE_INTEGER SafeAllocationSize; PVOID SystemEaBuffer = NULL; NTSTATUS Status = STATUS_SUCCESS; - + DPRINT("IoCreateFile(FileHandle %x, DesiredAccess %x, " "ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n", FileHandle,DesiredAccess,ObjectAttributes, ObjectAttributes->ObjectName->Buffer); - + ASSERT_IRQL(PASSIVE_LEVEL); if (IoStatusBlock == NULL || FileHandle == NULL) @@ -687,7 +687,7 @@ IoCreateFile(OUT PHANDLE FileHandle, AccessMode = KernelMode; else AccessMode = ExGetPreviousMode(); - + if(AccessMode != KernelMode) { _SEH_TRY @@ -733,7 +733,7 @@ IoCreateFile(OUT PHANDLE FileHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -775,7 +775,7 @@ IoCreateFile(OUT PHANDLE FileHandle, AccessMode, (PVOID*)&DeviceObject, NULL); - ZwClose(LocalHandle); + ZwClose(LocalHandle); if (!NT_SUCCESS(Status)) { return Status; @@ -808,9 +808,9 @@ IoCreateFile(OUT PHANDLE FileHandle, return Status; } } - RtlMapGenericMask(&DesiredAccess, + RtlMapGenericMask(&DesiredAccess, BODY_TO_HEADER(FileObject)->ObjectType->Mapping); - + Status = ObInsertObject ((PVOID)FileObject, NULL, DesiredAccess, @@ -840,10 +840,10 @@ IoCreateFile(OUT PHANDLE FileHandle, SecurityContext.AccessState = NULL; /* ?? */ SecurityContext.DesiredAccess = DesiredAccess; SecurityContext.FullCreateOptions = 0; /* ?? */ - + KeInitializeEvent(&FileObject->Lock, SynchronizationEvent, TRUE); KeInitializeEvent(&FileObject->Event, NotificationEvent, FALSE); - + DPRINT("FileObject %x\n", FileObject); DPRINT("FileObject->DeviceObject %x\n", FileObject->DeviceObject); /* @@ -867,7 +867,7 @@ IoCreateFile(OUT PHANDLE FileHandle, Irp->Tail.Overlay.Thread = PsGetCurrentThread(); Irp->UserEvent = &FileObject->Event; Irp->Overlay.AllocationSize = SafeAllocationSize; - + /* * Get the stack location for the new * IRP and prepare it. @@ -891,7 +891,7 @@ IoCreateFile(OUT PHANDLE FileHandle, StackLoc->Parameters.Create.ShareAccess = (USHORT)ShareAccess; StackLoc->Parameters.Create.EaLength = SystemEaBuffer != NULL ? EaLength : 0; break; - + case CreateFileTypeNamedPipe: StackLoc->MajorFunction = IRP_MJ_CREATE_NAMED_PIPE; StackLoc->Parameters.CreatePipe.SecurityContext = &SecurityContext; @@ -919,7 +919,7 @@ IoCreateFile(OUT PHANDLE FileHandle, */ Status = IofCallDriver(FileObject->DeviceObject, Irp ); DPRINT("Status :%x\n", Status); - + if (Status == STATUS_PENDING) { KeWaitForSingleObject(&FileObject->Event, @@ -992,25 +992,25 @@ IoCreateFileSpecifyDeviceObjectHint(OUT PHANDLE FileHandle, /* * NAME EXPORTED * IoCreateStreamFileObject@8 - * + * * DESCRIPTION - * + * * ARGUMENTS * FileObject * ? - * + * * DeviceObject * ? - * + * * RETURN VALUE * * NOTE - * + * * REVISIONS - * + * * @implemented */ -PFILE_OBJECT +PFILE_OBJECT STDCALL IoCreateStreamFileObject(PFILE_OBJECT FileObject, PDEVICE_OBJECT DeviceObject) @@ -1046,14 +1046,14 @@ IoCreateStreamFileObject(PFILE_OBJECT FileObject, DPRINT("DeviceObject %x\n", DeviceObject); - if (DeviceObject->Vpb && + if (DeviceObject->Vpb && DeviceObject->Vpb->DeviceObject) { CreatedFileObject->DeviceObject = DeviceObject->Vpb->DeviceObject; } else { - CreatedFileObject->DeviceObject = DeviceObject; + CreatedFileObject->DeviceObject = DeviceObject; } CreatedFileObject->Vpb = DeviceObject->Vpb; CreatedFileObject->Type = IO_TYPE_FILE; @@ -1093,7 +1093,7 @@ IoCreateStreamFileObjectLite(IN PFILE_OBJECT FileObject OPTIONAL, /* * @implemented */ -PGENERIC_MAPPING +PGENERIC_MAPPING STDCALL IoGetFileObjectGenericMapping(VOID) { @@ -1126,7 +1126,7 @@ IoQueryFileDosDeviceName(IN PFILE_OBJECT FileObject, /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL IoQueryFileInformation(IN PFILE_OBJECT FileObject, IN FILE_INFORMATION_CLASS FileInformationClass, @@ -1141,20 +1141,20 @@ IoQueryFileInformation(IN PFILE_OBJECT FileObject, BOOLEAN LocalEvent = FALSE; KEVENT Event; NTSTATUS Status; - + ASSERT(FileInformation != NULL); - + Status = ObReferenceObjectByPointer(FileObject, FILE_READ_ATTRIBUTES, IoFileObjectType, KernelMode); if (!NT_SUCCESS(Status)) return(Status); - + DPRINT("FileObject %x\n", FileObject); - + /* Get the Device Object */ DeviceObject = IoGetRelatedDeviceObject(FileObject); - + /* Check if we should use Sync IO or not */ if (FileObject->Flags & FO_SYNCHRONOUS_IO) { @@ -1167,10 +1167,10 @@ IoQueryFileInformation(IN PFILE_OBJECT FileObject, KeInitializeEvent(&Event, SynchronizationEvent, FALSE); LocalEvent = TRUE; } - + /* Allocate the IRP */ Irp = IoAllocateIrp(DeviceObject->StackSize, TRUE); - + /* Set the IRP */ Irp->Tail.Overlay.OriginalFileObject = FileObject; Irp->RequestorMode = KernelMode; @@ -1179,42 +1179,42 @@ IoQueryFileInformation(IN PFILE_OBJECT FileObject, Irp->UserEvent = (LocalEvent) ? &Event : NULL; Irp->Flags = (LocalEvent) ? IRP_SYNCHRONOUS_API : 0; Irp->Tail.Overlay.Thread = PsGetCurrentThread(); - + /* Set the Stack Data */ StackPtr = IoGetNextIrpStackLocation(Irp); - StackPtr->MajorFunction = IRP_MJ_QUERY_INFORMATION; + StackPtr->MajorFunction = IRP_MJ_QUERY_INFORMATION; StackPtr->FileObject = FileObject; - + /* Set Parameters */ StackPtr->Parameters.QueryFile.FileInformationClass = FileInformationClass; StackPtr->Parameters.QueryFile.Length = Length; - + /* Call the Driver */ Status = IoCallDriver(FileObject->DeviceObject, Irp); - + if (Status == STATUS_PENDING) { if (LocalEvent) { - KeWaitForSingleObject(&Event, - Executive, - KernelMode, - FileObject->Flags & FO_ALERTABLE_IO, + KeWaitForSingleObject(&Event, + Executive, + KernelMode, + FileObject->Flags & FO_ALERTABLE_IO, NULL); Status = IoStatusBlock.Status; } else { KeWaitForSingleObject(&FileObject->Event, - Executive, - KernelMode, - FileObject->Flags & FO_ALERTABLE_IO, + Executive, + KernelMode, + FileObject->Flags & FO_ALERTABLE_IO, NULL); Status = FileObject->FinalStatus; } } - - + + /* Return the Length and Status. ReturnedLength is NOT optional */ *ReturnedLength = IoStatusBlock.Information; return Status; @@ -1235,7 +1235,7 @@ IoSetFileOrigin(IN PFILE_OBJECT FileObject, /** * @name NtCancelIoFile * - * Cancel all pending I/O operations in the current thread for specified + * Cancel all pending I/O operations in the current thread for specified * file object. * * @param FileHandle @@ -1249,7 +1249,7 @@ IoSetFileOrigin(IN PFILE_OBJECT FileObject, * * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtCancelIoFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock) @@ -1293,7 +1293,7 @@ NtCancelIoFile(IN HANDLE FileHandle, /* Don't break here, we want to cancel all IRPs for the file object. */ OurIrpsInList = TRUE; } - } + } KfLowerIrql(OldIrql); @@ -1349,14 +1349,14 @@ NtCancelIoFile(IN HANDLE FileHandle, /* * NAME EXPORTED * NtCreateFile@44 - * + * * DESCRIPTION * Entry point to call IoCreateFile with * default parameters. * * ARGUMENTS * See IoCreateFile. - * + * * RETURN VALUE * See IoCreateFile. * @@ -1366,7 +1366,7 @@ NtCancelIoFile(IN HANDLE FileHandle, * * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtCreateFile(PHANDLE FileHandle, ACCESS_MASK DesiredAccess, @@ -1409,14 +1409,14 @@ NtCreateMailslotFile(OUT PHANDLE FileHandle, IN PLARGE_INTEGER TimeOut) { MAILSLOT_CREATE_PARAMETERS Buffer; - + DPRINT("NtCreateMailslotFile(FileHandle %x, DesiredAccess %x, " "ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n", FileHandle,DesiredAccess,ObjectAttributes, ObjectAttributes->ObjectName->Buffer); - + ASSERT_IRQL(PASSIVE_LEVEL); - + if (TimeOut != NULL) { Buffer.ReadTimeout.QuadPart = TimeOut->QuadPart; @@ -1506,9 +1506,9 @@ NtCreateNamedPipeFile(PHANDLE FileHandle, /* * NAME EXPORTED * NtDeleteFile@4 - * + * * DESCRIPTION - * + * * ARGUMENTS * ObjectAttributes * ? @@ -1516,10 +1516,10 @@ NtCreateNamedPipeFile(PHANDLE FileHandle, * RETURN VALUE * * REVISIONS - * + * * @unimplemented */ -NTSTATUS +NTSTATUS STDCALL NtDeleteFile(IN POBJECT_ATTRIBUTES ObjectAttributes) { @@ -1539,10 +1539,10 @@ NtFlushWriteBuffer(VOID) * FUNCTION: Flushes cached file data to disk * ARGUMENTS: * FileHandle = Points to the file - * IoStatusBlock = Caller must supply storage to receive the result of + * IoStatusBlock = Caller must supply storage to receive the result of * the flush buffers operation. The information field is * set to number of bytes flushed to disk. - * RETURNS: Status + * RETURNS: Status * REMARKS: This function maps to the win32 FlushFileBuffers */ NTSTATUS @@ -1577,7 +1577,7 @@ NtFlushBuffersFile(IN HANDLE FileHandle, { DeviceObject = IoGetRelatedDeviceObject(FileObject); } - + /* Check if we should use Sync IO or not */ if (FileObject->Flags & FO_SYNCHRONOUS_IO) { @@ -1597,7 +1597,7 @@ NtFlushBuffersFile(IN HANDLE FileHandle, ObDereferenceObject(FileObject); return STATUS_INSUFFICIENT_RESOURCES; } - + /* Set up the IRP */ Irp->Flags = (LocalEvent) ? IRP_SYNCHRONOUS_API : 0; Irp->RequestorMode = PreviousMode; @@ -1610,26 +1610,26 @@ NtFlushBuffersFile(IN HANDLE FileHandle, StackPtr = IoGetNextIrpStackLocation(Irp); StackPtr->MajorFunction = IRP_MJ_FLUSH_BUFFERS; StackPtr->FileObject = FileObject; - + /* Call the Driver */ Status = IoCallDriver(DeviceObject, Irp); if (Status == STATUS_PENDING) { if (LocalEvent) { - KeWaitForSingleObject(&Event, - Executive, - PreviousMode, - FileObject->Flags & FO_ALERTABLE_IO, + KeWaitForSingleObject(&Event, + Executive, + PreviousMode, + FileObject->Flags & FO_ALERTABLE_IO, NULL); Status = IoStatusBlock->Status; } else { KeWaitForSingleObject(&FileObject->Event, - Executive, - PreviousMode, - FileObject->Flags & FO_ALERTABLE_IO, + Executive, + PreviousMode, + FileObject->Flags & FO_ALERTABLE_IO, NULL); Status = FileObject->FinalStatus; } @@ -1645,9 +1645,9 @@ NtFlushBuffersFile(IN HANDLE FileHandle, NTSTATUS STDCALL NtNotifyChangeDirectoryFile(IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, OUT PIO_STATUS_BLOCK IoStatusBlock, OUT PVOID Buffer, IN ULONG BufferSize, @@ -1660,13 +1660,13 @@ NtNotifyChangeDirectoryFile(IN HANDLE FileHandle, PIO_STACK_LOCATION IoStack; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + DPRINT("NtNotifyChangeDirectoryFile()\n"); - + PAGED_CODE(); PreviousMode = ExGetPreviousMode(); - + if(PreviousMode != KernelMode) { _SEH_TRY @@ -1686,7 +1686,7 @@ NtNotifyChangeDirectoryFile(IN HANDLE FileHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -1700,18 +1700,18 @@ NtNotifyChangeDirectoryFile(IN HANDLE FileHandle, (PVOID *)&FileObject, NULL); if (Status != STATUS_SUCCESS) return(Status); - - + + DeviceObject = FileObject->DeviceObject; - - + + Irp = IoAllocateIrp(DeviceObject->StackSize, TRUE); if (Irp==NULL) { ObDereferenceObject(FileObject); return STATUS_UNSUCCESSFUL; } - + if (Event == NULL) { Event = &FileObject->Event; @@ -1727,16 +1727,16 @@ NtNotifyChangeDirectoryFile(IN HANDLE FileHandle, Irp->UserBuffer = Buffer; Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine; Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext; - + IoStack = IoGetNextIrpStackLocation(Irp); - + IoStack->MajorFunction = IRP_MJ_DIRECTORY_CONTROL; IoStack->MinorFunction = IRP_MN_NOTIFY_CHANGE_DIRECTORY; IoStack->Flags = 0; IoStack->Control = 0; IoStack->DeviceObject = DeviceObject; IoStack->FileObject = FileObject; - + if (WatchTree) { IoStack->Flags = SL_WATCH_TREE; @@ -1744,7 +1744,7 @@ NtNotifyChangeDirectoryFile(IN HANDLE FileHandle, IoStack->Parameters.NotifyDirectory.CompletionFilter = CompletionFilter; IoStack->Parameters.NotifyDirectory.Length = BufferSize; - + Status = IoCallDriver(FileObject->DeviceObject,Irp); /* FIXME: Should we wait here or not for synchronously opened files? */ @@ -1915,39 +1915,39 @@ fail:; /* * NAME EXPORTED * NtOpenFile@24 - * + * * DESCRIPTION * Opens an existing file (simpler than NtCreateFile). * * ARGUMENTS * FileHandle (OUT) * Variable that receives the file handle on return; - * + * * DesiredAccess * Access desired by the caller to the file; - * + * * ObjectAttributes * Structue describing the file to be opened; - * + * * IoStatusBlock (OUT) * Receives details about the result of the * operation; - * + * * ShareAccess * Type of shared access the caller requires; - * + * * OpenOptions * Options for the file open. * * RETURN VALUE * Status. - * + * * NOTE * Undocumented. * * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtOpenFile(PHANDLE FileHandle, ACCESS_MASK DesiredAccess, @@ -1973,7 +1973,7 @@ NtOpenFile(PHANDLE FileHandle, 0); } -NTSTATUS +NTSTATUS STDCALL NtQueryAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PFILE_BASIC_INFORMATION FileInformation) @@ -2028,10 +2028,10 @@ NtQueryAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes, * FileBothDirectoryInformation FILE_BOTH_DIR_INFORMATION * * Length = Size of the storage supplied - * FileInformationClass = Indicates the type of information requested. - * ReturnSingleEntry = Specify true if caller only requests the first + * FileInformationClass = Indicates the type of information requested. + * ReturnSingleEntry = Specify true if caller only requests the first * directory found. - * FileName = Initial directory name to query, that may contain wild + * FileName = Initial directory name to query, that may contain wild * cards. * RestartScan = Number of times the action should be repeated * RETURNS: Status [ STATUS_SUCCESS, STATUS_ACCESS_DENIED, STATUS_INSUFFICIENT_RESOURCES, @@ -2039,7 +2039,7 @@ NtQueryAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes, * STATUS_INVALID_INFO_CLASS, STATUS_NO_SUCH_FILE, STATUS_NO_MORE_FILES ] */ NTSTATUS -STDCALL +STDCALL NtQueryDirectoryFile(IN HANDLE FileHandle, IN HANDLE PEvent OPTIONAL, IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, @@ -2060,10 +2060,10 @@ NtQueryDirectoryFile(IN HANDLE FileHandle, NTSTATUS Status = STATUS_SUCCESS; BOOLEAN LocalEvent = FALSE; PKEVENT Event = NULL; - + DPRINT("NtQueryDirectoryFile()\n"); PAGED_CODE(); - + /* Validate User-Mode Buffers */ if(PreviousMode != KernelMode) { @@ -2093,7 +2093,7 @@ NtQueryDirectoryFile(IN HANDLE FileHandle, (PVOID *)&FileObject, NULL); if (Status != STATUS_SUCCESS) return(Status); - + /* Get Event Object */ if (PEvent) { @@ -2116,7 +2116,7 @@ NtQueryDirectoryFile(IN HANDLE FileHandle, { DeviceObject = IoGetRelatedDeviceObject(FileObject); } - + /* Check if we should use Sync IO or not */ if (FileObject->Flags & FO_SYNCHRONOUS_IO) { @@ -2127,14 +2127,14 @@ NtQueryDirectoryFile(IN HANDLE FileHandle, { LocalEvent = TRUE; } - + /* Allocate the IRP */ if (!(Irp = IoAllocateIrp(DeviceObject->StackSize, TRUE))) { ObDereferenceObject(FileObject); return STATUS_INSUFFICIENT_RESOURCES; } - + /* Set up the IRP */ Irp->RequestorMode = PreviousMode; Irp->UserIosb = IoStatusBlock; @@ -2144,13 +2144,13 @@ NtQueryDirectoryFile(IN HANDLE FileHandle, Irp->UserBuffer = FileInformation; Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine; Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext; - + /* Set up Stack Data */ StackPtr = IoGetNextIrpStackLocation(Irp); StackPtr->FileObject = FileObject; StackPtr->MajorFunction = IRP_MJ_DIRECTORY_CONTROL; StackPtr->MinorFunction = IRP_MN_QUERY_DIRECTORY; - + /* Set Parameters */ StackPtr->Parameters.QueryDirectory.FileInformationClass = FileInformationClass; StackPtr->Parameters.QueryDirectory.FileName = FileName; @@ -2159,7 +2159,7 @@ NtQueryDirectoryFile(IN HANDLE FileHandle, StackPtr->Flags = 0; if (RestartScan) StackPtr->Flags = SL_RESTART_SCAN; if (ReturnSingleEntry) StackPtr->Flags |= SL_RETURN_SINGLE_ENTRY; - + /* Call the Driver */ Status = IoCallDriver(DeviceObject, Irp); if (Status == STATUS_PENDING) @@ -2167,9 +2167,9 @@ NtQueryDirectoryFile(IN HANDLE FileHandle, if (!LocalEvent) { KeWaitForSingleObject(&FileObject->Event, - Executive, - PreviousMode, - FileObject->Flags & FO_ALERTABLE_IO, + Executive, + PreviousMode, + FileObject->Flags & FO_ALERTABLE_IO, NULL); Status = FileObject->FinalStatus; } @@ -2197,7 +2197,7 @@ NtQueryEaFile(IN HANDLE FileHandle, return STATUS_NOT_IMPLEMENTED; } -NTSTATUS +NTSTATUS STDCALL NtQueryFullAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PFILE_NETWORK_OPEN_INFORMATION FileInformation) @@ -2302,7 +2302,7 @@ NtQueryInformationFile(HANDLE FileHandle, } DPRINT("FileObject %x\n", FileObject); - + /* Check if this is a direct open or not */ if (FileObject->Flags & FO_DIRECT_DEVICE_OPEN) { @@ -2312,7 +2312,7 @@ NtQueryInformationFile(HANDLE FileHandle, { DeviceObject = IoGetRelatedDeviceObject(FileObject); } - + /* Check if we should use Sync IO or not */ if (FileObject->Flags & FO_SYNCHRONOUS_IO) { @@ -2332,10 +2332,10 @@ NtQueryInformationFile(HANDLE FileHandle, ObDereferenceObject(FileObject); return STATUS_INSUFFICIENT_RESOURCES; } - + /* Allocate the System Buffer */ - if (!(Irp->AssociatedIrp.SystemBuffer = ExAllocatePoolWithTag(NonPagedPool, - Length, + if (!(Irp->AssociatedIrp.SystemBuffer = ExAllocatePoolWithTag(NonPagedPool, + Length, TAG_SYSB))) { IoFreeIrp(Irp); @@ -2352,7 +2352,7 @@ NtQueryInformationFile(HANDLE FileHandle, Irp->Tail.Overlay.Thread = PsGetCurrentThread(); Irp->Flags = IRP_BUFFERED_IO | IRP_DEALLOCATE_BUFFER | IRP_INPUT_OPERATION; Irp->Flags |= (LocalEvent) ? IRP_SYNCHRONOUS_API : 0; - + /* Set up Stack Data */ StackPtr = IoGetNextIrpStackLocation(Irp); StackPtr->MajorFunction = IRP_MJ_QUERY_INFORMATION; @@ -2361,26 +2361,26 @@ NtQueryInformationFile(HANDLE FileHandle, /* Set the Parameters */ StackPtr->Parameters.QueryFile.FileInformationClass = FileInformationClass; StackPtr->Parameters.QueryFile.Length = Length; - + /* Call the Driver */ Status = IoCallDriver(DeviceObject, Irp); if (Status == STATUS_PENDING) { if (LocalEvent) { - KeWaitForSingleObject(&Event, - Executive, - PreviousMode, - FileObject->Flags & FO_ALERTABLE_IO, + KeWaitForSingleObject(&Event, + Executive, + PreviousMode, + FileObject->Flags & FO_ALERTABLE_IO, NULL); Status = IoStatusBlock->Status; } else { KeWaitForSingleObject(&FileObject->Event, - Executive, - PreviousMode, - FileObject->Flags & FO_ALERTABLE_IO, + Executive, + PreviousMode, + FileObject->Flags & FO_ALERTABLE_IO, NULL); Status = FileObject->FinalStatus; } @@ -2423,7 +2423,7 @@ NtQueryQuotaInformationFile(IN HANDLE FileHandle, * * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtReadFile(IN HANDLE FileHandle, IN HANDLE Event OPTIONAL, @@ -2448,7 +2448,7 @@ NtReadFile(IN HANDLE FileHandle, "IoStatusBlock %x)\n", FileHandle, Buffer, Length, ByteOffset, IoStatusBlock); PAGED_CODE(); - + /* Validate User-Mode Buffers */ if(PreviousMode != KernelMode) { @@ -2461,7 +2461,7 @@ NtReadFile(IN HANDLE FileHandle, ProbeForWrite(Buffer, Length, sizeof(ULONG)); - #endif + #endif } _SEH_HANDLE { @@ -2480,9 +2480,9 @@ NtReadFile(IN HANDLE FileHandle, (PVOID*)&FileObject, NULL); if (!NT_SUCCESS(Status)) return Status; - + /* Check the Byte Offset */ - if (!ByteOffset || + if (!ByteOffset || (ByteOffset->u.LowPart == FILE_USE_FILE_POINTER_POSITION && ByteOffset->u.HighPart == 0xffffffff)) { @@ -2525,7 +2525,7 @@ NtReadFile(IN HANDLE FileHandle, { DeviceObject = IoGetRelatedDeviceObject(FileObject); } - + /* Check if we should use Sync IO or not */ if (FileObject->Flags & FO_SYNCHRONOUS_IO) { @@ -2536,7 +2536,7 @@ NtReadFile(IN HANDLE FileHandle, { LocalEvent = TRUE; } - + /* Create the IRP */ _SEH_TRY { @@ -2573,7 +2573,7 @@ NtReadFile(IN HANDLE FileHandle, Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext; Irp->Flags |= IRP_READ_OPERATION; if (FileObject->Flags & FO_NO_INTERMEDIATE_BUFFERING) Irp->Flags |= IRP_NOCACHE; - + /* Setup Stack Data */ StackPtr = IoGetNextIrpStackLocation(Irp); StackPtr->FileObject = FileObject; @@ -2586,9 +2586,9 @@ NtReadFile(IN HANDLE FileHandle, if (!LocalEvent) { KeWaitForSingleObject(&FileObject->Event, - Executive, - PreviousMode, - FileObject->Flags & FO_ALERTABLE_IO, + Executive, + PreviousMode, + FileObject->Flags & FO_ALERTABLE_IO, NULL); Status = FileObject->FinalStatus; } @@ -2601,7 +2601,7 @@ NtReadFile(IN HANDLE FileHandle, /* * NAME EXPORTED * NtReadFileScatter - * + * * DESCRIPTION * * ARGUMENTS @@ -2629,7 +2629,7 @@ NtReadFileScatter(IN HANDLE FileHandle, /* * @unimplemented */ -NTSTATUS +NTSTATUS STDCALL NtSetEaFile(IN HANDLE FileHandle, IN PIO_STATUS_BLOCK IoStatusBlock, @@ -2820,7 +2820,7 @@ NtSetInformationFile(HANDLE FileHandle, /* * @unimplemented */ -NTSTATUS +NTSTATUS STDCALL NtSetQuotaInformationFile(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, @@ -2945,7 +2945,7 @@ fail:; * * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtWriteFile (IN HANDLE FileHandle, IN HANDLE Event OPTIONAL, @@ -3108,7 +3108,7 @@ NtWriteFile (IN HANDLE FileHandle, /* * NAME EXPORTED * NtWriteFileGather - * + * * DESCRIPTION * * ARGUMENTS diff --git a/reactos/ntoskrnl/io/fs.c b/reactos/ntoskrnl/io/fs.c index 1bec40bbabb..ababaef3925 100644 --- a/reactos/ntoskrnl/io/fs.c +++ b/reactos/ntoskrnl/io/fs.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/fs.c * PURPOSE: Filesystem functions - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -152,7 +152,7 @@ NtFsControlFile ( StackPtr->FileObject = FileObject; StackPtr->DeviceObject = DeviceObject; StackPtr->Parameters.FileSystemControl.InputBufferLength = InputBufferSize; - StackPtr->Parameters.FileSystemControl.OutputBufferLength = + StackPtr->Parameters.FileSystemControl.OutputBufferLength = OutputBufferSize; StackPtr->MajorFunction = IRP_MJ_FILE_SYSTEM_CONTROL; @@ -672,7 +672,7 @@ IoGetBaseFileSystemDeviceObject(IN PFILE_OBJECT FileObject) * If the FILE_OBJECT's VPB is defined, * get the device from it. */ - if (NULL != (Vpb = FileObject->Vpb)) + if (NULL != (Vpb = FileObject->Vpb)) { if (NULL != (DeviceObject = Vpb->DeviceObject)) { @@ -685,7 +685,7 @@ IoGetBaseFileSystemDeviceObject(IN PFILE_OBJECT FileObject) * in the FILE_OBJECT's DeviceObject. */ DeviceObject = FileObject->DeviceObject; - if (NULL == (Vpb = DeviceObject->Vpb)) + if (NULL == (Vpb = DeviceObject->Vpb)) { /* DeviceObject->Vpb UNDEFINED! */ return DeviceObject; diff --git a/reactos/ntoskrnl/io/iocomp.c b/reactos/ntoskrnl/io/iocomp.c index fe54d181772..3590a679df4 100644 --- a/reactos/ntoskrnl/io/iocomp.c +++ b/reactos/ntoskrnl/io/iocomp.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/iocomp.c * PURPOSE: No purpose listed. - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -13,13 +13,13 @@ #define NDEBUG #include -#define IOC_TAG TAG('I', 'O', 'C', 'T') +#define IOC_TAG TAG('I', 'O', 'C', 'T') POBJECT_TYPE ExIoCompletionType; NPAGED_LOOKASIDE_LIST IoCompletionPacketLookaside; -static GENERIC_MAPPING ExIoCompletionMapping = +static GENERIC_MAPPING ExIoCompletionMapping = { STANDARD_RIGHTS_READ | IO_COMPLETION_QUERY_STATE, STANDARD_RIGHTS_WRITE | IO_COMPLETION_MODIFY_STATE, @@ -35,7 +35,7 @@ static const INFORMATION_CLASS_INFO ExIoCompletionInfoClass[] = { /* FUNCTIONS *****************************************************************/ -VOID +VOID STDCALL IopDeleteIoCompletion(PVOID ObjectBody) { @@ -48,19 +48,19 @@ IopDeleteIoCompletion(PVOID ObjectBody) /* Rundown the Queue */ FirstEntry = KeRundownQueue(Queue); - + /* Clean up the IRPs */ if (FirstEntry) { - + CurrentEntry = FirstEntry; do { - + /* Get the Packet */ Packet = CONTAINING_RECORD(CurrentEntry, IO_COMPLETION_PACKET, ListEntry); - + /* Go to next Entry */ CurrentEntry = CurrentEntry->Flink; - + /* Free it */ ExFreeToNPagedLookasideList(&IoCompletionPacketLookaside, Packet); } while (FirstEntry != CurrentEntry); @@ -85,13 +85,13 @@ IoSetIoCompletion(IN PVOID IoCompletion, /* Allocate the Packet */ Packet = ExAllocateFromNPagedLookasideList(&IoCompletionPacketLookaside); if (NULL == Packet) return STATUS_NO_MEMORY; - + /* Set up the Packet */ Packet->Key = KeyContext; Packet->Context = ApcContext; Packet->IoStatus.Status = IoStatus; Packet->IoStatus.Information = IoStatusInformation; - + /* Insert the Queue */ KeInsertQueue(Queue, &Packet->ListEntry); @@ -121,7 +121,7 @@ FASTCALL IopInitIoCompletionImplementation(VOID) { /* Create the IO Completion Type */ - ExIoCompletionType = ExAllocatePool(NonPagedPool, sizeof(OBJECT_TYPE)); + ExIoCompletionType = ExAllocatePool(NonPagedPool, sizeof(OBJECT_TYPE)); RtlInitUnicodeString(&ExIoCompletionType->TypeName, L"IoCompletion"); ExIoCompletionType->Tag = IOC_TAG; ExIoCompletionType->PeakObjects = 0; @@ -163,7 +163,7 @@ NtCreateIoCompletion(OUT PHANDLE IoCompletionHandle, HANDLE hIoCompletionHandle; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); if (PreviousMode != KernelMode) { @@ -177,7 +177,7 @@ NtCreateIoCompletion(OUT PHANDLE IoCompletionHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if (!NT_SUCCESS(Status)) { return Status; @@ -194,10 +194,10 @@ NtCreateIoCompletion(OUT PHANDLE IoCompletionHandle, 0, 0, (PVOID*)&Queue); - + /* Check for success */ if (NT_SUCCESS(Status)) { - + /* Initialize the Queue */ KeInitializeQueue(Queue, NumberOfConcurrentThreads); @@ -209,7 +209,7 @@ NtCreateIoCompletion(OUT PHANDLE IoCompletionHandle, NULL, &hIoCompletionHandle); ObDereferenceObject(Queue); - + if (NT_SUCCESS(Status)) { _SEH_TRY { @@ -221,7 +221,7 @@ NtCreateIoCompletion(OUT PHANDLE IoCompletionHandle, } _SEH_END; } } - + /* Return Status */ return Status; } @@ -235,9 +235,9 @@ NtOpenIoCompletion(OUT PHANDLE IoCompletionHandle, KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); HANDLE hIoCompletionHandle; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + if(PreviousMode != KernelMode) { _SEH_TRY { @@ -255,7 +255,7 @@ NtOpenIoCompletion(OUT PHANDLE IoCompletionHandle, return Status; } } - + /* Open the Object */ Status = ObOpenObjectByName(ObjectAttributes, ExIoCompletionType, @@ -264,7 +264,7 @@ NtOpenIoCompletion(OUT PHANDLE IoCompletionHandle, DesiredAccess, NULL, &hIoCompletionHandle); - + if (NT_SUCCESS(Status)) { _SEH_TRY { @@ -275,8 +275,8 @@ NtOpenIoCompletion(OUT PHANDLE IoCompletionHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; } - - /* Return Status */ + + /* Return Status */ return Status; } @@ -292,7 +292,7 @@ NtQueryIoCompletion(IN HANDLE IoCompletionHandle, PKQUEUE Queue; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); /* Check buffers and parameters */ @@ -316,10 +316,10 @@ NtQueryIoCompletion(IN HANDLE IoCompletionHandle, PreviousMode, (PVOID*)&Queue, NULL); - + /* Check for Success */ if (NT_SUCCESS(Status)) { - + _SEH_TRY { /* Return Info */ @@ -358,7 +358,7 @@ NtRemoveIoCompletion(IN HANDLE IoCompletionHandle, PLIST_ENTRY ListEntry; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); if (PreviousMode != KernelMode) { @@ -386,13 +386,13 @@ NtRemoveIoCompletion(IN HANDLE IoCompletionHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if (!NT_SUCCESS(Status)) { return Status; } } - + /* Open the Object */ Status = ObReferenceObjectByHandle(IoCompletionHandle, IO_COMPLETION_MODIFY_STATE, @@ -400,7 +400,7 @@ NtRemoveIoCompletion(IN HANDLE IoCompletionHandle, PreviousMode, (PVOID*)&Queue, NULL); - + /* Check for success */ if (NT_SUCCESS(Status)) { @@ -409,21 +409,21 @@ NtRemoveIoCompletion(IN HANDLE IoCompletionHandle, /* If we got a timeout or user_apc back, return the status */ if ((NTSTATUS)ListEntry == STATUS_TIMEOUT || (NTSTATUS)ListEntry == STATUS_USER_APC) { - - Status = (NTSTATUS)ListEntry; - + + Status = (NTSTATUS)ListEntry; + } else { - + /* Get the Packet Data */ Packet = CONTAINING_RECORD(ListEntry, IO_COMPLETION_PACKET, ListEntry); - + _SEH_TRY { /* Return it */ *CompletionKey = Packet->Key; *CompletionContext = Packet->Context; *IoStatusBlock = Packet->IoStatus; - + } _SEH_HANDLE { Status = _SEH_GetExceptionCode(); @@ -432,11 +432,11 @@ NtRemoveIoCompletion(IN HANDLE IoCompletionHandle, /* Free packet */ ExFreeToNPagedLookasideList(&IoCompletionPacketLookaside, Packet); } - + /* Dereference the Object */ ObDereferenceObject(Queue); } - + /* Return status */ return Status; } @@ -454,9 +454,9 @@ NtSetIoCompletion(IN HANDLE IoCompletionPortHandle, { NTSTATUS Status; PKQUEUE Queue; - + PAGED_CODE(); - + /* Get the Object */ Status = ObReferenceObjectByHandle(IoCompletionPortHandle, IO_COMPLETION_MODIFY_STATE, @@ -464,20 +464,20 @@ NtSetIoCompletion(IN HANDLE IoCompletionPortHandle, ExGetPreviousMode(), (PVOID*)&Queue, NULL); - + /* Check for Success */ if (NT_SUCCESS(Status)) { - + /* Set the Completion */ - Status = IoSetIoCompletion(Queue, - CompletionKey, + Status = IoSetIoCompletion(Queue, + CompletionKey, CompletionContext, - CompletionStatus, - CompletionInformation, + CompletionStatus, + CompletionInformation, TRUE); ObDereferenceObject(Queue); } - + /* Return status */ return Status; } diff --git a/reactos/ntoskrnl/io/iomgr.c b/reactos/ntoskrnl/io/iomgr.c index 1e2849be1c6..7fbe39ab733 100644 --- a/reactos/ntoskrnl/io/iomgr.c +++ b/reactos/ntoskrnl/io/iomgr.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS Kernel * FILE: ntoskrnl/io/iomgr.c * PURPOSE: I/O Manager Initialization and Misc Utility Functions - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -36,21 +36,21 @@ GENERIC_MAPPING IopFileMapping = { FILE_GENERIC_WRITE, FILE_GENERIC_EXECUTE, FILE_ALL_ACCESS}; - + static KSPIN_LOCK CancelSpinLock; extern LIST_ENTRY ShutdownListHead; extern KSPIN_LOCK ShutdownListLock; /* INIT FUNCTIONS ************************************************************/ -VOID +VOID INIT_FUNCTION IoInitCancelHandling(VOID) { KeInitializeSpinLock(&CancelSpinLock); } -VOID +VOID INIT_FUNCTION IoInitShutdownNotification (VOID) { @@ -68,13 +68,13 @@ IoInit (VOID) HANDLE Handle; IopInitDriverImplementation(); - + /* * Register iomgr types: DeviceObjectType */ IoDeviceObjectType = ExAllocatePool (NonPagedPool, sizeof (OBJECT_TYPE)); - + IoDeviceObjectType->Tag = TAG_DEVICE_TYPE; IoDeviceObjectType->TotalObjects = 0; IoDeviceObjectType->TotalHandles = 0; @@ -93,7 +93,7 @@ IoInit (VOID) IoDeviceObjectType->OkayToClose = NULL; IoDeviceObjectType->Create = NULL; IoDeviceObjectType->DuplicationNotify = NULL; - + RtlInitUnicodeString(&IoDeviceObjectType->TypeName, L"Device"); ObpCreateTypeObject(IoDeviceObjectType); @@ -103,7 +103,7 @@ IoInit (VOID) * (alias DriverObjectType) */ IoFileObjectType = ExAllocatePool (NonPagedPool, sizeof (OBJECT_TYPE)); - + IoFileObjectType->Tag = TAG_FILE_TYPE; IoFileObjectType->TotalObjects = 0; IoFileObjectType->TotalHandles = 0; @@ -122,11 +122,11 @@ IoInit (VOID) IoFileObjectType->OkayToClose = NULL; IoFileObjectType->Create = IopCreateFile; IoFileObjectType->DuplicationNotify = NULL; - + RtlInitUnicodeString(&IoFileObjectType->TypeName, L"File"); ObpCreateTypeObject(IoFileObjectType); - + /* * Register iomgr types: AdapterObjectType */ @@ -237,7 +237,7 @@ IoInit (VOID) PnpInit(); } -VOID +VOID INIT_FUNCTION IoInit2(BOOLEAN BootLog) { @@ -247,7 +247,7 @@ IoInit2(BOOLEAN BootLog) NTSTATUS Status; IoCreateDriverList(); - + KeInitializeSpinLock (&IoStatisticsLock); /* Initialize raw filesystem driver */ @@ -293,10 +293,10 @@ IoInit2(BOOLEAN BootLog) IopInvalidateDeviceRelations( IopRootDeviceNode, BusRelations); - + /* Start boot logging */ IopInitBootLog(BootLog); - + /* Load boot start drivers */ IopInitializeBootDrivers(); } @@ -307,7 +307,7 @@ INIT_FUNCTION IoInit3(VOID) { NTSTATUS Status; - + /* Create ARC names for boot devices */ IoCreateArcNames(); @@ -339,7 +339,7 @@ IoInit3(VOID) IoAssignDriveLetters((PLOADER_PARAMETER_BLOCK)&KeLoaderBlock, NULL, NULL, - NULL); + NULL); } /* FUNCTIONS *****************************************************************/ @@ -347,8 +347,8 @@ IoInit3(VOID) /* * @implemented */ -VOID -STDCALL +VOID +STDCALL IoAcquireCancelSpinLock(PKIRQL Irql) { KeAcquireSpinLock(&CancelSpinLock,Irql); @@ -357,7 +357,7 @@ IoAcquireCancelSpinLock(PKIRQL Irql) /* * @implemented */ -PVOID +PVOID STDCALL IoGetInitialStack(VOID) { @@ -367,7 +367,7 @@ IoGetInitialStack(VOID) /* * @implemented */ -VOID +VOID STDCALL IoGetStackLimits(OUT PULONG LowLimit, OUT PULONG HighLimit) @@ -403,7 +403,7 @@ IoIsWdmVersionAvailable(IN UCHAR MajorVersion, * @implemented */ VOID -STDCALL +STDCALL IoReleaseCancelSpinLock(KIRQL Irql) { KeReleaseSpinLock(&CancelSpinLock,Irql); diff --git a/reactos/ntoskrnl/io/iowork.c b/reactos/ntoskrnl/io/iowork.c index 62ce6683eda..f27c1761749 100644 --- a/reactos/ntoskrnl/io/iowork.c +++ b/reactos/ntoskrnl/io/iowork.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/iowork.c * PURPOSE: Manage IO system work queues - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) * Robert Dickenson (odin@pnc.com.au) */ @@ -44,9 +44,9 @@ IoWorkItemCallback(PVOID Parameter) * @implemented */ VOID STDCALL -IoQueueWorkItem(IN PIO_WORKITEM IoWorkItem, +IoQueueWorkItem(IN PIO_WORKITEM IoWorkItem, IN PIO_WORKITEM_ROUTINE WorkerRoutine, - IN WORK_QUEUE_TYPE QueueType, + IN WORK_QUEUE_TYPE QueueType, IN PVOID Context) /* * FUNCTION: Inserts a work item in a queue for one of the system worker @@ -56,7 +56,7 @@ IoQueueWorkItem(IN PIO_WORKITEM IoWorkItem, * QueueType = Queue to insert it in */ { - ExInitializeWorkItem(&IoWorkItem->Item, IoWorkItemCallback, + ExInitializeWorkItem(&IoWorkItem->Item, IoWorkItemCallback, (PVOID)IoWorkItem); IoWorkItem->WorkerRoutine = WorkerRoutine; IoWorkItem->Context = Context; @@ -83,8 +83,8 @@ PIO_WORKITEM STDCALL IoAllocateWorkItem(PDEVICE_OBJECT DeviceObject) { PIO_WORKITEM IoWorkItem = NULL; - - IoWorkItem = + + IoWorkItem = ExAllocatePoolWithTag(NonPagedPool, sizeof(IO_WORKITEM), TAG_IOWI); if (IoWorkItem == NULL) { diff --git a/reactos/ntoskrnl/io/irp.c b/reactos/ntoskrnl/io/irp.c index 47f692abbe5..71f265c2264 100644 --- a/reactos/ntoskrnl/io/irp.c +++ b/reactos/ntoskrnl/io/irp.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/irp.c * PURPOSE: Handle IRPs - * + * * PROGRAMMERS: Hartmut Birr * Alex Ionescu (alex@relsoft.net) * David Welch (welch@mcmail.com) @@ -22,7 +22,7 @@ /* PRIVATE FUNCTIONS ********************************************************/ -VOID +VOID STDCALL IopFreeIrpKernelApc(PKAPC Apc, PKNORMAL_ROUTINE *NormalRoutine, @@ -34,7 +34,7 @@ IopFreeIrpKernelApc(PKAPC Apc, IoFreeIrp(CONTAINING_RECORD(Apc, IRP, Tail.Apc)); } -VOID +VOID STDCALL IopAbortIrpKernelApc(PKAPC Apc) { @@ -44,7 +44,7 @@ IopAbortIrpKernelApc(PKAPC Apc) /* * FUNCTION: Performs the second stage of irp completion for read/write irps - * + * * Called as a special kernel APC kernel-routine or directly from IofCompleteRequest() * * Note that we'll never see irp's flagged IRP_PAGING_IO (IRP_MOUNT_OPERATION) @@ -52,7 +52,7 @@ IopAbortIrpKernelApc(PKAPC Apc) * cleanup/completion is fully taken care of in IoCompleteRequest. * -Gunnar */ -VOID +VOID STDCALL IopCompleteRequest(PKAPC Apc, PKNORMAL_ROUTINE* NormalRoutine, @@ -67,15 +67,15 @@ IopCompleteRequest(PKAPC Apc, BOOLEAN SyncIrp; if (Apc) DPRINT("IoSecondStageCompletition with APC: %x\n", Apc); - + /* Get data from the APC */ FileObject = (PFILE_OBJECT)(*SystemArgument1); Irp = CONTAINING_RECORD(Apc, IRP, Tail.Apc); DPRINT("IoSecondStageCompletition, %x\n", Irp); - + /* Save the User Event */ UserEvent = Irp->UserEvent; - + /* Remember if the IRP is Sync or not */ SyncIrp = Irp->Flags & IRP_SYNCHRONOUS_API ? TRUE : FALSE; @@ -90,17 +90,17 @@ IopCompleteRequest(PKAPC Apc, Irp->AssociatedIrp.SystemBuffer, Irp->IoStatus.Information); } - + /* Also check if we should de-allocate it */ if (Irp->Flags & IRP_DEALLOCATE_BUFFER) { ExFreePoolWithTag(Irp->AssociatedIrp.SystemBuffer, TAG_SYS_BUF); } } - + /* Now we got rid of these two... */ Irp->Flags &= ~(IRP_BUFFERED_IO | IRP_DEALLOCATE_BUFFER); - + /* Check if there's an MDL */ while ((Mdl = Irp->MdlAddress)) { @@ -111,15 +111,15 @@ IopCompleteRequest(PKAPC Apc, /* Remove the IRP from the list of Thread Pending IRPs */ RemoveEntryList(&Irp->ThreadListEntry); - InitializeListHead(&Irp->ThreadListEntry); + InitializeListHead(&Irp->ThreadListEntry); #if 1 /* Check for Success but allow failure for Async IRPs */ - if (NT_SUCCESS(Irp->IoStatus.Status) || + if (NT_SUCCESS(Irp->IoStatus.Status) || (Irp->PendingReturned && !SyncIrp && (FileObject == NULL || FileObject->Flags & FO_SYNCHRONOUS_IO))) - { + { _SEH_TRY { /* Save the IOSB Information */ @@ -130,7 +130,7 @@ IopCompleteRequest(PKAPC Apc, /* Ignore any error */ } _SEH_END; - + /* Check if there's an event */ if (UserEvent) { @@ -163,9 +163,9 @@ IopCompleteRequest(PKAPC Apc, /* Signal the File Object Instead */ KeSetEvent(&FileObject->Event, 0, FALSE); - + } - + /* Now call the User APC if one was requested */ if (Irp->Overlay.AsynchronousParameters.UserApcRoutine != NULL) { @@ -197,7 +197,7 @@ IopCompleteRequest(PKAPC Apc, } } else - { + { /* Signal the Events only if PendingReturned and we have a File Object */ if (FileObject && Irp->PendingReturned) { @@ -214,7 +214,7 @@ IopCompleteRequest(PKAPC Apc, /* Ignore any error */ } _SEH_END; - + /* Signal our event if we have one */ if (UserEvent) { @@ -229,7 +229,7 @@ IopCompleteRequest(PKAPC Apc, else { #if 1 - /* FIXME: This is necessary to fix bug #609 */ + /* FIXME: This is necessary to fix bug #609 */ _SEH_TRY { *Irp->UserIosb = Irp->IoStatus; @@ -242,27 +242,27 @@ IopCompleteRequest(PKAPC Apc, #endif /* We'll report the Status to the File Object, not the IRP */ FileObject->FinalStatus = Irp->IoStatus.Status; - + /* Signal the File Object ONLY if this was Async */ KeSetEvent(&FileObject->Event, 0, FALSE); } } - + /* Dereference the Event if it's an ASYNC IRP on a File Object */ if (UserEvent && !SyncIrp && FileObject) { if (UserEvent != &FileObject->Event) { ObDereferenceObject(UserEvent); - } + } } - } - + } + /* Dereference the File Object */ if (FileObject) ObDereferenceObject(FileObject); - + /* Free the IRP */ - if (Irp) IoFreeIrp(Irp); + if (Irp) IoFreeIrp(Irp); #else @@ -294,7 +294,7 @@ IopCompleteRequest(PKAPC Apc, } } } - + /* Signal the user event, if one exist */ if (UserEvent) { @@ -331,7 +331,7 @@ IopCompleteRequest(PKAPC Apc, Irp = NULL; } } - + /* Free the Irp if it hasn't already */ if (Irp) IoFreeIrp(Irp); @@ -339,7 +339,7 @@ IopCompleteRequest(PKAPC Apc, { /* Dereference the user event, if it is an event object */ /* FIXME: Remove last check when I/O code is fixed */ - if (UserEvent && !SyncIrp && UserEvent != &FileObject->Event) + if (UserEvent && !SyncIrp && UserEvent != &FileObject->Event) { ObDereferenceObject(UserEvent); } @@ -361,14 +361,14 @@ IopCompleteRequest(PKAPC Apc, * ChargeQuota = Charge allocation to current threads quota * RETURNS: Irp allocated */ -PIRP +PIRP STDCALL IoAllocateIrp(CCHAR StackSize, BOOLEAN ChargeQuota) { PIRP Irp; USHORT Size = IoSizeOfIrp(StackSize); - + /* Check if we shoudl charge quota */ if (ChargeQuota) { @@ -391,7 +391,7 @@ IoAllocateIrp(CCHAR StackSize, /* Now Initialize it */ IoInitializeIrp(Irp, Size, StackSize); - + /* Return it */ return Irp; } @@ -401,7 +401,7 @@ IoAllocateIrp(CCHAR StackSize, * * FUNCTION: Allocates and sets up an IRP to be sent to lower level drivers * ARGUMENTS: - * MajorFunction = One of IRP_MJ_READ, IRP_MJ_WRITE, + * MajorFunction = One of IRP_MJ_READ, IRP_MJ_WRITE, * IRP_MJ_FLUSH_BUFFERS or IRP_MJ_SHUTDOWN * DeviceObject = Device object to send the irp to * Buffer = Buffer into which data will be read or written @@ -431,17 +431,17 @@ IoBuildAsynchronousFsdRequest(ULONG MajorFunction, /* Allocate IRP */ if (!(Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE))) return Irp; - + /* Get the Stack */ StackPtr = IoGetNextIrpStackLocation(Irp); - + /* Write the Major function and then deal with it */ - StackPtr->MajorFunction = (UCHAR)MajorFunction; - + StackPtr->MajorFunction = (UCHAR)MajorFunction; + /* Do not handle the following here */ if (MajorFunction != IRP_MJ_FLUSH_BUFFERS && MajorFunction != IRP_MJ_SHUTDOWN && - MajorFunction != IRP_MJ_PNP) + MajorFunction != IRP_MJ_PNP) { /* Check if this is Buffered IO */ if (DeviceObject->Flags & DO_BUFFERED_IO) @@ -450,10 +450,10 @@ IoBuildAsynchronousFsdRequest(ULONG MajorFunction, Irp->AssociatedIrp.SystemBuffer = ExAllocatePoolWithTag(NonPagedPool, Length, TAG_SYS_BUF); - + /* Set flags */ Irp->Flags = IRP_BUFFERED_IO | IRP_DEALLOCATE_BUFFER; - + /* Handle special IRP_MJ_WRITE Case */ if (MajorFunction == IRP_MJ_WRITE) { @@ -471,7 +471,7 @@ IoBuildAsynchronousFsdRequest(ULONG MajorFunction, { /* Use an MDL for Direct I/O */ Irp->MdlAddress = MmCreateMdl(NULL, Buffer, Length); - + /* Use the right Access Type */ if (MajorFunction == IRP_MJ_READ) { @@ -481,7 +481,7 @@ IoBuildAsynchronousFsdRequest(ULONG MajorFunction, { AccessType = IoWriteAccess; } - + /* Probe and Lock */ _SEH_FILTER(FreeAndGoOn) { @@ -489,7 +489,7 @@ IoBuildAsynchronousFsdRequest(ULONG MajorFunction, IoFreeMdl(Irp->MdlAddress); IoFreeIrp(Irp); return EXCEPTION_CONTINUE_SEARCH; - } + } _SEH_TRY { /* Do the probe */ @@ -504,10 +504,10 @@ IoBuildAsynchronousFsdRequest(ULONG MajorFunction, Irp = NULL; } _SEH_END; - + if (!Irp) return NULL; - } + } else { /* Neither, use the buffer */ @@ -525,12 +525,12 @@ IoBuildAsynchronousFsdRequest(ULONG MajorFunction, StackPtr->Parameters.Write.ByteOffset = *StartingOffset; } } - + /* Set the Current Thread and IOSB */ if (!IoStatusBlock) KEBUGCHECK(0); /* Temporary to catch illegal ROS Drivers */ Irp->UserIosb = IoStatusBlock; Irp->Tail.Overlay.Thread = PsGetCurrentThread(); - + /* Set the Status Block after all is done */ return Irp; } @@ -716,7 +716,7 @@ IoBuildDeviceIoControlRequest (ULONG IoControlCode, Irp = NULL; } _SEH_END; - + if (!Irp) return NULL; } @@ -760,7 +760,7 @@ IoBuildDeviceIoControlRequest (ULONG IoControlCode, * RETURNS: The IRP allocated on success, or * NULL on failure */ -PIRP +PIRP STDCALL IoBuildSynchronousFsdRequest(ULONG MajorFunction, PDEVICE_OBJECT DeviceObject, @@ -771,12 +771,12 @@ IoBuildSynchronousFsdRequest(ULONG MajorFunction, PIO_STATUS_BLOCK IoStatusBlock) { PIRP Irp; - + DPRINT("IoBuildSynchronousFsdRequest(MajorFunction %x, DeviceObject %x, " "Buffer %x, Length %x, StartingOffset %x, Event %x, " "IoStatusBlock %x\n",MajorFunction,DeviceObject,Buffer,Length, StartingOffset,Event,IoStatusBlock); - + /* Do the big work to set up the IRP */ Irp = IoBuildAsynchronousFsdRequest(MajorFunction, DeviceObject, @@ -784,7 +784,7 @@ IoBuildSynchronousFsdRequest(ULONG MajorFunction, Length, StartingOffset, IoStatusBlock ); - + /* Set the Event which makes it Syncronous */ Irp->UserEvent = Event; @@ -796,26 +796,26 @@ IoBuildSynchronousFsdRequest(ULONG MajorFunction, /* * @implemented */ -BOOLEAN -STDCALL +BOOLEAN +STDCALL IoCancelIrp(PIRP Irp) { KIRQL oldlvl; PDRIVER_CANCEL CancelRoutine; - + DPRINT("IoCancelIrp(Irp %x)\n",Irp); - + IoAcquireCancelSpinLock(&oldlvl); - + Irp->Cancel = TRUE; - + CancelRoutine = IoSetCancelRoutine(Irp, NULL); if (CancelRoutine == NULL) { IoReleaseCancelSpinLock(oldlvl); return(FALSE); } - + Irp->CancelIrql = oldlvl; CancelRoutine(IoGetCurrentIrpStackLocation(Irp)->DeviceObject, Irp); return(TRUE); @@ -830,7 +830,7 @@ IoCancelIrp(PIRP Irp) * Thread to cancel requests for. */ -VOID +VOID STDCALL IoCancelThreadIo(PETHREAD Thread) { @@ -877,7 +877,7 @@ IoCancelThreadIo(PETHREAD Thread) DPRINT1("Thread with dead IRPs!"); ASSERT(FALSE); } - + OldIrql = KfRaiseIrql(APC_LEVEL); } @@ -901,7 +901,7 @@ IoCallDriver (PDEVICE_OBJECT DeviceObject, PIRP Irp) /* * @implemented */ -VOID +VOID STDCALL IoCompleteRequest(PIRP Irp, CCHAR PriorityBoost) @@ -913,7 +913,7 @@ IoCompleteRequest(PIRP Irp, /* * @implemented */ -VOID +VOID STDCALL IoEnqueueIrp(IN PIRP Irp) { @@ -925,7 +925,7 @@ IoEnqueueIrp(IN PIRP Irp) * * FUNCTION: Sends an IRP to the next lower driver */ -NTSTATUS +NTSTATUS FASTCALL IofCallDriver(PDEVICE_OBJECT DeviceObject, PIRP Irp) @@ -938,10 +938,10 @@ IofCallDriver(PDEVICE_OBJECT DeviceObject, /* Get the Driver Object */ DriverObject = DeviceObject->DriverObject; - + /* Set the Stack Location */ IoSetNextIrpStackLocation(Irp); - + /* Get the current one */ Param = IoGetCurrentIrpStackLocation(Irp); @@ -949,7 +949,7 @@ IofCallDriver(PDEVICE_OBJECT DeviceObject, /* Get the Device Object */ Param->DeviceObject = DeviceObject; - + /* Call it */ return DriverObject->MajorFunction[Param->MajorFunction](DeviceObject, Irp); } @@ -967,7 +967,7 @@ IofCallDriver(PDEVICE_OBJECT DeviceObject, * PriorityBoost = Increment by which to boost the priority of the * thread making the request */ -VOID +VOID FASTCALL IofCompleteRequest(PIRP Irp, CCHAR PriorityBoost) @@ -985,17 +985,17 @@ IofCompleteRequest(PIRP Irp, ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL); ASSERT(!Irp->CancelRoutine); ASSERT(Irp->IoStatus.Status != STATUS_PENDING); - + /* Get the Current Stack */ StackPtr = IoGetCurrentIrpStackLocation(Irp); IoSkipCurrentIrpStackLocation(Irp); - + /* Loop the Stacks and complete the IRPs */ for (;Irp->CurrentLocation <= (Irp->StackCount + 1); StackPtr++) { /* Set Pending Returned */ Irp->PendingReturned = StackPtr->Control & SL_PENDING_RETURNED; - + /* * Completion routines expect the current irp stack location to be the same as when * IoSetCompletionRoutine was called to set them. A side effect is that completion @@ -1014,9 +1014,9 @@ IofCompleteRequest(PIRP Irp, } /* Check if there is a Completion Routine to Call */ - if ((NT_SUCCESS(Irp->IoStatus.Status) && + if ((NT_SUCCESS(Irp->IoStatus.Status) && (StackPtr->Control & SL_INVOKE_ON_SUCCESS)) || - (!NT_SUCCESS(Irp->IoStatus.Status) && + (!NT_SUCCESS(Irp->IoStatus.Status) && (StackPtr->Control & SL_INVOKE_ON_ERROR)) || (Irp->Cancel && (StackPtr->Control & SL_INVOKE_ON_CANCEL))) { @@ -1035,10 +1035,10 @@ IofCompleteRequest(PIRP Irp, if (IoGetCurrentIrpStackLocation(Irp)->Control & SL_PENDING_RETURNED) { Irp->PendingReturned = TRUE; - } + } } } - + /* Move to next stack */ IoSkipCurrentIrpStackLocation(Irp); } @@ -1055,7 +1055,7 @@ IofCompleteRequest(PIRP Irp, /* Decrement and get the old count */ MasterIrpCount = InterlockedDecrement(&MasterIrp->AssociatedIrp.IrpCount); - + /* Free MDLs and IRP */ while ((Mdl = Irp->MdlAddress)) { @@ -1063,7 +1063,7 @@ IofCompleteRequest(PIRP Irp, IoFreeMdl(Mdl); } IoFreeIrp(Irp); - + /* Complete the Master IRP */ if (!MasterIrpCount) IofCompleteRequest(MasterIrp, IO_NO_INCREMENT); return; @@ -1083,14 +1083,14 @@ IofCompleteRequest(PIRP Irp, DPRINT("Handling Sync Paging or Close I/O\n"); *Irp->UserIosb = Irp->IoStatus; KeSetEvent(Irp->UserEvent, PriorityBoost, FALSE); - + /* Free the IRP for a Paging I/O Only, Close is handled by us */ if (Irp->Flags & IRP_SYNCHRONOUS_PAGING_IO) { DPRINT("Handling Sync Paging I/O\n"); IoFreeIrp(Irp); } - } + } else { DPRINT1("BUG BUG, YOU SHOULDNT BE HERE\n"); @@ -1121,7 +1121,7 @@ IofCompleteRequest(PIRP Irp, DPRINT("Unlocking MDL: %x\n", Mdl); MmUnlockPages(Mdl); Mdl = Mdl->Next; - } + } /* Check if we should exit because of a Deferred I/O (page 168) */ if (Irp->Flags & IRP_DEFER_IO_COMPLETION && !Irp->PendingReturned) @@ -1129,7 +1129,7 @@ IofCompleteRequest(PIRP Irp, DPRINT("Quick return\n"); return; } - + /* Now queue the special APC */ if (!Irp->Cancel) { @@ -1173,7 +1173,7 @@ IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject, * ARGUMENTS: * Irp = Irp to free */ -VOID +VOID STDCALL IoFreeIrp(PIRP Irp) { @@ -1209,14 +1209,14 @@ IoGetRequestorSessionId(IN PIRP Irp, OUT PULONG pSessionId) { *pSessionId = IoGetRequestorProcess(Irp)->Session; - + return STATUS_SUCCESS; } /* * @implemented */ -PIRP +PIRP STDCALL IoGetTopLevelIrp(VOID) { @@ -1232,7 +1232,7 @@ IoGetTopLevelIrp(VOID) * PacketSize = Size in bytes of the IRP * StackSize = Number of stack locations in the IRP */ -VOID +VOID STDCALL IoInitializeIrp(PIRP Irp, USHORT PacketSize, @@ -1241,10 +1241,10 @@ IoInitializeIrp(PIRP Irp, ASSERT(Irp != NULL); DPRINT("IoInitializeIrp(StackSize %x, Irp %x)\n",StackSize, Irp); - + /* Clear it */ RtlZeroMemory(Irp, PacketSize); - + /* Set the Header and other data */ Irp->Type = IO_TYPE_IRP; Irp->Size = PacketSize; @@ -1252,11 +1252,11 @@ IoInitializeIrp(PIRP Irp, Irp->CurrentLocation = StackSize + 1; Irp->ApcEnvironment = KeGetCurrentThread()->ApcStateIndex; Irp->Tail.Overlay.CurrentStackLocation = (PIO_STACK_LOCATION)(Irp + 1) + StackSize; - + /* Initialize the Thread List */ InitializeListHead(&Irp->ThreadListEntry); - - DPRINT("Irp->Tail.Overlay.CurrentStackLocation %x\n", Irp->Tail.Overlay.CurrentStackLocation); + + DPRINT("Irp->Tail.Overlay.CurrentStackLocation %x\n", Irp->Tail.Overlay.CurrentStackLocation); } /* @@ -1275,14 +1275,14 @@ IoInitializeIrp(PIRP Irp, * * @implemented */ -BOOLEAN +BOOLEAN STDCALL IoIsOperationSynchronous(IN PIRP Irp) { /* Check the flags */ if ((Irp->Flags & IRP_SYNCHRONOUS_PAGING_IO) || - (Irp->Flags & IRP_SYNCHRONOUS_API) || - (IoGetCurrentIrpStackLocation(Irp)->FileObject->Flags & + (Irp->Flags & IRP_SYNCHRONOUS_API) || + (IoGetCurrentIrpStackLocation(Irp)->FileObject->Flags & FO_SYNCHRONOUS_IO)) { /* Synch API or Paging I/O is OK, as is Sync File I/O */ @@ -1316,7 +1316,7 @@ IoIsValidNameGraftingBuffer(IN PIRP Irp, * NOTE: The caller is responsible for incrementing * Irp->AssociatedIrp.IrpCount. */ -PIRP +PIRP STDCALL IoMakeAssociatedIrp(PIRP Irp, CCHAR StackSize) @@ -1335,15 +1335,15 @@ IoMakeAssociatedIrp(PIRP Irp, /* Associate them */ AssocIrp->AssociatedIrp.MasterIrp = Irp; - + return AssocIrp; } /* * @implemented */ -NTSTATUS -STDCALL +NTSTATUS +STDCALL IoPageRead(PFILE_OBJECT FileObject, PMDL Mdl, PLARGE_INTEGER Offset, @@ -1353,19 +1353,19 @@ IoPageRead(PFILE_OBJECT FileObject, PIRP Irp; PIO_STACK_LOCATION StackPtr; PDEVICE_OBJECT DeviceObject; - + DPRINT("IoPageRead(FileObject %x, Mdl %x)\n", FileObject, Mdl); - + /* Get the Device Object */ DeviceObject = IoGetRelatedDeviceObject(FileObject); - + /* Allocate IRP */ Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE); - + /* Get the Stack */ StackPtr = IoGetNextIrpStackLocation(Irp); - + /* Create the IRP Settings */ Irp->MdlAddress = Mdl; Irp->UserBuffer = MmGetMdlVirtualAddress(Mdl); @@ -1375,13 +1375,13 @@ IoPageRead(PFILE_OBJECT FileObject, Irp->Flags = IRP_PAGING_IO | IRP_NOCACHE | IRP_SYNCHRONOUS_PAGING_IO | IRP_INPUT_OPERATION; Irp->Tail.Overlay.OriginalFileObject = FileObject; Irp->Tail.Overlay.Thread = PsGetCurrentThread(); - + /* Set the Stack Settings */ StackPtr->Parameters.Read.Length = MmGetMdlByteCount(Mdl); StackPtr->Parameters.Read.ByteOffset = *Offset; StackPtr->MajorFunction = IRP_MJ_READ; StackPtr->FileObject = FileObject; - + /* Call the Driver */ return IofCallDriver(DeviceObject, Irp); } @@ -1389,43 +1389,43 @@ IoPageRead(PFILE_OBJECT FileObject, /* * @implemented */ -VOID +VOID STDCALL IoQueueThreadIrp(IN PIRP Irp) { KIRQL OldIrql; - + /* Raise to APC */ OldIrql = KfRaiseIrql(APC_LEVEL); - + /* * Synchronous irp's are queued to requestor thread. If they are not * completed when the thread exits, they are canceled (cleaned up). * - Gunnar */ InsertTailList(&Irp->Tail.Overlay.Thread->IrpList, &Irp->ThreadListEntry); - + /* Lower back */ KfLowerIrql(OldIrql); } /* * @implemented - * Reference: Chris Cant's "Writing WDM Device Drivers" + * Reference: Chris Cant's "Writing WDM Device Drivers" */ -VOID +VOID STDCALL IoReuseIrp(IN OUT PIRP Irp, IN NTSTATUS Status) { UCHAR AllocationFlags; - + /* Get the old flags */ AllocationFlags = Irp->AllocationFlags; - + /* Reinitialize the IRP */ IoInitializeIrp(Irp, Irp->Size, Irp->StackCount); - + /* Duplicate the data */ Irp->IoStatus.Status = Status; Irp->AllocationFlags = AllocationFlags; @@ -1444,8 +1444,8 @@ IoSetTopLevelIrp(IN PIRP Irp) /* * @implemented */ -NTSTATUS -STDCALL +NTSTATUS +STDCALL IoSynchronousPageWrite(PFILE_OBJECT FileObject, PMDL Mdl, PLARGE_INTEGER Offset, @@ -1455,19 +1455,19 @@ IoSynchronousPageWrite(PFILE_OBJECT FileObject, PIRP Irp; PIO_STACK_LOCATION StackPtr; PDEVICE_OBJECT DeviceObject; - + DPRINT("IoSynchronousPageWrite(FileObject %x, Mdl %x)\n", FileObject, Mdl); - + /* Get the Device Object */ DeviceObject = IoGetRelatedDeviceObject(FileObject); - + /* Allocate IRP */ Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE); - + /* Get the Stack */ StackPtr = IoGetNextIrpStackLocation(Irp); - + /* Create the IRP Settings */ Irp->MdlAddress = Mdl; Irp->UserBuffer = MmGetMdlVirtualAddress(Mdl); @@ -1477,13 +1477,13 @@ IoSynchronousPageWrite(PFILE_OBJECT FileObject, Irp->Flags = IRP_PAGING_IO | IRP_NOCACHE | IRP_SYNCHRONOUS_PAGING_IO; Irp->Tail.Overlay.OriginalFileObject = FileObject; Irp->Tail.Overlay.Thread = PsGetCurrentThread(); - + /* Set the Stack Settings */ StackPtr->Parameters.Write.Length = MmGetMdlByteCount(Mdl); StackPtr->Parameters.Write.ByteOffset = *Offset; StackPtr->MajorFunction = IRP_MJ_WRITE; StackPtr->FileObject = FileObject; - + /* Call the Driver */ return IofCallDriver(DeviceObject, Irp); } diff --git a/reactos/ntoskrnl/io/irq.c b/reactos/ntoskrnl/io/irq.c index 6b0cd50524a..ecb75fc040c 100644 --- a/reactos/ntoskrnl/io/irq.c +++ b/reactos/ntoskrnl/io/irq.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/irq.c * PURPOSE: IRQ handling - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -38,7 +38,7 @@ IoConnectInterrupt(PKINTERRUPT* InterruptObject, /* * FUNCTION: Registers a driver's isr to be called when its device interrupts * ARGUMENTS: - * InterruptObject (OUT) = Points to the interrupt object created on + * InterruptObject (OUT) = Points to the interrupt object created on * return * ServiceRoutine = Routine to be called when the device interrupts * ServiceContext = Parameter to be passed to ServiceRoutine @@ -46,7 +46,7 @@ IoConnectInterrupt(PKINTERRUPT* InterruptObject, * access between the isr and other driver routines. This is * required if the isr handles more than one vector or the * driver has more than one isr - * Vector = Interrupt vector to allocate + * Vector = Interrupt vector to allocate * (returned from HalGetInterruptVector) * Irql = DIRQL returned from HalGetInterruptVector * SynchronizeIrql = DIRQL at which the isr will execute. This must @@ -65,18 +65,18 @@ IoConnectInterrupt(PKINTERRUPT* InterruptObject, { PKINTERRUPT Interrupt; ULONG i, count; - + ASSERT_IRQL(PASSIVE_LEVEL); - + DPRINT("IoConnectInterrupt(Vector %x)\n",Vector); - + ProcessorEnableMask &= ((1 << KeNumberProcessors) - 1); if (ProcessorEnableMask == 0) { return STATUS_INVALID_PARAMETER; } - + for (i = 0, count = 0; i < KeNumberProcessors; i++) { if (ProcessorEnableMask & (1 << i)) diff --git a/reactos/ntoskrnl/io/plugplay.c b/reactos/ntoskrnl/io/plugplay.c index 4160efd6d2a..2f09eaca53e 100644 --- a/reactos/ntoskrnl/io/plugplay.c +++ b/reactos/ntoskrnl/io/plugplay.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/plugplay.c * PURPOSE: Plug-and-play interface routines - * + * * PROGRAMMERS: Eric Kohl */ diff --git a/reactos/ntoskrnl/io/pnpdma.c b/reactos/ntoskrnl/io/pnpdma.c index 60398aa1aa9..677bc337966 100644 --- a/reactos/ntoskrnl/io/pnpdma.c +++ b/reactos/ntoskrnl/io/pnpdma.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/pnpdma.c * PURPOSE: PnP manager DMA routines - * + * * PROGRAMMERS: Filip Navara (xnavara@volny.cz) */ @@ -223,9 +223,9 @@ IoGetDmaAdapter( PDMA_ADAPTER Result = NULL; PDMA_ADAPTER_INTERNAL ResultInternal = NULL; PADAPTER_OBJECT HalAdapter; - + DPRINT("IoGetDmaAdapter called\n"); - + /* * Try to create DMA adapter through bus driver */ @@ -233,11 +233,11 @@ IoGetDmaAdapter( { if (DeviceDescription->InterfaceType == 0x0F /*PNPBus*/ || DeviceDescription->InterfaceType == 0xFFFFFFFF) - { + { RtlCopyMemory(&PrivateDeviceDescription, DeviceDescription, sizeof(DEVICE_DESCRIPTION)); Status = IoGetDeviceProperty(PhysicalDeviceObject, - DevicePropertyLegacyBusType, sizeof(INTERFACE_TYPE), + DevicePropertyLegacyBusType, sizeof(INTERFACE_TYPE), &PrivateDeviceDescription.InterfaceType, &ResultLength); if (!NT_SUCCESS(Status)) { @@ -249,7 +249,7 @@ IoGetDmaAdapter( Stack.Parameters.QueryInterface.Size = sizeof(BUS_INTERFACE_STANDARD); Stack.Parameters.QueryInterface.Version = 1; Stack.Parameters.QueryInterface.Interface = (PINTERFACE)&BusInterface; - Stack.Parameters.QueryInterface.InterfaceType = + Stack.Parameters.QueryInterface.InterfaceType = &GUID_BUS_INTERFACE_STANDARD; Status = IopInitiatePnpIrp(PhysicalDeviceObject, &IoStatusBlock, IRP_MN_QUERY_INTERFACE, &Stack); diff --git a/reactos/ntoskrnl/io/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr.c index e06433b36b9..5e024386605 100644 --- a/reactos/ntoskrnl/io/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/pnpmgr.c * PURPOSE: Initializes the PnP manager - * + * * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net) */ @@ -159,8 +159,8 @@ IoGetDeviceProperty( KeyNameBuffer = ExAllocatePool(PagedPool, (49 * sizeof(WCHAR)) + DeviceNode->InstancePath.Length); - - DPRINT("KeyNameBuffer: %x, value %S\n", + + DPRINT("KeyNameBuffer: %x, value %S\n", KeyNameBuffer, RegistryPropertyName); if (KeyNameBuffer == NULL) @@ -283,7 +283,7 @@ IoInvalidateDeviceState( * @param DeviceObject Device to get the registry key for. * @param DevInstKeyType Type of the key to return. * @param DesiredAccess Access mask (eg. KEY_READ | KEY_WRITE). - * @param DevInstRegKey Handle to the opened registry key on + * @param DevInstRegKey Handle to the opened registry key on * successful return. * * @return Status. @@ -362,7 +362,7 @@ IoOpenDeviceRegistryKey( if (DevInstKeyType & PLUGPLAY_REGKEY_CURRENT_HWPROFILE) RtlAppendUnicodeToString(&KeyName, ProfileKeyName); - + if (DevInstKeyType & PLUGPLAY_REGKEY_DRIVER) { RtlAppendUnicodeToString(&KeyName, ClassKeyName); @@ -1384,11 +1384,11 @@ IopActionConfigureChildServices( { WCHAR RegKeyBuffer[MAX_PATH]; UNICODE_STRING RegKey; - + RegKey.Length = 0; RegKey.MaximumLength = sizeof(RegKeyBuffer); RegKey.Buffer = RegKeyBuffer; - + /* * Retrieve configuration from Enum key */ diff --git a/reactos/ntoskrnl/io/pnpnotify.c b/reactos/ntoskrnl/io/pnpnotify.c index 216890f951e..d218e99265d 100644 --- a/reactos/ntoskrnl/io/pnpnotify.c +++ b/reactos/ntoskrnl/io/pnpnotify.c @@ -1,10 +1,10 @@ -/* $Id:$ +/* $Id$ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/pnpnotify.c * PURPOSE: Plug & Play notification functions - * + * * PROGRAMMERS: Filip Navara (xnavara@volny.cz) * Hervé Poussineau (hpoussin@reactos.com) */ @@ -67,16 +67,16 @@ IoRegisterPlugPlayNotification( PPNP_NOTIFY_ENTRY Entry; PWSTR SymbolicLinkList; NTSTATUS Status; - + PAGED_CODE(); - + DPRINT("IoRegisterPlugPlayNotification(EventCategory 0x%x, EventCategoryFlags 0x%lx, DriverObject %p) called.\n", EventCategory, EventCategoryFlags, DriverObject); - + ObReferenceObject(DriverObject); - + /* Try to allocate entry for notification before sending any notification */ Entry = ExAllocatePoolWithTag( NonPagedPool, @@ -88,7 +88,7 @@ IoRegisterPlugPlayNotification( ObDereferenceObject(DriverObject); return STATUS_INSUFFICIENT_RESOURCES; } - + if (EventCategory == EventCategoryTargetDeviceChange && EventCategoryFlags & PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES) { @@ -108,7 +108,7 @@ IoRegisterPlugPlayNotification( DPRINT1("IoRegisterPlugPlayNotification(): need to send notifications for existing interfaces!\n"); ExFreePool(SymbolicLinkList); } - + Entry->PnpNotificationProc = CallbackRoutine; Entry->EventCategory = EventCategory; Entry->Context = Context; @@ -141,12 +141,12 @@ IoRegisterPlugPlayNotification( break; } } - + KeAcquireGuardedMutex(&PnpNotifyListLock); InsertHeadList(&PnpNotifyListHead, &Entry->PnpNotifyList); KeReleaseGuardedMutex(&PnpNotifyListLock); - + DPRINT("IoRegisterPlugPlayNotification() returns NotificationEntry %p\n", Entry); *NotificationEntry = Entry; @@ -162,18 +162,18 @@ IoUnregisterPlugPlayNotification( IN PVOID NotificationEntry) { PPNP_NOTIFY_ENTRY Entry; - + PAGED_CODE(); - + Entry = (PPNP_NOTIFY_ENTRY)NotificationEntry; DPRINT("IoUnregisterPlugPlayNotification(NotificationEntry %p) called\n", Entry); - + KeAcquireGuardedMutex(&PnpNotifyListLock); RtlFreeUnicodeString(&Entry->Guid); RemoveEntryList(&Entry->PnpNotifyList); KeReleaseGuardedMutex(&PnpNotifyListLock); - + return STATUS_SUCCESS; } @@ -189,16 +189,16 @@ IopNotifyPlugPlayNotification( PLIST_ENTRY Entry; PVOID NotificationStructure; BOOLEAN CallCurrentEntry; - + ASSERT(DeviceObject); - + KeAcquireGuardedMutex(&PnpNotifyListLock); if (IsListEmpty(&PnpNotifyListHead)) { KeReleaseGuardedMutex(&PnpNotifyListLock); return; } - + switch (EventCategory) { case EventCategoryDeviceInterfaceChange: @@ -246,17 +246,17 @@ IopNotifyPlugPlayNotification( return; } } - + /* Loop through procedures registred in PnpNotifyListHead * list to find those that meet some criteria. */ - + Entry = PnpNotifyListHead.Flink; while (Entry != &PnpNotifyListHead) { ChangeEntry = CONTAINING_RECORD(Entry, PNP_NOTIFY_ENTRY, PnpNotifyList); CallCurrentEntry = FALSE; - + switch (EventCategory) { case EventCategoryDeviceInterfaceChange: @@ -284,18 +284,18 @@ IopNotifyPlugPlayNotification( break; } } - + if (CallCurrentEntry) { /* Call entry into new allocated memory */ DPRINT("IopNotifyPlugPlayNotification(): found suitable callback %p\n", ChangeEntry); - + (ChangeEntry->PnpNotificationProc)( NotificationStructure, ChangeEntry->Context); } - + Entry = Entry->Flink; } KeReleaseGuardedMutex(&PnpNotifyListLock); diff --git a/reactos/ntoskrnl/io/pnpreport.c b/reactos/ntoskrnl/io/pnpreport.c index b3db2dc21ba..ea378a2b511 100644 --- a/reactos/ntoskrnl/io/pnpreport.c +++ b/reactos/ntoskrnl/io/pnpreport.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/pnpreport.c * PURPOSE: Device Changes Reporting functions - * + * * PROGRAMMERS: Filip Navara (xnavara@volny.cz) */ @@ -34,10 +34,10 @@ IoReportDetectedDevice( PDEVICE_NODE DeviceNode; PDEVICE_OBJECT Pdo; NTSTATUS Status = STATUS_SUCCESS; - + DPRINT("IoReportDetectedDevice (DeviceObject %p, *DeviceObject %p)\n", DeviceObject, DeviceObject ? *DeviceObject : NULL); - + /* if *DeviceObject is not NULL, we must use it as a PDO, * and don't create a new one. */ @@ -56,13 +56,13 @@ IoReportDetectedDevice( if (DeviceObject) *DeviceObject = Pdo; } - + /* we don't need to call AddDevice and send IRP_MN_START_DEVICE */ - + /* FIXME: save this device into the root-enumerated list, so this * device would be detected as a PnP device during next startups. */ - + return Status; } @@ -82,17 +82,17 @@ IoReportResourceForDetection( { *ConflictDetected = FALSE; DPRINT1("IoReportResourceForDetection partly implemented\n"); - + /* FIXME: Manually indicate conflicts with KD Ports */ if (DriverList) { if (KdpDetectConflicts(DriverList)) { *ConflictDetected = TRUE; - return STATUS_CONFLICTING_ADDRESSES; + return STATUS_CONFLICTING_ADDRESSES; } } - + if (PopSystemPowerDeviceNode != NULL && DriverListSize > 0) { /* We hope legacy devices will be enumerated by ACPI */ diff --git a/reactos/ntoskrnl/io/pnproot.c b/reactos/ntoskrnl/io/pnproot.c index 43b00655a05..6a0b74d1f54 100644 --- a/reactos/ntoskrnl/io/pnproot.c +++ b/reactos/ntoskrnl/io/pnproot.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/pnproot.c * PURPOSE: PnP manager root device - * + * * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net) */ @@ -304,7 +304,7 @@ PnpRootPdoPnpControl( NTSTATUS Status; DPRINT("Called\n"); - + Status = Irp->IoStatus.Status; IrpSp = IoGetCurrentIrpStackLocation(Irp); @@ -496,7 +496,7 @@ PnpRootFdoEnumerateDevices( } /* FIXME: Disabled due to still using the old method of auto loading drivers e.g. - there are more entries in the list than found in the registry as some + there are more entries in the list than found in the registry as some drivers are passed on the command line */ // DeviceExtension->DeviceListCount = 0; @@ -558,7 +558,7 @@ PnpRootFdoEnumerateDevices( if (!NT_SUCCESS(Status)) { DPRINT("PnpRootFdoReadDeviceInfo() failed with status %x\n", Status); - /* FIXME: */ + /* FIXME: */ } ExInterlockedInsertTailList( @@ -606,12 +606,12 @@ PnpRootQueryBusRelations( if (Irp->IoStatus.Information) { - /* FIXME: Another bus driver has already created a DEVICE_RELATIONS + /* FIXME: Another bus driver has already created a DEVICE_RELATIONS structure so we must merge this structure with our own */ } Size = sizeof(DEVICE_RELATIONS) + sizeof(Relations->Objects) * - (DeviceExtension->DeviceListCount - 1); + (DeviceExtension->DeviceListCount - 1); Relations = (PDEVICE_RELATIONS)ExAllocatePool(PagedPool, Size); if (!Relations) diff --git a/reactos/ntoskrnl/io/rawfs.c b/reactos/ntoskrnl/io/rawfs.c index c4198e48135..b19e58e428a 100755 --- a/reactos/ntoskrnl/io/rawfs.c +++ b/reactos/ntoskrnl/io/rawfs.c @@ -192,8 +192,8 @@ RawFsWriteDisk(IN PDEVICE_OBJECT pDeviceObject, pDeviceObject, Buffer, WriteLength, - WriteOffset, - &Event, + WriteOffset, + &Event, &IoStatus); if (!Irp) { @@ -227,7 +227,7 @@ RawFsBlockDeviceIoControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG CtlCode, IN PVOID InputBuffer, IN ULONG InputBufferSize, - IN OUT PVOID OutputBuffer, + IN OUT PVOID OutputBuffer, IN OUT PULONG pOutputBufferSize) { ULONG OutputBufferSize = 0; @@ -237,9 +237,9 @@ RawFsBlockDeviceIoControl(IN PDEVICE_OBJECT DeviceObject, NTSTATUS Status; DPRINT("RawFsBlockDeviceIoControl(DeviceObject %x, CtlCode %x, " - "InputBuffer %x, InputBufferSize %x, OutputBuffer %x, " - "POutputBufferSize %x (%x)\n", DeviceObject, CtlCode, - InputBuffer, InputBufferSize, OutputBuffer, pOutputBufferSize, + "InputBuffer %x, InputBufferSize %x, OutputBuffer %x, " + "POutputBufferSize %x (%x)\n", DeviceObject, CtlCode, + InputBuffer, InputBufferSize, OutputBuffer, pOutputBufferSize, pOutputBufferSize ? *pOutputBufferSize : 0); if (pOutputBufferSize) @@ -250,14 +250,14 @@ RawFsBlockDeviceIoControl(IN PDEVICE_OBJECT DeviceObject, KeInitializeEvent(&Event, NotificationEvent, FALSE); DPRINT("Building device I/O control request ...\n"); - Irp = IoBuildDeviceIoControlRequest(CtlCode, - DeviceObject, - InputBuffer, - InputBufferSize, + Irp = IoBuildDeviceIoControlRequest(CtlCode, + DeviceObject, + InputBuffer, + InputBufferSize, OutputBuffer, - OutputBufferSize, - FALSE, - &Event, + OutputBufferSize, + FALSE, + &Event, &IoStatus); if (Irp == NULL) { @@ -293,14 +293,14 @@ RawFsNewFCB(IN PRAWFS_GLOBAL_DATA pGlobalData) memset(Fcb, 0, sizeof(RAWFS_FCB)); ExInitializeResourceLite(&Fcb->PagingIoResource); ExInitializeResourceLite(&Fcb->MainResource); -// FsRtlInitializeFileLock(&Fcb->FileLock, NULL, NULL); +// FsRtlInitializeFileLock(&Fcb->FileLock, NULL, NULL); return Fcb; } static VOID RawFsDestroyFCB(IN PRAWFS_GLOBAL_DATA pGlobalData, IN PRAWFS_FCB pFcb) { - //FsRtlUninitializeFileLock(&pFcb->FileLock); + //FsRtlUninitializeFileLock(&pFcb->FileLock); ExDeleteResourceLite(&pFcb->PagingIoResource); ExDeleteResourceLite(&pFcb->MainResource); ExFreeToNPagedLookasideList(&pGlobalData->FcbLookasideList, pFcb); @@ -432,7 +432,7 @@ RawFsCreateFile(IN PRAWFS_IRP_CONTEXT IrpContext) FileObject = IoSp->FileObject; DeviceExt = IrpContext->DeviceObject->DeviceExtension; - if (FileObject->FileName.Length == 0 && + if (FileObject->FileName.Length == 0 && FileObject->RelatedFileObject == NULL) { /* This a open operation for the volume itself */ @@ -474,7 +474,7 @@ RawFsCreate(IN PRAWFS_IRP_CONTEXT IrpContext) DPRINT("RawFsCreate(IrpContext %x)\n", IrpContext); ASSERT(IrpContext); - + if (RawFsIsRawFileSystemDeviceObject(IrpContext->DeviceObject)) { /* DeviceObject represents FileSystem instead of logical volume */ @@ -496,7 +496,7 @@ RawFsCreate(IN PRAWFS_IRP_CONTEXT IrpContext) Status = RawFsCreateFile(IrpContext); IrpContext->Irp->IoStatus.Status = Status; - IoCompleteRequest(IrpContext->Irp, + IoCompleteRequest(IrpContext->Irp, (CCHAR)(NT_SUCCESS(Status) ? IO_DISK_INCREMENT : IO_NO_INCREMENT)); RawFsFreeIrpContext(IrpContext); @@ -561,7 +561,7 @@ RawFsMount(IN PRAWFS_IRP_CONTEXT IrpContext) DeviceObject->Flags |= DO_DIRECT_IO; DeviceExt = (PVOID) DeviceObject->DeviceExtension; RtlZeroMemory(DeviceExt, sizeof(RAWFS_DEVICE_EXTENSION)); - + /* Use same vpb as device disk */ DeviceObject->Vpb = IrpContext->Stack->Parameters.MountVolume.DeviceObject->Vpb; DeviceExt->StorageDevice = IrpContext->Stack->Parameters.MountVolume.DeviceObject; @@ -570,7 +570,7 @@ RawFsMount(IN PRAWFS_IRP_CONTEXT IrpContext) DeviceExt->StorageDevice->Vpb->Flags |= VPB_MOUNTED; DeviceObject->StackSize = DeviceExt->StorageDevice->StackSize + 1; DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; - + KeInitializeSpinLock(&DeviceExt->FcbListLock); InitializeListHead(&DeviceExt->FcbListHead); @@ -672,7 +672,7 @@ RawFsFileSystemControl(IN PRAWFS_IRP_CONTEXT IrpContext) NTSTATUS Status; DPRINT("RawFsFileSystemControl(IrpContext %x)\n", IrpContext); - + ASSERT(IrpContext); switch (IrpContext->MinorFunction) diff --git a/reactos/ntoskrnl/io/remlock.c b/reactos/ntoskrnl/io/remlock.c index eedb9e86bcc..ee81beaa76d 100644 --- a/reactos/ntoskrnl/io/remlock.c +++ b/reactos/ntoskrnl/io/remlock.c @@ -1,10 +1,10 @@ -/* $Id:$ - * +/* $Id$ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/remlock.c * PURPOSE: Remove Lock functions - * + * * PROGRAMMERS: Filip Navara (xnavara@volny.cz) */ diff --git a/reactos/ntoskrnl/io/resource.c b/reactos/ntoskrnl/io/resource.c index f066e1f63bb..c171aa54c70 100644 --- a/reactos/ntoskrnl/io/resource.c +++ b/reactos/ntoskrnl/io/resource.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/resource.c * PURPOSE: Hardware resource managment - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) * Alex Ionescu (alex@relsoft.net) */ @@ -85,7 +85,7 @@ PWSTR ArcTypes[42] = { * * FUNCTION: * Reads and returns Hardware information from the appropriate hardware - * registry key. Helper sub of IopQueryBusDescription. + * registry key. Helper sub of IopQueryBusDescription. * * ARGUMENTS: * Query - What the parent function wants. @@ -104,7 +104,7 @@ IopQueryDeviceDescription( UNICODE_STRING RootKey, HANDLE RootKeyHandle, ULONG Bus, - PKEY_VALUE_FULL_INFORMATION *BusInformation) + PKEY_VALUE_FULL_INFORMATION *BusInformation) { NTSTATUS Status = STATUS_SUCCESS; @@ -185,7 +185,7 @@ IopQueryDeviceDescription( ExFreePool(ControllerFullInformation); return Status; } - + /* Find out Controller Numbers */ ControllerNumber = 0; MaximumControllerNumber = ControllerFullInformation->SubKeys; @@ -210,7 +210,7 @@ IopQueryDeviceDescription( /* Create String */ Status |= RtlAppendUnicodeToString(&ControllerRootRegName, L"\\"); Status |= RtlAppendUnicodeStringToString(&ControllerRootRegName, &TempString); - + /* Something messed up */ if (!NT_SUCCESS(Status)) break; @@ -277,7 +277,7 @@ IopQueryDeviceDescription( Status |= RtlAppendUnicodeToString(&ControllerRootRegName, ArcTypes[*Query->PeripheralType]); /* Something messed up */ - if (!NT_SUCCESS(Status)) goto EndLoop; + if (!NT_SUCCESS(Status)) goto EndLoop; /* Set the Peripheral Number if specified */ if (Query->PeripheralNumber && *Query->PeripheralNumber) @@ -340,7 +340,7 @@ IopQueryDeviceDescription( /* Create String */ Status |= RtlAppendUnicodeToString(&ControllerRootRegName, L"\\"); Status |= RtlAppendUnicodeStringToString(&ControllerRootRegName, &TempString); - + /* Something messed up */ if (!NT_SUCCESS(Status)) break; @@ -458,7 +458,7 @@ IopQueryBusDescription( UNICODE_STRING RootKey, HANDLE RootKeyHandle, PULONG Bus, - BOOLEAN KeyIsRoot) + BOOLEAN KeyIsRoot) { NTSTATUS Status; ULONG BusLoop; @@ -645,7 +645,7 @@ IopQueryBusDescription( ZwClose(SubRootKeyHandle); SubRootKeyHandle = NULL; } - + /* Free the last remaining Allocated Memory */ if (BasicInformation) ExFreePool(BasicInformation); @@ -678,13 +678,13 @@ IoReportResourceUsage(PUNICODE_STRING DriverClassName, BOOLEAN OverrideConflict, PBOOLEAN ConflictDetected) /* - * FUNCTION: Reports hardware resources in the + * FUNCTION: Reports hardware resources in the * \Registry\Machine\Hardware\ResourceMap tree, so that a subsequently * loaded driver cannot attempt to use the same resources. * ARGUMENTS: * DriverClassName - The class of driver under which the resource * information should be stored. - * DriverObject - The driver object that was input to the + * DriverObject - The driver object that was input to the * DriverEntry. * DriverList - Resources that claimed for the driver rather than * per-device. @@ -762,7 +762,7 @@ IoQueryDeviceDescription(PINTERFACE_TYPE BusType, RootRegKey.MaximumLength = 2048; RootRegKey.Buffer = ExAllocatePoolWithTag(PagedPool, RootRegKey.MaximumLength, TAG_IO_RESOURCE); RtlAppendUnicodeToString(&RootRegKey, RootRegString); - + /* Open a handle to the Root Registry Key */ InitializeObjectAttributes( &ObjectAttributes, diff --git a/reactos/ntoskrnl/io/share.c b/reactos/ntoskrnl/io/share.c index 566561a067b..aee0141e46e 100644 --- a/reactos/ntoskrnl/io/share.c +++ b/reactos/ntoskrnl/io/share.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/share.c * PURPOSE: No purpose listed. - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -23,7 +23,7 @@ IoUpdateShareAccess(PFILE_OBJECT FileObject, PSHARE_ACCESS ShareAccess) { PAGED_CODE(); - + if (FileObject->ReadAccess || FileObject->WriteAccess || FileObject->DeleteAccess) @@ -56,7 +56,7 @@ IoCheckShareAccess(IN ACCESS_MASK DesiredAccess, BOOLEAN SharedRead; BOOLEAN SharedWrite; BOOLEAN SharedDelete; - + PAGED_CODE(); ReadAccess = (DesiredAccess & (FILE_READ_DATA | FILE_EXECUTE)) != 0; @@ -144,7 +144,7 @@ IoSetShareAccess(IN ACCESS_MASK DesiredAccess, BOOLEAN SharedRead; BOOLEAN SharedWrite; BOOLEAN SharedDelete; - + PAGED_CODE(); ReadAccess = (DesiredAccess & (FILE_READ_DATA | FILE_EXECUTE)) != 0; @@ -196,7 +196,7 @@ IoCheckDesiredAccess(IN OUT PACCESS_MASK DesiredAccess, IN ACCESS_MASK GrantedAccess) { PAGED_CODE(); - + RtlMapGenericMask(DesiredAccess, IoFileObjectType->Mapping); @@ -270,7 +270,7 @@ IoSetInformation(IN PFILE_OBJECT FileObject, } DPRINT("FileObject %x\n", FileObject); - + DeviceObject = FileObject->DeviceObject; Irp = IoAllocateIrp(DeviceObject->StackSize, @@ -310,7 +310,7 @@ IoSetInformation(IN PFILE_OBJECT FileObject, NULL); Status = IoStatusBlock.Status; } - + return Status; } diff --git a/reactos/ntoskrnl/io/timer.c b/reactos/ntoskrnl/io/timer.c index 3045b9275e8..090daa1a671 100644 --- a/reactos/ntoskrnl/io/timer.c +++ b/reactos/ntoskrnl/io/timer.c @@ -1,10 +1,10 @@ -/* $Id:$ - * +/* $Id$ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/timer.c * PURPOSE: IO timers - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) * Alex Ionescu (alex@relsoft.net) */ @@ -42,15 +42,15 @@ IopTimerDispatch(IN PKDPC Dpc, PLIST_ENTRY TimerEntry; PIO_TIMER Timer; ULONG i; - + DPRINT("Dispatching IO Timers. There are: %x \n", IopTimerCount); - + /* Check if any Timers are actualyl enabled as of now */ if (IopTimerCount) { - + /* Lock the Timers */ - KeAcquireSpinLock(&IopTimerLock, &OldIrql); - + KeAcquireSpinLock(&IopTimerLock, &OldIrql); + /* Call the Timer Routine of each enabled Timer */ for(TimerEntry = IopTimerQueueHead.Flink, i = IopTimerCount; (TimerEntry != &IopTimerQueueHead) && i; @@ -58,14 +58,14 @@ IopTimerDispatch(IN PKDPC Dpc, Timer = CONTAINING_RECORD(TimerEntry, IO_TIMER, IoTimerList); if (Timer->TimerEnabled) { - DPRINT("Dispatching a Timer Routine: %x for Device Object: %x \n", + DPRINT("Dispatching a Timer Routine: %x for Device Object: %x \n", Timer->TimerRoutine, Timer->DeviceObject); Timer->TimerRoutine(Timer->DeviceObject, Timer->Context); i--; } } - + /* Unlock the Timers */ KeReleaseSpinLock(&IopTimerLock, OldIrql); } @@ -81,11 +81,11 @@ IopRemoveTimerFromTimerList( /* Lock Timers */ KeAcquireSpinLock(&IopTimerLock, &OldIrql); - + /* Remove Timer from the List and Drop the Timer Count if Enabled */ RemoveEntryList(&Timer->IoTimerList); if (Timer->TimerEnabled) IopTimerCount--; - + /* Unlock the Timers */ KeReleaseSpinLock(&IopTimerLock, OldIrql); } @@ -98,13 +98,13 @@ IopInitTimerImplementation(VOID) */ { LARGE_INTEGER ExpireTime; - + /* Initialize Timer List Lock */ KeInitializeSpinLock(&IopTimerLock); - + /* Initialize Timer List */ InitializeListHead(&IopTimerQueueHead); - + /* Initialize the DPC/Timer which will call the other Timer Routines */ ExpireTime.QuadPart = -10000000; KeInitializeDpc(&IopTimerDpc, IopTimerDispatch, NULL); @@ -117,7 +117,7 @@ IopInitTimerImplementation(VOID) */ NTSTATUS STDCALL -IoInitializeTimer(PDEVICE_OBJECT DeviceObject, +IoInitializeTimer(PDEVICE_OBJECT DeviceObject, PIO_TIMER_ROUTINE TimerRoutine, PVOID Context) /* @@ -132,7 +132,7 @@ IoInitializeTimer(PDEVICE_OBJECT DeviceObject, */ { DPRINT("IoInitializeTimer() called for Device Object: %x with Routine: %x \n", DeviceObject, TimerRoutine); - + /* Allocate Timer */ if (!DeviceObject->Timer) { DeviceObject->Timer = ExAllocatePoolWithTag(NonPagedPool, @@ -144,7 +144,7 @@ IoInitializeTimer(PDEVICE_OBJECT DeviceObject, DeviceObject->Timer->Type = IO_TYPE_TIMER; DeviceObject->Timer->DeviceObject = DeviceObject; } - + DeviceObject->Timer->TimerRoutine = TimerRoutine; DeviceObject->Timer->Context = Context; DeviceObject->Timer->TimerEnabled = FALSE; @@ -153,8 +153,8 @@ IoInitializeTimer(PDEVICE_OBJECT DeviceObject, ExInterlockedInsertTailList(&IopTimerQueueHead, &DeviceObject->Timer->IoTimerList, &IopTimerLock); - - /* Return Success */ + + /* Return Success */ DPRINT("IoInitializeTimer() Completed\n"); return(STATUS_SUCCESS); } @@ -173,18 +173,18 @@ IoStartTimer(PDEVICE_OBJECT DeviceObject) */ { KIRQL OldIrql; - + DPRINT("IoStartTimer for Device Object: %x\n", DeviceObject); - + /* Lock Timers */ KeAcquireSpinLock(&IopTimerLock, &OldIrql); - + /* If the timer isn't already enabled, enable it and increase IO Timer Count*/ if (!DeviceObject->Timer->TimerEnabled) { DeviceObject->Timer->TimerEnabled = TRUE; IopTimerCount++; } - + /* Unlock Timers */ KeReleaseSpinLock(&IopTimerLock, OldIrql); DPRINT("IoStartTimer Completed for Device Object: %x New Count: %x \n", DeviceObject, IopTimerCount); @@ -204,18 +204,18 @@ IoStopTimer(PDEVICE_OBJECT DeviceObject) */ { KIRQL OldIrql; - + DPRINT("IoStopTimer for Device Object: %x\n", DeviceObject); - + /* Lock Timers */ KeAcquireSpinLock(&IopTimerLock, &OldIrql); - + /* If the timer is enabled, disable it and decrease IO Timer Count*/ if (DeviceObject->Timer->TimerEnabled) { DeviceObject->Timer->TimerEnabled = FALSE; IopTimerCount--; } - + /* Unlock Timers */ KeReleaseSpinLock(&IopTimerLock, OldIrql); DPRINT("IoStopTimer Completed for Device Object: %x New Count: %x \n", DeviceObject, IopTimerCount); diff --git a/reactos/ntoskrnl/io/vpb.c b/reactos/ntoskrnl/io/vpb.c index afe88324ec3..56f34acad90 100644 --- a/reactos/ntoskrnl/io/vpb.c +++ b/reactos/ntoskrnl/io/vpb.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/vpb.c * PURPOSE: Volume Parameter Block managment - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -34,16 +34,16 @@ STDCALL IopAttachVpb(PDEVICE_OBJECT DeviceObject) { PVPB Vpb; - + /* Allocate the Vpb */ Vpb = ExAllocatePoolWithTag(NonPagedPool, sizeof(VPB), TAG_VPB); if (Vpb == NULL) return(STATUS_UNSUCCESSFUL); - + /* Clear it so we don't waste time manually */ RtlZeroMemory(Vpb, sizeof(VPB)); - + /* Set the Header and Device Field */ Vpb->Type = IO_TYPE_VPB; Vpb->Size = sizeof(VPB); @@ -56,10 +56,10 @@ IopAttachVpb(PDEVICE_OBJECT DeviceObject) /* * FUNCTION: Queries the volume information - * ARGUMENTS: + * ARGUMENTS: * FileHandle = Handle to a file object on the target volume * ReturnLength = DataWritten - * FsInformation = Caller should supply storage for the information + * FsInformation = Caller should supply storage for the information * structure. * Length = Size of the information structure * FsInformationClass = Index to a information structure @@ -69,10 +69,10 @@ IopAttachVpb(PDEVICE_OBJECT DeviceObject) * FileFsSizeInformation FILE_FS_SIZE_INFORMATION * FileFsDeviceInformation FILE_FS_DEVICE_INFORMATION * FileFsAttributeInformation FILE_FS_ATTRIBUTE_INFORMATION - * FileFsControlInformation + * FileFsControlInformation * FileFsQuotaQueryInformation -- * FileFsQuotaSetInformation -- - * FileFsMaximumInformation + * FileFsMaximumInformation * * RETURNS: Status * @@ -93,10 +93,10 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle, PIO_STACK_LOCATION StackPtr; PVOID SystemBuffer; KPROCESSOR_MODE PreviousMode; - + ASSERT(IoStatusBlock != NULL); ASSERT(FsInformation != NULL); - + DPRINT("FsInformation %p\n", FsInformation); PreviousMode = ExGetPreviousMode(); @@ -111,9 +111,9 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle, { return(Status); } - + DeviceObject = FileObject->DeviceObject; - + Irp = IoAllocateIrp(DeviceObject->StackSize, TRUE); if (Irp == NULL) @@ -121,7 +121,7 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle, ObDereferenceObject(FileObject); return(STATUS_INSUFFICIENT_RESOURCES); } - + SystemBuffer = ExAllocatePoolWithTag(NonPagedPool, Length, TAG_SYSB); @@ -131,7 +131,7 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle, ObDereferenceObject(FileObject); return(STATUS_INSUFFICIENT_RESOURCES); } - + /* Trigger FileObject/Event dereferencing */ Irp->Tail.Overlay.OriginalFileObject = FileObject; @@ -141,7 +141,7 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle, Irp->UserEvent = &FileObject->Event; Irp->UserIosb = IoStatusBlock; Irp->Tail.Overlay.Thread = PsGetCurrentThread(); - + StackPtr = IoGetNextIrpStackLocation(Irp); StackPtr->MajorFunction = IRP_MJ_QUERY_VOLUME_INFORMATION; StackPtr->MinorFunction = 0; @@ -152,7 +152,7 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle, StackPtr->Parameters.QueryVolume.Length = Length; StackPtr->Parameters.QueryVolume.FsInformationClass = FsInformationClass; - + Status = IoCallDriver(DeviceObject, Irp); if (Status == STATUS_PENDING) @@ -165,7 +165,7 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle, Status = IoStatusBlock->Status; } DPRINT("Status %x\n", Status); - + if (NT_SUCCESS(Status)) { DPRINT("Information %lu\n", IoStatusBlock->Information); @@ -175,7 +175,7 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle, } ExFreePool(SystemBuffer); - + return(Status); } @@ -195,11 +195,11 @@ IoQueryVolumeInformation(IN PFILE_OBJECT FileObject, PDEVICE_OBJECT DeviceObject; PIRP Irp; NTSTATUS Status; - + ASSERT(FsInformation != NULL); - + DPRINT("FsInformation %p\n", FsInformation); - + Status = ObReferenceObjectByPointer(FileObject, FILE_READ_ATTRIBUTES, IoFileObjectType, @@ -208,9 +208,9 @@ IoQueryVolumeInformation(IN PFILE_OBJECT FileObject, { return(Status); } - + DeviceObject = FileObject->DeviceObject; - + Irp = IoAllocateIrp(DeviceObject->StackSize, TRUE); if (Irp == NULL) @@ -227,7 +227,7 @@ IoQueryVolumeInformation(IN PFILE_OBJECT FileObject, Irp->UserEvent = &FileObject->Event; Irp->UserIosb = &IoStatusBlock; Irp->Tail.Overlay.Thread = PsGetCurrentThread(); - + StackPtr = IoGetNextIrpStackLocation(Irp); StackPtr->MajorFunction = IRP_MJ_QUERY_VOLUME_INFORMATION; StackPtr->MinorFunction = 0; @@ -238,7 +238,7 @@ IoQueryVolumeInformation(IN PFILE_OBJECT FileObject, StackPtr->Parameters.QueryVolume.Length = Length; StackPtr->Parameters.QueryVolume.FsInformationClass = FsInformationClass; - + Status = IoCallDriver(DeviceObject, Irp); if (Status == STATUS_PENDING) @@ -251,12 +251,12 @@ IoQueryVolumeInformation(IN PFILE_OBJECT FileObject, Status = IoStatusBlock.Status; } DPRINT("Status %x\n", Status); - + if (ReturnedLength != NULL) { *ReturnedLength = IoStatusBlock.Information; } - + return(Status); } @@ -294,16 +294,16 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle, { return(Status); } - + DeviceObject = FileObject->DeviceObject; - + Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE); if (Irp == NULL) { ObDereferenceObject(FileObject); return(STATUS_INSUFFICIENT_RESOURCES); } - + SystemBuffer = ExAllocatePoolWithTag(NonPagedPool, Length, TAG_SYSB); @@ -313,11 +313,11 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle, ObDereferenceObject(FileObject); return(STATUS_INSUFFICIENT_RESOURCES); } - + MmSafeCopyFromUser(SystemBuffer, FsInformation, Length); - + /* Trigger FileObject/Event dereferencing */ Irp->Tail.Overlay.OriginalFileObject = FileObject; Irp->RequestorMode = PreviousMode; @@ -326,7 +326,7 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle, Irp->UserEvent = &FileObject->Event; Irp->UserIosb = IoStatusBlock; Irp->Tail.Overlay.Thread = PsGetCurrentThread(); - + StackPtr = IoGetNextIrpStackLocation(Irp); StackPtr->MajorFunction = IRP_MJ_SET_VOLUME_INFORMATION; StackPtr->MinorFunction = 0; @@ -337,7 +337,7 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle, StackPtr->Parameters.SetVolume.Length = Length; StackPtr->Parameters.SetVolume.FsInformationClass = FsInformationClass; - + Status = IoCallDriver(DeviceObject,Irp); if (Status == STATUS_PENDING) { @@ -350,7 +350,7 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle, } ExFreePool(SystemBuffer); - + return(Status); } diff --git a/reactos/ntoskrnl/io/wmi.c b/reactos/ntoskrnl/io/wmi.c index 9d01c6b1f55..61ff4b3c66c 100644 --- a/reactos/ntoskrnl/io/wmi.c +++ b/reactos/ntoskrnl/io/wmi.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/wmi.c * PURPOSE: Windows Management Instrumentation - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) */ diff --git a/reactos/ntoskrnl/kd/kdinit.c b/reactos/ntoskrnl/kd/kdinit.c index 7a1d1f5dd8b..97d0dbbdb96 100644 --- a/reactos/ntoskrnl/kd/kdinit.c +++ b/reactos/ntoskrnl/kd/kdinit.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS Kernel * FILE: ntoskrnl/kd/kdinit.c * PURPOSE: Kernel Debugger Initializtion - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) */ @@ -33,7 +33,7 @@ KdpGetWrapperDebugMode(PCHAR Currentp2, PLOADER_PARAMETER_BLOCK LoaderBlock) { PCHAR p2 = Currentp2; - + #ifdef DBG /* Check for BOCHS Debugging */ if (!_strnicmp(p2, "BOCHS", 5)) @@ -50,7 +50,7 @@ KdpGetWrapperDebugMode(PCHAR Currentp2, /* Enable it */ p2 += 3; KdpDebugMode.Gdb = TRUE; - + /* Enable Debugging */ KdDebuggerEnabled = TRUE; WrapperInitRoutine = KdpGdbStubInit; @@ -62,7 +62,7 @@ KdpGetWrapperDebugMode(PCHAR Currentp2, /* Enable it */ p2 += 4; KdpDebugMode.Pice = TRUE; - + /* Enable Debugging */ KdDebuggerEnabled = TRUE; } @@ -76,14 +76,14 @@ KdpGetWrapperDebugMode(PCHAR Currentp2, #endif return p2; } - + PCHAR STDCALL KdpGetDebugMode(PCHAR Currentp2) { PCHAR p2 = Currentp2; ULONG Value; - + /* Check for Screen Debugging */ if (!_strnicmp(p2, "SCREEN", 6)) { @@ -101,7 +101,7 @@ KdpGetDebugMode(PCHAR Currentp2) { /* Valid port found, enable Serial Debugging */ KdpDebugMode.Serial = TRUE; - + /* Set the port to use */ SerialPortInfo.ComPort = Value; KdpPort = Value; @@ -124,23 +124,23 @@ KdpCallInitRoutine(ULONG BootPhase) { PLIST_ENTRY CurrentEntry; PKD_DISPATCH_TABLE CurrentTable; - + /* Call the registered handlers */ CurrentEntry = KdProviders.Flink; while (CurrentEntry != &KdProviders) { /* Get the current table */ - CurrentTable = CONTAINING_RECORD(CurrentEntry, - KD_DISPATCH_TABLE, + CurrentTable = CONTAINING_RECORD(CurrentEntry, + KD_DISPATCH_TABLE, KdProvidersList); - + /* Call it */ CurrentTable->KdpInitRoutine(CurrentTable, BootPhase); - + /* Next Table */ CurrentEntry = CurrentEntry->Flink; } - + /* Call the Wrapper Init Routine */ if (WrapperInitRoutine) WrapperTable.KdpInitRoutine(&WrapperTable, BootPhase); @@ -160,14 +160,14 @@ KdInitSystem(ULONG BootPhase, { /* Initialize the Provider List */ InitializeListHead(&KdProviders); - + /* Parse the Command Line */ p1 = (PCHAR)LoaderBlock->CommandLine; while (p1 && (p2 = strchr(p1, '/'))) { /* Move past the slash */ p2++; - + /* Identify the Debug Type being Used */ if (!_strnicmp(p2, "DEBUGPORT=", 10)) { @@ -190,7 +190,7 @@ KdInitSystem(ULONG BootPhase, p2 += 7; KdDebuggerEnabled = FALSE; } - /* Check for Kernel Debugging Bypass unless STOP Error */ + /* Check for Kernel Debugging Bypass unless STOP Error */ else if (!_strnicmp(p2, "CRASHDEBUG", 10)) { /* Disable Debugging */ @@ -203,7 +203,7 @@ KdInitSystem(ULONG BootPhase, /* Get the Baud Rate */ p2 += 9; Value = (ULONG)atol(p2); - + /* Check if it's valid and Set it */ if (0 < Value) PortInfo.BaudRate = SerialPortInfo.BaudRate = Value; } @@ -213,21 +213,21 @@ KdInitSystem(ULONG BootPhase, /* Get the IRQ */ p2 += 3; Value = (ULONG)atol(p2); - + /* Check if it's valid and set it */ if (0 < Value) KdpPortIrq = Value; } - + /* Move to next */ p1 = p2; - } - + } + /* Call Providers at Phase 0 */ for (i = 0; i < KdMax; i++) { InitRoutines[i](&DispatchTable[i], 0); } - + /* Call Wrapper at Phase 0 */ if (WrapperInitRoutine) WrapperInitRoutine(&WrapperTable, 0); diff --git a/reactos/ntoskrnl/kd/kdio.c b/reactos/ntoskrnl/kd/kdio.c index d53473bfd07..e463282ce51 100644 --- a/reactos/ntoskrnl/kd/kdio.c +++ b/reactos/ntoskrnl/kd/kdio.c @@ -14,7 +14,7 @@ /* GLOBALS *******************************************************************/ -#define BufferSize 32*1024 +#define BufferSize 32*1024 HANDLE KdbLogFileHandle; BOOLEAN KdpLogInitialized; @@ -45,10 +45,10 @@ KdpPrintToLogInternal(PVOID Context) CurrentPosition, NULL, NULL); - + /* Clear the Current Position */ CurrentPosition = 0; - + /* A new item can be queued now */ ItemQueued = FALSE; } @@ -58,19 +58,19 @@ STDCALL KdpPrintToLog(PCH String) { ULONG StringLength = strlen(String); - + /* Don't overflow */ if ((CurrentPosition + StringLength) > BufferSize) return; - + /* Add the string to the buffer */ RtlMoveMemory(&DebugBuffer[CurrentPosition], String, StringLength); - + /* Update the Current Position */ CurrentPosition += StringLength; - + /* Make sure we are initialized and can queue */ if (!KdpLogInitialized || (ItemQueued)) return; - + /* Queue the work item */ ExQueueWorkItem(&KdpDebugLogQueue, HyperCriticalWorkQueue); ItemQueued = TRUE; @@ -85,14 +85,14 @@ KdpInitDebugLog(PKD_DISPATCH_TABLE DispatchTable, NTSTATUS Status; OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING FileName; - IO_STATUS_BLOCK Iosb; - + IO_STATUS_BLOCK Iosb; + if (BootPhase == 0) { /* Write out the functions that we support for now */ DispatchTable->KdpInitRoutine = KdpInitDebugLog; DispatchTable->KdpPrintRoutine = KdpPrintToLog; - + /* Register as a Provider */ InsertTailList(&KdProviders, &DispatchTable->KdProvidersList); } @@ -109,7 +109,7 @@ KdpInitDebugLog(PKD_DISPATCH_TABLE DispatchTable, 0, NULL, NULL); - + /* Create the Log File */ Status = NtCreateFile(&KdbLogFileHandle, FILE_ALL_ACCESS, @@ -122,7 +122,7 @@ KdpInitDebugLog(PKD_DISPATCH_TABLE DispatchTable, FILE_WRITE_THROUGH | FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0); - + /* Allow it to be used */ ExInitializeWorkItem(&KdpDebugLogQueue, &KdpPrintToLogInternal, NULL); KdpLogInitialized = TRUE; @@ -160,17 +160,17 @@ KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable, /* Write out the functions that we support for now */ DispatchTable->KdpInitRoutine = KdpSerialInit; DispatchTable->KdpPrintRoutine = KdpSerialDebugPrint; - + /* Initialize the Port */ KdPortInitializeEx(&SerialPortInfo, 0, 0); - + /* Register as a Provider */ InsertTailList(&KdProviders, &DispatchTable->KdProvidersList); } else if (BootPhase == 2) { HalDisplayString("\n Serial debugging enabled\n\n"); - } + } } /* SCREEN FUNCTIONS **********************************************************/ @@ -187,14 +187,14 @@ KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable, /* Write out the functions that we support for now */ DispatchTable->KdpInitRoutine = KdpScreenInit; DispatchTable->KdpPrintRoutine = HalDisplayString; - + /* Register as a Provider */ InsertTailList(&KdProviders, &DispatchTable->KdProvidersList); } else if (BootPhase == 2) { HalDisplayString("\n Screen debugging enabled\n\n"); - } + } } /* GENERAL FUNCTIONS *********************************************************/ @@ -215,15 +215,15 @@ KdpDetectConflicts(PCM_RESOURCE_LIST DriverList) case 3: ComPortBase = 0x3e8; break; case 4: ComPortBase = 0x2e8; break; } - + /* search for this port address in DriverList */ for (i = 0; i < DriverList->List[0].PartialResourceList.Count; i++) { ResourceDescriptor = &DriverList->List[0].PartialResourceList.PartialDescriptors[i]; if (ResourceDescriptor->Type == CmResourceTypePort) { - if ((ResourceDescriptor->u.Port.Start.u.LowPart <= ComPortBase) && - (ResourceDescriptor->u.Port.Start.u.LowPart + + if ((ResourceDescriptor->u.Port.Start.u.LowPart <= ComPortBase) && + (ResourceDescriptor->u.Port.Start.u.LowPart + ResourceDescriptor->u.Port.Length > ComPortBase)) { /* Conflict found */ @@ -231,7 +231,7 @@ KdpDetectConflicts(PCM_RESOURCE_LIST DriverList) } } } - + /* No Conflicts */ return FALSE; } @@ -244,23 +244,23 @@ KdpPrintString(PANSI_STRING String) PCH pch = String->Buffer; PLIST_ENTRY CurrentEntry; PKD_DISPATCH_TABLE CurrentTable; - + /* Call the registered handlers */ CurrentEntry = KdProviders.Flink; while (CurrentEntry != &KdProviders) { /* Get the current table */ - CurrentTable = CONTAINING_RECORD(CurrentEntry, + CurrentTable = CONTAINING_RECORD(CurrentEntry, KD_DISPATCH_TABLE, KdProvidersList); - + /* Call it */ CurrentTable->KdpPrintRoutine(pch); - + /* Next Table */ CurrentEntry = CurrentEntry->Flink; } - + /* Call the Wrapper Routine */ if (WrapperInitRoutine) WrapperTable.KdpPrintRoutine(pch); diff --git a/reactos/ntoskrnl/kd/kdmain.c b/reactos/ntoskrnl/kd/kdmain.c index b8135000154..3569c06690e 100644 --- a/reactos/ntoskrnl/kd/kdmain.c +++ b/reactos/ntoskrnl/kd/kdmain.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS Kernel * FILE: ntoskrnl/kd/kdinit.c * PURPOSE: Kernel Debugger Initializtion - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) */ @@ -36,27 +36,27 @@ KdpServiceDispatcher(ULONG Service, case 1: /* DbgPrint */ Result = KdpPrintString ((PANSI_STRING)Context1); break; - + case TAG('R', 'o', 's', ' '): /* ROS-INTERNAL */ { switch ((ULONG)Context1) { - case DumpNonPagedPool: + case DumpNonPagedPool: MiDebugDumpNonPagedPool(FALSE); break; - + case ManualBugCheck: KEBUGCHECK(MANUALLY_INITIATED_CRASH); break; - + case DumpNonPagedPoolStats: MiDebugDumpNonPagedPoolStats(FALSE); break; - + case DumpNewNonPagedPool: MiDebugDumpNonPagedPool(TRUE); break; - + case DumpNewNonPagedPoolStats: MiDebugDumpNonPagedPoolStats(TRUE); break; @@ -64,15 +64,15 @@ KdpServiceDispatcher(ULONG Service, case DumpAllThreads: PspDumpThreads(TRUE); break; - + case DumpUserThreads: PspDumpThreads(FALSE); break; - + case EnterDebugger: DbgBreakPoint(); break; - + default: break; } @@ -97,7 +97,7 @@ KdpEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord, { /* Get out of here if the Debugger isn't enabled */ if (!KdDebuggerEnabled) return kdHandleException; - + /* FIXME: * Right now, the GDB wrapper seems to handle exceptions differntly * from KDGB and both are called at different times, while the GDB @@ -108,11 +108,11 @@ KdpEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord, { /* Call the registered wrapper */ if (WrapperInitRoutine) return WrapperTable. - KdpExceptionRoutine(ExceptionRecord, + KdpExceptionRoutine(ExceptionRecord, Context, TrapFrame); } - + /* Call KDBG if available */ return KdbEnterDebuggerException(ExceptionRecord, PreviousMode, @@ -131,15 +131,15 @@ STDCALL KdDisableDebugger(VOID) { KIRQL OldIrql; - + /* Raise IRQL */ KeRaiseIrql(DISPATCH_LEVEL, &OldIrql); - + /* TODO: Disable any breakpoints */ - + /* Disable the Debugger */ KdDebuggerEnabled = FALSE; - + /* Lower the IRQL */ KeLowerIrql(OldIrql); } @@ -152,15 +152,15 @@ STDCALL KdEnableDebugger(VOID) { KIRQL OldIrql; - + /* Raise IRQL */ KeRaiseIrql(DISPATCH_LEVEL, &OldIrql); - + /* TODO: Re-enable any breakpoints */ - + /* Enable the Debugger */ KdDebuggerEnabled = TRUE; - + /* Lower the IRQL */ KeLowerIrql(OldIrql); } @@ -168,7 +168,7 @@ KdEnableDebugger(VOID) /* * @implemented */ -BOOLEAN +BOOLEAN STDCALL KdPollBreakIn(VOID) { @@ -178,7 +178,7 @@ KdPollBreakIn(VOID) /* * @implemented */ -VOID +VOID STDCALL KeEnterKernelDebugger(VOID) { @@ -186,7 +186,7 @@ KeEnterKernelDebugger(VOID) /* Set the Variable */ KdEnteredDebugger = TRUE; - + /* Halt the CPU */ for (;;) Ke386HaltProcessor(); } diff --git a/reactos/ntoskrnl/kd/wrappers/bochs.c b/reactos/ntoskrnl/kd/wrappers/bochs.c index e0c5cca9025..b7661282dfb 100644 --- a/reactos/ntoskrnl/kd/wrappers/bochs.c +++ b/reactos/ntoskrnl/kd/wrappers/bochs.c @@ -1,9 +1,9 @@ -/* +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/kd/wrappers/bochs.c * PURPOSE: BOCHS Wrapper for Kd - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) */ @@ -49,7 +49,7 @@ KdpBochsInit(PKD_DISPATCH_TABLE WrapperTable, else if (BootPhase == 2) { HalDisplayString("\n Bochs debugging enabled\n\n"); - } + } } /* EOF */ diff --git a/reactos/ntoskrnl/kd/wrappers/gdbstub.c b/reactos/ntoskrnl/kd/wrappers/gdbstub.c index c80e5ed04fc..49e5d20c3d5 100644 --- a/reactos/ntoskrnl/kd/wrappers/gdbstub.c +++ b/reactos/ntoskrnl/kd/wrappers/gdbstub.c @@ -132,20 +132,20 @@ typedef struct _CPU_REGISTER #define EIP_REGNO 8 -typedef -VOID -STDCALL_FUNC -(*PKSYSTEM_ROUTINE)(PKSTART_ROUTINE StartRoutine, +typedef +VOID +STDCALL_FUNC +(*PKSYSTEM_ROUTINE)(PKSTART_ROUTINE StartRoutine, PVOID StartContext); VOID STDCALL -KiThreadStartup(PKSYSTEM_ROUTINE SystemRoutine, - PKSTART_ROUTINE StartRoutine, - PVOID StartContext, +KiThreadStartup(PKSYSTEM_ROUTINE SystemRoutine, + PKSTART_ROUTINE StartRoutine, + PVOID StartContext, BOOLEAN UserThread, KTRAP_FRAME TrapFrame); - + static CPU_REGISTER GspRegisters[NUMREGS] = { { 4, FIELD_OFFSET (KTRAP_FRAME_X86, Eax), FIELD_OFFSET (CONTEXT, Eax), TRUE }, @@ -165,16 +165,16 @@ static CPU_REGISTER GspRegisters[NUMREGS] = { 4, FIELD_OFFSET (KTRAP_FRAME_X86, Fs), FIELD_OFFSET (CONTEXT, SegFs), TRUE }, { 4, FIELD_OFFSET (KTRAP_FRAME_X86, Gs), FIELD_OFFSET (CONTEXT, SegGs), TRUE } }; - + static PCHAR GspThreadStates[DeferredReady+1] = -{ "Initialized", - "Ready", +{ "Initialized", + "Ready", "Running", - "Standby", - "Terminated", + "Standby", + "Terminated", "Waiting", - "Transition", - "DeferredReady" + "Transition", + "DeferredReady" }; char * @@ -873,9 +873,9 @@ GspQuery(PCHAR Request) if (GspFindThread (ptr, &ThreadInfo)) { PCHAR String = GspThreadStates[ThreadInfo->Tcb.State]; - + ObDereferenceObject(ThreadInfo); - + GspMem2Hex (String, &GspOutBuffer[0], strlen (String), FALSE); } } @@ -1166,7 +1166,7 @@ KdpGdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord, else { /* Don't switch threads */ - + /* Always use the current thread when entering the exception handler */ if (NULL != GspDbgThread) { @@ -1502,7 +1502,7 @@ KdpGdbDebugPrint(PCH Message) if (GspInitialized) { ULONG Length; - + GspOutBuffer[0] = 'O'; GspOutBuffer[1] = '\0'; strcat (&GspOutBuffer[0], Message); @@ -1544,20 +1544,20 @@ KdGdbListModules() } /* Initialize the GDB stub */ -VOID +VOID STDCALL KdpGdbStubInit(PKD_DISPATCH_TABLE WrapperTable, ULONG BootPhase) { if (!KdDebuggerEnabled || !KdpDebugMode.Gdb) return; - + if (BootPhase == 0) { /* Write out the functions that we support for now */ WrapperTable->KdpInitRoutine = KdpGdbStubInit; WrapperTable->KdpPrintRoutine = KdpGdbDebugPrint; WrapperTable->KdpExceptionRoutine = KdpGdbEnterDebuggerException; - + /* Initialize the Port */ KdPortInitializeEx(&GdbPortInfo, 0, 0); } @@ -1572,7 +1572,7 @@ KdpGdbStubInit(PKD_DISPATCH_TABLE WrapperTable, HalDisplayString("Waiting for GDB to attach\n"); DbgPrint("Module 'hal.dll' loaded at 0x%.08x.\n", LdrHalBase); DbgBreakPointWithStatus (DBG_STATUS_CONTROL_C); - } + } else if (BootPhase == 2) { HalDisplayString("\n GDB debugging enabled\n\n"); diff --git a/reactos/ntoskrnl/kdbg/i386/dis-asm.h b/reactos/ntoskrnl/kdbg/i386/dis-asm.h index d2d1bfe712e..1bfd8063aea 100644 --- a/reactos/ntoskrnl/kdbg/i386/dis-asm.h +++ b/reactos/ntoskrnl/kdbg/i386/dis-asm.h @@ -1,7 +1,7 @@ /* Interface between the opcode library and its callers. Copyright 2001, 2002 Free Software Foundation, Inc. - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) @@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - + Written by Cygnus Support, 1993. The opcode library (libopcodes.a) provides instruction decoders for @@ -49,7 +49,7 @@ enum dis_insn_type { dis_dref2 /* Two data references in instruction */ }; -/* This struct is passed into the instruction decoding routine, +/* This struct is passed into the instruction decoding routine, and is passed back out into each callback. The various fields are used for conveying information from your main routine into your callbacks, for passing information into the instruction decoders (such as the @@ -153,7 +153,7 @@ typedef struct disassemble_info { int bytes_per_chunk; enum bfd_endian display_endian; - /* Number of octets per incremented target address + /* Number of octets per incremented target address Normally one, but some DSPs have byte sizes of 16 or 32 bits. */ unsigned int octets_per_byte; @@ -231,7 +231,7 @@ extern int print_insn_pj PARAMS ((bfd_vma, disassemble_info*)); extern int print_insn_big_powerpc PARAMS ((bfd_vma, disassemble_info*)); extern int print_insn_little_powerpc PARAMS ((bfd_vma, disassemble_info*)); extern int print_insn_rs6000 PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_s390 PARAMS ((bfd_vma, disassemble_info*)); +extern int print_insn_s390 PARAMS ((bfd_vma, disassemble_info*)); extern int print_insn_sh PARAMS ((bfd_vma, disassemble_info*)); extern int print_insn_tic30 PARAMS ((bfd_vma, disassemble_info*)); extern int print_insn_tic4x PARAMS ((bfd_vma, disassemble_info*)); diff --git a/reactos/ntoskrnl/kdbg/i386/i386-dis.c b/reactos/ntoskrnl/kdbg/i386/i386-dis.c index 95c5f4c619a..c6773ebc1a7 100644 --- a/reactos/ntoskrnl/kdbg/i386/i386-dis.c +++ b/reactos/ntoskrnl/kdbg/i386/i386-dis.c @@ -1,5 +1,5 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/dbg/i386/i386-dis.c @@ -19,7 +19,7 @@ typedef enum bfd_flavour } bfd_flavour; typedef enum bfd_architecture { - bfd_arch_i386, + bfd_arch_i386, } bfd_arch; typedef unsigned int bfd_vma; typedef unsigned char bfd_byte; diff --git a/reactos/ntoskrnl/kdbg/kdb.c b/reactos/ntoskrnl/kdbg/kdb.c index 95b94f16c99..82581034353 100644 --- a/reactos/ntoskrnl/kdbg/kdb.c +++ b/reactos/ntoskrnl/kdbg/kdb.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/kdbg/kdb.c * PURPOSE: Kernel Debugger - * + * * PROGRAMMERS: Gregor Anich */ @@ -130,13 +130,13 @@ KdbpOverwriteInstruction( /* Get the protection for the address. */ Protect = MmGetPageProtect(Process, (PVOID)PAGE_ROUND_DOWN(Address)); - + /* Return if that page isn't present. */ if (Protect & PAGE_NOACCESS) { return STATUS_MEMORY_NOT_ALLOCATED; } - + /* Attach to the process */ if (CurrentProcess != Process) { @@ -149,7 +149,7 @@ KdbpOverwriteInstruction( MmSetPageProtect(Process, (PVOID)PAGE_ROUND_DOWN(Address), (Protect & ~(PAGE_READONLY|PAGE_EXECUTE|PAGE_EXECUTE_READ)) | PAGE_READWRITE); } - + /* Copy the old instruction back to the caller. */ if (OldInst != NULL) { @@ -168,16 +168,16 @@ KdbpOverwriteInstruction( return Status; } } - + /* Copy the new instruction in its place. */ Status = KdbpSafeWriteMemory((PUCHAR)Address, &NewInst, 1); - + /* Restore the page protection. */ if (Protect & (PAGE_READONLY|PAGE_EXECUTE|PAGE_EXECUTE_READ)) { MmSetPageProtect(Process, (PVOID)PAGE_ROUND_DOWN(Address), Protect); } - + /* Detach from process */ if (CurrentProcess != Process) { @@ -303,7 +303,7 @@ KdbpStepIntoInstruction(ULONG_PTR Eip) /*KdbpPrint("Couldn't access memory at 0x%x\n", (UINT)Idtr.Base + (IntVect * 8));*/ return FALSE; } - + /* Check descriptor and get target eip (16 bit interrupt/trap gates not supported) */ if ((IntDesc[1] & (1 << 15)) == 0) /* not present */ { @@ -384,7 +384,7 @@ KdbpGetBreakPointInfo( { return FALSE; } - + bp = KdbBreakPoints + BreakPointNr; if (Address != NULL) *Address = bp->Address; @@ -461,7 +461,7 @@ KdbpInsertBreakPoint( { return STATUS_UNSUCCESSFUL; } - + /* Parse conditon expression string and duplicate it */ if (ConditionExpression != NULL) { @@ -504,7 +504,7 @@ KdbpInsertBreakPoint( } } ASSERT(i < RTL_NUMBER_OF(KdbBreakPoints)); - + /* Set the breakpoint */ ASSERT(KdbCurrentProcess != NULL); KdbBreakPoints[i].Type = Type; @@ -521,7 +521,7 @@ KdbpInsertBreakPoint( KdbBreakPoints[i].Data.Hw.AccessType = AccessType; } KdbBreakPointCount++; - + if (Type != KdbBreakPointTemporary) KdbpPrint("Breakpoint %d inserted.\n", i); @@ -576,7 +576,7 @@ KdbpDeleteBreakPoint( KdbpPrint("Breakpoint %d deleted.\n", BreakPointNr); BreakPoint->Type = KdbBreakPointNone; KdbBreakPointCount--; - + return TRUE; } @@ -626,7 +626,7 @@ KdbpIsBreakPointOurs( } } } - + return -1; } @@ -668,7 +668,7 @@ KdbpEnableBreakPoint( KdbpPrint("Invalid breakpoint: %d\n", BreakPointNr); return FALSE; } - + if (BreakPoint->Enabled == TRUE) { KdbpPrint("Breakpoint %d is already enabled.\n", BreakPointNr); @@ -803,7 +803,7 @@ KdbpDisableBreakPoint( { INT i; NTSTATUS Status; - + if (BreakPointNr < 0) { ASSERT(BreakPoint != NULL); @@ -841,7 +841,7 @@ KdbpDisableBreakPoint( KdbpPrint("Couldn't restore original instruction.\n"); return FALSE; } - + for (i = 0; i < KdbSwBreakPointCount; i++) { if (KdbSwBreakPoints[i] == BreakPoint) @@ -857,7 +857,7 @@ KdbpDisableBreakPoint( else { ASSERT(BreakPoint->Type == KdbBreakPointHardware); - + /* Clear the breakpoint. */ KdbTrapFrame.Tf.Dr7 &= ~(0x3 << (BreakPoint->Data.Hw.DebugReg * 2)); if ((KdbTrapFrame.Tf.Dr7 & 0xFF) == 0) @@ -976,7 +976,7 @@ KdbpAttachToThread( KdbpPrint("Cannot attach to thread within another process while executing a DPC.\n"); return FALSE; } - + /* Save the current thread's context (if we previously attached to a thread) */ if (KdbCurrentThread != KdbOriginalThread) { @@ -1076,11 +1076,11 @@ KdbpCallMainLoop() */ STATIC VOID KdbpInternalEnter() -{ +{ PETHREAD Thread; PVOID SavedInitialStack, SavedStackBase, SavedKernelStack; ULONG SavedStackLimit; - + KbdDisableMouse(); if (KdpDebugMode.Screen) { @@ -1188,7 +1188,7 @@ KdbEnterDebuggerException( { Resume = TRUE; /* Set the resume flag when continuing execution */ } - + /* * When a temporary breakpoint is hit we have to make sure that we are * in the same context in which it was set, otherwise it could happen @@ -1198,7 +1198,7 @@ KdbEnterDebuggerException( BreakPoint->Process == KdbCurrentProcess) { ASSERT((TrapFrame->Eflags & X86_EFLAGS_TF) == 0); - + /* * Delete the temporary breakpoint which was used to step over or into the instruction. */ @@ -1228,7 +1228,7 @@ KdbEnterDebuggerException( TrapFrame->Eflags |= X86_EFLAGS_TF; KdbBreakPointToReenable = BreakPoint; } - + /* * Make sure that the breakpoint should be triggered in this context */ @@ -1236,7 +1236,7 @@ KdbEnterDebuggerException( { goto continue_execution; /* return */ } - + /* * Check if the condition for the breakpoint is met. */ @@ -1385,10 +1385,10 @@ KdbEnterDebuggerException( } } } - + /* Once we enter the debugger we do not expect any more single steps to happen */ KdbNumSingleSteps = 0; - + /* Update the current process pointer */ KdbCurrentProcess = KdbOriginalProcess = PsGetCurrentProcess(); KdbCurrentThread = KdbOriginalThread = PsGetCurrentThread(); @@ -1472,7 +1472,7 @@ continue_execution: { TrapFrame->Eflags |= X86_EFLAGS_RF; } - + /* Clear dr6 status flags. */ TrapFrame->Dr6 &= ~0x0000e00f; @@ -1485,7 +1485,7 @@ VOID KdbDeleteProcessHook(IN PEPROCESS Process) { KdbSymFreeProcessSymbols(Process); - + /* FIXME: Delete breakpoints for process */ } @@ -1510,7 +1510,7 @@ KdbpGetCommandLineSettings(PCHAR p1) p2 += 8; KdbDebugState |= KD_DEBUG_KDNOECHO; } - + p1 = p2; } } diff --git a/reactos/ntoskrnl/kdbg/kdb.h b/reactos/ntoskrnl/kdbg/kdb.h index c9b631d51a5..5849a1cbaff 100644 --- a/reactos/ntoskrnl/kdbg/kdb.h +++ b/reactos/ntoskrnl/kdbg/kdb.h @@ -94,7 +94,7 @@ LONG KdbpDisassemble( IN ULONG Address, IN ULONG IntelSyntax); - + LONG KdbpGetInstLength( IN ULONG Address); @@ -167,7 +167,7 @@ BOOLEAN KdbpSymFindModuleByIndex(IN INT Index, OUT PKDB_MODULE_INFO pInfo); -BOOLEAN +BOOLEAN KdbSymPrintAddress(IN PVOID Address); NTSTATUS @@ -219,7 +219,7 @@ KdbpInsertBreakPoint( IN PCHAR ConditionExpression OPTIONAL, IN BOOLEAN Global, OUT PULONG BreakPointNumber OPTIONAL); - + BOOLEAN KdbpDeleteBreakPoint( IN LONG BreakPointNr OPTIONAL, diff --git a/reactos/ntoskrnl/kdbg/kdb_cli.c b/reactos/ntoskrnl/kdbg/kdb_cli.c index 65c7c943392..bb96f7e2c87 100644 --- a/reactos/ntoskrnl/kdbg/kdb_cli.c +++ b/reactos/ntoskrnl/kdbg/kdb_cli.c @@ -25,7 +25,7 @@ * UPDATE HISTORY: * Created 16/01/2005 */ - + /* INCLUDES ******************************************************************/ #include @@ -187,7 +187,7 @@ KdbpEvaluateExpression( ErrMsg += 2; KdbpPrint("%*s%s\n", ExpressionErrOffset, "", ErrMsg); } - + return Ok; } @@ -207,7 +207,7 @@ KdbpCmdEvalExpression(ULONG Argc, PCHAR Argv[]) KdbpPrint("?: Argument required\n"); return TRUE; } - + /* Put the arguments back together */ Argc--; for (i = 1; i < Argc; i++) @@ -215,7 +215,7 @@ KdbpCmdEvalExpression(ULONG Argc, PCHAR Argv[]) len = strlen(Argv[i]); Argv[i][len] = ' '; } - + /* Evaluate the expression */ Ok = KdbpEvaluateExpression(Argv[1], sizeof("kdb:> ")-1 + (Argv[1]-Argv[0]), &Result); if (Ok) @@ -242,7 +242,7 @@ KdbpCmdEvalExpression(ULONG Argc, PCHAR Argv[]) KdbpPrint("0x%08lx %10lu\n", ul, ul); } } - + return TRUE; } @@ -376,7 +376,7 @@ KdbpCmdRegs(ULONG Argc, PCHAR Argv[]) { ULONG Esp; USHORT Ss; - + if (!(Tf->Cs & 1)) { Esp = (ULONG)Tf->TempEsp; @@ -435,7 +435,7 @@ KdbpCmdRegs(ULONG Argc, PCHAR Argv[]) " PCE", " OSFXSR", " OSXMMEXCPT", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; - + Cr0 = KdbCurrentTrapFrame->Cr0; Cr2 = KdbCurrentTrapFrame->Cr2; Cr3 = KdbCurrentTrapFrame->Cr3; @@ -448,7 +448,7 @@ KdbpCmdRegs(ULONG Argc, PCHAR Argv[]) /* Get the task register */ asm volatile("str %0" : "=g"(Tr)); - + /* Display the control registers */ KdbpPrint("CR0 0x%08x ", Cr0); for (i = 0; i < 32; i++) @@ -469,7 +469,7 @@ KdbpCmdRegs(ULONG Argc, PCHAR Argv[]) if ((Cr4 & (1 << i)) != 0) KdbpPrint(Cr4Bits[i]); } - + /* Display the descriptor table regs */ KdbpPrint("\nGDTR Base 0x%08x Size 0x%04x\n", Gdtr.Base, Gdtr.Limit); KdbpPrint("LDTR Base 0x%08x Size 0x%04x\n", Ldtr.Base, Ldtr.Limit); @@ -597,7 +597,7 @@ KdbpCmdBackTrace(ULONG Argc, PCHAR Argv[]) break; } } - + return TRUE; } @@ -616,7 +616,7 @@ STATIC BOOLEAN KdbpCmdStep(ULONG Argc, PCHAR Argv[]) { ULONG Count = 1; - + if (Argc > 1) { Count = strtoul(Argv[1], NULL, 0); @@ -626,7 +626,7 @@ KdbpCmdStep(ULONG Argc, PCHAR Argv[]) return TRUE; } } - + if (Argv[0][0] == 'n') KdbSingleStepOver = TRUE; else @@ -661,7 +661,7 @@ KdbpCmdBreakPointList(ULONG Argc, PCHAR Argv[]) KdbpPrint("No breakpoints.\n"); return TRUE; } - + KdbpPrint("Breakpoints:\n"); do { @@ -782,7 +782,7 @@ KdbpCmdBreakPoint(ULONG Argc, PCHAR Argv[]) KDB_ACCESS_TYPE AccessType = 0; INT AddressArgIndex, ConditionArgIndex, i; BOOLEAN Global = TRUE; - + if (Argv[0][2] == 'x') /* software breakpoint */ { if (Argc < 2) @@ -797,7 +797,7 @@ KdbpCmdBreakPoint(ULONG Argc, PCHAR Argv[]) else /* memory breakpoint */ { ASSERT(Argv[0][2] == 'm'); - + if (Argc < 2) { KdbpPrint("bpm: Access type argument required (one of r, w, rw, x)\n"); @@ -817,7 +817,7 @@ KdbpCmdBreakPoint(ULONG Argc, PCHAR Argv[]) KdbpPrint("bpm: Unknown access type '%s'\n", Argv[1]); return TRUE; } - + if (Argc < 3) { KdbpPrint("bpm: %s argument required.\n", AccessType == KdbAccessExec ? "Address" : "Memory size"); @@ -840,7 +840,7 @@ KdbpCmdBreakPoint(ULONG Argc, PCHAR Argv[]) KdbpPrint("bpm: Unknown memory size '%s'\n", Argv[2]); return TRUE; } - + if (Argc <= AddressArgIndex) { KdbpPrint("bpm: Address argument required.\n"); @@ -849,7 +849,7 @@ KdbpCmdBreakPoint(ULONG Argc, PCHAR Argv[]) Type = KdbBreakPointHardware; } - + /* Put the arguments back together */ ConditionArgIndex = -1; for (i = AddressArgIndex; i < (Argc-1); i++) @@ -883,7 +883,7 @@ KdbpCmdBreakPoint(ULONG Argc, PCHAR Argv[]) KdbpInsertBreakPoint(Address, Type, Size, AccessType, (ConditionArgIndex < 0) ? NULL : Argv[ConditionArgIndex], Global, NULL); - + return TRUE; } @@ -909,7 +909,7 @@ KdbpCmdThread(ULONG Argc, PCHAR Argv[]) if (Argc >= 2 && _stricmp(Argv[1], "list") == 0) { Process = KdbCurrentProcess; - + if (Argc >= 3) { ul = strtoul(Argv[2], &pend, 0); @@ -924,7 +924,7 @@ KdbpCmdThread(ULONG Argc, PCHAR Argv[]) return TRUE; } } - + Entry = Process->ThreadListHead.Flink; if (Entry == &Process->ThreadListHead) { @@ -963,13 +963,13 @@ KdbpCmdThread(ULONG Argc, PCHAR Argv[]) Ebp = (PULONG)Esp[4]; Eip = 0; if (Ebp != NULL) /* FIXME: Should we attach to the process to read Ebp[1]? */ - KdbpSafeReadMemory(&Eip, Ebp + 1, sizeof (Eip));; + KdbpSafeReadMemory(&Eip, Ebp + 1, sizeof (Eip)); } if (Thread->Tcb.State < (DeferredReady + 1)) State = ThreadStateToString[Thread->Tcb.State]; else State = "Unknown"; - + KdbpPrint(" %s0x%08x %-11s %3d 0x%08x 0x%08x 0x%08x%s\n", str1, Thread->Cid.UniqueThread, @@ -979,7 +979,7 @@ KdbpCmdThread(ULONG Argc, PCHAR Argv[]) Ebp, Eip, str2); - + Entry = Entry->Flink; } while (Entry != &Process->ThreadListHead); @@ -1022,7 +1022,7 @@ KdbpCmdThread(ULONG Argc, PCHAR Argv[]) return TRUE; } } - + if (Thread->Tcb.State < (DeferredReady + 1)) State = ThreadStateToString[Thread->Tcb.State]; else @@ -1074,7 +1074,7 @@ KdbpCmdProc(ULONG Argc, PCHAR Argv[]) KdbpPrint("No processes in the system!\n"); return TRUE; } - + KdbpPrint(" PID State Filename\n"); do { @@ -1093,14 +1093,14 @@ KdbpCmdProc(ULONG Argc, PCHAR Argv[]) State = ((Process->Pcb.State == PROCESS_STATE_TERMINATED) ? "Terminated" : ((Process->Pcb.State == PROCESS_STATE_ACTIVE) ? "Active" : "Unknown")); - + KdbpPrint(" %s0x%08x %-10s %s%s\n", str1, Process->UniqueProcessId, State, Process->ImageFileName, str2); - + Entry = Entry->Flink; } while(Entry != &PsActiveProcessHead); @@ -1186,7 +1186,7 @@ KdbpCmdMod(ULONG Argc, PCHAR Argv[]) if (Result > (ULONGLONG)(~((ULONG_PTR)0))) KdbpPrint("%s: Warning: Address %I64x is beeing truncated\n", Argv[0]); Address = (ULONG_PTR)Result; - + if (!KdbpSymFindModuleByAddress((PVOID)Address, &Info)) { KdbpPrint("No module containing address 0x%x found!\n", Address); @@ -1308,7 +1308,7 @@ KdbpCmdGdtLdtIdt(ULONG Argc, PCHAR Argv[]) i = 0; ul = 1 << 2; } - + if (Reg.Limit < 7) { KdbpPrint("%s descriptor table is empty.\n", @@ -1419,7 +1419,7 @@ KdbpCmdGdtLdtIdt(ULONG Argc, PCHAR Argv[]) } } } - + return TRUE; } @@ -1465,7 +1465,7 @@ KdbpCmdPcr(ULONG Argc, PCHAR Argv[]) Pcr->MajorVersion, Pcr->MinorVersion, Pcr->SetMember, Pcr->StallScaleFactor, Pcr->DebugActive, Pcr->ProcessorNumber, Pcr->L2CacheAssociativity, Pcr->VdmAlert, Pcr->L2CacheSize, Pcr->InterruptMode); - + return TRUE; } @@ -1718,11 +1718,11 @@ KdbpPrint( if (!TerminalInitialized) { DbgPrint("\x1b[7h"); /* Enable linewrap */ - + /* Query terminal type */ /*DbgPrint("\x1b[Z");*/ DbgPrint("\x05"); - + TerminalInitialized = TRUE; Length = 0; for (;;) @@ -1803,7 +1803,7 @@ KdbpPrint( while (p[0] != '\0') { i = strcspn(p, "\n"); - + /* Calculate the number of lines which will be printed in the terminal * when outputting the current line */ @@ -1813,7 +1813,7 @@ KdbpPrint( RowsPrintedByTerminal = 0; if (p[i] == '\n') RowsPrintedByTerminal++; - + /*DbgPrint("!%d!%d!%d!%d!", KdbNumberOfRowsPrinted, KdbNumberOfColsPrinted, i, RowsPrintedByTerminal);*/ /* Display a prompt if we printed one screen full of text */ @@ -1856,7 +1856,7 @@ KdbpPrint( { c = '\0'; } - + /* Remove escape sequences from the line if there's no terminal connected */ if (!TerminalConnected) { @@ -1906,7 +1906,7 @@ KdbpCommandHistoryAppend( LONG Length2 = 0; INT i; PCHAR Buffer; - + ASSERT(Length1 <= RTL_NUMBER_OF(KdbCommandHistoryBuffer)); if (Length1 <= 1 || @@ -2169,7 +2169,7 @@ KdbpDoCommand( p++; if (*p == '\0') break; - + i = strcspn(p, "\t "); Argv[Argc++] = p; p += i; @@ -2241,11 +2241,11 @@ KdbpCliMainLoop( /* Read a command and remember it */ KdbpReadCommand(Command, sizeof (Command)); KdbpCommandHistoryAppend(Command); - + /* Reset the number of rows/cols printed and output aborted state */ KdbNumberOfRowsPrinted = KdbNumberOfColsPrinted = 0; KdbOutputAborted = FALSE; - + /* Call the command */ Continue = KdbpDoCommand(Command); } while (Continue); @@ -2302,7 +2302,7 @@ KdbpCliInterpretInitFile() { KdbpDoCommand(p1); } - + p1[i] = c; } p1 += i; @@ -2332,7 +2332,7 @@ KdbpCliInit() /* Initialize the object attributes */ RtlInitUnicodeString(&FileName, L"\\SystemRoot\\system32\\drivers\\etc\\KDBinit"); InitializeObjectAttributes(&ObjectAttributes, &FileName, 0, NULL, NULL); - + /* Open the file */ Status = ZwOpenFile(&hFile, FILE_READ_DATA, &ObjectAttributes, &Iosb, 0, FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | diff --git a/reactos/ntoskrnl/kdbg/kdb_expr.c b/reactos/ntoskrnl/kdbg/kdb_expr.c index e3d2680a6a1..2c23abd3478 100644 --- a/reactos/ntoskrnl/kdbg/kdb_expr.c +++ b/reactos/ntoskrnl/kdbg/kdb_expr.c @@ -212,11 +212,11 @@ RpnpDumpStack( case RpnOpNop: DbgPrint("NOP,"); break; - + case RpnOpImmediate: DbgPrint("0x%I64x,", Op->Data.Immediate); break; - + case RpnOpBinaryOperator: if (Op->Data.BinaryOperator == RpnBinaryOperatorAdd) DbgPrint("+,"); @@ -243,11 +243,11 @@ RpnpDumpStack( else DbgPrint("UNKNOWN OP,"); break; - + case RpnOpRegister: DbgPrint("%s,", RegisterToTrapFrame[Op->Data.Register].Name); break; - + case RpnOpDereference: DbgPrint("[%s],", (Op->Data.DerefMemorySize == 1) ? ("byte") : @@ -256,7 +256,7 @@ RpnpDumpStack( ) ); break; - + default: DbgPrint("\nUnsupported Type: %d\n", Op->Type); ul = Stack->Sp; @@ -401,7 +401,7 @@ RpnpParseExpression( p++; CharacterOffset++; } - + /* Check for end of expression */ if (p[0] == '\0' || p[0] == ')' || p[0] == ']') break; @@ -410,8 +410,8 @@ RpnpParseExpression( { /* Remember operator */ Operator = p++; - OperatorOffset = CharacterOffset++;; - + OperatorOffset = CharacterOffset++; + /* Pop operator (to get the right operator precedence) */ HavePoppedOperator = FALSE; if (*Operator == '*' || *Operator == '/' || *Operator == '%') @@ -508,7 +508,7 @@ get_operand: *ErrOffset = CharacterOffset; return FALSE; } - + p += i; CharacterOffset += i; goto get_operand; @@ -624,7 +624,7 @@ get_operand: /* Skip closing brace/bracket */ pend++; - + CharacterOffset += pend - p; p = pend; } @@ -690,7 +690,7 @@ get_operand: IsComparativeOp = TRUE; RpnOp.Data.BinaryOperator = RpnBinaryOperatorEquals; break; - + case '!': ASSERT(Operator[1] == '='); IsComparativeOp = TRUE; @@ -749,10 +749,10 @@ get_operand: } } } - + First = FALSE; } - + //end_of_expression: if (ComparativeOpFilled && !RpnpPushStack(Stack, &ComparativeOp)) @@ -772,7 +772,7 @@ get_operand: if (End != NULL) *End = p; - + return TRUE; } @@ -825,7 +825,7 @@ RpnpEvaluateStack( case RpnOpNop: /* No operation */ break; - + case RpnOpImmediate: if (ValueStackPointer == RPN_VALUE_STACK_SIZE) { @@ -951,7 +951,7 @@ RpnpEvaluateStack( *ErrOffset = -1; return FALSE; } - + *Result = ValueStack[0]; return TRUE; } @@ -976,7 +976,7 @@ KdbpRpnEvaluateExpression( OUT PCHAR ErrMsg OPTIONAL) { PRPN_STACK Stack = (PRPN_STACK)&RpnStack; - + ASSERT(Expression != NULL); ASSERT(TrapFrame != NULL); ASSERT(Result != NULL); @@ -1045,7 +1045,7 @@ KdbpRpnParseExpression( } memcpy(NewStack, Stack, Size); NewStack->Size = NewStack->Sp; - + return NewStack; } diff --git a/reactos/ntoskrnl/kdbg/kdb_keyboard.c b/reactos/ntoskrnl/kdbg/kdb_keyboard.c index bf3bfdc843e..a1863d2df05 100644 --- a/reactos/ntoskrnl/kdbg/kdb_keyboard.c +++ b/reactos/ntoskrnl/kdbg/kdb_keyboard.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/dbg/kdb_keyboard.c * PURPOSE: Keyboard driver - * + * * PROGRAMMERS: Victor Kirhenshtein (sauros@iname.com) * Jason Filby (jasonfilby@yahoo.com) */ @@ -17,9 +17,9 @@ #if 1 -#define KBD_STATUS_REG 0x64 -#define KBD_CNTL_REG 0x64 -#define KBD_DATA_REG 0x60 +#define KBD_STATUS_REG 0x64 +#define KBD_CNTL_REG 0x64 +#define KBD_DATA_REG 0x60 #define KBD_DISABLE_MOUSE 0xA7 #define KBD_ENABLE_MOUSE 0xA8 @@ -92,7 +92,7 @@ KdbpTryGetCharKeyboard(PULONG ScanCode, UINT Retry) } } } - + return -1; } @@ -121,7 +121,7 @@ KdbpTryGetCharKeyboard(PULONG ScanCode, UINT Retry) #define K_TIMEOUT 0x40 /* timout error flag */ #define K_PARITY_ERROR 0x80 /* parity error flag */ -/* +/* * Keyboard controller commands (sent to K_CMD port). */ #define KC_CMD_READ 0x20 /* read controller command byte */ @@ -140,14 +140,14 @@ KdbpTryGetCharKeyboard(PULONG ScanCode, UINT Retry) #define KC_CMD_ECHO 0xee /* used for diagnostic testing */ #define KC_CMD_PULSE 0xff /* pulse bits 3-0 based on low nybble */ -/* +/* * Keyboard commands (send to K_RDWR). */ #define K_CMD_LEDS 0xed /* set status LEDs (caps lock, etc.) */ #define K_CMD_TYPEMATIC 0xf3 /* set key repeat and delay */ -/* - * Bit definitions for controller command byte (sent following +/* + * Bit definitions for controller command byte (sent following * KC_CMD_WRITE command). * * Bits 0x02 and 0x80 unused, always set to 0. @@ -159,16 +159,16 @@ KdbpTryGetCharKeyboard(PULONG ScanCode, UINT Retry) #define K_CB_IGNPARITY 0x20 /* ignore parity from keyboard */ #define K_CB_SCAN 0x40 /* standard scan conversion */ -/* - * Bit definitions for "Indicator Status Byte" (sent after a - * K_CMD_LEDS command). If the bit is on, the LED is on. Undefined +/* + * Bit definitions for "Indicator Status Byte" (sent after a + * K_CMD_LEDS command). If the bit is on, the LED is on. Undefined * bit positions must be 0. */ #define K_LED_SCRLLK 0x1 /* scroll lock */ #define K_LED_NUMLK 0x2 /* num lock */ #define K_LED_CAPSLK 0x4 /* caps lock */ -/* +/* * Bit definitions for "Miscellaneous port B" (K_PORTB). */ /* read/write */ diff --git a/reactos/ntoskrnl/kdbg/kdb_serial.c b/reactos/ntoskrnl/kdbg/kdb_serial.c index 5ab846a9689..9cadb113b61 100644 --- a/reactos/ntoskrnl/kdbg/kdb_serial.c +++ b/reactos/ntoskrnl/kdbg/kdb_serial.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/dbg/kdb_serial.c * PURPOSE: Serial driver - * + * * PROGRAMMERS: Victor Kirhenshtein (sauros@iname.com) * Jason Filby (jasonfilby@yahoo.com) * arty diff --git a/reactos/ntoskrnl/kdbg/kdb_symbols.c b/reactos/ntoskrnl/kdbg/kdb_symbols.c index 89c34b7c7c0..0cfd513b47d 100644 --- a/reactos/ntoskrnl/kdbg/kdb_symbols.c +++ b/reactos/ntoskrnl/kdbg/kdb_symbols.c @@ -1,9 +1,9 @@ -/* +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/dbg/kdb_symbols.c * PURPOSE: Getting symbol information... - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ diff --git a/reactos/ntoskrnl/ke/apc.c b/reactos/ntoskrnl/ke/apc.c index 81feb42d15b..b76c82af0f8 100644 --- a/reactos/ntoskrnl/ke/apc.c +++ b/reactos/ntoskrnl/ke/apc.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/apc.c * PURPOSE: NT Implementation of APCs - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) * Phillip Susi */ @@ -17,7 +17,7 @@ /* FUNCTIONS *****************************************************************/ /*++ - * KiKernelApcDeliveryCheck + * KiKernelApcDeliveryCheck * @implemented NT 5.2 * * The KiKernelApcDeliveryCheck routine is called whenever APCs have just @@ -62,10 +62,10 @@ KiKernelApcDeliveryCheck(VOID) } /*++ - * KeEnterCriticalRegion + * KeEnterCriticalRegion * @implemented NT4 * - * The KeEnterCriticalRegion routine temporarily disables the delivery of + * The KeEnterCriticalRegion routine temporarily disables the delivery of * normal kernel APCs; special kernel-mode APCs are still delivered. * * Params: @@ -76,15 +76,15 @@ KiKernelApcDeliveryCheck(VOID) * * Remarks: * Highest-level drivers can call this routine while running in the context - * of the thread that requested the current I/O operation. Any caller of + * of the thread that requested the current I/O operation. Any caller of * this routine should call KeLeaveCriticalRegion as quickly as possible. * * Callers of KeEnterCriticalRegion must be running at IRQL <= APC_LEVEL. * *--*/ #undef KeEnterCriticalRegion -VOID -STDCALL +VOID +STDCALL KeEnterCriticalRegion(VOID) { /* Disable Kernel APCs */ @@ -93,10 +93,10 @@ KeEnterCriticalRegion(VOID) } /*++ - * KeLeaveCriticalRegion + * KeLeaveCriticalRegion * @implemented NT4 * - * The KeLeaveCriticalRegion routine reenables the delivery of normal + * The KeLeaveCriticalRegion routine reenables the delivery of normal * kernel-mode APCs that were disabled by a call to KeEnterCriticalRegion. * * Params: @@ -107,39 +107,39 @@ KeEnterCriticalRegion(VOID) * * Remarks: * Highest-level drivers can call this routine while running in the context - * of the thread that requested the current I/O operation. + * of the thread that requested the current I/O operation. * * Callers of KeLeaveCriticalRegion must be running at IRQL <= DISPATCH_LEVEL. * *--*/ #undef KeLeaveCriticalRegion -VOID -STDCALL +VOID +STDCALL KeLeaveCriticalRegion (VOID) { - PKTHREAD Thread = KeGetCurrentThread(); + PKTHREAD Thread = KeGetCurrentThread(); /* Check if Kernel APCs are now enabled */ - if((Thread) && (++Thread->KernelApcDisable == 0)) - { + if((Thread) && (++Thread->KernelApcDisable == 0)) + { /* Check if we need to request an APC Delivery */ - if (!IsListEmpty(&Thread->ApcState.ApcListHead[KernelMode])) - { + if (!IsListEmpty(&Thread->ApcState.ApcListHead[KernelMode])) + { /* Check for the right environment */ KiKernelApcDeliveryCheck(); - } - } + } + } } /*++ - * KeInitializeApc + * KeInitializeApc * @implemented NT4 * * The The KeInitializeApc routine initializes an APC object, and registers * the Kernel, Rundown and Normal routines for that object. * * Params: - * Apc - Pointer to a KAPC structure that represents the APC object to + * Apc - Pointer to a KAPC structure that represents the APC object to * initialize. The caller must allocate storage for the structure * from resident memory. * @@ -161,7 +161,7 @@ KeLeaveCriticalRegion (VOID) * * Mode - Specifies the processor mode at which to run the Normal Routine. * - * Context - Specifices the value to pass as Context parameter to the + * Context - Specifices the value to pass as Context parameter to the * registered routines. * * Returns: @@ -170,7 +170,7 @@ KeLeaveCriticalRegion (VOID) * Remarks: * The caller can queue an initialized APC with KeInsertQueueApc. * - * Storage for the APC object must be resident, such as nonpaged pool + * Storage for the APC object must be resident, such as nonpaged pool * allocated by the caller. * * Callers of this routine must be running at IRQL = PASSIVE_LEVEL. @@ -196,44 +196,44 @@ KeInitializeApc(IN PKAPC Apc, RtlZeroMemory(Apc, sizeof(KAPC)); Apc->Type = ApcObject; Apc->Size = sizeof(KAPC); - + /* Set the Environment */ if (TargetEnvironment == CurrentApcEnvironment) { - + Apc->ApcStateIndex = Thread->ApcStateIndex; - + } else { - + Apc->ApcStateIndex = TargetEnvironment; } - + /* Set the Thread and Routines */ Apc->Thread = Thread; Apc->KernelRoutine = KernelRoutine; Apc->RundownRoutine = RundownRoutine; Apc->NormalRoutine = NormalRoutine; - + /* Check if this is a Special APC, in which case we use KernelMode and no Context */ if (ARGUMENT_PRESENT(NormalRoutine)) { - + Apc->ApcMode = Mode; Apc->NormalContext = Context; - + } else { - + Apc->ApcMode = KernelMode; - } + } } /*++ - * KiInsertQueueApc + * KiInsertQueueApc * * The KiInsertQueueApc routine queues a APC for execution when the right * scheduler environment exists. * * Params: * Apc - Pointer to an initialized control object of type DPC for which the - * caller provides the storage. + * caller provides the storage. * * PriorityBoost - Priority Boost to apply to the Thread. * @@ -256,29 +256,29 @@ KiInsertQueueApc(PKAPC Apc, PKTHREAD Thread = Apc->Thread; PLIST_ENTRY ApcListEntry; PKAPC QueuedApc; - + /* Don't do anything if the APC is already inserted */ if (Apc->Inserted) { - + return FALSE; } - - /* Three scenarios: + + /* Three scenarios: 1) Kernel APC with Normal Routine or User APC = Put it at the end of the List 2) User APC which is PsExitSpecialApc = Put it at the front of the List 3) Kernel APC without Normal Routine = Put it at the end of the No-Normal Routine Kernel APC list */ if ((Apc->ApcMode != KernelMode) && (Apc->KernelRoutine == (PKKERNEL_ROUTINE)PsExitSpecialApc)) { - + DPRINT ("Inserting the Process Exit APC into the Queue\n"); Thread->ApcStatePointer[(int)Apc->ApcStateIndex]->UserApcPending = TRUE; InsertHeadList(&Thread->ApcStatePointer[(int)Apc->ApcStateIndex]->ApcListHead[(int)Apc->ApcMode], &Apc->ApcListEntry); - + } else if (Apc->NormalRoutine == NULL) { - + DPRINT ("Inserting Special APC %x into the Queue\n", Apc); - + for (ApcListEntry = Thread->ApcStatePointer[(int)Apc->ApcStateIndex]->ApcListHead[(int)Apc->ApcMode].Flink; ApcListEntry != &Thread->ApcStatePointer[(int)Apc->ApcStateIndex]->ApcListHead[(int)Apc->ApcMode]; ApcListEntry = ApcListEntry->Flink) { @@ -286,19 +286,19 @@ KiInsertQueueApc(PKAPC Apc, QueuedApc = CONTAINING_RECORD(ApcListEntry, KAPC, ApcListEntry); if (Apc->NormalRoutine != NULL) break; } - + /* We found the first "Normal" APC, so write right before it */ ApcListEntry = ApcListEntry->Blink; InsertHeadList(ApcListEntry, &Apc->ApcListEntry); - + } else { - + DPRINT ("Inserting Normal APC %x into the %x Queue\n", Apc, Apc->ApcMode); InsertTailList(&Thread->ApcStatePointer[(int)Apc->ApcStateIndex]->ApcListHead[(int)Apc->ApcMode], &Apc->ApcListEntry); } - - /* Confirm Insertion */ + + /* Confirm Insertion */ Apc->Inserted = TRUE; /* @@ -306,41 +306,41 @@ KiInsertQueueApc(PKAPC Apc, * 1) Kernel APC, The thread is Running: Request an Interrupt * 2) Kernel APC, The Thread is Waiting at PASSIVE_LEVEL and APCs are enabled and not in progress: Unwait the Thread * 3) User APC, Unwait the Thread if it is alertable - */ - if (Apc->ApcMode == KernelMode) { - + */ + if (Apc->ApcMode == KernelMode) { + /* Set Kernel APC pending */ Thread->ApcState.KernelApcPending = TRUE; - + /* Check the Thread State */ - if (Thread->State == Running) { - + if (Thread->State == Running) { + /* FIXME: Use IPI */ DPRINT ("Requesting APC Interrupt for Running Thread \n"); HalRequestSoftwareInterrupt(APC_LEVEL); - + } else if ((Thread->State == Waiting) && (Thread->WaitIrql == PASSIVE_LEVEL) && - ((Apc->NormalRoutine == NULL) || + ((Apc->NormalRoutine == NULL) || ((!Thread->KernelApcDisable) && (!Thread->ApcState.KernelApcInProgress)))) { - + DPRINT("Waking up Thread for Kernel-Mode APC Delivery \n"); KiAbortWaitThread(Thread, STATUS_KERNEL_APC, PriorityBoost); } - - } else if ((Thread->State == Waiting) && - (Thread->WaitMode == UserMode) && + + } else if ((Thread->State == Waiting) && + (Thread->WaitMode == UserMode) && (Thread->Alertable)) { - + DPRINT("Waking up Thread for User-Mode APC Delivery \n"); Thread->ApcState.UserApcPending = TRUE; KiAbortWaitThread(Thread, STATUS_USER_APC, PriorityBoost); } - + return TRUE; } - + /*++ - * KeInsertQueueApc + * KeInsertQueueApc * @implemented NT4 * * The KeInsertQueueApc routine queues a APC for execution when the right @@ -348,7 +348,7 @@ KiInsertQueueApc(PKAPC Apc, * * Params: * Apc - Pointer to an initialized control object of type DPC for which the - * caller provides the storage. + * caller provides the storage. * * SystemArgument[1,2] - Pointer to a set of two parameters that contain * untyped data. @@ -377,7 +377,7 @@ KeInsertQueueApc(PKAPC Apc, KIRQL OldIrql; PKTHREAD Thread; BOOLEAN Inserted; - + ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL); DPRINT("KeInsertQueueApc(Apc %x, SystemArgument1 %x, " "SystemArgument2 %x)\n",Apc,SystemArgument1, @@ -385,10 +385,10 @@ KeInsertQueueApc(PKAPC Apc, /* Lock the Dispatcher Database */ OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* Get the Thread specified in the APC */ Thread = Apc->Thread; - + /* Make sure the thread allows APC Queues. * The thread is not apc queueable, for instance, when it's (about to be) terminated. */ @@ -397,7 +397,7 @@ KeInsertQueueApc(PKAPC Apc, KeReleaseDispatcherDatabaseLock(OldIrql); return FALSE; } - + /* Set the System Arguments */ Apc->SystemArgument1 = SystemArgument1; Apc->SystemArgument2 = SystemArgument2; @@ -411,9 +411,9 @@ KeInsertQueueApc(PKAPC Apc, } /*++ - * KeRemoveQueueApc + * KeRemoveQueueApc * - * The KeRemoveQueueApc routine removes a given APC object from the system + * The KeRemoveQueueApc routine removes a given APC object from the system * APC queue. * * Params: @@ -431,7 +431,7 @@ KeInsertQueueApc(PKAPC Apc, * Callers of KeLeaveCriticalRegion can be running at any IRQL. * *--*/ -BOOLEAN +BOOLEAN STDCALL KeRemoveQueueApc(PKAPC Apc) { @@ -440,39 +440,39 @@ KeRemoveQueueApc(PKAPC Apc) ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL); DPRINT("KeRemoveQueueApc called for APC: %x \n", Apc); - + OldIrql = KeAcquireDispatcherDatabaseLock(); KeAcquireSpinLock(&Thread->ApcQueueLock, &OldIrql); - + /* Check if it's inserted */ if (Apc->Inserted) { - + /* Remove it from the Queue*/ RemoveEntryList(&Apc->ApcListEntry); Apc->Inserted = FALSE; - + /* If the Queue is completely empty, then no more APCs are pending */ if (IsListEmpty(&Thread->ApcStatePointer[(int)Apc->ApcStateIndex]->ApcListHead[(int)Apc->ApcMode])) { - + /* Set the correct State based on the Apc Mode */ if (Apc->ApcMode == KernelMode) { - + Thread->ApcStatePointer[(int)Apc->ApcStateIndex]->KernelApcPending = FALSE; - + } else { - + Thread->ApcStatePointer[(int)Apc->ApcStateIndex]->UserApcPending = FALSE; } } - + } else { - + /* It's not inserted, fail */ KeReleaseSpinLock(&Thread->ApcQueueLock, OldIrql); KeReleaseDispatcherDatabaseLock(OldIrql); return(FALSE); } - + /* Restore IRQL and Return */ KeReleaseSpinLock(&Thread->ApcQueueLock, OldIrql); KeReleaseDispatcherDatabaseLock(OldIrql); @@ -480,12 +480,12 @@ KeRemoveQueueApc(PKAPC Apc) } /*++ - * KiDeliverApc + * KiDeliverApc * @implemented @NT4 - * + * * The KiDeliverApc routine is called from IRQL switching code if the * thread is returning from an IRQL >= APC_LEVEL and Kernel-Mode APCs are - * pending. + * pending. * * Params: * DeliveryMode - Specifies the current processor mode. @@ -505,7 +505,7 @@ KeRemoveQueueApc(PKAPC Apc) * Upon entry, this routine executes at APC_LEVEL. * *--*/ -VOID +VOID STDCALL KiDeliverApc(KPROCESSOR_MODE DeliveryMode, PVOID Reserved, @@ -520,7 +520,7 @@ KiDeliverApc(KPROCESSOR_MODE DeliveryMode, PKNORMAL_ROUTINE NormalRoutine; PVOID SystemArgument1; PVOID SystemArgument2; - + ASSERT_IRQL_EQUAL(APC_LEVEL); /* Lock the APC Queue and Raise IRQL to Synch */ @@ -528,31 +528,31 @@ KiDeliverApc(KPROCESSOR_MODE DeliveryMode, /* Clear APC Pending */ Thread->ApcState.KernelApcPending = FALSE; - + /* Do the Kernel APCs first */ while (!IsListEmpty(&Thread->ApcState.ApcListHead[KernelMode])) { - + /* Get the next Entry */ ApcListEntry = Thread->ApcState.ApcListHead[KernelMode].Flink; Apc = CONTAINING_RECORD(ApcListEntry, KAPC, ApcListEntry); - + /* Save Parameters so that it's safe to free the Object in Kernel Routine*/ NormalRoutine = Apc->NormalRoutine; KernelRoutine = Apc->KernelRoutine; NormalContext = Apc->NormalContext; SystemArgument1 = Apc->SystemArgument1; SystemArgument2 = Apc->SystemArgument2; - + /* Special APC */ if (NormalRoutine == NULL) { - + /* Remove the APC from the list */ Apc->Inserted = FALSE; RemoveEntryList(ApcListEntry); - + /* Go back to APC_LEVEL */ KeReleaseSpinLock(&Thread->ApcQueueLock, OldIrql); - + /* Call the Special APC */ DPRINT("Delivering a Special APC: %x\n", Apc); KernelRoutine(Apc, @@ -563,15 +563,15 @@ KiDeliverApc(KPROCESSOR_MODE DeliveryMode, /* Raise IRQL and Lock again */ KeAcquireSpinLock(&Thread->ApcQueueLock, &OldIrql); - + } else { - + /* Normal Kernel APC */ if (Thread->ApcState.KernelApcInProgress || Thread->KernelApcDisable) { - + /* * DeliveryMode must be KernelMode in this case, since one may not - * return to umode while being inside a critical section or while + * return to umode while being inside a critical section or while * a regular kmode apc is running (the latter should be impossible btw). * -Gunnar */ @@ -580,14 +580,14 @@ KiDeliverApc(KPROCESSOR_MODE DeliveryMode, KeReleaseSpinLock(&Thread->ApcQueueLock, OldIrql); return; } - + /* Dequeue the APC */ RemoveEntryList(ApcListEntry); Apc->Inserted = FALSE; - + /* Go back to APC_LEVEL */ KeReleaseSpinLock(&Thread->ApcQueueLock, OldIrql); - + /* Call the Kernel APC */ DPRINT("Delivering a Normal APC: %x\n", Apc); KernelRoutine(Apc, @@ -595,14 +595,14 @@ KiDeliverApc(KPROCESSOR_MODE DeliveryMode, &NormalContext, &SystemArgument1, &SystemArgument2); - + /* If There still is a Normal Routine, then we need to call this at PASSIVE_LEVEL */ if (NormalRoutine != NULL) { - + /* At Passive Level, this APC can be prempted by a Special APC */ Thread->ApcState.KernelApcInProgress = TRUE; KeLowerIrql(PASSIVE_LEVEL); - + /* Call and Raise IRQ back to APC_LEVEL */ DPRINT("Calling the Normal Routine for a Normal APC: %x\n", Apc); NormalRoutine(&NormalContext, &SystemArgument1, &SystemArgument2); @@ -614,29 +614,29 @@ KiDeliverApc(KPROCESSOR_MODE DeliveryMode, Thread->ApcState.KernelApcInProgress = FALSE; } } - + /* Now we do the User APCs */ if ((!IsListEmpty(&Thread->ApcState.ApcListHead[UserMode])) && (DeliveryMode == UserMode) && (Thread->ApcState.UserApcPending == TRUE)) { - + /* It's not pending anymore */ Thread->ApcState.UserApcPending = FALSE; /* Get the APC Object */ ApcListEntry = Thread->ApcState.ApcListHead[UserMode].Flink; Apc = CONTAINING_RECORD(ApcListEntry, KAPC, ApcListEntry); - + /* Save Parameters so that it's safe to free the Object in Kernel Routine*/ NormalRoutine = Apc->NormalRoutine; KernelRoutine = Apc->KernelRoutine; NormalContext = Apc->NormalContext; SystemArgument1 = Apc->SystemArgument1; - SystemArgument2 = Apc->SystemArgument2; - + SystemArgument2 = Apc->SystemArgument2; + /* Remove the APC from Queue, restore IRQL and call the APC */ RemoveEntryList(ApcListEntry); Apc->Inserted = FALSE; - + KeReleaseSpinLock(&Thread->ApcQueueLock, OldIrql); DPRINT("Calling the Kernel Routine for for a User APC: %x\n", Apc); KernelRoutine(Apc, @@ -646,30 +646,30 @@ KiDeliverApc(KPROCESSOR_MODE DeliveryMode, &SystemArgument2); if (NormalRoutine == NULL) { - + /* Check if more User APCs are Pending */ KeTestAlertThread(UserMode); - + } else { - + /* Set up the Trap Frame and prepare for Execution in NTDLL.DLL */ DPRINT("Delivering a User APC: %x\n", Apc); - KiInitializeUserApc(Reserved, + KiInitializeUserApc(Reserved, TrapFrame, NormalRoutine, NormalContext, SystemArgument1, SystemArgument2); } - + } else { - + /* Go back to APC_LEVEL */ KeReleaseSpinLock(&Thread->ApcQueueLock, OldIrql); } } -VOID +VOID STDCALL KiFreeApcRoutine(PKAPC Apc, PKNORMAL_ROUTINE* NormalRoutine, @@ -682,8 +682,8 @@ KiFreeApcRoutine(PKAPC Apc, } /*++ - * KiInitializeUserApc - * + * KiInitializeUserApc + * * Prepares the Context for a User-Mode APC called through NTDLL.DLL * * Params: @@ -712,13 +712,13 @@ KiInitializeUserApc(IN PVOID Reserved, IN PKNORMAL_ROUTINE NormalRoutine, IN PVOID NormalContext, IN PVOID SystemArgument1, - IN PVOID SystemArgument2) + IN PVOID SystemArgument2) { PCONTEXT Context; PULONG Esp; DPRINT("KiInitializeUserApc(TrapFrame %x/%x)\n", TrapFrame, KeGetCurrentThread()->TrapFrame); - + /* * Save the thread's current context (in other words the registers * that will be restored when it returns to user mode) so the @@ -743,7 +743,7 @@ KiInitializeUserApc(IN PVOID Reserved, Context->EFlags = TrapFrame->Eflags; Context->Esp = TrapFrame->Esp; Context->SegSs = TrapFrame->Ss; - + /* * Setup the trap frame so the thread will start executing at the * APC Dispatcher when it returns to user-mode @@ -761,9 +761,9 @@ KiInitializeUserApc(IN PVOID Reserved, } /*++ - * KeAreApcsDisabled + * KeAreApcsDisabled * @implemented NT4 - * + * * Prepares the Context for a User-Mode APC called through NTDLL.DLL * * Params: @@ -774,10 +774,10 @@ KiInitializeUserApc(IN PVOID Reserved, * or a guarded region, and FALSE otherwise. * * Remarks: - * A thread running at IRQL = PASSIVE_LEVEL can use KeAreApcsDisabled to - * determine if normal kernel APCs are disabled. A thread that is inside a - * critical region has both user APCs and normal kernel APCs disabled, but - * not special kernel APCs. A thread that is inside a guarded region has + * A thread running at IRQL = PASSIVE_LEVEL can use KeAreApcsDisabled to + * determine if normal kernel APCs are disabled. A thread that is inside a + * critical region has both user APCs and normal kernel APCs disabled, but + * not special kernel APCs. A thread that is inside a guarded region has * all APCs disabled, including special kernel APCs. * * Callers of this routine must be running at IRQL <= APC_LEVEL. @@ -792,10 +792,10 @@ KeAreApcsDisabled(VOID) } /*++ - * NtQueueApcThread + * NtQueueApcThread * NT4 - * - * This routine is used to queue an APC from user-mode for the specified + * + * This routine is used to queue an APC from user-mode for the specified * thread. * * Params: @@ -812,11 +812,11 @@ KeAreApcsDisabled(VOID) * STATUS_SUCCESS or failure cute from associated calls. * * Remarks: - * The thread must enter an alertable wait before the APC will be + * The thread must enter an alertable wait before the APC will be * delivered. * *--*/ -NTSTATUS +NTSTATUS STDCALL NtQueueApcThread(HANDLE ThreadHandle, PKNORMAL_ROUTINE ApcRoutine, @@ -836,28 +836,28 @@ NtQueueApcThread(HANDLE ThreadHandle, PreviousMode, (PVOID)&Thread, NULL); - + /* Fail if the Handle is invalid for some reason */ if (!NT_SUCCESS(Status)) { - + return(Status); } - + /* If this is a Kernel or System Thread, then fail */ if (Thread->Tcb.Teb == NULL) { - + ObDereferenceObject(Thread); return STATUS_INVALID_HANDLE; } - + /* Allocate an APC */ Apc = ExAllocatePoolWithTag(NonPagedPool, sizeof(KAPC), TAG('P', 's', 'a', 'p')); if (Apc == NULL) { - + ObDereferenceObject(Thread); return(STATUS_NO_MEMORY); } - + /* Initialize and Queue a user mode apc (always!) */ KeInitializeApc(Apc, &Thread->Tcb, @@ -867,34 +867,34 @@ NtQueueApcThread(HANDLE ThreadHandle, ApcRoutine, UserMode, NormalContext); - + if (!KeInsertQueueApc(Apc, SystemArgument1, SystemArgument2, IO_NO_INCREMENT)) { - + Status = STATUS_UNSUCCESSFUL; - + } else { - + Status = STATUS_SUCCESS; } - + /* Dereference Thread and Return */ ObDereferenceObject(Thread); return Status; } -static inline -VOID RepairList(PLIST_ENTRY Original, +static inline +VOID RepairList(PLIST_ENTRY Original, PLIST_ENTRY Copy, KPROCESSOR_MODE Mode) { /* Copy Source to Desination */ if (IsListEmpty(&Original[(int)Mode])) { - + InitializeListHead(&Copy[(int)Mode]); - + } else { - - Copy[(int)Mode].Flink = Original[(int)Mode].Flink; + + Copy[(int)Mode].Flink = Original[(int)Mode].Flink; Copy[(int)Mode].Blink = Original[(int)Mode].Blink; Original[(int)Mode].Flink->Blink = &Copy[(int)Mode]; Original[(int)Mode].Blink->Flink = &Copy[(int)Mode]; @@ -908,7 +908,7 @@ KiMoveApcState(PKAPC_STATE OldState, { /* Restore backup of Original Environment */ *NewState = *OldState; - + /* Repair Lists */ RepairList(NewState->ApcListHead, OldState->ApcListHead, KernelMode); RepairList(NewState->ApcListHead, OldState->ApcListHead, UserMode); diff --git a/reactos/ntoskrnl/ke/bug.c b/reactos/ntoskrnl/ke/bug.c index a22b8a04f0d..bfff3a6eb6e 100644 --- a/reactos/ntoskrnl/ke/bug.c +++ b/reactos/ntoskrnl/ke/bug.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/bug.c * PURPOSE: Graceful system shutdown if a bug is detected - * + * * PROGRAMMERS: Alex Ionescu - Rewrote Bugcheck Routines and implemented Reason Callbacks. * David Welch (welch@cwcom.net) * Phillip Susi @@ -43,24 +43,24 @@ KiInitializeBugCheck(VOID) ResourceInfo.Type = 11; ResourceInfo.Name = 1; ResourceInfo.Language = 9; - + /* Do the lookup. */ Status = LdrFindResource_U((PVOID)KERNEL_BASE, &ResourceInfo, RESOURCE_DATA_LEVEL, &ResourceDataEntry); - + /* Make sure it worked */ if (NT_SUCCESS(Status)) { - + DPRINT1("Found Bugcheck Resource Data!\n"); - + /* Now actually get a pointer to it */ Status = LdrAccessResource((PVOID)KERNEL_BASE, ResourceDataEntry, (PVOID*)&BugCheckData, NULL); - + /* Make sure it worked */ if (NT_SUCCESS(Status)) { @@ -73,23 +73,23 @@ KiInitializeBugCheck(VOID) /* * @implemented */ -BOOLEAN +BOOLEAN STDCALL KeDeregisterBugCheckCallback(PKBUGCHECK_CALLBACK_RECORD CallbackRecord) { KIRQL OldIrql; BOOLEAN Status = FALSE; - + /* Raise IRQL to High */ KeRaiseIrql(HIGH_LEVEL, &OldIrql); - + /* Check the Current State */ if (CallbackRecord->State == BufferInserted) { /* Reset state and remove from list */ CallbackRecord->State = BufferEmpty; RemoveEntryList(&CallbackRecord->Entry); - + Status = TRUE; } @@ -107,17 +107,17 @@ KeDeregisterBugCheckReasonCallback(IN PKBUGCHECK_REASON_CALLBACK_RECORD Callback { KIRQL OldIrql; BOOLEAN Status = FALSE; - + /* Raise IRQL to High */ KeRaiseIrql(HIGH_LEVEL, &OldIrql); - + /* Check the Current State */ if (CallbackRecord->State == BufferInserted) { /* Reset state and remove from list */ CallbackRecord->State = BufferEmpty; RemoveEntryList(&CallbackRecord->Entry); - + Status = TRUE; } @@ -129,7 +129,7 @@ KeDeregisterBugCheckReasonCallback(IN PKBUGCHECK_REASON_CALLBACK_RECORD Callback /* * @implemented */ -BOOLEAN +BOOLEAN STDCALL KeRegisterBugCheckCallback(PKBUGCHECK_CALLBACK_RECORD CallbackRecord, PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine, @@ -139,13 +139,13 @@ KeRegisterBugCheckCallback(PKBUGCHECK_CALLBACK_RECORD CallbackRecord, { KIRQL OldIrql; BOOLEAN Status = FALSE; - + /* Raise IRQL to High */ KeRaiseIrql(HIGH_LEVEL, &OldIrql); - + /* Check the Current State first so we don't double-register */ if (CallbackRecord->State == BufferEmpty) { - + /* Set the Callback Settings and insert into the list */ CallbackRecord->Length = Length; CallbackRecord->Buffer = Buffer; @@ -153,7 +153,7 @@ KeRegisterBugCheckCallback(PKBUGCHECK_CALLBACK_RECORD CallbackRecord, CallbackRecord->CallbackRoutine = CallbackRoutine; CallbackRecord->State = BufferInserted; InsertTailList(&BugcheckCallbackListHead, &CallbackRecord->Entry); - + Status = TRUE; } @@ -174,20 +174,20 @@ KeRegisterBugCheckReasonCallback(IN PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRe { KIRQL OldIrql; BOOLEAN Status = FALSE; - + /* Raise IRQL to High */ KeRaiseIrql(HIGH_LEVEL, &OldIrql); - + /* Check the Current State first so we don't double-register */ if (CallbackRecord->State == BufferEmpty) { - + /* Set the Callback Settings and insert into the list */ CallbackRecord->Component = Component; CallbackRecord->CallbackRoutine = CallbackRoutine; CallbackRecord->State = BufferInserted; CallbackRecord->Reason = Reason; InsertTailList(&BugcheckReasonCallbackListHead, &CallbackRecord->Entry); - + Status = TRUE; } @@ -204,37 +204,37 @@ KeGetBugMessageText(ULONG BugCheckCode, PANSI_STRING OutputString) ULONG IdOffset; ULONG_PTR MessageEntry; PCHAR BugCode; - + /* Find the message. This code is based on RtlFindMesssage -- Alex */ for (i = 0; i < KiBugCodeMessages->NumberOfBlocks; i++) { - + /* Check if the ID Matches */ if ((BugCheckCode >= KiBugCodeMessages->Blocks[i].LowId) && (BugCheckCode <= KiBugCodeMessages->Blocks[i].HighId)) { - + /* Get Offset to Entry */ MessageEntry = (ULONG_PTR)KiBugCodeMessages + KiBugCodeMessages->Blocks[i].OffsetToEntries; IdOffset = BugCheckCode - KiBugCodeMessages->Blocks[i].LowId; - + /* Get offset to ID */ for (i = 0; i < IdOffset; i++) { - - /* Advance in the Entries */ + + /* Advance in the Entries */ MessageEntry += ((PRTL_MESSAGE_RESOURCE_ENTRY)MessageEntry)->Length; } - + /* Get the final Code */ BugCode = ((PRTL_MESSAGE_RESOURCE_ENTRY)MessageEntry)->Text; - + /* Return it in the OutputString */ if (OutputString) { - + OutputString->Buffer = BugCode; OutputString->Length = strlen(BugCode) + 1; OutputString->MaximumLength = strlen(BugCode) + 1; - + } else { - + /* Direct Output to Screen */ DbgPrint("%s\n", BugCode); break; @@ -250,39 +250,39 @@ KiDoBugCheckCallbacks(VOID) PKBUGCHECK_CALLBACK_RECORD CurrentRecord; PLIST_ENTRY ListHead; PLIST_ENTRY NextEntry; - + /* FIXME: Check Checksum and add support for WithReason Callbacks */ - + /* First make sure that the list is Initialized... it might not be */ ListHead = &BugcheckCallbackListHead; if (ListHead->Flink && ListHead->Blink) { - + /* Loop the list */ NextEntry = ListHead->Flink; while (NextEntry != ListHead) { - + /* Get the Callback Record */ - CurrentRecord = CONTAINING_RECORD(NextEntry, + CurrentRecord = CONTAINING_RECORD(NextEntry, KBUGCHECK_CALLBACK_RECORD, Entry); - + /* Make sure it's inserted */ if (CurrentRecord->State == BufferInserted) { - + /* Call the routine */ CurrentRecord->State = BufferStarted; - (CurrentRecord->CallbackRoutine)(CurrentRecord->Buffer, + (CurrentRecord->CallbackRoutine)(CurrentRecord->Buffer, CurrentRecord->Length); CurrentRecord->State = BufferFinished; } - + /* Move to next Entry */ NextEntry = NextEntry->Flink; } } } -VOID +VOID STDCALL KeBugCheckWithTf(ULONG BugCheckCode, ULONG BugCheckParameter1, @@ -297,43 +297,43 @@ KeBugCheckWithTf(ULONG BugCheckCode, PLIST_ENTRY CurrentEntry; MODULE_TEXT_SECTION* CurrentSection = NULL; extern LIST_ENTRY ModuleTextListHead; - + /* Make sure we're switching back to the blue screen and print messages on it */ HalReleaseDisplayOwnership(); if (KdpDebugMode.Gdb) KdpDebugMode.Screen = TRUE; - + /* Try to find out who did this. For this, we need a Trap Frame. * Note: Some special BSODs pass the Frame/EIP as a Param. MSDN has the - * info so it eventually needs to be supported. + * info so it eventually needs to be supported. */ if (Tf) { - + /* For now, get Address from EIP */ Address = (PVOID)Tf->Eip; - + /* Try to get information on the module */ CurrentEntry = ModuleTextListHead.Flink; while (CurrentEntry != &ModuleTextListHead && CurrentEntry != NULL) { - + /* Get the current Section */ - CurrentSection = CONTAINING_RECORD(CurrentEntry, - MODULE_TEXT_SECTION, + CurrentSection = CONTAINING_RECORD(CurrentEntry, + MODULE_TEXT_SECTION, ListEntry); /* Check if this is the right one */ if ((Address != NULL && (Address >= (PVOID)CurrentSection->Base && Address < (PVOID)(CurrentSection->Base + CurrentSection->Length)))) { - /* We got it */ + /* We got it */ GotExtendedCrashInfo = TRUE; break; } - + /* Loop again */ CurrentEntry = CurrentEntry->Flink; } } - + /* Raise IRQL to HIGH_LEVEL */ Ke386DisableInterrupts(); KeRaiseIrql(HIGH_LEVEL, &OldIrql); @@ -341,16 +341,16 @@ KeBugCheckWithTf(ULONG BugCheckCode, /* Unload the Kernel Adress Space if we own it */ if (MmGetKernelAddressSpace()->Lock.Owner == KeGetCurrentThread()) MmUnlockAddressSpace(MmGetKernelAddressSpace()); - + /* FIXMEs: Use inbv to clear, fill and write to screen. */ - + /* Show the STOP Message */ DbgPrint("A problem has been detected and ReactOS has been shut down to prevent " "damage to your computer.\n\n"); - + /* Show the module name of who caused this */ if (GotExtendedCrashInfo) { - + DbgPrint("The problem seems to be caused by the following file: %S\n\n", CurrentSection->Name); } @@ -367,23 +367,23 @@ KeBugCheckWithTf(ULONG BugCheckCode, /* Show the module name and more data of who caused this */ if (GotExtendedCrashInfo) { - - DbgPrint("*** %S - Address 0x%p base at 0x%p, DateStamp 0x%x\n\n", + + DbgPrint("*** %S - Address 0x%p base at 0x%p, DateStamp 0x%x\n\n", CurrentSection->Name, Address, CurrentSection->Base, 0); } - + /* There can only be one Bugcheck per Bootup */ if (!InterlockedDecrement((PLONG)&KeBugCheckCount)) { #ifdef CONFIG_SMP ULONG i; /* Freeze the other CPUs */ - for (i = 0; i < KeNumberProcessors; i++) { + for (i = 0; i < KeNumberProcessors; i++) { if (i != KeGetCurrentProcessorNumber()) { - + /* Send the IPI and give them one second to catch up */ KiIpiSendRequest(1 << i, IPI_REQUEST_FREEZE); KeStallExecutionProcessor(1000000); @@ -393,12 +393,12 @@ KeBugCheckWithTf(ULONG BugCheckCode, /* Check if we got a Trap Frame */ if (Tf) { - + /* Dump it */ KiDumpTrapFrame(Tf, BugCheckParameter1, BugCheckParameter2); - + } else { - + /* We can only dump the frames */ #if defined(__GNUC__) KeDumpStackFrames((PULONG)__builtin_frame_address(0)); @@ -410,16 +410,16 @@ KeBugCheckWithTf(ULONG BugCheckCode, #error Unknown compiler for inline assembler #endif } - + /* Call the Callbacks */; KiDoBugCheckCallbacks(); /* Dump the BSOD to the Paging File */ - MmDumpToPagingFile(BugCheckCode, - BugCheckParameter1, - BugCheckParameter2, + MmDumpToPagingFile(BugCheckCode, + BugCheckParameter1, + BugCheckParameter2, BugCheckParameter3, - BugCheckParameter4, + BugCheckParameter4, Tf); /* Wake up the Debugger */ @@ -437,14 +437,14 @@ KeBugCheckWithTf(ULONG BugCheckCode, /* * @implemented * - * FUNCTION: Brings the system down in a controlled manner when an + * FUNCTION: Brings the system down in a controlled manner when an * inconsistency that might otherwise cause corruption has been detected * ARGUMENTS: * BugCheckCode = Specifies the reason for the bug check * BugCheckParameter[1-4] = Additional information about bug * RETURNS: Doesn't */ -VOID +VOID STDCALL KeBugCheckEx(ULONG BugCheckCode, ULONG BugCheckParameter1, @@ -453,18 +453,18 @@ KeBugCheckEx(ULONG BugCheckCode, ULONG BugCheckParameter4) { /* Call the Trap Frame version without a Trap Frame */ - KeBugCheckWithTf(BugCheckCode, - BugCheckParameter1, + KeBugCheckWithTf(BugCheckCode, + BugCheckParameter1, BugCheckParameter2, - BugCheckParameter3, - BugCheckParameter4, + BugCheckParameter3, + BugCheckParameter4, NULL); } /* * @implemented * - * FUNCTION: Brings the system down in a controlled manner when an + * FUNCTION: Brings the system down in a controlled manner when an * inconsistency that might otherwise cause corruption has been detected * ARGUMENTS: * BugCheckCode = Specifies the reason for the bug check diff --git a/reactos/ntoskrnl/ke/catch.c b/reactos/ntoskrnl/ke/catch.c index ac3a9df3681..c6df3c12d68 100644 --- a/reactos/ntoskrnl/ke/catch.c +++ b/reactos/ntoskrnl/ke/catch.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/catch.c * PURPOSE: Exception handling - * + * * PROGRAMMERS: Anich Gregor * David Welch (welch@mcmail.com) * Casper S. Hornstrup (chorns@users.sourceforge.net) @@ -57,18 +57,18 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord, /* Increase number of Exception Dispatches */ KeGetCurrentPrcb()->KeExceptionDispatchCount++; - if (!Context) + if (!Context) { /* Assume Full context */ TContext.ContextFlags = CONTEXT_FULL; - + /* Check the mode */ - if (PreviousMode == UserMode) + if (PreviousMode == UserMode) { /* Add Debugger Registers if this is User Mode */ TContext.ContextFlags = TContext.ContextFlags | CONTEXT_DEBUGGER; } - + /* Convert the Trapframe into a Context */ KeTrapFrameToContext(Tf, &TContext); @@ -77,24 +77,24 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord, } /* Break into Debugger */ - Action = KdpEnterDebuggerException(ExceptionRecord, - PreviousMode, - Context, - Tf, + Action = KdpEnterDebuggerException(ExceptionRecord, + PreviousMode, + Context, + Tf, TRUE, TRUE); /* If the debugger said continue, then continue */ if (Action == kdContinue) return; - + /* If the Debugger couldn't handle it... */ - if (Action != kdDoNotHandleException) - { + if (Action != kdDoNotHandleException) + { /* See what kind of Exception this is */ - if (PreviousMode == UserMode) - { + if (PreviousMode == UserMode) + { /* User mode exception, search the frames if we have to */ - if (SearchFrames) + if (SearchFrames) { PULONG Stack; ULONG CDest; @@ -103,10 +103,10 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord, NTSTATUS StatusOfCopy; /* Enter Debugger if available */ - Action = KdpEnterDebuggerException(ExceptionRecord, + Action = KdpEnterDebuggerException(ExceptionRecord, PreviousMode, - Context, - Tf, + Context, + Tf, TRUE, FALSE); @@ -116,7 +116,7 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord, /* FIXME: Forward exception to user mode debugger */ /* FIXME: Check user mode stack for enough space */ - + /* Let usermode try and handle the exception. Setup Stack */ Stack = (PULONG)temp_space; CDest = 3 + (ROUND_UP(sizeof(EXCEPTION_RECORD), 4) / 4); @@ -128,20 +128,20 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord, Stack[2] = (ULONG)&pNewUserStack[CDest]; memcpy(&Stack[3], ExceptionRecord, sizeof(EXCEPTION_RECORD)); memcpy(&Stack[CDest], Context, sizeof(CONTEXT)); - + /* Copy Stack */ StatusOfCopy = MmCopyToCaller(pNewUserStack, temp_space, (12 + sizeof(EXCEPTION_RECORD) + sizeof(CONTEXT))); - + /* Check for success */ - if (NT_SUCCESS(StatusOfCopy)) + if (NT_SUCCESS(StatusOfCopy)) { /* Set new Stack Pointer */ Tf->Esp = (ULONG)pNewUserStack; - } - else - { + } + else + { /* * Now it really hit the ventilation device. Sorry, * can do nothing but kill the sucker. @@ -159,10 +159,10 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord, /* FIXME: Forward the exception to the process exception port */ /* Enter KDB if available */ - Action = KdpEnterDebuggerException(ExceptionRecord, + Action = KdpEnterDebuggerException(ExceptionRecord, PreviousMode, - Context, - Tf, + Context, + Tf, FALSE, FALSE); @@ -172,16 +172,16 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord, /* Terminate the offending thread */ DPRINT1("Unhandled UserMode exception, terminating thread\n"); ZwTerminateThread(NtCurrentThread(), ExceptionRecord->ExceptionCode); - } - else + } + else { - /* This is Kernel Mode */ + /* This is Kernel Mode */ /* Enter KDB if available */ - Action = KdpEnterDebuggerException(ExceptionRecord, + Action = KdpEnterDebuggerException(ExceptionRecord, PreviousMode, - Context, - Tf, + Context, + Tf, TRUE, FALSE); @@ -191,26 +191,26 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord, /* Dispatch the Exception */ Value = RtlpDispatchException (ExceptionRecord, Context); DPRINT("RtlpDispatchException() returned with 0x%X\n", Value); - + /* If RtlpDispatchException() did not handle the exception then bugcheck */ if (Value != ExceptionContinueExecution || - 0 != (ExceptionRecord->ExceptionFlags & EXCEPTION_NONCONTINUABLE)) + 0 != (ExceptionRecord->ExceptionFlags & EXCEPTION_NONCONTINUABLE)) { DPRINT("ExceptionRecord->ExceptionAddress = 0x%x\n", ExceptionRecord->ExceptionAddress); /* Enter KDB if available */ - Action = KdpEnterDebuggerException(ExceptionRecord, + Action = KdpEnterDebuggerException(ExceptionRecord, PreviousMode, - Context, - Tf, + Context, + Tf, FALSE, FALSE); /* Exit if we're continuing */ if (Action == kdContinue) return; - KEBUGCHECKWITHTF(KMODE_EXCEPTION_NOT_HANDLED, - ExceptionRecord->ExceptionCode, + KEBUGCHECKWITHTF(KMODE_EXCEPTION_NOT_HANDLED, + ExceptionRecord->ExceptionCode, (ULONG)ExceptionRecord->ExceptionAddress, ExceptionRecord->ExceptionInformation[0], ExceptionRecord->ExceptionInformation[1], diff --git a/reactos/ntoskrnl/ke/clock.c b/reactos/ntoskrnl/ke/clock.c index 4a03c0ed363..e22d81bfb0f 100644 --- a/reactos/ntoskrnl/ke/clock.c +++ b/reactos/ntoskrnl/ke/clock.c @@ -3,11 +3,11 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/clock.c * PURPOSE: Handle System Clock - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) - Created * David Welch & Phillip Susi - Implementation (?) */ - + /* NOTES ******************************************************************/ /* * System time units are 100-nanosecond intervals @@ -45,9 +45,9 @@ extern LIST_ENTRY KiTimerListHead; /* * The increment in the system clock every timer tick (in system time units) - * - * = (1/18.2)*10^9 - * + * + * = (1/18.2)*10^9 + * * RJJ was 54945055 */ #define CLOCK_INCREMENT (100000) @@ -80,7 +80,7 @@ KiInitializeSystemClock(VOID) DPRINT1("KiInitializeSystemClock()\n"); InitializeListHead(&KiTimerListHead); KeInitializeDpc(&KiExpireTimerDpc, (PKDEFERRED_ROUTINE)KiExpireTimers, 0); - + /* Calculate the starting time for the system clock */ HalQueryRealTimeClock(&TimeFields); RtlTimeFieldsToTime(&TimeFields, &SystemBootTime); @@ -145,7 +145,7 @@ ULONG STDCALL KeQueryTimeIncrement(VOID) /* - * FUNCTION: Gets the increment (in 100-nanosecond units) that is added to + * FUNCTION: Gets the increment (in 100-nanosecond units) that is added to * the system clock every time the clock interrupts * RETURNS: The increment */ @@ -156,7 +156,7 @@ KeQueryTimeIncrement(VOID) /* * @implemented */ -VOID +VOID STDCALL KeQueryTickCount(PLARGE_INTEGER TickCount) /* @@ -187,7 +187,7 @@ KeQuerySystemTime(PLARGE_INTEGER CurrentTime) } while (CurrentTime->u.HighPart != SharedUserData->SystemTime.High2Time); } -ULONGLONG +ULONGLONG STDCALL KeQueryInterruptTime(VOID) { @@ -260,7 +260,7 @@ KeUpdateRunTime( CurrentThread = Prcb->CurrentThread; CurrentProcess = CurrentThread->ApcState.Process; - /* + /* * Cs bit 0 is always set for user mode if we are in protected mode. * V86 mode is counted as user time. */ @@ -325,7 +325,7 @@ KeUpdateRunTime( * * @implemented */ -VOID +VOID STDCALL KeUpdateSystemTime( IN PKTRAP_FRAME TrapFrame, @@ -340,11 +340,11 @@ KeUpdateSystemTime( ASSERT(KeGetCurrentIrql() == PROFILE_LEVEL); KiRawTicks++; - + if (KiClockSetupComplete == FALSE) return; /* - * Increment the number of timers ticks + * Increment the number of timers ticks */ KeTickCount++; SharedUserData->TickCountLowDeprecated++; @@ -382,12 +382,12 @@ STDCALL NtGetTickCount(VOID) { LARGE_INTEGER TickCount; - + KeQueryTickCount(&TickCount); return TickCount.u.LowPart; } -NTSTATUS +NTSTATUS STDCALL NtQueryTimerResolution(OUT PULONG MinimumResolution, OUT PULONG MaximumResolution, @@ -397,7 +397,7 @@ NtQueryTimerResolution(OUT PULONG MinimumResolution, return STATUS_NOT_IMPLEMENTED; } -NTSTATUS +NTSTATUS STDCALL NtSetTimerResolution(IN ULONG DesiredResolution, IN BOOLEAN SetResolution, diff --git a/reactos/ntoskrnl/ke/device.c b/reactos/ntoskrnl/ke/device.c index 8fd2915adf5..123965e9caa 100644 --- a/reactos/ntoskrnl/ke/device.c +++ b/reactos/ntoskrnl/ke/device.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/device.c * PURPOSE: Kernel Device/Settings Functions - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) */ @@ -58,38 +58,38 @@ KeFlushEntireTb( KIRQL OldIrql; PKPROCESS Process = NULL; PKPRCB Prcb = NULL; - + /* Raise the IRQL for the TB Flush */ OldIrql = KeRaiseIrqlToSynchLevel(); - + /* All CPUs need to have the TB flushed. */ if (CurrentCpuOnly == FALSE) { Prcb = KeGetCurrentPrcb(); - + /* How many CPUs is our caller using? */ Process = Prcb->CurrentThread->ApcState.Process; - + /* More then one, so send an IPI */ if (Process->ActiveProcessors > 1) { /* Send IPI Packet */ } } - + /* Flush the TB for the Current CPU */ KeFlushCurrentTb(); - + /* Clean up */ if (CurrentCpuOnly == FALSE) { /* Did we send an IPI? If so, wait for completion */ if (Process->ActiveProcessors > 1) { do { } while (Prcb->TargetSet != 0); - } - } - + } + } + /* FIXME: According to MSKB, we should increment a counter? */ - - /* Return to Original IRQL */ + + /* Return to Original IRQL */ KeLowerIrql(OldIrql); } diff --git a/reactos/ntoskrnl/ke/dpc.c b/reactos/ntoskrnl/ke/dpc.c index bb9ae17a0d6..f71ad3ae624 100644 --- a/reactos/ntoskrnl/ke/dpc.c +++ b/reactos/ntoskrnl/ke/dpc.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/dpc.c * PURPOSE: Handle DPCs (Delayed Procedure Calls) - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) * Philip Susi (phreak@iag.net) * Eric Kohl (ekohl@abo.rhein-zeitung.de) @@ -35,7 +35,7 @@ INIT_FUNCTION KeInitDpc(PKPRCB Prcb) { InitializeListHead(&Prcb->DpcData[0].DpcListHead); -#if 0 +#if 0 /* * FIXME: * Prcb->DpcEvent is a NULL pointer. @@ -57,7 +57,7 @@ KeInitializeThreadedDpc(PKDPC Dpc, PKDEFERRED_ROUTINE DeferredRoutine, PVOID DeferredContext) /* - * FUNCTION: + * FUNCTION: * Initalizes a Threaded DPC and registers the DeferredRoutine for it. * ARGUMENTS: * Dpc = Pointer to a caller supplied DPC to be initialized. The caller must allocate this memory. @@ -78,7 +78,7 @@ KeInitializeThreadedDpc(PKDPC Dpc, /* * @implemented * - * FUNCTION: + * FUNCTION: * Initalizes a DPC and registers the DeferredRoutine for it. * ARGUMENTS: * Dpc = Pointer to a caller supplied DPC to be initialized. The caller must allocate this memory. @@ -104,17 +104,17 @@ KeInitializeDpc(PKDPC Dpc, /* * @implemented * - * FUNCTION: + * FUNCTION: * Queues a DPC for execution when the IRQL of a processor * drops below DISPATCH_LEVEL * ARGUMENTS: * Dpc = Pointed to a DPC Object Initalized by KeInitializeDpc. * SystemArgument1 = Driver Determined context data * SystemArgument2 = Driver Determined context data - * RETURNS: + * RETURNS: * TRUE if the DPC object wasn't already in the queue * FALSE otherwise - * NOTES: + * NOTES: * If there is currently a DPC active on the target processor, or a DPC * interrupt has already been requested on the target processor when a * DPC is queued, then no further action is necessary. The DPC will be @@ -155,7 +155,7 @@ KeInitializeDpc(PKDPC Dpc, * is greater that the target depth or the minimum DPC rate is less than the * target rate. */ -BOOLEAN +BOOLEAN STDCALL KeInsertQueueDpc(PKDPC Dpc, PVOID SystemArgument1, @@ -170,7 +170,7 @@ KeInsertQueueDpc(PKDPC Dpc, /* Check IRQL and Raise it to HIGH_LEVEL */ ASSERT(KeGetCurrentIrql()>=DISPATCH_LEVEL); KeRaiseIrql(HIGH_LEVEL, &OldIrql); - + /* Check if this is a Thread DPC, which we don't support (yet) */ if (Dpc->Type == ThreadedDpcObject) { return FALSE; @@ -180,17 +180,17 @@ KeInsertQueueDpc(PKDPC Dpc, #ifdef CONFIG_SMP /* Get the right PCR for this CPU */ if (Dpc->Number >= MAXIMUM_PROCESSORS) { - + ASSERT (Dpc->Number - MAXIMUM_PROCESSORS < KeNumberProcessors); Prcb = ((PKPCR)((ULONG_PTR)KPCR_BASE + ((Dpc->Number - MAXIMUM_PROCESSORS) * PAGE_SIZE)))->Prcb; - + } else { - + ASSERT (Dpc->Number < KeNumberProcessors); Prcb = KeGetCurrentPrcb(); Dpc->Number = KeGetCurrentProcessorNumber(); } - + KiAcquireSpinLock(&Prcb->DpcData[0].DpcLock); #else Prcb = ((PKPCR)KPCR_BASE)->Prcb; @@ -198,7 +198,7 @@ KeInsertQueueDpc(PKDPC Dpc, /* Get the DPC Data */ if (InterlockedCompareExchangeUL(&Dpc->DpcData, &Prcb->DpcData[0].DpcLock, 0)) { - + DPRINT("DPC Already Inserted"); #ifdef CONFIG_SMP KiReleaseSpinLock(&Prcb->DpcData[0].DpcLock); @@ -206,13 +206,13 @@ KeInsertQueueDpc(PKDPC Dpc, KeLowerIrql(OldIrql); return(FALSE); } - + /* Make sure the lists are free if the Queue is 0 */ if (Prcb->DpcData[0].DpcQueueDepth == 0) { - + ASSERT(IsListEmpty(&Prcb->DpcData[0].DpcListHead)); } else { - + ASSERT(!IsListEmpty(&Prcb->DpcData[0].DpcListHead)); } @@ -221,44 +221,44 @@ KeInsertQueueDpc(PKDPC Dpc, Dpc->SystemArgument2=SystemArgument2; Prcb->DpcData[0].DpcQueueDepth++; Prcb->DpcData[0].DpcCount++; - + /* Insert the DPC into the list. HighImportance DPCs go at the beginning */ if (Dpc->Importance == HighImportance) { - + InsertHeadList(&Prcb->DpcData[0].DpcListHead, &Dpc->DpcListEntry); - } else { - + } else { + InsertTailList(&Prcb->DpcData[0].DpcListHead, &Dpc->DpcListEntry); } DPRINT("New DPC Added. Dpc->DpcListEntry.Flink %x\n", Dpc->DpcListEntry.Flink); - + /* Make sure a DPC isn't executing already and respect rules outlined above. */ if ((!Prcb->DpcRoutineActive) && (!Prcb->DpcInterruptRequested)) { - -#ifdef CONFIG_SMP + +#ifdef CONFIG_SMP /* Check if this is the same CPU */ if (Prcb != KeGetCurrentPrcb()) { - + /* Send IPI if High Importance */ if ((Dpc->Importance == HighImportance) || (Prcb->DpcData[0].DpcQueueDepth >= Prcb->MaximumDpcQueueDepth)) { - + if (Dpc->Number >= MAXIMUM_PROCESSORS) { - + KiIpiSendRequest(1 << (Dpc->Number - MAXIMUM_PROCESSORS), IPI_REQUEST_DPC); } else { - + KiIpiSendRequest(1 << Dpc->Number, IPI_REQUEST_DPC); } } } else { - + /* Request an Interrupt only if the DPC isn't low priority */ - if ((Dpc->Importance != LowImportance) || + if ((Dpc->Importance != LowImportance) || (Prcb->DpcData[0].DpcQueueDepth >= Prcb->MaximumDpcQueueDepth) || (Prcb->DpcRequestRate < Prcb->MinimumDpcRate)) { - + /* Request Interrupt */ HalRequestSoftwareInterrupt(DISPATCH_LEVEL); Prcb->DpcInterruptRequested = TRUE; @@ -266,12 +266,12 @@ KeInsertQueueDpc(PKDPC Dpc, } #else DPRINT("Requesting Interrupt. Importance: %x. QueueDepth: %x. MaxQueue: %x . RequestRate: %x. MinRate:%x \n", Dpc->Importance, Prcb->DpcData[0].DpcQueueDepth, Prcb->MaximumDpcQueueDepth, Prcb->DpcRequestRate, Prcb->MinimumDpcRate); - + /* Request an Interrupt only if the DPC isn't low priority */ - if ((Dpc->Importance != LowImportance) || + if ((Dpc->Importance != LowImportance) || (Prcb->DpcData[0].DpcQueueDepth >= Prcb->MaximumDpcQueueDepth) || (Prcb->DpcRequestRate < Prcb->MinimumDpcRate)) { - + /* Request Interrupt */ DPRINT("Requesting Interrupt\n"); HalRequestSoftwareInterrupt(DISPATCH_LEVEL); @@ -282,7 +282,7 @@ KeInsertQueueDpc(PKDPC Dpc, #ifdef CONFIG_SMP KiReleaseSpinLock(&Prcb->DpcData[0].DpcLock); #endif - /* Lower IRQL */ + /* Lower IRQL */ KeLowerIrql(OldIrql); return(TRUE); } @@ -290,32 +290,32 @@ KeInsertQueueDpc(PKDPC Dpc, /* * @implemented * - * FUNCTION: + * FUNCTION: * Removes DPC object from the system dpc queue * ARGUMENTS: * Dpc = Pointer to DPC to remove from the queue. - * RETURNS: + * RETURNS: * TRUE if the DPC was in the queue * FALSE otherwise */ -BOOLEAN +BOOLEAN STDCALL KeRemoveQueueDpc(PKDPC Dpc) { BOOLEAN WasInQueue; KIRQL OldIrql; - + /* Raise IRQL */ DPRINT("Removing DPC: %x\n", Dpc); KeRaiseIrql(HIGH_LEVEL, &OldIrql); #ifdef CONFIG_SMP KiAcquireSpinLock(&((PKDPC_DATA)Dpc->DpcData)->DpcLock); #endif - + /* First make sure the DPC lock isn't being held */ WasInQueue = Dpc->DpcData ? TRUE : FALSE; - if (Dpc->DpcData) { - + if (Dpc->DpcData) { + /* Remove the DPC */ ((PKDPC_DATA)Dpc->DpcData)->DpcQueueDepth--; RemoveEntryList(&Dpc->DpcListEntry); @@ -337,7 +337,7 @@ VOID STDCALL KeFlushQueuedDpcs(VOID) /* - * FUNCTION: + * FUNCTION: * Called to Deliver DPCs if any are pending. * NOTES: * Called when deleting a Driver. @@ -350,7 +350,7 @@ KeFlushQueuedDpcs(VOID) /* * @implemented */ -BOOLEAN +BOOLEAN STDCALL KeIsExecutingDpc( VOID @@ -369,7 +369,7 @@ KeIsExecutingDpc( * * @implemented */ -VOID +VOID STDCALL KeSetImportanceDpc (IN PKDPC Dpc, IN KDPC_IMPORTANCE Importance) @@ -387,19 +387,19 @@ KeSetImportanceDpc (IN PKDPC Dpc, * Number = Processor number * RETURNS: None */ -VOID +VOID STDCALL KeSetTargetProcessorDpc(IN PKDPC Dpc, IN CCHAR Number) { /* Check how many CPUs are on the system */ if (Number >= MAXIMUM_PROCESSORS) { - + /* No CPU Number */ Dpc->Number = 0; - + } else { - + /* Set the Number Specified */ ASSERT(Number < KeNumberProcessors); Dpc->Number = Number + MAXIMUM_PROCESSORS; @@ -407,7 +407,7 @@ KeSetTargetProcessorDpc(IN PKDPC Dpc, } /* - * FUNCTION: + * FUNCTION: * Called when a quantum end occurs to check if priority should be changed * and wether a new thread should be dispatched. * NOTES: @@ -423,15 +423,15 @@ KiQuantumEnd(VOID) PKPROCESS Process; KPRIORITY OldPriority; KPRIORITY NewPriority; - + /* Lock dispatcher, get current thread */ Prcb = KeGetCurrentPrcb(); CurrentThread = KeGetCurrentThread(); OldIrql = KeRaiseIrqlToSynchLevel(); - + /* Get the Thread's Process */ Process = CurrentThread->ApcState.Process; - + /* Set DPC Event if requested */ if (Prcb->DpcSetEventRequest) { /* @@ -441,47 +441,47 @@ KiQuantumEnd(VOID) KEBUGCHECK(0); KeSetEvent(Prcb->DpcEvent, 0, 0); } - + /* Check if Quantum expired */ if (CurrentThread->Quantum <= 0) { - + /* Reset the new Quantum */ CurrentThread->Quantum = CurrentThread->QuantumReset; - + /* Calculate new priority */ OldPriority = CurrentThread->Priority; if (OldPriority < LOW_REALTIME_PRIORITY) { - + /* Set the New Priority and add the Priority Decrement */ NewPriority = OldPriority - CurrentThread->PriorityDecrement - 1; - + /* Don't go out of bounds */ if (NewPriority < CurrentThread->BasePriority) NewPriority = CurrentThread->BasePriority; - + /* Reset the priority decrement */ CurrentThread->PriorityDecrement = 0; - + /* Set a new priority if needed */ if (OldPriority != NewPriority) { - + /* Set new Priority */ CurrentThread->Priority = NewPriority; - + } else { - + /* Queue new thread if none is already */ if (Prcb->NextThread == NULL) { - + /* FIXME: Schedule a New Thread, when ROS will have NT Scheduler */ - + } else { - + /* Make the current thread non-premeptive if a new thread is queued */ CurrentThread->Preempted = FALSE; } } - + } else { /* Set the Quantum back to Maximum */ //if (CurrentThread->DisableQuantum) { @@ -493,12 +493,12 @@ KiQuantumEnd(VOID) /* Dispatch the Thread */ KeLowerIrql(DISPATCH_LEVEL); KiDispatchThread(Ready); -} +} /* * @implemented * - * FUNCTION: + * FUNCTION: * Called whenever a system interrupt is generated at DISPATCH_LEVEL. * It delivers queued DPCs and dispatches a new thread if need be. */ @@ -520,7 +520,7 @@ KiDispatchInterrupt(VOID) if (Prcb->DpcData[0].DpcQueueDepth > 0) { /* Raise IRQL */ KeRaiseIrql(HIGH_LEVEL, &OldIrql); -#ifdef CONFIG_SMP +#ifdef CONFIG_SMP KiAcquireSpinLock(&Prcb->DpcData[0].DpcLock); #endif Prcb->DpcRoutineActive = TRUE; @@ -528,10 +528,10 @@ KiDispatchInterrupt(VOID) DPRINT("&Prcb->DpcData[0].DpcListHead: %x\n", &Prcb->DpcData[0].DpcListHead); /* Loop while we have entries */ while (!IsListEmpty(&Prcb->DpcData[0].DpcListHead)) { - + ASSERT(Prcb->DpcData[0].DpcQueueDepth > 0); DPRINT("Queue Depth: %x\n", Prcb->DpcData[0].DpcQueueDepth); - + /* Get the DPC call it */ DpcEntry = RemoveHeadList(&Prcb->DpcData[0].DpcListHead); Dpc = CONTAINING_RECORD(DpcEntry, KDPC, DpcListEntry); @@ -549,16 +549,16 @@ KiDispatchInterrupt(VOID) Dpc->SystemArgument1, Dpc->SystemArgument2); KeRaiseIrql(HIGH_LEVEL, &OldIrql); - + #ifdef CONFIG_SMP KiAcquireSpinLock(&Prcb->DpcData[0].DpcLock); - /* + /* * If the dpc routine drops the irql below DISPATCH_LEVEL, - * a thread switch can occur and after the next thread switch + * a thread switch can occur and after the next thread switch * the execution may start on an other processor. */ if (Prcb != KeGetCurrentPrcb()) { - + Prcb->DpcRoutineActive = FALSE; KiReleaseSpinLock(&Prcb->DpcData[0].DpcLock); Prcb = KeGetCurrentPrcb(); @@ -573,16 +573,16 @@ KiDispatchInterrupt(VOID) #ifdef CONFIG_SMP KiReleaseSpinLock(&Prcb->DpcData[0].DpcLock); #endif - + /* DPC Dispatching Ended, re-enable interrupts */ KeLowerIrql(OldIrql); } - + DPRINT("Checking for Quantum End\n"); - + /* If we have Quantum End, call the function */ if (Prcb->QuantumEnd) { - + Prcb->QuantumEnd = FALSE; KiQuantumEnd(); } diff --git a/reactos/ntoskrnl/ke/event.c b/reactos/ntoskrnl/ke/event.c index 364f498b53e..43f0555fcc6 100644 --- a/reactos/ntoskrnl/ke/event.c +++ b/reactos/ntoskrnl/ke/event.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/event.c * PURPOSE: Implements events - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) * David Welch (welch@mcmail.com) */ @@ -20,12 +20,12 @@ /* * @implemented */ -VOID -STDCALL +VOID +STDCALL KeClearEvent(PKEVENT Event) { DPRINT("KeClearEvent(Event %x)\n", Event); - + /* Reset Signal State */ Event->Header.SignalState = FALSE; } @@ -33,14 +33,14 @@ KeClearEvent(PKEVENT Event) /* * @implemented */ -VOID -STDCALL +VOID +STDCALL KeInitializeEvent(PKEVENT Event, EVENT_TYPE Type, BOOLEAN State) { DPRINT("KeInitializeEvent(Event %x)\n", Event); - + /* Initialize the Dispatcher Header */ KeInitializeDispatcherHeader(&Event->Header, Type, @@ -51,16 +51,16 @@ KeInitializeEvent(PKEVENT Event, /* * @implemented */ -VOID -STDCALL +VOID +STDCALL KeInitializeEventPair(PKEVENT_PAIR EventPair) { DPRINT("KeInitializeEventPair(Event %x)\n", EventPair); - + /* Initialize the Event Pair Type and Size */ EventPair->Type = EventPairObject; EventPair->Size = sizeof(KEVENT_PAIR); - + /* Initialize the two Events */ KeInitializeEvent(&EventPair->LowEvent, SynchronizationEvent, FALSE); KeInitializeEvent(&EventPair->HighEvent, SynchronizationEvent, FALSE); @@ -78,34 +78,34 @@ KePulseEvent(IN PKEVENT Event, LONG PreviousState; DPRINT("KePulseEvent(Event %x, Wait %x)\n",Event,Wait); - + /* Lock the Dispatcher Database */ OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* Save the Old State */ PreviousState = Event->Header.SignalState; - + /* Check if we are non-signaled and we have stuff in the Wait Queue */ if (!PreviousState && !IsListEmpty(&Event->Header.WaitListHead)) { - + /* Set the Event to Signaled */ Event->Header.SignalState = 1; - + /* Wake the Event */ KiWaitTest(&Event->Header, Increment); } - + /* Unsignal it */ Event->Header.SignalState = 0; - + /* Check what wait state was requested */ if (Wait == FALSE) { - - /* Wait not requested, release Dispatcher Database and return */ + + /* Wait not requested, release Dispatcher Database and return */ KeReleaseDispatcherDatabaseLock(OldIrql); - + } else { - + /* Return Locked and with a Wait */ KTHREAD *Thread = KeGetCurrentThread(); Thread->WaitNext = TRUE; @@ -119,8 +119,8 @@ KePulseEvent(IN PKEVENT Event, /* * @implemented */ -LONG -STDCALL +LONG +STDCALL KeReadStateEvent(PKEVENT Event) { /* Return the Signal State */ @@ -130,25 +130,25 @@ KeReadStateEvent(PKEVENT Event) /* * @implemented */ -LONG -STDCALL +LONG +STDCALL KeResetEvent(PKEVENT Event) { KIRQL OldIrql; LONG PreviousState; - + DPRINT("KeResetEvent(Event %x)\n",Event); - + /* Lock the Dispatcher Database */ OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* Save the Previous State */ PreviousState = Event->Header.SignalState; - + /* Set it to zero */ Event->Header.SignalState = 0; - - /* Release Dispatcher Database and return previous state */ + + /* Release Dispatcher Database and return previous state */ KeReleaseDispatcherDatabaseLock(OldIrql); return PreviousState; } @@ -157,7 +157,7 @@ KeResetEvent(PKEVENT Event) * @implemented */ LONG -STDCALL +STDCALL KeSetEvent(PKEVENT Event, KPRIORITY Increment, BOOLEAN Wait) @@ -170,52 +170,52 @@ KeSetEvent(PKEVENT Event, /* Lock the Dispathcer Database */ OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* Save the Previous State */ PreviousState = Event->Header.SignalState; - + /* Check if we have stuff in the Wait Queue */ if (IsListEmpty(&Event->Header.WaitListHead)) { - + /* Set the Event to Signaled */ DPRINT("Empty Wait Queue, Signal the Event\n"); Event->Header.SignalState = 1; - + } else { - + /* Get the Wait Block */ WaitBlock = CONTAINING_RECORD(Event->Header.WaitListHead.Flink, KWAIT_BLOCK, WaitListEntry); - - + + /* Check the type of event */ if (Event->Header.Type == NotificationEvent || WaitBlock->WaitType == WaitAll) { - + if (PreviousState == 0) { - + /* We must do a full wait satisfaction */ DPRINT("Notification Event or WaitAll, Wait on the Event and Signal\n"); Event->Header.SignalState = 1; KiWaitTest(&Event->Header, Increment); } - + } else { - - /* We can satisfy wait simply by waking the thread, since our signal state is 0 now */ + + /* We can satisfy wait simply by waking the thread, since our signal state is 0 now */ DPRINT("WaitAny or Sync Event, just unwait the thread\n"); KiAbortWaitThread(WaitBlock->Thread, WaitBlock->WaitKey, Increment); } } - + /* Check what wait state was requested */ if (Wait == FALSE) { - - /* Wait not requested, release Dispatcher Database and return */ + + /* Wait not requested, release Dispatcher Database and return */ KeReleaseDispatcherDatabaseLock(OldIrql); - + } else { - + /* Return Locked and with a Wait */ KTHREAD *Thread = KeGetCurrentThread(); Thread->WaitNext = TRUE; @@ -239,20 +239,20 @@ KeSetEventBoostPriority(IN PKEVENT Event, KIRQL OldIrql; DPRINT("KeSetEventBoostPriority(Event %x, Thread %x)\n",Event,Thread); - + /* Acquire Dispatcher Database Lock */ OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* If our wait list is empty, then signal the event and return */ if (IsListEmpty(&Event->Header.WaitListHead)) { - + Event->Header.SignalState = 1; - + } else { - + /* Get Thread that is currently waiting. First get the Wait Block, then the Thread */ - WaitingThread = CONTAINING_RECORD(Event->Header.WaitListHead.Flink, - KWAIT_BLOCK, + WaitingThread = CONTAINING_RECORD(Event->Header.WaitListHead.Flink, + KWAIT_BLOCK, WaitListEntry)->Thread; /* Return it to caller if requested */ @@ -262,7 +262,7 @@ KeSetEventBoostPriority(IN PKEVENT Event, WaitingThread->Quantum = WaitingThread->QuantumReset; KiAbortWaitThread(WaitingThread, STATUS_SUCCESS, EVENT_INCREMENT); } - + /* Release the Dispatcher Database Lock */ KeReleaseDispatcherDatabaseLock(OldIrql); } diff --git a/reactos/ntoskrnl/ke/gate.c b/reactos/ntoskrnl/ke/gate.c index 34cbb0c20ba..220e2f41c9a 100644 --- a/reactos/ntoskrnl/ke/gate.c +++ b/reactos/ntoskrnl/ke/gate.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS Kernel * FILE: ntoskrnl/ke/gate.c * PURPOSE: Implements the Gate Dispatcher Object - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) */ @@ -15,12 +15,12 @@ /* FUNCTIONS ****************************************************************/ -VOID +VOID FASTCALL KeInitializeGate(PKGATE Gate) { DPRINT1("KeInitializeGate(Gate %x)\n", Gate); - + /* Initialize the Dispatcher Header */ KeInitializeDispatcherHeader(&Gate->Header, GateObject, @@ -32,65 +32,65 @@ VOID FASTCALL KeWaitForGate(PKGATE Gate, KWAIT_REASON WaitReason, - KPROCESSOR_MODE WaitMode) + KPROCESSOR_MODE WaitMode) { KIRQL OldIrql; PKTHREAD CurrentThread = KeGetCurrentThread(); PKWAIT_BLOCK GateWaitBlock; NTSTATUS Status; - + DPRINT1("KeWaitForGate(Gate %x)\n", Gate); - - do + + do { /* Lock the APC Queue */ KeAcquireSpinLock(&CurrentThread->ApcQueueLock, &OldIrql); - + /* Check if it's already signaled */ if (!Gate->Header.SignalState) { /* Unsignal it */ Gate->Header.SignalState = 0; - + /* Unlock the Queue and return */ KeReleaseSpinLock(&CurrentThread->ApcQueueLock, OldIrql); return; } - + /* Setup a Wait Block */ GateWaitBlock = &CurrentThread->WaitBlock[0]; GateWaitBlock->Object = (PVOID)Gate; GateWaitBlock->Thread = CurrentThread; - + /* Set the Thread Wait Data */ CurrentThread->WaitReason = WaitReason; CurrentThread->WaitMode = WaitMode; CurrentThread->WaitIrql = OldIrql; CurrentThread->GateObject = Gate; - + /* Insert into the Wait List */ InsertTailList(&Gate->Header.WaitListHead, &GateWaitBlock->WaitListEntry); - + /* Handle Kernel Queues */ - if (CurrentThread->Queue) + if (CurrentThread->Queue) { DPRINT1("Waking Queue\n"); KiWakeQueue(CurrentThread->Queue); } - + /* Unlock the Queue*/ KeReleaseSpinLock(&CurrentThread->ApcQueueLock, OldIrql); - + /* Block the Thread */ DPRINT1("Blocking the Thread: %x\n", CurrentThread); - KiBlockThread(&Status, - CurrentThread->Alertable, - WaitMode, + KiBlockThread(&Status, + CurrentThread->Alertable, + WaitMode, WaitReason); - + /* Check if we were executing an APC */ if (Status != STATUS_KERNEL_APC) return; - + DPRINT1("Looping Again\n"); } while (TRUE); } @@ -105,43 +105,43 @@ KeSignalGateBoostPriority(PKGATE Gate) NTSTATUS WaitStatus = STATUS_SUCCESS; DPRINT1("KeSignalGateBoostPriority(EveGate %x)\n", Gate); - + /* Acquire Dispatcher Database Lock */ OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* Make sure we're not already signaled or that the list is empty */ if (Gate->Header.SignalState) goto quit; - + /* If our wait list is empty, then signal the event and return */ if (IsListEmpty(&Gate->Header.WaitListHead)) - { + { Gate->Header.SignalState = 1; goto quit; } - + /* Get WaitBlock */ - WaitBlock = CONTAINING_RECORD(Gate->Header.WaitListHead.Flink, - KWAIT_BLOCK, - WaitListEntry); + WaitBlock = CONTAINING_RECORD(Gate->Header.WaitListHead.Flink, + KWAIT_BLOCK, + WaitListEntry); /* Remove it */ RemoveEntryList(&WaitBlock->WaitListEntry); - + /* Get the Associated thread */ WaitThread = WaitBlock->Thread; /* Increment the Queue's active threads */ - if (WaitThread->Queue) + if (WaitThread->Queue) { DPRINT1("Incrementing Queue's active threads\n"); WaitThread->Queue->CurrentCount++; } - + /* Reschedule the Thread */ DPRINT1("Unblocking the Thread\n"); KiUnblockThread(WaitThread, &WaitStatus, EVENT_INCREMENT); return; -quit: +quit: /* Release the Dispatcher Database Lock */ KeReleaseDispatcherDatabaseLock(OldIrql); } diff --git a/reactos/ntoskrnl/ke/gmutex.c b/reactos/ntoskrnl/ke/gmutex.c index f0df282ca85..464d91db145 100644 --- a/reactos/ntoskrnl/ke/gmutex.c +++ b/reactos/ntoskrnl/ke/gmutex.c @@ -3,8 +3,8 @@ * PROJECT: ReactOS Kernel * FILE: ntoskrnl/ke/gmutex.c * PURPOSE: Implements Guarded Mutex - * - * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) and + * + * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) and * Filip Navara (xnavara@volny.cz) */ @@ -33,7 +33,7 @@ typedef enum _KGUARDED_MUTEX_BITS * Enters a guarded region. This causes all (incl. special kernel) APCs * to be disabled. */ -VOID +VOID STDCALL KeEnterGuardedRegion(VOID) { @@ -51,7 +51,7 @@ STDCALL KeLeaveGuardedRegion(VOID) { PKTHREAD Thread = KeGetCurrentThread(); - + /* Boost the enable count and check if Special APCs are enabled */ if (++Thread->SpecialApcDisable == 0) { @@ -63,8 +63,8 @@ KeLeaveGuardedRegion(VOID) } } } - -VOID + +VOID FASTCALL KeInitializeGuardedMutex(PKGUARDED_MUTEX GuardedMutex) { @@ -72,7 +72,7 @@ KeInitializeGuardedMutex(PKGUARDED_MUTEX GuardedMutex) GuardedMutex->Count = GM_LOCK_BIT; GuardedMutex->Owner = NULL; GuardedMutex->Contention = 0; - + /* Initialize the Wait Gate */ KeInitializeGate(&GuardedMutex->Gate); } @@ -84,45 +84,45 @@ KiAcquireGuardedMutexContented(PKGUARDED_MUTEX GuardedMutex) ULONG BitsToRemove; ULONG BitsToAdd; LONG OldValue; - + /* Increase the contention count */ InterlockedIncrement((PLONG)&GuardedMutex->Contention); - + /* Start by unlocking the Guarded Mutex */ BitsToRemove = GM_LOCK_BIT; BitsToAdd = GM_LOCK_WAITER_INC; - + while (1) { /* Get the Count Bits */ OldValue = (volatile LONG)GuardedMutex->Count; - + /* Check if the Guarded Mutex is locked */ if (OldValue & GM_LOCK_BIT) { /* Unlock it by removing the Lock Bit */ - if (InterlockedCompareExchange(&GuardedMutex->Count, - OldValue &~ BitsToRemove, - OldValue) == OldValue) + if (InterlockedCompareExchange(&GuardedMutex->Count, + OldValue &~ BitsToRemove, + OldValue) == OldValue) { /* The Guarded Mutex is now unlocked */ break; } - } + } else { /* The Guarded Mutex isn't locked, so simply set the bits */ - if (InterlockedCompareExchange(&GuardedMutex->Count, - OldValue | BitsToAdd, - OldValue) != OldValue) + if (InterlockedCompareExchange(&GuardedMutex->Count, + OldValue | BitsToAdd, + OldValue) != OldValue) { /* The Guarded Mutex value changed behind our back, start over */ continue; } - + /* Now we have to wait for it */ KeWaitForGate(&GuardedMutex->Gate, WrGuardedMutex, KernelMode); - + /* Ok, the wait is done, so set the new bits */ BitsToRemove = GM_LOCK_BIT | GM_LOCK_WAITER_WOKEN; BitsToAdd = GM_LOCK_WAITER_WOKEN; @@ -130,14 +130,14 @@ KiAcquireGuardedMutexContented(PKGUARDED_MUTEX GuardedMutex) } } -VOID +VOID FASTCALL KeAcquireGuardedMutex(PKGUARDED_MUTEX GuardedMutex) { /* Disable Special APCs */ KeEnterGuardedRegion(); - /* Do the Unsafe Acquire */ + /* Do the Unsafe Acquire */ KeAcquireGuardedMutexUnsafe(GuardedMutex); } @@ -151,31 +151,31 @@ KeAcquireGuardedMutexUnsafe(PKGUARDED_MUTEX GuardedMutex) /* The Guarded Mutex was already locked, enter contented case */ KiAcquireGuardedMutexContented(GuardedMutex); } - + /* Set the Owner */ GuardedMutex->Owner = KeGetCurrentThread(); } -VOID +VOID FASTCALL KeReleaseGuardedMutexUnsafe(PKGUARDED_MUTEX GuardedMutex) { LONG OldValue; - + /* Destroy the Owner */ GuardedMutex->Owner = NULL; - + /* Add the Lock Bit */ OldValue = InterlockedExchangeAdd(&GuardedMutex->Count, 1); - + /* Check if it was already locked, but not woken */ if (OldValue && !(OldValue & GM_LOCK_WAITER_WOKEN)) { /* Update the Oldvalue to what it should be now */ OldValue |= GM_LOCK_BIT; - + /* Remove the Woken bit */ - if (InterlockedCompareExchange(&GuardedMutex->Count, + if (InterlockedCompareExchange(&GuardedMutex->Count, OldValue &~ GM_LOCK_WAITER_WOKEN, OldValue) == OldValue) { @@ -185,34 +185,34 @@ KeReleaseGuardedMutexUnsafe(PKGUARDED_MUTEX GuardedMutex) } } -VOID +VOID FASTCALL KeReleaseGuardedMutex(PKGUARDED_MUTEX GuardedMutex) { /* Do the actual release */ KeReleaseGuardedMutexUnsafe(GuardedMutex); - + /* Re-enable APCs */ KeLeaveGuardedRegion(); } -BOOL +BOOL FASTCALL KeTryToAcquireGuardedMutex(PKGUARDED_MUTEX GuardedMutex) { /* Block APCs */ KeEnterGuardedRegion(); - + /* Remove the lock */ if (InterlockedClearBit(&GuardedMutex->Count, 0)) { /* Re-enable APCs */ KeLeaveGuardedRegion(); - + /* Return failure */ return FALSE; } - + /* Set the Owner */ GuardedMutex->Owner = KeGetCurrentThread(); return TRUE; diff --git a/reactos/ntoskrnl/ke/i386/bios.c b/reactos/ntoskrnl/ke/i386/bios.c index facd6a9c6c6..2e3dea873f8 100644 --- a/reactos/ntoskrnl/ke/i386/bios.c +++ b/reactos/ntoskrnl/ke/i386/bios.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/i386/bios.c * PURPOSE: Support for calling the BIOS in v86 mode - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -37,10 +37,10 @@ Ke386CallBios(UCHAR Int, PKV86M_REGISTERS Regs) Ip[0] = 0xCD; /* int XX */ Ip[1] = Int; Ip[2] = 0x63; /* arpl ax, ax */ - Ip[3] = 0xC0; + Ip[3] = 0xC0; Ip[4] = 0x90; /* nop */ Ip[5] = 0x90; /* nop */ - + /* * Munge the registers */ @@ -51,7 +51,7 @@ Ke386CallBios(UCHAR Int, PKV86M_REGISTERS Regs) Regs->Eflags = (1 << 1) | (1 << 17) | (1 << 9); /* VM, IF */ Regs->RecoveryAddress = TRAMPOLINE_BASE + 2; Regs->RecoveryInstruction[0] = 0x63; /* arpl ax, ax */ - Regs->RecoveryInstruction[1] = 0xC0; + Regs->RecoveryInstruction[1] = 0xC0; Regs->RecoveryInstruction[2] = 0x90; /* nop */ Regs->RecoveryInstruction[3] = 0x90; /* nop */ Regs->Flags = KV86M_EMULATE_CLI_STI | KV86M_ALLOW_IO_PORT_ACCESS; @@ -67,7 +67,7 @@ Ke386CallBios(UCHAR Int, PKV86M_REGISTERS Regs) * Copy the return values back to the caller */ memcpy(Regs, &ORegs, sizeof(KV86M_REGISTERS)); - + return(Status); } diff --git a/reactos/ntoskrnl/ke/i386/brkpoint.c b/reactos/ntoskrnl/ke/i386/brkpoint.c index c967faec31e..47530400c71 100644 --- a/reactos/ntoskrnl/ke/i386/brkpoint.c +++ b/reactos/ntoskrnl/ke/i386/brkpoint.c @@ -1,5 +1,5 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/i386/brkpoint.c @@ -18,7 +18,7 @@ /* * @implemented */ -VOID STDCALL +VOID STDCALL DbgBreakPoint(VOID) { #if defined(__GNUC__) @@ -43,7 +43,7 @@ DbgBreakPoint(VOID) /* * @implemented */ -VOID STDCALL +VOID STDCALL DbgBreakPointWithStatus(ULONG Status) { #if defined(__GNUC__) diff --git a/reactos/ntoskrnl/ke/i386/exp.c b/reactos/ntoskrnl/ke/i386/exp.c index e923f53fed7..2db4926aa61 100644 --- a/reactos/ntoskrnl/ke/i386/exp.c +++ b/reactos/ntoskrnl/ke/i386/exp.c @@ -593,10 +593,10 @@ KeContextToTrapFrame(PCONTEXT Context, TrapFrame->Ss = Context->SegSs; TrapFrame->Cs = Context->SegCs; TrapFrame->Eip = Context->Eip; - TrapFrame->Eflags = Context->EFlags; + TrapFrame->Eflags = Context->EFlags; TrapFrame->Ebp = Context->Ebp; } - + /* Process the Integer Registers */ if ((Context->ContextFlags & CONTEXT_INTEGER) == CONTEXT_INTEGER) { @@ -607,7 +607,7 @@ KeContextToTrapFrame(PCONTEXT Context, TrapFrame->Esi = Context->Esi; TrapFrame->Edi = Context->Edi; } - + /* Process the Context Segments */ if ((Context->ContextFlags & CONTEXT_SEGMENTS) == CONTEXT_SEGMENTS) { @@ -616,7 +616,7 @@ KeContextToTrapFrame(PCONTEXT Context, TrapFrame->Fs = Context->SegFs; TrapFrame->Gs = Context->SegGs; } - + /* Handle the Debug Registers */ if ((Context->ContextFlags & CONTEXT_DEBUG_REGISTERS) == CONTEXT_DEBUG_REGISTERS) { @@ -627,7 +627,7 @@ KeContextToTrapFrame(PCONTEXT Context, TrapFrame->Dr6 = Context->Dr6; TrapFrame->Dr7 = Context->Dr7; } - + /* Handle FPU and Extended Registers */ return KiContextToFxSaveArea((PFX_SAVE_AREA)(TrapFrame + 1), Context); } @@ -673,7 +673,7 @@ KeTrapFrameToContext(PKTRAP_FRAME TrapFrame, { /* * FIXME: Implement this case - */ + */ Context->ContextFlags &= (~CONTEXT_DEBUG_REGISTERS) | CONTEXT_i386; } if ((Context->ContextFlags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT) diff --git a/reactos/ntoskrnl/ke/i386/fpu.c b/reactos/ntoskrnl/ke/i386/fpu.c index 59195b40c72..27d42faccd3 100644 --- a/reactos/ntoskrnl/ke/i386/fpu.c +++ b/reactos/ntoskrnl/ke/i386/fpu.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/i386/fpu.c * PURPOSE: Handles the FPU - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -69,7 +69,7 @@ KiTagWordFxsaveToFnsave(PFXSAVE_FORMAT FxSave) UCHAR Tag; INT i; struct FPREG { USHORT Significand[4]; USHORT Exponent; } *FpReg; - + for (i = 0; i < 8; i++) { if (FxSave->TagWord & (1 << i)) /* valid */ @@ -88,11 +88,11 @@ KiTagWordFxsaveToFnsave(PFXSAVE_FORMAT FxSave) Tag = 2; /* Special */ } break; - + case 0x7fff: Tag = 2; /* Special */ break; - + default: if (FpReg->Significand[3] & 0x00008000) { @@ -303,11 +303,11 @@ KiCheckFPU(VOID) if (Prcb->FeatureBits & (X86_FEATURE_SSE | X86_FEATURE_SSE2)) { Ke386SetCr4(Ke386GetCr4() | X86_CR4_OSXMMEXCPT); - + /* enable SSE */ XmmSupport = 1; } - + Ke386SetCr0(Ke386GetCr0() | X86_CR0_TS); Ke386RestoreFlags(Flags); } @@ -388,7 +388,7 @@ KiHandleFpuFault(PKTRAP_FRAME Tf, ULONG ExceptionNr) #ifndef CONFIG_SMP PKTHREAD NpxThread; #endif - + (void) cr0; ASSERT((cr0 & X86_CR0_TS) == X86_CR0_TS); ASSERT((Tf->Eflags & X86_EFLAGS_VM) == 0); @@ -570,7 +570,7 @@ KiHandleFpuFault(PKTRAP_FRAME Tf, ULONG ExceptionNr) /* Dispatch exception */ DPRINT("Dispatching exception (ExceptionCode = 0x%08x)\n", Er.ExceptionCode); KiDispatchException(&Er, Context, Tf, PreviousMode, TRUE); - + DPRINT("Math-fault handled!\n"); return STATUS_SUCCESS; } diff --git a/reactos/ntoskrnl/ke/i386/gdt.c b/reactos/ntoskrnl/ke/i386/gdt.c index 716eb7cddcd..9555cb8a574 100644 --- a/reactos/ntoskrnl/ke/i386/gdt.c +++ b/reactos/ntoskrnl/ke/i386/gdt.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/i386/gdt.c * PURPOSE: GDT managment - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -18,7 +18,7 @@ PUSHORT KiGdtArray[MAXIMUM_PROCESSORS]; -USHORT KiBootGdt[11 * 4] = +USHORT KiBootGdt[11 * 4] = { 0x0, 0x0, 0x0, 0x0, /* Null */ 0xffff, 0x0, 0x9a00, 0xcf, /* Kernel CS */ @@ -61,7 +61,7 @@ KiInitializeGdt(PKPCR Pcr) PUSHORT Gdt; struct LocalGdtDescriptor_t Descriptor; ULONG Entry; - ULONG Base; + ULONG Base; if (Pcr == NULL) { @@ -89,15 +89,15 @@ KiInitializeGdt(PKPCR Pcr) Pcr->GDT = Gdt; /* - * Set the base address of the PCR + * Set the base address of the PCR */ Base = (ULONG)Pcr; Entry = PCR_SELECTOR / 2; Gdt[Entry + 1] = (USHORT)(((ULONG)Base) & 0xffff); - + Gdt[Entry + 2] = Gdt[Entry + 2] & ~(0xff); Gdt[Entry + 2] = (USHORT)(Gdt[Entry + 2] | ((((ULONG)Base) & 0xff0000) >> 16)); - + Gdt[Entry + 3] = Gdt[Entry + 3] & ~(0xff00); Gdt[Entry + 3] = (USHORT)(Gdt[Entry + 3] | ((((ULONG)Base) & 0xff000000) >> 16)); @@ -108,7 +108,7 @@ KiInitializeGdt(PKPCR Pcr) Descriptor.Base = (ULONG)Gdt; #if defined(__GNUC__) __asm__ ("lgdt %0\n\t" : /* no output */ : "m" (Descriptor)); - + /* * Reload the selectors */ @@ -162,7 +162,7 @@ KeI386FlatToGdtSelector( /* * @unimplemented */ -NTSTATUS +NTSTATUS KeI386ReleaseGdtSelectors( OUT PULONG SelArray, IN ULONG NumOfSelectors @@ -185,77 +185,77 @@ KeI386AllocateGdtSelectors( return 0; } -VOID +VOID KeSetBaseGdtSelector(ULONG Entry, PVOID Base) { KIRQL oldIrql; PUSHORT Gdt; - + DPRINT("KeSetBaseGdtSelector(Entry %x, Base %x)\n", Entry, Base); - + KeAcquireSpinLock(&GdtLock, &oldIrql); - + Gdt = KeGetCurrentKPCR()->GDT; Entry = (Entry & (~0x3)) / 2; - + Gdt[Entry + 1] = (USHORT)(((ULONG)Base) & 0xffff); - + Gdt[Entry + 2] = Gdt[Entry + 2] & ~(0xff); Gdt[Entry + 2] = (USHORT)(Gdt[Entry + 2] | ((((ULONG)Base) & 0xff0000) >> 16)); - + Gdt[Entry + 3] = Gdt[Entry + 3] & ~(0xff00); Gdt[Entry + 3] = (USHORT)(Gdt[Entry + 3] | ((((ULONG)Base) & 0xff000000) >> 16)); - - DPRINT("%x %x %x %x\n", + + DPRINT("%x %x %x %x\n", Gdt[Entry + 0], Gdt[Entry + 1], Gdt[Entry + 2], Gdt[Entry + 3]); - + KeReleaseSpinLock(&GdtLock, oldIrql); } -VOID +VOID KeSetGdtSelector(ULONG Entry, ULONG Value1, ULONG Value2) { KIRQL oldIrql; - PULONG Gdt; - + PULONG Gdt; + DPRINT("KeSetGdtSelector(Entry %x, Value1 %x, Value2 %x)\n", Entry, Value1, Value2); - + KeAcquireSpinLock(&GdtLock, &oldIrql); - - Gdt = (PULONG) KeGetCurrentKPCR()->GDT;; + + Gdt = (PULONG) KeGetCurrentKPCR()->GDT; Entry = (Entry & (~0x3)) / 4; Gdt[Entry] = Value1; Gdt[Entry + 1] = Value2; - DPRINT("%x %x\n", + DPRINT("%x %x\n", Gdt[Entry + 0], Gdt[Entry + 1]); - + KeReleaseSpinLock(&GdtLock, oldIrql); } -VOID +VOID KeDumpGdtSelector(ULONG Entry) { USHORT a, b, c, d; ULONG RawLimit; - + a = KiBootGdt[Entry*4]; b = KiBootGdt[Entry*4 + 1]; c = KiBootGdt[Entry*4 + 2]; d = KiBootGdt[Entry*4 + 3]; - + DbgPrint("Base: %x\n", b + ((c & 0xff) * (1 << 16)) + ((d & 0xff00) * (1 << 16))); RawLimit = a + ((d & 0xf) * (1 << 16)); diff --git a/reactos/ntoskrnl/ke/i386/idt.c b/reactos/ntoskrnl/ke/i386/idt.c index e4c4486beaa..1a9c86aa94c 100644 --- a/reactos/ntoskrnl/ke/i386/idt.c +++ b/reactos/ntoskrnl/ke/i386/idt.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/i386/idt.c * PURPOSE: IDT managment - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ diff --git a/reactos/ntoskrnl/ke/i386/irq.c b/reactos/ntoskrnl/ke/i386/irq.c index 60a0f76bbdf..2678e2504ca 100644 --- a/reactos/ntoskrnl/ke/i386/irq.c +++ b/reactos/ntoskrnl/ke/i386/irq.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/i386/irq.c * PURPOSE: IRQ handling - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) * Hartmut Birr */ @@ -156,7 +156,7 @@ static unsigned int irq_handler[NR_IRQS]= #endif /* CONFIG_SMP */ /* - * PURPOSE: Object describing each isr + * PURPOSE: Object describing each isr * NOTE: The data in this table is only modified at passsive level but can * be accessed at any irq level. */ @@ -209,7 +209,7 @@ KeInitInterrupts (VOID) } } -STATIC VOID +STATIC VOID KeIRQTrapFrameToTrapFrame(PKIRQ_TRAPFRAME IrqTrapFrame, PKTRAP_FRAME TrapFrame) { @@ -293,7 +293,7 @@ KiInterruptDispatch2 (ULONG vector, KIRQL old_level) KiReleaseSpinLock(&CurrentIsr->Lock); } -VOID +VOID KiInterruptDispatch (ULONG vector, PKIRQ_TRAPFRAME Trapframe) /* * FUNCTION: Calls the irq specific handler for an irq @@ -310,7 +310,7 @@ KiInterruptDispatch (ULONG vector, PKIRQ_TRAPFRAME Trapframe) * At this point we have interrupts disabled, nothing has been done to * the PIC. */ - + KeGetCurrentPrcb()->InterruptCount++; /* @@ -358,10 +358,10 @@ KiInterruptDispatch (ULONG vector, PKIRQ_TRAPFRAME Trapframe) CurrentThread = KeGetCurrentThread(); if (CurrentThread!=NULL && CurrentThread->Alerted[1]) { - DPRINT("PID: %d, TID: %d CS %04x/%04x\n", + DPRINT("PID: %d, TID: %d CS %04x/%04x\n", ((PETHREAD)CurrentThread)->ThreadsProcess->UniqueProcessId, ((PETHREAD)CurrentThread)->Cid.UniqueThread, - Trapframe->Cs, + Trapframe->Cs, CurrentThread->TrapFrame ? CurrentThread->TrapFrame->Cs : 0); if (CurrentThread->TrapFrame == NULL) { @@ -369,11 +369,11 @@ KiInterruptDispatch (ULONG vector, PKIRQ_TRAPFRAME Trapframe) KeIRQTrapFrameToTrapFrame(Trapframe, &KernelTrapFrame); CurrentThread->TrapFrame = &KernelTrapFrame; } - + Ke386EnableInterrupts(); KiDeliverApc(KernelMode, NULL, NULL); Ke386DisableInterrupts(); - + ASSERT(KeGetCurrentThread() == CurrentThread); if (CurrentThread->TrapFrame == &KernelTrapFrame) { @@ -384,7 +384,7 @@ KiInterruptDispatch (ULONG vector, PKIRQ_TRAPFRAME Trapframe) } } -static VOID +static VOID KeDumpIrqList(VOID) { PKINTERRUPT current; @@ -392,7 +392,7 @@ KeDumpIrqList(VOID) ULONG i, j; KIRQL oldlvl; BOOLEAN printed; - + for (i=0;iLock); KeLowerIrql(oldlvl); - + KeDumpIrqList(); KeRevertToUserAffinityThread(); @@ -508,7 +508,7 @@ KeDisconnectInterrupt(PKINTERRUPT InterruptObject) PISR_TABLE CurrentIsr; DPRINT("KeDisconnectInterrupt\n"); - + ASSERT (InterruptObject->ProcessorNumber < KeNumberProcessors); KeSetSystemAffinityThread(1 << InterruptObject->ProcessorNumber); @@ -532,7 +532,7 @@ KeDisconnectInterrupt(PKINTERRUPT InterruptObject) */ KiReleaseSpinLock(&CurrentIsr->Lock); KeLowerIrql(oldlvl); - + KeRevertToUserAffinityThread(); } diff --git a/reactos/ntoskrnl/ke/i386/kernel.c b/reactos/ntoskrnl/ke/i386/kernel.c index a18306511d9..24af58b0bc6 100644 --- a/reactos/ntoskrnl/ke/i386/kernel.c +++ b/reactos/ntoskrnl/ke/i386/kernel.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/i386/kernel.c * PURPOSE: Initializes the kernel - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -47,10 +47,10 @@ Ki386GetCpuId(VOID) Flags = OrigFlags ^ X86_EFLAGS_ID; Ke386RestoreFlags(Flags); Ke386SaveFlags(FinalFlags); - + Pcr->PrcbData.LogicalProcessorsPerPhysicalProcessor = 1; Pcr->PrcbData.InitialApicId = 0xff; - + if ((OrigFlags & X86_EFLAGS_ID) == (FinalFlags & X86_EFLAGS_ID)) { /* No cpuid supported. */ @@ -63,7 +63,7 @@ Ki386GetCpuId(VOID) /* Get the vendor name and the maximum cpuid level supported. */ Ki386Cpuid(0, &MaxCpuidLevel, (PULONG)&Pcr->PrcbData.VendorString[0], (PULONG)&Pcr->PrcbData.VendorString[8], (PULONG)&Pcr->PrcbData.VendorString[4]); if (MaxCpuidLevel > 0) - { + { /* Get the feature flags. */ Ki386Cpuid(1, &Eax, &Ke386CpuidExMisc, &Ke386CpuidFlags2, &Pcr->PrcbData.FeatureBits); /* Get the cache alignment, if it is available */ @@ -73,7 +73,7 @@ Ki386GetCpuId(VOID) } Pcr->PrcbData.CpuType = (Eax >> 8) & 0xf; Pcr->PrcbData.CpuStep = (Eax & 0xf) | ((Eax << 4) & 0xf00); - + Pcr->PrcbData.InitialApicId = (Ke386CpuidExMisc >> 24) & 0xff; /* detect Hyper-Threading on Pentium 4 CPUs or later */ @@ -133,8 +133,8 @@ KeApplicationProcessorInitDispatcher(VOID) IdleProcessorMask |= (1 << KeGetCurrentProcessorNumber()); KeReleaseDispatcherDatabaseLock(oldIrql); } - -VOID + +VOID INIT_FUNCTION KeCreateApplicationProcessorIdleThread(ULONG Id) { @@ -144,7 +144,7 @@ KeCreateApplicationProcessorIdleThread(ULONG Id) PsInitializeIdleOrFirstThread(PsIdleProcess, &IdleThread, NULL, - KernelMode, + KernelMode, FALSE); IdleThread->Tcb.State = Running; IdleThread->Tcb.FreezeCount = 0; @@ -188,7 +188,7 @@ KePrepareForApplicationProcessorInit(ULONG Id) Pcr->Irql = SYNCH_LEVEL; Pcr->PrcbData.MHz = BootPcr->PrcbData.MHz; - Pcr->StallScaleFactor = BootPcr->StallScaleFactor; + Pcr->StallScaleFactor = BootPcr->StallScaleFactor; /* Mark the end of the exception handler list */ Pcr->Tib.ExceptionList = (PVOID)-1; @@ -209,7 +209,7 @@ KeApplicationProcessorInit(VOID) /* Enable global pages */ Ke386SetCr4(Ke386GetCr4() | X86_CR4_PGE); } - + Offset = InterlockedIncrementUL(&PcrsAllocated) - 1; Pcr = (PKPCR)((ULONG_PTR)KPCR_BASE + Offset * PAGE_SIZE); @@ -271,7 +271,7 @@ KeInit1(PCHAR CommandLine, PULONG LastKernelAddress) /* * Initialize the initial PCR region. We can't allocate a page * with MmAllocPage() here because MmInit1() has not yet been - * called, so we use a predefined page in low memory + * called, so we use a predefined page in low memory */ KPCR = (PKPCR)KPCR_BASE; @@ -340,7 +340,7 @@ KeInit1(PCHAR CommandLine, PULONG LastKernelAddress) p1 = p2; } #if 0 - /* + /* * FIXME: * Make the detection of the noexecute feature more portable. */ @@ -359,15 +359,15 @@ KeInit1(PCHAR CommandLine, PULONG LastKernelAddress) Ke386NoExecute = TRUE; Ke386RestoreFlags(Flags); } - } + } else { NoExecute=FALSE; } #endif - Ke386Pae = Ke386GetCr4() & X86_CR4_PAE ? TRUE : FALSE; -#if 0 + Ke386Pae = Ke386GetCr4() & X86_CR4_PAE ? TRUE : FALSE; +#if 0 /* Enable PAE mode */ if ((Pae && (KPCR->PrcbData.FeatureBits & X86_FEATURE_PAE)) || NoExecute) { @@ -472,7 +472,7 @@ Ki386SetProcessorFeatures(VOID) (Pcr->PrcbData.FeatureBits & X86_FEATURE_MMX); SharedUserData->ProcessorFeatures[PF_PPC_MOVEMEM_64BIT_OK] = FALSE; SharedUserData->ProcessorFeatures[PF_ALPHA_BYTE_INSTRUCTIONS] = FALSE; - SharedUserData->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] = + SharedUserData->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] = (Pcr->PrcbData.FeatureBits & X86_FEATURE_SSE); SharedUserData->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = (Ke386CpuidExFlags & X86_EXT_FEATURE_3DNOW); @@ -484,13 +484,13 @@ Ki386SetProcessorFeatures(VOID) /* Does the CPU Support Fast System Call? */ if (Pcr->PrcbData.FeatureBits & X86_FEATURE_SYSCALL) { - + /* FIXME: Check for Family == 6, Model < 3 and Stepping < 3 and disable */ - + /* Make sure it's not disabled in registry */ - RtlRosInitUnicodeStringFromLiteral(&KeyName, + RtlRosInitUnicodeStringFromLiteral(&KeyName, L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Session Manager\\Kernel"); - RtlRosInitUnicodeStringFromLiteral(&ValueName, + RtlRosInitUnicodeStringFromLiteral(&ValueName, L"FastSystemCallDisable"); InitializeObjectAttributes(&ObjectAttributes, &KeyName, @@ -498,9 +498,9 @@ Ki386SetProcessorFeatures(VOID) NULL, NULL); Status = NtOpenKey(&KeyHandle, KEY_ALL_ACCESS, &ObjectAttributes); - + if (NT_SUCCESS(Status)) { - + /* Read the Value then Close the Key */ Status = NtQueryValueKey(KeyHandle, &ValueName, @@ -509,20 +509,20 @@ Ki386SetProcessorFeatures(VOID) sizeof(ValueData), &ResultLength); RtlMoveMemory(&FastSystemCallDisable, ValueData.Data, sizeof(ULONG)); - + NtClose(KeyHandle); } - + } else { - + /* Disable SYSENTER/SYSEXIT, because the CPU doesn't support it */ FastSystemCallDisable = 1; - + } - + if (FastSystemCallDisable) { - - /* Use INT2E */ + + /* Use INT2E */ SharedUserData->SystemCall[0] = 0x8D; SharedUserData->SystemCall[1] = 0x54; SharedUserData->SystemCall[2] = 0x24; @@ -530,15 +530,15 @@ Ki386SetProcessorFeatures(VOID) SharedUserData->SystemCall[4] = 0xCD; SharedUserData->SystemCall[5] = 0x2E; SharedUserData->SystemCall[6] = 0xC3; - + } else { - + /* Use SYSENTER */ SharedUserData->SystemCall[0] = 0x8B; SharedUserData->SystemCall[1] = 0xD4; SharedUserData->SystemCall[2] = 0x0F; SharedUserData->SystemCall[3] = 0x34; - SharedUserData->SystemCall[4] = 0xC3; + SharedUserData->SystemCall[4] = 0xC3; /* Enable SYSENTER/SYSEXIT */ KiFastSystemCallDisable = 0; diff --git a/reactos/ntoskrnl/ke/i386/ldt.c b/reactos/ntoskrnl/ke/i386/ldt.c index 711daddcad0..3bef069dc3f 100644 --- a/reactos/ntoskrnl/ke/i386/ldt.c +++ b/reactos/ntoskrnl/ke/i386/ldt.c @@ -23,7 +23,7 @@ static KSPIN_LOCK LdtLock; BOOL PspIsDescriptorValid(PLDT_ENTRY ldt_entry) { ULONG Base, SegLimit; - /* + /* Allow invalid descriptors. */ if(!ldt_entry->HighWord.Bits.Type && @@ -121,12 +121,12 @@ NtSetLdtEntries (ULONG Selector1, ((PULONG) LdtDescriptor)[1]); #if defined(__GNUC__) - __asm__("lldtw %%ax" + __asm__("lldtw %%ax" : /* no output */ : "a" (LDT_SELECTOR)); #elif defined(_MSC_VER) __asm mov ax, LDT_SELECTOR - __asm lldt ax + __asm lldt ax #else #error Unknown compiler for inline assembler #endif @@ -167,7 +167,7 @@ Ki386InitializeLdt(VOID) * Set up an a descriptor for the LDT */ base = length = 0; - + Gdt[(LDT_SELECTOR / 2) + 0] = (length & 0xFFFF); Gdt[(LDT_SELECTOR / 2) + 1] = (base & 0xFFFF); Gdt[(LDT_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8200; diff --git a/reactos/ntoskrnl/ke/i386/thread.c b/reactos/ntoskrnl/ke/i386/thread.c index 6737e6258b8..d04533e9aea 100644 --- a/reactos/ntoskrnl/ke/i386/thread.c +++ b/reactos/ntoskrnl/ke/i386/thread.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/i386/thread.c * PURPOSE: i386 Thread Context Creation - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) */ @@ -12,7 +12,7 @@ #include #define NDEBUG #include - + typedef struct _KSHARED_CTXSWITCH_FRAME { ULONG Esp0; PVOID ExceptionList; @@ -23,7 +23,7 @@ typedef struct _KSTART_FRAME { PKSYSTEM_ROUTINE SystemRoutine; PKSTART_ROUTINE StartRoutine; PVOID StartContext; - BOOLEAN UserThread; + BOOLEAN UserThread; } KSTART_FRAME, *PKSTART_FRAME; /* @@ -61,7 +61,7 @@ typedef struct _KKINIT_FRAME { VOID STDCALL -Ke386InitThreadWithContext(PKTHREAD Thread, +Ke386InitThreadWithContext(PKTHREAD Thread, PKSYSTEM_ROUTINE SystemRoutine, PKSTART_ROUTINE StartRoutine, PVOID StartContext, @@ -71,84 +71,84 @@ Ke386InitThreadWithContext(PKTHREAD Thread, PKSTART_FRAME StartFrame; PKSHARED_CTXSWITCH_FRAME CtxSwitchFrame; PKTRAP_FRAME TrapFrame = NULL; - + /* Check if this is a With-Context Thread */ DPRINT("Ke386InitThreadContext\n"); - if (Context) + if (Context) { /* Set up the Initial Frame */ PKUINIT_FRAME InitFrame; InitFrame = (PKUINIT_FRAME)((ULONG_PTR)Thread->InitialStack - sizeof(KUINIT_FRAME)); DPRINT("Setting up a user-mode thread with the Frame at: %x\n", InitFrame); - + /* Setup the Trap Frame */ TrapFrame = &InitFrame->TrapFrame; - + /* Set up a trap frame from the context. */ if (KeContextToTrapFrame(Context, TrapFrame)) { Thread->NpxState = NPX_STATE_VALID; - } - else - { + } + else + { Thread->NpxState = NPX_STATE_INVALID; } - + /* Enable Interrupts and disable some unsupported flags right now */ TrapFrame->Eflags = Context->EFlags | X86_EFLAGS_IF; TrapFrame->Eflags &= ~(X86_EFLAGS_VM | X86_EFLAGS_NT | X86_EFLAGS_IOPL); - + /* Set the previous mode as user */ TrapFrame->PreviousMode = UserMode; - + /* Terminate the Exception Handler List */ TrapFrame->ExceptionList = (PVOID)0xFFFFFFFF; - + /* Setup the Stack for KiThreadStartup and Context Switching */ StartFrame = &InitFrame->StartFrame; CtxSwitchFrame = &InitFrame->CtxSwitchFrame; - + /* Tell the thread it will run in User Mode */ Thread->PreviousMode = UserMode; - + /* Tell KiThreadStartup of that too */ StartFrame->UserThread = TRUE; - } - else + } + else { /* No context Thread, meaning System Thread */ - + /* Set up the Initial Frame */ PKKINIT_FRAME InitFrame; InitFrame = (PKKINIT_FRAME)((ULONG_PTR)Thread->InitialStack - sizeof(KKINIT_FRAME)); DPRINT("Setting up a kernel thread with the Frame at: %x\n", InitFrame); - + /* Setup the Fx Area */ FxSaveArea = &InitFrame->FxSaveArea; RtlZeroMemory(FxSaveArea, sizeof(FX_SAVE_AREA)); Thread->NpxState = NPX_STATE_INVALID; - + /* Setup the Stack for KiThreadStartup and Context Switching */ StartFrame = &InitFrame->StartFrame; CtxSwitchFrame = &InitFrame->CtxSwitchFrame; - + /* Tell the thread it will run in Kernel Mode */ Thread->PreviousMode = KernelMode; - + /* Tell KiThreadStartup of that too */ StartFrame->UserThread = FALSE; } - + /* Now setup the remaining data for KiThreadStartup */ StartFrame->StartContext = StartContext; StartFrame->StartRoutine = StartRoutine; StartFrame->SystemRoutine = SystemRoutine; - + /* And set up the Context Switch Frame */ CtxSwitchFrame->RetEip = KiThreadStartup; CtxSwitchFrame->Esp0 = (ULONG)Thread->InitialStack - sizeof(FX_SAVE_AREA); CtxSwitchFrame->ExceptionList = (PVOID)0xFFFFFFFF; - + /* Save back the new value of the kernel stack. */ DPRINT("Final Kernel Stack: %x \n", CtxSwitchFrame); Thread->KernelStack = (PVOID)CtxSwitchFrame; diff --git a/reactos/ntoskrnl/ke/i386/tss.c b/reactos/ntoskrnl/ke/i386/tss.c index 03c63f8135e..ff024cf3e42 100644 --- a/reactos/ntoskrnl/ke/i386/tss.c +++ b/reactos/ntoskrnl/ke/i386/tss.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/i386/tss.c * PURPOSE: TSS managment - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -121,7 +121,7 @@ Ki386ApplicationProcessorInitializeTSS(VOID) Tss->Esp0 = (ULONG)Ki386InitialStackArray[Id] + MM_STACK_SIZE; /* FIXME: - sizeof(FX_SAVE_AREA)? */ Tss->Ss0 = KERNEL_DS; Tss->IoMapBase = 0xFFFF; /* No i/o bitmap */ - Tss->IoBitmap[8192] = 0xFF; + Tss->IoBitmap[8192] = 0xFF; Tss->Ldt = 0; /* @@ -129,7 +129,7 @@ Ki386ApplicationProcessorInitializeTSS(VOID) */ base = (ULONG)Tss; length = sizeof(KTSS) - 1; - + Gdt[(TSS_SELECTOR / 2) + 0] = (USHORT)(length & 0xFFFF); Gdt[(TSS_SELECTOR / 2) + 1] = (USHORT)(base & 0xFFFF); Gdt[(TSS_SELECTOR / 2) + 2] = (USHORT)(((base & 0xFF0000) >> 16) | 0x8900); @@ -148,9 +148,9 @@ Ki386ApplicationProcessorInitializeTSS(VOID) TrapTss->Es = KERNEL_DS; TrapTss->Fs = PCR_SELECTOR; TrapTss->IoMapBase = 0xFFFF; /* No i/o bitmap */ - TrapTss->IoBitmap[0] = 0xFF; + TrapTss->IoBitmap[0] = 0xFF; TrapTss->Ldt = 0; - TrapTss->Cr3 = cr3_; + TrapTss->Cr3 = cr3_; /* * Initialize a descriptor for the trap TSS. @@ -168,7 +168,7 @@ Ki386ApplicationProcessorInitializeTSS(VOID) * Load the task register */ #if defined(__GNUC__) - __asm__("ltr %%ax" + __asm__("ltr %%ax" : /* no output */ : "a" (TSS_SELECTOR)); #elif defined(_MSC_VER) @@ -198,7 +198,7 @@ Ki386BootInitializeTSS(VOID) KiBootTss.Ss0 = KERNEL_DS; // KiBootTss.IoMapBase = FIELD_OFFSET(KTSS, IoBitmap); KiBootTss.IoMapBase = 0xFFFF; /* No i/o bitmap */ - KiBootTss.IoBitmap[8192] = 0xFF; + KiBootTss.IoBitmap[8192] = 0xFF; KiBootTss.Ldt = LDT_SELECTOR; /* @@ -206,7 +206,7 @@ Ki386BootInitializeTSS(VOID) */ base = (unsigned int)&KiBootTss; length = sizeof(KiBootTss) - 1; - + KiBootGdt[(TSS_SELECTOR / 2) + 0] = (length & 0xFFFF); KiBootGdt[(TSS_SELECTOR / 2) + 1] = (base & 0xFFFF); KiBootGdt[(TSS_SELECTOR / 2) + 2] = ((base & 0xFF0000) >> 16) | 0x8900; @@ -225,10 +225,10 @@ Ki386BootInitializeTSS(VOID) KiBootTrapTss.Es = KERNEL_DS; KiBootTrapTss.Fs = PCR_SELECTOR; KiBootTrapTss.IoMapBase = 0xFFFF; /* No i/o bitmap */ - KiBootTrapTss.IoBitmap[0] = 0xFF; + KiBootTrapTss.IoBitmap[0] = 0xFF; KiBootTrapTss.Ldt = 0x0; KiBootTrapTss.Cr3 = cr3_; - + /* * Initialize a descriptor for the trap TSS. */ @@ -245,7 +245,7 @@ Ki386BootInitializeTSS(VOID) * Load the task register */ #if defined(__GNUC__) - __asm__("ltr %%ax" + __asm__("ltr %%ax" : /* no output */ : "a" (TSS_SELECTOR)); #elif defined(_MSC_VER) diff --git a/reactos/ntoskrnl/ke/i386/usertrap.c b/reactos/ntoskrnl/ke/i386/usertrap.c index 2307fe9099c..f545addbeb4 100644 --- a/reactos/ntoskrnl/ke/i386/usertrap.c +++ b/reactos/ntoskrnl/ke/i386/usertrap.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/i386/usertrap.c * PURPOSE: Handling usermode exceptions. - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -16,7 +16,7 @@ /* FUNCTIONS ****************************************************************/ -BOOLEAN +BOOLEAN print_user_address(PVOID address) { PLIST_ENTRY current_entry; @@ -32,7 +32,7 @@ print_user_address(PVOID address) { Peb = CurrentProcess->Peb; } - + if (NULL == Peb) { DbgPrint("<%x>", address); @@ -46,17 +46,17 @@ print_user_address(PVOID address) return(TRUE); } current_entry = Ldr->InLoadOrderModuleList.Flink; - + while (current_entry != &Ldr->InLoadOrderModuleList && current_entry != NULL) { - current = + current = CONTAINING_RECORD(current_entry, LDR_MODULE, InLoadOrderModuleList); - + if (address >= (PVOID)current->BaseAddress && address < (PVOID)((char*)current->BaseAddress + current->ResidentSize)) { - RelativeAddress = + RelativeAddress = (ULONG_PTR) address - (ULONG_PTR)current->BaseAddress; DbgPrint("<%wZ: %x>", ¤t->BaseDllName, RelativeAddress); return(TRUE); @@ -113,7 +113,7 @@ KiUserTrapHandler(PKTRAP_FRAME Tf, ULONG ExceptionNr, PVOID Cr2) { Er.NumberParameters = 0; } - + /* FIXME: Which exceptions are noncontinuable? */ Er.ExceptionFlags = 0; diff --git a/reactos/ntoskrnl/ke/i386/v86m.c b/reactos/ntoskrnl/ke/i386/v86m.c index 6cae7824595..a2109ab9250 100644 --- a/reactos/ntoskrnl/ke/i386/v86m.c +++ b/reactos/ntoskrnl/ke/i386/v86m.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/i386/v86m.c * PURPOSE: Support for v86 mode - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -29,7 +29,7 @@ ULONG KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) { PUCHAR ip; - PUSHORT sp; + PUSHORT sp; PULONG dsp; BOOL BigDataPrefix = FALSE; BOOL BigAddressPrefix = FALSE; @@ -43,7 +43,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) DPRINT("KeV86GPF handling %x at %x:%x ss:sp %x:%x Flags %x\n", ip[0], Tf->Cs, Tf->Eip, Tf->Ss, Tf->Esp, VTf->regs->Flags); - + while (!Exit) { switch (ip[i]) @@ -84,7 +84,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) } Exit = TRUE; break; - + /* cli */ case 0xFA: if (BigDataPrefix || BigAddressPrefix || RepPrefix) @@ -100,7 +100,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) } Exit = TRUE; break; - + /* pushf */ case 0x9C: if (RepPrefix) @@ -144,7 +144,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) } Exit = TRUE; break; - + /* popf */ case 0x9D: if (RepPrefix) @@ -166,7 +166,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) else { VTf->regs->Vif = 0; - } + } Tf->Eflags = Tf->Eflags | INTERRUPT_FLAG; Tf->Esp = Tf->Esp + 2; } @@ -227,14 +227,14 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) if (VTf->regs->Flags & KV86M_ALLOW_IO_PORT_ACCESS) { DPRINT("outb %d, %x\n", (ULONG)ip[i + 1], Tf->Eax & 0xFF); - WRITE_PORT_UCHAR((PUCHAR)(ULONG)ip[i + 1], + WRITE_PORT_UCHAR((PUCHAR)(ULONG)ip[i + 1], (UCHAR)(Tf->Eax & 0xFF)); Tf->Eip = Tf->Eip + 2; return(0); } Exit = TRUE; break; - + /* out imm8, ax */ case 0xE7: if (RepPrefix) @@ -276,7 +276,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) } Exit = TRUE; break; - + /* out dx, ax */ case 0xEF: if (RepPrefix) @@ -289,13 +289,13 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) if (!BigDataPrefix) { DPRINT("outw %d, %x\n", Tf->Edx & 0xFFFF, Tf->Eax & 0xFFFF); - WRITE_PORT_USHORT((PUSHORT)(Tf->Edx & 0xFFFF), + WRITE_PORT_USHORT((PUSHORT)(Tf->Edx & 0xFFFF), (USHORT)(Tf->Eax & 0xFFFF)); } else { DPRINT("outl %d, %x\n", Tf->Edx & 0xFFFF, Tf->Eax); - WRITE_PORT_ULONG((PULONG)(Tf->Edx & 0xFFFF), + WRITE_PORT_ULONG((PULONG)(Tf->Edx & 0xFFFF), Tf->Eax); } Tf->Eip = Tf->Eip + 1; @@ -303,7 +303,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) } Exit = TRUE; break; - + /* in al, imm8 */ case 0xE4: if (RepPrefix) @@ -314,7 +314,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) if (VTf->regs->Flags & KV86M_ALLOW_IO_PORT_ACCESS) { UCHAR v; - + v = READ_PORT_UCHAR((PUCHAR)(ULONG)ip[1]); DPRINT("inb %d\t%X\n", (ULONG)ip[1], v); Tf->Eax = Tf->Eax & (~0xFF); @@ -324,7 +324,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) } Exit = TRUE; break; - + /* in ax, imm8 */ case 0xE5: if (RepPrefix) @@ -333,7 +333,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) return(1); } if (VTf->regs->Flags & KV86M_ALLOW_IO_PORT_ACCESS) - { + { if (!BigDataPrefix) { USHORT v; @@ -365,7 +365,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) if (VTf->regs->Flags & KV86M_ALLOW_IO_PORT_ACCESS) { UCHAR v; - + v = READ_PORT_UCHAR((PUCHAR)(Tf->Edx & 0xFFFF)); DPRINT("inb %d\t%X\n", Tf->Edx & 0xFFFF, v); Tf->Eax = Tf->Eax & (~0xFF); @@ -375,7 +375,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) } Exit = TRUE; break; - + /* in ax, dx */ case 0xED: if (RepPrefix) @@ -416,7 +416,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) PUCHAR Port; PUCHAR Buffer; ULONG Offset; - + Count = 1; if (RepPrefix) { @@ -445,7 +445,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) { Buffer--; } - } + } Tf->Eip++; return(0); } @@ -461,7 +461,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) PUSHORT BufferS = NULL; PULONG BufferL = NULL; ULONG Offset; - + Count = 1; if (RepPrefix) { @@ -518,13 +518,13 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) BufferS--; } } - } + } Tf->Eip++; return(0); } Exit = TRUE; break; - + /* insb */ case 0x6C: if (VTf->regs->Flags & KV86M_ALLOW_IO_PORT_ACCESS) @@ -533,7 +533,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) PUCHAR Port; PUCHAR Buffer; ULONG Offset; - + Count = 1; if (RepPrefix) { @@ -562,7 +562,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) { Buffer--; } - } + } Tf->Eip++; return(0); } @@ -578,7 +578,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) PUSHORT BufferS = NULL; PULONG BufferL = NULL; ULONG Offset; - + Count = 1; if (RepPrefix) { @@ -635,7 +635,7 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) BufferS--; } } - } + } Tf->Eip++; return(0); } @@ -647,13 +647,13 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) { unsigned int inum; unsigned int entry; - + inum = ip[1]; entry = ((unsigned int *)0)[inum]; - + Tf->Esp = Tf->Esp - 6; sp = sp - 3; - + sp[0] = (USHORT)((Tf->Eip & 0xFFFF) + 2); sp[1] = (USHORT)(Tf->Cs & 0xFFFF); sp[2] = (USHORT)(Tf->Eflags & 0xFFFF); @@ -665,16 +665,16 @@ KeV86GPF(PKV86M_TRAP_FRAME VTf, PKTRAP_FRAME Tf) Tf->Eip = entry & 0xFFFF; Tf->Cs = entry >> 16; Tf->Eflags = Tf->Eflags & (~TRAP_FLAG); - + return(0); } } - + /* FIXME: Also emulate ins and outs */ /* FIXME: Handle opcode prefixes */ /* FIXME: Don't allow the BIOS to write to sensitive I/O ports */ } - + DPRINT1("V86GPF unhandled (was %x)\n", ip[i]); *VTf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION; return(1); @@ -776,7 +776,7 @@ KeV86Exception(ULONG ExceptionNr, PKTRAP_FRAME Tf, ULONG address) /* Segment not present */ case 11: - *VTf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION;; + *VTf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION; return(1); /* Stack fault */ @@ -819,7 +819,7 @@ KeV86Exception(ULONG ExceptionNr, PKTRAP_FRAME Tf, ULONG address) case 16: *VTf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION; return(1); - + /* Alignment check */ case 17: *VTf->regs->PStatus = STATUS_NONCONTINUABLE_EXCEPTION; diff --git a/reactos/ntoskrnl/ke/i386/vdm.c b/reactos/ntoskrnl/ke/i386/vdm.c index 5285b6a84b5..11a680bbc1b 100644 --- a/reactos/ntoskrnl/ke/i386/vdm.c +++ b/reactos/ntoskrnl/ke/i386/vdm.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/i386/vdm.c * PURPOSE: Virtual DOS machine support - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -67,7 +67,7 @@ NTSTATUS STDCALL NtVdmControl(ULONG ControlCode, /* FIXME: This should use ->VdmObjects */ KeGetCurrentProcess()->Unused = 1; Ki386RetToV86Mode(&V86Registers, &V86Registers); - + /* FIXME: This should use ->VdmObjects */ KeGetCurrentProcess()->Unused = 0; diff --git a/reactos/ntoskrnl/ke/ipi.c b/reactos/ntoskrnl/ke/ipi.c index 25843863125..4aae8a6eab5 100644 --- a/reactos/ntoskrnl/ke/ipi.c +++ b/reactos/ntoskrnl/ke/ipi.c @@ -6,7 +6,7 @@ * PURPOSE: IPI Routines (Inter-Processor Interrupts). NT5+ * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) - * Hartmut Birr + * Hartmut Birr */ /* INCLUDES *****************************************************************/ @@ -21,7 +21,7 @@ KSPIN_LOCK KiIpiLock; /* FUNCTIONS *****************************************************************/ -VOID +VOID KiIpiSendRequest(ULONG TargetSet, ULONG IpiRequest) { ULONG i; @@ -46,10 +46,10 @@ STDCALL KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame) { -#ifdef DBG +#ifdef DBG LARGE_INTEGER StartTime, CurrentTime, Frequency; ULONG Count = 5; -#endif +#endif PKPRCB Prcb; ASSERT(KeGetCurrentIrql() == IPI_LEVEL); @@ -74,38 +74,38 @@ KiIpiServiceRoutine(IN PKTRAP_FRAME TrapFrame, InterlockedDecrementUL(&Prcb->SignalDone->CurrentPacket[1]); if (InterlockedCompareExchangeUL(&Prcb->SignalDone->CurrentPacket[2], 0, 0)) { -#ifdef DBG +#ifdef DBG StartTime = KeQueryPerformanceCounter(&Frequency); -#endif +#endif while (0 != InterlockedCompareExchangeUL(&Prcb->SignalDone->CurrentPacket[1], 0, 0)) { -#ifdef DBG +#ifdef DBG CurrentTime = KeQueryPerformanceCounter(NULL); if (CurrentTime.QuadPart > StartTime.QuadPart + Count * Frequency.QuadPart) { DbgPrint("(%s:%d) CPU%d, waiting longer than %d seconds to start the ipi routine\n", __FILE__,__LINE__, KeGetCurrentProcessorNumber(), Count); KEBUGCHECK(0); } -#endif +#endif } } ((VOID STDCALL(*)(PVOID))(Prcb->SignalDone->WorkerRoutine))(Prcb->SignalDone->CurrentPacket[0]); Ke386TestAndClearBit(KeGetCurrentProcessorNumber(), &Prcb->SignalDone->TargetSet); if (InterlockedCompareExchangeUL(&Prcb->SignalDone->CurrentPacket[2], 0, 0)) { -#ifdef DBG +#ifdef DBG StartTime = KeQueryPerformanceCounter(&Frequency); -#endif +#endif while (0 != InterlockedCompareExchangeUL(&Prcb->SignalDone->TargetSet, 0, 0)) { -#ifdef DBG +#ifdef DBG CurrentTime = KeQueryPerformanceCounter(NULL); if (CurrentTime.QuadPart > StartTime.QuadPart + Count * Frequency.QuadPart) { DbgPrint("(%s:%d) CPU%d, waiting longer than %d seconds after executing the ipi routine\n", __FILE__,__LINE__, KeGetCurrentProcessorNumber(), Count); KEBUGCHECK(0); } -#endif +#endif } } InterlockedExchangePointer(&Prcb->SignalDone, NULL); @@ -170,11 +170,11 @@ KeIpiGenericCall(VOID (STDCALL *Function)(PVOID), PVOID Argument) TargetSet = (1 << KeNumberProcessors) - 1; KiIpiSendPacket(TargetSet, Function, Argument, KeNumberProcessors, TRUE); - + KiReleaseSpinLock(&KiIpiLock); - + KeLowerIrql(oldIrql); - + DPRINT("KeIpiGenericCall on CPU%d done\n", KeGetCurrentProcessorNumber()); } diff --git a/reactos/ntoskrnl/ke/kqueue.c b/reactos/ntoskrnl/ke/kqueue.c index 441d238a1db..1ef6d266a4e 100644 --- a/reactos/ntoskrnl/ke/kqueue.c +++ b/reactos/ntoskrnl/ke/kqueue.c @@ -3,7 +3,7 @@ * PURPOSE: ReactOS kernel * FILE: ntoskrnl/ke/kqueue.c * PURPOSE: Implement device queues - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) - Several optimizations and implement * usage of Inserted flag + reformat and * add debug output. @@ -33,11 +33,11 @@ KeInitializeDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue) /* Initialize the Header */ DeviceQueue->Type = DeviceQueueObject; DeviceQueue->Size = sizeof(KDEVICE_QUEUE); - + /* Initialize the Listhead and Spinlock */ InitializeListHead(&DeviceQueue->DeviceListHead); KeInitializeSpinLock(&DeviceQueue->Lock); - + /* Set it as busy */ DeviceQueue->Busy=FALSE; } @@ -58,32 +58,32 @@ KeInsertDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue, IN PKDEVICE_QUEUE_ENTRY DeviceQueueEntry) { BOOLEAN Inserted; - + DPRINT("KeInsertDeviceQueue(DeviceQueue %x)\n", DeviceQueue); ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL); /* Lock the Queue */ KeAcquireSpinLockAtDpcLevel(&DeviceQueue->Lock); - + if (!DeviceQueue->Busy) { - + /* Set it as busy */ Inserted = FALSE; DeviceQueue->Busy = TRUE; - + } else { /* Insert it into the list */ - Inserted = TRUE; - InsertTailList(&DeviceQueue->DeviceListHead, + Inserted = TRUE; + InsertTailList(&DeviceQueue->DeviceListHead, &DeviceQueueEntry->DeviceListEntry); - - + + } - + /* Sert the Insert state into the entry */ DeviceQueueEntry->Inserted = Inserted; - + /* Release lock and return */ KeReleaseSpinLockFromDpcLevel(&DeviceQueue->Lock); return Inserted; @@ -92,30 +92,30 @@ KeInsertDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue, /* * @implemented */ -BOOLEAN +BOOLEAN STDCALL KeInsertByKeyDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue, IN PKDEVICE_QUEUE_ENTRY DeviceQueueEntry, IN ULONG SortKey) { BOOLEAN Inserted; - + DPRINT("KeInsertByKeyDeviceQueue(DeviceQueue %x)\n", DeviceQueue); ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL); /* Acquire the Lock */ KeAcquireSpinLockAtDpcLevel(&DeviceQueue->Lock); - + /* Set the Sort Key */ DeviceQueueEntry->SortKey=SortKey; - + if (!DeviceQueue->Busy) { - + DeviceQueue->Busy=TRUE; Inserted = FALSE; - + } else { - + /* Insert new entry after the last entry with SortKey less or equal to passed-in SortKey */ InsertAscendingListFIFO(&DeviceQueue->DeviceListHead, KDEVICE_QUEUE_ENTRY, @@ -124,10 +124,10 @@ KeInsertByKeyDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue, SortKey); Inserted = TRUE; } - + /* Reset the Inserted State */ DeviceQueueEntry->Inserted = Inserted; - + /* Release Lock and Return */ KeReleaseSpinLockFromDpcLevel(&DeviceQueue->Lock); return Inserted; @@ -147,27 +147,27 @@ KeRemoveDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue) { PLIST_ENTRY ListEntry; PKDEVICE_QUEUE_ENTRY ReturnEntry; - + DPRINT("KeRemoveDeviceQueue(DeviceQueue %x)\n", DeviceQueue); ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL); - + /* Acquire the Lock */ KeAcquireSpinLockAtDpcLevel(&DeviceQueue->Lock); ASSERT(DeviceQueue->Busy); - + /* An attempt to remove an entry from an empty (and busy) queue sets the queue idle */ if (IsListEmpty(&DeviceQueue->DeviceListHead)) { DeviceQueue->Busy = FALSE; ReturnEntry = NULL; - + } else { - + /* Remove the Entry from the List */ ListEntry = RemoveHeadList(&DeviceQueue->DeviceListHead); - ReturnEntry = CONTAINING_RECORD(ListEntry, + ReturnEntry = CONTAINING_RECORD(ListEntry, KDEVICE_QUEUE_ENTRY, DeviceListEntry); - + /* Set it as non-inserted */ ReturnEntry->Inserted = FALSE; } @@ -190,53 +190,53 @@ KeRemoveByKeyDeviceQueue (IN PKDEVICE_QUEUE DeviceQueue, DPRINT("KeRemoveByKeyDeviceQueue(DeviceQueue %x)\n", DeviceQueue); ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL); - + /* Acquire the Lock */ KeAcquireSpinLockAtDpcLevel(&DeviceQueue->Lock); ASSERT(DeviceQueue->Busy); /* An attempt to remove an entry from an empty (and busy) queue sets the queue idle */ if (IsListEmpty(&DeviceQueue->DeviceListHead)) { - + DeviceQueue->Busy = FALSE; ReturnEntry = NULL; - + } else { - + /* Find entry with SortKey greater than or equal to the passed-in SortKey */ ListEntry = DeviceQueue->DeviceListHead.Flink; while (ListEntry != &DeviceQueue->DeviceListHead) { /* Get Entry */ - ReturnEntry = CONTAINING_RECORD(ListEntry, + ReturnEntry = CONTAINING_RECORD(ListEntry, KDEVICE_QUEUE_ENTRY, DeviceListEntry); - + /* Check if keys match */ if (ReturnEntry->SortKey >= SortKey) break; - + /* Move to next item */ ListEntry = ListEntry->Flink; } - + /* Check if we found something */ if (ListEntry == &DeviceQueue->DeviceListHead) { - + /* Not found, return the first entry */ ListEntry = RemoveHeadList(&DeviceQueue->DeviceListHead); - ReturnEntry = CONTAINING_RECORD(ListEntry, + ReturnEntry = CONTAINING_RECORD(ListEntry, KDEVICE_QUEUE_ENTRY, DeviceListEntry); } else { - + /* We found it, so just remove it */ RemoveEntryList(&ReturnEntry->DeviceListEntry); } - + /* Set it as non-inserted */ ReturnEntry->Inserted = FALSE; } - + /* Release lock and Return */ KeReleaseSpinLockFromDpcLevel(&DeviceQueue->Lock); return ReturnEntry; @@ -263,21 +263,21 @@ KeRemoveEntryDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue, { KIRQL OldIrql; BOOLEAN OldState; - + DPRINT("KeRemoveEntryDeviceQueue(DeviceQueue %x)\n", DeviceQueue); ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL); - + /* Acquire the Lock */ KeAcquireSpinLock(&DeviceQueue->Lock, &OldIrql); - + /* Check/Set Old State */ if ((OldState = DeviceQueueEntry->Inserted)) { - + /* Remove it */ DeviceQueueEntry->Inserted = FALSE; RemoveEntryList(&DeviceQueueEntry->DeviceListEntry); } - + /* Unlock and return old state */ KeReleaseSpinLock(&DeviceQueue->Lock, OldIrql); return OldState; diff --git a/reactos/ntoskrnl/ke/kthread.c b/reactos/ntoskrnl/ke/kthread.c index 1bfc3f15c31..ea2da3b21d4 100644 --- a/reactos/ntoskrnl/ke/kthread.c +++ b/reactos/ntoskrnl/ke/kthread.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/kthread.c * PURPOSE: Microkernel thread support - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) * David Welch (welch@cwcom.net) */ @@ -29,7 +29,7 @@ extern PETHREAD PspReaperList; /* FUNCTIONS *****************************************************************/ -STATIC +STATIC VOID KiRequestReschedule(CCHAR Processor) { @@ -40,39 +40,39 @@ KiRequestReschedule(CCHAR Processor) KiIpiSendRequest(1 << Processor, IPI_REQUEST_DPC); } -STATIC +STATIC VOID -KiInsertIntoThreadList(KPRIORITY Priority, +KiInsertIntoThreadList(KPRIORITY Priority, PKTHREAD Thread) { ASSERT(Ready == Thread->State); ASSERT(Thread->Priority == Priority); - + if (Priority >= MAXIMUM_PRIORITY || Priority < LOW_PRIORITY) { - + DPRINT1("Invalid thread priority (%d)\n", Priority); KEBUGCHECK(0); } - + InsertTailList(&PriorityListHead[Priority], &Thread->WaitListEntry); PriorityListMask |= (1 << Priority); } STATIC -VOID +VOID KiRemoveFromThreadList(PKTHREAD Thread) { ASSERT(Ready == Thread->State); RemoveEntryList(&Thread->WaitListEntry); if (IsListEmpty(&PriorityListHead[(ULONG)Thread->Priority])) { - + PriorityListMask &= ~(1 << Thread->Priority); } } STATIC -PKTHREAD -KiScanThreadList(KPRIORITY Priority, +PKTHREAD +KiScanThreadList(KPRIORITY Priority, KAFFINITY Affinity) { PLIST_ENTRY current_entry; @@ -80,36 +80,36 @@ KiScanThreadList(KPRIORITY Priority, ULONG Mask; Mask = (1 << Priority); - + if (PriorityListMask & Mask) { - + current_entry = PriorityListHead[Priority].Flink; - + while (current_entry != &PriorityListHead[Priority]) { - + current = CONTAINING_RECORD(current_entry, KTHREAD, WaitListEntry); - + if (current->State != Ready) { - + DPRINT1("%d/%d\n", ¤t, current->State); } - + ASSERT(current->State == Ready); - + if (current->Affinity & Affinity) { - + KiRemoveFromThreadList(current); return(current); } - + current_entry = current_entry->Flink; } } - + return(NULL); } -VOID +VOID STDCALL KiDispatchThreadNoLock(ULONG NewThreadStatus) { @@ -122,28 +122,28 @@ KiDispatchThreadNoLock(ULONG NewThreadStatus) CurrentThread, NewThreadStatus, CurrentThread->State); CurrentThread->State = (UCHAR)NewThreadStatus; - + if (NewThreadStatus == Ready) { - + KiInsertIntoThreadList(CurrentThread->Priority, CurrentThread); } Affinity = 1 << KeGetCurrentProcessorNumber(); - + for (CurrentPriority = HIGH_PRIORITY; CurrentPriority >= LOW_PRIORITY; CurrentPriority--) { - + Candidate = KiScanThreadList(CurrentPriority, Affinity); - + if (Candidate == CurrentThread) { Candidate->State = Running; - KeReleaseDispatcherDatabaseLockFromDpcLevel(); + KeReleaseDispatcherDatabaseLockFromDpcLevel(); return; } - + if (Candidate != NULL) { - + PKTHREAD OldThread; PKTHREAD IdleThread; @@ -156,11 +156,11 @@ KiDispatchThreadNoLock(ULONG NewThreadStatus) IdleThread = KeGetCurrentPrcb()->IdleThread; if (OldThread == IdleThread) { - + IdleProcessorMask &= ~Affinity; - + } else if (CurrentThread == IdleThread) { - + IdleProcessorMask |= Affinity; } @@ -173,15 +173,15 @@ KiDispatchThreadNoLock(ULONG NewThreadStatus) return; } } - + DPRINT1("CRITICAL: No threads are ready (CPU%d)\n", KeGetCurrentProcessorNumber()); KEBUGCHECK(0); } VOID STDCALL -KiBlockThread(PNTSTATUS Status, - UCHAR Alertable, +KiBlockThread(PNTSTATUS Status, + UCHAR Alertable, ULONG WaitMode, UCHAR WaitReason) { @@ -189,9 +189,9 @@ KiBlockThread(PNTSTATUS Status, PKWAIT_BLOCK WaitBlock; if (Thread->ApcState.KernelApcPending) { - + DPRINT("Dispatching Thread as ready (APC!)\n"); - + /* Remove Waits */ WaitBlock = Thread->WaitBlockList; do { @@ -199,7 +199,7 @@ KiBlockThread(PNTSTATUS Status, WaitBlock = WaitBlock->NextWaitBlock; } while (WaitBlock != Thread->WaitBlockList); Thread->WaitBlockList = NULL; - + /* Dispatch it and return status */ KiDispatchThreadNoLock (Ready); if (Status != NULL) *Status = STATUS_KERNEL_APC; @@ -211,18 +211,18 @@ KiBlockThread(PNTSTATUS Status, Thread->Alertable = Alertable; Thread->WaitMode = (UCHAR)WaitMode; Thread->WaitReason = WaitReason; - + /* Dispatch it and return status */ KiDispatchThreadNoLock(Waiting); DPRINT("Dispatching Thread as blocked: %d\n", Thread->WaitStatus); if (Status != NULL) *Status = Thread->WaitStatus; } - + DPRINT("Releasing Dispatcher Lock\n"); KfLowerIrql(Thread->WaitIrql); } -VOID +VOID STDCALL KiDispatchThread(ULONG NewThreadStatus) { @@ -231,7 +231,7 @@ KiDispatchThread(ULONG NewThreadStatus) if (!DoneInitYet || KeGetCurrentPrcb()->IdleThread == NULL) { return; } - + OldIrql = KeAcquireDispatcherDatabaseLock(); KiDispatchThreadNoLock(NewThreadStatus); KeLowerIrql(OldIrql); @@ -239,23 +239,23 @@ KiDispatchThread(ULONG NewThreadStatus) VOID STDCALL -KiUnblockThread(PKTHREAD Thread, - PNTSTATUS WaitStatus, +KiUnblockThread(PKTHREAD Thread, + PNTSTATUS WaitStatus, KPRIORITY Increment) { if (Terminated == Thread->State) { DPRINT("Can't unblock thread 0x%x because it's terminating\n", Thread); - + } else if (Ready == Thread->State || Running == Thread->State) { - + DPRINT("Can't unblock thread 0x%x because it's %s\n", Thread, (Thread->State == Ready ? "ready" : "running")); - + } else { - + ULONG Processor; KAFFINITY Affinity; @@ -263,46 +263,46 @@ KiUnblockThread(PKTHREAD Thread, /* No it's not... i'll fix it later-- Alex */ if (Thread->Priority < LOW_REALTIME_PRIORITY && Thread->BasePriority < LOW_REALTIME_PRIORITY - 2) { - + if (!Thread->PriorityDecrement && !Thread->DisableBoost) { - + Thread->Priority = Thread->BasePriority + Increment; Thread->PriorityDecrement = Increment; } - + } else { - + Thread->Quantum = Thread->QuantumReset; } - + if (WaitStatus != NULL) { - + Thread->WaitStatus = *WaitStatus; } - + Thread->State = Ready; KiInsertIntoThreadList(Thread->Priority, Thread); Processor = KeGetCurrentProcessorNumber(); Affinity = Thread->Affinity; - + if (!(IdleProcessorMask & (1 << Processor) & Affinity) && (IdleProcessorMask & ~(1 << Processor) & Affinity)) { - + ULONG i; - + for (i = 0; i < KeNumberProcessors - 1; i++) { - + Processor++; - + if (Processor >= KeNumberProcessors) { - + Processor = 0; } - + if (IdleProcessorMask & (1 << Processor) & Affinity) { -#if 0 +#if 0 /* FIXME: - * Reschedule the threads on an other processor + * Reschedule the threads on an other processor */ KeReleaseDispatcherDatabaseLockFromDpcLevel(); KiRequestReschedule(Processor); @@ -311,11 +311,11 @@ KiUnblockThread(PKTHREAD Thread, break; } } - } + } } } -VOID +VOID STDCALL KiSuspendThreadKernelRoutine(PKAPC Apc, PKNORMAL_ROUTINE* NormalRoutine, @@ -325,14 +325,14 @@ KiSuspendThreadKernelRoutine(PKAPC Apc, { } -VOID +VOID STDCALL KiSuspendThreadNormalRoutine(PVOID NormalContext, PVOID SystemArgument1, PVOID SystemArgument2) { PKTHREAD CurrentThread = KeGetCurrentThread(); - + /* Non-alertable kernel-mode suspended wait */ DPRINT("Waiting...\n"); KeWaitForSingleObject(&CurrentThread->SuspendSemaphore, @@ -349,8 +349,8 @@ KiSuspendThreadNormalRoutine(PVOID NormalContext, /* * @implemented */ -PKTHREAD -STDCALL +PKTHREAD +STDCALL KeGetCurrentThread(VOID) { #ifdef CONFIG_SMP @@ -376,7 +376,7 @@ KeSetPreviousMode(ULONG Mode) /* * @implemented */ -KPROCESSOR_MODE +KPROCESSOR_MODE STDCALL KeGetPreviousMode(VOID) { @@ -391,36 +391,36 @@ KeRundownThread(VOID) PKTHREAD Thread = KeGetCurrentThread(); PLIST_ENTRY CurrentEntry; PKMUTANT Mutant; - + DPRINT("KeRundownThread: %x\n", Thread); /* Lock the Dispatcher Database */ OldIrql = KeAcquireDispatcherDatabaseLock(); while (!IsListEmpty(&Thread->MutantListHead)) { - + /* Get the Mutant */ CurrentEntry = RemoveHeadList(&Thread->MutantListHead); Mutant = CONTAINING_RECORD(CurrentEntry, KMUTANT, MutantListEntry); ASSERT(Mutant->ApcDisable == 0); - + /* Uncondtionally abandon it */ DPRINT("Abandonning the Mutant\n"); Mutant->Header.SignalState = 1; Mutant->Abandoned = TRUE; Mutant->OwnerThread = NULL; RemoveEntryList(&Mutant->MutantListEntry); - + /* Check if the Wait List isn't empty */ DPRINT("Checking whether to wake the Mutant\n"); if (!IsListEmpty(&Mutant->Header.WaitListHead)) { - + /* Wake the Mutant */ DPRINT("Waking the Mutant\n"); KiWaitTest(&Mutant->Header, MUTANT_INCREMENT); } } - + /* Release the Lock */ KeReleaseDispatcherDatabaseLock(OldIrql); } @@ -431,7 +431,7 @@ KeResumeThread(PKTHREAD Thread) { ULONG PreviousCount; KIRQL OldIrql; - + DPRINT("KeResumeThread (Thread %p called). %x, %x\n", Thread, Thread->SuspendCount, Thread->FreezeCount); /* Lock the Dispatcher */ @@ -442,18 +442,18 @@ KeResumeThread(PKTHREAD Thread) /* Check if it existed */ if (PreviousCount) { - + Thread->SuspendCount--; - + /* Decrease the current Suspend Count and Check Freeze Count */ if ((!Thread->SuspendCount) && (!Thread->FreezeCount)) { - + /* Signal the Suspend Semaphore */ Thread->SuspendSemaphore.Header.SignalState++; KiWaitTest(&Thread->SuspendSemaphore.Header, IO_NO_INCREMENT); } } - + /* Release Lock and return the Old State */ KeReleaseDispatcherDatabaseLock(OldIrql); return PreviousCount; @@ -479,22 +479,22 @@ KeFreezeAllThreads(PKPROCESS Process) /* Acquire Lock */ OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* Loop the Process's Threads */ CurrentEntry = Process->ThreadListHead.Flink; while (CurrentEntry != &Process->ThreadListHead) { /* Get the Thread */ Current = CONTAINING_RECORD(CurrentEntry, KTHREAD, ThreadListEntry); - + /* Make sure it's not ours */ if (Current == CurrentThread) continue; - + /* Make sure it wasn't already frozen, and that it's not suspended */ if (!(++Current->FreezeCount) && !(Current->SuspendCount)) { /* Insert the APC */ - if (!KiInsertQueueApc(&Current->SuspendApc, IO_NO_INCREMENT)) + if (!KiInsertQueueApc(&Current->SuspendApc, IO_NO_INCREMENT)) { /* Unsignal the Semaphore, the APC already got inserted */ Current->SuspendSemaphore.Header.SignalState--; @@ -507,7 +507,7 @@ KeFreezeAllThreads(PKPROCESS Process) /* Release the lock */ KeReleaseDispatcherDatabaseLock(OldIrql); } - + NTSTATUS STDCALL KeSuspendThread(PKTHREAD Thread) @@ -516,27 +516,27 @@ KeSuspendThread(PKTHREAD Thread) KIRQL OldIrql; DPRINT("KeSuspendThread (Thread %p called). %x, %x\n", Thread, Thread->SuspendCount, Thread->FreezeCount); - + /* Lock the Dispatcher */ OldIrql = KeAcquireDispatcherDatabaseLock(); /* Save the Old Count */ PreviousCount = Thread->SuspendCount; - + /* Increment it */ Thread->SuspendCount++; - + /* Check if we should suspend it */ if (!PreviousCount && !Thread->FreezeCount) { - + /* Insert the APC */ if (!KiInsertQueueApc(&Thread->SuspendApc, IO_NO_INCREMENT)) { - + /* Unsignal the Semaphore, the APC already got inserted */ Thread->SuspendSemaphore.Header.SignalState--; } } - + /* Release Lock and return the Old State */ KeReleaseDispatcherDatabaseLock(OldIrql); return PreviousCount; @@ -548,25 +548,25 @@ KeForceResumeThread(IN PKTHREAD Thread) { KIRQL OldIrql; ULONG PreviousCount; - + /* Lock the Dispatcher Database and the APC Queue */ OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* Save the old Suspend Count */ - PreviousCount = Thread->SuspendCount + Thread->FreezeCount; - + PreviousCount = Thread->SuspendCount + Thread->FreezeCount; + /* If the thread is suspended, wake it up!!! */ if (PreviousCount) { - + /* Unwait it completely */ Thread->SuspendCount = 0; Thread->FreezeCount = 0; - + /* Signal and satisfy */ Thread->SuspendSemaphore.Header.SignalState++; KiWaitTest(&Thread->SuspendSemaphore.Header, IO_NO_INCREMENT); } - + /* Release Lock and return the Old State */ KeReleaseDispatcherDatabaseLock(OldIrql); return PreviousCount; @@ -580,36 +580,36 @@ KeAlertResumeThread(IN PKTHREAD Thread) KIRQL OldIrql; ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL); - + /* Lock the Dispatcher Database and the APC Queue */ OldIrql = KeAcquireDispatcherDatabaseLock(); KiAcquireSpinLock(&Thread->ApcQueueLock); /* Return if Thread is already alerted. */ if (Thread->Alerted[KernelMode] == FALSE) { - + /* If it's Blocked, unblock if it we should */ if (Thread->State == Waiting && Thread->Alertable) { - + DPRINT("Aborting Wait\n"); KiAbortWaitThread(Thread, STATUS_ALERTED, THREAD_ALERT_INCREMENT); - + } else { - + /* If not, simply Alert it */ Thread->Alerted[KernelMode] = TRUE; } } - + /* Save the old Suspend Count */ - PreviousCount = Thread->SuspendCount; - + PreviousCount = Thread->SuspendCount; + /* If the thread is suspended, decrease one of the suspend counts */ if (PreviousCount) { - + /* Decrease count. If we are now zero, unwait it completely */ if (--Thread->SuspendCount) { - + /* Signal and satisfy */ Thread->SuspendSemaphore.Header.SignalState++; KiWaitTest(&Thread->SuspendSemaphore.Header, IO_NO_INCREMENT); @@ -624,7 +624,7 @@ KeAlertResumeThread(IN PKTHREAD Thread) BOOLEAN STDCALL -KeAlertThread(PKTHREAD Thread, +KeAlertThread(PKTHREAD Thread, KPROCESSOR_MODE AlertMode) { KIRQL OldIrql; @@ -632,31 +632,31 @@ KeAlertThread(PKTHREAD Thread, /* Acquire the Dispatcher Database Lock */ OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* Save the Previous State */ PreviousState = Thread->Alerted[AlertMode]; - + /* Return if Thread is already alerted. */ if (PreviousState == FALSE) { - + /* If it's Blocked, unblock if it we should */ - if (Thread->State == Waiting && + if (Thread->State == Waiting && (AlertMode == KernelMode || Thread->WaitMode == AlertMode) && Thread->Alertable) { - + DPRINT("Aborting Wait\n"); KiAbortWaitThread(Thread, STATUS_ALERTED, THREAD_ALERT_INCREMENT); - + } else { - + /* If not, simply Alert it */ Thread->Alerted[AlertMode] = TRUE; } } - + /* Release the Dispatcher Lock */ KeReleaseDispatcherDatabaseLock(OldIrql); - + /* Return the old state */ return PreviousState; } @@ -682,32 +682,32 @@ KeCapturePersistentThreadState(IN PVOID CurrentThread, */ VOID STDCALL -KeInitializeThread(PKPROCESS Process, - PKTHREAD Thread, +KeInitializeThread(PKPROCESS Process, + PKTHREAD Thread, PKSYSTEM_ROUTINE SystemRoutine, PKSTART_ROUTINE StartRoutine, PVOID StartContext, PCONTEXT Context, PVOID Teb, PVOID KernelStack) -{ +{ /* Initalize the Dispatcher Header */ DPRINT("Initializing Dispatcher Header for New Thread: %x in Process: %x\n", Thread, Process); KeInitializeDispatcherHeader(&Thread->DispatcherHeader, ThreadObject, sizeof(KTHREAD), FALSE); - + DPRINT("Thread Header Created. SystemRoutine: %x, StartRoutine: %x with Context: %x\n", SystemRoutine, StartRoutine, StartContext); DPRINT("UserMode Information. Context: %x, Teb: %x\n", Context, Teb); - + /* Initialize the Mutant List */ InitializeListHead(&Thread->MutantListHead); - + /* Setup the Service Descriptor Table for Native Calls */ Thread->ServiceTable = KeServiceDescriptorTable; - + /* Setup APC Fields */ InitializeListHead(&Thread->ApcState.ApcListHead[0]); InitializeListHead(&Thread->ApcState.ApcListHead[1]); @@ -716,8 +716,8 @@ KeInitializeThread(PKPROCESS Process, Thread->ApcStatePointer[AttachedApcEnvironment] = &Thread->SavedApcState; Thread->ApcStateIndex = OriginalApcEnvironment; KeInitializeSpinLock(&Thread->ApcQueueLock); - - /* Initialize the Suspend APC */ + + /* Initialize the Suspend APC */ KeInitializeApc(&Thread->SuspendApc, Thread, OriginalApcEnvironment, @@ -726,10 +726,10 @@ KeInitializeThread(PKPROCESS Process, KiSuspendThreadNormalRoutine, KernelMode, NULL); - + /* Initialize the Suspend Semaphore */ - KeInitializeSemaphore(&Thread->SuspendSemaphore, 0, 128); - + KeInitializeSemaphore(&Thread->SuspendSemaphore, 0, 128); + /* FIXME OPTIMIZATION OF DOOM. DO NOT ENABLE FIXME */ #if 0 Thread->WaitBlock[3].Object = (PVOID)&Thread->Timer; @@ -741,33 +741,33 @@ KeInitializeThread(PKPROCESS Process, &Thread->WaitBlock[3].WaitListEntry); #endif KeInitializeTimer(&Thread->Timer); - + /* Set the TEB */ Thread->Teb = Teb; - + /* Set the Thread Stacks */ Thread->InitialStack = (PCHAR)KernelStack + MM_STACK_SIZE; Thread->StackBase = (PCHAR)KernelStack + MM_STACK_SIZE; Thread->StackLimit = (ULONG_PTR)KernelStack; Thread->KernelStackResident = TRUE; - - /* - * Establish the pde's for the new stack and the thread structure within the + + /* + * Establish the pde's for the new stack and the thread structure within the * address space of the new process. They are accessed while taskswitching or - * while handling page faults. At this point it isn't possible to call the - * page fault handler for the missing pde's. + * while handling page faults. At this point it isn't possible to call the + * page fault handler for the missing pde's. */ MmUpdatePageDir((PEPROCESS)Process, (PVOID)Thread->StackLimit, MM_STACK_SIZE); MmUpdatePageDir((PEPROCESS)Process, (PVOID)Thread, sizeof(ETHREAD)); - + /* Initalize the Thread Context */ DPRINT("Initializing the Context for the thread: %x\n", Thread); - KiArchInitThreadWithContext(Thread, + KiArchInitThreadWithContext(Thread, SystemRoutine, StartRoutine, StartContext, Context); - + /* Setup scheduler Fields based on Parent */ DPRINT("Thread context created, setting Scheduler Data\n"); Thread->BasePriority = Process->BasePriority; @@ -779,12 +779,12 @@ KeInitializeThread(PKPROCESS Process, Thread->DisableBoost = Process->DisableBoost; Thread->AutoAlignment = Process->AutoAlignment; Thread->Iopl = Process->Iopl; - + /* Set the Thread to initalized */ Thread->State = Initialized; - - /* - * Insert the Thread into the Process's Thread List + + /* + * Insert the Thread into the Process's Thread List * Note, this is the KTHREAD Thread List. It is removed in * ke/kthread.c!KeTerminateThread. */ @@ -813,7 +813,7 @@ KeQueryRuntimeThread(IN PKTHREAD Thread, { /* Return the User Time */ *UserTime = Thread->UserTime; - + /* Return the Kernel Time */ return Thread->KernelTime; } @@ -828,7 +828,7 @@ KeSetKernelStackSwapEnable(IN BOOLEAN Enable) PKTHREAD Thread = KeGetCurrentThread(); BOOLEAN PreviousState; KIRQL OldIrql; - + /* Lock the Dispatcher Database */ OldIrql = KeAcquireDispatcherDatabaseLock(); @@ -840,7 +840,7 @@ KeSetKernelStackSwapEnable(IN BOOLEAN Enable) /* No, Release Lock */ KeReleaseDispatcherDatabaseLock(OldIrql); - + /* Return Old State */ return PreviousState; } @@ -856,7 +856,7 @@ KeRevertToUserAffinityThread(VOID) KIRQL OldIrql; ASSERT(CurrentThread->SystemAffinityActive != FALSE); - + /* Lock the Dispatcher Database */ OldIrql = KeAcquireDispatcherDatabaseLock(); @@ -865,15 +865,15 @@ KeRevertToUserAffinityThread(VOID) /* Disable System Affinity */ CurrentThread->SystemAffinityActive = FALSE; - + /* Check if we need to Dispatch a New thread */ if (CurrentThread->Affinity & (1 << KeGetCurrentProcessorNumber())) { - + /* No, just release */ KeReleaseDispatcherDatabaseLock(OldIrql); - + } else { - + /* We need to dispatch a new thread */ CurrentThread->WaitIrql = OldIrql; KiDispatchThreadNoLock(Ready); @@ -891,7 +891,7 @@ KeSetIdealProcessorThread(IN PKTHREAD Thread, { CCHAR PreviousIdealProcessor; KIRQL OldIrql; - + /* Lock the Dispatcher Database */ OldIrql = KeAcquireDispatcherDatabaseLock(); @@ -900,10 +900,10 @@ KeSetIdealProcessorThread(IN PKTHREAD Thread, /* Set New Ideal Processor */ Thread->IdealProcessor = Processor; - + /* Release Lock */ - KeReleaseDispatcherDatabaseLock(OldIrql); - + KeReleaseDispatcherDatabaseLock(OldIrql); + /* Return Old Ideal Processor */ return PreviousIdealProcessor; } @@ -919,7 +919,7 @@ KeSetSystemAffinityThread(IN KAFFINITY Affinity) KIRQL OldIrql; ASSERT(Affinity & ((1 << KeNumberProcessors) - 1)); - + /* Lock the Dispatcher Database */ OldIrql = KeAcquireDispatcherDatabaseLock(); @@ -928,15 +928,15 @@ KeSetSystemAffinityThread(IN KAFFINITY Affinity) /* Enable System Affinity */ CurrentThread->SystemAffinityActive = TRUE; - + /* Check if we need to Dispatch a New thread */ if (Affinity & (1 << KeGetCurrentProcessorNumber())) { - + /* No, just release */ KeReleaseDispatcherDatabaseLock(OldIrql); - + } else { - + /* We need to dispatch a new thread */ CurrentThread->WaitIrql = OldIrql; KiDispatchThreadNoLock(Ready); @@ -980,9 +980,9 @@ KeSetBasePriorityThread (PKTHREAD Thread, /* * @implemented */ -KPRIORITY +KPRIORITY STDCALL -KeSetPriorityThread(PKTHREAD Thread, +KeSetPriorityThread(PKTHREAD Thread, KPRIORITY Priority) { KPRIORITY OldPriority; @@ -993,7 +993,7 @@ KeSetPriorityThread(PKTHREAD Thread, PKPCR Pcr; if (Priority < LOW_PRIORITY || Priority >= MAXIMUM_PRIORITY) { - + KEBUGCHECK(0); } @@ -1002,44 +1002,44 @@ KeSetPriorityThread(PKTHREAD Thread, OldPriority = Thread->Priority; if (OldPriority != Priority) { - + CurrentThread = KeGetCurrentThread(); - + if (Thread->State == Ready) { - + KiRemoveFromThreadList(Thread); Thread->BasePriority = Thread->Priority = (CHAR)Priority; KiInsertIntoThreadList(Priority, Thread); - + if (CurrentThread->Priority < Priority) { - + KiDispatchThreadNoLock(Ready); KeLowerIrql(OldIrql); return (OldPriority); } - + } else if (Thread->State == Running) { - + Thread->BasePriority = Thread->Priority = (CHAR)Priority; - + if (Priority < OldPriority) { - + /* Check for threads with a higher priority */ Mask = ~((1 << (Priority + 1)) - 1); if (PriorityListMask & Mask) { - + if (Thread == CurrentThread) { - + KiDispatchThreadNoLock(Ready); KeLowerIrql(OldIrql); return (OldPriority); - + } else { - + for (i = 0; i < KeNumberProcessors; i++) { - + Pcr = (PKPCR)(KPCR_BASE + i * PAGE_SIZE); - + if (Pcr->Prcb->CurrentThread == Thread) { KeReleaseDispatcherDatabaseLockFromDpcLevel(); @@ -1052,11 +1052,11 @@ KeSetPriorityThread(PKTHREAD Thread, } } } else { - + Thread->BasePriority = Thread->Priority = (CHAR)Priority; } } - + KeReleaseDispatcherDatabaseLock(OldIrql); return(OldPriority); } @@ -1066,7 +1066,7 @@ KeSetPriorityThread(PKTHREAD Thread, * * Sets thread's affinity */ -NTSTATUS +NTSTATUS STDCALL KeSetAffinityThread(PKTHREAD Thread, KAFFINITY Affinity) @@ -1083,38 +1083,38 @@ KeSetAffinityThread(PKTHREAD Thread, OldIrql = KeAcquireDispatcherDatabaseLock(); Thread->UserAffinity = Affinity; - + if (Thread->SystemAffinityActive == FALSE) { - + Thread->Affinity = Affinity; - + if (Thread->State == Running) { - + ProcessorMask = 1 << KeGetCurrentKPCR()->ProcessorNumber; if (Thread == KeGetCurrentThread()) { - + if (!(Affinity & ProcessorMask)) { - + KiDispatchThreadNoLock(Ready); KeLowerIrql(OldIrql); return STATUS_SUCCESS; } - + } else { - + for (i = 0; i < KeNumberProcessors; i++) { - + Pcr = (PKPCR)(KPCR_BASE + i * PAGE_SIZE); if (Pcr->Prcb->CurrentThread == Thread) { - + if (!(Affinity & ProcessorMask)) { - + KeReleaseDispatcherDatabaseLockFromDpcLevel(); KiRequestReschedule(i); KeLowerIrql(OldIrql); return STATUS_SUCCESS; } - + break; } } @@ -1123,7 +1123,7 @@ KeSetAffinityThread(PKTHREAD Thread, } } } - + KeReleaseDispatcherDatabaseLock(OldIrql); return STATUS_SUCCESS; } @@ -1138,23 +1138,23 @@ KeTerminateThread(IN KPRIORITY Increment) { KIRQL OldIrql; PKTHREAD Thread = KeGetCurrentThread(); - + /* Lock the Dispatcher Database and the APC Queue */ DPRINT("Terminating\n"); OldIrql = KeAcquireDispatcherDatabaseLock(); /* Remove the thread from the list */ RemoveEntryList(&Thread->ThreadListEntry); - + /* Insert into the Reaper List */ DPRINT("List: %p\n", PspReaperList); ((PETHREAD)Thread)->ReaperLink = PspReaperList; PspReaperList = (PETHREAD)Thread; DPRINT("List: %p\n", PspReaperList); - + /* Check if it's active */ if (PspReaping == FALSE) { - + /* Activate it. We use the internal function for speed, and use the Hyper Critical Queue */ PspReaping = TRUE; DPRINT("Terminating\n"); @@ -1162,23 +1162,23 @@ KeTerminateThread(IN KPRIORITY Increment) &PspReaperWorkItem.List, FALSE); } - + /* Handle Kernel Queues */ if (Thread->Queue) { - + DPRINT("Waking Queue\n"); RemoveEntryList(&Thread->QueueListEntry); KiWakeQueue(Thread->Queue); } - + /* Signal the thread */ Thread->DispatcherHeader.SignalState = TRUE; if (IsListEmpty(&Thread->DispatcherHeader.WaitListHead) != TRUE) { - + /* Satisfy waits */ KiWaitTest((PVOID)Thread, Increment); } - + /* Find a new Thread */ KiDispatchThreadNoLock(Terminated); } @@ -1194,27 +1194,27 @@ KeTestAlertThread(IN KPROCESSOR_MODE AlertMode) KIRQL OldIrql; PKTHREAD Thread = KeGetCurrentThread(); BOOLEAN OldState; - + ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL); - + /* Lock the Dispatcher Database and the APC Queue */ OldIrql = KeAcquireDispatcherDatabaseLock(); KiAcquireSpinLock(&Thread->ApcQueueLock); - + /* Save the old State */ OldState = Thread->Alerted[AlertMode]; - + /* If the Thread is Alerted, Clear it */ if (OldState) { - + Thread->Alerted[AlertMode] = FALSE; - + } else if ((AlertMode == UserMode) && (!IsListEmpty(&Thread->ApcState.ApcListHead[UserMode]))) { - + /* If the mode is User and the Queue isn't empty, set Pending */ Thread->ApcState.UserApcPending = TRUE; } - + /* Release Locks and return the Old State */ KiReleaseSpinLock(&Thread->ApcQueueLock); KeReleaseDispatcherDatabaseLock(OldIrql); @@ -1225,21 +1225,21 @@ VOID KiServiceCheck (VOID) { PKTHREAD Thread = KeGetCurrentThread(); - + /* Check if we need to inialize Win32 for this Thread */ if (Thread->ServiceTable != KeServiceDescriptorTableShadow) { - - /* We do. Initialize it and save the new table */ + + /* We do. Initialize it and save the new table */ PsInitWin32Thread((PETHREAD)Thread); Thread->ServiceTable = KeServiceDescriptorTableShadow; } } -/* +/* * * NOT EXPORTED */ -NTSTATUS +NTSTATUS STDCALL NtAlertResumeThread(IN HANDLE ThreadHandle, OUT PULONG SuspendCount) @@ -1251,20 +1251,20 @@ NtAlertResumeThread(IN HANDLE ThreadHandle, /* Check if parameters are valid */ if(PreviousMode != KernelMode) { - + _SEH_TRY { - + ProbeForWrite(SuspendCount, sizeof(HANDLE), sizeof(ULONG)); - + } _SEH_HANDLE { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } - + /* Reference the Object */ Status = ObReferenceObjectByHandle(ThreadHandle, THREAD_SUSPEND_RESUME, @@ -1272,40 +1272,40 @@ NtAlertResumeThread(IN HANDLE ThreadHandle, PreviousMode, (PVOID*)&Thread, NULL); - - /* Check for Success */ + + /* Check for Success */ if (NT_SUCCESS(Status)) { - + /* Call the Kernel Function */ PreviousState = KeAlertResumeThread(&Thread->Tcb); - + /* Dereference Object */ ObDereferenceObject(Thread); - + if (SuspendCount) { - + _SEH_TRY { - + *SuspendCount = PreviousState; - + } _SEH_HANDLE { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } } - + /* Return status */ return Status; } -/* +/* * @implemented * * EXPORTED */ -NTSTATUS +NTSTATUS STDCALL NtAlertThread (IN HANDLE ThreadHandle) { @@ -1320,27 +1320,27 @@ NtAlertThread (IN HANDLE ThreadHandle) PreviousMode, (PVOID*)&Thread, NULL); - - /* Check for Success */ + + /* Check for Success */ if (NT_SUCCESS(Status)) { - - /* + + /* * Do an alert depending on the processor mode. If some kmode code wants to * enforce a umode alert it should call KeAlertThread() directly. If kmode * code wants to do a kmode alert it's sufficient to call it with Zw or just - * use KeAlertThread() directly + * use KeAlertThread() directly */ KeAlertThread(&Thread->Tcb, PreviousMode); - + /* Dereference Object */ ObDereferenceObject(Thread); } - + /* Return status */ return Status; } -NTSTATUS +NTSTATUS STDCALL NtDelayExecution(IN BOOLEAN Alertable, IN PLARGE_INTEGER DelayInterval) @@ -1348,22 +1348,22 @@ NtDelayExecution(IN BOOLEAN Alertable, KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); LARGE_INTEGER SafeInterval; NTSTATUS Status; - + /* Check if parameters are valid */ if(PreviousMode != KernelMode) { - + _SEH_TRY { - + ProbeForRead(DelayInterval, sizeof(LARGE_INTEGER), sizeof(ULONG)); - + /* make a copy on the kernel stack and let DelayInterval point to it so we don't need to wrap KeDelayExecutionThread in SEH! */ SafeInterval = *DelayInterval; - + } _SEH_HANDLE { - + Status = _SEH_GetExceptionCode(); } _SEH_END; } @@ -1372,7 +1372,7 @@ NtDelayExecution(IN BOOLEAN Alertable, Status = KeDelayExecutionThread(PreviousMode, Alertable, &SafeInterval); - + /* Return Status */ return Status; } diff --git a/reactos/ntoskrnl/ke/main.c b/reactos/ntoskrnl/ke/main.c index 1a88704240d..c4299a1d27e 100644 --- a/reactos/ntoskrnl/ke/main.c +++ b/reactos/ntoskrnl/ke/main.c @@ -86,22 +86,22 @@ __attribute((noinline)) KiSystemStartup(BOOLEAN BootProcessor) { DPRINT("KiSystemStartup(%d)\n", BootProcessor); - + /* Initialize the Application Processor */ if (!BootProcessor) KeApplicationProcessorInit(); - + /* Initialize the Processor with HAL */ HalInitializeProcessor(KeNumberProcessors, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); /* Load the Kernel if this is the Boot CPU, else inialize the App CPU only */ if (BootProcessor) { - + /* Initialize the Kernel Executive */ ExpInitializeExecutive(); - + /* Free Initial Memory */ MiFreeInitMemory(); - + /* Never returns */ #if 0 /* FIXME: @@ -114,17 +114,17 @@ KiSystemStartup(BOOLEAN BootProcessor) Timeout.QuadPart = 0x7fffffffffffffffLL; KeDelayExecutionThread(KernelMode, FALSE, &Timeout); } -#endif +#endif } else { - + /* Do application processor initialization */ KeApplicationProcessorInitDispatcher(); - + /* Lower IRQL and go to Idle Thread */ KeLowerIrql(PASSIVE_LEVEL); PsIdleThreadMain(NULL); } - + /* Bug Check and loop forever if anything failed */ KEBUGCHECK(0); for(;;); @@ -133,14 +133,14 @@ KiSystemStartup(BOOLEAN BootProcessor) /* * FUNCTION: Called by the boot loader to start the kernel * ARGUMENTS: - * LoaderBlock = Pointer to boot parameters initialized by the boot + * LoaderBlock = Pointer to boot parameters initialized by the boot * loader * NOTE: The boot parameters are stored in low memory which will become * invalid after the memory managment is initialized so we make a local copy. */ -VOID +VOID INIT_FUNCTION -_main(ULONG MultiBootMagic, +_main(ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock) { ULONG i; @@ -157,10 +157,10 @@ _main(ULONG MultiBootMagic, trap_stack_top = trap_stack + 3 * PAGE_SIZE; init_stack = PAGE_ROUND_UP(&kernel_stack); init_stack_top = init_stack + 3 * PAGE_SIZE; - + /* Copy the Loader Block Data locally since Low-Memory will be wiped */ memcpy(&KeLoaderBlock, _LoaderBlock, sizeof(LOADER_PARAMETER_BLOCK)); - memcpy(&KeLoaderModules[1], + memcpy(&KeLoaderModules[1], (PVOID)KeLoaderBlock.ModsAddr, sizeof(LOADER_MODULE) * KeLoaderBlock.ModsCount); KeLoaderBlock.ModsCount++; @@ -168,48 +168,48 @@ _main(ULONG MultiBootMagic, /* Save the Base Address */ MmSystemRangeStart = (PVOID)KeLoaderBlock.KernelBase; - + /* Set the Command Line */ strcpy(KeLoaderCommandLine, (PCHAR)_LoaderBlock->CommandLine); KeLoaderBlock.CommandLine = (ULONG)KeLoaderCommandLine; - + /* Write the first Module (the Kernel) */ strcpy(KeLoaderModuleStrings[0], "ntoskrnl.exe"); KeLoaderModules[0].String = (ULONG)KeLoaderModuleStrings[0]; KeLoaderModules[0].ModStart = KERNEL_BASE; - + /* Read PE Data */ NtHeader = RtlImageNtHeader((PVOID)KeLoaderModules[0].ModStart); OptHead = &NtHeader->OptionalHeader; - + /* Set Kernel Ending */ KeLoaderModules[0].ModEnd = KeLoaderModules[0].ModStart + PAGE_ROUND_UP((ULONG)OptHead->SizeOfImage); - + /* Create a block for each module */ - for (i = 1; i < KeLoaderBlock.ModsCount; i++) { - + for (i = 1; i < KeLoaderBlock.ModsCount; i++) { + /* Check if we have to copy the path or not */ if ((s = strrchr((PCHAR)KeLoaderModules[i].String, '/')) != 0) { - + strcpy(KeLoaderModuleStrings[i], s + 1); - + } else { - + strcpy(KeLoaderModuleStrings[i], (PCHAR)KeLoaderModules[i].String); } - - /* Substract the base Address in Physical Memory */ + + /* Substract the base Address in Physical Memory */ KeLoaderModules[i].ModStart -= 0x200000; - + /* Add the Kernel Base Address in Virtual Memory */ KeLoaderModules[i].ModStart += KERNEL_BASE; - - /* Substract the base Address in Physical Memory */ + + /* Substract the base Address in Physical Memory */ KeLoaderModules[i].ModEnd -= 0x200000; - + /* Add the Kernel Base Address in Virtual Memory */ KeLoaderModules[i].ModEnd += KERNEL_BASE; - + /* Select the proper String */ KeLoaderModules[i].String = (ULONG)KeLoaderModuleStrings[i]; } @@ -219,29 +219,29 @@ _main(ULONG MultiBootMagic, /* Low level architecture specific initialization */ KeInit1((PCHAR)KeLoaderBlock.CommandLine, &LastKernelAddress); - + /* Select the HAL Base */ HalBase = KeLoaderModules[1].ModStart; - + /* Choose Driver Base */ DriverBase = LastKernelAddress; LdrHalBase = (ULONG_PTR)DriverBase; - + /* Initialize Module Management */ LdrInitModuleManagement(); - + /* Load HAL.DLL with the PE Loader */ - LdrSafePEProcessModule((PVOID)HalBase, - (PVOID)DriverBase, - (PVOID)KERNEL_BASE, + LdrSafePEProcessModule((PVOID)HalBase, + (PVOID)DriverBase, + (PVOID)KERNEL_BASE, &DriverSize); - + /* Increase the last kernel address with the size of HAL */ LastKernelAddress += PAGE_ROUND_UP(DriverSize); /* Load the Kernel with the PE Loader */ - LdrSafePEProcessModule((PVOID)KERNEL_BASE, - (PVOID)KERNEL_BASE, + LdrSafePEProcessModule((PVOID)KERNEL_BASE, + (PVOID)KERNEL_BASE, (PVOID)DriverBase, &DriverSize); @@ -251,40 +251,40 @@ _main(ULONG MultiBootMagic, KeMemoryMapRangeCount = 0; if (KeLoaderBlock.Flags & MB_FLAGS_MMAP_INFO) { - + /* We have a memory map from the nice BIOS */ size = *((PULONG)(KeLoaderBlock.MmapAddr - sizeof(ULONG))); i = 0; - + /* Map it until we run out of size */ while (i < KeLoaderBlock.MmapLength) { - + /* Copy into the Kernel Memory Map */ memcpy (&KeMemoryMap[KeMemoryMapRangeCount], (PVOID)(KeLoaderBlock.MmapAddr + i), sizeof(ADDRESS_RANGE)); - + /* Increase Memory Map Count */ KeMemoryMapRangeCount++; - + /* Increase Size */ i += size; } - + /* Save data */ KeLoaderBlock.MmapLength = KeMemoryMapRangeCount * sizeof(ADDRESS_RANGE); KeLoaderBlock.MmapAddr = (ULONG)KeMemoryMap; - + } else { - + /* Nothing from BIOS */ KeLoaderBlock.MmapLength = 0; KeLoaderBlock.MmapAddr = (ULONG)KeMemoryMap; } - + /* Initialize the Debugger */ KdInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); - + /* Initialize HAL */ HalInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); diff --git a/reactos/ntoskrnl/ke/mutex.c b/reactos/ntoskrnl/ke/mutex.c index 2ff0507fd5c..06f81c9665b 100644 --- a/reactos/ntoskrnl/ke/mutex.c +++ b/reactos/ntoskrnl/ke/mutex.c @@ -3,8 +3,8 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/mutex.c * PURPOSE: Implements Mutexes and Mutants (that silly davec...) - * - * PROGRAMMERS: + * + * PROGRAMMERS: * Alex Ionescu (alex@relsoft.net) - Reorganized/commented some of the code. * Simplified some functions, fixed some return values and * corrected some minor bugs, added debug output. @@ -22,7 +22,7 @@ /* * @implemented */ -VOID +VOID STDCALL KeInitializeMutant(IN PKMUTANT Mutant, IN BOOLEAN InitialOwner) @@ -30,34 +30,34 @@ KeInitializeMutant(IN PKMUTANT Mutant, ULONG Signaled = TRUE; PKTHREAD CurrentThread = NULL; KIRQL OldIrql; - + DPRINT("KeInitializeMutant: %x\n", Mutant); - + /* Check if we have an initial owner */ if (InitialOwner == TRUE) { - + /* In this case, the object is not signaled */ Signaled = FALSE; - + /* We also need to associate a thread */ CurrentThread = KeGetCurrentThread(); - + /* We're about to touch the Thread, so lock the Dispatcher */ OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* And insert it into its list */ InsertTailList(&CurrentThread->MutantListHead, &Mutant->MutantListEntry); - + /* Release Dispatcher Lock */ KeReleaseDispatcherDatabaseLock(OldIrql); DPRINT("Mutant with Initial Owner\n"); - + } else { - + /* In this case, we don't have an owner yet */ Mutant->OwnerThread = NULL; } - + /* Now we set up the Dispatcher Header */ KeInitializeDispatcherHeader(&Mutant->Header, MutantObject, @@ -73,20 +73,20 @@ KeInitializeMutant(IN PKMUTANT Mutant, /* * @implemented */ -VOID +VOID STDCALL KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level) { DPRINT("KeInitializeMutex: %x\n", Mutex); - - + + /* Set up the Dispatcher Header */ KeInitializeDispatcherHeader(&Mutex->Header, MutantObject, sizeof(KMUTEX) / sizeof(ULONG), 1); - + /* Initialize the default data */ Mutex->OwnerThread = NULL; Mutex->Abandoned = FALSE; @@ -97,7 +97,7 @@ KeInitializeMutex(IN PKMUTEX Mutex, /* * @implemented */ -LONG +LONG STDCALL KeReadStateMutant(IN PKMUTANT Mutant) { @@ -119,7 +119,7 @@ KeReadStateMutex(IN PKMUTEX Mutex) /* * @implemented */ -LONG +LONG STDCALL KeReleaseMutant(IN PKMUTANT Mutant, IN KPRIORITY Increment, @@ -129,72 +129,72 @@ KeReleaseMutant(IN PKMUTANT Mutant, KIRQL OldIrql; LONG PreviousState; PKTHREAD CurrentThread = KeGetCurrentThread(); - + DPRINT("KeReleaseMutant: %x\n", Mutant); /* Lock the Dispatcher Database */ OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* Save the Previous State */ PreviousState = Mutant->Header.SignalState; - + /* Check if it is to be abandonned */ if (Abandon == FALSE) { /* Make sure that the Owner Thread is the current Thread */ if (Mutant->OwnerThread != CurrentThread) { - + KeReleaseDispatcherDatabaseLock(OldIrql); - + DPRINT1("Trying to touch a Mutant that the caller doesn't own!\n"); ExRaiseStatus(STATUS_MUTANT_NOT_OWNED); } /* If the thread owns it, then increase the signal state */ Mutant->Header.SignalState++; - + } else { - + /* It's going to be abandonned */ DPRINT("Abandonning the Mutant\n"); Mutant->Header.SignalState = 1; Mutant->Abandoned = TRUE; } - + /* Check if the signal state is only single */ if (Mutant->Header.SignalState == 1) { - + /* Check if it's below 0 now */ if (PreviousState <= 0) { - + /* Remove the mutant from the list */ DPRINT("Removing Mutant\n"); RemoveEntryList(&Mutant->MutantListEntry); - + /* Reenable APCs */ DPRINT("Re-enabling APCs\n"); CurrentThread->KernelApcDisable += Mutant->ApcDisable; - + /* Force an Interrupt if Apcs are pending */ if (!IsListEmpty(&CurrentThread->ApcState.ApcListHead[KernelMode])) { - + /* Make sure they aren't disabled though */ if (!CurrentThread->KernelApcDisable) { - + /* Request the Interrupt */ DPRINT("Requesting APC Interupt\n"); HalRequestSoftwareInterrupt(APC_LEVEL); } } } - + /* Remove the Owning Thread and wake it */ Mutant->OwnerThread = NULL; - + /* Check if the Wait List isn't empty */ DPRINT("Checking whether to wake the Mutant\n"); if (!IsListEmpty(&Mutant->Header.WaitListHead)) { - + /* Wake the Mutant */ DPRINT("Waking the Mutant\n"); KiWaitTest(&Mutant->Header, Increment); @@ -203,12 +203,12 @@ KeReleaseMutant(IN PKMUTANT Mutant, /* If the Wait is true, then return with a Wait and don't unlock the Dispatcher Database */ if (Wait == FALSE) { - + /* Release the Lock */ KeReleaseDispatcherDatabaseLock(OldIrql); - + } else { - + /* Set a wait */ CurrentThread->WaitNext = TRUE; CurrentThread->WaitIrql = OldIrql; @@ -221,7 +221,7 @@ KeReleaseMutant(IN PKMUTANT Mutant, /* * @implemented */ -LONG +LONG STDCALL KeReleaseMutex(IN PKMUTEX Mutex, IN BOOLEAN Wait) @@ -234,7 +234,7 @@ KeReleaseMutex(IN PKMUTEX Mutex, /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL KeWaitForMutexObject(IN PKMUTEX Mutex, IN KWAIT_REASON WaitReason, diff --git a/reactos/ntoskrnl/ke/process.c b/reactos/ntoskrnl/ke/process.c index 91235c0346d..8bf238dcc1a 100644 --- a/reactos/ntoskrnl/ke/process.c +++ b/reactos/ntoskrnl/ke/process.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/process.c * PURPOSE: Attaching/Detaching and System Call Tables - * + * * PROGRAMMERS: Alex Ionescu (Implemented Attach/Detach and KeRemoveSystemServiceTable) * Gregor Anich (Bugfixes to Attach Functions) */ @@ -26,7 +26,7 @@ KeServiceDescriptorTable[SSDT_MAX_ENTRIES] = { { NULL, NULL, 0, NULL } }; -SSDT_ENTRY +SSDT_ENTRY KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES] = { { MainSSDT, NULL, NUMBER_OF_SYSCALLS, MainSSPT }, { NULL, NULL, 0, NULL }, @@ -39,15 +39,15 @@ KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES] = { static inline void UpdatePageDirs(PKTHREAD Thread, PKPROCESS Process) { - /* - * The stack and the thread structure of the current process may be - * located in a page which is not present in the page directory of - * the process we're attaching to. That would lead to a page fault - * when this function returns. However, since the processor can't - * call the page fault handler 'cause it can't push EIP on the stack, + /* + * The stack and the thread structure of the current process may be + * located in a page which is not present in the page directory of + * the process we're attaching to. That would lead to a page fault + * when this function returns. However, since the processor can't + * call the page fault handler 'cause it can't push EIP on the stack, * this will show up as a stack fault which will crash the entire system. * To prevent this, make sure the page directory of the process we're - * attaching to is up-to-date. + * attaching to is up-to-date. */ MmUpdatePageDir((PEPROCESS)Process, (PVOID)Thread->StackLimit, MM_STACK_SIZE); MmUpdatePageDir((PEPROCESS)Process, (PVOID)Thread, sizeof(ETHREAD)); @@ -71,13 +71,13 @@ KeInitializeProcess(PKPROCESS Process, LARGE_INTEGER DirectoryTableBase) { DPRINT("KeInitializeProcess. Process: %x, DirectoryTableBase: %x\n", Process, DirectoryTableBase); - + /* Initialize the Dispatcher Header */ KeInitializeDispatcherHeader(&Process->Header, ProcessObject, sizeof(KPROCESS), FALSE); - + /* Initialize Scheduler Data, Disable Alignment Faults and Set the PDE */ Process->Affinity = Affinity; Process->BasePriority = Priority; @@ -86,45 +86,45 @@ KeInitializeProcess(PKPROCESS Process, Process->AutoAlignment = TRUE; Process->IopmOffset = 0xFFFF; Process->State = PROCESS_STATE_ACTIVE; - + /* Initialize the Thread List */ - InitializeListHead(&Process->ThreadListHead); + InitializeListHead(&Process->ThreadListHead); DPRINT("The Process has now been initalized with the Kernel\n"); } ULONG STDCALL -KeSetProcess(PKPROCESS Process, +KeSetProcess(PKPROCESS Process, KPRIORITY Increment) { KIRQL OldIrql; ULONG OldState; - + /* Lock Dispatcher */ OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* Get Old State */ OldState = Process->Header.SignalState; - + /* Signal the Process */ Process->Header.SignalState = TRUE; if ((OldState == 0) && IsListEmpty(&Process->Header.WaitListHead) != TRUE) { - + /* Satisfy waits */ KiWaitTest((PVOID)Process, Increment); } - - /* Release Dispatcher Database */ + + /* Release Dispatcher Database */ KeReleaseDispatcherDatabaseLock(OldIrql); - + /* Return the previous State */ - return OldState; + return OldState; } /* * @implemented */ -VOID +VOID STDCALL KeAttachProcess(PKPROCESS Process) { @@ -141,18 +141,18 @@ KeAttachProcess(PKPROCESS Process) /* Crash system if DPC is being executed! */ if (KeIsExecutingDpc()) { - + DPRINT1("Invalid attach (Thread is executing a DPC!)\n"); KEBUGCHECK(INVALID_PROCESS_ATTACH_ATTEMPT); } /* Check if the Target Process is already attached */ if (Thread->ApcState.Process == Process || Thread->ApcStateIndex != OriginalApcEnvironment) { - + DPRINT("Process already Attached. Exitting\n"); KeReleaseDispatcherDatabaseLock(OldIrql); - } else { - + } else { + KiAttachProcess(Thread, Process, OldIrql, &Thread->SavedApcState); } } @@ -161,15 +161,15 @@ VOID STDCALL KiAttachProcess(PKTHREAD Thread, PKPROCESS Process, KIRQL ApcLock, PRKAPC_STATE SavedApcState) { - + DPRINT("KiAttachProcess(Thread: %x, Process: %x, SavedApcState: %x\n", Thread, Process, SavedApcState); - + /* Increase Stack Count */ Process->StackCount++; /* Swap the APC Environment */ KiMoveApcState(&Thread->ApcState, SavedApcState); - + /* Reinitialize Apc State */ InitializeListHead(&Thread->ApcState.ApcListHead[KernelMode]); InitializeListHead(&Thread->ApcState.ApcListHead[UserMode]); @@ -177,29 +177,29 @@ KiAttachProcess(PKTHREAD Thread, PKPROCESS Process, KIRQL ApcLock, PRKAPC_STATE Thread->ApcState.KernelApcInProgress = FALSE; Thread->ApcState.KernelApcPending = FALSE; Thread->ApcState.UserApcPending = FALSE; - + /* Update Environment Pointers if needed*/ if (SavedApcState == &Thread->SavedApcState) { - + Thread->ApcStatePointer[OriginalApcEnvironment] = &Thread->SavedApcState; Thread->ApcStatePointer[AttachedApcEnvironment] = &Thread->ApcState; Thread->ApcStateIndex = AttachedApcEnvironment; } - + /* Swap the Processes */ DPRINT("Swapping\n"); KiSwapProcess(Process, SavedApcState->Process); - + /* Return to old IRQL*/ KeReleaseDispatcherDatabaseLock(ApcLock); - + DPRINT("KiAttachProcess Completed Sucesfully\n"); } VOID STDCALL -KiSwapProcess(PKPROCESS NewProcess, - PKPROCESS OldProcess) +KiSwapProcess(PKPROCESS NewProcess, + PKPROCESS OldProcess) { /* FIXME: Write this in ASM. Much easier */ DPRINT("Switching CR3 to: %x\n", NewProcess->DirectoryTableBase.u.LowPart); @@ -232,29 +232,29 @@ KeStackAttachProcess(IN PKPROCESS Process, UpdatePageDirs(Thread, Process); OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* Crash system if DPC is being executed! */ if (KeIsExecutingDpc()) { - + DPRINT1("Invalid attach (Thread is executing a DPC!)\n"); KEBUGCHECK(INVALID_PROCESS_ATTACH_ATTEMPT); } - + /* Check if the Target Process is already attached */ if (Thread->ApcState.Process == Process) { - + ApcState->Process = (PKPROCESS)1; /* Meaning already attached to the same Process */ - - } else { - + + } else { + /* Check if the Current Thread is already attached and call the Internal Function*/ if (Thread->ApcStateIndex != OriginalApcEnvironment) { - + KiAttachProcess(Thread, Process, OldIrql, ApcState); } else { - + KiAttachProcess(Thread, Process, OldIrql, &Thread->SavedApcState); - ApcState->Process = NULL; + ApcState->Process = NULL; } } } @@ -267,32 +267,32 @@ KeDetachProcess (VOID) { PKTHREAD Thread; KIRQL OldIrql; - + DPRINT("KeDetachProcess()\n"); - + /* Get Current Thread and Lock */ Thread = KeGetCurrentThread(); OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* Check if it's attached */ DPRINT("Current ApcStateIndex: %x\n", Thread->ApcStateIndex); - + if (Thread->ApcStateIndex == OriginalApcEnvironment) { - + DPRINT1("Invalid detach (thread was not attached)\n"); KEBUGCHECK(INVALID_PROCESS_DETACH_ATTEMPT); } - + /* Decrease Stack Count */ Thread->ApcState.Process->StackCount--; - + /* Restore the APC State */ KiMoveApcState(&Thread->SavedApcState, &Thread->ApcState); Thread->SavedApcState.Process = NULL; Thread->ApcStatePointer[OriginalApcEnvironment] = &Thread->ApcState; Thread->ApcStatePointer[AttachedApcEnvironment] = &Thread->SavedApcState; Thread->ApcStateIndex = OriginalApcEnvironment; - + /* Swap Processes */ KiSwapProcess(Thread->ApcState.Process, Thread->ApcState.Process); @@ -312,29 +312,29 @@ KeUnstackDetachProcess ( KIRQL OldIrql; PKTHREAD Thread; - /* - * If the special "We tried to attach to the process already being - * attached to" flag is there, don't do anything + /* + * If the special "We tried to attach to the process already being + * attached to" flag is there, don't do anything */ if (ApcState->Process == (PKPROCESS)1) return; - + Thread = KeGetCurrentThread(); OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* Sorry Buddy, can't help you if you've got APCs or just aren't attached */ if ((Thread->ApcStateIndex == OriginalApcEnvironment) || (Thread->ApcState.KernelApcInProgress)) { - + DPRINT1("Invalid detach (Thread not Attached, or Kernel APC in Progress!)\n"); KEBUGCHECK(INVALID_PROCESS_DETACH_ATTEMPT); } - + /* Restore the Old APC State if a Process was present */ if (ApcState->Process) { - + KiMoveApcState(ApcState, &Thread->ApcState); - + } else { - + /* The ApcState parameter is useless, so use the saved data and reset it */ KiMoveApcState(&Thread->SavedApcState, &Thread->ApcState); Thread->SavedApcState.Process = NULL; @@ -361,7 +361,7 @@ KeAddSystemServiceTable(PSSDT SSDT, ULONG TableIndex) { /* check if descriptor table entry is free */ - if ((TableIndex > SSDT_MAX_ENTRIES - 1) || + if ((TableIndex > SSDT_MAX_ENTRIES - 1) || (KeServiceDescriptorTable[TableIndex].SSDT != NULL) || (KeServiceDescriptorTableShadow[TableIndex].SSDT != NULL)) return FALSE; @@ -371,7 +371,7 @@ KeAddSystemServiceTable(PSSDT SSDT, KeServiceDescriptorTableShadow[TableIndex].SSPT = SSPT; KeServiceDescriptorTableShadow[TableIndex].NumberOfServices = NumberOfServices; KeServiceDescriptorTableShadow[TableIndex].ServiceCounterTable = ServiceCounterTable; - + return TRUE; } @@ -384,23 +384,23 @@ KeRemoveSystemServiceTable(IN ULONG TableIndex) { /* Make sure the Index is valid */ if (TableIndex > SSDT_MAX_ENTRIES - 1) return FALSE; - + /* Is there a Normal Descriptor Table? */ if (!KeServiceDescriptorTable[TableIndex].SSDT) { - + /* Not with the index, is there a shadow at least? */ if (!KeServiceDescriptorTableShadow[TableIndex].SSDT) return FALSE; } - + /* Now clear from the Shadow Table. */ KeServiceDescriptorTableShadow[TableIndex].SSDT = NULL; KeServiceDescriptorTableShadow[TableIndex].SSPT = NULL; KeServiceDescriptorTableShadow[TableIndex].NumberOfServices = 0; KeServiceDescriptorTableShadow[TableIndex].ServiceCounterTable = NULL; - + /* Check if we should clean from the Master one too */ if (TableIndex == 1) { - + KeServiceDescriptorTable[TableIndex].SSDT = NULL; KeServiceDescriptorTable[TableIndex].SSPT = NULL; KeServiceDescriptorTable[TableIndex].NumberOfServices = 0; diff --git a/reactos/ntoskrnl/ke/profile.c b/reactos/ntoskrnl/ke/profile.c index cb2279bf878..25ba7fc4536 100644 --- a/reactos/ntoskrnl/ke/profile.c +++ b/reactos/ntoskrnl/ke/profile.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/profile.c * PURPOSE: Kernel Profiling - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) */ @@ -22,7 +22,7 @@ ULONG KiProfileTimeInterval = 78125; /* Default resolution 7.8ms (sysinternals) /* FUNCTIONS *****************************************************************/ -STDCALL +STDCALL VOID KeInitializeProfile(PKPROFILE Profile, PKPROCESS Process, @@ -35,7 +35,7 @@ KeInitializeProfile(PKPROFILE Profile, /* Initialize the Header */ Profile->Type = ProfileObject; Profile->Size = sizeof(KPROFILE); - + /* Copy all the settings we were given */ Profile->Process = Process; Profile->RegionStart = ImageBase; @@ -43,7 +43,7 @@ KeInitializeProfile(PKPROFILE Profile, Profile->RegionEnd = (PVOID)(ULONG_PTR)ImageBase + ImageSize; Profile->Active = FALSE; Profile->Source = ProfileSource; - Profile->Affinity = Affinity; + Profile->Affinity = Affinity; } STDCALL @@ -58,77 +58,77 @@ KeStartProfile(PKPROFILE Profile, BOOLEAN FreeBuffer = TRUE; PKPROCESS ProfileProcess; PLIST_ENTRY ListEntry; - + /* Allocate a buffer first, before we raise IRQL */ - SourceBuffer = ExAllocatePoolWithTag(NonPagedPool, + SourceBuffer = ExAllocatePoolWithTag(NonPagedPool, sizeof(KPROFILE_SOURCE_OBJECT), TAG('P', 'r', 'o', 'f')); RtlZeroMemory(Source, sizeof(KPROFILE_SOURCE_OBJECT)); - + /* Raise to PROFILE_LEVEL */ KeRaiseIrql(PROFILE_LEVEL, &OldIrql); KeAcquireSpinLockAtDpcLevel(&KiProfileLock); - + /* Make sure it's not running */ if (!Profile->Active) { - + /* Set it as active */ Profile->Buffer = Buffer; Profile->Active = TRUE; - + /* Get the process, if any */ ProfileProcess = Profile->Process; - + /* Insert it into the Process List or Global List */ if (ProfileProcess) { - + InsertTailList(&ProfileProcess->ProfileListHead, &Profile->ListEntry); - + } else { - + InsertTailList(&KiProfileListHead, &Profile->ListEntry); } - + /* Check if this type of profile (source) is already running */ - for (ListEntry = KiProfileSourceListHead.Flink; - ListEntry != &KiProfileSourceListHead; + for (ListEntry = KiProfileSourceListHead.Flink; + ListEntry != &KiProfileSourceListHead; ListEntry = ListEntry->Flink) { - + /* Get the Source Object */ - CurrentSource = CONTAINING_RECORD(ListEntry, + CurrentSource = CONTAINING_RECORD(ListEntry, KPROFILE_SOURCE_OBJECT, ListEntry); - + /* Check if it's the same as the one being requested now */ if (CurrentSource->Source == Profile->Source) { - + Source = CurrentSource; break; } } - + /* See if the loop found something */ if (!Source) { - + /* Nothing found, use our allocated buffer */ Source = SourceBuffer; - + /* Set up the Source Object */ Source->Source = Profile->Source; InsertHeadList(&KiProfileSourceListHead, &Source->ListEntry); - + /* Don't free the pool later on */ FreeBuffer = FALSE; } } - + /* Lower the IRQL */ KeReleaseSpinLockFromDpcLevel(&KiProfileLock); KeLowerIrql(OldIrql); - + /* FIXME: Tell HAL to Start the Profile Interrupt */ //HalStartProfileInterrupt(Profile->Source); - + /* Free the pool */ if (!FreeBuffer) ExFreePool(SourceBuffer); } @@ -140,40 +140,40 @@ KeStopProfile(PKPROFILE Profile) KIRQL OldIrql; PLIST_ENTRY ListEntry; PKPROFILE_SOURCE_OBJECT CurrentSource = NULL; - + /* Raise to PROFILE_LEVEL and acquire spinlock */ KeRaiseIrql(PROFILE_LEVEL, &OldIrql); KeAcquireSpinLockAtDpcLevel(&KiProfileLock); - + /* Make sure it's running */ if (Profile->Active) { - + /* Remove it from the list and disable */ RemoveEntryList(&Profile->ListEntry); Profile->Active = FALSE; - + /* Find the Source Object */ - for (ListEntry = KiProfileSourceListHead.Flink; - CurrentSource->Source != Profile->Source; + for (ListEntry = KiProfileSourceListHead.Flink; + CurrentSource->Source != Profile->Source; ListEntry = ListEntry->Flink) { - + /* Get the Source Object */ - CurrentSource = CONTAINING_RECORD(ListEntry, + CurrentSource = CONTAINING_RECORD(ListEntry, KPROFILE_SOURCE_OBJECT, ListEntry); } - + /* Remove it */ RemoveEntryList(&CurrentSource->ListEntry); } - + /* Lower IRQL */ KeReleaseSpinLockFromDpcLevel(&KiProfileLock); KeLowerIrql(OldIrql); - + /* Stop Profiling. FIXME: Implement in HAL */ //HalStopProfileInterrupt(Profile->Source); - + /* Free the Source Object */ if (CurrentSource) ExFreePool(CurrentSource); } @@ -184,40 +184,40 @@ KeQueryIntervalProfile(KPROFILE_SOURCE ProfileSource) { /* Check if this is the timer profile */ if (ProfileSource == ProfileTime) { - + /* Return the good old 100ns sampling interval */ return KiProfileTimeInterval; - + } else { - + /* Request it from HAL. FIXME: What structure is used? */ HalQuerySystemInformation(HalProfileSourceInformation, sizeof(NULL), NULL, NULL); - + return 0; } } -STDCALL -VOID +STDCALL +VOID KeSetIntervalProfile(KPROFILE_SOURCE ProfileSource, ULONG Interval) { /* Check if this is the timer profile */ if (ProfileSource == ProfileTime) { - + /* Set the good old 100ns sampling interval */ KiProfileTimeInterval = Interval; - + } else { - + /* Set it with HAL. FIXME: What structure is used? */ HalSetSystemInformation(HalProfileSourceInformation, sizeof(NULL), NULL); - + } } @@ -241,26 +241,26 @@ KiParseProfileList(IN PKTRAP_FRAME TrapFrame, PULONG BucketValue; PKPROFILE Profile; PLIST_ENTRY NextEntry; - + /* Loop the List */ for (NextEntry = ListHead->Flink; NextEntry != ListHead; NextEntry = NextEntry->Flink) { - + /* Get the Current Profile in the List */ Profile = CONTAINING_RECORD(NextEntry, KPROFILE, ListEntry); - + /* Check if the source is good, and if it's within the range */ - if ((Profile->Source != Source) || - (TrapFrame->Eip < (ULONG_PTR)Profile->RegionStart) || + if ((Profile->Source != Source) || + (TrapFrame->Eip < (ULONG_PTR)Profile->RegionStart) || (TrapFrame->Eip > (ULONG_PTR)Profile->RegionEnd)) { - + continue; - } + } /* Get the Pointer to the Bucket Value representing this EIP */ - BucketValue = (PULONG)(((ULONG_PTR)(Profile->Buffer + + BucketValue = (PULONG)(((ULONG_PTR)(Profile->Buffer + (TrapFrame->Eip - (ULONG_PTR)Profile->RegionStart)) >> Profile->BucketShift) &~ 0x3); - + /* Increment the value */ ++BucketValue; } @@ -282,7 +282,7 @@ KeProfileInterruptWithSource(IN PKTRAP_FRAME TrapFrame, IN KPROFILE_SOURCE Source) { PKPROCESS Process = KeGetCurrentThread()->ApcState.Process; - + /* We have to parse 2 lists. Per-Process and System-Wide */ KiParseProfileList(TrapFrame, Source, &Process->ProfileListHead); KiParseProfileList(TrapFrame, Source, &KiProfileListHead); diff --git a/reactos/ntoskrnl/ke/queue.c b/reactos/ntoskrnl/ke/queue.c index fc663b734f1..830bb63dd86 100644 --- a/reactos/ntoskrnl/ke/queue.c +++ b/reactos/ntoskrnl/ke/queue.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/queue.c * PURPOSE: Implements kernel queues - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) * Gunnar Dalsnes * Eric Kohl (ekohl@rz-online.de) @@ -18,27 +18,27 @@ /* FUNCTIONS *****************************************************************/ LONG STDCALL KiInsertQueue(IN PKQUEUE Queue, IN PLIST_ENTRY Entry, BOOLEAN Head); - + /* * @implemented */ -VOID +VOID STDCALL KeInitializeQueue(IN PKQUEUE Queue, IN ULONG Count OPTIONAL) { DPRINT("KeInitializeQueue %x\n", Queue); - + /* Initialize the Header */ KeInitializeDispatcherHeader(&Queue->Header, QueueObject, sizeof(KQUEUE)/sizeof(ULONG), 0); - + /* Initialize the Lists */ InitializeListHead(&Queue->EntryListHead); InitializeListHead(&Queue->ThreadListHead); - + /* Set the Current and Maximum Count */ Queue->CurrentCount = 0; Queue->MaximumCount = (Count == 0) ? (ULONG) KeNumberProcessors : Count; @@ -54,18 +54,18 @@ KeInsertHeadQueue(IN PKQUEUE Queue, { LONG PreviousState; KIRQL OldIrql; - + DPRINT("KeInsertHeadQueue %x\n", Queue); - + /* Lock the Dispatcher Database */ OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* Insert the Queue */ PreviousState = KiInsertQueue(Queue, Entry, TRUE); - + /* Release the Dispatcher Lock */ KeReleaseDispatcherDatabaseLock(OldIrql); - + /* Return previous State */ return PreviousState; } @@ -79,18 +79,18 @@ KeInsertQueue(IN PKQUEUE Queue, { LONG PreviousState; KIRQL OldIrql; - + DPRINT("KeInsertQueue %x\n", Queue); - + /* Lock the Dispatcher Database */ OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* Insert the Queue */ PreviousState = KiInsertQueue(Queue, Entry, FALSE); - + /* Release the Dispatcher Lock */ KeReleaseDispatcherDatabaseLock(OldIrql); - + /* Return previous State */ return PreviousState; } @@ -111,13 +111,13 @@ KeReadStateQueue(IN PKQUEUE Queue) /* * @implemented */ -PLIST_ENTRY +PLIST_ENTRY STDCALL KeRemoveQueue(IN PKQUEUE Queue, IN KPROCESSOR_MODE WaitMode, IN PLARGE_INTEGER Timeout OPTIONAL) { - + PLIST_ENTRY ListEntry; NTSTATUS Status; PKTHREAD Thread = KeGetCurrentThread(); @@ -128,14 +128,14 @@ KeRemoveQueue(IN PKQUEUE Queue, PKTIMER Timer; DPRINT("KeRemoveQueue %x\n", Queue); - + /* Check if the Lock is already held */ if (Thread->WaitNext) { - + DPRINT("Lock is already held\n"); - + } else { - + /* Lock the Dispatcher Database */ DPRINT("Lock not held, acquiring\n"); OldIrql = KeAcquireDispatcherDatabaseLock(); @@ -146,9 +146,9 @@ KeRemoveQueue(IN PKQUEUE Queue, PreviousQueue = Thread->Queue; Thread->Queue = Queue; - /* Check if this is a different queue */ + /* Check if this is a different queue */ if (Queue != PreviousQueue) { - + /* * INVESTIGATE: What is the Thread->QueueListEntry used for? It's linked it into the * Queue->ThreadListHead when the thread registers with the queue and unlinked when @@ -158,11 +158,11 @@ KeRemoveQueue(IN PKQUEUE Queue, */ DPRINT("Different Queue\n"); if (PreviousQueue) { - + /* Remove from this list */ DPRINT("Removing Old Queue\n"); RemoveEntryList(&Thread->QueueListEntry); - + /* Wake the queue */ DPRINT("Activating new thread\n"); KiWakeQueue(PreviousQueue); @@ -171,68 +171,68 @@ KeRemoveQueue(IN PKQUEUE Queue, /* Insert in this new Queue */ DPRINT("Inserting new Queue!\n"); InsertTailList(&Queue->ThreadListHead, &Thread->QueueListEntry); - + } else { - + /* Same queue, decrement waiting threads */ DPRINT("Same Queue!\n"); Queue->CurrentCount--; } - + /* Loop until the queue is processed */ while (TRUE) { - + /* Get the Entry */ ListEntry = Queue->EntryListHead.Flink; - + /* Check if the counts are valid and if there is still a queued entry */ - if ((Queue->CurrentCount < Queue->MaximumCount) && + if ((Queue->CurrentCount < Queue->MaximumCount) && (ListEntry != &Queue->EntryListHead)) { - + /* Remove the Entry and Save it */ - DPRINT("Removing Queue Entry. CurrentCount: %d, Maximum Count: %d\n", + DPRINT("Removing Queue Entry. CurrentCount: %d, Maximum Count: %d\n", Queue->CurrentCount, Queue->MaximumCount); ListEntry = RemoveHeadList(&Queue->EntryListHead); - + /* Decrease the number of entries */ Queue->Header.SignalState--; - + /* Increase numbef of running threads */ Queue->CurrentCount++; - + /* Check if the entry is valid. If not, bugcheck */ if (!ListEntry->Flink || !ListEntry->Blink) { - + KEBUGCHECK(INVALID_WORK_QUEUE_ITEM); } - + /* Remove the Entry */ RemoveEntryList(ListEntry); ListEntry->Flink = NULL; - + /* Nothing to wait on */ break; - + } else { - + /* Do the wait */ - DPRINT("Waiting on Queue Entry. CurrentCount: %d, Maximum Count: %d\n", + DPRINT("Waiting on Queue Entry. CurrentCount: %d, Maximum Count: %d\n", Queue->CurrentCount, Queue->MaximumCount); - + /* Use the Thread's Wait Block, it's big enough */ Thread->WaitBlockList = &Thread->WaitBlock[0]; - + /* Fail if there's an APC Pending */ if (WaitMode == UserMode && Thread->ApcState.UserApcPending) { - + /* Return the status and increase the pending threads */ ListEntry = (PLIST_ENTRY)STATUS_USER_APC; Queue->CurrentCount++; - + /* Nothing to wait on */ break; } - + /* Build the Wait Block */ WaitBlock = &Thread->WaitBlock[0]; WaitBlock->Object = (PVOID)Queue; @@ -240,25 +240,25 @@ KeRemoveQueue(IN PKQUEUE Queue, WaitBlock->WaitType = WaitAny; WaitBlock->Thread = Thread; WaitBlock->NextWaitBlock = WaitBlock; - + Thread->WaitStatus = STATUS_SUCCESS; - + /* We need to wait for the object... check if we have a timeout */ if (Timeout) { - + /* If it's zero, then don't do any waiting */ if (!Timeout->QuadPart) { - + /* Instant Timeout, return the status and increase the pending threads */ DPRINT("Queue Wait has timed out\n"); ListEntry = (PLIST_ENTRY)STATUS_TIMEOUT; Queue->CurrentCount++; - + /* Nothing to wait on */ break; } - - /* + + /* * Set up the Timer. We'll use the internal function so that we can * hold on to the dispatcher lock. */ @@ -271,51 +271,51 @@ KeRemoveQueue(IN PKQUEUE Queue, TimerWaitBlock->WaitKey = STATUS_TIMEOUT; TimerWaitBlock->WaitType = WaitAny; TimerWaitBlock->NextWaitBlock = TimerWaitBlock; - + /* Link the timer to this Wait Block */ InitializeListHead(&Timer->Header.WaitListHead); InsertTailList(&Timer->Header.WaitListHead, &TimerWaitBlock->WaitListEntry); - + /* Create Timer */ DPRINT("Creating Timer with timeout %I64d\n", *Timeout); KiInsertTimer(Timer, *Timeout); } - + /* Insert the wait block into the Queues's wait list */ WaitBlock = Thread->WaitBlockList; InsertTailList(&Queue->Header.WaitListHead, &WaitBlock->WaitListEntry); - + /* Block the Thread */ DPRINT("Blocking the Thread: %x %x!\n", KeGetCurrentThread(), Thread); - KiBlockThread(&Status, - FALSE, + KiBlockThread(&Status, + FALSE, WaitMode, WrQueue); - + /* Reset the wait reason */ Thread->WaitReason = 0; - + /* Check if we were executing an APC */ if (Status != STATUS_KERNEL_APC) { - + /* Done Waiting */ DPRINT("Done waking queue. Thread: %x %x!\n", KeGetCurrentThread(), Thread); return (PLIST_ENTRY)Status; } - + /* Acquire again the lock */ DPRINT("Looping again\n"); OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* Save the new IRQL and decrease number of waiting threads */ Thread->WaitIrql = OldIrql; Queue->CurrentCount--; } } - + /* Unlock Database and return */ KeReleaseDispatcherDatabaseLock(Thread->WaitIrql); - DPRINT("Returning. CurrentCount: %d, Maximum Count: %d\n", + DPRINT("Returning. CurrentCount: %d, Maximum Count: %d\n", Queue->CurrentCount, Queue->MaximumCount); return ListEntry; } @@ -323,7 +323,7 @@ KeRemoveQueue(IN PKQUEUE Queue, /* * @implemented */ -PLIST_ENTRY +PLIST_ENTRY STDCALL KeRundownQueue(IN PKQUEUE Queue) { @@ -339,28 +339,28 @@ KeRundownQueue(IN PKQUEUE Queue) /* Get the First Empty Entry */ FirstEntry = Queue->EntryListHead.Flink; - + /* Make sure the list is not empty */ if (FirstEntry == &Queue->EntryListHead) { - + /* It is, so don't return anything */ EnumEntry = NULL; - + } else { - + /* Remove it */ RemoveEntryList(&Queue->EntryListHead); } - + /* Unlink threads and clear their Thread->Queue */ while (!IsListEmpty(&Queue->ThreadListHead)) { - + /* Get the Entry and Remove it */ EnumEntry = RemoveHeadList(&Queue->ThreadListHead); - + /* Get the Entry's Thread */ Thread = CONTAINING_RECORD(EnumEntry, KTHREAD, QueueListEntry); - + /* Kill its Queue */ Thread->Queue = NULL; } @@ -380,45 +380,45 @@ KiWakeQueue(IN PKQUEUE Queue) PLIST_ENTRY QueueEntry; PLIST_ENTRY WaitEntry; PKWAIT_BLOCK WaitBlock; - + /* Decrement the number of active threads */ DPRINT("KiWakeQueue: %x. Thread: %x\n", Queue, KeGetCurrentThread()); Queue->CurrentCount--; - + /* Make sure the counts are OK */ if (Queue->CurrentCount < Queue->MaximumCount) { - + /* Get the Queue Entry */ QueueEntry = Queue->EntryListHead.Flink; - + /* Get the Wait Entry */ WaitEntry = Queue->Header.WaitListHead.Blink; DPRINT("Queue Count is ok, Queue entries: %x, %x\n", QueueEntry, WaitEntry); - + /* Make sure that the Queue List isn't empty and that this entry is valid */ - if (!IsListEmpty(&Queue->Header.WaitListHead) && + if (!IsListEmpty(&Queue->Header.WaitListHead) && (QueueEntry != &Queue->EntryListHead)) { - + /* Remove this entry */ DPRINT("Queue in List, removing it\n"); RemoveEntryList(QueueEntry); QueueEntry->Flink = NULL; - + /* Decrease the Signal State */ Queue->Header.SignalState--; - + /* Unwait the Thread */ DPRINT("Unwaiting Thread\n"); WaitBlock = CONTAINING_RECORD(WaitEntry, KWAIT_BLOCK, WaitListEntry); KiAbortWaitThread(WaitBlock->Thread, (NTSTATUS)QueueEntry, IO_NO_INCREMENT); } - } + } } /* * Returns the previous number of entries in the queue */ -LONG +LONG STDCALL KiInsertQueue(IN PKQUEUE Queue, IN PLIST_ENTRY Entry, @@ -428,65 +428,65 @@ KiInsertQueue(IN PKQUEUE Queue, PKTHREAD Thread = KeGetCurrentThread(); PKWAIT_BLOCK WaitBlock; PLIST_ENTRY WaitEntry; - + DPRINT("KiInsertQueue(Queue %x, Entry %x)\n", Queue, Entry); - + /* Save the old state */ InitialState = Queue->Header.SignalState; - + /* Get the Entry */ WaitEntry = Queue->Header.WaitListHead.Blink; DPRINT("Initial State, WaitEntry: %d, %x\n", InitialState, WaitEntry); - + /* * Why the KeGetCurrentThread()->Queue != Queue? - * KiInsertQueue might be called from an APC for the current thread. + * KiInsertQueue might be called from an APC for the current thread. * -Gunnar */ - if ((Queue->CurrentCount < Queue->MaximumCount) && + if ((Queue->CurrentCount < Queue->MaximumCount) && (WaitEntry != &Queue->Header.WaitListHead) && ((Thread->Queue != Queue) || (Thread->WaitReason != WrQueue))) { - + /* Remove the wait entry */ DPRINT("Removing Entry\n"); RemoveEntryList(WaitEntry); - + /* Get the Wait Block and Thread */ WaitBlock = CONTAINING_RECORD(WaitEntry, KWAIT_BLOCK, WaitListEntry); DPRINT("Got wait block: %x\n", WaitBlock); Thread = WaitBlock->Thread; - + /* Reset the wait reason */ Thread->WaitReason = 0; - + /* Increase the waiting threads */ Queue->CurrentCount++; - + /* Check if there's a Thread Timer */ if (Thread->Timer.Header.Inserted) { - + /* Cancel the Thread Timer with the no-lock fastpath */ DPRINT("Removing the Thread's Timer\n"); Thread->Timer.Header.Inserted = FALSE; RemoveEntryList(&Thread->Timer.TimerListEntry); } - + /* Reschedule the Thread */ DPRINT("Unblocking the Thread\n"); KiUnblockThread(Thread, (PNTSTATUS)&Entry, 0); - + } else { - + /* Increase the Entries */ DPRINT("Adding new Queue Entry: %d %d\n", Head, Queue->Header.SignalState); Queue->Header.SignalState++; - + if (Head) { - + InsertHeadList(&Queue->EntryListHead, Entry); - + } else { - + InsertTailList(&Queue->EntryListHead, Entry); } } diff --git a/reactos/ntoskrnl/ke/sem.c b/reactos/ntoskrnl/ke/sem.c index 2d3fe4db6c2..bbf1b1a53e8 100644 --- a/reactos/ntoskrnl/ke/sem.c +++ b/reactos/ntoskrnl/ke/sem.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/sem.c * PURPOSE: Implements kernel semaphores - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -27,7 +27,7 @@ KeInitializeSemaphore(PKSEMAPHORE Semaphore, { DPRINT("KeInitializeSemaphore Sem: %x\n", Semaphore); - + /* Simply Initialize the Header */ KeInitializeDispatcherHeader(&Semaphore->Header, SemaphoreObject, @@ -35,13 +35,13 @@ KeInitializeSemaphore(PKSEMAPHORE Semaphore, Count); /* Set the Limit */ - Semaphore->Limit = Limit; + Semaphore->Limit = Limit; } /* * @implemented */ -LONG +LONG STDCALL KeReadStateSemaphore(PKSEMAPHORE Semaphore) { @@ -62,7 +62,7 @@ KeReadStateSemaphore(PKSEMAPHORE Semaphore) * Semaphore = Points to an initialized semaphore object for which the * caller provides the storage. * Increment = Specifies the priority increment to be applied if - * releasing the semaphore causes a wait to be + * releasing the semaphore causes a wait to be * satisfied. * Adjustment = Specifies a value to be added to the current semaphore * count. This value must be positive @@ -71,7 +71,7 @@ KeReadStateSemaphore(PKSEMAPHORE Semaphore) * RETURNS: If the return value is zero, the previous state of the semaphore * object is Not-Signaled. */ -LONG +LONG STDCALL KeReleaseSemaphore(PKSEMAPHORE Semaphore, KPRIORITY Increment, @@ -83,10 +83,10 @@ KeReleaseSemaphore(PKSEMAPHORE Semaphore, KIRQL OldIrql; PKTHREAD CurrentThread; - DPRINT("KeReleaseSemaphore(Semaphore %x, Increment %d, Adjustment %d, Wait %d)\n", - Semaphore, - Increment, - Adjustment, + DPRINT("KeReleaseSemaphore(Semaphore %x, Increment %d, Adjustment %d, Wait %d)\n", + Semaphore, + Increment, + Adjustment, Wait); /* Lock the Dispatcher Database */ @@ -94,11 +94,11 @@ KeReleaseSemaphore(PKSEMAPHORE Semaphore, /* Save the Old State */ InitialState = Semaphore->Header.SignalState; - + /* Check if the Limit was exceeded */ - if (Semaphore->Limit < (LONG) InitialState + Adjustment || + if (Semaphore->Limit < (LONG) InitialState + Adjustment || InitialState > InitialState + Adjustment) { - + /* Raise an error if it was exceeded */ KeReleaseDispatcherDatabaseLock(OldIrql); ExRaiseStatus(STATUS_SEMAPHORE_LIMIT_EXCEEDED); @@ -106,22 +106,22 @@ KeReleaseSemaphore(PKSEMAPHORE Semaphore, /* Now set the new state */ Semaphore->Header.SignalState += Adjustment; - + /* Check if we should wake it */ if (InitialState == 0 && !IsListEmpty(&Semaphore->Header.WaitListHead)) { - + /* Wake the Semaphore */ KiWaitTest(&Semaphore->Header, Increment); } /* If the Wait is true, then return with a Wait and don't unlock the Dispatcher Database */ if (Wait == FALSE) { - + /* Release the Lock */ KeReleaseDispatcherDatabaseLock(OldIrql); - + } else { - + /* Set a wait */ CurrentThread = KeGetCurrentThread(); CurrentThread->WaitNext = TRUE; diff --git a/reactos/ntoskrnl/ke/spinlock.c b/reactos/ntoskrnl/ke/spinlock.c index 258a15d9a07..6d14603aedf 100644 --- a/reactos/ntoskrnl/ke/spinlock.c +++ b/reactos/ntoskrnl/ke/spinlock.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/spinlock.c * PURPOSE: Implements spinlocks - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -33,7 +33,7 @@ KeSynchronizeExecution (PKINTERRUPT Interrupt, * of a given interrupt object * ARGUMENTS: * Interrupt = Interrupt object to synchronize with - * SynchronizeRoutine = Routine to call whose execution is + * SynchronizeRoutine = Routine to call whose execution is * synchronized with the ISR * SynchronizeContext = Parameter to pass to the synchronized routine * RETURNS: TRUE if the operation succeeded @@ -41,13 +41,13 @@ KeSynchronizeExecution (PKINTERRUPT Interrupt, { KIRQL oldlvl; BOOLEAN ret; - + oldlvl = KeAcquireInterruptSpinLock(Interrupt); - + ret = SynchronizeRoutine(SynchronizeContext); - + KeReleaseInterruptSpinLock(Interrupt, oldlvl); - + return(ret); } @@ -61,7 +61,7 @@ KeAcquireInterruptSpinLock( ) { KIRQL oldIrql; - + KeRaiseIrql(Interrupt->SynchLevel, &oldIrql); KiAcquireSpinLock(Interrupt->ActualLock); return oldIrql; @@ -101,7 +101,7 @@ KefAcquireSpinLockAtDpcLevel(PKSPIN_LOCK SpinLock) VOID STDCALL KeAcquireSpinLockAtDpcLevel (PKSPIN_LOCK SpinLock) /* - * FUNCTION: Acquires a spinlock when the caller is already running at + * FUNCTION: Acquires a spinlock when the caller is already running at * dispatch level * ARGUMENTS: * SpinLock = Spinlock to acquire @@ -134,7 +134,7 @@ VOID FASTCALL KefReleaseSpinLockFromDpcLevel(PKSPIN_LOCK SpinLock) { ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL); - KiReleaseSpinLock(SpinLock); + KiReleaseSpinLock(SpinLock); } #undef KeReleaseSpinLockFromDpcLevel @@ -147,7 +147,7 @@ KeReleaseSpinLockFromDpcLevel (PKSPIN_LOCK SpinLock) /* * FUNCTION: Releases a spinlock when the caller was running at dispatch * level before acquiring it - * ARGUMENTS: + * ARGUMENTS: * SpinLock = Spinlock to release */ { @@ -179,7 +179,7 @@ KiAcquireSpinLock(PKSPIN_LOCK SpinLock) * the spinlock's value. */ ASSERT(*SpinLock < 2); - + while ((i = InterlockedExchangeUL(SpinLock, 1)) == 1) { #ifdef CONFIG_SMP @@ -190,7 +190,7 @@ KiAcquireSpinLock(PKSPIN_LOCK SpinLock) "jne 1b\n\t" : : "r" (SpinLock)); -#else +#else while (0 != *(volatile KSPIN_LOCK*)SpinLock); #endif #else diff --git a/reactos/ntoskrnl/ke/timer.c b/reactos/ntoskrnl/ke/timer.c index 49504f9dbaa..1867049e3dc 100644 --- a/reactos/ntoskrnl/ke/timer.c +++ b/reactos/ntoskrnl/ke/timer.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/timer.c * PURPOSE: Handle Kernel Timers (Kernel-part of Executive Timers) - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) - Reimplemented some parts, fixed many bugs. * David Welch (welch@mcmail.com) & Phillip Susi - Original Implementation. */ @@ -35,13 +35,13 @@ VOID STDCALL KiHandleExpiredTimer(PKTIMER Timer); * RETURNS: True if the timer was running * False otherwise */ -BOOLEAN +BOOLEAN STDCALL KeCancelTimer(PKTIMER Timer) { KIRQL OldIrql; BOOLEAN Inserted = FALSE; - + DPRINT("KeCancelTimer(Timer %x)\n",Timer); /* Lock the Database and Raise IRQL */ @@ -49,14 +49,14 @@ KeCancelTimer(PKTIMER Timer) /* Check if it's inserted, and remove it if it is */ if ((Inserted = Timer->Header.Inserted)) { - + /* Remove from list */ DPRINT("Timer was inserted, removing\n"); RemoveEntryList(&Timer->TimerListEntry); Timer->Header.Inserted = FALSE; - + } else { - + DPRINT("Timer was not inserted\n"); } @@ -76,7 +76,7 @@ KeCancelTimer(PKTIMER Timer) * Timer = caller supplied storage for the timer * NOTE: This function initializes a notification timer */ -VOID +VOID STDCALL KeInitializeTimer (PKTIMER Timer) @@ -93,24 +93,24 @@ KeInitializeTimer (PKTIMER Timer) * Timer = caller supplied storage for the timer * Type = the type of timer (notification or synchronization) * NOTE: When a notification type expires all waiting threads are released - * and the timer remains signalled until it is explicitly reset. When a + * and the timer remains signalled until it is explicitly reset. When a * syncrhonization timer expires its state is set to signalled until a * single waiting thread is released and then the timer is reset. */ -VOID +VOID STDCALL KeInitializeTimerEx (PKTIMER Timer, TIMER_TYPE Type) { DPRINT("KeInitializeTimerEx(%x, %d)\n", Timer, Type); - + /* Initialize the Dispatch Header */ KeInitializeDispatcherHeader(&Timer->Header, TimerNotificationObject + Type, sizeof(KTIMER) / sizeof(ULONG), FALSE); - + /* Initalize the Other data */ Timer->DueTime.QuadPart = 0; Timer->Period = 0; @@ -120,7 +120,7 @@ KeInitializeTimerEx (PKTIMER Timer, /* * @implemented */ -BOOLEAN +BOOLEAN STDCALL KeReadStateTimer (PKTIMER Timer) { @@ -132,7 +132,7 @@ KeReadStateTimer (PKTIMER Timer) * @implemented * * FUNCTION: Sets the absolute or relative interval at which a timer object - * is to be set to the signaled state and optionally supplies a + * is to be set to the signaled state and optionally supplies a * CustomTimerDpc to be executed when the timer expires. * ARGUMENTS: * Timer = Points to a previously initialized timer object @@ -142,7 +142,7 @@ KeReadStateTimer (PKTIMER Timer) * RETURNS: True if the timer was already in the system timer queue * False otherwise */ -BOOLEAN +BOOLEAN STDCALL KeSetTimer (PKTIMER Timer, LARGE_INTEGER DueTime, @@ -156,7 +156,7 @@ KeSetTimer (PKTIMER Timer, * @implemented * * FUNCTION: Sets the absolute or relative interval at which a timer object - * is to be set to the signaled state and optionally supplies a + * is to be set to the signaled state and optionally supplies a * CustomTimerDpc to be executed when the timer expires. * ARGUMENTS: * Timer = Points to a previously initialized timer object @@ -166,7 +166,7 @@ KeSetTimer (PKTIMER Timer, * RETURNS: True if the timer was already in the system timer queue * False otherwise */ -BOOLEAN +BOOLEAN STDCALL KeSetTimerEx (PKTIMER Timer, LARGE_INTEGER DueTime, @@ -184,18 +184,18 @@ KeSetTimerEx (PKTIMER Timer, /* Check if it's inserted, and remove it if it is */ if ((Inserted = Timer->Header.Inserted)) { - + /* Remove from list */ DPRINT("Timer was already inserted\n"); RemoveEntryList(&Timer->TimerListEntry); - Timer->Header.Inserted = FALSE; + Timer->Header.Inserted = FALSE; } - - /* Set Default Timer Data */ + + /* Set Default Timer Data */ Timer->Dpc = Dpc; Timer->Period = Period; Timer->Header.SignalState = FALSE; - + /* Insert it */ if (!KiInsertTimer(Timer, DueTime)) { @@ -224,41 +224,41 @@ KiExpireTimers(PKDPC Dpc, KIRQL OldIrql; DPRINT("KiExpireTimers(Dpc: %x)\n", Dpc); - + /* Initialize the Expired Timer List */ InitializeListHead(&ExpiredTimerList); /* Lock the Database and Raise IRQL */ OldIrql = KeAcquireDispatcherDatabaseLock(); - - /* Query Interrupt Times */ + + /* Query Interrupt Times */ InterruptTime = KeQueryInterruptTime(); /* Loop through the Timer List and remove Expired Timers. Insert them into the Expired Listhead */ CurrentEntry = KiTimerListHead.Flink; while (CurrentEntry != &KiTimerListHead) { - + /* Get the Current Timer */ Timer = CONTAINING_RECORD(CurrentEntry, KTIMER, TimerListEntry); DPRINT("Looping for Timer: %x. Duetime: %I64d. InterruptTime %I64d \n", Timer, Timer->DueTime.QuadPart, InterruptTime); - + /* Check if we have to Expire it */ if (InterruptTime < Timer->DueTime.QuadPart) break; - + CurrentEntry = CurrentEntry->Flink; - + /* Remove it from the Timer List, add it to the Expired List */ RemoveEntryList(&Timer->TimerListEntry); InsertTailList(&ExpiredTimerList, &Timer->TimerListEntry); } - + /* Expire the Timers */ while ((CurrentEntry = RemoveHeadList(&ExpiredTimerList)) != &ExpiredTimerList) { - + /* Get the Timer */ Timer = CONTAINING_RECORD(CurrentEntry, KTIMER, TimerListEntry); DPRINT("Expiring Timer: %x\n", Timer); - + /* Expire it */ KiHandleExpiredTimer(Timer); } @@ -273,29 +273,29 @@ KiExpireTimers(PKDPC Dpc, * We enter this function at IRQL DISPATCH_LEVEL, and with the * Dispatcher Lock held! */ -VOID +VOID STDCALL KiHandleExpiredTimer(PKTIMER Timer) { LARGE_INTEGER DueTime; DPRINT("HandleExpiredTime(Timer %x)\n", Timer); - + if(Timer->Header.Inserted) { /* First of all, remove the Timer */ Timer->Header.Inserted = FALSE; RemoveEntryList(&Timer->TimerListEntry); } - + /* Set it as Signaled */ DPRINT("Setting Timer as Signaled\n"); Timer->Header.SignalState = TRUE; - KiWaitTest(&Timer->Header, IO_NO_INCREMENT); + KiWaitTest(&Timer->Header, IO_NO_INCREMENT); /* If the Timer is periodic, reinsert the timer with the new due time */ if (Timer->Period) { - + /* Reinsert the Timer */ DueTime.QuadPart = Timer->Period * -SYSTEM_TIME_UNITS_PER_MSEC; if (!KiInsertTimer(Timer, DueTime)) { @@ -304,17 +304,17 @@ KiHandleExpiredTimer(PKTIMER Timer) DPRINT("CRITICAL UNHANDLED CASE: TIMER ALREADY EXPIRED!!!\n"); }; } - + /* Check if the Timer has a DPC */ if (Timer->Dpc) { DPRINT("Timer->Dpc %x Timer->Dpc->DeferredRoutine %x\n", Timer->Dpc, Timer->Dpc->DeferredRoutine); - + /* Insert the DPC */ KeInsertQueueDpc(Timer->Dpc, NULL, NULL); - + DPRINT("Finished dpc routine\n"); } } @@ -330,54 +330,54 @@ KiInsertTimer(PKTIMER Timer, LARGE_INTEGER SystemTime; LARGE_INTEGER DifferenceTime; ULONGLONG InterruptTime; - + DPRINT("KiInsertTimer(Timer %x DueTime %I64d)\n", Timer, DueTime.QuadPart); - + /* Set default data */ Timer->Header.Inserted = TRUE; Timer->Header.Absolute = FALSE; if (!Timer->Period) Timer->Header.SignalState = FALSE; - + /* Convert to relative time if needed */ if (DueTime.u.HighPart >= 0) { - + /* Get System Time */ KeQuerySystemTime(&SystemTime); - + /* Do the conversion */ DifferenceTime.QuadPart = SystemTime.QuadPart - DueTime.QuadPart; DPRINT("Time Difference is: %I64d\n", DifferenceTime.QuadPart); - + /* Make sure it hasn't already expired */ if (DifferenceTime.u.HighPart >= 0) { - + /* Cancel everything */ DPRINT("Timer already expired: %d\n", DifferenceTime.u.HighPart); Timer->Header.SignalState = TRUE; Timer->Header.Inserted = FALSE; return FALSE; } - + /* Set the time as Absolute */ Timer->Header.Absolute = TRUE; DueTime = DifferenceTime; } - + /* Get the Interrupt Time */ InterruptTime = KeQueryInterruptTime(); - + /* Set the Final Due Time */ Timer->DueTime.QuadPart = InterruptTime - DueTime.QuadPart; DPRINT("Final Due Time is: %I64d\n", Timer->DueTime.QuadPart); - - /* Now insert it into the Timer List */ + + /* Now insert it into the Timer List */ DPRINT("Inserting Timer into list\n"); - InsertAscendingList(&KiTimerListHead, + InsertAscendingList(&KiTimerListHead, KTIMER, - TimerListEntry, + TimerListEntry, Timer, DueTime.QuadPart); - + return TRUE; } /* EOF */ diff --git a/reactos/ntoskrnl/ke/usercall.c b/reactos/ntoskrnl/ke/usercall.c index 02573bfad44..96592954e0b 100644 --- a/reactos/ntoskrnl/ke/usercall.c +++ b/reactos/ntoskrnl/ke/usercall.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/usercall.c * PURPOSE: User-Mode callbacks. Portable part. - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) */ @@ -17,8 +17,8 @@ #if ALEX_CB_REWRITE -NTSTATUS -STDCALL +NTSTATUS +STDCALL KiSwitchToUserMode(IN PVOID *OutputBuffer, IN PULONG OutputLength); @@ -54,8 +54,8 @@ PsInitialiseW32Call(VOID) } VOID STATIC -PsFreeCallbackStackPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address, - PFN_TYPE Page, SWAPENTRY SwapEntry, +PsFreeCallbackStackPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address, + PFN_TYPE Page, SWAPENTRY SwapEntry, BOOLEAN Dirty) { ASSERT(SwapEntry == 0); @@ -161,7 +161,7 @@ KeUserModeCallback(IN ULONG RoutineIndex, IN ULONG ArgumentLength, OUT PVOID *Result, OUT PULONG ResultLength) -{ +{ PETHREAD Thread; PVOID NewStack; ULONG_PTR StackSize; @@ -171,7 +171,7 @@ KeUserModeCallback(IN ULONG RoutineIndex, NTSTATUS CallbackStatus; NTW32CALL_SAVED_STATE SavedState; PNTW32CALL_CALLBACK_STACK AssignedStack; - + PAGED_CODE(); DPRINT("KeUserModeCallback(RoutineIndex %d, Argument %X, ArgumentLength %d)\n", @@ -239,8 +239,8 @@ KeUserModeCallback(IN ULONG RoutineIndex, KeGetCurrentKPCR()->TSS->Esp0 = (ULONG)Thread->Tcb.InitialStack - sizeof(FX_SAVE_AREA); KePushAndStackSwitchAndSysRet((ULONG)&SavedState, Thread->Tcb.KernelStack); - /* - * The callback return will have already restored most of the state we + /* + * The callback return will have already restored most of the state we * modified. */ KeLowerIrql(DISPATCH_LEVEL); @@ -249,5 +249,5 @@ KeUserModeCallback(IN ULONG RoutineIndex, KeReleaseSpinLock(&CallbackStackListLock, PASSIVE_LEVEL); return(CallbackStatus); } - + /* EOF */ diff --git a/reactos/ntoskrnl/ke/wait.c b/reactos/ntoskrnl/ke/wait.c index 4c74388c471..9faf3209e19 100644 --- a/reactos/ntoskrnl/ke/wait.c +++ b/reactos/ntoskrnl/ke/wait.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS project * FILE: ntoskrnl/ke/wait.c * PURPOSE: Manages non-busy waiting - * + * * PROGRAMMERS: Alex Ionescu - Fixes and optimization. * Gunnar Dalsnes - Implementation */ @@ -37,23 +37,23 @@ KiCheckAlertability(BOOLEAN Alertable, { /* At this point, we have to do a wait, so make sure we can make the thread Alertable if requested */ if (Alertable) { - - /* If the Thread is Alerted, set the Wait Status accordingly */ + + /* If the Thread is Alerted, set the Wait Status accordingly */ if (CurrentThread->Alerted[(int)WaitMode]) { - + CurrentThread->Alerted[(int)WaitMode] = FALSE; DPRINT("Thread was Alerted\n"); *Status = STATUS_ALERTED; - + /* If there are User APCs Pending, then we can't really be alertable */ - } else if ((!IsListEmpty(&CurrentThread->ApcState.ApcListHead[UserMode])) && + } else if ((!IsListEmpty(&CurrentThread->ApcState.ApcListHead[UserMode])) && (WaitMode == UserMode)) { - + DPRINT("APCs are Pending\n"); CurrentThread->ApcState.UserApcPending = TRUE; *Status = STATUS_USER_APC; } - + /* If there are User APCs Pending and we are waiting in usermode, then we must notify the caller */ } else if ((CurrentThread->ApcState.UserApcPending) && (WaitMode == UserMode)) { DPRINT("APCs are Pending\n"); @@ -64,7 +64,7 @@ KiCheckAlertability(BOOLEAN Alertable, /* * @implemented * - * FUNCTION: Puts the current thread into an alertable or nonalertable + * FUNCTION: Puts the current thread into an alertable or nonalertable * wait state for a given internal * ARGUMENTS: * WaitMode = Processor mode in which the caller is waiting @@ -72,7 +72,7 @@ KiCheckAlertability(BOOLEAN Alertable, * Interval = Specifies the interval to wait * RETURNS: Status */ -NTSTATUS +NTSTATUS STDCALL KeDelayExecutionThread(KPROCESSOR_MODE WaitMode, BOOLEAN Alertable, @@ -87,83 +87,83 @@ KeDelayExecutionThread(KPROCESSOR_MODE WaitMode, /* Check if the lock is already held */ if (CurrentThread->WaitNext) { - + /* Lock is held, disable Wait Next */ DPRINT("Lock is held\n"); CurrentThread->WaitNext = FALSE; - + } else { - + /* Lock not held, acquire it */ DPRINT("Lock is not held, acquiring\n"); CurrentThread->WaitIrql = KeAcquireDispatcherDatabaseLock(); } - + /* Use built-in Wait block */ TimerWaitBlock = &CurrentThread->WaitBlock[TIMER_WAIT_BLOCK]; - + /* Start Wait Loop */ do { - + /* We are going to wait no matter what (that's the point), so test Alertability */ KiCheckAlertability(Alertable, CurrentThread, KernelMode, &Status); - + /* Set Timer */ ThreadTimer = &CurrentThread->Timer; - + /* Setup the Wait Block */ CurrentThread->WaitBlockList = TimerWaitBlock; TimerWaitBlock->Object = (PVOID)ThreadTimer; TimerWaitBlock->Thread = CurrentThread; TimerWaitBlock->WaitKey = (USHORT)STATUS_TIMEOUT; - TimerWaitBlock->WaitType = WaitAny; + TimerWaitBlock->WaitType = WaitAny; TimerWaitBlock->NextWaitBlock = TimerWaitBlock; - + /* Link the timer to this Wait Block */ InitializeListHead(&ThreadTimer->Header.WaitListHead); InsertTailList(&ThreadTimer->Header.WaitListHead, &TimerWaitBlock->WaitListEntry); /* Insert the Timer into the Timer Lists and enable it */ - if (!KiInsertTimer(ThreadTimer, *Interval)) { + if (!KiInsertTimer(ThreadTimer, *Interval)) { /* FIXME: The timer already expired, we should find a new ready thread */ Status = STATUS_SUCCESS; break; - } - + } + /* Handle Kernel Queues */ if (CurrentThread->Queue) { - + DPRINT("Waking Queue\n"); KiWakeQueue(CurrentThread->Queue); } /* Block the Thread */ DPRINT("Blocking the Thread: %d, %d, %x\n", Alertable, WaitMode, KeGetCurrentThread()); - KiBlockThread(&Status, - Alertable, - WaitMode, + KiBlockThread(&Status, + Alertable, + WaitMode, DelayExecution); - + /* Check if we were executing an APC or if we timed out */ if (Status != STATUS_KERNEL_APC) { - + /* This is a good thing */ if (Status == STATUS_TIMEOUT) Status = STATUS_SUCCESS; - + /* Return Status */ return Status; } - + DPRINT("Looping Again\n"); CurrentThread->WaitIrql = KeAcquireDispatcherDatabaseLock(); - + } while (TRUE); - + /* Release the Lock, we are done */ DPRINT("Returning from KeDelayExecutionThread(), %x. Status: %d\n", KeGetCurrentThread(), Status); KeReleaseDispatcherDatabaseLock(CurrentThread->WaitIrql); - return Status; + return Status; } /* @@ -181,7 +181,7 @@ KeDelayExecutionThread(KPROCESSOR_MODE WaitMode, * Timeout = Optional timeout value * RETURNS: Status */ -NTSTATUS +NTSTATUS STDCALL KeWaitForSingleObject(PVOID Object, KWAIT_REASON WaitReason, @@ -198,16 +198,16 @@ KeWaitForSingleObject(PVOID Object, NTSTATUS WaitStatus; DPRINT("Entering KeWaitForSingleObject\n"); - + /* Check if the lock is already held */ if (CurrentThread->WaitNext) { - + /* Lock is held, disable Wait Next */ DPRINT("Lock is held\n"); CurrentThread->WaitNext = FALSE; - + } else { - + /* Lock not held, acquire it */ DPRINT("Lock is not held, acquiring\n"); CurrentThread->WaitIrql = KeAcquireDispatcherDatabaseLock(); @@ -215,17 +215,17 @@ KeWaitForSingleObject(PVOID Object, /* Start the actual Loop */ do { - + /* Get the current Wait Status */ WaitStatus = CurrentThread->WaitStatus; - + /* Append wait block to the KTHREAD wait block list */ CurrentThread->WaitBlockList = WaitBlock = &CurrentThread->WaitBlock[0]; - + /* Get the Current Object */ CurrentObject = (PDISPATCHER_HEADER)Object; - - /* FIXME: + + /* FIXME: * Temporary hack until my Object Manager re-write. Basically some objects, like * the File Object, but also LPCs and others, are actually waitable on their event. * The Object Manager sets this up in The ObjectTypeInformation->DefaultObject member, @@ -236,119 +236,119 @@ KeWaitForSingleObject(PVOID Object, * -- Alex Ionescu 24/02/05 */ if (CurrentObject->Type == IO_TYPE_FILE) { - + DPRINT1("Hack used: %x\n", &((PFILE_OBJECT)CurrentObject)->Event); CurrentObject = (PDISPATCHER_HEADER)(&((PFILE_OBJECT)CurrentObject)->Event); } /* Check if the Object is Signaled */ if (KiIsObjectSignaled(CurrentObject, CurrentThread)) { - + /* Just unwait this guy and exit */ if (CurrentObject->SignalState != MINLONG) { - + /* It has a normal signal state, so unwait it and return */ KiSatisfyObjectWait(CurrentObject, CurrentThread); Status = STATUS_WAIT_0; goto WaitDone; - + } else { - + /* Is this a Mutant? */ if (CurrentObject->Type == MutantObject) { - + /* According to wasm.ru, we must raise this exception (tested and true) */ KeReleaseDispatcherDatabaseLock(CurrentThread->WaitIrql); - ExRaiseStatus(STATUS_MUTANT_LIMIT_EXCEEDED); - } + ExRaiseStatus(STATUS_MUTANT_LIMIT_EXCEEDED); + } } } - + /* Set up the Wait Block */ WaitBlock->Object = CurrentObject; WaitBlock->Thread = CurrentThread; WaitBlock->WaitKey = (USHORT)(STATUS_WAIT_0); - WaitBlock->WaitType = WaitAny; + WaitBlock->WaitType = WaitAny; WaitBlock->NextWaitBlock = WaitBlock; - + /* Make sure we can satisfy the Alertable request */ KiCheckAlertability(Alertable, CurrentThread, WaitMode, &Status); - + /* Set the Wait Status */ CurrentThread->WaitStatus = Status; - + /* Enable the Timeout Timer if there was any specified */ if (Timeout != NULL) { - + /* However if 0 timeout was specified, then we must fail since we need to peform a wait */ if (!Timeout->QuadPart) { - + /* Return a timeout */ Status = STATUS_TIMEOUT; goto WaitDone; } - + /* Point to Timer Wait Block and Thread Timer */ TimerWaitBlock = &CurrentThread->WaitBlock[TIMER_WAIT_BLOCK]; ThreadTimer = &CurrentThread->Timer; /* Connect the Timer Wait Block */ WaitBlock->NextWaitBlock = TimerWaitBlock; - + /* Set up the Timer Wait Block */ TimerWaitBlock->Object = (PVOID)ThreadTimer; TimerWaitBlock->Thread = CurrentThread; TimerWaitBlock->WaitKey = STATUS_TIMEOUT; TimerWaitBlock->WaitType = WaitAny; TimerWaitBlock->NextWaitBlock = WaitBlock; - + /* Link the timer to this Wait Block */ InitializeListHead(&ThreadTimer->Header.WaitListHead); InsertTailList(&ThreadTimer->Header.WaitListHead, &TimerWaitBlock->WaitListEntry); /* Insert the Timer into the Timer Lists and enable it */ - if (!KiInsertTimer(ThreadTimer, *Timeout)) { + if (!KiInsertTimer(ThreadTimer, *Timeout)) { /* Return a timeout if we couldn't insert the timer for some reason */ Status = STATUS_TIMEOUT; goto WaitDone; - } + } } /* Link the Object to this Wait Block */ - InsertTailList(&CurrentObject->WaitListHead, &WaitBlock->WaitListEntry); - + InsertTailList(&CurrentObject->WaitListHead, &WaitBlock->WaitListEntry); + /* Handle Kernel Queues */ if (CurrentThread->Queue) { - + DPRINT("Waking Queue\n"); KiWakeQueue(CurrentThread->Queue); } /* Block the Thread */ DPRINT("Blocking the Thread: %d, %d, %d, %x\n", Alertable, WaitMode, WaitReason, KeGetCurrentThread()); - KiBlockThread(&Status, - Alertable, - WaitMode, + KiBlockThread(&Status, + Alertable, + WaitMode, (UCHAR)WaitReason); - + /* Check if we were executing an APC */ if (Status != STATUS_KERNEL_APC) { - + /* Return Status */ return Status; } - + DPRINT("Looping Again\n"); CurrentThread->WaitIrql = KeAcquireDispatcherDatabaseLock(); - + } while (TRUE); - + WaitDone: /* Release the Lock, we are done */ DPRINT("Returning from KeWaitForMultipleObjects(), %x. Status: %d\n", KeGetCurrentThread(), Status); KeReleaseDispatcherDatabaseLock(CurrentThread->WaitIrql); - return Status; + return Status; } /* @@ -379,16 +379,16 @@ KeWaitForMultipleObjects(ULONG Count, /* Set the Current Thread */ CurrentThread = KeGetCurrentThread(); - + /* Check if the lock is already held */ if (CurrentThread->WaitNext) { - + /* Lock is held, disable Wait Next */ DPRINT("Lock is held\n"); CurrentThread->WaitNext = FALSE; - + } else { - + /* Lock not held, acquire it */ DPRINT("Lock is not held, acquiring\n"); CurrentThread->WaitIrql = KeAcquireDispatcherDatabaseLock(); @@ -396,44 +396,44 @@ KeWaitForMultipleObjects(ULONG Count, /* Make sure the Wait Count is valid for the Thread and Maximum Wait Objects */ if (!WaitBlockArray) { - + /* Check in regards to the Thread Object Limit */ if (Count > THREAD_WAIT_OBJECTS) { - + KEBUGCHECK(MAXIMUM_WAIT_OBJECTS_EXCEEDED); } - + /* Use the Thread's Wait Block */ WaitBlockArray = &CurrentThread->WaitBlock[0]; - + } else { - + /* Using our own Block Array. Check in regards to System Object Limit */ if (Count > MAXIMUM_WAIT_OBJECTS) { - + KEBUGCHECK(MAXIMUM_WAIT_OBJECTS_EXCEEDED); } } - + /* Start the actual Loop */ do { - + /* Get the current Wait Status */ WaitStatus = CurrentThread->WaitStatus; - + /* Append wait block to the KTHREAD wait block list */ CurrentThread->WaitBlockList = WaitBlock = WaitBlockArray; - + /* Check if the wait is (already) satisfied */ AllObjectsSignaled = TRUE; - + /* First, we'll try to satisfy the wait directly */ for (WaitIndex = 0; WaitIndex < Count; WaitIndex++) { - + /* Get the Current Object */ CurrentObject = (PDISPATCHER_HEADER)Object[WaitIndex]; - - /* FIXME: + + /* FIXME: * Temporary hack until my Object Manager re-write. Basically some objects, like * the File Object, but also LPCs and others, are actually waitable on their event. * The Object Manager sets this up in The ObjectTypeInformation->DefaultObject member, @@ -444,38 +444,38 @@ KeWaitForMultipleObjects(ULONG Count, * -- Alex Ionescu 24/02/05 */ if (CurrentObject->Type == IO_TYPE_FILE) { - + CurrentObject = (PDISPATCHER_HEADER)(&((PFILE_OBJECT)CurrentObject)->Event); } /* Check if the Object is Signaled */ if (KiIsObjectSignaled(CurrentObject, CurrentThread)) { - - /* Check what kind of wait this is */ + + /* Check what kind of wait this is */ if (WaitType == WaitAny) { - + /* This is a Wait Any, so just unwait this guy and exit */ if (CurrentObject->SignalState != MINLONG) { - + /* It has a normal signal state, so unwait it and return */ KiSatisfyObjectWait(CurrentObject, CurrentThread); Status = STATUS_WAIT_0 | WaitIndex; goto WaitDone; - + } else { - + /* Is this a Mutant? */ if (CurrentObject->Type == MutantObject) { - + /* According to wasm.ru, we must raise this exception (tested and true) */ KeReleaseDispatcherDatabaseLock(CurrentThread->WaitIrql); - ExRaiseStatus(STATUS_MUTANT_LIMIT_EXCEEDED); - } + ExRaiseStatus(STATUS_MUTANT_LIMIT_EXCEEDED); + } } } - + } else { - + /* One of the objects isn't signaled... if this is a WaitAll, we will fail later */ AllObjectsSignaled = FALSE; } @@ -484,65 +484,65 @@ KeWaitForMultipleObjects(ULONG Count, WaitBlock->Object = CurrentObject; WaitBlock->Thread = CurrentThread; WaitBlock->WaitKey = (USHORT)(STATUS_WAIT_0 + WaitIndex); - WaitBlock->WaitType = (USHORT)WaitType; + WaitBlock->WaitType = (USHORT)WaitType; WaitBlock->NextWaitBlock = WaitBlock + 1; - + /* Move to the next Wait Block */ WaitBlock = WaitBlock->NextWaitBlock; } - + /* Return to the Root Wait Block */ WaitBlock--; WaitBlock->NextWaitBlock = WaitBlockArray; - + /* Check if this is a Wait All and all the objects are signaled */ if ((WaitType == WaitAll) && (AllObjectsSignaled)) { - + /* Return to the Root Wait Block */ WaitBlock = CurrentThread->WaitBlockList; - + /* Satisfy their Waits and return to the caller */ KiSatisifyMultipleObjectWaits(WaitBlock); Status = STATUS_WAIT_0; goto WaitDone; } - + /* Make sure we can satisfy the Alertable request */ KiCheckAlertability(Alertable, CurrentThread, WaitMode, &Status); - + /* Set the Wait Status */ CurrentThread->WaitStatus = Status; - + /* Enable the Timeout Timer if there was any specified */ if (Timeout != NULL) { - + /* However if 0 timeout was specified, then we must fail since we need to peform a wait */ if (!Timeout->QuadPart) { - + /* Return a timeout */ Status = STATUS_TIMEOUT; goto WaitDone; } - + /* Point to Timer Wait Block and Thread Timer */ TimerWaitBlock = &CurrentThread->WaitBlock[TIMER_WAIT_BLOCK]; ThreadTimer = &CurrentThread->Timer; /* Connect the Timer Wait Block */ WaitBlock->NextWaitBlock = TimerWaitBlock; - + /* Set up the Timer Wait Block */ TimerWaitBlock->Object = (PVOID)ThreadTimer; TimerWaitBlock->Thread = CurrentThread; TimerWaitBlock->WaitKey = STATUS_TIMEOUT; TimerWaitBlock->WaitType = WaitAny; TimerWaitBlock->NextWaitBlock = WaitBlockArray; - + /* Link the timer to this Wait Block */ InitializeListHead(&ThreadTimer->Header.WaitListHead); /* Insert the Timer into the Timer Lists and enable it */ - if (!KiInsertTimer(ThreadTimer, *Timeout)) { + if (!KiInsertTimer(ThreadTimer, *Timeout)) { /* Return a timeout if we couldn't insert the timer for some reason */ Status = STATUS_TIMEOUT; @@ -553,43 +553,43 @@ KeWaitForMultipleObjects(ULONG Count, /* Insert into Object's Wait List*/ WaitBlock = CurrentThread->WaitBlockList; do { - + /* Get the Current Object */ CurrentObject = WaitBlock->Object; - + /* Link the Object to this Wait Block */ InsertTailList(&CurrentObject->WaitListHead, &WaitBlock->WaitListEntry); - + /* Move to the next Wait Block */ WaitBlock = WaitBlock->NextWaitBlock; } while (WaitBlock != WaitBlockArray); - + /* Handle Kernel Queues */ if (CurrentThread->Queue) { - + DPRINT("Waking Queue\n"); KiWakeQueue(CurrentThread->Queue); } - + /* Block the Thread */ DPRINT("Blocking the Thread: %d, %d, %d, %x\n", Alertable, WaitMode, WaitReason, KeGetCurrentThread()); - KiBlockThread(&Status, - Alertable, + KiBlockThread(&Status, + Alertable, WaitMode, (UCHAR)WaitReason); - + /* Check if we were executing an APC */ if (Status != STATUS_KERNEL_APC) { - + /* Return Status */ return Status; } - + DPRINT("Looping Again\n"); CurrentThread->WaitIrql = KeAcquireDispatcherDatabaseLock(); - + } while (TRUE); - + WaitDone: /* Release the Lock, we are done */ DPRINT("Returning from KeWaitForMultipleObjects(), %x. Status: %d\n", KeGetCurrentThread(), Status); @@ -605,43 +605,43 @@ KiSatisfyObjectWait(PDISPATCHER_HEADER Object, { /* Special case for Mutants */ if (Object->Type == MutantObject) { - + /* Decrease the Signal State */ Object->SignalState--; - + /* Check if it's now non-signaled */ if (Object->SignalState == 0) { - + /* Set the Owner Thread */ ((PKMUTANT)Object)->OwnerThread = Thread; - + /* Disable APCs if needed */ Thread->KernelApcDisable -= ((PKMUTANT)Object)->ApcDisable; - + /* Check if it's abandoned */ if (((PKMUTANT)Object)->Abandoned) { - + /* Unabandon it */ ((PKMUTANT)Object)->Abandoned = FALSE; - + /* Return Status */ Thread->WaitStatus = STATUS_ABANDONED; } - + /* Insert it into the Mutant List */ InsertHeadList(&Thread->MutantListHead, &((PKMUTANT)Object)->MutantListEntry); } - + } else if ((Object->Type & TIMER_OR_EVENT_TYPE) == EventSynchronizationObject) { - + /* These guys (Syncronization Timers and Events) just get un-signaled */ Object->SignalState = 0; - + } else if (Object->Type == SemaphoreObject) { /* These ones can have multiple signalings, so we only decrease it */ Object->SignalState--; - } + } } VOID @@ -654,53 +654,53 @@ KiWaitTest(PDISPATCHER_HEADER Object, PKWAIT_BLOCK CurrentWaitBlock; PKWAIT_BLOCK NextWaitBlock; PKTHREAD WaitThread; - + /* Loop the Wait Entries */ DPRINT("KiWaitTest for Object: %x\n", Object); WaitList = &Object->WaitListHead; WaitEntry = WaitList->Flink; while ((WaitEntry != WaitList) && (Object->SignalState > 0)) { - + /* Get the current wait block */ CurrentWaitBlock = CONTAINING_RECORD(WaitEntry, KWAIT_BLOCK, WaitListEntry); WaitThread = CurrentWaitBlock->Thread; - + /* Check the current Wait Mode */ if (CurrentWaitBlock->WaitType == WaitAny) { - + /* Easy case, satisfy only this wait */ DPRINT("Satisfiying a Wait any\n"); WaitEntry = WaitEntry->Blink; KiSatisfyObjectWait(Object, WaitThread); - + } else { - + /* Everything must be satisfied */ DPRINT("Checking for a Wait All\n"); NextWaitBlock = CurrentWaitBlock->NextWaitBlock; - + /* Loop first to make sure they are valid */ while (NextWaitBlock != CurrentWaitBlock) { - + /* Check if the object is signaled */ DPRINT("Checking: %x %d\n", NextWaitBlock->Object, Object->SignalState); if (!KiIsObjectSignaled(NextWaitBlock->Object, WaitThread)) { - + /* It's not, move to the next one */ DPRINT("One of the object is non-signaled, sorry.\n"); goto SkipUnwait; } - + /* Go to the next Wait block */ NextWaitBlock = NextWaitBlock->NextWaitBlock; } - + /* All the objects are signaled, we can satisfy */ DPRINT("Satisfiying a Wait All\n"); WaitEntry = WaitEntry->Blink; KiSatisifyMultipleObjectWaits(CurrentWaitBlock); } - + /* All waits satisfied, unwait the thread */ DPRINT("Unwaiting the Thread\n"); KiAbortWaitThread(WaitThread, CurrentWaitBlock->WaitKey, Increment); @@ -709,14 +709,14 @@ SkipUnwait: /* Next entry */ WaitEntry = WaitEntry->Flink; } - + DPRINT("Done\n"); -} +} /* Must be called with the dispatcher lock held */ VOID -FASTCALL -KiAbortWaitThread(PKTHREAD Thread, +FASTCALL +KiAbortWaitThread(PKTHREAD Thread, NTSTATUS WaitStatus, KPRIORITY Increment) { @@ -730,27 +730,27 @@ KiAbortWaitThread(PKTHREAD Thread, DPRINT("Removing waits\n"); WaitBlock = Thread->WaitBlockList; do { - + /* Remove it */ DPRINT("Removing Waitblock: %x, %x\n", WaitBlock, WaitBlock->NextWaitBlock); RemoveEntryList(&WaitBlock->WaitListEntry); - + /* Go to the next one */ WaitBlock = WaitBlock->NextWaitBlock; } while (WaitBlock != Thread->WaitBlockList); - + /* Check if there's a Thread Timer */ if (Thread->Timer.Header.Inserted) { - + /* Cancel the Thread Timer with the no-lock fastpath */ DPRINT("Removing the Thread's Timer\n"); Thread->Timer.Header.Inserted = FALSE; RemoveEntryList(&Thread->Timer.TimerListEntry); } - + /* Increment the Queue's active threads */ if (Thread->Queue) { - + DPRINT("Incrementing Queue's active threads\n"); Thread->Queue->CurrentCount++; } @@ -769,24 +769,24 @@ KiIsObjectSignaled(PDISPATCHER_HEADER Object, /* Mutants are...well...mutants! */ if (Object->Type == MutantObject) { - /* + /* * Because Cutler hates mutants, they are actually signaled if the Signal State is <= 0 * Well, only if they are recursivly acquired (i.e if we own it right now). * Of course, they are also signaled if their signal state is 1. */ - if ((Object->SignalState <= 0 && ((PKMUTANT)Object)->OwnerThread == Thread) || + if ((Object->SignalState <= 0 && ((PKMUTANT)Object)->OwnerThread == Thread) || (Object->SignalState == 1)) { - + /* Signaled Mutant */ return (TRUE); - + } else { - + /* Unsignaled Mutant */ return (FALSE); } } - + /* Any other object is not a mutated freak, so let's use logic */ return (!Object->SignalState <= 0); } @@ -798,7 +798,7 @@ KiIsObjectWaitable(PVOID Object) { POBJECT_HEADER Header; Header = BODY_TO_HEADER(Object); - + if (Header->ObjectType == ExEventObjectType || Header->ObjectType == ExIoCompletionType || Header->ObjectType == ExMutantObjectType || @@ -807,11 +807,11 @@ KiIsObjectWaitable(PVOID Object) Header->ObjectType == PsProcessType || Header->ObjectType == PsThreadType || Header->ObjectType == IoFileObjectType) { - + return TRUE; - + } else { - + return FALSE; } } @@ -823,10 +823,10 @@ KiSatisifyMultipleObjectWaits(PKWAIT_BLOCK WaitBlock) { PKWAIT_BLOCK FirstBlock = WaitBlock; PKTHREAD WaitThread = WaitBlock->Thread; - + /* Loop through all the Wait Blocks, and wake each Object */ do { - + /* Wake the Object */ KiSatisfyObjectWait(WaitBlock->Object, WaitThread); WaitBlock = WaitBlock->NextWaitBlock; @@ -868,7 +868,7 @@ KeAcquireDispatcherDatabaseLockAtDpcLevel(VOID) KeAcquireSpinLockAtDpcLevel (&DispatcherDatabaseLock); } -VOID +VOID inline FASTCALL KeInitializeDispatcher(VOID) @@ -883,14 +883,14 @@ FASTCALL KeReleaseDispatcherDatabaseLock(KIRQL OldIrql) { /* If it's the idle thread, dispatch */ - if (!KeIsExecutingDpc() && OldIrql < DISPATCH_LEVEL && KeGetCurrentThread() != NULL && + if (!KeIsExecutingDpc() && OldIrql < DISPATCH_LEVEL && KeGetCurrentThread() != NULL && KeGetCurrentThread() == KeGetCurrentPrcb()->IdleThread) { - + KiDispatchThreadNoLock(Ready); KeLowerIrql(OldIrql); - + } else { - + /* Just release the spin lock */ KeReleaseSpinLock(&DispatcherDatabaseLock, OldIrql); } diff --git a/reactos/ntoskrnl/ldr/init.c b/reactos/ntoskrnl/ldr/init.c index aaddd443b46..d68f3535723 100644 --- a/reactos/ntoskrnl/ldr/init.c +++ b/reactos/ntoskrnl/ldr/init.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ldr/init.c * PURPOSE: Loaders for PE executables - * + * * PROGRAMMERS: Jean Michault * Rex Jolliff (rex@lvcablemodem.com) */ @@ -18,7 +18,7 @@ #include -/* +/* * HACK! No matter what i did, i couldnt get it working when i put these into ntos\rtl.h * (got redefinition problems, since ntdll\rtl.h somehow include ntos\rtl.h). * We need to merge ntos\rtl.h and ntdll\rtl.h to get this working. -Gunnar @@ -103,7 +103,7 @@ LdrLoadInitialProcess(PHANDLE ProcessHandle, return Status; } - + Status = RtlCreateProcessParameters( &Params, &ImagePath, @@ -116,14 +116,14 @@ LdrLoadInitialProcess(PHANDLE ProcessHandle, NULL, NULL ); - + if(!NT_SUCCESS(Status)) { DPRINT1("Failed to create ppb!\n"); ZwClose(SystemProcessHandle); return Status; } - + DPRINT("Creating process\n"); @@ -142,7 +142,7 @@ LdrLoadInitialProcess(PHANDLE ProcessHandle, ZwClose(SystemProcessHandle); RtlDestroyProcessParameters(Params); - + if (!NT_SUCCESS(Status)) { DPRINT1("NtCreateProcess() failed (Status %lx)\n", Status); diff --git a/reactos/ntoskrnl/ldr/resource.c b/reactos/ntoskrnl/ldr/resource.c index 97588714a0e..feffb09365b 100644 --- a/reactos/ntoskrnl/ldr/resource.c +++ b/reactos/ntoskrnl/ldr/resource.c @@ -1,5 +1,5 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ldr/resource.c diff --git a/reactos/ntoskrnl/ldr/rtl.c b/reactos/ntoskrnl/ldr/rtl.c index dd345fcf803..af5e2c78053 100644 --- a/reactos/ntoskrnl/ldr/rtl.c +++ b/reactos/ntoskrnl/ldr/rtl.c @@ -33,21 +33,21 @@ LdrGetProcedureAddress (IN PVOID BaseAddress, /* get the pointer to the export directory */ ExportDir = (PIMAGE_EXPORT_DIRECTORY) - RtlImageDirectoryEntryToData (BaseAddress, TRUE, + RtlImageDirectoryEntryToData (BaseAddress, TRUE, IMAGE_DIRECTORY_ENTRY_EXPORT, &i); if (!ExportDir || !i || !ProcedureAddress) { return(STATUS_INVALID_PARAMETER); } - + AddressPtr = (PULONG)RVA((char*)BaseAddress, ExportDir->AddressOfFunctions); if (Name && Name->Length) { LONG minn, maxn; /* by name */ - OrdinalPtr = + OrdinalPtr = (PUSHORT)RVA((char*)BaseAddress, ExportDir->AddressOfNameOrdinals); NamePtr = (PULONG)RVA((char*)BaseAddress, ExportDir->AddressOfNames); @@ -62,7 +62,7 @@ LdrGetProcedureAddress (IN PVOID BaseAddress, Name->Length); if (res == 0) { - *ProcedureAddress = + *ProcedureAddress = (PVOID)RVA((char*)BaseAddress, AddressPtr[OrdinalPtr[mid]]); return(STATUS_SUCCESS); } @@ -78,11 +78,11 @@ LdrGetProcedureAddress (IN PVOID BaseAddress, for (i = 0; i < ExportDir->NumberOfNames; i++, NamePtr++, OrdinalPtr++) { - if (!_strnicmp(Name->Buffer, + if (!_strnicmp(Name->Buffer, (char*)((char*)BaseAddress + *NamePtr), Name->Length)) { - *ProcedureAddress = - (PVOID)((ULONG)BaseAddress + + *ProcedureAddress = + (PVOID)((ULONG)BaseAddress + (ULONG)AddressPtr[*OrdinalPtr]); return STATUS_SUCCESS; } @@ -95,8 +95,8 @@ LdrGetProcedureAddress (IN PVOID BaseAddress, Ordinal &= 0x0000FFFF; if (Ordinal - ExportDir->Base < ExportDir->NumberOfFunctions) { - *ProcedureAddress = - (PVOID)((ULONG)BaseAddress + + *ProcedureAddress = + (PVOID)((ULONG)BaseAddress + (ULONG)AddressPtr[Ordinal - ExportDir->Base]); return STATUS_SUCCESS; } diff --git a/reactos/ntoskrnl/ldr/sysdll.c b/reactos/ntoskrnl/ldr/sysdll.c index 497754910f9..8567ab57407 100644 --- a/reactos/ntoskrnl/ldr/sysdll.c +++ b/reactos/ntoskrnl/ldr/sysdll.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ldr/sysdll.c * PURPOSE: Loaders for PE executables - * + * * PROGRAMMERS: Jean Michault * Rex Jolliff (rex@lvcablemodem.com) * Skywing @@ -60,7 +60,7 @@ LdrpGetSystemDllEntryPoints(VOID) { ANSI_STRING ProcedureName; NTSTATUS Status; - + /* Retrieve ntdll's startup address */ DPRINT("Getting Entrypoint: %p\n", LdrpSystemDllBase); RtlInitAnsiString(&ProcedureName, "LdrInitializeThunk"); @@ -68,9 +68,9 @@ LdrpGetSystemDllEntryPoints(VOID) &ProcedureName, 0, &SystemDllEntryPoint); - + if (!NT_SUCCESS(Status)) { - + DPRINT1 ("LdrGetProcedureAddress failed (Status %x)\n", Status); return (Status); } @@ -82,13 +82,13 @@ LdrpGetSystemDllEntryPoints(VOID) &ProcedureName, 0, &SystemDllApcDispatcher); - + if (!NT_SUCCESS(Status)) { - + DPRINT1 ("LdrGetProcedureAddress failed (Status %x)\n", Status); return (Status); } - + /* Get Exception Dispatcher */ DPRINT("Getting Entrypoint\n"); RtlInitAnsiString(&ProcedureName, "KiUserExceptionDispatcher"); @@ -96,13 +96,13 @@ LdrpGetSystemDllEntryPoints(VOID) &ProcedureName, 0, &SystemDllExceptionDispatcher); - + if (!NT_SUCCESS(Status)) { - + DPRINT1 ("LdrGetProcedureAddress failed (Status %x)\n", Status); return (Status); } - + /* Get Callback Dispatcher */ DPRINT("Getting Entrypoint\n"); RtlInitAnsiString(&ProcedureName, "KiUserCallbackDispatcher"); @@ -110,13 +110,13 @@ LdrpGetSystemDllEntryPoints(VOID) &ProcedureName, 0, &SystemDllCallbackDispatcher); - + if (!NT_SUCCESS(Status)) { - + DPRINT1 ("LdrGetProcedureAddress failed (Status %x)\n", Status); return (Status); } - + /* Get Raise Exception Dispatcher */ DPRINT("Getting Entrypoint\n"); RtlInitAnsiString(&ProcedureName, "KiRaiseUserExceptionDispatcher"); @@ -124,9 +124,9 @@ LdrpGetSystemDllEntryPoints(VOID) &ProcedureName, 0, &SystemDllRaiseExceptionDispatcher); - + if (!NT_SUCCESS(Status)) { - + DPRINT1 ("LdrGetProcedureAddress failed (Status %x)\n", Status); return (Status); } @@ -137,13 +137,13 @@ LdrpGetSystemDllEntryPoints(VOID) NTSTATUS STDCALL -LdrpMapSystemDll(PEPROCESS Process, +LdrpMapSystemDll(PEPROCESS Process, PVOID *DllBase) { NTSTATUS Status; ULONG ViewSize = 0; PVOID ImageBase = 0; - + /* Map the System DLL */ DPRINT("Mapping System DLL\n"); Status = MmMapViewOfSection(LdrpSystemDllSection, @@ -156,14 +156,14 @@ LdrpMapSystemDll(PEPROCESS Process, 0, MEM_COMMIT, PAGE_READWRITE); - + if (!NT_SUCCESS(Status)) { - + DPRINT1("Failed to map System DLL Into Process\n"); } - + if (DllBase) *DllBase = ImageBase; - + return Status; } @@ -180,14 +180,14 @@ LdrpInitializeSystemDll(VOID) CHAR BlockBuffer[1024]; PIMAGE_DOS_HEADER DosHeader; PIMAGE_NT_HEADERS NTHeaders; - + /* Locate and open NTDLL to determine ImageBase and LdrStartup */ InitializeObjectAttributes(&FileObjectAttributes, &DllPathname, 0, NULL, NULL); - + DPRINT("Opening NTDLL\n"); Status = ZwOpenFile(&FileHandle, FILE_READ_ACCESS, @@ -195,12 +195,12 @@ LdrpInitializeSystemDll(VOID) &Iosb, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_NONALERT); - + if (!NT_SUCCESS(Status)) { DPRINT1("NTDLL open failed (Status %x)\n", Status); return Status; } - + /* Load NTDLL is valid */ DPRINT("Reading NTDLL\n"); Status = ZwReadFile(FileHandle, @@ -213,25 +213,25 @@ LdrpInitializeSystemDll(VOID) 0, 0); if (!NT_SUCCESS(Status) || Iosb.Information != sizeof(BlockBuffer)) { - + DPRINT1("NTDLL header read failed (Status %x)\n", Status); ZwClose(FileHandle); return Status; } - + /* Check if it's valid */ DosHeader = (PIMAGE_DOS_HEADER)BlockBuffer; NTHeaders = (PIMAGE_NT_HEADERS)(BlockBuffer + DosHeader->e_lfanew); - - if ((DosHeader->e_magic != IMAGE_DOS_SIGNATURE) || - (DosHeader->e_lfanew == 0L) || + + if ((DosHeader->e_magic != IMAGE_DOS_SIGNATURE) || + (DosHeader->e_lfanew == 0L) || (*(PULONG) NTHeaders != IMAGE_NT_SIGNATURE)) { - + DPRINT1("NTDLL format invalid\n"); - ZwClose(FileHandle); + ZwClose(FileHandle); return(STATUS_UNSUCCESSFUL); } - + /* Create a section for NTDLL */ DPRINT("Creating section\n"); Status = ZwCreateSection(&NTDllSectionHandle, @@ -242,13 +242,13 @@ LdrpInitializeSystemDll(VOID) SEC_IMAGE | SEC_COMMIT, FileHandle); if (!NT_SUCCESS(Status)) { - + DPRINT1("NTDLL create section failed (Status %x)\n", Status); - ZwClose(FileHandle); + ZwClose(FileHandle); return(Status); } - ZwClose(FileHandle); - + ZwClose(FileHandle); + /* Reference the Section */ DPRINT("ObReferenceObjectByHandle section: %d\n", NTDllSectionHandle); Status = ObReferenceObjectByHandle(NTDllSectionHandle, @@ -258,18 +258,18 @@ LdrpInitializeSystemDll(VOID) (PVOID*)&LdrpSystemDllSection, NULL); if (!NT_SUCCESS(Status)) { - + DPRINT1("NTDLL section reference failed (Status %x)\n", Status); return(Status); } - + /* Map it */ LdrpMapSystemDll(PsGetCurrentProcess(), &LdrpSystemDllBase); DPRINT("LdrpSystemDllBase: %x\n", LdrpSystemDllBase); - + /* Now get the Entrypoints */ LdrpGetSystemDllEntryPoints(); - + return STATUS_SUCCESS; } diff --git a/reactos/ntoskrnl/ldr/userldr.c b/reactos/ntoskrnl/ldr/userldr.c index 26c2239840c..136ef09166f 100644 --- a/reactos/ntoskrnl/ldr/userldr.c +++ b/reactos/ntoskrnl/ldr/userldr.c @@ -1,10 +1,10 @@ -/* $Id:$ - * +/* $Id$ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ldr/userldr.c * PURPOSE: Loaders for PE executables - * + * * PROGRAMMERS: Jean Michault * Rex Jolliff (rex@lvcablemodem.com) */ @@ -26,20 +26,20 @@ NTSTATUS LdrpMapImage(HANDLE ProcessHandle, * PARAMETERS: * ProcessHandle * Points to the process to map the image into - * + * * SectionHandle * Points to the section to map - * + * * RETURNS: Status */ -{ +{ ULONG ViewSize; PVOID ImageBase; NTSTATUS Status; ViewSize = 0; ImageBase = 0; - + Status = ZwMapViewOfSection(SectionHandle, ProcessHandle, (PVOID*)&ImageBase, @@ -55,8 +55,8 @@ NTSTATUS LdrpMapImage(HANDLE ProcessHandle, CPRINT("Image map view of section failed (Status %x)", Status); return(Status); } - + *ReturnedImageBase = ImageBase; - + return(STATUS_SUCCESS); } diff --git a/reactos/ntoskrnl/lpc/close.c b/reactos/ntoskrnl/lpc/close.c index c73a8dfe367..b8c681d956b 100644 --- a/reactos/ntoskrnl/lpc/close.c +++ b/reactos/ntoskrnl/lpc/close.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/lpc/close.c * PURPOSE: Communication mechanism - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -88,7 +88,7 @@ VOID STDCALL NiDeletePort (PVOID ObjectBody) { // PEPORT Port = (PEPORT)ObjectBody; - + // DPRINT1("Deleting port %x\n", Port); } diff --git a/reactos/ntoskrnl/lpc/complete.c b/reactos/ntoskrnl/lpc/complete.c index 343e143d966..e14350d5623 100644 --- a/reactos/ntoskrnl/lpc/complete.c +++ b/reactos/ntoskrnl/lpc/complete.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/lpc/complete.c * PURPOSE: Communication mechanism - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -37,9 +37,9 @@ NtCompleteConnectPort (HANDLE hServerSideCommPort) { NTSTATUS Status; PEPORT ReplyPort; - + DPRINT("NtCompleteConnectPort(hServerSideCommPort %x)\n", hServerSideCommPort); - + /* * Ask Ob to translate the port handle to EPORT */ @@ -58,23 +58,23 @@ NtCompleteConnectPort (HANDLE hServerSideCommPort) * otherwise tell the caller the port handle is not * valid. */ - if (ReplyPort->Type != EPORT_TYPE_SERVER_COMM_PORT) + if (ReplyPort->Type != EPORT_TYPE_SERVER_COMM_PORT) { ObDereferenceObject (ReplyPort); return STATUS_INVALID_PORT_HANDLE; } - + ReplyPort->State = EPORT_CONNECTED_SERVER; /* * Wake up the client thread that issued NtConnectPort. - */ - KeReleaseSemaphore(&ReplyPort->OtherPort->Semaphore, IO_NO_INCREMENT, 1, + */ + KeReleaseSemaphore(&ReplyPort->OtherPort->Semaphore, IO_NO_INCREMENT, 1, FALSE); /* * Tell Ob we are no more interested in ReplyPort - */ + */ ObDereferenceObject (ReplyPort); - + return (STATUS_SUCCESS); } diff --git a/reactos/ntoskrnl/lpc/connect.c b/reactos/ntoskrnl/lpc/connect.c index 544788268dd..9bb82a7ea0f 100644 --- a/reactos/ntoskrnl/lpc/connect.c +++ b/reactos/ntoskrnl/lpc/connect.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/lpc/connect.c * PURPOSE: Communication mechanism - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -82,8 +82,8 @@ EiConnectPort(IN PEPORT* ConnectedPort, /* * Allocate a request message. */ - RequestMessage = ExAllocatePool(NonPagedPool, - sizeof(EPORT_CONNECT_REQUEST_MESSAGE) + + RequestMessage = ExAllocatePool(NonPagedPool, + sizeof(EPORT_CONNECT_REQUEST_MESSAGE) + RequestConnectDataLength); if (RequestMessage == NULL) { @@ -94,10 +94,10 @@ EiConnectPort(IN PEPORT* ConnectedPort, /* * Initialize the request message. */ - RequestMessage->MessageHeader.DataSize = + RequestMessage->MessageHeader.DataSize = sizeof(EPORT_CONNECT_REQUEST_MESSAGE) + RequestConnectDataLength - sizeof(LPC_MESSAGE); - RequestMessage->MessageHeader.MessageSize = + RequestMessage->MessageHeader.MessageSize = sizeof(EPORT_CONNECT_REQUEST_MESSAGE) + RequestConnectDataLength; DPRINT("RequestMessageSize %d\n", RequestMessage->MessageHeader.MessageSize); @@ -116,7 +116,7 @@ EiConnectPort(IN PEPORT* ConnectedPort, memcpy(RequestMessage->ConnectData, ConnectData, RequestConnectDataLength); } - + /* * Queue the message to the named port */ @@ -126,7 +126,7 @@ EiConnectPort(IN PEPORT* ConnectedPort, OurPort); KeReleaseSemaphore(&NamedPort->Semaphore, IO_NO_INCREMENT, 1, FALSE); ExFreePool(RequestMessage); - + /* * Wait for them to accept our connection */ @@ -136,7 +136,7 @@ EiConnectPort(IN PEPORT* ConnectedPort, FALSE, NULL); - /* + /* * Dequeue the response */ KeAcquireSpinLock (&OurPort->Lock, &oldIrql); @@ -221,9 +221,9 @@ EiConnectPort(IN PEPORT* ConnectedPort, /********************************************************************** * NAME EXPORTED * NtConnectPort/8 - * + * * DESCRIPTION - * Connect to a named port and wait for the other side to + * Connect to a named port and wait for the other side to * accept or reject the connection request. * * ARGUMENTS @@ -235,9 +235,9 @@ EiConnectPort(IN PEPORT* ConnectedPort, * MaxMessageSize * ConnectInfo * UserConnectInfoLength - * + * * RETURN VALUE - * + * * @unimplemented */ NTSTATUS STDCALL @@ -261,7 +261,7 @@ NtConnectPort (PHANDLE UnsafeConnectedPortHandle, PEPORT ConnectedPort; NTSTATUS Status; PEPORT NamedPort; - + /* * Copy in write map and partially validate. */ @@ -415,7 +415,7 @@ NtConnectPort (PHANDLE UnsafeConnectedPortHandle, } ObDereferenceObject(NamedPort); NamedPort = NULL; - + /* * Copy the data back to the caller. */ @@ -543,7 +543,7 @@ NtAcceptConnectPort (PHANDLE ServerPortHandle, { return(STATUS_NO_MEMORY); } - + Status = ObReferenceObjectByHandle(NamedPortHandle, PORT_ALL_ACCESS, LpcPortObjectType, @@ -601,14 +601,14 @@ NtAcceptConnectPort (PHANDLE ServerPortHandle, ConnectionRequest = EiDequeueConnectMessagePort (NamedPort); KeReleaseSpinLock(&NamedPort->Lock, oldIrql); CRequest = (PEPORT_CONNECT_REQUEST_MESSAGE)(&ConnectionRequest->Message); - + /* * Prepare the reply. */ if (LpcMessage != NULL) { memcpy(&CReply->MessageHeader, LpcMessage, sizeof(LPC_MESSAGE)); - memcpy(&CReply->ConnectData, (PVOID)(LpcMessage + 1), + memcpy(&CReply->ConnectData, (PVOID)(LpcMessage + 1), LpcMessage->DataSize); CReply->MessageHeader.MessageSize = sizeof(EPORT_CONNECT_REPLY_MESSAGE) + LpcMessage->DataSize; @@ -624,7 +624,7 @@ NtAcceptConnectPort (PHANDLE ServerPortHandle, CReply->ConnectDataLength = 0; } if (!AcceptIt) - { + { EiReplyOrRequestPort(ConnectionRequest->Sender, &CReply->MessageHeader, LPC_CONNECTION_REFUSED, @@ -634,12 +634,12 @@ NtAcceptConnectPort (PHANDLE ServerPortHandle, 1, FALSE); ObDereferenceObject(ConnectionRequest->Sender); - ExFreePool(ConnectionRequest); + ExFreePool(ConnectionRequest); ExFreePool(CReply); ObDereferenceObject(NamedPort); return (STATUS_SUCCESS); } - + /* * Prepare the connection. */ @@ -675,7 +675,7 @@ NtAcceptConnectPort (PHANDLE ServerPortHandle, if (!NT_SUCCESS(Status)) { return(Status); - } + } WriteMap->ViewBase = 0; Status = MmMapViewOfSection(SectionObject, @@ -691,8 +691,8 @@ NtAcceptConnectPort (PHANDLE ServerPortHandle, if (!NT_SUCCESS(Status)) { return(Status); - } - + } + ObDereferenceObject(SectionObject); } if (ReadMap != NULL && CRequest->SendSectionObject != NULL) @@ -747,19 +747,19 @@ NtAcceptConnectPort (PHANDLE ServerPortHandle, OurPort); ExFreePool(ConnectionRequest); ExFreePool(CReply); - + ObDereferenceObject(OurPort); ObDereferenceObject(NamedPort); - + return (STATUS_SUCCESS); } /********************************************************************** * NAME EXPORTED * NtSecureConnectPort/9 - * + * * DESCRIPTION - * Connect to a named port and wait for the other side to + * Connect to a named port and wait for the other side to * accept the connection. Possibly verify that the server * matches the ServerSid (trusted server). * Present in w2k+. @@ -774,7 +774,7 @@ NtAcceptConnectPort (PHANDLE ServerPortHandle, * MaxMessageSize * ConnectInfo * UserConnectInfoLength - * + * * RETURN VALUE */ NTSTATUS STDCALL diff --git a/reactos/ntoskrnl/lpc/create.c b/reactos/ntoskrnl/lpc/create.c index 637c54d0166..9d2339025a5 100644 --- a/reactos/ntoskrnl/lpc/create.c +++ b/reactos/ntoskrnl/lpc/create.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/lpc/create.c * PURPOSE: Communication mechanism - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -26,7 +26,7 @@ * * RETURN VALUE */ -STATIC NTSTATUS STDCALL +STATIC NTSTATUS STDCALL LpcpVerifyCreateParameters (IN PHANDLE PortHandle, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG MaxConnectInfoLength, @@ -83,12 +83,12 @@ NiCreatePort (PVOID ObjectBody, { return (STATUS_SUCCESS); } - + if (wcschr(RemainingPath+1, '\\') != NULL) { return (STATUS_UNSUCCESSFUL); } - + return (STATUS_SUCCESS); } @@ -96,7 +96,7 @@ NiCreatePort (PVOID ObjectBody, /********************************************************************** * NAME EXPORTED * NtCreatePort/5 - * + * * DESCRIPTION * * ARGUMENTS @@ -105,10 +105,10 @@ NiCreatePort (PVOID ObjectBody, * MaxConnectInfoLength, * MaxDataLength, * MaxPoolUsage: size of NP zone the NP part of msgs is kept in - * + * * RETURN VALUE */ -/*EXPORTED*/ NTSTATUS STDCALL +/*EXPORTED*/ NTSTATUS STDCALL NtCreatePort (PHANDLE PortHandle, POBJECT_ATTRIBUTES ObjectAttributes, ULONG MaxConnectInfoLength, @@ -117,9 +117,9 @@ NtCreatePort (PHANDLE PortHandle, { PEPORT Port; NTSTATUS Status; - + DPRINT("NtCreatePort() Name %x\n", ObjectAttributes->ObjectName->Buffer); - + /* Verify parameters */ Status = LpcpVerifyCreateParameters (PortHandle, ObjectAttributes, @@ -162,16 +162,16 @@ NtCreatePort (PHANDLE PortHandle, Port->MaxConnectInfoLength = PORT_MAX_DATA_LENGTH; Port->MaxDataLength = PORT_MAX_MESSAGE_LENGTH; Port->MaxPoolUsage = MaxPoolUsage; - + ObDereferenceObject (Port); - + return (Status); } /********************************************************************** * NAME EXPORTED * NtCreateWaitablePort/5 - * + * * DESCRIPTION * Waitable ports can be connected to with NtSecureConnectPort. * No port interface can be used with waitable ports but @@ -184,7 +184,7 @@ NtCreatePort (PHANDLE PortHandle, * MaxConnectInfoLength, * MaxDataLength, * MaxPoolUsage - * + * * RETURN VALUE */ /*EXPORTED*/ NTSTATUS STDCALL @@ -195,7 +195,7 @@ NtCreateWaitablePort (OUT PHANDLE PortHandle, IN ULONG MaxPoolUsage) { NTSTATUS Status; - + /* Verify parameters */ Status = LpcpVerifyCreateParameters (PortHandle, ObjectAttributes, diff --git a/reactos/ntoskrnl/lpc/listen.c b/reactos/ntoskrnl/lpc/listen.c index 7b5d3cbc34d..d83d84379a3 100644 --- a/reactos/ntoskrnl/lpc/listen.c +++ b/reactos/ntoskrnl/lpc/listen.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/lpc/listen.c * PURPOSE: Communication mechanism - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -43,7 +43,7 @@ NtListenPort (IN HANDLE PortHandle, IN PLPC_MESSAGE ConnectMsg) { NTSTATUS Status; - + /* * Wait forever for a connection request. */ @@ -57,7 +57,7 @@ NtListenPort (IN HANDLE PortHandle, * Accept only LPC_CONNECTION_REQUEST requests. * Drop any other message. */ - if (!NT_SUCCESS(Status) || + if (!NT_SUCCESS(Status) || LPC_CONNECTION_REQUEST == ConnectMsg->MessageType) { DPRINT("Got message (type %x)\n", LPC_CONNECTION_REQUEST); @@ -65,7 +65,7 @@ NtListenPort (IN HANDLE PortHandle, } DPRINT("Got message (type %x)\n", ConnectMsg->MessageType); } - + return (Status); } diff --git a/reactos/ntoskrnl/lpc/port.c b/reactos/ntoskrnl/lpc/port.c index f7710930f40..60d4ed816f8 100644 --- a/reactos/ntoskrnl/lpc/port.c +++ b/reactos/ntoskrnl/lpc/port.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/lpc/port.c * PURPOSE: Communication mechanism - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -36,9 +36,9 @@ LpcpInitSystem (VOID) /* Allocate Memory for the LPC Object */ LpcPortObjectType = ExAllocatePool(NonPagedPool, sizeof(OBJECT_TYPE)); RtlZeroMemory (LpcPortObjectType, sizeof (OBJECT_TYPE)); - + RtlInitUnicodeString(&LpcPortObjectType->TypeName,L"Port"); - + LpcPortObjectType->Tag = TAG('L', 'P', 'R', 'T'); LpcPortObjectType->PeakObjects = 0; LpcPortObjectType->PeakHandles = 0; @@ -59,11 +59,11 @@ LpcpInitSystem (VOID) LpcPortObjectType->DuplicationNotify = NULL; ObpCreateTypeObject(LpcPortObjectType); - + LpcpNextMessageId = 0; ExInitializeFastMutex (& LpcpLock); - + return(STATUS_SUCCESS); } @@ -71,7 +71,7 @@ LpcpInitSystem (VOID) /********************************************************************** * NAME INTERNAL * NiInitializePort/3 - * + * * DESCRIPTION * Initialize the EPORT object attributes. The Port * object enters the inactive state. @@ -108,7 +108,7 @@ LpcpInitializePort (IN OUT PEPORT Port, Port->State = EPORT_INACTIVE; InitializeListHead (& Port->QueueListHead); InitializeListHead (& Port->ConnectQueueListHead); - + return (STATUS_SUCCESS); } @@ -119,7 +119,7 @@ LpcpInitializePort (IN OUT PEPORT Port, /********************************************************************** * NAME SYSTEM * NtImpersonateClientOfPort/2 - * + * * DESCRIPTION * * ARGUMENTS diff --git a/reactos/ntoskrnl/lpc/query.c b/reactos/ntoskrnl/lpc/query.c index faad386e23b..b5a8d362438 100644 --- a/reactos/ntoskrnl/lpc/query.c +++ b/reactos/ntoskrnl/lpc/query.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/lpc/query.c * PURPOSE: Communication mechanism - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -19,7 +19,7 @@ /********************************************************************** * NAME EXPORTED * NtQueryInformationPort@20 - * + * * DESCRIPTION * * ARGUMENTS @@ -39,14 +39,14 @@ */ /*EXPORTED*/ NTSTATUS STDCALL NtQueryInformationPort (IN HANDLE PortHandle, - IN CINT PortInformationClass, - OUT PVOID PortInformation, + IN CINT PortInformationClass, + OUT PVOID PortInformation, IN ULONG PortInformationLength, OUT PULONG ReturnLength) { NTSTATUS Status; PEPORT Port; - + Status = ObReferenceObjectByHandle (PortHandle, PORT_ALL_ACCESS, /* AccessRequired */ LpcPortObjectType, diff --git a/reactos/ntoskrnl/lpc/queue.c b/reactos/ntoskrnl/lpc/queue.c index ebb60623bab..971e1085d51 100644 --- a/reactos/ntoskrnl/lpc/queue.c +++ b/reactos/ntoskrnl/lpc/queue.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/lpc/queue.c * PURPOSE: Communication mechanism - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -39,7 +39,7 @@ EiDequeueMessagePort (IN OUT PEPORT Port) { PQUEUEDMESSAGE Message; PLIST_ENTRY entry; - + if (IsListEmpty(&Port->QueueListHead)) { return(NULL); @@ -47,7 +47,7 @@ EiDequeueMessagePort (IN OUT PEPORT Port) entry = RemoveHeadList (&Port->QueueListHead); Message = CONTAINING_RECORD (entry, QUEUEDMESSAGE, QueueListEntry); Port->QueueLength--; - + return (Message); } @@ -67,7 +67,7 @@ EiDequeueConnectMessagePort (IN OUT PEPORT Port) { PQUEUEDMESSAGE Message; PLIST_ENTRY entry; - + if (IsListEmpty(&Port->ConnectQueueListHead)) { return(NULL); @@ -75,7 +75,7 @@ EiDequeueConnectMessagePort (IN OUT PEPORT Port) entry = RemoveHeadList (&Port->ConnectQueueListHead); Message = CONTAINING_RECORD (entry, QUEUEDMESSAGE, QueueListEntry); Port->ConnectQueueLength--; - + return (Message); } diff --git a/reactos/ntoskrnl/lpc/receive.c b/reactos/ntoskrnl/lpc/receive.c index 6b05130b2ff..f45d9c72bca 100644 --- a/reactos/ntoskrnl/lpc/receive.c +++ b/reactos/ntoskrnl/lpc/receive.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/lpc/receive.c * PURPOSE: Communication mechanism - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ diff --git a/reactos/ntoskrnl/lpc/reply.c b/reactos/ntoskrnl/lpc/reply.c index 73bb67f4090..45db8dad56e 100644 --- a/reactos/ntoskrnl/lpc/reply.c +++ b/reactos/ntoskrnl/lpc/reply.c @@ -1,5 +1,5 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/lpc/reply.c @@ -30,14 +30,14 @@ * REVISIONS */ NTSTATUS STDCALL -EiReplyOrRequestPort (IN PEPORT Port, - IN PLPC_MESSAGE LpcReply, +EiReplyOrRequestPort (IN PEPORT Port, + IN PLPC_MESSAGE LpcReply, IN ULONG MessageType, IN PEPORT Sender) { KIRQL oldIrql; PQUEUEDMESSAGE MessageReply; - + if (Port == NULL) { KEBUGCHECK(0); @@ -46,21 +46,21 @@ EiReplyOrRequestPort (IN PEPORT Port, MessageReply = ExAllocatePoolWithTag(NonPagedPool, sizeof(QUEUEDMESSAGE), TAG_LPC_MESSAGE); MessageReply->Sender = Sender; - + if (LpcReply != NULL) { memcpy(&MessageReply->Message, LpcReply, LpcReply->MessageSize); } - + MessageReply->Message.ClientId.UniqueProcess = PsGetCurrentProcessId(); MessageReply->Message.ClientId.UniqueThread = PsGetCurrentThreadId(); MessageReply->Message.MessageType = MessageType; MessageReply->Message.MessageId = InterlockedIncrementUL(&LpcpNextMessageId); - + KeAcquireSpinLock(&Port->Lock, &oldIrql); EiEnqueueMessagePort(Port, MessageReply); KeReleaseSpinLock(&Port->Lock, oldIrql); - + return(STATUS_SUCCESS); } @@ -82,9 +82,9 @@ NtReplyPort (IN HANDLE PortHandle, { NTSTATUS Status; PEPORT Port; - + DPRINT("NtReplyPort(PortHandle %x, LpcReply %x)\n", PortHandle, LpcReply); - + Status = ObReferenceObjectByHandle(PortHandle, PORT_ALL_ACCESS, /* AccessRequired */ LpcPortObjectType, @@ -102,15 +102,15 @@ NtReplyPort (IN HANDLE PortHandle, ObDereferenceObject(Port); return STATUS_PORT_DISCONNECTED; } - - Status = EiReplyOrRequestPort(Port->OtherPort, - LpcReply, + + Status = EiReplyOrRequestPort(Port->OtherPort, + LpcReply, LPC_REPLY, Port); KeReleaseSemaphore(&Port->OtherPort->Semaphore, IO_NO_INCREMENT, 1, FALSE); - + ObDereferenceObject(Port); - + return(Status); } @@ -118,11 +118,11 @@ NtReplyPort (IN HANDLE PortHandle, /********************************************************************** * NAME EXPORTED * NtReplyWaitReceivePortEx - * + * * DESCRIPTION * Can be used with waitable ports. * Present only in w2k+. - * + * * ARGUMENTS * PortHandle * PortId @@ -137,7 +137,7 @@ NtReplyPort (IN HANDLE PortHandle, NTSTATUS STDCALL NtReplyWaitReceivePortEx(IN HANDLE PortHandle, OUT PULONG PortId, - IN PLPC_MESSAGE LpcReply, + IN PLPC_MESSAGE LpcReply, OUT PLPC_MESSAGE LpcMessage, IN PLARGE_INTEGER Timeout) { @@ -147,10 +147,10 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle, PQUEUEDMESSAGE Request; BOOLEAN Disconnected; LARGE_INTEGER to; - + DPRINT("NtReplyWaitReceivePortEx(PortHandle %x, LpcReply %x, " "LpcMessage %x)\n", PortHandle, LpcReply, LpcMessage); - + Status = ObReferenceObjectByHandle(PortHandle, PORT_ALL_ACCESS, LpcPortObjectType, @@ -173,19 +173,19 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle, Timeout = &to; } else Disconnected = FALSE; - + /* * Send the reply, only if port is connected */ if (LpcReply != NULL && !Disconnected) { - Status = EiReplyOrRequestPort(Port->OtherPort, + Status = EiReplyOrRequestPort(Port->OtherPort, LpcReply, LPC_REPLY, Port); - KeReleaseSemaphore(&Port->OtherPort->Semaphore, IO_NO_INCREMENT, 1, + KeReleaseSemaphore(&Port->OtherPort->Semaphore, IO_NO_INCREMENT, 1, FALSE); - + if (!NT_SUCCESS(Status)) { ObDereferenceObject(Port); @@ -193,7 +193,7 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle, return(Status); } } - + /* * Want for a message to be received */ @@ -211,7 +211,7 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle, ObDereferenceObject(Port); return(Disconnected ? STATUS_PORT_DISCONNECTED : STATUS_TIMEOUT); } - + if (!NT_SUCCESS(Status)) { if (STATUS_THREAD_IS_TERMINATING != Status) @@ -254,7 +254,7 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle, 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. * FIXME: Also increment semaphore. */ @@ -274,7 +274,7 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle, { ExFreePool(Request); } - + /* * Dereference the port */ @@ -286,10 +286,10 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle, /********************************************************************** * NAME EXPORTED * NtReplyWaitReceivePort - * + * * DESCRIPTION * Can be used with waitable ports. - * + * * ARGUMENTS * PortHandle * PortId @@ -303,7 +303,7 @@ NtReplyWaitReceivePortEx(IN HANDLE PortHandle, NTSTATUS STDCALL NtReplyWaitReceivePort (IN HANDLE PortHandle, OUT PULONG PortId, - IN PLPC_MESSAGE LpcReply, + IN PLPC_MESSAGE LpcReply, OUT PLPC_MESSAGE LpcMessage) { return(NtReplyWaitReceivePortEx (PortHandle, diff --git a/reactos/ntoskrnl/lpc/send.c b/reactos/ntoskrnl/lpc/send.c index 1179f1280d9..6fa0a0721ad 100644 --- a/reactos/ntoskrnl/lpc/send.c +++ b/reactos/ntoskrnl/lpc/send.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/lpc/send.c * PURPOSE: Communication mechanism - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -28,13 +28,13 @@ * * REVISIONS */ -NTSTATUS STDCALL +NTSTATUS STDCALL LpcSendTerminationPort (IN PEPORT Port, IN LARGE_INTEGER CreationTime) { NTSTATUS Status; LPC_TERMINATION_MESSAGE Msg; - + #ifdef __USE_NT_LPC__ Msg.Header.MessageType = LPC_NEW_MESSAGE; #endif @@ -56,7 +56,7 @@ LpcSendTerminationPort (IN PEPORT Port, * * REVISIONS */ -NTSTATUS STDCALL +NTSTATUS STDCALL LpcSendDebugMessagePort (IN PEPORT Port, IN PLPC_DBG_MESSAGE Message, OUT PLPC_DBG_MESSAGE Reply) @@ -64,9 +64,9 @@ LpcSendDebugMessagePort (IN PEPORT Port, NTSTATUS Status; KIRQL oldIrql; PQUEUEDMESSAGE ReplyMessage; - - Status = EiReplyOrRequestPort(Port, - &Message->Header, + + Status = EiReplyOrRequestPort(Port, + &Message->Header, LPC_REQUEST, Port); if (!NT_SUCCESS(Status)) @@ -84,7 +84,7 @@ LpcSendDebugMessagePort (IN PEPORT Port, UserMode, FALSE, NULL); - + /* * Dequeue the reply */ @@ -101,7 +101,7 @@ LpcSendDebugMessagePort (IN PEPORT Port, /********************************************************************** * NAME * LpcRequestPort/2 - * + * * DESCRIPTION * * ARGUMENTS @@ -111,7 +111,7 @@ LpcSendDebugMessagePort (IN PEPORT Port, * REVISIONS * 2002-03-01 EA * I investigated this function a bit more in depth. - * It looks like the legal values for the MessageType field in the + * It looks like the legal values for the MessageType field in the * message to send are in the range LPC_NEW_MESSAGE .. LPC_CLIENT_DIED, * but LPC_DATAGRAM is explicitly forbidden. * @@ -121,7 +121,7 @@ NTSTATUS STDCALL LpcRequestPort (IN PEPORT Port, IN PLPC_MESSAGE LpcMessage) { NTSTATUS Status; - + DPRINT("LpcRequestPort(PortHandle %08x, LpcMessage %08x)\n", Port, LpcMessage); #ifdef __USE_NT_LPC__ @@ -145,8 +145,8 @@ NTSTATUS STDCALL LpcRequestPort (IN PEPORT Port, } #endif - Status = EiReplyOrRequestPort(Port, - LpcMessage, + Status = EiReplyOrRequestPort(Port, + LpcMessage, LPC_DATAGRAM, Port); KeReleaseSemaphore( &Port->Semaphore, IO_NO_INCREMENT, 1, FALSE ); @@ -174,10 +174,10 @@ NTSTATUS STDCALL NtRequestPort (IN HANDLE PortHandle, { NTSTATUS Status; PEPORT Port; - - DPRINT("NtRequestPort(PortHandle %x LpcMessage %x)\n", PortHandle, + + DPRINT("NtRequestPort(PortHandle %x LpcMessage %x)\n", PortHandle, LpcMessage); - + Status = ObReferenceObjectByHandle(PortHandle, PORT_ALL_ACCESS, LpcPortObjectType, @@ -190,9 +190,9 @@ NTSTATUS STDCALL NtRequestPort (IN HANDLE PortHandle, return(Status); } - Status = LpcRequestPort(Port->OtherPort, + Status = LpcRequestPort(Port->OtherPort, LpcMessage); - + ObDereferenceObject(Port); return(Status); } @@ -212,9 +212,9 @@ NTSTATUS STDCALL NtRequestPort (IN HANDLE PortHandle, * * @implemented */ -NTSTATUS STDCALL +NTSTATUS STDCALL NtRequestWaitReplyPort (IN HANDLE PortHandle, - PLPC_MESSAGE UnsafeLpcRequest, + PLPC_MESSAGE UnsafeLpcRequest, PLPC_MESSAGE UnsafeLpcReply) { PETHREAD CurrentThread; @@ -230,7 +230,7 @@ NtRequestWaitReplyPort (IN HANDLE PortHandle, "LpcReply %x)\n", PortHandle, UnsafeLpcRequest, UnsafeLpcReply); Status = ObReferenceObjectByHandle(PortHandle, - PORT_ALL_ACCESS, + PORT_ALL_ACCESS, LpcPortObjectType, UserMode, (PVOID*)&Port, @@ -326,8 +326,8 @@ NtRequestWaitReplyPort (IN HANDLE PortHandle, return(STATUS_PORT_MESSAGE_TOO_LONG); } - Status = EiReplyOrRequestPort(Port->OtherPort, - LpcRequest, + Status = EiReplyOrRequestPort(Port->OtherPort, + LpcRequest, LPC_REQUEST, Port); if (!NT_SUCCESS(Status)) @@ -342,9 +342,9 @@ NtRequestWaitReplyPort (IN HANDLE PortHandle, return(Status); } ExFreePool(LpcRequest); - KeReleaseSemaphore (&Port->OtherPort->Semaphore, IO_NO_INCREMENT, - 1, FALSE); - + KeReleaseSemaphore (&Port->OtherPort->Semaphore, IO_NO_INCREMENT, + 1, FALSE); + /* * Wait for a reply */ @@ -355,7 +355,7 @@ NtRequestWaitReplyPort (IN HANDLE PortHandle, NULL); if (Status == STATUS_SUCCESS) { - + /* * Dequeue the reply */ @@ -366,7 +366,7 @@ NtRequestWaitReplyPort (IN HANDLE PortHandle, { DPRINT("Message->Message.MessageSize %d\n", Message->Message.MessageSize); - Status = MmCopyToCaller(UnsafeLpcReply, &Message->Message, + Status = MmCopyToCaller(UnsafeLpcReply, &Message->Message, Message->Message.MessageSize); ExFreePool(Message); } @@ -385,7 +385,7 @@ NtRequestWaitReplyPort (IN HANDLE PortHandle, KeAttachProcess(AttachedProcess); } ObDereferenceObject(Port); - + return(Status); } @@ -393,7 +393,7 @@ NtRequestWaitReplyPort (IN HANDLE PortHandle, /********************************************************************** * NAME * NtWriteRequestData/6 - * + * * DESCRIPTION * * ARGUMENTS diff --git a/reactos/ntoskrnl/mkconfig.c b/reactos/ntoskrnl/mkconfig.c index 26994e1f83f..5c514890602 100644 --- a/reactos/ntoskrnl/mkconfig.c +++ b/reactos/ntoskrnl/mkconfig.c @@ -1,5 +1,5 @@ -/* $Id:$ - * +/* $Id$ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/mkconfig.c diff --git a/reactos/ntoskrnl/mm/anonmem.c b/reactos/ntoskrnl/mm/anonmem.c index 33efecd23cb..71dc55af95e 100644 --- a/reactos/ntoskrnl/mm/anonmem.c +++ b/reactos/ntoskrnl/mm/anonmem.c @@ -134,7 +134,7 @@ MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace, } /* - * Paging out non-dirty data is easy. + * Paging out non-dirty data is easy. */ if (!WasDirty) { @@ -489,20 +489,20 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle, * FUNCTION: Allocates a block of virtual memory in the process address space * ARGUMENTS: * ProcessHandle = The handle of the process which owns the virtual memory - * BaseAddress = A pointer to the virtual memory allocated. If you - * supply a non zero value the system will try to - * allocate the memory at the address supplied. It round + * BaseAddress = A pointer to the virtual memory allocated. If you + * supply a non zero value the system will try to + * allocate the memory at the address supplied. It round * it down to a multiple of the page size. - * ZeroBits = (OPTIONAL) You can specify the number of high order bits - * that must be zero, ensuring that the memory will be + * ZeroBits = (OPTIONAL) You can specify the number of high order bits + * that must be zero, ensuring that the memory will be * allocated at a address below a certain value. * RegionSize = The number of bytes to allocate - * AllocationType = Indicates the type of virtual memory you like to - * allocated, can be a combination of MEM_COMMIT, + * AllocationType = Indicates the type of virtual memory you like to + * allocated, can be a combination of MEM_COMMIT, * MEM_RESERVE, MEM_RESET, MEM_TOP_DOWN. * Protect = Indicates the protection type of the pages allocated, can be - * a combination of PAGE_READONLY, PAGE_READWRITE, - * PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE, PAGE_GUARD, + * a combination of PAGE_READONLY, PAGE_READWRITE, + * PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE, PAGE_GUARD, * PAGE_NOACCESS * RETURNS: Status */ @@ -626,7 +626,7 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle, MemoryAreaLength = (ULONG_PTR)MemoryArea->EndingAddress - (ULONG_PTR)MemoryArea->StartingAddress; - + MmInitialiseRegion(&MemoryArea->Data.VirtualMemoryData.RegionListHead, MemoryAreaLength, Type, Protect); @@ -757,14 +757,14 @@ NtFreeVirtualMemory(IN HANDLE ProcessHandle, /* * FUNCTION: Frees a range of virtual memory * ARGUMENTS: - * ProcessHandle = Points to the process that allocated the virtual + * ProcessHandle = Points to the process that allocated the virtual * memory - * BaseAddress = Points to the memory address, rounded down to a + * BaseAddress = Points to the memory address, rounded down to a * multiple of the pagesize - * RegionSize = Limits the range to free, rounded up to a multiple of + * RegionSize = Limits the range to free, rounded up to a multiple of * the paging size * FreeType = Can be one of the values: MEM_DECOMMIT, or MEM_RELEASE - * RETURNS: Status + * RETURNS: Status */ { MEMORY_AREA* MemoryArea; diff --git a/reactos/ntoskrnl/mm/aspace.c b/reactos/ntoskrnl/mm/aspace.c index 28f62383ad3..d66d5610e40 100644 --- a/reactos/ntoskrnl/mm/aspace.c +++ b/reactos/ntoskrnl/mm/aspace.c @@ -1,5 +1,5 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/aspace.c diff --git a/reactos/ntoskrnl/mm/balance.c b/reactos/ntoskrnl/mm/balance.c index c026a991e1c..3c7f9155ef4 100644 --- a/reactos/ntoskrnl/mm/balance.c +++ b/reactos/ntoskrnl/mm/balance.c @@ -1,10 +1,10 @@ /* $Id$ * * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel + * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/balance.c * PURPOSE: kernel memory managment functions - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -191,7 +191,7 @@ MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN CanWait, } /* - * Allocate always memory for the non paged pool and for the pager thread. + * Allocate always memory for the non paged pool and for the pager thread. */ if (Consumer == MC_NPPOOL || MiIsBalancerThread()) { diff --git a/reactos/ntoskrnl/mm/cont.c b/reactos/ntoskrnl/mm/cont.c index 4aeec1f9614..eb9c93e7c87 100644 --- a/reactos/ntoskrnl/mm/cont.c +++ b/reactos/ntoskrnl/mm/cont.c @@ -1,5 +1,5 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/cont.c @@ -106,14 +106,14 @@ MmAllocateContiguousAlignedMemory(IN ULONG NumberOfBytes, * DESCRIPTION * Allocates a range of physically contiguous cache aligned * memory from the non-paged pool. - * + * * ARGUMENTS * NumberOfBytes * Size of the memory block to allocate; - * + * * HighestAcceptableAddress * Highest address valid for the caller. - * + * * RETURN VALUE * The virtual address of the memory block on success; * NULL on error. @@ -152,7 +152,7 @@ MmAllocateContiguousMemory (IN ULONG NumberOfBytes, * DESCRIPTION * Releases a range of physically contiguous memory allocated * with MmAllocateContiguousMemory. - * + * * ARGUMENTS * BaseAddress * Virtual address of the memory to be freed. @@ -186,23 +186,23 @@ MmFreeContiguousMemory(IN PVOID BaseAddress) * DESCRIPTION * Allocates a range of physically contiguous memory * with a cache parameter. - * + * * ARGUMENTS * NumberOfBytes * Size of the memory block to allocate; - * + * * LowestAcceptableAddress * Lowest address valid for the caller. - * + * * HighestAcceptableAddress * Highest address valid for the caller. - * + * * BoundaryAddressMultiple * Address multiple not to be crossed by allocated buffer (optional). - * + * * CacheType * Type of caching to use. - * + * * RETURN VALUE * The virtual address of the memory block on success; * NULL on error. @@ -233,17 +233,17 @@ MmAllocateContiguousMemorySpecifyCache (IN ULONG NumberOfBytes, * DESCRIPTION * Releases a range of physically contiguous memory allocated * with MmAllocateContiguousMemorySpecifyCache. - * + * * ARGUMENTS * BaseAddress * Virtual address of the memory to be freed. * * NumberOfBytes * Size of the memory block to free. - * + * * CacheType * Type of caching used. - * + * * RETURN VALUE * None. * diff --git a/reactos/ntoskrnl/mm/drvlck.c b/reactos/ntoskrnl/mm/drvlck.c index 8da058c2b9a..74d202e7b47 100644 --- a/reactos/ntoskrnl/mm/drvlck.c +++ b/reactos/ntoskrnl/mm/drvlck.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/drvlck.c * PURPOSE: Managing driver managing - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -20,7 +20,7 @@ VOID MmUnlockPagableImageSection(IN PVOID ImageSectionHandle) /* * FUNCTION: Releases a section of driver code or driver data, previously - * locked into system space with MmLockPagableCodeSection, + * locked into system space with MmLockPagableCodeSection, * MmLockPagableDataSection or MmLockPagableSectionByHandle * ARGUMENTS: * ImageSectionHandle = Handle returned by MmLockPagableCodeSection or diff --git a/reactos/ntoskrnl/mm/elf32.c b/reactos/ntoskrnl/mm/elf32.c index 7b497ad37ca..b2008041590 100644 --- a/reactos/ntoskrnl/mm/elf32.c +++ b/reactos/ntoskrnl/mm/elf32.c @@ -1,5 +1,5 @@ -/* $Id:$ - * +/* $Id$ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/elf32.c diff --git a/reactos/ntoskrnl/mm/elf64.c b/reactos/ntoskrnl/mm/elf64.c index 99a92931bb1..c1980f80ab7 100644 --- a/reactos/ntoskrnl/mm/elf64.c +++ b/reactos/ntoskrnl/mm/elf64.c @@ -1,5 +1,5 @@ -/* $Id:$ - * +/* $Id$ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/elf64.c diff --git a/reactos/ntoskrnl/mm/freelist.c b/reactos/ntoskrnl/mm/freelist.c index 02bcd736b07..bbf3139996f 100644 --- a/reactos/ntoskrnl/mm/freelist.c +++ b/reactos/ntoskrnl/mm/freelist.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/freelist.c * PURPOSE: Handle the list of free physical pages - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) * Robert Bergkvist */ @@ -238,7 +238,7 @@ MmGetContinuousPages(ULONG NumberOfBytes, MmPageArray[i].Flags.Zero = 0; } } - + return start; } @@ -282,7 +282,7 @@ MiIsPfnRam(PADDRESS_RANGE BIOSMemoryMap, } return TRUE; } - + PVOID INIT_FUNCTION MmInitializePageList(ULONG_PTR FirstPhysKernelAddress, @@ -388,7 +388,7 @@ MmInitializePageList(ULONG_PTR FirstPhysKernelAddress, MmSetPageProtect(NULL, Address, PAGE_READWRITE); } memset(Address, 0, PAGE_SIZE); - + start = ((ULONG_PTR)Address - (ULONG_PTR)MmPageArray) / sizeof(PHYSICAL_PAGE); end = ((ULONG_PTR)Address - (ULONG_PTR)MmPageArray + PAGE_SIZE) / sizeof(PHYSICAL_PAGE); @@ -837,7 +837,7 @@ MmLockPage(PFN_TYPE Pfn) { KEBUGCHECK(0); } - + MmLockPageUnsafe(Pfn); } @@ -969,7 +969,7 @@ MmAllocPagesSpecifyRange(ULONG Consumer, HighestPage = HighestAddress.QuadPart / PAGE_SIZE; if ((HighestAddress.u.LowPart % PAGE_SIZE) != 0) HighestPage++; - + if (LowestPage >= MmPageArraySize) { DPRINT1("MmAllocPagesSpecifyRange(): Out of memory\n"); @@ -1162,7 +1162,7 @@ MmInitZeroPageThread(VOID) { NTSTATUS Status; HANDLE ThreadHandle; - + ZeroPageThreadShouldTerminate = FALSE; Status = PsCreateSystemThread(&ThreadHandle, THREAD_ALL_ACCESS, diff --git a/reactos/ntoskrnl/mm/i386/page.c b/reactos/ntoskrnl/mm/i386/page.c index 8d4da896bf5..12556c840e9 100644 --- a/reactos/ntoskrnl/mm/i386/page.c +++ b/reactos/ntoskrnl/mm/i386/page.c @@ -39,14 +39,14 @@ #define PAE_PAGEDIRECTORY_MAP (0xf0000000 + (PAGETABLE_MAP / (512))) -#define HYPERSPACE (0xf0800000) +#define HYPERSPACE (0xf0800000) #define IS_HYPERSPACE(v) (((ULONG)(v) >= 0xF0800000 && (ULONG)(v) < 0xF0C00000)) ULONG MmGlobalKernelPageDirectory[1024]; ULONGLONG MmGlobalKernelPageDirectoryForPAE[2048]; #define PTE_TO_PFN(X) ((X) >> PAGE_SHIFT) -#define PFN_TO_PTE(X) ((X) << PAGE_SHIFT) +#define PFN_TO_PTE(X) ((X) << PAGE_SHIFT) #define PAE_PTE_TO_PFN(X) (PAE_PAGE_MASK(X) >> PAGE_SHIFT) #define PAE_PFN_TO_PTE(X) ((X) << PAGE_SHIFT) @@ -144,7 +144,7 @@ ProtectToPTE(ULONG flProtect) DPRINT1("Unknown main protection type.\n"); KEBUGCHECK(0); } - if (Ke386NoExecute && + if (Ke386NoExecute && !(flProtect & PAGE_IS_EXECUTABLE)) { Attributes = Attributes | 0x80000000; @@ -176,7 +176,7 @@ ProtectToPTE(ULONG flProtect) #define ADDR_TO_PDE_OFFSET(v) ((((ULONG)(v)) / (1024 * PAGE_SIZE))) -#define ADDR_TO_PTE_OFFSET(v) ((((ULONG)(v)) % (1024 * PAGE_SIZE)) / PAGE_SIZE) +#define ADDR_TO_PTE_OFFSET(v) ((((ULONG)(v)) % (1024 * PAGE_SIZE)) / PAGE_SIZE) #define PAE_ADDR_TO_PAGE_TABLE(v) (((ULONG)(v)) / (512 * PAGE_SIZE)) @@ -232,9 +232,9 @@ NTSTATUS Mmi386ReleaseMmInfo(PEPROCESS Process) { if (PageDir[j] != 0LL) { - DPRINT1("ProcessId %d, Pde for %08x - %08x is not freed, RefCount %d\n", + DPRINT1("ProcessId %d, Pde for %08x - %08x is not freed, RefCount %d\n", Process->UniqueProcessId, - (i * 512 + j) * 512 * PAGE_SIZE, (i * 512 + j + 1) * 512 * PAGE_SIZE - 1, + (i * 512 + j) * 512 * PAGE_SIZE, (i * 512 + j + 1) * 512 * PAGE_SIZE - 1, Process->AddressSpace.PageTableRefCountTable[i*512 + j]); Pde = MmCreateHyperspaceMapping(PAE_PTE_TO_PFN(PageDir[j])); for (k = 0; k < 512; k++) @@ -278,8 +278,8 @@ NTSTATUS Mmi386ReleaseMmInfo(PEPROCESS Process) { if (PageDir[i] != 0) { - DPRINT1("Pde for %08x - %08x is not freed, RefCount %d\n", - i * 4 * 1024 * 1024, (i + 1) * 4 * 1024 * 1024 - 1, + DPRINT1("Pde for %08x - %08x is not freed, RefCount %d\n", + i * 4 * 1024 * 1024, (i + 1) * 4 * 1024 * 1024 - 1, Process->AddressSpace.PageTableRefCountTable[i]); Pde = MmCreateHyperspaceMapping(PTE_TO_PFN(PageDir[i])); for (j = 0; j < 1024; j++) @@ -319,17 +319,17 @@ NTSTATUS Mmi386ReleaseMmInfo(PEPROCESS Process) return(STATUS_SUCCESS); } -NTSTATUS +NTSTATUS STDCALL -MmCopyMmInfo(PEPROCESS Src, - PEPROCESS Dest, +MmCopyMmInfo(PEPROCESS Src, + PEPROCESS Dest, PPHYSICAL_ADDRESS DirectoryTableBase) { NTSTATUS Status; ULONG i, j; PFN_TYPE Pfn[7]; ULONG Count; - + DPRINT("MmCopyMmInfo(Src %x, Dest %x)\n", Src, Dest); Count = Ke386Pae ? 7 : 2; @@ -533,7 +533,7 @@ MmGetPageTableForProcessForPAE(PEPROCESS Process, PVOID Address, BOOLEAN Create) { KEBUGCHECK(0); } - Entry = PFN_TO_PTE(Pfn) | PA_PRESENT | PA_READWRITE | PA_USER; + Entry = PFN_TO_PTE(Pfn) | PA_PRESENT | PA_READWRITE | PA_USER; Entry = ExfInterlockedCompareExchange64UL(PageDir, &Entry, &ZeroEntry); if (Entry != 0LL) { @@ -600,10 +600,10 @@ MmGetPageTableForProcessForPAE(PEPROCESS Process, PVOID Address, BOOLEAN Create) } } } - return (PULONGLONG)PAE_ADDR_TO_PTE(Address); + return (PULONGLONG)PAE_ADDR_TO_PTE(Address); } -static PULONG +static PULONG MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) { ULONG PdeOffset = ADDR_TO_PDE_OFFSET(Address); @@ -611,7 +611,7 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) PFN_TYPE Pfn; ULONG Entry; PULONG Pt, PageDir; - + if (Address < (PVOID)KERNEL_BASE && Process && Process != PsGetCurrentProcess()) { PageDir = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase.QuadPart)); @@ -696,7 +696,7 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) } } } - return (PULONG)ADDR_TO_PTE(Address); + return (PULONG)ADDR_TO_PTE(Address); } BOOLEAN MmUnmapPageTable(PULONG Pt) @@ -751,7 +751,7 @@ static ULONG MmGetPageEntryForProcess(PEPROCESS Process, PVOID Address) } return 0; } - + PFN_TYPE MmGetPfnForProcess(PEPROCESS Process, PVOID Address) @@ -782,7 +782,7 @@ MmGetPfnForProcess(PEPROCESS Process, VOID MmDisableVirtualMapping(PEPROCESS Process, PVOID Address, BOOL* WasDirty, PPFN_TYPE Page) /* - * FUNCTION: Delete a virtual mapping + * FUNCTION: Delete a virtual mapping */ { BOOLEAN WasValid; @@ -804,7 +804,7 @@ MmDisableVirtualMapping(PEPROCESS Process, PVOID Address, BOOL* WasDirty, PPFN_T { Pte = *Pt; tmpPte = Pte & ~PA_PRESENT; - } while (Pte != ExfInterlockedCompareExchange64UL(Pt, &tmpPte, &Pte)); + } while (Pte != ExfInterlockedCompareExchange64UL(Pt, &tmpPte, &Pte)); MiFlushTlb((PULONG)Pt, Address); WasValid = PAE_PAGE_MASK(Pte) != 0LL ? TRUE : FALSE; @@ -841,7 +841,7 @@ MmDisableVirtualMapping(PEPROCESS Process, PVOID Address, BOOL* WasDirty, PPFN_T do { Pte = *Pt; - } while (Pte != InterlockedCompareExchangeUL(Pt, Pte & ~PA_PRESENT, Pte)); + } while (Pte != InterlockedCompareExchangeUL(Pt, Pte & ~PA_PRESENT, Pte)); MiFlushTlb(Pt, Address); WasValid = (PAGE_MASK(Pte) != 0); @@ -901,7 +901,7 @@ VOID MmDeleteVirtualMapping(PEPROCESS Process, PVOID Address, BOOL FreePage, BOOL* WasDirty, PPFN_TYPE Page) /* - * FUNCTION: Delete a virtual mapping + * FUNCTION: Delete a virtual mapping */ { BOOLEAN WasValid = FALSE; @@ -1028,7 +1028,7 @@ MmDeleteVirtualMapping(PEPROCESS Process, PVOID Address, BOOL FreePage, { PUSHORT Ptrc; ULONG Idx; - + Ptrc = Process->AddressSpace.PageTableRefCountTable; Idx = Ke386Pae ? PAE_ADDR_TO_PAGE_TABLE(Address) : ADDR_TO_PAGE_TABLE(Address); @@ -1044,7 +1044,7 @@ VOID MmDeletePageFileMapping(PEPROCESS Process, PVOID Address, SWAPENTRY* SwapEntry) /* - * FUNCTION: Delete a virtual mapping + * FUNCTION: Delete a virtual mapping */ { if (Ke386Pae) @@ -1097,7 +1097,7 @@ MmDeletePageFileMapping(PEPROCESS Process, PVOID Address, PULONG Pt; Pt = MmGetPageTableForProcess(Process, Address, FALSE); - + if (Pt == NULL) { *SwapEntry = 0; @@ -1209,7 +1209,7 @@ MmIsAccessedAndResetAccessPage(PEPROCESS Process, PVOID Address) { KEBUGCHECK(0); } - + do { Pte = *Pt; @@ -1237,7 +1237,7 @@ MmIsAccessedAndResetAccessPage(PEPROCESS Process, PVOID Address) { KEBUGCHECK(0); } - + do { Pte = *Pt; @@ -1341,7 +1341,7 @@ VOID MmSetDirtyPage(PEPROCESS Process, PVOID Address) do { Pte = *Pt; - tmpPte = Pte | PA_DIRTY; + tmpPte = Pte | PA_DIRTY; } while (Pte != ExfInterlockedCompareExchange64UL(Pt, &tmpPte, &Pte)); if (!(Pte & PA_DIRTY)) { @@ -1625,7 +1625,7 @@ MmCreatePageFileMapping(PEPROCESS Process, MmMarkPageUnmapped(PAE_PTE_TO_PFN((Pte))); } - if (Pte != 0) + if (Pte != 0) { MiFlushTlb((PULONG)Pt, Address); } @@ -1650,7 +1650,7 @@ MmCreatePageFileMapping(PEPROCESS Process, MmMarkPageUnmapped(PTE_TO_PFN((Pte))); } InterlockedExchangeUL(Pt, SwapEntry << 1); - if (Pte != 0) + if (Pte != 0) { MiFlushTlb(Pt, Address); } @@ -1689,7 +1689,7 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process, DPRINT("MmCreateVirtualMappingUnsafe(%x, %x, %x, %x (%x), %d)\n", Process, Address, flProtect, Pages, *Pages, PageCount); - + if (Process == NULL) { if (Address < (PVOID)KERNEL_BASE) @@ -1697,7 +1697,7 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process, DPRINT1("No process\n"); KEBUGCHECK(0); } - if (PageCount > 0x10000 || + if (PageCount > 0x10000 || (ULONG_PTR) Address / PAGE_SIZE + PageCount > 0x100000) { DPRINT1("Page count to large\n"); @@ -1921,7 +1921,7 @@ MmGetPageProtect(PEPROCESS Process, PVOID Address) { Protect = PAGE_NOACCESS; } - else + else { if (Entry & PA_READWRITE) { @@ -1943,7 +1943,7 @@ MmGetPageProtect(PEPROCESS Process, PVOID Address) { Protect |= PAGE_SYSTEM; } - + } return(Protect); } @@ -2099,7 +2099,7 @@ MmCreateHyperspaceMapping(PFN_TYPE Page) } } } - else + else { for (i = Page %1024; i >= 0; i--, Pte--) { @@ -2187,7 +2187,7 @@ MmCreateHyperspaceMapping(PFN_TYPE Page) return Address; } -PFN_TYPE +PFN_TYPE MmChangeHyperspaceMapping(PVOID Address, PFN_TYPE NewPage) { PFN_TYPE Pfn; @@ -2231,7 +2231,7 @@ MmDeleteHyperspaceMapping(PVOID Address) VOID MmUpdatePageDir(PEPROCESS Process, PVOID Address, ULONG Size) { - ULONG StartOffset, EndOffset, Offset; + ULONG StartOffset, EndOffset, Offset; if (Address < (PVOID)KERNEL_BASE) { @@ -2274,7 +2274,7 @@ VOID MmUpdatePageDir(PEPROCESS Process, PVOID Address, ULONG Size) Pde = (PULONGLONG)PAE_PAGEDIRECTORY_MAP + i*512; } - for (Offset = StartOffset; Offset <= EndOffset; Offset++) + for (Offset = StartOffset; Offset <= EndOffset; Offset++) { if (i * 512 + Offset < PAE_ADDR_TO_PDE_OFFSET(PAGETABLE_MAP) || i * 512 + Offset >= PAE_ADDR_TO_PDE_OFFSET(PAGETABLE_MAP)+4) { @@ -2289,7 +2289,7 @@ VOID MmUpdatePageDir(PEPROCESS Process, PVOID Address, ULONG Size) PULONG Pde; StartOffset = ADDR_TO_PDE_OFFSET(Address); EndOffset = ADDR_TO_PDE_OFFSET(Address + Size); - + if (Process != NULL && Process != PsGetCurrentProcess()) { Pde = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase.u.LowPart)); @@ -2298,7 +2298,7 @@ VOID MmUpdatePageDir(PEPROCESS Process, PVOID Address, ULONG Size) { Pde = (PULONG)PAGEDIRECTORY_MAP; } - for (Offset = StartOffset; Offset <= EndOffset; Offset++) + for (Offset = StartOffset; Offset <= EndOffset; Offset++) { if (Offset != ADDR_TO_PDE_OFFSET(PAGETABLE_MAP)) { diff --git a/reactos/ntoskrnl/mm/i386/pfault.c b/reactos/ntoskrnl/mm/i386/pfault.c index c948c9e5cce..0e7be09b0c5 100644 --- a/reactos/ntoskrnl/mm/i386/pfault.c +++ b/reactos/ntoskrnl/mm/i386/pfault.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/i386/pfault.c * PURPOSE: Paging file functions - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -71,7 +71,7 @@ NTSTATUS MmPageFault(ULONG Cs, Cs != KERNEL_CS) { KIRQL oldIrql; - + KeRaiseIrql(APC_LEVEL, &oldIrql); KiDeliverApc(KernelMode, NULL, NULL); KeLowerIrql(oldIrql); diff --git a/reactos/ntoskrnl/mm/iospace.c b/reactos/ntoskrnl/mm/iospace.c index 0e7031e5db6..8e12f1c2fec 100644 --- a/reactos/ntoskrnl/mm/iospace.c +++ b/reactos/ntoskrnl/mm/iospace.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/iospace.c * PURPOSE: Mapping I/O space - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -19,17 +19,17 @@ /********************************************************************** * NAME EXPORTED * MmMapIoSpace@16 - * + * * DESCRIPTION * Maps a physical memory range into system space. - * + * * ARGUMENTS * PhysicalAddress * First physical address to map; - * + * * NumberOfBytes * Number of bytes to map; - * + * * CacheEnable * Type of memory caching. * @@ -116,14 +116,14 @@ MmMapIoSpace (IN PHYSICAL_ADDRESS PhysicalAddress, /********************************************************************** * NAME EXPORTED * MmUnmapIoSpace@8 - * + * * DESCRIPTION * Unmaps a physical memory range from system space. - * + * * ARGUMENTS * BaseAddress - * The base virtual address which maps the region; - * + * The base virtual address which maps the region; + * * NumberOfBytes * Number of bytes to unmap. * diff --git a/reactos/ntoskrnl/mm/marea.c b/reactos/ntoskrnl/mm/marea.c index 282dfd7c548..cf3f55f1ec3 100644 --- a/reactos/ntoskrnl/mm/marea.c +++ b/reactos/ntoskrnl/mm/marea.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/marea.c * PURPOSE: Implements memory areas - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ diff --git a/reactos/ntoskrnl/mm/mdl.c b/reactos/ntoskrnl/mm/mdl.c index e51234f721f..488988eb0c7 100644 --- a/reactos/ntoskrnl/mm/mdl.c +++ b/reactos/ntoskrnl/mm/mdl.c @@ -125,10 +125,10 @@ MmUnlockPages(PMDL Mdl) PPFN_NUMBER MdlPages; PFN_NUMBER Page; - /* + /* * MmProbeAndLockPages MUST have been called to lock this mdl! * - * Windows will bugcheck if you pass MmUnlockPages an mdl that hasn't been + * Windows will bugcheck if you pass MmUnlockPages an mdl that hasn't been * locked with MmLockAndProbePages, but (for now) we'll be more forgiving... */ if (!(Mdl->MdlFlags & MDL_PAGES_LOCKED)) @@ -136,14 +136,14 @@ MmUnlockPages(PMDL Mdl) DPRINT1("MmUnlockPages called for non-locked mdl!\n"); return; } - + /* If mdl buffer is mapped io space -> do nothing */ if (Mdl->MdlFlags & MDL_IO_SPACE) { Mdl->MdlFlags &= ~MDL_PAGES_LOCKED; return; } - + /* Automagically undo any calls to MmGetSystemAddressForMdl's for this mdl */ if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA) { @@ -151,7 +151,7 @@ MmUnlockPages(PMDL Mdl) } /* - * FIXME: I don't know whether this right, but it looks sensible + * FIXME: I don't know whether this right, but it looks sensible */ if ((Mdl->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL) || (Mdl->MdlFlags & MDL_IO_PAGE_READ)) @@ -167,7 +167,7 @@ MmUnlockPages(PMDL Mdl) MmUnlockPage(Page); MmDereferencePage(Page); } - + Mdl->MdlFlags &= ~MDL_PAGES_LOCKED; } @@ -199,7 +199,7 @@ MmUnmapLockedPages(PVOID BaseAddress, PMDL Mdl) * ARGUMENTS: * BaseAddress = Base virtual address to which the pages were mapped * MemoryDescriptorList = MDL describing the mapped pages - * + * * User space unmappings _must_ be done from the original process context! */ { @@ -225,11 +225,11 @@ MmUnmapLockedPages(PVOID BaseAddress, PMDL Mdl) PageCount = PAGE_ROUND_UP(Mdl->ByteCount + Mdl->ByteOffset) / PAGE_SIZE; /* - * Docs says that BaseAddress should be a _base_ address, but every example + * Docs says that BaseAddress should be a _base_ address, but every example * I've seen pass the actual address. -Gunnar */ BaseAddress = PAGE_ALIGN(BaseAddress); - + /* Unmap all the pages. */ for (i = 0; i < PageCount; i++) { @@ -243,7 +243,7 @@ MmUnmapLockedPages(PVOID BaseAddress, PMDL Mdl) if ((ULONG_PTR)BaseAddress >= KERNEL_BASE) { ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA); - + KeAcquireSpinLock(&MiMdlMappingRegionLock, &oldIrql); /* Deallocate all the pages used. */ Base = (ULONG)((char*)BaseAddress - (char*)MiMdlMappingRegionBase) / PAGE_SIZE; @@ -253,16 +253,16 @@ MmUnmapLockedPages(PVOID BaseAddress, PMDL Mdl) MiMdlMappingRegionHint = min (MiMdlMappingRegionHint, Base); KeReleaseSpinLock(&MiMdlMappingRegionLock, oldIrql); - + /* Reset the MDL state. */ Mdl->MdlFlags &= ~MDL_MAPPED_TO_SYSTEM_VA; Mdl->MappedSystemVa = NULL; - + } else { MEMORY_AREA *Marea; - + ASSERT(Mdl->Process == PsGetCurrentProcess()); Marea = MmLocateMemoryAreaByAddress( &Mdl->Process->AddressSpace, BaseAddress ); @@ -349,7 +349,7 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl, * Operation = Operation to probe for * * This function can be seen as a safe version of MmBuildMdlForNonPagedPool - * used in cases where you know that the mdl address is paged memory or + * used in cases where you know that the mdl address is paged memory or * you don't know where the mdl address comes from. MmProbeAndLockPages will * work no matter what kind of mdl address you have. */ @@ -370,7 +370,7 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl, MdlPages = (PPFN_TYPE)(Mdl + 1); NrPages = PAGE_ROUND_UP(Mdl->ByteOffset + Mdl->ByteCount) / PAGE_SIZE; - + /* mdl must have enough page entries */ ASSERT(NrPages <= (Mdl->Size - sizeof(MDL))/sizeof(PFN_TYPE)); @@ -379,12 +379,12 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl, MmGetPfnForProcess(NULL, Mdl->StartVa) >= MmPageArraySize) { /* phys addr is not phys memory so this must be io memory */ - + for (i = 0; i < NrPages; i++) { MdlPages[i] = MmGetPfnForProcess(NULL, (char*)Mdl->StartVa + (i*PAGE_SIZE)); } - + Mdl->MdlFlags |= MDL_PAGES_LOCKED|MDL_IO_SPACE; return; } @@ -401,7 +401,7 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl, { /* FIXME: why isn't AccessMode used? */ Mode = UserMode; - Mdl->Process = CurrentProcess; + Mdl->Process = CurrentProcess; AddressSpace = &CurrentProcess->AddressSpace; } @@ -421,7 +421,7 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl, * FIXME: skip the probing/access stuff if buffer is nonpaged kernel space? * -Gunnar */ - + if (!MmIsPagePresent(NULL, Address)) { Status = MmNotPresentFault(Mode, (ULONG_PTR)Address, TRUE); @@ -444,7 +444,7 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl, { MmLockPage(MmGetPfnForProcess(NULL, Address)); } - + if ((Operation == IoWriteAccess || Operation == IoModifyAccess) && (!(MmGetPageProtect(NULL, (PVOID)Address) & PAGE_READWRITE))) { @@ -471,7 +471,7 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl, else MmReferencePage(Page); } - + MmUnlockAddressSpace(AddressSpace); Mdl->MdlFlags |= MDL_PAGES_LOCKED; } @@ -496,7 +496,7 @@ MmProbeAndLockProcessPages ( /* * @unimplemented */ -VOID +VOID STDCALL MmProbeAndLockSelectedPages( IN OUT PMDL MemoryDescriptorList, @@ -536,37 +536,37 @@ ULONG STDCALL MmSizeOfMdl (PVOID Base, VOID STDCALL MmBuildMdlForNonPagedPool (PMDL Mdl) /* - * FUNCTION: Fills in the corresponding physical page array of a given + * FUNCTION: Fills in the corresponding physical page array of a given * MDL for a buffer in nonpaged system space * ARGUMENTS: - * Mdl = Points to an MDL that supplies a virtual address, + * Mdl = Points to an MDL that supplies a virtual address, * byte offset and length * * This function can be seen as a fast version of MmProbeAndLockPages in case - * you _know_ that the mdl address is within nonpaged kernel space. + * you _know_ that the mdl address is within nonpaged kernel space. */ { ULONG i; ULONG PageCount; PPFN_TYPE MdlPages; - - /* - * mdl buffer must (at least) be in kernel space, thou this doesn't + + /* + * mdl buffer must (at least) be in kernel space, thou this doesn't * necesarely mean that the buffer in within _nonpaged_ kernel space... */ ASSERT((ULONG_PTR)Mdl->StartVa >= KERNEL_BASE); - + PageCount = PAGE_ROUND_UP(Mdl->ByteOffset + Mdl->ByteCount) / PAGE_SIZE; MdlPages = (PPFN_TYPE)(Mdl + 1); - + /* mdl must have enough page entries */ ASSERT(PageCount <= (Mdl->Size - sizeof(MDL))/sizeof(PFN_TYPE)); - + for (i=0; i < PageCount; i++) { *MdlPages++ = MmGetPfnForProcess(NULL, (char*)Mdl->StartVa + (i * PAGE_SIZE)); } - + Mdl->MdlFlags |= MDL_SOURCE_IS_NONPAGED_POOL; Mdl->Process = NULL; Mdl->MappedSystemVa = (char*)Mdl->StartVa + Mdl->ByteOffset; @@ -634,11 +634,11 @@ MmAllocatePagesForMdl ( IN PHYSICAL_ADDRESS LowAddress, { /* MmAllocatePagesForMdl allocates zero-filled, nonpaged, physical memory pages to an MDL - - MmAllocatePagesForMdlSearch the PFN database for free, zeroed or standby + + MmAllocatePagesForMdlSearch the PFN database for free, zeroed or standby pagesAllocates pages and puts in MDLDoes not map pages (caller responsibility) Designed to be used by an AGP driver - + LowAddress is the lowest acceptable physical address it wants to allocate and HighAddress is the highest. SkipBytes are the number of bytes that the kernel should keep free above LowAddress and below the address at which it @@ -649,20 +649,20 @@ MmAllocatePagesForMdl ( IN PHYSICAL_ADDRESS LowAddress, from the returned MDL that describe appropriate portions of the physical memory. When a driver wants to access physical memory described by a sub-MDL it must map the sub-MDL using MmGetSystemAddressForMdlSafe. - + Konstantin Gusev */ - + PMDL Mdl; PPFN_TYPE Pages; ULONG NumberOfPagesWanted, NumberOfPagesAllocated; ULONG Ret; - + DPRINT("MmAllocatePagesForMdl - LowAddress = 0x%I64x, HighAddress = 0x%I64x, " "SkipBytes = 0x%I64x, Totalbytes = 0x%x\n", LowAddress.QuadPart, HighAddress.QuadPart, SkipBytes.QuadPart, Totalbytes); - + /* SkipBytes must be a multiple of the page size */ if ((SkipBytes.QuadPart % PAGE_SIZE) != 0) { @@ -725,20 +725,20 @@ MmFreePagesFromMdl ( IN PMDL Mdl ) Drivers use the MmFreePagesFromMdl, the kernel-mode equivalent of FreeUserPhysicalPages, to free the physical memory it has allocated with MmAllocatePagesForMdl. This function is also prototyped in ntddk.h: - + Note that a driver is responsible for deallocating the MDL returned by MmAllocatePagesForMdl with a call to ExFreePool, since MmFreePagesFromMdl does not free the MDL. - + Konstantin Gusev - + */ PPFN_TYPE Pages; LONG NumberOfPages; - + NumberOfPages = PAGE_ROUND_UP(Mdl->ByteCount + Mdl->ByteOffset) / PAGE_SIZE; Pages = (PPFN_TYPE)(Mdl + 1); - + while (--NumberOfPages >= 0) { MmDereferencePage(Pages[NumberOfPages]); @@ -852,7 +852,7 @@ MmMapLockedPagesSpecifyCache ( IN PMDL Mdl, } KeReleaseSpinLock(&MiMdlMappingRegionLock, oldIrql); - + Mdl->Process = NULL; } diff --git a/reactos/ntoskrnl/mm/mm.c b/reactos/ntoskrnl/mm/mm.c index 91f7c533795..eafada883d2 100644 --- a/reactos/ntoskrnl/mm/mm.c +++ b/reactos/ntoskrnl/mm/mm.c @@ -1,7 +1,7 @@ /* $Id$ * * COPYRIGHT: See COPYING in the top directory - * PROJECT: ReactOS kernel + * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/mm.c * PURPOSE: Kernel memory managment functions * PROGRAMMERS: David Welch (welch@cwcom.net) @@ -484,19 +484,19 @@ MmGetSystemRoutineAddress ( PVOID ProcAddress; ANSI_STRING AnsiRoutineName; NTSTATUS Status; - + if(!NT_SUCCESS(RtlUnicodeStringToAnsiString(&AnsiRoutineName, SystemRoutineName, TRUE))) { return NULL; } - + Status = LdrGetProcedureAddress(NtoskrnlModuleObject.Base, &AnsiRoutineName, 0, &ProcAddress); - + if(!NT_SUCCESS(Status)) { Status = LdrGetProcedureAddress(HalModuleObject.Base, @@ -504,9 +504,9 @@ MmGetSystemRoutineAddress ( 0, &ProcAddress); } - + RtlFreeAnsiString(&AnsiRoutineName); - + return (NT_SUCCESS(Status) ? ProcAddress : NULL); } diff --git a/reactos/ntoskrnl/mm/mminit.c b/reactos/ntoskrnl/mm/mminit.c index f3ebeae7c66..a925fb6c73a 100644 --- a/reactos/ntoskrnl/mm/mminit.c +++ b/reactos/ntoskrnl/mm/mminit.c @@ -1,7 +1,7 @@ /* $Id$ * * COPYRIGHT: See COPYING in the top directory - * PROJECT: ReactOS kernel + * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/mminit.c * PURPOSE: Kernel memory managment initialization functions * @@ -368,9 +368,9 @@ MmInit1(ULONG_PTR FirstKrnlPhysAddr, * Initialize the kernel address space */ MmInitializeKernelAddressSpace(); - + MmInitGlobalKernelPageDirectory(); - + DbgPrint("Used memory %dKb\n", (MmStats.NrTotalPages * PAGE_SIZE) / 1024); DPRINT1("Kernel Stack Limits. InitTop = 0x%x, Init = 0x%x\n", init_stack_top, init_stack); @@ -389,13 +389,13 @@ MmInit1(ULONG_PTR FirstKrnlPhysAddr, #ifdef CONFIG_SMP /* In SMP mode we unmap the low memory pagetable in MmInit3. The APIC needs the mapping of the first pages - while the processors are starting up. + while the processors are starting up. We unmap all pages except page 2 and 3. */ for (MappingAddress = 0; MappingAddress < 1024 * PAGE_SIZE; MappingAddress += PAGE_SIZE) { - if (MappingAddress != 2 * PAGE_SIZE && + if (MappingAddress != 2 * PAGE_SIZE && MappingAddress != 3 * PAGE_SIZE) { MmRawDeleteVirtualMapping((PVOID)MappingAddress); diff --git a/reactos/ntoskrnl/mm/mpw.c b/reactos/ntoskrnl/mm/mpw.c index 43f4d2dcaf9..f6989391b9d 100644 --- a/reactos/ntoskrnl/mm/mpw.c +++ b/reactos/ntoskrnl/mm/mpw.c @@ -5,7 +5,7 @@ * FILE: ntoskrnl/mm/mpw.c * PURPOSE: Writes data that has been modified in memory but not on * the disk - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ diff --git a/reactos/ntoskrnl/mm/ncache.c b/reactos/ntoskrnl/mm/ncache.c index 8eef949bab0..8ed053202a8 100644 --- a/reactos/ntoskrnl/mm/ncache.c +++ b/reactos/ntoskrnl/mm/ncache.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/ncache.c * PURPOSE: Manages non-cached memory - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -24,11 +24,11 @@ * DESCRIPTION * Allocates a virtual address range of noncached and cache * aligned memory. - * + * * ARGUMENTS * NumberOfBytes * Size of region to allocate. - * + * * RETURN VALUE * The base address of the range on success; * NULL on failure. @@ -103,16 +103,16 @@ MmFreeNonCachedPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address, * MmFreeNonCachedMemory@8 * * DESCRIPTION - * Releases a range of noncached memory allocated with + * Releases a range of noncached memory allocated with * MmAllocateNonCachedMemory. - * + * * ARGUMENTS * BaseAddress * Virtual address to be freed; - * + * * NumberOfBytes * Size of the region to be freed. - * + * * RETURN VALUE * None. * diff --git a/reactos/ntoskrnl/mm/npool.c b/reactos/ntoskrnl/mm/npool.c index cf60a883e9a..c019519728c 100644 --- a/reactos/ntoskrnl/mm/npool.c +++ b/reactos/ntoskrnl/mm/npool.c @@ -1233,7 +1233,7 @@ grow_block(BLOCK_HDR* blk, PVOID end) PFN_TYPE Page[32]; ULONG_PTR StartIndex, EndIndex; ULONG i, j, k; - + StartIndex = (ULONG_PTR)(PAGE_ROUND_UP((ULONG_PTR)blk + BLOCK_HDR_SIZE - (ULONG_PTR)MiNonPagedPoolStart)) / PAGE_SIZE; EndIndex = ((ULONG_PTR)PAGE_ROUND_UP(end) - (ULONG_PTR)MiNonPagedPoolStart) / PAGE_SIZE; @@ -1465,16 +1465,16 @@ ExRosQueryNonPagedPoolTag ( PVOID Addr ) UNIMPLEMENTED; return 0; - + #else /* not WHOLE_PAGE_ALLOCATIONS */ BLOCK_HDR* blk=address_to_block(Addr); - + if (blk->Magic != BLOCK_HDR_USED_MAGIC) KEBUGCHECK(0); if (blk->Magic == BLOCK_HDR_FREE_MAGIC) KEBUGCHECK(0); - + return blk->Used.Tag; #endif /* WHOLE_PAGE_ALLOCATIONS */ @@ -1798,7 +1798,7 @@ MiInitializeNonPagedPool(VOID) } Address += PAGE_SIZE; } - RtlInitializeBitMap(&NonPagedPoolAllocMap, MiNonPagedPoolStart, + RtlInitializeBitMap(&NonPagedPoolAllocMap, MiNonPagedPoolStart, MiNonPagedPoolLength / PAGE_SIZE); RtlClearAllBits(&NonPagedPoolAllocMap); RtlSetBits(&NonPagedPoolAllocMap, 0, NonPagedPoolAllocMapHint); diff --git a/reactos/ntoskrnl/mm/pagefile.c b/reactos/ntoskrnl/mm/pagefile.c index ff38500d129..1a5f69c3e10 100644 --- a/reactos/ntoskrnl/mm/pagefile.c +++ b/reactos/ntoskrnl/mm/pagefile.c @@ -78,7 +78,7 @@ ULONG MiFreeSwapPages; ULONG MiUsedSwapPages; /* - * Number of pages that have been reserved for swapping but not yet allocated + * Number of pages that have been reserved for swapping but not yet allocated */ static ULONG MiReservedSwapPages; @@ -122,14 +122,14 @@ STDCALL MmIsFileAPagingFile(PFILE_OBJECT FileObject) { ULONG i; - + /* Loop through all the paging files */ for (i = 0; i < MiPagingFileCount; i++) { /* Check if this is one of them */ if (PagingFileList[i]->FileObject == FileObject) return TRUE; } - + /* Nothing found */ return FALSE; } @@ -251,7 +251,7 @@ NTSTATUS MmWriteToSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page) KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); Status = Iosb.Status; } - MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl); + MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl); return(Status); } @@ -305,7 +305,7 @@ NTSTATUS MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page) KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); Status = Iosb.Status; } - MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl); + MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl); return(Status); } @@ -408,7 +408,7 @@ MmFreeSwapPage(SWAPENTRY Entry) i = FILE_FROM_ENTRY(Entry); off = OFFSET_FROM_ENTRY(Entry); - + if (i >= MAX_PAGING_FILES) { DPRINT1("Bad swap entry 0x%.8X\n", Entry); @@ -421,9 +421,9 @@ MmFreeSwapPage(SWAPENTRY Entry) KEBUGCHECK(0); } KeAcquireSpinLockAtDpcLevel(&PagingFileList[i]->AllocMapLock); - + PagingFileList[i]->AllocMap[off >> 5] &= (~(1 << (off % 32))); - + PagingFileList[i]->FreePages++; PagingFileList[i]->UsedPages--; @@ -602,7 +602,7 @@ MmDumpToPagingFile(ULONG BugCode, for (i = 0; i < MmStats.NrTotalPages; i++) { MdlMap[0] = i; - MmCreateVirtualMappingForKernel(MmCoreDumpPageFrame, + MmCreateVirtualMappingForKernel(MmCoreDumpPageFrame, PAGE_READWRITE, MdlMap, 1); @@ -695,7 +695,7 @@ MmInitializeCrashDump(HANDLE PageFileHandle, ULONG PageFileNum) FALSE, &Event, &Iosb); - if(Irp == NULL) + if(Irp == NULL) { ObDereferenceObject(PageFile); return(STATUS_NO_MEMORY);// tMk - is this correct return code ??? @@ -792,7 +792,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName, } PreviousMode = ExGetPreviousMode(); - + Status = RtlCaptureUnicodeString(&CapturedFileName, PreviousMode, PagedPool, @@ -820,7 +820,7 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if (!NT_SUCCESS(Status)) { RtlReleaseCapturedUnicodeString(&CapturedFileName, diff --git a/reactos/ntoskrnl/mm/pageop.c b/reactos/ntoskrnl/mm/pageop.c index e68414dea15..d290c960e88 100644 --- a/reactos/ntoskrnl/mm/pageop.c +++ b/reactos/ntoskrnl/mm/pageop.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/pageop.c * PURPOSE: No purpose listed. - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -134,7 +134,7 @@ MmGetPageOp(PMEMORY_AREA MArea, HANDLE Pid, PVOID Address, /* * FUNCTION: Get a page operation descriptor corresponding to * the memory area and either the segment, offset pair or the - * pid, address pair. + * pid, address pair. */ { ULONG_PTR Hash; diff --git a/reactos/ntoskrnl/mm/pagfault.c b/reactos/ntoskrnl/mm/pagfault.c index a274cd210a2..0432a1eac7e 100644 --- a/reactos/ntoskrnl/mm/pagfault.c +++ b/reactos/ntoskrnl/mm/pagfault.c @@ -1,5 +1,5 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/pagfault.c diff --git a/reactos/ntoskrnl/mm/paging.c b/reactos/ntoskrnl/mm/paging.c index 159909c8341..ae27ab5e68f 100644 --- a/reactos/ntoskrnl/mm/paging.c +++ b/reactos/ntoskrnl/mm/paging.c @@ -1,10 +1,10 @@ -/* $Id:$ +/* $Id$ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/paging.c * PURPOSE: Paging file functions - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ diff --git a/reactos/ntoskrnl/mm/pe.c b/reactos/ntoskrnl/mm/pe.c index fc8e2b97ffd..0993043011d 100644 --- a/reactos/ntoskrnl/mm/pe.c +++ b/reactos/ntoskrnl/mm/pe.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/pe.c * PURPOSE: Loader for PE executables - * + * * PROGRAMMERS: KJK::Hyperion */ @@ -209,7 +209,7 @@ NTSTATUS NTAPI PeFmtCreateSection ASSERT(ImageSectionObject); ASSERT(ReadFileCb); ASSERT(AllocateSegmentsCb); - + ASSERT(Intsafe_CanOffsetPointer(FileHeader, FileHeaderSize)); ASSERT(FileHeaderSize >= sizeof(IMAGE_DOS_HEADER)); @@ -327,7 +327,7 @@ l_ReadHeaderFromFile: /* don't trust an invalid NT header */ if(pinhNtHeader->Signature != IMAGE_NT_SIGNATURE) DIE(("The file isn't a PE executable, Signature is %X\n", pinhNtHeader->Signature)); - + if(!Intsafe_AddULong32(&cbOptHeaderOffsetSize, pidhDosHeader->e_lfanew, FIELD_OFFSET(IMAGE_NT_HEADERS32, OptionalHeader))) DIE(("The DOS stub is too large, e_lfanew is %X\n", pidhDosHeader->e_lfanew)); @@ -357,7 +357,7 @@ l_ReadHeaderFromFile: case IMAGE_NT_OPTIONAL_HDR32_MAGIC: case IMAGE_NT_OPTIONAL_HDR64_MAGIC: break; - + default: DIE(("Unrecognized optional header, Magic is %X\n", piohOptHeader->Magic)); } @@ -677,10 +677,10 @@ l_ReadHeaderFromFile: { if(nCharacteristics & IMAGE_SCN_CNT_CODE) nCharacteristics |= IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ; - + if(nCharacteristics & IMAGE_SCN_CNT_INITIALIZED_DATA) nCharacteristics |= IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE; - + if(nCharacteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA) nCharacteristics |= IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE; } diff --git a/reactos/ntoskrnl/mm/physical.c b/reactos/ntoskrnl/mm/physical.c index ec3f719f9b8..8e57dc0d446 100644 --- a/reactos/ntoskrnl/mm/physical.c +++ b/reactos/ntoskrnl/mm/physical.c @@ -1,10 +1,10 @@ -/* $Id:$ - * +/* $Id$ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/physical.c * PURPOSE: Physical Memory Manipulation functions - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) */ diff --git a/reactos/ntoskrnl/mm/pool.c b/reactos/ntoskrnl/mm/pool.c index 30ae6e44139..5d7d8b7cb23 100644 --- a/reactos/ntoskrnl/mm/pool.c +++ b/reactos/ntoskrnl/mm/pool.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/pool.c * PURPOSE: Implements the kernel memory pool - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -81,14 +81,14 @@ ExAllocatePool (POOL_TYPE PoolType, ULONG NumberOfBytes) * PoolType * Specifies the type of memory to allocate which can be one * of the following: - * + * * NonPagedPool * NonPagedPoolMustSucceed * NonPagedPoolCacheAligned * NonPagedPoolCacheAlignedMustS * PagedPool * PagedPoolCacheAligned - * + * * NumberOfBytes * Specifies the number of bytes to allocate * RETURNS: The allocated block on success @@ -264,9 +264,9 @@ ExFreePoolWithTag(IN PVOID Block, IN ULONG Tag) */ SIZE_T STDCALL -ExQueryPoolBlockSize ( - IN PVOID PoolBlock, - OUT PBOOLEAN QuotaCharged +ExQueryPoolBlockSize ( + IN PVOID PoolBlock, + OUT PBOOLEAN QuotaCharged ) { UNIMPLEMENTED; diff --git a/reactos/ntoskrnl/mm/process.c b/reactos/ntoskrnl/mm/process.c index f5ddc7a9abb..b4b4bf856cc 100644 --- a/reactos/ntoskrnl/mm/process.c +++ b/reactos/ntoskrnl/mm/process.c @@ -1,4 +1,4 @@ -/* +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/process.c @@ -18,7 +18,7 @@ extern ULONG NtMinorVersion; extern ULONG NtOSCSDVersion; /* FUNCTIONS *****************************************************************/ - + PVOID STDCALL MiCreatePebOrTeb(PEPROCESS Process, @@ -30,12 +30,12 @@ MiCreatePebOrTeb(PEPROCESS Process, PHYSICAL_ADDRESS BoundaryAddressMultiple; BoundaryAddressMultiple.QuadPart = 0; PVOID AllocatedBase = BaseAddress; - + /* Acquire the Lock */ MmLockAddressSpace(ProcessAddressSpace); - /* - * Create a Peb or Teb. + /* + * Create a Peb or Teb. * Loop until it works, decreasing by PAGE_SIZE each time. The logic here * is that a PEB allocation should never fail since the address is free, * while TEB allocation can fail, and we should simply try the address @@ -56,16 +56,16 @@ MiCreatePebOrTeb(PEPROCESS Process, BoundaryAddressMultiple); AllocatedBase = AllocatedBase - PAGE_SIZE; } while (Status != STATUS_SUCCESS); - + /* Initialize the Region */ MmInitialiseRegion(&MemoryArea->Data.VirtualMemoryData.RegionListHead, - PAGE_SIZE, - MEM_COMMIT, + PAGE_SIZE, + MEM_COMMIT, PAGE_READWRITE); - + /* Reserve the pages */ MmReserveSwapPages(PAGE_SIZE); - + /* Unlock Address Space */ DPRINT("Returning\n"); MmUnlockAddressSpace(ProcessAddressSpace); @@ -73,11 +73,11 @@ MiCreatePebOrTeb(PEPROCESS Process, } VOID -MiFreeStackPage(PVOID Context, - MEMORY_AREA* MemoryArea, - PVOID Address, - PFN_TYPE Page, - SWAPENTRY SwapEntry, +MiFreeStackPage(PVOID Context, + MEMORY_AREA* MemoryArea, + PVOID Address, + PFN_TYPE Page, + SWAPENTRY SwapEntry, BOOLEAN Dirty) { ASSERT(SwapEntry == 0); @@ -88,26 +88,26 @@ VOID STDCALL MmDeleteKernelStack(PVOID Stack, BOOLEAN GuiStack) -{ +{ /* Lock the Address Space */ MmLockAddressSpace(MmGetKernelAddressSpace()); - + /* Delete the Stack */ MmFreeMemoryAreaByPtr(MmGetKernelAddressSpace(), Stack, MiFreeStackPage, NULL); - + /* Unlock the Address Space */ MmUnlockAddressSpace(MmGetKernelAddressSpace()); } VOID -MiFreePebPage(PVOID Context, - MEMORY_AREA* MemoryArea, - PVOID Address, - PFN_TYPE Page, - SWAPENTRY SwapEntry, +MiFreePebPage(PVOID Context, + MEMORY_AREA* MemoryArea, + PVOID Address, + PFN_TYPE Page, + SWAPENTRY SwapEntry, BOOLEAN Dirty) { PEPROCESS Process = (PEPROCESS)Context; @@ -134,18 +134,18 @@ VOID STDCALL MmDeleteTeb(PEPROCESS Process, PTEB Teb) -{ +{ PMADDRESS_SPACE ProcessAddressSpace = &Process->AddressSpace; - + /* Lock the Address Space */ MmLockAddressSpace(ProcessAddressSpace); - + /* Delete the Stack */ MmFreeMemoryAreaByPtr(ProcessAddressSpace, Teb, MiFreePebPage, Process); - + /* Unlock the Address Space */ MmUnlockAddressSpace(ProcessAddressSpace); } @@ -160,13 +160,13 @@ MmCreateKernelStack(BOOLEAN GuiStack) PFN_TYPE Page[MM_STACK_SIZE / PAGE_SIZE]; PVOID KernelStack = NULL; NTSTATUS Status; - + /* Initialize the Boundary Address */ BoundaryAddressMultiple.QuadPart = 0; - + /* Lock the Kernel Address Space */ MmLockAddressSpace(MmGetKernelAddressSpace()); - + /* Create a MAREA for the Kernel Stack */ Status = MmCreateMemoryArea(NULL, MmGetKernelAddressSpace(), @@ -178,53 +178,53 @@ MmCreateKernelStack(BOOLEAN GuiStack) FALSE, FALSE, BoundaryAddressMultiple); - + /* Unlock the Address Space */ MmUnlockAddressSpace(MmGetKernelAddressSpace()); - + /* Check for Success */ - if (!NT_SUCCESS(Status)) - { + if (!NT_SUCCESS(Status)) + { DPRINT1("Failed to create thread stack\n"); KEBUGCHECK(0); } - + /* Mark the Stack in use */ - for (i = 0; i < (MM_STACK_SIZE / PAGE_SIZE); i++) + for (i = 0; i < (MM_STACK_SIZE / PAGE_SIZE); i++) { Status = MmRequestPageMemoryConsumer(MC_NPPOOL, TRUE, &Page[i]); } - + /* Create a Virtual Mapping for it */ Status = MmCreateVirtualMapping(NULL, KernelStack, PAGE_READWRITE, Page, MM_STACK_SIZE / PAGE_SIZE); - + /* Check for success */ - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { DPRINT1("Could not create Virtual Mapping for Kernel Stack\n"); KEBUGCHECK(0); } - + return KernelStack; } NTSTATUS STDCALL MmCreatePeb(PEPROCESS Process) -{ +{ PPEB Peb = NULL; LARGE_INTEGER SectionOffset; ULONG ViewSize = 0; PVOID TableBase = NULL; NTSTATUS Status; SectionOffset.QuadPart = (ULONGLONG)0; - + DPRINT("MmCreatePeb\n"); - + /* Map NLS Tables */ DPRINT("Mapping NLS\n"); Status = MmMapViewOfSection(NlsSectionObject, @@ -237,7 +237,7 @@ MmCreatePeb(PEPROCESS Process) ViewShare, MEM_TOP_DOWN, PAGE_READONLY); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { DPRINT1("MmMapViewOfSection() failed (Status %lx)\n", Status); return(Status); @@ -246,10 +246,10 @@ MmCreatePeb(PEPROCESS Process) /* Attach to Process */ KeAttachProcess(&Process->Pcb); - + /* Allocate the PEB */ Peb = MiCreatePebOrTeb(Process, (PVOID)PEB_BASE); - + /* Initialize the PEB */ DPRINT("Allocated: %x\n", Peb); RtlZeroMemory(Peb, sizeof(PEB)); @@ -283,7 +283,7 @@ MmCreateTeb(PEPROCESS Process, { PTEB Teb; BOOLEAN Attached = FALSE; - + /* Attach to the process */ DPRINT("MmCreateTeb\n"); if (Process != PsGetCurrentProcess()) @@ -292,24 +292,24 @@ MmCreateTeb(PEPROCESS Process, KeAttachProcess(&Process->Pcb); Attached = TRUE; } - + /* Allocate the TEB */ Teb = MiCreatePebOrTeb(Process, (PVOID)TEB_BASE); - + /* Initialize the PEB */ RtlZeroMemory(Teb, sizeof(TEB)); - + /* Set TIB Data */ Teb->Tib.ExceptionList = (PVOID)0xFFFFFFFF; Teb->Tib.Version = 1; Teb->Tib.Self = (PNT_TIB)Teb; - + /* Set TEB Data */ Teb->Cid = *ClientId; Teb->RealClientId = *ClientId; Teb->Peb = Process->Peb; Teb->CurrentLocale = PsDefaultThreadLocaleId; - + /* Store stack information from InitialTeb */ if(InitialTeb != NULL) { @@ -328,7 +328,7 @@ MmCreateTeb(PEPROCESS Process, Teb->DeallocationStack = InitialTeb->StackReserved; } } - + /* Return TEB Address */ DPRINT("Allocated: %x\n", Teb); if (Attached) KeDetachProcess(); @@ -348,10 +348,10 @@ MmCreateProcessAddressSpace(IN PEPROCESS Process, BoundaryAddressMultiple.QuadPart = 0; ULONG ViewSize = 0; PVOID ImageBase = 0; - + /* Initialize the Addresss Space */ - MmInitializeAddressSpace(Process, ProcessAddressSpace); - + MmInitializeAddressSpace(Process, ProcessAddressSpace); + /* Acquire the Lock */ MmLockAddressSpace(ProcessAddressSpace); @@ -367,12 +367,12 @@ MmCreateProcessAddressSpace(IN PEPROCESS Process, FALSE, FALSE, BoundaryAddressMultiple); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { DPRINT1("Failed to protect last 64KB\n"); goto exit; } - + /* Protect the 60KB above the shared user page */ BaseAddress = (char*)USER_SHARED_DATA + PAGE_SIZE; Status = MmCreateMemoryArea(Process, @@ -385,7 +385,7 @@ MmCreateProcessAddressSpace(IN PEPROCESS Process, FALSE, FALSE, BoundaryAddressMultiple); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { DPRINT1("Failed to protect the memory above the shared user page\n"); goto exit; @@ -403,24 +403,24 @@ MmCreateProcessAddressSpace(IN PEPROCESS Process, FALSE, FALSE, BoundaryAddressMultiple); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { DPRINT1("Failed to create Shared User Data\n"); goto exit; } - + /* Check if there's a Section Object */ - if (Section) + if (Section) { UNICODE_STRING FileName; PWCHAR szSrc; PCHAR szDest; USHORT lnFName = 0; - + /* Unlock the Address Space */ DPRINT("Unlocking\n"); MmUnlockAddressSpace(ProcessAddressSpace); - + DPRINT("Mapping process image. Section: %p, Process: %p, ImageBase: %p\n", Section, Process, &ImageBase); Status = MmMapViewOfSection(Section, @@ -433,30 +433,30 @@ MmCreateProcessAddressSpace(IN PEPROCESS Process, 0, MEM_COMMIT, PAGE_READWRITE); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { DPRINT1("Failed to map process Image\n"); - ObDereferenceObject(Section); + ObDereferenceObject(Section); goto exit; } ObDereferenceObject(Section); - + /* Save the pointer */ Process->SectionBaseAddress = ImageBase; - + /* Determine the image file name and save it to EPROCESS */ DPRINT("Getting Image name\n"); FileName = Section->FileObject->FileName; szSrc = (PWCHAR)(FileName.Buffer + (FileName.Length / sizeof(WCHAR)) - 1); - while(szSrc >= FileName.Buffer) + while(szSrc >= FileName.Buffer) { - if(*szSrc == L'\\') + if(*szSrc == L'\\') { szSrc++; break; - } - else + } + else { szSrc--; lnFName++; @@ -468,16 +468,16 @@ MmCreateProcessAddressSpace(IN PEPROCESS Process, szDest = Process->ImageFileName; lnFName = min(lnFName, sizeof(Process->ImageFileName) - 1); while(lnFName-- > 0) *(szDest++) = (UCHAR)*(szSrc++); - + /* Return status to caller */ return Status; } - + exit: /* Unlock the Address Space */ DPRINT("Unlocking\n"); MmUnlockAddressSpace(ProcessAddressSpace); - + /* Return status to caller */ return Status; } diff --git a/reactos/ntoskrnl/mm/region.c b/reactos/ntoskrnl/mm/region.c index e5efd3fe827..0a7738c46e1 100644 --- a/reactos/ntoskrnl/mm/region.c +++ b/reactos/ntoskrnl/mm/region.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/region.c * PURPOSE: No purpose listed. - * + * * PROGRAMMERS: David Welch */ diff --git a/reactos/ntoskrnl/mm/rmap.c b/reactos/ntoskrnl/mm/rmap.c index da916f1f1af..d12dfaa18d2 100644 --- a/reactos/ntoskrnl/mm/rmap.c +++ b/reactos/ntoskrnl/mm/rmap.c @@ -1,10 +1,10 @@ /* $Id$ * * COPYRIGHT: See COPYING in the top directory - * PROJECT: ReactOS kernel + * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/rmap.c * PURPOSE: Kernel memory managment functions - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -95,7 +95,7 @@ MmWritePagePhysicalAddress(PFN_TYPE Page) /* * Lock the address space; then check that the address we are using * still corresponds to a valid memory area (the page might have been - * freed or paged out after we read the rmap entry.) + * freed or paged out after we read the rmap entry.) */ MmLockAddressSpace(AddressSpace); MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, Address); diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index 931a65950d3..9080e9f6bb4 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/section.c * PURPOSE: Implements section objects - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -371,7 +371,7 @@ MmUnsharePageEntrySectionSegment(PSECTION_OBJECT Section, { /* * FIXME: - * We hold all locks. Nobody can do something with the current + * We hold all locks. Nobody can do something with the current * process and the current segment (also not within an other process). */ NTSTATUS Status; @@ -716,7 +716,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, if (PAGE_FROM_SSE(Entry) == 0 || HasSwapEntry) { /* - * The page was a private page in another or in our address space + * The page was a private page in another or in our address space */ MmUnlockSectionSegment(Segment); MmspCompleteAndReleasePageOp(PageOp); @@ -2615,7 +2615,7 @@ ExeFmtpReadFile(IN PVOID File, BufferSize, &FileOffset, NULL); - + if(NT_SUCCESS(Status)) { UsedSize = Iosb.Information; @@ -2773,7 +2773,7 @@ MmspCheckSegmentBounds * TODO: relax the limitation on gaps. For example, gaps smaller than a * page could be OK (Windows seems to be OK with them), and larger gaps * could lead to image sections spanning several discontiguous regions - * (NtMapViewOfSection could then refuse to map them, and they could + * (NtMapViewOfSection could then refuse to map them, and they could * e.g. only be allowed as parameters to NtCreateProcess, like on UNIX) */ if ((ImageSectionObject->Segments[i - 1].VirtualAddress + @@ -2827,25 +2827,25 @@ MmspPageAlignSegments ULONG_PTR VirtualOffset; VirtualAddress = EffectiveSegment->VirtualAddress; - + /* Round down the virtual address to the nearest page */ EffectiveSegment->VirtualAddress = PAGE_ROUND_DOWN(VirtualAddress); - + /* Round up the virtual size to the nearest page */ EffectiveSegment->Length = PAGE_ROUND_UP(VirtualAddress + EffectiveSegment->Length) - EffectiveSegment->VirtualAddress; - + /* Adjust the raw address and size */ VirtualOffset = VirtualAddress - EffectiveSegment->VirtualAddress; - + if (EffectiveSegment->FileOffset < VirtualOffset) { return FALSE; } - + /* - * Garbage in, garbage out: unaligned base addresses make the file - * offset point in curious and odd places, but that's what we were + * Garbage in, garbage out: unaligned base addresses make the file + * offset point in curious and odd places, but that's what we were * asked for */ EffectiveSegment->FileOffset -= VirtualOffset; @@ -2858,7 +2858,7 @@ MmspPageAlignSegments EndOfEffectiveSegment = EffectiveSegment->VirtualAddress + EffectiveSegment->Length; ASSERT((EndOfEffectiveSegment % PAGE_SIZE) == 0); - + /* * The current segment begins exactly where the current effective * segment ended, therefore beginning a new effective segment @@ -2915,24 +2915,24 @@ MmspPageAlignSegments /* * Extend the file size */ - + /* Unaligned segments must be contiguous within the file */ if (Segment->FileOffset != (EffectiveSegment->FileOffset + EffectiveSegment->RawLength)) { return FALSE; } - + EffectiveSegment->RawLength += Segment->RawLength; - + /* * Extend the virtual size */ ASSERT(PAGE_ROUND_UP(Segment->VirtualAddress + Segment->Length) > EndOfEffectiveSegment); - + EffectiveSegment->Length = PAGE_ROUND_UP(Segment->VirtualAddress + Segment->Length) - EffectiveSegment->VirtualAddress; - + /* * Merge the protection */ @@ -3064,10 +3064,10 @@ ExeFmtpCreateImageSection(HANDLE FileHandle, /* FIXME? are these values platform-dependent? */ if(ImageSectionObject->StackReserve == 0) ImageSectionObject->StackReserve = 0x40000; - + if(ImageSectionObject->StackCommit == 0) ImageSectionObject->StackCommit = 0x1000; - + if(ImageSectionObject->ImageBase == 0) { if(ImageSectionObject->ImageCharacteristics & IMAGE_FILE_DLL) @@ -3324,7 +3324,7 @@ NtCreateSection (OUT PHANDLE SectionHandle, NTSTATUS Status = STATUS_SUCCESS; PreviousMode = ExGetPreviousMode(); - + if(MaximumSize != NULL && PreviousMode != KernelMode) { _SEH_TRY @@ -3341,13 +3341,13 @@ NtCreateSection (OUT PHANDLE SectionHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; } } - + /* * Check the protection */ @@ -3406,9 +3406,9 @@ NtOpenSection(PHANDLE SectionHandle, HANDLE hSection; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PreviousMode = ExGetPreviousMode(); - + if(PreviousMode != KernelMode) { _SEH_TRY @@ -3422,7 +3422,7 @@ NtOpenSection(PHANDLE SectionHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -3577,15 +3577,15 @@ NtMapViewOfSection(IN HANDLE SectionHandle, KPROCESSOR_MODE PreviousMode; PMADDRESS_SPACE AddressSpace; NTSTATUS Status = STATUS_SUCCESS; - + PreviousMode = ExGetPreviousMode(); - + if(PreviousMode != KernelMode) { SafeBaseAddress = NULL; SafeSectionOffset.QuadPart = 0; SafeViewSize = 0; - + _SEH_TRY { if(BaseAddress != NULL) @@ -3612,7 +3612,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -3664,7 +3664,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle, ObDereferenceObject(Section); ObDereferenceObject(Process); - + if(NT_SUCCESS(Status)) { /* copy parameters back to the caller */ @@ -3989,7 +3989,7 @@ NtUnmapViewOfSection (HANDLE ProcessHandle, /** * Queries the information of a section object. - * + * * @param SectionHandle * Handle to the section object. It must be opened with SECTION_QUERY * access. @@ -4019,9 +4019,9 @@ NtQuerySection(IN HANDLE SectionHandle, PSECTION_OBJECT Section; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PreviousMode = ExGetPreviousMode(); - + DefaultQueryInfoBufferCheck(SectionInformationClass, ExSectionInfoClass, SectionInformation, @@ -4075,7 +4075,7 @@ NtQuerySection(IN HANDLE SectionHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + break; } @@ -4101,7 +4101,7 @@ NtQuerySection(IN HANDLE SectionHandle, Sii->ImageNumber = ImageSectionObject->Machine; Sii->Executable = ImageSectionObject->Executable; } - + if (ResultLength != NULL) { *ResultLength = sizeof(SECTION_IMAGE_INFORMATION); @@ -4113,21 +4113,21 @@ NtQuerySection(IN HANDLE SectionHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + break; } } ObDereferenceObject(Section); } - + return(Status); } /** * Extends size of file backed section. - * + * * @param SectionHandle * Handle to the section object. It must be opened with * SECTION_EXTEND_SIZE access. @@ -4147,9 +4147,9 @@ NtExtendSection(IN HANDLE SectionHandle, PSECTION_OBJECT Section; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PreviousMode = ExGetPreviousMode(); - + if(PreviousMode != KernelMode) { _SEH_TRY @@ -4166,7 +4166,7 @@ NtExtendSection(IN HANDLE SectionHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -4189,7 +4189,7 @@ NtExtendSection(IN HANDLE SectionHandle, ObfDereferenceObject(Section); return STATUS_INVALID_PARAMETER; } - + /* * - Acquire file extneding resource. * - Check if we're not resizing the section below it's actual size! diff --git a/reactos/ntoskrnl/mm/verifier.c b/reactos/ntoskrnl/mm/verifier.c index bf25b4165f6..d51949c1642 100644 --- a/reactos/ntoskrnl/mm/verifier.c +++ b/reactos/ntoskrnl/mm/verifier.c @@ -1,10 +1,10 @@ -/* $Id:$ +/* $Id$ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/verifier.c * PURPOSE: Driver Verifier functions - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) */ diff --git a/reactos/ntoskrnl/mm/virtual.c b/reactos/ntoskrnl/mm/virtual.c index 0f9be5620e3..1b198b295a7 100644 --- a/reactos/ntoskrnl/mm/virtual.c +++ b/reactos/ntoskrnl/mm/virtual.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/virtual.c * PURPOSE: Implementing operations on virtual memory. - * + * * PROGRAMMERS: David Welch */ @@ -189,7 +189,7 @@ MiQueryVirtualMemory (IN HANDLE ProcessHandle, Info->AllocationProtect = MemoryArea->Attributes; Info->BaseAddress = MemoryArea->StartingAddress; Info->AllocationBase = MemoryArea->StartingAddress; - Info->RegionSize = (ULONG_PTR)MemoryArea->EndingAddress - + Info->RegionSize = (ULONG_PTR)MemoryArea->EndingAddress - (ULONG_PTR)MemoryArea->StartingAddress; Status = STATUS_SUCCESS; *ResultLength = sizeof(MEMORY_BASIC_INFORMATION); @@ -201,7 +201,7 @@ MiQueryVirtualMemory (IN HANDLE ProcessHandle, Info->AllocationProtect = MemoryArea->Attributes; Info->BaseAddress = MemoryArea->StartingAddress; Info->AllocationBase = MemoryArea->StartingAddress; - Info->RegionSize = (ULONG_PTR)MemoryArea->EndingAddress - + Info->RegionSize = (ULONG_PTR)MemoryArea->EndingAddress - (ULONG_PTR)MemoryArea->StartingAddress; Status = STATUS_SUCCESS; *ResultLength = sizeof(MEMORY_BASIC_INFORMATION); @@ -222,7 +222,7 @@ MiQueryVirtualMemory (IN HANDLE ProcessHandle, Info->AllocationProtect = MemoryArea->Attributes; Info->BaseAddress = MemoryArea->StartingAddress; Info->AllocationBase = MemoryArea->StartingAddress; - Info->RegionSize = (ULONG_PTR)MemoryArea->EndingAddress - + Info->RegionSize = (ULONG_PTR)MemoryArea->EndingAddress - (ULONG_PTR)MemoryArea->StartingAddress; Status = STATUS_SUCCESS; *ResultLength = sizeof(MEMORY_BASIC_INFORMATION); @@ -243,7 +243,7 @@ MiQueryVirtualMemory (IN HANDLE ProcessHandle, Info->AllocationProtect = MemoryArea->Attributes; Info->BaseAddress = MemoryArea->StartingAddress; Info->AllocationBase = MemoryArea->StartingAddress; - Info->RegionSize = (ULONG_PTR)MemoryArea->EndingAddress - + Info->RegionSize = (ULONG_PTR)MemoryArea->EndingAddress - (ULONG_PTR)MemoryArea->StartingAddress; Status = STATUS_SUCCESS; *ResultLength = sizeof(MEMORY_BASIC_INFORMATION); @@ -468,11 +468,11 @@ NtReadVirtualMemory(IN HANDLE ProcessHandle, KPROCESSOR_MODE PreviousMode; PEPROCESS Process, CurrentProcess; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); - + if(PreviousMode != KernelMode) { _SEH_TRY @@ -492,7 +492,7 @@ NtReadVirtualMemory(IN HANDLE ProcessHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -549,7 +549,7 @@ NtReadVirtualMemory(IN HANDLE ProcessHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(NT_SUCCESS(Status)) { KeAttachProcess(&Process->Pcb); @@ -593,7 +593,7 @@ NtReadVirtualMemory(IN HANDLE ProcessHandle, } _SEH_END; } - + return(Status); } diff --git a/reactos/ntoskrnl/mm/wset.c b/reactos/ntoskrnl/mm/wset.c index d6ff15b5a85..411fdea3b6b 100644 --- a/reactos/ntoskrnl/mm/wset.c +++ b/reactos/ntoskrnl/mm/wset.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/wset.c * PURPOSE: Manages working sets - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ diff --git a/reactos/ntoskrnl/ob/dirobj.c b/reactos/ntoskrnl/ob/dirobj.c index de44ab0d7c8..ca0b805e6a6 100644 --- a/reactos/ntoskrnl/ob/dirobj.c +++ b/reactos/ntoskrnl/ob/dirobj.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ob/dirobj.c * PURPOSE: Interface functions to directory object - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -24,20 +24,20 @@ * * DESCRIPTION * Opens a namespace directory object. - * + * * ARGUMENTS * DirectoryHandle (OUT) * Variable which receives the directory handle. - * + * * DesiredAccess * Desired access to the directory. - * + * * ObjectAttributes * Structure describing the directory. - * + * * RETURN VALUE * Status. - * + * * NOTES * Undocumented. */ @@ -49,11 +49,11 @@ NtOpenDirectoryObject (OUT PHANDLE DirectoryHandle, HANDLE hDirectory; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); - + if(PreviousMode != KernelMode) { _SEH_TRY @@ -67,14 +67,14 @@ NtOpenDirectoryObject (OUT PHANDLE DirectoryHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { DPRINT1("NtOpenDirectoryObject failed, Status: 0x%x\n", Status); return Status; } } - + Status = ObOpenObjectByName(ObjectAttributes, ObDirectoryType, NULL, @@ -94,7 +94,7 @@ NtOpenDirectoryObject (OUT PHANDLE DirectoryHandle, } _SEH_END; } - + return Status; } @@ -102,35 +102,35 @@ NtOpenDirectoryObject (OUT PHANDLE DirectoryHandle, /********************************************************************** * NAME EXPORTED * NtQueryDirectoryObject - * + * * DESCRIPTION * Reads information from a directory in the system namespace. - * + * * ARGUMENTS * DirectoryHandle * Handle, obtained with NtOpenDirectoryObject(), which * must grant DIRECTORY_QUERY access to the directory * object. - * + * * Buffer (OUT) * Buffer to hold the data read. - * + * * BufferLength * Size of the buffer in bytes. - * + * * ReturnSingleEntry * When TRUE, only 1 entry is written in DirObjInformation; * otherwise as many as will fit in the buffer. - * + * * RestartScan * If TRUE start reading at index 0. * If FALSE start reading at the index specified * by object index *ObjectIndex. - * + * * Context * Zero based index into the directory, interpretation * depends on RestartScan. - * + * * ReturnLength (OUT) * Caller supplied storage for the number of bytes * written (or NULL). @@ -171,9 +171,9 @@ NtQueryDirectoryObject (IN HANDLE DirectoryHandle, ULONG NextEntry = 0; ULONG CopyBytes = 0; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); if(PreviousMode != KernelMode) @@ -216,7 +216,7 @@ NtQueryDirectoryObject (IN HANDLE DirectoryHandle, { SkipEntries = *Context; } - + Status = ObReferenceObjectByHandle(DirectoryHandle, DIRECTORY_QUERY, ObDirectoryType, @@ -235,7 +235,7 @@ NtQueryDirectoryObject (IN HANDLE DirectoryHandle, ULONG RequiredSize = 0; ULONG nDirectories = 0; POBJECT_DIRECTORY_INFORMATION DirInfo = (POBJECT_DIRECTORY_INFORMATION)TemporaryBuffer; - + Status = STATUS_NO_MORE_ENTRIES; KeAcquireSpinLock(&Directory->Lock, &OldLevel); @@ -275,7 +275,7 @@ NtQueryDirectoryObject (IN HANDLE DirectoryHandle, nDirectories++; RequiredSize += EntrySize; - + Status = STATUS_SUCCESS; if(ReturnSingleEntry) @@ -295,12 +295,12 @@ NtQueryDirectoryObject (IN HANDLE DirectoryHandle, RequiredSize += EntrySize; Status = STATUS_BUFFER_TOO_SMALL; } - + /* we couldn't query this entry, so leave the index that will be stored in Context to this entry so the caller can query it the next time he queries (hopefully with a buffer that is large enough then...) */ NextEntry--; - + /* just copy the entries that fit into the buffer */ break; } @@ -311,7 +311,7 @@ NtQueryDirectoryObject (IN HANDLE DirectoryHandle, SkipEntries--; } } - + if(!ReturnSingleEntry && ListEntry != &Directory->head) { /* there are more entries to enumerate but the buffer is already full. @@ -323,9 +323,9 @@ NtQueryDirectoryObject (IN HANDLE DirectoryHandle, { PWSTR strbuf = (PWSTR)((POBJECT_DIRECTORY_INFORMATION)TemporaryBuffer + nDirectories); PWSTR deststrbuf = (PWSTR)((POBJECT_DIRECTORY_INFORMATION)Buffer + nDirectories); - + CopyBytes = nDirectories * sizeof(OBJECT_DIRECTORY_INFORMATION); - + /* copy the names from the objects and append them to the list of the objects. copy to the temporary buffer only because the directory lock can't be released and the buffer might be pagable memory! */ @@ -334,7 +334,7 @@ NtQueryDirectoryObject (IN HANDLE DirectoryHandle, nDirectories--, DirInfo++) { ULONG NameLength; - + if(DirInfo->ObjectName.Length > 0) { RtlCopyMemory(strbuf, @@ -350,7 +350,7 @@ NtQueryDirectoryObject (IN HANDLE DirectoryHandle, CopyBytes += (NameLength + 1) * sizeof(WCHAR); } - + RtlCopyMemory(strbuf, DirInfo->ObjectTypeName.Buffer, DirInfo->ObjectTypeName.Length); @@ -361,7 +361,7 @@ NtQueryDirectoryObject (IN HANDLE DirectoryHandle, strbuf[NameLength] = L'\0'; strbuf += NameLength + 1; deststrbuf += NameLength + 1; - + CopyBytes += (NameLength + 1) * sizeof(WCHAR); } } @@ -391,7 +391,7 @@ NtQueryDirectoryObject (IN HANDLE DirectoryHandle, } _SEH_END; } - + ExFreePool(TemporaryBuffer); } else @@ -399,7 +399,7 @@ NtQueryDirectoryObject (IN HANDLE DirectoryHandle, Status = STATUS_INSUFFICIENT_RESOURCES; } } - + return Status; } @@ -407,23 +407,23 @@ NtQueryDirectoryObject (IN HANDLE DirectoryHandle, /********************************************************************** * NAME (EXPORTED as Zw) * NtCreateDirectoryObject - * + * * DESCRIPTION * Creates or opens a directory object (a container for other * objects). - * + * * ARGUMENTS * DirectoryHandle (OUT) - * Caller supplied storage for the handle of the + * Caller supplied storage for the handle of the * directory. - * + * * DesiredAccess * Access desired to the directory. - * + * * ObjectAttributes * Object attributes initialized with * InitializeObjectAttributes. - * + * * RETURN VALUE * Status. */ @@ -436,9 +436,9 @@ NtCreateDirectoryObject (OUT PHANDLE DirectoryHandle, HANDLE hDirectory; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + DPRINT("NtCreateDirectoryObject(DirectoryHandle %x, " "DesiredAccess %x, ObjectAttributes %x\n", DirectoryHandle, DesiredAccess, ObjectAttributes); diff --git a/reactos/ntoskrnl/ob/handle.c b/reactos/ntoskrnl/ob/handle.c index 872237e7156..fc0ddeb4ced 100644 --- a/reactos/ntoskrnl/ob/handle.c +++ b/reactos/ntoskrnl/ob/handle.c @@ -71,7 +71,7 @@ ObpDecrementHandleCount(PVOID ObjectBody) if it's not a permanent object. */ ObpRemoveEntryDirectory(ObjectHeader); } - + /* remove the keep-alive reference */ ObDereferenceObject(ObjectBody); } @@ -85,11 +85,11 @@ ObpQueryHandleAttributes(HANDLE Handle, PHANDLE_TABLE HandleTable; PHANDLE_TABLE_ENTRY HandleTableEntry; LONG ExHandle; - + PAGED_CODE(); DPRINT("ObpQueryHandleAttributes(Handle %x)\n", Handle); - + if(ObIsKernelHandle(Handle, ExGetPreviousMode())) { HandleTable = ObpKernelHandleTable; @@ -130,7 +130,7 @@ ObpSetHandleAttributes(HANDLE Handle, PHANDLE_TABLE HandleTable; PHANDLE_TABLE_ENTRY HandleTableEntry; LONG ExHandle; - + PAGED_CODE(); DPRINT("ObpSetHandleAttributes(Handle %x)\n", Handle); @@ -145,7 +145,7 @@ ObpSetHandleAttributes(HANDLE Handle, HandleTable = PsGetCurrentProcess()->ObjectTable; ExHandle = HANDLE_TO_EX_HANDLE(Handle); } - + KeEnterCriticalRegion(); HandleTableEntry = ExMapHandleToPointer(HandleTable, @@ -242,9 +242,9 @@ ObDuplicateObject(PEPROCESS SourceProcess, LONG ExTargetHandle; LONG ExSourceHandle; ULONG NewHandleCount; - + PAGED_CODE(); - + if(ObIsKernelHandle(SourceHandle, ExGetPreviousMode())) { SourceHandleTable = ObpKernelHandleTable; @@ -254,11 +254,11 @@ ObDuplicateObject(PEPROCESS SourceProcess, { SourceHandleTable = SourceProcess->ObjectTable; } - + ExSourceHandle = HANDLE_TO_EX_HANDLE(SourceHandle); - + KeEnterCriticalRegion(); - + SourceHandleEntry = ExMapHandleToPointer(SourceHandleTable, ExSourceHandle); if (SourceHandleEntry == NULL) @@ -291,11 +291,11 @@ ObDuplicateObject(PEPROCESS SourceProcess, } NewHandleEntry.u2.GrantedAccess = DesiredAccess; } - + /* reference the object so it doesn't get deleted after releasing the lock and before creating a new handle for it */ ObReferenceObject(ObjectBody); - + /* increment the handle count of the object, it should always be >= 2 because we're holding a handle lock to this object! if the new handle count was 1 here, we're in big trouble... it would've been safe to increment and @@ -303,7 +303,7 @@ ObDuplicateObject(PEPROCESS SourceProcess, entry is locked, which means the handle count can't change. */ NewHandleCount = InterlockedIncrement(&ObjectHeader->HandleCount); ASSERT(NewHandleCount >= 2); - + ExUnlockHandleTableEntry(SourceHandleTable, SourceHandleEntry); @@ -319,11 +319,11 @@ ObDuplicateObject(PEPROCESS SourceProcess, ObpDeleteHandle(SourceHandleTable, SourceHandle); } - + ObDereferenceObject(ObjectBody); *TargetHandle = EX_HANDLE_TO_HANDLE(ExTargetHandle); - + return STATUS_SUCCESS; } else @@ -334,7 +334,7 @@ ObDuplicateObject(PEPROCESS SourceProcess, { ObDereferenceObject(ObjectBody); } - + ObDereferenceObject(ObjectBody); return STATUS_UNSUCCESSFUL; } @@ -343,7 +343,7 @@ ObDuplicateObject(PEPROCESS SourceProcess, /* * @implemented */ -NTSTATUS STDCALL +NTSTATUS STDCALL NtDuplicateObject (IN HANDLE SourceProcessHandle, IN HANDLE SourceHandle, IN HANDLE TargetProcessHandle, @@ -354,23 +354,23 @@ NtDuplicateObject (IN HANDLE SourceProcessHandle, /* * FUNCTION: Copies a handle from one process space to another * ARGUMENTS: - * SourceProcessHandle = The source process owning the handle. The + * SourceProcessHandle = The source process owning the handle. The * source process should have opened - * the SourceHandle with PROCESS_DUP_HANDLE + * the SourceHandle with PROCESS_DUP_HANDLE * access. * SourceHandle = The handle to the object. - * TargetProcessHandle = The destination process owning the handle - * TargetHandle (OUT) = Caller should supply storage for the - * duplicated handle. + * TargetProcessHandle = The destination process owning the handle + * TargetHandle (OUT) = Caller should supply storage for the + * duplicated handle. * DesiredAccess = The desired access to the handle. * InheritHandle = Indicates wheter the new handle will be inheritable * or not. - * Options = Specifies special actions upon duplicating the handle. - * Can be one of the values DUPLICATE_CLOSE_SOURCE | - * DUPLICATE_SAME_ACCESS. DUPLICATE_CLOSE_SOURCE specifies - * that the source handle should be closed after duplicating. - * DUPLICATE_SAME_ACCESS specifies to ignore the - * DesiredAccess paramter and just grant the same access to + * Options = Specifies special actions upon duplicating the handle. + * Can be one of the values DUPLICATE_CLOSE_SOURCE | + * DUPLICATE_SAME_ACCESS. DUPLICATE_CLOSE_SOURCE specifies + * that the source handle should be closed after duplicating. + * DUPLICATE_SAME_ACCESS specifies to ignore the + * DesiredAccess paramter and just grant the same access to * the new handle. * RETURNS: Status * REMARKS: This function maps to the win32 DuplicateHandle. @@ -381,11 +381,11 @@ NtDuplicateObject (IN HANDLE SourceProcessHandle, HANDLE hTarget; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); - + if(TargetHandle != NULL && PreviousMode != KernelMode) { _SEH_TRY @@ -399,13 +399,13 @@ NtDuplicateObject (IN HANDLE SourceProcessHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; } } - + Status = ObReferenceObjectByHandle(SourceProcessHandle, PROCESS_DUP_HANDLE, NULL, @@ -435,7 +435,7 @@ NtDuplicateObject (IN HANDLE SourceProcessHandle, { PVOID ObjectBody; POBJECT_TYPE ObjectType; - + ObjectType = (SourceHandle == NtCurrentThread()) ? PsThreadType : PsProcessType; Status = ObReferenceObjectByHandle(SourceHandle, @@ -512,12 +512,12 @@ DeleteHandleCallback(PHANDLE_TABLE HandleTable, { POBJECT_HEADER ObjectHeader; PVOID ObjectBody; - + PAGED_CODE(); ObjectHeader = EX_OBJ_TO_HDR(Object); ObjectBody = HEADER_TO_BODY(ObjectHeader); - + ObpDecrementHandleCount(ObjectBody); } @@ -528,9 +528,9 @@ DuplicateHandleCallback(PHANDLE_TABLE HandleTable, { POBJECT_HEADER ObjectHeader; BOOLEAN Ret = FALSE; - + PAGED_CODE(); - + Ret = (HandleTableEntry->u1.ObAttributes & EX_HANDLE_ENTRY_INHERITABLE) != 0; if(Ret) { @@ -540,7 +540,7 @@ DuplicateHandleCallback(PHANDLE_TABLE HandleTable, ObReferenceObject(HEADER_TO_BODY(ObjectHeader)); } } - + return Ret; } @@ -556,7 +556,7 @@ VOID ObCreateHandleTable(PEPROCESS Parent, */ { PAGED_CODE(); - + DPRINT("ObCreateHandleTable(Parent %x, Inherit %d, Process %x)\n", Parent,Inherit,Process); if(Parent != NULL) @@ -602,7 +602,7 @@ ObCreateHandle(PEPROCESS Process, HANDLE_TABLE_ENTRY NewEntry; POBJECT_HEADER ObjectHeader; LONG ExHandle; - + PAGED_CODE(); DPRINT("ObCreateHandle(Process %x, obj %x)\n",Process,ObjectBody); @@ -613,7 +613,7 @@ ObCreateHandle(PEPROCESS Process, ObjectHeader = BODY_TO_HEADER(ObjectBody); ASSERT((ULONG_PTR)ObjectHeader & EX_HANDLE_ENTRY_LOCKED); - + if (GrantedAccess & MAXIMUM_ALLOWED) { GrantedAccess &= ~MAXIMUM_ALLOWED; @@ -632,7 +632,7 @@ ObCreateHandle(PEPROCESS Process, else NewEntry.u1.ObAttributes &= ~EX_HANDLE_ENTRY_INHERITABLE; NewEntry.u2.GrantedAccess = GrantedAccess; - + ExHandle = ExCreateHandle(Process->ObjectTable, &NewEntry); DPRINT("ObCreateHandle(0x%x)==0x%x [HT:0x%x]\n", ObjectHeader, *HandleReturn, Process->ObjectTable); @@ -645,7 +645,7 @@ ObCreateHandle(PEPROCESS Process, NULL, UserMode); } - + *HandleReturn = EX_HANDLE_TO_HANDLE(ExHandle); return STATUS_SUCCESS; @@ -665,13 +665,13 @@ ObQueryObjectAuditingByHandle(IN HANDLE Handle, PHANDLE_TABLE_ENTRY HandleEntry; PEPROCESS Process; LONG ExHandle = HANDLE_TO_EX_HANDLE(Handle); - + PAGED_CODE(); DPRINT("ObQueryObjectAuditingByHandle(Handle %x)\n", Handle); Process = PsGetCurrentProcess(); - + KeEnterCriticalRegion(); HandleEntry = ExMapHandleToPointer(Process->ObjectTable, @@ -679,31 +679,31 @@ ObQueryObjectAuditingByHandle(IN HANDLE Handle, if(HandleEntry != NULL) { *GenerateOnClose = (HandleEntry->u1.ObAttributes & EX_HANDLE_ENTRY_AUDITONCLOSE) != 0; - + ExUnlockHandleTableEntry(Process->ObjectTable, HandleEntry); KeLeaveCriticalRegion(); - + return STATUS_SUCCESS; } - + KeLeaveCriticalRegion(); - + return STATUS_INVALID_HANDLE; } /* - * FUNCTION: Increments the reference count for an object and returns a + * FUNCTION: Increments the reference count for an object and returns a * pointer to its body * ARGUMENTS: * Handle = Handle for the object * DesiredAccess = Desired access to the object * ObjectType - * AccessMode + * AccessMode * Object (OUT) = Points to the object body on return - * HandleInformation (OUT) = Contains information about the handle + * HandleInformation (OUT) = Contains information about the handle * on return * RETURNS: Status * @@ -724,9 +724,9 @@ ObReferenceObjectByHandle(HANDLE Handle, ACCESS_MASK GrantedAccess; ULONG Attributes; LONG ExHandle; - + PAGED_CODE(); - + DPRINT("ObReferenceObjectByHandle(Handle %x, DesiredAccess %x, " "ObjectType %x, AccessMode %d, Object %x)\n",Handle,DesiredAccess, ObjectType,AccessMode,Object); @@ -734,11 +734,11 @@ ObReferenceObjectByHandle(HANDLE Handle, /* * Handle special handle names */ - if (Handle == NtCurrentProcess() && + if (Handle == NtCurrentProcess() && (ObjectType == PsProcessType || ObjectType == NULL)) { PEPROCESS CurrentProcess = PsGetCurrentProcess(); - + ObReferenceObject(CurrentProcess); if (HandleInformation != NULL) @@ -757,11 +757,11 @@ ObReferenceObjectByHandle(HANDLE Handle, return(STATUS_OBJECT_TYPE_MISMATCH); } - if (Handle == NtCurrentThread() && + if (Handle == NtCurrentThread() && (ObjectType == PsThreadType || ObjectType == NULL)) { PETHREAD CurrentThread = PsGetCurrentThread(); - + ObReferenceObject(CurrentThread); if (HandleInformation != NULL) @@ -779,14 +779,14 @@ ObReferenceObjectByHandle(HANDLE Handle, CHECKPOINT; return(STATUS_OBJECT_TYPE_MISMATCH); } - + /* desire as much access rights as possible */ if (DesiredAccess & MAXIMUM_ALLOWED) { DesiredAccess &= ~MAXIMUM_ALLOWED; DesiredAccess |= GENERIC_ALL; } - + if(ObIsKernelHandle(Handle, AccessMode)) { HandleTable = ObpKernelHandleTable; @@ -799,7 +799,7 @@ ObReferenceObjectByHandle(HANDLE Handle, } KeEnterCriticalRegion(); - + HandleEntry = ExMapHandleToPointer(HandleTable, ExHandle); if (HandleEntry == NULL) @@ -811,9 +811,9 @@ ObReferenceObjectByHandle(HANDLE Handle, ObjectHeader = EX_HTE_TO_HDR(HandleEntry); ObjectBody = HEADER_TO_BODY(ObjectHeader); - + DPRINT("locked1: ObjectHeader: 0x%x [HT:0x%x]\n", ObjectHeader, HandleTable); - + if (ObjectType != NULL && ObjectType != ObjectHeader->ObjectType) { DPRINT("ObjectType mismatch: %wZ vs %wZ (handle 0x%x)\n", &ObjectType->TypeName, ObjectHeader->ObjectType ? &ObjectHeader->ObjectType->TypeName : NULL, Handle); @@ -832,9 +832,9 @@ ObReferenceObjectByHandle(HANDLE Handle, RtlMapGenericMask(&DesiredAccess, BODY_TO_HEADER(ObjectBody)->ObjectType->Mapping); } - + GrantedAccess = HandleEntry->u2.GrantedAccess; - + /* Unless running as KernelMode, deny access if caller desires more access rights than the handle can grant */ if(AccessMode != KernelMode && (~GrantedAccess & DesiredAccess)) @@ -843,21 +843,21 @@ ObReferenceObjectByHandle(HANDLE Handle, HandleEntry); KeLeaveCriticalRegion(); - + DPRINT1("GrantedAccess: 0x%x, ~GrantedAccess: 0x%x, DesiredAccess: 0x%x, denied: 0x%x\n", GrantedAccess, ~GrantedAccess, DesiredAccess, ~GrantedAccess & DesiredAccess); return(STATUS_ACCESS_DENIED); } ObReferenceObject(ObjectBody); - + Attributes = HandleEntry->u1.ObAttributes & (EX_HANDLE_ENTRY_PROTECTFROMCLOSE | EX_HANDLE_ENTRY_INHERITABLE | EX_HANDLE_ENTRY_AUDITONCLOSE); ExUnlockHandleTableEntry(HandleTable, HandleEntry); - + KeLeaveCriticalRegion(); if (HandleInformation != NULL) @@ -867,7 +867,7 @@ ObReferenceObjectByHandle(HANDLE Handle, } *Object = ObjectBody; - + return(STATUS_SUCCESS); } @@ -875,14 +875,14 @@ ObReferenceObjectByHandle(HANDLE Handle, /********************************************************************** * NAME EXPORTED * NtClose - * + * * DESCRIPTION * Closes a handle reference to an object. - * + * * ARGUMENTS * Handle * Handle to close. - * + * * RETURN VALUE * Status. * @@ -893,9 +893,9 @@ NtClose(IN HANDLE Handle) { PHANDLE_TABLE HandleTable; NTSTATUS Status; - + PAGED_CODE(); - + if(ObIsKernelHandle(Handle, ExGetPreviousMode())) { HandleTable = ObpKernelHandleTable; @@ -905,7 +905,7 @@ NtClose(IN HANDLE Handle) { HandleTable = PsGetCurrentProcess()->ObjectTable; } - + Status = ObpDeleteHandle(HandleTable, Handle); if (!NT_SUCCESS(Status)) @@ -917,7 +917,7 @@ NtClose(IN HANDLE Handle) } return Status; } - + return(STATUS_SUCCESS); } @@ -935,7 +935,7 @@ ObInsertObject(IN PVOID Object, { POBJECT_HEADER ObjectHeader; ACCESS_MASK Access; - + PAGED_CODE(); Access = DesiredAccess; @@ -1014,7 +1014,7 @@ ObpGetNextHandleByProcessCount(PSYSTEM_HANDLE_TABLE_ENTRY_INFO pshi, // pshi->HandleValue; -/* +/* This will never work with ROS! M$, I guess uses 0 -> 65535. Ros uses 0 -> 4294967295! */ diff --git a/reactos/ntoskrnl/ob/namespc.c b/reactos/ntoskrnl/ob/namespc.c index 2041cb89570..34cb5d5c479 100644 --- a/reactos/ntoskrnl/ob/namespc.c +++ b/reactos/ntoskrnl/ob/namespc.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ob/namespc.c * PURPOSE: Manages the system namespace - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -55,7 +55,7 @@ ObReferenceObjectByName(PUNICODE_STRING ObjectPath, UNICODE_STRING RemainingPath; OBJECT_ATTRIBUTES ObjectAttributes; NTSTATUS Status; - + PAGED_CODE(); InitializeObjectAttributes(&ObjectAttributes, @@ -91,10 +91,10 @@ DPRINT("Object %p\n", Object); /********************************************************************** * NAME EXPORTED * ObOpenObjectByName - * + * * DESCRIPTION * Obtain a handle to an existing object. - * + * * ARGUMENTS * ObjectAttributes * ... @@ -128,7 +128,7 @@ ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes, UNICODE_STRING RemainingPath; PVOID Object = NULL; NTSTATUS Status; - + PAGED_CODE(); DPRINT("ObOpenObjectByName(...)\n"); @@ -177,23 +177,23 @@ ObQueryDeviceMapInformation(PEPROCESS Process, PPROCESS_DEVICEMAP_INFORMATION DeviceMapInfo) { //KIRQL OldIrql ; - + /* * FIXME: This is an ugly hack for now, to always return the System Device Map * instead of returning the Process Device Map. Not important yet since we don't use it */ - + /* FIXME: Acquire the DeviceMap Spinlock */ // KeAcquireSpinLock(DeviceMap->Lock, &OldIrql); - + /* Make a copy */ DeviceMapInfo->Query.DriveMap = ObSystemDeviceMap->DriveMap; RtlMoveMemory(DeviceMapInfo->Query.DriveType, ObSystemDeviceMap->DriveType, sizeof(ObSystemDeviceMap->DriveType)); - + /* FIXME: Release the DeviceMap Spinlock */ // KeReleasepinLock(DeviceMap->Lock, OldIrql); -} - +} + VOID ObpAddEntryDirectory(PDIRECTORY_OBJECT Parent, POBJECT_HEADER Header, @@ -248,7 +248,7 @@ ObpFindEntryDirectory(PDIRECTORY_OBJECT DirectoryObject, POBJECT_HEADER current_obj; DPRINT("ObFindEntryDirectory(dir %x, name %S)\n",DirectoryObject, Name); - + if (Name[0]==0) { return(DirectoryObject); @@ -388,7 +388,7 @@ ObInit(VOID) /* create 'directory' object type */ ObDirectoryType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE)); - + ObDirectoryType->Tag = TAG('D', 'I', 'R', 'T'); ObDirectoryType->TotalObjects = 0; ObDirectoryType->TotalHandles = 0; @@ -413,7 +413,7 @@ ObInit(VOID) /* create 'type' object type*/ ObTypeObjectType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE)); - + ObTypeObjectType->Tag = TAG('T', 'y', 'p', 'T'); ObTypeObjectType->TotalObjects = 0; ObTypeObjectType->TotalHandles = 0; @@ -492,7 +492,7 @@ ObInit(VOID) /* Create 'symbolic link' object type */ ObInitSymbolicLinkImplementation(); - + /* FIXME: Hack Hack! */ ObSystemDeviceMap = ExAllocatePoolWithTag(NonPagedPool, sizeof(*ObSystemDeviceMap), TAG('O', 'b', 'D', 'm')); RtlZeroMemory(ObSystemDeviceMap, sizeof(*ObSystemDeviceMap)); diff --git a/reactos/ntoskrnl/ob/ntobj.c b/reactos/ntoskrnl/ob/ntobj.c index b6553f15f6b..77702b55eb7 100644 --- a/reactos/ntoskrnl/ob/ntobj.c +++ b/reactos/ntoskrnl/ob/ntobj.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ob/ntobj.c * PURPOSE: User mode interface to object manager - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -20,7 +20,7 @@ /********************************************************************** * NAME EXPORTED * NtSetInformationObject - * + * * DESCRIPTION * * ARGUMENTS @@ -37,7 +37,7 @@ NtSetInformationObject (IN HANDLE ObjectHandle, { PVOID Object; NTSTATUS Status; - + PAGED_CODE(); if (ObjectInformationClass != ObjectHandleInformation) @@ -90,7 +90,7 @@ NtQueryObject (IN HANDLE ObjectHandle, ULONG InfoLength; PVOID Object; NTSTATUS Status; - + PAGED_CODE(); Status = ObReferenceObjectByHandle (ObjectHandle, @@ -224,7 +224,7 @@ ObpSetPermanentObject (IN PVOID ObjectBody, IN BOOLEAN Permanent) ObjectHeader = BODY_TO_HEADER(ObjectBody); ObjectHeader->Permanent = Permanent; - + if (ObjectHeader->HandleCount == 0 && !Permanent && ObjectHeader->Parent != NULL) { /* Remove the object from the namespace */ @@ -270,7 +270,7 @@ NtMakeTemporaryObject(IN HANDLE ObjectHandle) { PVOID ObjectBody; NTSTATUS Status; - + PAGED_CODE(); Status = ObReferenceObjectByHandle(ObjectHandle, @@ -311,7 +311,7 @@ NtMakePermanentObject(IN HANDLE ObjectHandle) { PVOID ObjectBody; NTSTATUS Status; - + PAGED_CODE(); Status = ObReferenceObjectByHandle(ObjectHandle, diff --git a/reactos/ntoskrnl/ob/object.c b/reactos/ntoskrnl/ob/object.c index 9e1821650ed..e96d541891c 100644 --- a/reactos/ntoskrnl/ob/object.c +++ b/reactos/ntoskrnl/ob/object.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ob/object.c * PURPOSE: Implements generic object managment functions - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) * Skywing (skywing@valhallalegends.com) */ @@ -48,7 +48,7 @@ ObpCaptureObjectAttributes(IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, if(AccessMode != KernelMode) { RtlZeroMemory(&AttributesCopy, sizeof(AttributesCopy)); - + _SEH_TRY { ProbeForRead(ObjectAttributes, @@ -142,7 +142,7 @@ ObpCaptureObjectAttributes(IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, if(AttributesCopy.SecurityQualityOfService != NULL) { SECURITY_QUALITY_OF_SERVICE SafeQoS; - + RtlZeroMemory(&SafeQoS, sizeof(SafeQoS)); _SEH_TRY @@ -198,7 +198,7 @@ ObpCaptureObjectAttributes(IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, if(AccessMode != KernelMode) { RtlZeroMemory(&OriginalCopy, sizeof(OriginalCopy)); - + _SEH_TRY { /* probe the ObjectName structure and make a local stack copy of it */ @@ -397,7 +397,7 @@ ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes, UNICODE_STRING PathString; ULONG Attributes; PUNICODE_STRING ObjectName; - + PAGED_CODE(); DPRINT("ObFindObject(ObjectAttributes %x, ReturnedObject %x, " @@ -490,7 +490,7 @@ ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes, /* reparse the object path */ NextObject = NameSpaceRoot; current = PathString.Buffer; - + ObReferenceObjectByPointer(NextObject, DIRECTORY_TRAVERSE, NULL, @@ -536,7 +536,7 @@ ObQueryNameString (IN PVOID Object, POBJECT_HEADER ObjectHeader; ULONG LocalReturnLength; NTSTATUS Status; - + PAGED_CODE(); *ReturnLength = 0; @@ -667,7 +667,7 @@ ObCreateObject (IN KPROCESSOR_MODE ObjectAttributesAccessMode OPTIONAL, SECURITY_SUBJECT_CONTEXT SubjectContext; PAGED_CODE(); - + if(ObjectAttributesAccessMode == UserMode && ObjectAttributes != NULL) { Status = STATUS_SUCCESS; @@ -682,7 +682,7 @@ ObCreateObject (IN KPROCESSOR_MODE ObjectAttributesAccessMode OPTIONAL, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -880,14 +880,14 @@ ObReferenceObjectByPointer(IN PVOID Object, IN KPROCESSOR_MODE AccessMode) { POBJECT_HEADER Header; - + /* NOTE: should be possible to reference an object above APC_LEVEL! */ DPRINT("ObReferenceObjectByPointer(Object %x, ObjectType %x)\n", Object,ObjectType); - + Header = BODY_TO_HEADER(Object); - + if (ObjectType != NULL && Header->ObjectType != ObjectType) { DPRINT("Failed %x (type was %x %S) should be %x %S\n", @@ -910,7 +910,7 @@ ObReferenceObjectByPointer(IN PVOID Object, Object, Header->RefCount, PsThreadType); DPRINT("eip %x\n", ((PULONG)&Object)[-1]); } - + if (Header->RefCount == 0 && !Header->Permanent) { if (Header->ObjectType == PsProcessType) @@ -928,7 +928,7 @@ ObReferenceObjectByPointer(IN PVOID Object, { KEBUGCHECK(0); } - + return(STATUS_SUCCESS); } @@ -946,11 +946,11 @@ ObOpenObjectByPointer(IN POBJECT Object, OUT PHANDLE Handle) { NTSTATUS Status; - + PAGED_CODE(); - + DPRINT("ObOpenObjectByPointer()\n"); - + Status = ObReferenceObjectByPointer(Object, 0, ObjectType, @@ -959,15 +959,15 @@ ObOpenObjectByPointer(IN POBJECT Object, { return Status; } - + Status = ObCreateHandle(PsGetCurrentProcess(), Object, DesiredAccess, (BOOLEAN)(HandleAttributes & OBJ_INHERIT), Handle); - + ObDereferenceObject(Object); - + return STATUS_SUCCESS; } @@ -1031,7 +1031,7 @@ ObpDeleteObjectDpcLevel(IN POBJECT_HEADER ObjectHeader, if (ObjectHeader->RefCount < 0) { CPRINT("Object %p/%p has invalid reference count (%d)\n", - ObjectHeader, HEADER_TO_BODY(ObjectHeader), + ObjectHeader, HEADER_TO_BODY(ObjectHeader), ObjectHeader->RefCount); KEBUGCHECK(0); } @@ -1039,23 +1039,23 @@ ObpDeleteObjectDpcLevel(IN POBJECT_HEADER ObjectHeader, if (ObjectHeader->HandleCount < 0) { CPRINT("Object %p/%p has invalid handle count (%d)\n", - ObjectHeader, HEADER_TO_BODY(ObjectHeader), + ObjectHeader, HEADER_TO_BODY(ObjectHeader), ObjectHeader->HandleCount); KEBUGCHECK(0); } #endif - + switch (KeGetCurrentIrql ()) { case PASSIVE_LEVEL: return ObpDeleteObject (ObjectHeader); - + case APC_LEVEL: case DISPATCH_LEVEL: { PRETENTION_CHECK_PARAMS Params; - + /* We use must succeed pool here because if the allocation fails then we leak memory. @@ -1072,7 +1072,7 @@ ObpDeleteObjectDpcLevel(IN POBJECT_HEADER ObjectHeader, CriticalWorkQueue); } return STATUS_PENDING; - + default: DPRINT("ObpDeleteObjectDpcLevel called at unsupported " "IRQL %u!\n", KeGetCurrentIrql()); @@ -1146,7 +1146,7 @@ ObfDereferenceObject(IN PVOID Object) Header = BODY_TO_HEADER(Object); Permanent = Header->Permanent; - /* + /* Drop our reference and get the new count so we can tell if this was the last reference. */ @@ -1164,7 +1164,7 @@ ObfDereferenceObject(IN PVOID Object) VOID FASTCALL -ObInitializeFastReference(IN PEX_FAST_REF FastRef, +ObInitializeFastReference(IN PEX_FAST_REF FastRef, PVOID Object) { /* FIXME: Fast Referencing is Unimplemented */ @@ -1177,10 +1177,10 @@ FASTCALL ObFastReferenceObject(IN PEX_FAST_REF FastRef) { /* FIXME: Fast Referencing is Unimplemented */ - + /* Do a normal Reference */ ObReferenceObject(FastRef->Object); - + /* Return the Object */ return FastRef->Object; } @@ -1191,7 +1191,7 @@ ObFastDereferenceObject(IN PEX_FAST_REF FastRef, PVOID Object) { /* FIXME: Fast Referencing is Unimplemented */ - + /* Do a normal Dereference */ ObDereferenceObject(FastRef->Object); } @@ -1202,10 +1202,10 @@ ObFastReplaceObject(IN PEX_FAST_REF FastRef, PVOID Object) { PVOID OldObject = FastRef->Object; - + /* FIXME: Fast Referencing is Unimplemented */ FastRef->Object = Object; - + /* Do a normal Dereference */ ObDereferenceObject(OldObject); @@ -1232,7 +1232,7 @@ ULONG STDCALL ObGetObjectPointerCount(PVOID Object) { POBJECT_HEADER Header; - + PAGED_CODE(); ASSERT(Object); @@ -1259,7 +1259,7 @@ ULONG ObGetObjectHandleCount(PVOID Object) { POBJECT_HEADER Header; - + PAGED_CODE(); ASSERT(Object); diff --git a/reactos/ntoskrnl/ob/sdcache.c b/reactos/ntoskrnl/ob/sdcache.c index 9cfc5a4c843..c7c300d43b8 100644 --- a/reactos/ntoskrnl/ob/sdcache.c +++ b/reactos/ntoskrnl/ob/sdcache.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ob/sdcache.c * PURPOSE: No purpose listed. - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ diff --git a/reactos/ntoskrnl/ob/security.c b/reactos/ntoskrnl/ob/security.c index 0b72810f48f..040f3072f54 100644 --- a/reactos/ntoskrnl/ob/security.c +++ b/reactos/ntoskrnl/ob/security.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/ob/security.c * PURPOSE: Security manager - * + * * PROGRAMERS: No programmer listed. */ @@ -27,7 +27,7 @@ ObAssignSecurity(IN PACCESS_STATE AccessState, { PSECURITY_DESCRIPTOR NewDescriptor; NTSTATUS Status; - + PAGED_CODE(); /* Build the new security descriptor */ @@ -75,7 +75,7 @@ ObGetObjectSecurity(IN PVOID Object, POBJECT_HEADER Header; ULONG Length; NTSTATUS Status; - + PAGED_CODE(); Header = BODY_TO_HEADER(Object); @@ -134,7 +134,7 @@ ObReleaseObjectSecurity(IN PSECURITY_DESCRIPTOR SecurityDescriptor, IN BOOLEAN MemoryAllocated) { PAGED_CODE(); - + if (SecurityDescriptor == NULL) return; @@ -162,7 +162,7 @@ NtQuerySecurityObject(IN HANDLE Handle, POBJECT_HEADER Header; PVOID Object; NTSTATUS Status; - + PAGED_CODE(); DPRINT("NtQuerySecurityObject() called\n"); @@ -234,7 +234,7 @@ NtSetSecurityObject(IN HANDLE Handle, ULONG Control = 0; ULONG_PTR Current; NTSTATUS Status; - + PAGED_CODE(); DPRINT("NtSetSecurityObject() called\n"); @@ -277,7 +277,7 @@ NtSetSecurityObject(IN HANDLE Handle, if (SecurityDescriptor->Owner != NULL) { if( SecurityDescriptor->Control & SE_SELF_RELATIVE ) - Owner = (PSID)((ULONG_PTR)SecurityDescriptor->Owner + + Owner = (PSID)((ULONG_PTR)SecurityDescriptor->Owner + (ULONG_PTR)SecurityDescriptor); else Owner = (PSID)SecurityDescriptor->Owner; @@ -301,7 +301,7 @@ NtSetSecurityObject(IN HANDLE Handle, if (SecurityDescriptor->Group != NULL) { if( SecurityDescriptor->Control & SE_SELF_RELATIVE ) - Group = (PSID)((ULONG_PTR)SecurityDescriptor->Group + + Group = (PSID)((ULONG_PTR)SecurityDescriptor->Group + (ULONG_PTR)SecurityDescriptor); else Group = (PSID)SecurityDescriptor->Group; @@ -326,7 +326,7 @@ NtSetSecurityObject(IN HANDLE Handle, (SecurityDescriptor->Dacl != NULL)) { if( SecurityDescriptor->Control & SE_SELF_RELATIVE ) - Dacl = (PACL)((ULONG_PTR)SecurityDescriptor->Dacl + + Dacl = (PACL)((ULONG_PTR)SecurityDescriptor->Dacl + (ULONG_PTR)SecurityDescriptor); else Dacl = (PACL)SecurityDescriptor->Dacl; @@ -353,7 +353,7 @@ NtSetSecurityObject(IN HANDLE Handle, (SecurityDescriptor->Sacl != NULL)) { if( SecurityDescriptor->Control & SE_SELF_RELATIVE ) - Sacl = (PACL)((ULONG_PTR)SecurityDescriptor->Sacl + + Sacl = (PACL)((ULONG_PTR)SecurityDescriptor->Sacl + (ULONG_PTR)SecurityDescriptor); else Sacl = (PACL)SecurityDescriptor->Sacl; diff --git a/reactos/ntoskrnl/ob/symlink.c b/reactos/ntoskrnl/ob/symlink.c index bffcebabdef..9872e5b3332 100644 --- a/reactos/ntoskrnl/ob/symlink.c +++ b/reactos/ntoskrnl/ob/symlink.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ob/symlink.c * PURPOSE: Implements symbolic links - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -213,7 +213,7 @@ NtCreateSymbolicLinkObject(OUT PHANDLE LinkHandle, NTSTATUS Status = STATUS_SUCCESS; PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); if(PreviousMode != KernelMode) @@ -235,7 +235,7 @@ NtCreateSymbolicLinkObject(OUT PHANDLE LinkHandle, return Status; } } - + Status = RtlCaptureUnicodeString(&CapturedLinkTarget, PreviousMode, PagedPool, @@ -298,7 +298,7 @@ NtCreateSymbolicLinkObject(OUT PHANDLE LinkHandle, } ObDereferenceObject(SymbolicLink); } - + RtlReleaseCapturedUnicodeString(&CapturedLinkTarget, PreviousMode, FALSE); @@ -330,9 +330,9 @@ NtOpenSymbolicLinkObject(OUT PHANDLE LinkHandle, NTSTATUS Status = STATUS_SUCCESS; PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); - + if(PreviousMode != KernelMode) { _SEH_TRY @@ -346,7 +346,7 @@ NtOpenSymbolicLinkObject(OUT PHANDLE LinkHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -375,7 +375,7 @@ NtOpenSymbolicLinkObject(OUT PHANDLE LinkHandle, } _SEH_END; } - + return Status; } @@ -402,11 +402,11 @@ NtQuerySymbolicLinkObject(IN HANDLE LinkHandle, PSYMLINK_OBJECT SymlinkObject; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); - + if(PreviousMode != KernelMode) { _SEH_TRY @@ -432,7 +432,7 @@ NtQuerySymbolicLinkObject(IN HANDLE LinkHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -452,7 +452,7 @@ NtQuerySymbolicLinkObject(IN HANDLE LinkHandle, if (NT_SUCCESS(Status)) { ULONG LengthRequired = SymlinkObject->TargetName.Length + sizeof(WCHAR); - + _SEH_TRY { if(SafeLinkTarget.MaximumLength >= LengthRequired) @@ -470,7 +470,7 @@ NtQuerySymbolicLinkObject(IN HANDLE LinkHandle, { Status = STATUS_BUFFER_TOO_SMALL; } - + if(ResultLength != NULL) { *ResultLength = LengthRequired; diff --git a/reactos/ntoskrnl/ob/wait.c b/reactos/ntoskrnl/ob/wait.c index e74275368ab..8c832e1e53b 100644 --- a/reactos/ntoskrnl/ob/wait.c +++ b/reactos/ntoskrnl/ob/wait.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ob/wait.c * PURPOSE: Handles Waiting on Objects - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) - Created file * David Welch (welch@mcmail.com) */ @@ -54,7 +54,7 @@ NtWaitForMultipleObjects(IN ULONG ObjectCount, what objects we referenced in case dereferencing pointers suddenly fails */ RtlCopyMemory(SafeObjectsArray, ObjectsArray, ObjectCount * sizeof(ObjectsArray[0])); ObjectsArray = SafeObjectsArray; - + if(TimeOut != NULL) { ProbeForRead(TimeOut, @@ -70,7 +70,7 @@ NtWaitForMultipleObjects(IN ULONG ObjectCount, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -90,7 +90,7 @@ NtWaitForMultipleObjects(IN ULONG ObjectCount, { if (NT_SUCCESS(Status)) { - DPRINT1("Waiting for object type '%wZ' is not supported\n", + DPRINT1("Waiting for object type '%wZ' is not supported\n", &BODY_TO_HEADER(ObjectPtrArray[i])->ObjectType->TypeName); Status = STATUS_HANDLE_NOT_WAITABLE; i++; @@ -141,7 +141,7 @@ NtWaitForSingleObject(IN HANDLE ObjectHandle, ObjectHandle,Alertable,TimeOut); PreviousMode = ExGetPreviousMode(); - + if(TimeOut != NULL && PreviousMode != KernelMode) { _SEH_TRY @@ -158,7 +158,7 @@ NtWaitForSingleObject(IN HANDLE ObjectHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -177,7 +177,7 @@ NtWaitForSingleObject(IN HANDLE ObjectHandle, } if (!KiIsObjectWaitable(ObjectPtr)) { - DPRINT1("Waiting for object type '%wZ' is not supported\n", + DPRINT1("Waiting for object type '%wZ' is not supported\n", &BODY_TO_HEADER(ObjectPtr)->ObjectType->TypeName); Status = STATUS_HANDLE_NOT_WAITABLE; } @@ -210,7 +210,7 @@ NtSignalAndWaitForSingleObject(IN HANDLE ObjectHandleToSignal, NTSTATUS Status = STATUS_SUCCESS; PreviousMode = ExGetPreviousMode(); - + if(TimeOut != NULL && PreviousMode != KernelMode) { _SEH_TRY @@ -227,13 +227,13 @@ NtSignalAndWaitForSingleObject(IN HANDLE ObjectHandleToSignal, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; } } - + Status = ObReferenceObjectByHandle(ObjectHandleToSignal, 0, NULL, diff --git a/reactos/ntoskrnl/po/power.c b/reactos/ntoskrnl/po/power.c index 2dc711b7071..4d3857db70d 100644 --- a/reactos/ntoskrnl/po/power.c +++ b/reactos/ntoskrnl/po/power.c @@ -1,10 +1,10 @@ /* $Id$ - * + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/po/power.c * PURPOSE: Power Manager - * + * * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net) */ @@ -64,7 +64,7 @@ NTSTATUS STDCALL PoRequestPowerIrp( IN PDEVICE_OBJECT DeviceObject, - IN UCHAR MinorFunction, + IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PREQUEST_POWER_COMPLETE CompletionFunction, IN PVOID Context, @@ -91,7 +91,7 @@ PoSetPowerState( IN POWER_STATE State) { POWER_STATE ps; - + ASSERT_IRQL(DISPATCH_LEVEL); ps.SystemState = PowerSystemWorking; // Fully on @@ -133,7 +133,7 @@ PoUnregisterSystemState( NTSTATUS PopSetSystemPowerState( SYSTEM_POWER_STATE PowerState) -{ +{ IO_STATUS_BLOCK IoStatusBlock; PDEVICE_OBJECT DeviceObject; PIO_STACK_LOCATION IrpSp; @@ -141,7 +141,7 @@ PopSetSystemPowerState( NTSTATUS Status; KEVENT Event; PIRP Irp; - + if (!PopAcpiPresent) return STATUS_NOT_IMPLEMENTED; Status = IopGetSystemPowerDeviceObject(&DeviceObject); @@ -191,9 +191,9 @@ PopSetSystemPowerState( return Status; } -VOID +VOID INIT_FUNCTION -PoInit(PLOADER_PARAMETER_BLOCK LoaderBlock, +PoInit(PLOADER_PARAMETER_BLOCK LoaderBlock, BOOLEAN ForceAcpiDisable) { if (ForceAcpiDisable) @@ -226,8 +226,8 @@ NtInitiatePowerAction ( /* * @unimplemented */ -NTSTATUS -STDCALL +NTSTATUS +STDCALL NtPowerInformation( IN POWER_INFORMATION_LEVEL PowerInformationLevel, IN PVOID InputBuffer OPTIONAL, @@ -237,7 +237,7 @@ NtPowerInformation( ) { NTSTATUS Status; - + PAGED_CODE(); DPRINT("NtPowerInformation(PowerInformationLevel 0x%x, InputBuffer 0x%x, " @@ -283,7 +283,7 @@ PoQueueShutdownWorkItem( ) { PAGED_CODE(); - + DPRINT1("PoQueueShutdownWorkItem(%p)\n", WorkItem); return STATUS_NOT_IMPLEMENTED; diff --git a/reactos/ntoskrnl/ps/cid.c b/reactos/ntoskrnl/ps/cid.c index 7a6ec8169e2..f3f919628fa 100644 --- a/reactos/ntoskrnl/ps/cid.c +++ b/reactos/ntoskrnl/ps/cid.c @@ -38,9 +38,9 @@ PsCreateCidHandle(PVOID Object, POBJECT_TYPE ObjectType, PHANDLE Handle) { HANDLE_TABLE_ENTRY NewEntry; LONG ExHandle; - + PAGED_CODE(); - + NewEntry.u1.Object = Object; if(ObjectType == PsThreadType) NewEntry.u2.GrantedAccess = CID_FLAG_THREAD; @@ -51,7 +51,7 @@ PsCreateCidHandle(PVOID Object, POBJECT_TYPE ObjectType, PHANDLE Handle) DPRINT1("Can't create CID handles for %wZ objects\n", &ObjectType->TypeName); KEBUGCHECK(0); } - + ExHandle = ExCreateHandle(PspCidTable, &NewEntry); if(ExHandle != EX_INVALID_HANDLE) @@ -59,7 +59,7 @@ PsCreateCidHandle(PVOID Object, POBJECT_TYPE ObjectType, PHANDLE Handle) *Handle = EX_HANDLE_TO_HANDLE(ExHandle); return STATUS_SUCCESS; } - + return STATUS_UNSUCCESSFUL; } @@ -68,7 +68,7 @@ PsDeleteCidHandle(HANDLE CidHandle, POBJECT_TYPE ObjectType) { PHANDLE_TABLE_ENTRY Entry; LONG ExHandle = HANDLE_TO_EX_HANDLE(CidHandle); - + PAGED_CODE(); KeEnterCriticalRegion(); @@ -102,11 +102,11 @@ PHANDLE_TABLE_ENTRY PsLookupCidHandle(HANDLE CidHandle, POBJECT_TYPE ObjectType, PVOID *Object) { PHANDLE_TABLE_ENTRY Entry; - + PAGED_CODE(); KeEnterCriticalRegion(); - + Entry = ExMapHandleToPointer(PspCidTable, HANDLE_TO_EX_HANDLE(CidHandle)); if(Entry != NULL) @@ -125,9 +125,9 @@ PsLookupCidHandle(HANDLE CidHandle, POBJECT_TYPE ObjectType, PVOID *Object) Entry); } } - + KeLeaveCriticalRegion(); - + return NULL; } diff --git a/reactos/ntoskrnl/ps/debug.c b/reactos/ntoskrnl/ps/debug.c index 35a6db6ea9d..bd72696f362 100644 --- a/reactos/ntoskrnl/ps/debug.c +++ b/reactos/ntoskrnl/ps/debug.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ps/debug.c * PURPOSE: Thread managment - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) * Phillip Susi */ @@ -31,7 +31,7 @@ typedef struct _GET_SET_CTX_CONTEXT { * FUNCTION: This routine is called by an APC sent by NtGetContextThread to * copy the context of a thread into a buffer. */ -VOID +VOID STDCALL PspGetOrSetContextKernelRoutine(PKAPC Apc, PKNORMAL_ROUTINE* NormalRoutine, @@ -42,7 +42,7 @@ PspGetOrSetContextKernelRoutine(PKAPC Apc, PGET_SET_CTX_CONTEXT GetSetContext; PKEVENT Event; PCONTEXT Context; - + /* Get the Context Structure */ GetSetContext = CONTAINING_RECORD(Apc, GET_SET_CTX_CONTEXT, Apc); Context = &GetSetContext->Context; @@ -50,21 +50,21 @@ PspGetOrSetContextKernelRoutine(PKAPC Apc, /* Check if it's a set or get */ if (SystemArgument1) { - - /* Get the Context */ + + /* Get the Context */ KeTrapFrameToContext(KeGetCurrentThread()->TrapFrame, Context); - + } else { - + /* Set the Context */ KeContextToTrapFrame(Context, KeGetCurrentThread()->TrapFrame); } - + /* Notify the Native API that we are done */ KeSetEvent(Event, IO_NO_INCREMENT, FALSE); } -NTSTATUS +NTSTATUS STDCALL NtGetContextThread(IN HANDLE ThreadHandle, OUT PCONTEXT ThreadContext) @@ -73,26 +73,26 @@ NtGetContextThread(IN HANDLE ThreadHandle, KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); GET_SET_CTX_CONTEXT GetSetContext; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); /* Check the buffer to be OK */ if(PreviousMode != KernelMode) { - + _SEH_TRY { - + ProbeForWrite(ThreadContext, sizeof(CONTEXT), sizeof(ULONG)); } _SEH_HANDLE { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; if(!NT_SUCCESS(Status)) return Status; } - + /* Get the Thread Object */ Status = ObReferenceObjectByHandle(ThreadHandle, THREAD_GET_CONTEXT, @@ -100,26 +100,26 @@ NtGetContextThread(IN HANDLE ThreadHandle, PreviousMode, (PVOID*)&Thread, NULL); - + /* Check success */ if(NT_SUCCESS(Status)) { - + /* Check if we're running in the same thread */ if(Thread == PsGetCurrentThread()) { - + /* * I don't know if trying to get your own context makes much * sense but we can handle it more efficently. */ KeTrapFrameToContext(Thread->Tcb.TrapFrame, &GetSetContext.Context); - + } else { - + /* Use an APC... Initialize the Event */ KeInitializeEvent(&GetSetContext.Event, NotificationEvent, FALSE); - + /* Initialize the APC */ KeInitializeApc(&GetSetContext.Apc, &Thread->Tcb, @@ -129,17 +129,17 @@ NtGetContextThread(IN HANDLE ThreadHandle, NULL, KernelMode, NULL); - + /* Queue it as a Get APC */ if (!KeInsertQueueApc(&GetSetContext.Apc, (PVOID)1, NULL, IO_NO_INCREMENT)) { - + Status = STATUS_THREAD_IS_TERMINATING; - + } else { - + /* Wait for the APC to complete */ Status = KeWaitForSingleObject(&GetSetContext.Event, 0, @@ -148,30 +148,30 @@ NtGetContextThread(IN HANDLE ThreadHandle, NULL); } } - + /* Dereference the thread */ ObDereferenceObject(Thread); - + /* Check for success and return the Context */ if(NT_SUCCESS(Status)) { - + _SEH_TRY { - + *ThreadContext = GetSetContext.Context; - + } _SEH_HANDLE { - + Status = _SEH_GetExceptionCode(); - - } _SEH_END; + + } _SEH_END; } } - - /* Return status */ + + /* Return status */ return Status; } -NTSTATUS +NTSTATUS STDCALL NtSetContextThread(IN HANDLE ThreadHandle, IN PCONTEXT ThreadContext) @@ -180,26 +180,26 @@ NtSetContextThread(IN HANDLE ThreadHandle, GET_SET_CTX_CONTEXT GetSetContext; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + /* Check the buffer to be OK */ if(PreviousMode != KernelMode) { - + _SEH_TRY { - + ProbeForRead(ThreadContext, sizeof(CONTEXT), sizeof(ULONG)); - + GetSetContext.Context = *ThreadContext; ThreadContext = &GetSetContext.Context; - + } _SEH_HANDLE { - + Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) return Status; } @@ -210,26 +210,26 @@ NtSetContextThread(IN HANDLE ThreadHandle, PreviousMode, (PVOID*)&Thread, NULL); - + /* Check success */ if(NT_SUCCESS(Status)) { - + /* Check if we're running in the same thread */ if(Thread == PsGetCurrentThread()) { - + /* * I don't know if trying to get your own context makes much * sense but we can handle it more efficently. */ KeContextToTrapFrame(&GetSetContext.Context, Thread->Tcb.TrapFrame); - + } else { - + /* Use an APC... Initialize the Event */ KeInitializeEvent(&GetSetContext.Event, NotificationEvent, FALSE); - + /* Initialize the APC */ KeInitializeApc(&GetSetContext.Apc, &Thread->Tcb, @@ -239,17 +239,17 @@ NtSetContextThread(IN HANDLE ThreadHandle, NULL, KernelMode, NULL); - + /* Queue it as a Get APC */ if (!KeInsertQueueApc(&GetSetContext.Apc, NULL, NULL, IO_NO_INCREMENT)) { - + Status = STATUS_THREAD_IS_TERMINATING; - + } else { - + /* Wait for the APC to complete */ Status = KeWaitForSingleObject(&GetSetContext.Event, 0, @@ -258,16 +258,16 @@ NtSetContextThread(IN HANDLE ThreadHandle, NULL); } } - + /* Dereference the thread */ ObDereferenceObject(Thread); } - - /* Return status */ + + /* Return status */ return Status; } -VOID +VOID STDCALL PspDumpThreads(BOOLEAN IncludeSystem) { @@ -275,14 +275,14 @@ PspDumpThreads(BOOLEAN IncludeSystem) PEPROCESS Process; PETHREAD Thread; ULONG nThreads = 0; - + /* Loop all Active Processes */ CurrentProcess = PsActiveProcessHead.Flink; while(CurrentProcess != &PsActiveProcessHead) { /* Get the process */ Process = CONTAINING_RECORD(CurrentProcess, EPROCESS, ActiveProcessLinks); - + /* Skip the Initial Process if requested */ if((Process != PsInitialSystemProcess) || (Process == PsInitialSystemProcess && IncludeSystem)) @@ -291,11 +291,11 @@ PspDumpThreads(BOOLEAN IncludeSystem) CurrentThread = Process->ThreadListHead.Flink; while(CurrentThread != &Process->ThreadListHead) { - + /* Get teh Thread */ Thread = CONTAINING_RECORD(CurrentThread, ETHREAD, ThreadListEntry); nThreads++; - + /* Print the Info */ DbgPrint("State %d Affinity %08x Priority %d PID.TID %d.%d Name %.8s Stack: \n", Thread->Tcb.State, @@ -304,7 +304,7 @@ PspDumpThreads(BOOLEAN IncludeSystem) Thread->Cid.UniqueProcess, Thread->Cid.UniqueThread, Thread->ThreadsProcess->ImageFileName); - + /* Make sure it's not running */ if(Thread->Tcb.State == Ready || Thread->Tcb.State == Standby || @@ -313,10 +313,10 @@ PspDumpThreads(BOOLEAN IncludeSystem) ULONG i = 0; PULONG Esp = (PULONG)Thread->Tcb.KernelStack; PULONG Ebp = (PULONG)Esp[4]; - + /* Print EBP */ DbgPrint("Ebp 0x%.8X\n", Ebp); - + /* Walk it */ while(Ebp != 0 && Ebp >= (PULONG)Thread->Tcb.StackLimit) { @@ -325,16 +325,16 @@ PspDumpThreads(BOOLEAN IncludeSystem) Ebp = (PULONG)Ebp[0]; i++; } - + /* Print a new line if there's nothing */ if((i % 8) != 0) DbgPrint("\n"); } } - + /* Move to the next Thread */ CurrentThread = CurrentThread->Flink; } - + /* Move to the next Process */ CurrentProcess = CurrentProcess->Flink; } diff --git a/reactos/ntoskrnl/ps/i386/continue.c b/reactos/ntoskrnl/ps/i386/continue.c index 39064fd139a..4c8bd99da67 100644 --- a/reactos/ntoskrnl/ps/i386/continue.c +++ b/reactos/ntoskrnl/ps/i386/continue.c @@ -28,7 +28,7 @@ NtContinue ( { PKTHREAD Thread = KeGetCurrentThread(); PKTRAP_FRAME TrapFrame = Thread->TrapFrame; - PKTRAP_FRAME PrevTrapFrame = (PKTRAP_FRAME)TrapFrame->Edx; + PKTRAP_FRAME PrevTrapFrame = (PKTRAP_FRAME)TrapFrame->Edx; PFX_SAVE_AREA FxSaveArea; KIRQL oldIrql; diff --git a/reactos/ntoskrnl/ps/idle.c b/reactos/ntoskrnl/ps/idle.c index 62b846f75da..60c60bc8722 100644 --- a/reactos/ntoskrnl/ps/idle.c +++ b/reactos/ntoskrnl/ps/idle.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ps/idle.c * PURPOSE: Using idle time - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) * David Welch (welch@cwcom.net) */ @@ -19,7 +19,7 @@ extern PEPROCESS PsIdleProcess; /* FUNCTIONS *****************************************************************/ - + /** System idle thread procedure * */ @@ -29,7 +29,7 @@ PsIdleThreadMain(PVOID Context) KIRQL oldlvl; PKPRCB Prcb = KeGetCurrentPrcb(); - + for(;;) { if (Prcb->DpcData[0].DpcQueueDepth > 0) @@ -45,7 +45,7 @@ PsIdleThreadMain(PVOID Context) } } -/* +/* * HACK-O-RAMA * Antique vestigial code left alive for the sole purpose of First/Idle Thread * creation until I can merge my fix for properly creating them. @@ -63,8 +63,8 @@ PsInitializeIdleOrFirstThread(PEPROCESS Process, Thread = ExAllocatePool(NonPagedPool, sizeof(ETHREAD)); RtlZeroMemory(Thread, sizeof(ETHREAD)); - Thread->ThreadsProcess = Process; - if (First) + Thread->ThreadsProcess = Process; + if (First) { KernelStack = (PVOID)init_stack; } @@ -72,8 +72,8 @@ PsInitializeIdleOrFirstThread(PEPROCESS Process, { KernelStack = MmCreateKernelStack(FALSE); } - KeInitializeThread(&Process->Pcb, - &Thread->Tcb, + KeInitializeThread(&Process->Pcb, + &Thread->Tcb, PspSystemThreadStartup, StartRoutine, NULL, @@ -86,12 +86,12 @@ PsInitializeIdleOrFirstThread(PEPROCESS Process, return STATUS_SUCCESS; } -/* +/* * HACK-O-RAMA * Antique vestigial code left alive for the sole purpose of First/Idle Thread * creation until I can merge my fix for properly creating them. */ -VOID +VOID INIT_FUNCTION PsInitIdleThread(VOID) { diff --git a/reactos/ntoskrnl/ps/kill.c b/reactos/ntoskrnl/ps/kill.c index 6efe4fbb27e..9306a6b2de6 100644 --- a/reactos/ntoskrnl/ps/kill.c +++ b/reactos/ntoskrnl/ps/kill.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ps/kill.c * PURPOSE: Thread Termination and Reaping - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) * David Welch (welch@cwcom.net) */ @@ -15,7 +15,7 @@ #include /* GLOBALS *******************************************************************/ - + #define TAG_TERMINATE_APC TAG('T', 'A', 'P', 'C') PETHREAD PspReaperList = NULL; @@ -32,48 +32,48 @@ PspReapRoutine(PVOID Context) { KIRQL OldIrql; PETHREAD Thread, NewThread; - + /* Acquire lock */ DPRINT("Evil reaper running!!\n"); OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* Get the first Thread Entry */ Thread = PspReaperList; PspReaperList = NULL; DPRINT("PspReaperList: %x\n", Thread); - + /* Check to see if the list is empty */ do { - + /* Unlock the Dispatcher */ KeReleaseDispatcherDatabaseLock(OldIrql); - + /* Is there a thread on the list? */ while (Thread) { - + /* Get the next Thread */ DPRINT("Thread: %x\n", Thread); DPRINT("Thread: %x\n", Thread->ReaperLink); NewThread = Thread->ReaperLink; - + /* Remove reference to current thread */ ObDereferenceObject(Thread); - + /* Move to next Thread */ Thread = NewThread; } - + /* No more linked threads... Reacquire the Lock */ OldIrql = KeAcquireDispatcherDatabaseLock(); - + /* Now try to get a new thread from the list */ Thread = PspReaperList; PspReaperList = NULL; DPRINT("PspReaperList: %x\n", Thread); - + /* Loop again if there is a new thread */ } while (Thread); - + PspReaping = FALSE; DPRINT("Done reaping\n"); KeReleaseDispatcherDatabaseLock(OldIrql); @@ -85,17 +85,17 @@ PspKillMostProcesses(VOID) { PLIST_ENTRY current_entry; PEPROCESS current; - + /* Acquire the Active Process Lock */ - ExAcquireFastMutex(&PspActiveProcessMutex); - + ExAcquireFastMutex(&PspActiveProcessMutex); + /* Loop all processes on the list */ current_entry = PsActiveProcessHead.Flink; while (current_entry != &PsActiveProcessHead) { current = CONTAINING_RECORD(current_entry, EPROCESS, ActiveProcessLinks); current_entry = current_entry->Flink; - + if (current->UniqueProcessId != PsInitialSystemProcess->UniqueProcessId && current->UniqueProcessId != PsGetCurrentProcessId()) { @@ -103,7 +103,7 @@ PspKillMostProcesses(VOID) PspTerminateProcessThreads(current, STATUS_SUCCESS); } } - + /* Release the lock */ ExReleaseFastMutex(&PspActiveProcessMutex); } @@ -115,24 +115,24 @@ PspTerminateProcessThreads(PEPROCESS Process, { PLIST_ENTRY CurrentEntry; PETHREAD Thread, CurrentThread = PsGetCurrentThread(); - + CurrentEntry = Process->ThreadListHead.Flink; while (CurrentEntry != &Process->ThreadListHead) { - + /* Get the Current Thread */ Thread = CONTAINING_RECORD(CurrentEntry, ETHREAD, ThreadListEntry); - + /* Move to the Next Thread */ CurrentEntry = CurrentEntry->Flink; - + /* Make sure it's not the one we're in */ if (Thread != CurrentThread) { - + /* Make sure it didn't already terminate */ if (!Thread->Terminated) { Thread->Terminated = TRUE; - + /* Terminate it by APC */ PspTerminateThreadByPointer(Thread, ExitStatus); } @@ -140,8 +140,8 @@ PspTerminateProcessThreads(PEPROCESS Process, } } -VOID -STDCALL +VOID +STDCALL PspDeleteProcess(PVOID ObjectBody) { PEPROCESS Process = (PEPROCESS)ObjectBody; @@ -152,27 +152,27 @@ PspDeleteProcess(PVOID ObjectBody) ExAcquireFastMutex(&PspActiveProcessMutex); RemoveEntryList(&Process->ActiveProcessLinks); ExReleaseFastMutex(&PspActiveProcessMutex); - - /* Delete the CID Handle */ + + /* Delete the CID Handle */ if(Process->UniqueProcessId != NULL) { - + PsDeleteCidHandle(Process->UniqueProcessId, PsProcessType); } - + /* KDB hook */ KDB_DELETEPROCESS_HOOK(Process); - + /* Dereference the Token */ SeDeassignPrimaryToken(Process); - + /* Release Memory Information */ MmReleaseMmInfo(Process); - + /* Delete the W32PROCESS structure if there's one associated */ if(Process->Win32Process != NULL) ExFreePool(Process->Win32Process); } -VOID +VOID STDCALL PspDeleteThread(PVOID ObjectBody) { @@ -186,20 +186,20 @@ PspDeleteThread(PVOID ObjectBody) /* Delete the CID Handle */ if(Thread->Cid.UniqueThread != NULL) { - + PsDeleteCidHandle(Thread->Cid.UniqueThread, PsThreadType); } - + /* Free the W32THREAD structure if present */ if(Thread->Tcb.Win32Thread != NULL) ExFreePool (Thread->Tcb.Win32Thread); /* Release the Kernel Stack */ MmDeleteKernelStack((PVOID)Thread->Tcb.StackLimit, FALSE); - + /* Dereference the Process */ ObDereferenceObject(Process); } - + /* * FUNCTION: Terminates the current thread * See "Windows Internals" - Chapter 13, Page 50-53 @@ -219,39 +219,39 @@ PspExitThread(NTSTATUS ExitStatus) /* Get the Current Thread and Process */ CurrentThread = PsGetCurrentThread(); CurrentProcess = CurrentThread->ThreadsProcess; - + /* Set the Exit Status and Exit Time */ CurrentThread->ExitStatus = ExitStatus; KeQuerySystemTime(&CurrentThread->ExitTime); /* Can't terminate a thread if it attached another process */ if (KeIsAttachedProcess()) { - + KEBUGCHECKEX(INVALID_PROCESS_ATTACH_ATTEMPT, (ULONG) CurrentProcess, (ULONG) CurrentThread->Tcb.ApcState.Process, (ULONG) CurrentThread->Tcb.ApcStateIndex, (ULONG) CurrentThread); } - + /* Lower to Passive Level */ KeLowerIrql(PASSIVE_LEVEL); /* Lock the Process before we modify its thread entries */ PsLockProcess(CurrentProcess, FALSE); - + /* wake up the thread so we don't deadlock on PsLockProcess */ KeForceResumeThread(&CurrentThread->Tcb); - + /* Run Thread Notify Routines before we desintegrate the thread */ PspRunCreateThreadNotifyRoutines(CurrentThread, FALSE); /* Remove the thread from the thread list of its process */ RemoveEntryList(&CurrentThread->ThreadListEntry); Last = IsListEmpty(&CurrentProcess->ThreadListHead); - + /* Set the last Thread Exit Status */ CurrentProcess->LastThreadExitStatus = ExitStatus; - + if (Last) { /* Save the Exit Time if not already done by NtTerminateProcess. This @@ -259,37 +259,37 @@ PspExitThread(NTSTATUS ExitStatus) terminating the process. */ CurrentProcess->ExitTime = CurrentThread->ExitTime; } - + /* Check if the process has a debug port */ if (CurrentProcess->DebugPort) { - + /* Notify the Debug API. TODO */ //Last ? DbgkExitProcess(ExitStatus) : DbgkExitThread(ExitStatus); } - - /* Process the Termination Ports */ + + /* Process the Termination Ports */ TerminationPort = CurrentThread->TerminationPort; DPRINT("TerminationPort: %p\n", TerminationPort); while (TerminationPort) { - + /* Send the LPC Message */ LpcSendTerminationPort(TerminationPort->Port, CurrentThread->CreateTime); - + /* Free the Port */ ExFreePool(TerminationPort); - + /* Get the next one */ TerminationPort = TerminationPort->Next; DPRINT("TerminationPort: %p\n", TerminationPort); } - + /* Rundown Win32 Structures */ PsTerminateWin32Thread(CurrentThread); if (Last) PsTerminateWin32Process(CurrentProcess); - + /* Rundown Registry Notifications. TODO (refers to NtChangeNotify, not Cm callbacks) */ //CmNotifyRunDown(CurrentThread); - + /* Free the TEB */ if((Teb = CurrentThread->Tcb.Teb)) { @@ -297,27 +297,27 @@ PspExitThread(NTSTATUS ExitStatus) MmDeleteTeb(CurrentProcess, Teb); CurrentThread->Tcb.Teb = NULL; } - + /* The last Thread shuts down the Process */ if (Last) PspExitProcess(CurrentProcess); - + /* Unlock the Process */ PsUnlockProcess(CurrentProcess); - + /* Cancel I/O for the thread. */ IoCancelThreadIo(CurrentThread); - + /* Rundown Timers */ ExTimerRundown(); KeCancelTimer(&CurrentThread->Tcb.Timer); - + /* If the Processor Control Block's NpxThread points to the current thread * unset it. */ InterlockedCompareExchangePointer(&KeGetCurrentPrcb()->NpxThread, NULL, (PKPROCESS)CurrentThread); - + /* Rundown Mutexes */ KeRundownThread(); @@ -327,7 +327,7 @@ PspExitThread(NTSTATUS ExitStatus) KEBUGCHECK(0); } -VOID +VOID STDCALL PsExitSpecialApc(PKAPC Apc, PKNORMAL_ROUTINE* NormalRoutine, @@ -336,31 +336,31 @@ PsExitSpecialApc(PKAPC Apc, PVOID* SystemArguemnt2) { NTSTATUS ExitStatus = (NTSTATUS)Apc->NormalContext; - + DPRINT("PsExitSpecialApc called: 0x%x (proc: 0x%x)\n", PsGetCurrentThread(), PsGetCurrentProcess()); - + /* Free the APC */ ExFreePool(Apc); - + /* Terminate the Thread */ PspExitThread(ExitStatus); - + /* we should never reach this point! */ KEBUGCHECK(0); } -VOID +VOID STDCALL PspExitNormalApc(PVOID NormalContext, PVOID SystemArgument1, PVOID SystemArgument2) { - /* Not fully supported yet... must work out some issues that - * I don't understand yet -- Alex + /* Not fully supported yet... must work out some issues that + * I don't understand yet -- Alex */ DPRINT1("APC2\n"); PspExitThread((NTSTATUS)NormalContext); - + /* we should never reach this point! */ KEBUGCHECK(0); } @@ -373,11 +373,11 @@ STDCALL PspTerminateThreadByPointer(PETHREAD Thread, NTSTATUS ExitStatus) { - PKAPC Apc; - + PKAPC Apc; + DPRINT("PspTerminatedThreadByPointer(Thread %x, ExitStatus %x)\n", Thread, ExitStatus); - + /* Check if we are already in the right context */ if (PsGetCurrentThread() == Thread) { @@ -387,10 +387,10 @@ PspTerminateThreadByPointer(PETHREAD Thread, /* we should never reach this point! */ KEBUGCHECK(0); } - + /* Allocate the APC */ Apc = ExAllocatePoolWithTag(NonPagedPool, sizeof(KAPC), TAG_TERMINATE_APC); - + /* Initialize a Kernel Mode APC to Kill the Thread */ KeInitializeApc(Apc, &Thread->Tcb, @@ -400,35 +400,35 @@ PspTerminateThreadByPointer(PETHREAD Thread, PspExitNormalApc, KernelMode, (PVOID)ExitStatus); - + /* Insert it into the APC Queue */ KeInsertQueueApc(Apc, Apc, NULL, 2); - + /* Forcefully resume the thread */ KeForceResumeThread(&Thread->Tcb); } - -NTSTATUS + +NTSTATUS STDCALL PspExitProcess(PEPROCESS Process) { DPRINT("PspExitProcess 0x%x\n", Process); - + PspRunCreateProcessNotifyRoutines(Process, FALSE); - + /* close all handles associated with our process, this needs to be done when the last thread still runs */ ObKillProcess(Process); KeSetProcess(&Process->Pcb, IO_NO_INCREMENT); - + return(STATUS_SUCCESS); } -NTSTATUS +NTSTATUS STDCALL NtTerminateProcess(IN HANDLE ProcessHandle OPTIONAL, IN NTSTATUS ExitStatus) @@ -437,12 +437,12 @@ NtTerminateProcess(IN HANDLE ProcessHandle OPTIONAL, PEPROCESS Process; PETHREAD CurrentThread; BOOLEAN KillByHandle; - + PAGED_CODE(); - + DPRINT("NtTerminateProcess(ProcessHandle %x, ExitStatus %x)\n", ProcessHandle, ExitStatus); - + KillByHandle = (ProcessHandle != NULL); /* Get the Process Object */ @@ -457,20 +457,20 @@ NtTerminateProcess(IN HANDLE ProcessHandle OPTIONAL, DPRINT1("Invalid handle to Process\n"); return(Status); } - + CurrentThread = PsGetCurrentThread(); - + PsLockProcess(Process, FALSE); - + if(Process->ExitTime.QuadPart != 0) { PsUnlockProcess(Process); return STATUS_PROCESS_IS_TERMINATING; } - + /* Terminate all the Process's Threads */ PspTerminateProcessThreads(Process, ExitStatus); - + /* only kill the calling thread if it either passed a process handle or NtCurrentProcess() */ if (KillByHandle) { @@ -507,20 +507,20 @@ NtTerminateProcess(IN HANDLE ProcessHandle OPTIONAL, /* unlock and dereference the process so the threads can kill themselves */ PsUnlockProcess(Process); ObDereferenceObject(Process); - + return(STATUS_SUCCESS); } -NTSTATUS +NTSTATUS STDCALL NtTerminateThread(IN HANDLE ThreadHandle, IN NTSTATUS ExitStatus) { PETHREAD Thread; NTSTATUS Status; - + PAGED_CODE(); - + /* Get the Thread Object */ Status = ObReferenceObjectByHandle(ThreadHandle, THREAD_TERMINATE, @@ -529,84 +529,84 @@ NtTerminateThread(IN HANDLE ThreadHandle, (PVOID*)&Thread, NULL); if (!NT_SUCCESS(Status)) { - + DPRINT1("Could not reference thread object\n"); return(Status); } - + /* Make sure this is not a system thread */ if (PsIsSystemThread(Thread)) { - + DPRINT1("Trying to Terminate a system thread!\n"); ObDereferenceObject(Thread); return STATUS_INVALID_PARAMETER; } - + /* Check to see if we're running in the same thread */ if (Thread != PsGetCurrentThread()) { - + /* we need to lock the process to make sure it's not already terminating */ PsLockProcess(Thread->ThreadsProcess, FALSE); - + /* This isn't our thread, terminate it if not already done */ if (!Thread->Terminated) { - + Thread->Terminated = TRUE; - + /* Terminate it */ PspTerminateThreadByPointer(Thread, ExitStatus); } - + PsUnlockProcess(Thread->ThreadsProcess); - + /* Dereference the Thread and return */ ObDereferenceObject(Thread); - + } else { Thread->Terminated = TRUE; - + /* it's safe to dereference thread, there's at least the keep-alive reference which will be removed by the thread reaper causing the thread to be finally destroyed */ ObDereferenceObject(Thread); - + /* Terminate him, he's ours */ PspExitThread(ExitStatus); /* We do never reach this point */ KEBUGCHECK(0); } - + return(STATUS_SUCCESS); } /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL PsTerminateSystemThread(NTSTATUS ExitStatus) { PETHREAD Thread = PsGetCurrentThread(); - + /* Make sure this is a system thread */ if (!PsIsSystemThread(Thread)) { - + DPRINT1("Trying to Terminate a non-system thread!\n"); return STATUS_INVALID_PARAMETER; } - + /* Terminate it for real */ PspExitThread(ExitStatus); - + /* we should never reach this point! */ KEBUGCHECK(0); - + return(STATUS_SUCCESS); } -NTSTATUS +NTSTATUS STDCALL NtRegisterThreadTerminatePort(HANDLE PortHandle) { @@ -614,27 +614,27 @@ NtRegisterThreadTerminatePort(HANDLE PortHandle) PTERMINATION_PORT TerminationPort; PVOID TerminationLpcPort; PETHREAD Thread; - + PAGED_CODE(); - + /* Get the Port */ Status = ObReferenceObjectByHandle(PortHandle, PORT_ALL_ACCESS, LpcPortObjectType, KeGetPreviousMode(), &TerminationLpcPort, - NULL); + NULL); if (!NT_SUCCESS(Status)) { - + DPRINT1("Failed to reference Port\n"); return(Status); } - + /* Allocate the Port and make sure it suceeded */ - if((TerminationPort = ExAllocatePoolWithTag(NonPagedPool, - sizeof(PTERMINATION_PORT), + if((TerminationPort = ExAllocatePoolWithTag(NonPagedPool, + sizeof(PTERMINATION_PORT), TAG('P', 's', 'T', '=')))) { - + /* Associate the Port */ Thread = PsGetCurrentThread(); TerminationPort->Port = TerminationLpcPort; @@ -645,9 +645,9 @@ NtRegisterThreadTerminatePort(HANDLE PortHandle) /* Return success */ return(STATUS_SUCCESS); - + } else { - + /* Dereference and Fail */ ObDereferenceObject(TerminationPort); return(STATUS_INSUFFICIENT_RESOURCES); diff --git a/reactos/ntoskrnl/ps/locale.c b/reactos/ntoskrnl/ps/locale.c index 45b2f8d8ec9..839bded03ec 100644 --- a/reactos/ntoskrnl/ps/locale.c +++ b/reactos/ntoskrnl/ps/locale.c @@ -254,7 +254,7 @@ NtSetDefaultLocale(IN BOOLEAN UserProfile, WCHAR ValueBuffer[20]; HANDLE UserKey = NULL; NTSTATUS Status; - + PAGED_CODE(); if (UserProfile) @@ -362,7 +362,7 @@ NtQueryDefaultUILanguage(OUT PLANGID LanguageId) HANDLE UserKey; HANDLE KeyHandle; NTSTATUS Status; - + PAGED_CODE(); Status = RtlOpenCurrentUser(KEY_READ, @@ -438,7 +438,7 @@ NTSTATUS STDCALL NtQueryInstallUILanguage(OUT PLANGID LanguageId) { PAGED_CODE(); - + *LanguageId = PsInstallUILanguageId; return STATUS_SUCCESS; @@ -459,7 +459,7 @@ NtSetDefaultUILanguage(IN LANGID LanguageId) HANDLE UserHandle; HANDLE KeyHandle; NTSTATUS Status; - + PAGED_CODE(); Status = RtlOpenCurrentUser(KEY_WRITE, diff --git a/reactos/ntoskrnl/ps/notify.c b/reactos/ntoskrnl/ps/notify.c index 2622610be0a..b3fe83dc967 100644 --- a/reactos/ntoskrnl/ps/notify.c +++ b/reactos/ntoskrnl/ps/notify.c @@ -22,7 +22,7 @@ static ULONG PspThreadNotifyRoutineCount = 0; static PCREATE_THREAD_NOTIFY_ROUTINE PspThreadNotifyRoutine[MAX_THREAD_NOTIFY_ROUTINE_COUNT]; -static PCREATE_PROCESS_NOTIFY_ROUTINE +static PCREATE_PROCESS_NOTIFY_ROUTINE PspProcessNotifyRoutine[MAX_PROCESS_NOTIFY_ROUTINE_COUNT]; static PLOAD_IMAGE_NOTIFY_ROUTINE @@ -35,7 +35,7 @@ static PVOID PspLegoNotifyRoutine; /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL PsSetCreateProcessNotifyRoutine(IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine, IN BOOLEAN Remove) @@ -56,8 +56,8 @@ PsSetCreateProcessNotifyRoutine(IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine, return(STATUS_SUCCESS); } } - } - else + } + else { /* Loop the routines */ for(i=0;iUniqueProcessId; HANDLE ParentId = CurrentProcess->InheritedFromUniqueProcessId; - - for(i = 0; i < MAX_PROCESS_NOTIFY_ROUTINE_COUNT; ++i) + + for(i = 0; i < MAX_PROCESS_NOTIFY_ROUTINE_COUNT; ++i) { - if(PspProcessNotifyRoutine[i]) + if(PspProcessNotifyRoutine[i]) { PspProcessNotifyRoutine[i](ParentId, ProcessId, Create); } } } -VOID +VOID STDCALL PspRunLoadImageNotifyRoutines(PUNICODE_STRING FullImageName, HANDLE ProcessId, PIMAGE_INFO ImageInfo) { ULONG i; - + for (i = 0; i < MAX_PROCESS_NOTIFY_ROUTINE_COUNT; ++ i) { if (PspLoadImageNotifyRoutine[i]) diff --git a/reactos/ntoskrnl/ps/process.c b/reactos/ntoskrnl/ps/process.c index cc65454e526..7a68afe3d11 100644 --- a/reactos/ntoskrnl/ps/process.c +++ b/reactos/ntoskrnl/ps/process.c @@ -23,7 +23,7 @@ POBJECT_TYPE EXPORTED PsProcessType = NULL; LIST_ENTRY PsActiveProcessHead; FAST_MUTEX PspActiveProcessMutex; LARGE_INTEGER ShortPsLockDelay, PsLockTimeout; - + /* INTERNAL FUNCTIONS *****************************************************************/ NTSTATUS @@ -34,11 +34,11 @@ PsLockProcess(PEPROCESS Process, BOOLEAN Timeout) NTSTATUS Status = STATUS_UNSUCCESSFUL; PLARGE_INTEGER Delay = (Timeout ? &PsLockTimeout : NULL); PKTHREAD CallingThread = KeGetCurrentThread(); - + PAGED_CODE(); - + KeEnterCriticalRegion(); - + for(;;) { PrevLockOwner = (PKTHREAD)InterlockedCompareExchangePointer( @@ -80,7 +80,7 @@ PsLockProcess(PEPROCESS Process, BOOLEAN Timeout) } } } - + return Status; } @@ -88,15 +88,15 @@ VOID PsUnlockProcess(PEPROCESS Process) { PAGED_CODE(); - + ASSERT(Process->LockOwner == KeGetCurrentThread()); - + if(InterlockedDecrementUL(&Process->LockCount) == 0) { InterlockedExchangePointer(&Process->LockOwner, NULL); KeSetEvent(&Process->LockEvent, IO_NO_INCREMENT, FALSE); } - + KeLeaveCriticalRegion(); } @@ -106,7 +106,7 @@ PsGetNextProcess(PEPROCESS OldProcess) { PEPROCESS NextProcess; NTSTATUS Status; - + /* Check if we have a previous process */ if (OldProcess == NULL) { @@ -114,29 +114,29 @@ PsGetNextProcess(PEPROCESS OldProcess) Status = ObReferenceObjectByPointer(PsIdleProcess, PROCESS_ALL_ACCESS, PsProcessType, - KernelMode); + KernelMode); if (!NT_SUCCESS(Status)) { DPRINT1("PsGetNextProcess(): ObReferenceObjectByPointer failed for PsIdleProcess\n"); KEBUGCHECK(0); } - + return PsIdleProcess; } - + /* Acquire the Active Process Lock */ ExAcquireFastMutex(&PspActiveProcessMutex); - + /* Start at the previous process */ NextProcess = OldProcess; - + /* Loop until we fail */ while (1) { /* Get the Process Link */ PLIST_ENTRY Flink = (NextProcess == PsIdleProcess ? PsActiveProcessHead.Flink : NextProcess->ActiveProcessLinks.Flink); - + /* Move to the next Process if we're not back at the beginning */ if (Flink != &PsActiveProcessHead) { @@ -154,13 +154,13 @@ PsGetNextProcess(PEPROCESS OldProcess) PsProcessType, KernelMode); - /* Exit the loop if the reference worked, keep going if there's an error */ + /* Exit the loop if the reference worked, keep going if there's an error */ if (NT_SUCCESS(Status)) break; } - + /* Release the lock */ ExReleaseFastMutex(&PspActiveProcessMutex); - + /* Reference the Process we had referenced earlier */ ObDereferenceObject(OldProcess); return(NextProcess); @@ -179,7 +179,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle, { HANDLE hProcess; PEPROCESS Process; - PEPROCESS pParentProcess; + PEPROCESS pParentProcess; PEPORT pDebugPort = NULL; PEPORT pExceptionPort = NULL; PSECTION_OBJECT SectionObject = NULL; @@ -190,9 +190,9 @@ PspCreateProcess(OUT PHANDLE ProcessHandle, DirectoryTableBase.QuadPart = (ULONGLONG)0; DPRINT("PspCreateProcess(ObjectAttributes %x)\n", ObjectAttributes); - + /* Reference the Parent if there is one */ - if(ParentProcess != NULL) + if(ParentProcess != NULL) { Status = ObReferenceObjectByHandle(ParentProcess, PROCESS_CREATE_PROCESS, @@ -200,33 +200,33 @@ PspCreateProcess(OUT PHANDLE ProcessHandle, PreviousMode, (PVOID*)&pParentProcess, NULL); - - if (!NT_SUCCESS(Status)) + + if (!NT_SUCCESS(Status)) { DPRINT1("Failed to reference the parent process: Status: 0x%x\n", Status); return(Status); } - + /* Inherit Parent process's Affinity. */ - Affinity = pParentProcess->Pcb.Affinity; - - } - else + Affinity = pParentProcess->Pcb.Affinity; + + } + else { pParentProcess = NULL; Affinity = KeActiveProcessors; } /* Add the debug port */ - if (DebugPort != NULL) - { + if (DebugPort != NULL) + { Status = ObReferenceObjectByHandle(DebugPort, PORT_ALL_ACCESS, LpcPortObjectType, - PreviousMode, + PreviousMode, (PVOID*)&pDebugPort, NULL); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { DPRINT1("Failed to reference the debug port: Status: 0x%x\n", Status); goto exitdereferenceobjects; @@ -234,7 +234,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle, } /* Add the exception port */ - if (ExceptionPort != NULL) + if (ExceptionPort != NULL) { Status = ObReferenceObjectByHandle(ExceptionPort, PORT_ALL_ACCESS, @@ -242,8 +242,8 @@ PspCreateProcess(OUT PHANDLE ProcessHandle, PreviousMode, (PVOID*)&pExceptionPort, NULL); - - if (!NT_SUCCESS(Status)) + + if (!NT_SUCCESS(Status)) { DPRINT1("Failed to reference the exception port: Status: 0x%x\n", Status); goto exitdereferenceobjects; @@ -251,7 +251,7 @@ PspCreateProcess(OUT PHANDLE ProcessHandle, } /* Add the Section */ - if (SectionHandle != NULL) + if (SectionHandle != NULL) { Status = ObReferenceObjectByHandle(SectionHandle, 0, @@ -277,81 +277,81 @@ PspCreateProcess(OUT PHANDLE ProcessHandle, 0, 0, (PVOID*)&Process); - - if (!NT_SUCCESS(Status)) + + if (!NT_SUCCESS(Status)) { DPRINT1("Failed to create process object, Status: 0x%x\n", Status); goto exitdereferenceobjects; } - + /* Clean up the Object */ DPRINT("Cleaning Process Object\n"); RtlZeroMemory(Process, sizeof(EPROCESS)); - + /* Inherit stuff from the Parent since we now have the object created */ - if (pParentProcess) + if (pParentProcess) { Process->InheritedFromUniqueProcessId = pParentProcess->UniqueProcessId; Process->Session = pParentProcess->Session; } - + /* FIXME: Set up the Quota Block from the Parent PspInheritQuota(Parent, Process); */ - + /* FIXME: Set up Dos Device Map from the Parent ObInheritDeviceMap(Parent, Process) */ - + /* Set the Process' LPC Ports */ Process->DebugPort = pDebugPort; Process->ExceptionPort = pExceptionPort; - + /* Setup the Lock Event */ DPRINT("Initialzing Process Lock\n"); KeInitializeEvent(&Process->LockEvent, SynchronizationEvent, FALSE); - + /* Setup the Thread List Head */ DPRINT("Initialzing Process ThreadListHead\n"); InitializeListHead(&Process->ThreadListHead); - + /* Create or Clone the Handle Table */ DPRINT("Initialzing Process Handle Table\n"); ObCreateHandleTable(pParentProcess, InheritObjectTable, Process); DPRINT("Handle Table: %x\n", Process->ObjectTable); - + /* Set Process's Directory Base */ DPRINT("Initialzing Process Directory Base\n"); - MmCopyMmInfo(pParentProcess ? pParentProcess : PsInitialSystemProcess, + MmCopyMmInfo(pParentProcess ? pParentProcess : PsInitialSystemProcess, Process, &DirectoryTableBase); - + /* Now initialize the Kernel Process */ DPRINT("Initialzing Kernel Process\n"); KeInitializeProcess(&Process->Pcb, PROCESS_PRIO_NORMAL, Affinity, DirectoryTableBase); - + /* Duplicate Parent Token */ DPRINT("Initialzing Process Token\n"); Status = PspInitializeProcessSecurity(Process, pParentProcess); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { DbgPrint("PspInitializeProcessSecurity failed (Status %x)\n", Status); ObDereferenceObject(Process); goto exitdereferenceobjects; } - + /* Create the Process' Address Space */ DPRINT("Initialzing Process Address Space\n"); Status = MmCreateProcessAddressSpace(Process, SectionObject); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { DPRINT1("Failed to create Address Space\n"); ObDereferenceObject(Process); goto exitdereferenceobjects; } - - if (SectionObject) + + if (SectionObject) { /* Map the System Dll */ DPRINT("Mapping System DLL\n"); @@ -364,27 +364,27 @@ PspCreateProcess(OUT PHANDLE ProcessHandle, PsProcessType, &Process->UniqueProcessId); DPRINT("Created CID: %d\n", Process->UniqueProcessId); - if(!NT_SUCCESS(Status)) + if(!NT_SUCCESS(Status)) { DPRINT1("Failed to create CID handle (unique process ID)! Status: 0x%x\n", Status); ObDereferenceObject(Process); goto exitdereferenceobjects; } - + /* FIXME: Insert into Job Object */ /* Create PEB only for User-Mode Processes */ - if (pParentProcess) + if (pParentProcess) { DPRINT("Creating PEB\n"); Status = MmCreatePeb(Process); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { DbgPrint("NtCreateProcess() Peb creation failed: Status %x\n",Status); ObDereferenceObject(Process); goto exitdereferenceobjects; } - + /* Let's take advantage of this time to kill the reference too */ ObDereferenceObject(pParentProcess); pParentProcess = NULL; @@ -395,9 +395,9 @@ PspCreateProcess(OUT PHANDLE ProcessHandle, ExAcquireFastMutex(&PspActiveProcessMutex); InsertTailList(&PsActiveProcessHead, &Process->ActiveProcessLinks); ExReleaseFastMutex(&PspActiveProcessMutex); - + /* FIXME: SeCreateAccessStateEx */ - + /* Insert the Process into the Object Directory */ DPRINT("Inserting Process Object\n"); Status = ObInsertObject(Process, @@ -406,32 +406,32 @@ PspCreateProcess(OUT PHANDLE ProcessHandle, 0, NULL, &hProcess); - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { DPRINT1("Could not get a handle to the Process Object\n"); ObDereferenceObject(Process); goto exitdereferenceobjects; } - + /* Set the Creation Time */ KeQuerySystemTime(&Process->CreateTime); - + DPRINT("Done. Returning handle: %x\n", hProcess); - _SEH_TRY + _SEH_TRY { *ProcessHandle = hProcess; - } - _SEH_HANDLE + } + _SEH_HANDLE { Status = _SEH_GetExceptionCode(); } _SEH_END; - + /* FIXME: ObGetObjectSecurity(Process, &SecurityDescriptor) SeAccessCheck */ ObDereferenceObject(Process); return Status; - + exitdereferenceobjects: if(SectionObject != NULL) ObDereferenceObject(SectionObject); if(pExceptionPort != NULL) ObDereferenceObject(pExceptionPort); @@ -445,7 +445,7 @@ exitdereferenceobjects: /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL PsCreateSystemProcess(PHANDLE ProcessHandle, ACCESS_MASK DesiredAccess, @@ -464,7 +464,7 @@ PsCreateSystemProcess(PHANDLE ProcessHandle, /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL PsLookupProcessByProcessId(IN HANDLE ProcessId, OUT PEPROCESS *Process) @@ -498,7 +498,7 @@ PsLookupProcessByProcessId(IN HANDLE ProcessId, PEPROCESS STDCALL IoGetCurrentProcess(VOID) { - if (PsGetCurrentThread() == NULL || + if (PsGetCurrentThread() == NULL || PsGetCurrentThread()->Tcb.ApcState.Process == NULL) { return(PsInitialSystemProcess); @@ -701,7 +701,7 @@ PsIsProcessBeingDebugged(PEPROCESS Process) /* * @implemented - */ + */ VOID STDCALL PsSetProcessPriorityClass(PEPROCESS Process, @@ -712,7 +712,7 @@ PsSetProcessPriorityClass(PEPROCESS Process, /* * @implemented - */ + */ VOID STDCALL PsSetProcessSecurityPort(PEPROCESS Process, @@ -766,7 +766,7 @@ PsSetProcessWin32WindowStation(PEPROCESS Process, * * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtCreateProcess(OUT PHANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, @@ -779,10 +779,10 @@ NtCreateProcess(OUT PHANDLE ProcessHandle, { KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - - /* Check parameters */ + + /* Check parameters */ if(PreviousMode != KernelMode) { _SEH_TRY @@ -799,7 +799,7 @@ NtCreateProcess(OUT PHANDLE ProcessHandle, if(!NT_SUCCESS(Status)) return Status; } - + /* Make sure there's a parent process */ if(ParentProcess == NULL) { @@ -818,7 +818,7 @@ NtCreateProcess(OUT PHANDLE ProcessHandle, DebugPort, ExceptionPort); } - + /* Return Status */ return Status; } @@ -826,7 +826,7 @@ NtCreateProcess(OUT PHANDLE ProcessHandle, /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtOpenProcess(OUT PHANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, @@ -837,19 +837,19 @@ NtOpenProcess(OUT PHANDLE ProcessHandle, NTSTATUS Status = STATUS_INVALID_PARAMETER; PEPROCESS Process; PETHREAD Thread = NULL; - + DPRINT("NtOpenProcess(ProcessHandle %x, DesiredAccess %x, " "ObjectAttributes %x, ClientId %x { UniP %d, UniT %d })\n", ProcessHandle, DesiredAccess, ObjectAttributes, ClientId, ClientId->UniqueProcess, ClientId->UniqueThread); - + PAGED_CODE(); - + /* Open by name if one was given */ DPRINT("Checking type\n"); if (ObjectAttributes->ObjectName) { - /* Open it */ + /* Open it */ DPRINT("Opening by name\n"); Status = ObOpenObjectByName(ObjectAttributes, PsProcessType, @@ -858,12 +858,12 @@ NtOpenProcess(OUT PHANDLE ProcessHandle, DesiredAccess, NULL, ProcessHandle); - + if (Status != STATUS_SUCCESS) { DPRINT1("Could not open object by name\n"); } - + /* Return Status */ DPRINT("Found: %x\n", ProcessHandle); return(Status); @@ -880,8 +880,8 @@ NtOpenProcess(OUT PHANDLE ProcessHandle, &Process, &Thread); DPRINT("Found: %x\n", Process); - } - else + } + else { /* Get the Process */ DPRINT("Opening by Process ID: %x\n", ClientId->UniqueProcess); @@ -889,13 +889,13 @@ NtOpenProcess(OUT PHANDLE ProcessHandle, &Process); DPRINT("Found: %x\n", Process); } - + if(!NT_SUCCESS(Status)) { DPRINT1("Failure to find process\n"); return Status; } - + /* Open the Process Object */ Status = ObOpenObjectByPointer(Process, ObjectAttributes->Attributes, @@ -908,14 +908,14 @@ NtOpenProcess(OUT PHANDLE ProcessHandle, { DPRINT1("Failure to open process\n"); } - + /* Dereference the thread if we used it */ if (Thread) ObDereferenceObject(Thread); - + /* Dereference the Process */ ObDereferenceObject(Process); } - + return Status; } /* EOF */ diff --git a/reactos/ntoskrnl/ps/psmgr.c b/reactos/ntoskrnl/ps/psmgr.c index d60224f65e3..51af275d573 100644 --- a/reactos/ntoskrnl/ps/psmgr.c +++ b/reactos/ntoskrnl/ps/psmgr.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ps/psmgr.c * PURPOSE: Process management - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -21,7 +21,7 @@ static GENERIC_MAPPING PiProcessMapping = { STANDARD_RIGHTS_READ | PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, STANDARD_RIGHTS_WRITE | PROCESS_CREATE_PROCESS | PROCESS_CREATE_THREAD | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_DUP_HANDLE | - PROCESS_TERMINATE | PROCESS_SET_QUOTA | PROCESS_SET_INFORMATION | + PROCESS_TERMINATE | PROCESS_SET_QUOTA | PROCESS_SET_INFORMATION | PROCESS_SUSPEND_RESUME, STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE, PROCESS_ALL_ACCESS}; @@ -32,14 +32,14 @@ static GENERIC_MAPPING PiThreadMapping = { THREAD_ALERT | THREAD_SET_INFORMATION | THREAD_SET_CONTEXT, STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE, THREAD_ALL_ACCESS}; - + BOOLEAN DoneInitYet = FALSE; extern ULONG NtBuildNumber; extern ULONG NtMajorVersion; extern ULONG NtMinorVersion; -VOID +VOID INIT_FUNCTION PsInitClientIDManagment(VOID); @@ -50,7 +50,7 @@ VOID STDCALL PspKillMostProcesses(); VOID PiShutdownProcessManager(VOID) { DPRINT("PiShutdownProcessManager()\n"); - + PspKillMostProcesses(); } @@ -64,7 +64,7 @@ PiInitProcessManager(VOID) PsInitialiseW32Call(); } -VOID +VOID INIT_FUNCTION PsInitThreadManagment(VOID) /* @@ -114,23 +114,23 @@ PsInitThreadManagment(VOID) DPRINT("FirstThread %x\n",FirstThread); DoneInitYet = TRUE; - + ExInitializeWorkItem(&PspReaperWorkItem, PspReapRoutine, NULL); } -VOID +VOID INIT_FUNCTION PsInitProcessManagment(VOID) { PKPROCESS KProcess; NTSTATUS Status; - + ShortPsLockDelay.QuadPart = -100LL; PsLockTimeout.QuadPart = -10000000LL; /* one second */ /* * Register the process object type */ - + PsProcessType = ExAllocatePool(NonPagedPool, sizeof(OBJECT_TYPE)); PsProcessType->Tag = TAG('P', 'R', 'O', 'C'); @@ -151,14 +151,14 @@ PsInitProcessManagment(VOID) PsProcessType->OkayToClose = NULL; PsProcessType->Create = NULL; PsProcessType->DuplicationNotify = NULL; - + RtlInitUnicodeString(&PsProcessType->TypeName, L"Process"); - + ObpCreateTypeObject(PsProcessType); InitializeListHead(&PsActiveProcessHead); ExInitializeFastMutex(&PspActiveProcessMutex); - + /* * Initialize the idle process */ @@ -179,7 +179,7 @@ PsInitProcessManagment(VOID) } RtlZeroMemory(PsIdleProcess, sizeof(EPROCESS)); - + PsIdleProcess->Pcb.Affinity = 0xFFFFFFFF; PsIdleProcess->Pcb.IopmOffset = 0xffff; PsIdleProcess->Pcb.BasePriority = PROCESS_PRIO_IDLE; @@ -213,7 +213,7 @@ PsInitProcessManagment(VOID) KEBUGCHECK(0); return; } - + /* System threads may run on any processor. */ RtlZeroMemory(PsInitialSystemProcess, sizeof(EPROCESS)); PsInitialSystemProcess->Pcb.Affinity = 0xFFFFFFFF; @@ -226,14 +226,14 @@ PsInitProcessManagment(VOID) sizeof(EPROCESS), FALSE); KProcess = &PsInitialSystemProcess->Pcb; - + MmInitializeAddressSpace(PsInitialSystemProcess, &PsInitialSystemProcess->AddressSpace); - + KeInitializeEvent(&PsInitialSystemProcess->LockEvent, SynchronizationEvent, FALSE); #if defined(__GNUC__) - KProcess->DirectoryTableBase = + KProcess->DirectoryTableBase = (LARGE_INTEGER)(LONGLONG)(ULONG)MmGetPageDirectory(); #else { @@ -244,16 +244,16 @@ PsInitProcessManagment(VOID) #endif strcpy(PsInitialSystemProcess->ImageFileName, "System"); - + PsInitialSystemProcess->Win32WindowStation = (HANDLE)0; - + InsertHeadList(&PsActiveProcessHead, &PsInitialSystemProcess->ActiveProcessLinks); InitializeListHead(&PsInitialSystemProcess->ThreadListHead); - + #ifndef SCHED_REWRITE PTOKEN BootToken; - + /* No parent, this is the Initial System Process. Assign Boot Token */ BootToken = SepCreateSystemProcessToken(); BootToken->TokenInUse = TRUE; @@ -266,15 +266,15 @@ VOID PspPostInitSystemProcess(VOID) { NTSTATUS Status; - + /* this routine is called directly after the exectuive handle tables were initialized. We'll set up the Client ID handle table and assign the system process a PID */ PsInitClientIDManagment(); - + ObCreateHandleTable(NULL, FALSE, PsInitialSystemProcess); ObpKernelHandleTable = PsInitialSystemProcess->ObjectTable; - + Status = PsCreateCidHandle(PsInitialSystemProcess, PsProcessType, &PsInitialSystemProcess->UniqueProcessId); diff --git a/reactos/ntoskrnl/ps/query.c b/reactos/ntoskrnl/ps/query.c index 48d5321d105..5b4f8553f3a 100644 --- a/reactos/ntoskrnl/ps/query.c +++ b/reactos/ntoskrnl/ps/query.c @@ -62,7 +62,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] = ICI_SQ_SAME( 0, 1, 0 ), /* ProcessUnknown33 */ ICI_SQ_SAME( 0, 1, 0 ), /* ProcessUnknown34 */ ICI_SQ_SAME( 0, 1, 0 ), /* ProcessUnknown35 */ - + ICI_SQ_SAME( sizeof(ULONG), sizeof(ULONG), ICIF_QUERY), /* ProcessCookie */ }; @@ -75,7 +75,7 @@ static const struct { BOOLEAN Implemented; ULONG Size; -} QueryInformationData[MaxThreadInfoClass + 1] = +} QueryInformationData[MaxThreadInfoClass + 1] = { {TRUE, sizeof(THREAD_BASIC_INFORMATION)}, // ThreadBasicInformation {TRUE, sizeof(KERNEL_USER_TIMES)}, // ThreadTimes @@ -101,7 +101,7 @@ static const struct { BOOLEAN Implemented; ULONG Size; -} SetInformationData[MaxThreadInfoClass + 1] = +} SetInformationData[MaxThreadInfoClass + 1] = { {TRUE, 0}, // ThreadBasicInformation {TRUE, 0}, // ThreadTimes @@ -138,11 +138,11 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, PEPROCESS Process; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); - + DefaultQueryInfoBufferCheck(ProcessInformationClass, PsProcessInfoClass, ProcessInformation, @@ -155,7 +155,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, DPRINT1("NtQueryInformationProcess() failed, Status: 0x%x\n", Status); return Status; } - + if(ProcessInformationClass != ProcessCookie) { Status = ObReferenceObjectByHandle(ProcessHandle, @@ -176,7 +176,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, real handle actually represents the current process. */ return STATUS_INVALID_PARAMETER; } - + switch (ProcessInformationClass) { case ProcessBasicInformation: @@ -254,7 +254,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, _SEH_END; break; } - + case ProcessLdtInformation: case ProcessWorkingSetWatch: case ProcessWx86Information: @@ -264,7 +264,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, case ProcessHandleCount: { ULONG HandleCount = ObpGetHandleCountByHandleTable(Process->ObjectTable); - + _SEH_TRY { *(PULONG)ProcessInformation = HandleCount; @@ -300,7 +300,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, _SEH_END; break; } - + case ProcessWow64Information: DPRINT1("We currently don't support the ProcessWow64Information information class!\n"); Status = STATUS_NOT_IMPLEMENTED; @@ -309,7 +309,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, case ProcessVmCounters: { PVM_COUNTERS pOut = (PVM_COUNTERS)ProcessInformation; - + _SEH_TRY { pOut->PeakVirtualSize = Process->PeakVirtualSize; @@ -364,7 +364,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, case ProcessPriorityBoost: { PULONG BoostEnabled = (PULONG)ProcessInformation; - + _SEH_TRY { *BoostEnabled = Process->Pcb.DisableBoost ? FALSE : TRUE; @@ -385,7 +385,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, case ProcessDeviceMap: { PROCESS_DEVICEMAP_INFORMATION DeviceMap; - + ObQueryDeviceMapInformation(Process, &DeviceMap); _SEH_TRY @@ -445,7 +445,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, if(Attached) KeAttachProcess(&Process->Pcb); - + _SEH_TRY { ProcParams = Process->Peb->ProcessParameters; @@ -456,7 +456,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(NT_SUCCESS(Status)) { if(ProcessInformationLength < sizeof(UNICODE_STRING) + ImagePathLen + sizeof(WCHAR)) @@ -466,7 +466,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, else { PWSTR StrSource = NULL; - + RtlZeroMemory(&LocalDest, sizeof(LocalDest)); /* create a DstPath structure on the stack */ @@ -543,7 +543,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, } } } - + /* don't forget to detach from the process!!! */ if(Attached) KeDetachProcess(); @@ -555,11 +555,11 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, } break; } - + case ProcessCookie: { ULONG Cookie; - + /* receive the process cookie, this is only allowed for the current process! */ @@ -571,16 +571,16 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, LARGE_INTEGER SystemTime; ULONG NewCookie; PKPRCB Prcb; - + /* generate a new cookie */ - + KeQuerySystemTime(&SystemTime); - + Prcb = KeGetCurrentPrcb(); NewCookie = Prcb->KeSystemCalls ^ Prcb->InterruptTime ^ SystemTime.u.LowPart ^ SystemTime.u.HighPart; - + /* try to set the new cookie, return the current one if another thread set it in the meanwhile */ Cookie = InterlockedCompareExchange((LONG*)&Process->Cookie, @@ -592,7 +592,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, Cookie = NewCookie; } } - + _SEH_TRY { *(PULONG)ProcessInformation = Cookie; @@ -606,7 +606,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + break; } @@ -632,7 +632,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle, { ObDereferenceObject(Process); } - + return Status; } @@ -649,9 +649,9 @@ NtSetInformationProcess(IN HANDLE ProcessHandle, KPROCESSOR_MODE PreviousMode; ACCESS_MASK Access; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); DefaultSetInfoBufferCheck(ProcessInformationClass, @@ -666,7 +666,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle, DPRINT1("NtSetInformationProcess() %x failed, Status: 0x%x\n", Status); return Status; } - + switch(ProcessInformationClass) { case ProcessSessionInformation: @@ -680,7 +680,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle, Access = PROCESS_SET_INFORMATION; break; } - + Status = ObReferenceObjectByHandle(ProcessHandle, Access, PsProcessType, @@ -715,11 +715,11 @@ NtSetInformationProcess(IN HANDLE ProcessHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(NT_SUCCESS(Status)) { PEPORT ExceptionPort; - + /* in case we had success reading from the buffer, verify the provided * LPC port handle */ @@ -732,7 +732,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle, if(NT_SUCCESS(Status)) { /* lock the process to be thread-safe! */ - + Status = PsLockProcess(Process, FALSE); if(NT_SUCCESS(Status)) { @@ -801,14 +801,14 @@ NtSetInformationProcess(IN HANDLE ProcessHandle, _SEH_END; break; } - + case ProcessSessionInformation: { PROCESS_SESSION_INFORMATION SessionInfo; Status = STATUS_SUCCESS; - + RtlZeroMemory(&SessionInfo, sizeof(SessionInfo)); - + _SEH_TRY { /* copy the structure to the stack */ @@ -819,11 +819,11 @@ NtSetInformationProcess(IN HANDLE ProcessHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(NT_SUCCESS(Status)) { /* we successfully copied the structure to the stack, continue processing */ - + /* * setting the session id requires the SeTcbPrivilege! */ @@ -835,7 +835,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle, Status = STATUS_PRIVILEGE_NOT_HELD; break; } - + /* FIXME - update the session id for the process token */ Status = PsLockProcess(Process, FALSE); @@ -870,7 +870,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle, } break; } - + case ProcessPriorityClass: { PROCESS_PRIORITY_CLASS ppc; @@ -884,14 +884,14 @@ NtSetInformationProcess(IN HANDLE ProcessHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(NT_SUCCESS(Status)) { } - + break; } - + case ProcessLdtInformation: case ProcessLdtSize: case ProcessIoPortHandlers: @@ -923,7 +923,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle, * PiQuerySystemProcessInformation * * DESCRIPTION - * Compute the size of a process+thread snapshot as + * Compute the size of a process+thread snapshot as * expected by NtQuerySystemInformation. * * RETURN VALUE @@ -945,16 +945,16 @@ PiQuerySystemProcessInformation(PVOID Buffer, PEPROCESS CurrentP; PLIST_ENTRY CurrentEntryT; PETHREAD CurrentT; - + ULONG RequiredSize = 0L; BOOLEAN SizeOnly = FALSE; ULONG SpiSize = 0L; - + PSYSTEM_PROCESS_INFORMATION pInfoP = (PSYSTEM_PROCESS_INFORMATION) SnapshotBuffer; PSYSTEM_PROCESS_INFORMATION pInfoPLast = NULL; PSYSTEM_THREAD_INFO pInfoT = NULL; - + /* Lock the process list. */ ExAcquireFastMutex(&PspActiveProcessMutex); @@ -991,14 +991,14 @@ PiQuerySystemProcessInformation(PVOID Buffer, SizeOnly = TRUE; continue; } - /* - * Get a reference to the + /* + * Get a reference to the * process descriptor we are * handling. */ CurrentP = CONTAINING_RECORD( CurrentEntryP, - EPROCESS, + EPROCESS, ProcessListEntry ); /* @@ -1015,9 +1015,9 @@ PiQuerySystemProcessInformation(PVOID Buffer, /* THREAD */ for ( pInfoT = & CurrentP->ThreadSysInfo [0], CurrentEntryT = CurrentP->ThreadListHead.Flink; - + (CurrentEntryT != & CurrentP->ThreadListHead); - + pInfoT = & CurrentP->ThreadSysInfo [pInfoP->ThreadCount], CurrentEntryT = CurrentEntryT->Flink ) @@ -1044,14 +1044,14 @@ PiQuerySystemProcessInformation(PVOID Buffer, SizeOnly = TRUE; continue; } - /* - * Get a reference to the + /* + * Get a reference to the * thread descriptor we are * handling. */ CurrentT = CONTAINING_RECORD( CurrentEntryT, - KTHREAD, + KTHREAD, ThreadListEntry ); /* @@ -1074,7 +1074,7 @@ PiQuerySystemProcessInformation(PVOID Buffer, pInfoT->State = CurrentT-> ; /* DWORD */ pInfoT->WaitReason = CurrentT-> ; /* KWAIT_REASON */ /* - * Count the number of threads + * Count the number of threads * this process has. */ ++ pInfoP->ThreadCount; @@ -1091,9 +1091,9 @@ PiQuerySystemProcessInformation(PVOID Buffer, */ pInfoPLast = pInfoP; /* - * Compute the offset of the + * Compute the offset of the * SYSTEM_PROCESS_INFORMATION - * descriptor in the snapshot + * descriptor in the snapshot * buffer for the next process. */ (ULONG) pInfoP += SpiSize; @@ -1120,7 +1120,7 @@ PiQuerySystemProcessInformation(PVOID Buffer, * Mark the end of the snapshot. */ pInfoP->RelativeOffset = 0L; - /* OK */ + /* OK */ return STATUS_SUCCESS; #endif } @@ -1144,7 +1144,7 @@ NtSetInformationThread (IN HANDLE ThreadHandle, HANDLE Handle; PVOID Address; }u; - + PAGED_CODE(); if (ThreadInformationClass <= MaxThreadInfoClass && @@ -1188,19 +1188,19 @@ NtSetInformationThread (IN HANDLE ThreadHandle, } KeSetPriorityThread(&Thread->Tcb, u.Priority); break; - + case ThreadBasePriority: KeSetBasePriorityThread (&Thread->Tcb, u.Increment); break; - + case ThreadAffinityMask: Status = KeSetAffinityThread(&Thread->Tcb, u.Affinity); break; - + case ThreadImpersonationToken: Status = PsAssignImpersonationToken (Thread, u.Handle); break; - + case ThreadQuerySetWin32StartAddress: Thread->Win32StartAddress = u.Address; break; @@ -1235,7 +1235,7 @@ NtQueryInformationThread (IN HANDLE ThreadHandle, LARGE_INTEGER Count; BOOLEAN Last; }u; - + PAGED_CODE(); if (ThreadInformationClass <= MaxThreadInfoClass && @@ -1268,7 +1268,7 @@ NtQueryInformationThread (IN HANDLE ThreadHandle, { case ThreadBasicInformation: /* A test on W2K agains ntdll shows NtQueryInformationThread return STATUS_PENDING - * as ExitStatus for current/running thread, while KETHREAD's ExitStatus is + * as ExitStatus for current/running thread, while KETHREAD's ExitStatus is * 0. So do the conversion here: * -Gunnar */ u.TBI.ExitStatus = (Thread->ExitStatus == 0) ? STATUS_PENDING : Thread->ExitStatus; @@ -1278,7 +1278,7 @@ NtQueryInformationThread (IN HANDLE ThreadHandle, u.TBI.Priority = Thread->Tcb.Priority; u.TBI.BasePriority = Thread->Tcb.BasePriority; break; - + case ThreadTimes: u.TTI.KernelTime.QuadPart = Thread->Tcb.KernelTime * 100000LL; u.TTI.UserTime.QuadPart = Thread->Tcb.UserTime * 100000LL; diff --git a/reactos/ntoskrnl/ps/quota.c b/reactos/ntoskrnl/ps/quota.c index 73015e76ff6..50a81f04669 100644 --- a/reactos/ntoskrnl/ps/quota.c +++ b/reactos/ntoskrnl/ps/quota.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ps/quota.c * PURPOSE: Process Pool Quotas - * + * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) */ @@ -30,7 +30,7 @@ PsChargePoolQuota(IN PEPROCESS Process, Status = PsChargeProcessPoolQuota(Process, PoolType, Amount); /* Raise Exception */ - if (!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { ExRaiseStatus(Status); } @@ -83,12 +83,12 @@ PsChargeProcessPoolQuota(IN PEPROCESS Process, NewUsageSize = QuotaBlock->QuotaEntry[PoolType].Usage + Amount; /* Does this size respect the quota? */ - if (NewUsageSize > QuotaBlock->QuotaEntry[PoolType].Limit) + if (NewUsageSize > QuotaBlock->QuotaEntry[PoolType].Limit) { /* It doesn't, so keep raising the Quota */ - while (MiRaisePoolQuota(PoolType, - QuotaBlock->QuotaEntry[PoolType].Limit, - &NewMaxQuota)) + while (MiRaisePoolQuota(PoolType, + QuotaBlock->QuotaEntry[PoolType].Limit, + &NewMaxQuota)) { /* Save new Maximum Quota */ QuotaBlock->QuotaEntry[PoolType].Limit = NewMaxQuota; @@ -105,7 +105,7 @@ QuotaChanged: QuotaBlock->QuotaEntry[PoolType].Usage = NewUsageSize; /* Is this a new peak? */ - if (NewUsageSize > QuotaBlock->QuotaEntry[PoolType].Peak) + if (NewUsageSize > QuotaBlock->QuotaEntry[PoolType].Peak) { QuotaBlock->QuotaEntry[PoolType].Peak = NewUsageSize; } @@ -116,7 +116,7 @@ QuotaChanged: /* * @unimplemented - */ + */ VOID STDCALL PsReturnPoolQuota(IN PEPROCESS Process, @@ -124,22 +124,22 @@ PsReturnPoolQuota(IN PEPROCESS Process, IN ULONG_PTR Amount) { UNIMPLEMENTED; -} +} /* * @unimplemented - */ + */ VOID STDCALL PsReturnProcessNonPagedPoolQuota(IN PEPROCESS Process, IN ULONG_PTR Amount) { UNIMPLEMENTED; -} +} /* * @unimplemented - */ + */ VOID STDCALL PsReturnProcessPagedPoolQuota(IN PEPROCESS Process, diff --git a/reactos/ntoskrnl/ps/security.c b/reactos/ntoskrnl/ps/security.c index a3dcae3ffe0..31190e1a4e6 100644 --- a/reactos/ntoskrnl/ps/security.c +++ b/reactos/ntoskrnl/ps/security.c @@ -22,9 +22,9 @@ PspLockProcessSecurityShared(PEPROCESS Process) { /* Enter a Guarded Region */ KeEnterGuardedRegion(); - + /* Lock the Process */ - //ExAcquirePushLockShared(&Process->ProcessLock); + //ExAcquirePushLockShared(&Process->ProcessLock); } /* FIXME: Turn into Macro */ @@ -34,7 +34,7 @@ PspUnlockProcessSecurityShared(PEPROCESS Process) { /* Unlock the Process */ //ExReleasePushLockShared(&Process->ProcessLock); - + /* Leave Guarded Region */ KeLeaveGuardedRegion(); } @@ -44,8 +44,8 @@ PspUnlockProcessSecurityShared(PEPROCESS Process) /* * @implemented */ -NTSTATUS -STDCALL +NTSTATUS +STDCALL NtOpenProcessToken(IN HANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, OUT PHANDLE TokenHandle) @@ -70,11 +70,11 @@ NtOpenProcessTokenEx(IN HANDLE ProcessHandle, HANDLE hToken; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); - + if(PreviousMode == UserMode) { _SEH_TRY @@ -119,35 +119,35 @@ NtOpenProcessTokenEx(IN HANDLE ProcessHandle, _SEH_END; } } - + return Status; } /* * @implemented */ -PACCESS_TOKEN +PACCESS_TOKEN STDCALL PsReferencePrimaryToken(PEPROCESS Process) { PACCESS_TOKEN Token; - + /* Fast Reference the Token */ Token = ObFastReferenceObject(&Process->Token); - + /* Check if we got the Token or if we got locked */ if (!Token) { /* Lock the Process */ PspLockProcessSecurityShared(Process); - + /* Do a Locked Fast Reference */ //Token = ObFastReferenceObjectLocked(&Process->Token); - + /* Unlock the Process */ PspUnlockProcessSecurityShared(Process); } - + /* Return the Token */ return Token; } @@ -162,7 +162,7 @@ PsOpenTokenOfProcess(HANDLE ProcessHandle, { PEPROCESS Process; NTSTATUS Status; - + /* Get the Token */ Status = ObReferenceObjectByHandle(ProcessHandle, PROCESS_QUERY_INFORMATION, @@ -170,14 +170,14 @@ PsOpenTokenOfProcess(HANDLE ProcessHandle, ExGetPreviousMode(), (PVOID*)&Process, NULL); - + /* Reference it */ if(NT_SUCCESS(Status)) { - + *Token = PsReferencePrimaryToken(Process); ObDereferenceObject(Process); } - + /* Return */ return Status; } @@ -188,10 +188,10 @@ PspInitializeProcessSecurity(PEPROCESS Process, PEPROCESS Parent OPTIONAL) { NTSTATUS Status = STATUS_SUCCESS; - + /* If we have a parent, then duplicate the Token */ if (Parent) { - + PTOKEN pNewToken; PTOKEN pParentToken; OBJECT_ATTRIBUTES ObjectAttributes; @@ -205,7 +205,7 @@ PspInitializeProcessSecurity(PEPROCESS Process, 0, NULL, NULL); - + /* Duplicate the Token */ Status = SepDuplicateToken(pParentToken, &ObjectAttributes, @@ -214,24 +214,24 @@ PspInitializeProcessSecurity(PEPROCESS Process, pParentToken->ImpersonationLevel, KernelMode, &pNewToken); - + if(!NT_SUCCESS(Status)) { - + DPRINT1("Failed to Duplicate Token\n"); return Status; } - + /* Dereference the Token */ ObFastDereferenceObject(&Parent->Token, pParentToken); - + /* Set the new Token */ ObInitializeFastReference(&Process->Token, pNewToken); - + } else { - + #ifdef SCHED_REWRITE PTOKEN BootToken; - + /* No parent, this is the Initial System Process. Assign Boot Token */ BootToken = SepCreateSystemProcessToken(); BootToken->TokenInUse = TRUE; @@ -241,7 +241,7 @@ PspInitializeProcessSecurity(PEPROCESS Process, DPRINT1("PspInitializeProcessSecurity called with no parent.\n"); #endif } - + /* Return to caller */ return Status; } @@ -255,7 +255,7 @@ PspAssignPrimaryToken(PEPROCESS Process, PACCESS_TOKEN Token; PACCESS_TOKEN OldToken; NTSTATUS Status; - + /* Reference the Token */ Status = ObReferenceObjectByHandle(TokenHandle, 0, @@ -267,10 +267,10 @@ PspAssignPrimaryToken(PEPROCESS Process, return(Status); } - + /* Exchange them */ Status = SeExchangePrimaryToken(Process, Token, &OldToken); - + /* Derefernece Tokens and Return */ ObDereferenceObject(Token); return(Status); @@ -279,7 +279,7 @@ PspAssignPrimaryToken(PEPROCESS Process, /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL PsAssignImpersonationToken(PETHREAD Thread, HANDLE TokenHandle) @@ -296,16 +296,16 @@ PsAssignImpersonationToken(PETHREAD Thread, KeGetPreviousMode(), (PVOID*)&Token, NULL); - + if (!NT_SUCCESS(Status)) { - + return(Status); } - + ImpersonationLevel = SeTokenImpersonationLevel(Token); - + } else { - + Token = NULL; ImpersonationLevel = 0; } @@ -315,7 +315,7 @@ PsAssignImpersonationToken(PETHREAD Thread, FALSE, FALSE, ImpersonationLevel); - + if (Token != NULL) ObDereferenceObject(Token); return(STATUS_SUCCESS); } @@ -337,7 +337,7 @@ STDCALL PsRevertThreadToSelf(IN PETHREAD Thread) { if (Thread->ActiveImpersonationInfo == TRUE) { - + ObDereferenceObject (Thread->ImpersonationInfo->Token); Thread->ActiveImpersonationInfo = FALSE; } @@ -346,7 +346,7 @@ PsRevertThreadToSelf(IN PETHREAD Thread) /* * @implemented */ -VOID +VOID STDCALL PsImpersonateClient(IN PETHREAD Thread, IN PACCESS_TOKEN Token, @@ -354,24 +354,24 @@ PsImpersonateClient(IN PETHREAD Thread, IN BOOLEAN EffectiveOnly, IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel) { - + if (Token == NULL) { - + if (Thread->ActiveImpersonationInfo == TRUE) { - + Thread->ActiveImpersonationInfo = FALSE; - + if (Thread->ImpersonationInfo->Token != NULL) { - + ObDereferenceObject (Thread->ImpersonationInfo->Token); } } - + return; } if (Thread->ImpersonationInfo == NULL) { - + Thread->ImpersonationInfo = ExAllocatePool(NonPagedPool, sizeof(PS_IMPERSONATION_INFORMATION)); } @@ -380,12 +380,12 @@ PsImpersonateClient(IN PETHREAD Thread, Thread->ImpersonationInfo->CopyOnOpen = CopyOnOpen; Thread->ImpersonationInfo->EffectiveOnly = EffectiveOnly; Thread->ImpersonationInfo->Token = Token; - + ObReferenceObjectByPointer(Token, 0, SepTokenObjectType, KernelMode); - + Thread->ActiveImpersonationInfo = TRUE; } @@ -399,41 +399,41 @@ PsReferenceEffectiveToken(PETHREAD Thread, { PEPROCESS Process; PACCESS_TOKEN Token; - - if (Thread->ActiveImpersonationInfo == FALSE) - { + + if (Thread->ActiveImpersonationInfo == FALSE) + { Process = Thread->ThreadsProcess; *TokenType = TokenPrimary; *EffectiveOnly = FALSE; - + /* Fast Reference the Token */ Token = ObFastReferenceObject(&Process->Token); - + /* Check if we got the Token or if we got locked */ if (!Token) { /* Lock the Process */ PspLockProcessSecurityShared(Process); - + /* Do a Locked Fast Reference */ //Token = ObFastReferenceObjectLocked(&Process->Token); - + /* Unlock the Process */ PspUnlockProcessSecurityShared(Process); - } - } - else + } + } + else { Token = Thread->ImpersonationInfo->Token; *TokenType = TokenImpersonation; *EffectiveOnly = Thread->ImpersonationInfo->EffectiveOnly; *Level = Thread->ImpersonationInfo->ImpersonationLevel; } - + return Token; } -NTSTATUS +NTSTATUS STDCALL NtImpersonateThread(IN HANDLE ThreadHandle, IN HANDLE ThreadToImpersonateHandle, @@ -445,11 +445,11 @@ NtImpersonateThread(IN HANDLE ThreadHandle, PETHREAD ThreadToImpersonate; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); - + if(PreviousMode != KernelMode) { _SEH_TRY @@ -465,7 +465,7 @@ NtImpersonateThread(IN HANDLE ThreadHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -513,23 +513,23 @@ NtImpersonateThread(IN HANDLE ThreadHandle, /* * @implemented */ -PACCESS_TOKEN +PACCESS_TOKEN STDCALL PsReferenceImpersonationToken(IN PETHREAD Thread, OUT PBOOLEAN CopyOnOpen, OUT PBOOLEAN EffectiveOnly, OUT PSECURITY_IMPERSONATION_LEVEL ImpersonationLevel) { - + if (Thread->ActiveImpersonationInfo == FALSE) { - + return NULL; } *ImpersonationLevel = Thread->ImpersonationInfo->ImpersonationLevel; *CopyOnOpen = Thread->ImpersonationInfo->CopyOnOpen; *EffectiveOnly = Thread->ImpersonationInfo->EffectiveOnly; - + ObReferenceObjectByPointer(Thread->ImpersonationInfo->Token, TOKEN_ALL_ACCESS, SepTokenObjectType, @@ -549,7 +549,7 @@ STDCALL PsDereferenceImpersonationToken(IN PACCESS_TOKEN ImpersonationToken) { if (ImpersonationToken) { - + ObDereferenceObject(ImpersonationToken); } } @@ -600,19 +600,19 @@ PsDisableImpersonation(IN PETHREAD Thread, /* * @implemented - */ + */ VOID STDCALL PsRestoreImpersonation(IN PETHREAD Thread, IN PSE_IMPERSONATION_STATE ImpersonationState) { - - PsImpersonateClient(Thread, + + PsImpersonateClient(Thread, ImpersonationState->Token, ImpersonationState->CopyOnOpen, ImpersonationState->EffectiveOnly, ImpersonationState->Level); - + ObfDereferenceObject(ImpersonationState->Token); } diff --git a/reactos/ntoskrnl/ps/suspend.c b/reactos/ntoskrnl/ps/suspend.c index 5e73015379c..3b50812ef3b 100644 --- a/reactos/ntoskrnl/ps/suspend.c +++ b/reactos/ntoskrnl/ps/suspend.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/ps/suspend.c * PURPOSE: Thread managment - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -22,7 +22,7 @@ KeResumeThread(PKTHREAD Thread); /* * FUNCTION: Decrements a thread's resume count - * ARGUMENTS: + * ARGUMENTS: * ThreadHandle = Handle to the thread that should be resumed * ResumeCount = The resulting resume count. * RETURNS: Status @@ -36,26 +36,26 @@ NtResumeThread(IN HANDLE ThreadHandle, ULONG Prev; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); DPRINT("NtResumeThead(ThreadHandle %lx SuspendCount %p)\n", ThreadHandle, SuspendCount); - + /* Check buffer validity */ if(SuspendCount && PreviousMode == UserMode) { - + _SEH_TRY { - + ProbeForWrite(SuspendCount, sizeof(ULONG), sizeof(ULONG)); } _SEH_HANDLE { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; if(!NT_SUCCESS(Status)) return Status; @@ -69,24 +69,24 @@ NtResumeThread(IN HANDLE ThreadHandle, (PVOID*)&Thread, NULL); if (!NT_SUCCESS(Status)) { - + return Status; } - + /* Call the Kernel Function */ Prev = KeResumeThread(&Thread->Tcb); - - /* Return it */ + + /* Return it */ if(SuspendCount) { - + _SEH_TRY { - + *SuspendCount = Prev; - + } _SEH_HANDLE { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } @@ -97,18 +97,18 @@ NtResumeThread(IN HANDLE ThreadHandle, /* * FUNCTION: Increments a thread's suspend count - * ARGUMENTS: + * ARGUMENTS: * ThreadHandle = Handle to the thread that should be resumed * PreviousSuspendCount = The resulting/previous suspend count. * REMARK: - * A thread will be suspended if its suspend count is greater than 0. - * This procedure maps to the win32 SuspendThread function. ( + * A thread will be suspended if its suspend count is greater than 0. + * This procedure maps to the win32 SuspendThread function. ( * documentation about the the suspend count can be found here aswell ) - * The suspend count is not increased if it is greater than + * The suspend count is not increased if it is greater than * MAXIMUM_SUSPEND_COUNT. * RETURNS: Status */ -NTSTATUS +NTSTATUS STDCALL NtSuspendThread(IN HANDLE ThreadHandle, IN PULONG PreviousSuspendCount OPTIONAL) @@ -117,23 +117,23 @@ NtSuspendThread(IN HANDLE ThreadHandle, ULONG Prev; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); - + /* Check buffer validity */ if(PreviousSuspendCount && PreviousMode == UserMode) { - + _SEH_TRY { - + ProbeForWrite(PreviousSuspendCount, sizeof(ULONG), sizeof(ULONG)); } _SEH_HANDLE { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; if(!NT_SUCCESS(Status)) return Status; @@ -147,24 +147,24 @@ NtSuspendThread(IN HANDLE ThreadHandle, (PVOID*)&Thread, NULL); if (!NT_SUCCESS(Status)) { - + return Status; } - + /* Call the Kernel Function */ Prev = KeSuspendThread(&Thread->Tcb); - - /* Return it */ + + /* Return it */ if(PreviousSuspendCount) { - + _SEH_TRY { - + *PreviousSuspendCount = Prev; - + } _SEH_HANDLE { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } @@ -184,11 +184,11 @@ NtSuspendProcess(IN HANDLE ProcessHandle) KPROCESSOR_MODE PreviousMode; PEPROCESS Process; NTSTATUS Status; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); - + Status = ObReferenceObjectByHandle(ProcessHandle, PROCESS_SUSPEND_RESUME, PsProcessType, @@ -200,10 +200,10 @@ NtSuspendProcess(IN HANDLE ProcessHandle) /* FIXME */ Status = STATUS_NOT_IMPLEMENTED; DPRINT1("NtSuspendProcess not yet implemented!\n"); - + ObDereferenceObject(Process); } - + return Status; } @@ -234,7 +234,7 @@ NtResumeProcess(IN HANDLE ProcessHandle) /* FIXME */ Status = STATUS_NOT_IMPLEMENTED; DPRINT1("NtResumeProcess not yet implemented!\n"); - + ObDereferenceObject(Process); } diff --git a/reactos/ntoskrnl/ps/thread.c b/reactos/ntoskrnl/ps/thread.c index 8e7e0971c5e..6bfb29e7376 100644 --- a/reactos/ntoskrnl/ps/thread.c +++ b/reactos/ntoskrnl/ps/thread.c @@ -20,7 +20,7 @@ extern LIST_ENTRY PsActiveProcessHead; extern PEPROCESS PsIdleProcess; POBJECT_TYPE EXPORTED PsThreadType = NULL; - + /* FUNCTIONS ***************************************************************/ VOID @@ -41,16 +41,16 @@ PspUserThreadStartup(PKSTART_ROUTINE StartRoutine, { PKAPC ThreadApc; PETHREAD Thread = PsGetCurrentThread(); - + DPRINT("I am a new USER thread. This is my start routine: %p. This my context: %p." "This is my IRQL: %d. This is my Thread Pointer: %x.\n", StartRoutine, StartContext, KeGetCurrentIrql(), Thread); - + if (!Thread->Terminated) { - + /* Allocate the APC */ ThreadApc = ExAllocatePoolWithTag(NonPagedPool, sizeof(KAPC), TAG('T', 'h', 'r','d')); - + /* Initialize it */ KeInitializeApc(ThreadApc, &Thread->Tcb, @@ -60,12 +60,12 @@ PspUserThreadStartup(PKSTART_ROUTINE StartRoutine, LdrpGetSystemDllEntryPoint(), UserMode, NULL); - + /* Insert it into the queue */ KeInsertQueueApc(ThreadApc, NULL, NULL, IO_NO_INCREMENT); Thread->Tcb.ApcState.UserApcPending = TRUE; } - + /* Go to Passive Level and notify debugger */ KeLowerIrql(PASSIVE_LEVEL); DbgkCreateThread(StartContext); @@ -77,17 +77,17 @@ PspSystemThreadStartup(PKSTART_ROUTINE StartRoutine, PVOID StartContext) { PETHREAD Thread = PsGetCurrentThread(); - + /* Unlock the dispatcher Database */ KeLowerIrql(PASSIVE_LEVEL); - + /* Make sure it's not terminated by now */ if (!Thread->Terminated) { - + /* Call it */ (StartRoutine)(StartContext); } - + /* Exit the thread */ PspExitThread(STATUS_SUCCESS); } @@ -114,11 +114,11 @@ PspCreateThread(OUT PHANDLE ThreadHandle, KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status; PVOID KernelStack; - + /* Reference the Process by handle or pointer, depending on what we got */ DPRINT("PspCreateThread: %x, %x, %x\n", ProcessHandle, TargetProcess, ThreadContext); if (ProcessHandle) { - + /* Normal thread or System Thread */ DPRINT("Referencing Parent Process\n"); Status = ObReferenceObjectByHandle(ProcessHandle, @@ -128,30 +128,30 @@ PspCreateThread(OUT PHANDLE ThreadHandle, (PVOID*)&Process, NULL); } else { - + /* System thread inside System Process, or Normal Thread with a bug */ if (StartRoutine) { - + /* Reference the Process by Pointer */ DPRINT("Referencing Parent System Process\n"); ObReferenceObject(TargetProcess); Process = TargetProcess; Status = STATUS_SUCCESS; - + } else { - + /* Fake ObReference returning this */ Status = STATUS_INVALID_HANDLE; } } - + /* Check for success */ if(!NT_SUCCESS(Status)) { - + DPRINT1("Invalid Process Handle, or no handle given\n"); return(Status); } - + /* Create Thread Object */ DPRINT("Creating Thread Object\n"); Status = ObCreateObject(PreviousMode, @@ -163,120 +163,120 @@ PspCreateThread(OUT PHANDLE ThreadHandle, 0, 0, (PVOID*)&Thread); - + /* Check for success */ if (!NT_SUCCESS(Status)) { - + /* Dereference the Process */ DPRINT1("Failed to Create Thread Object\n"); ObDereferenceObject(Process); return(Status); } - + /* Zero the Object entirely */ DPRINT("Cleaning Thread Object\n"); RtlZeroMemory(Thread, sizeof(ETHREAD)); - + /* Create Cid Handle */ DPRINT("Creating Thread Handle (CID)\n"); if (!(NT_SUCCESS(PsCreateCidHandle(Thread, PsThreadType, &Thread->Cid.UniqueThread)))) { - + DPRINT1("Failed to create Thread Handle (CID)\n"); ObDereferenceObject(Process); ObDereferenceObject(Thread); return Status; } - + /* Initialize Lists */ DPRINT("Initialliazing Thread Lists and Locks\n"); InitializeListHead(&Thread->LpcReplyChain); InitializeListHead(&Thread->IrpList); InitializeListHead(&Thread->ActiveTimerListHead); KeInitializeSpinLock(&Thread->ActiveTimerListLock); - + /* Initialize LPC */ DPRINT("Initialliazing Thread Semaphore\n"); KeInitializeSemaphore(&Thread->LpcReplySemaphore, 0, LONG_MAX); - + /* Allocate Stack for non-GUI Thread */ DPRINT("Initialliazing Thread Stack\n"); KernelStack = MmCreateKernelStack(FALSE); - + /* Set the Process CID */ DPRINT("Initialliazing Thread PID and Parent Process\n"); Thread->Cid.UniqueProcess = Process->UniqueProcessId; Thread->ThreadsProcess = Process; - + /* Now let the kernel initialize the context */ if (ThreadContext) { - + /* User-mode Thread */ - + /* Create Teb */ DPRINT("Initialliazing Thread PEB\n"); TebBase = MmCreateTeb(Process, &Thread->Cid, InitialTeb); - + /* Set the Start Addresses */ DPRINT("Initialliazing Thread Start Addresses :%x, %x\n", ThreadContext->Eip, ThreadContext->Eax); Thread->StartAddress = (PVOID)ThreadContext->Eip; Thread->Win32StartAddress = (PVOID)ThreadContext->Eax; - + /* Let the kernel intialize the Thread */ DPRINT("Initialliazing Kernel Thread\n"); - KeInitializeThread(&Process->Pcb, - &Thread->Tcb, + KeInitializeThread(&Process->Pcb, + &Thread->Tcb, PspUserThreadStartup, NULL, NULL, ThreadContext, TebBase, - KernelStack); - + KernelStack); + } else { - + /* System Thread */ DPRINT("Initialliazing Thread Start Address :%x\n", StartRoutine); Thread->StartAddress = StartRoutine; Thread->SystemThread = TRUE; - + /* Let the kernel intialize the Thread */ DPRINT("Initialliazing Kernel Thread\n"); - KeInitializeThread(&Process->Pcb, - &Thread->Tcb, + KeInitializeThread(&Process->Pcb, + &Thread->Tcb, PspSystemThreadStartup, StartRoutine, StartContext, NULL, NULL, - KernelStack); + KernelStack); } - /* - * Insert the Thread into the Process's Thread List + /* + * Insert the Thread into the Process's Thread List * Note, this is the ETHREAD Thread List. It is removed in * ps/kill.c!PspExitThread. */ DPRINT("Inserting into Process Thread List \n"); InsertTailList(&Process->ThreadListHead, &Thread->ThreadListEntry); - + /* Notify Thread Creation */ DPRINT("Running Thread Notify \n"); PspRunCreateThreadNotifyRoutines(Thread, TRUE); - + /* FIXME: Use Lock */ DPRINT("Apcs Queueable: %d \n", Thread->Tcb.ApcQueueable); Thread->Tcb.ApcQueueable = TRUE; - + /* Suspend the Thread if we have to */ if (CreateSuspended) { DPRINT("Suspending Thread\n"); KeSuspendThread(&Thread->Tcb); } - + /* Reference ourselves as a keep-alive */ ObReferenceObject(Thread); - + /* Insert the Thread into the Object Manager */ DPRINT("Inserting Thread\n"); Status = ObInsertObject((PVOID)Thread, @@ -285,35 +285,35 @@ PspCreateThread(OUT PHANDLE ThreadHandle, 0, NULL, &hThread); - + /* Return Cid and Handle */ DPRINT("All worked great!\n"); if(NT_SUCCESS(Status)) { - + _SEH_TRY { - + if(ClientId != NULL) { - + *ClientId = Thread->Cid; } *ThreadHandle = hThread; - + } _SEH_HANDLE { - + Status = _SEH_GetExceptionCode(); - + } _SEH_END; } - + /* FIXME: SECURITY */ - + /* Dispatch thread */ DPRINT("About to dispatch the thread: %x!\n", &Thread->Tcb); OldIrql = KeAcquireDispatcherDatabaseLock (); KiUnblockThread(&Thread->Tcb, NULL, 0); ObDereferenceObject(Thread); KeReleaseDispatcherDatabaseLock(OldIrql); - + /* Return */ DPRINT("Returning\n"); return Status; @@ -322,7 +322,7 @@ PspCreateThread(OUT PHANDLE ThreadHandle, /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL PsCreateSystemThread(PHANDLE ThreadHandle, ACCESS_MASK DesiredAccess, @@ -333,15 +333,15 @@ PsCreateSystemThread(PHANDLE ThreadHandle, PVOID StartContext) { PEPROCESS TargetProcess = NULL; - HANDLE Handle = ProcessHandle; - + HANDLE Handle = ProcessHandle; + /* Check if we have a handle. If not, use the System Process */ if (!ProcessHandle) { - + Handle = NULL; TargetProcess = PsInitialSystemProcess; } - + /* Call the shared function */ return PspCreateThread(ThreadHandle, DesiredAccess, @@ -359,8 +359,8 @@ PsCreateSystemThread(PHANDLE ThreadHandle, /* * @implemented */ -HANDLE -STDCALL +HANDLE +STDCALL PsGetCurrentThreadId(VOID) { return(PsGetCurrentThread()->Cid.UniqueThread); @@ -479,7 +479,7 @@ PsGetCurrentThreadStackLimit(VOID) /* * @implemented */ -BOOLEAN +BOOLEAN STDCALL PsIsThreadTerminating(IN PETHREAD Thread) { @@ -508,7 +508,7 @@ PsIsThreadImpersonating(PETHREAD Thread) /* * @implemented - */ + */ VOID STDCALL PsSetThreadHardErrorsAreDisabled(PETHREAD Thread, @@ -519,7 +519,7 @@ PsSetThreadHardErrorsAreDisabled(PETHREAD Thread, /* * @implemented - */ + */ VOID STDCALL PsSetThreadWin32Thread(PETHREAD Thread, @@ -528,7 +528,7 @@ PsSetThreadWin32Thread(PETHREAD Thread, Thread->Tcb.Win32Thread = Win32Thread; } -NTSTATUS +NTSTATUS STDCALL NtCreateThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, @@ -540,54 +540,54 @@ NtCreateThread(OUT PHANDLE ThreadHandle, IN BOOLEAN CreateSuspended) { INITIAL_TEB SafeInitialTeb; - + PAGED_CODE(); - + DPRINT("NtCreateThread(ThreadHandle %x, PCONTEXT %x)\n", ThreadHandle,ThreadContext); - + if(KeGetPreviousMode() != KernelMode) { - + _SEH_TRY { - + ProbeForWrite(ThreadHandle, sizeof(HANDLE), sizeof(ULONG)); - + if(ClientId != NULL) { - + ProbeForWrite(ClientId, sizeof(CLIENT_ID), sizeof(ULONG)); } - + if(ThreadContext != NULL) { - + ProbeForRead(ThreadContext, sizeof(CONTEXT), sizeof(ULONG)); - + } else { - + DPRINT1("No context for User-Mode Thread!!\n"); return STATUS_INVALID_PARAMETER; } - + ProbeForRead(InitialTeb, sizeof(INITIAL_TEB), sizeof(ULONG)); - + } _SEH_HANDLE { - + return _SEH_GetExceptionCode(); - + } _SEH_END; } - + /* Use probed data for the Initial TEB */ SafeInitialTeb = *InitialTeb; InitialTeb = &SafeInitialTeb; - + /* Call the shared function */ return PspCreateThread(ThreadHandle, DesiredAccess, @@ -605,7 +605,7 @@ NtCreateThread(OUT PHANDLE ThreadHandle, /* * @implemented */ -NTSTATUS +NTSTATUS STDCALL NtOpenThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, @@ -628,13 +628,13 @@ NtOpenThread(OUT PHANDLE ThreadHandle, ProbeForWrite(ThreadHandle, sizeof(HANDLE), sizeof(ULONG)); - + if(ClientId != NULL) { ProbeForRead(ClientId, sizeof(CLIENT_ID), sizeof(ULONG)); - + SafeClientId = *ClientId; ClientId = &SafeClientId; } @@ -642,7 +642,7 @@ NtOpenThread(OUT PHANDLE ThreadHandle, _SEH_HANDLE { Status = _SEH_GetExceptionCode(); - } + } _SEH_END; if(!NT_SUCCESS(Status)) return Status; @@ -659,12 +659,12 @@ NtOpenThread(OUT PHANDLE ThreadHandle, DesiredAccess, NULL, hThread); - + if (Status != STATUS_SUCCESS) { DPRINT1("Could not open object by name\n"); } - + /* Return Status */ return(Status); } @@ -679,21 +679,21 @@ NtOpenThread(OUT PHANDLE ThreadHandle, Status = PsLookupProcessThreadByCid(ClientId, NULL, &Thread); - } - else + } + else { /* Get the Process */ DPRINT("Opening by Thread ID: %x\n", ClientId->UniqueThread); Status = PsLookupThreadByThreadId(ClientId->UniqueThread, &Thread); } - + if(!NT_SUCCESS(Status)) { DPRINT1("Failure to find Thread\n"); return Status; } - + /* Open the Thread Object */ Status = ObOpenObjectByPointer(Thread, ObjectAttributes->Attributes, @@ -706,7 +706,7 @@ NtOpenThread(OUT PHANDLE ThreadHandle, { DPRINT1("Failure to open Thread\n"); } - + /* Dereference the thread */ ObDereferenceObject(Thread); } @@ -729,7 +729,7 @@ NtOpenThread(OUT PHANDLE ThreadHandle, return Status; } -NTSTATUS +NTSTATUS STDCALL NtYieldExecution(VOID) { @@ -737,7 +737,7 @@ NtYieldExecution(VOID) return(STATUS_SUCCESS); } -NTSTATUS +NTSTATUS STDCALL NtTestAlert(VOID) { @@ -748,7 +748,7 @@ NtTestAlert(VOID) /* * @implemented */ -KPROCESSOR_MODE +KPROCESSOR_MODE STDCALL ExGetPreviousMode (VOID) { diff --git a/reactos/ntoskrnl/ps/win32.c b/reactos/ntoskrnl/ps/win32.c index 2a0a5570763..50ce36fc887 100644 --- a/reactos/ntoskrnl/ps/win32.c +++ b/reactos/ntoskrnl/ps/win32.c @@ -91,7 +91,7 @@ PsEstablishWin32Callouts (PW32_PROCESS_CALLBACK W32ProcessCallback, PspWin32ProcessSize = W32ProcessSize; PspWin32ThreadSize = W32ThreadSize; - + ExpWindowStationObjectCreate = W32ObjectCallback->WinStaCreate; ExpWindowStationObjectParse = W32ObjectCallback->WinStaParse; ExpWindowStationObjectDelete = W32ObjectCallback->WinStaDelete; @@ -194,7 +194,7 @@ STDCALL ULONG i, j; PHYSICAL_ADDRESS BoundaryAddressMultiple; PPFN_TYPE Pages = alloca(sizeof(PFN_TYPE) * (StackSize /PAGE_SIZE)); - + DPRINT1("PsAllocateCallbackStack\n"); BoundaryAddressMultiple.QuadPart = 0; StackSize = PAGE_ROUND_UP(StackSize); @@ -244,7 +244,7 @@ STDCALL return(KernelStack); } -NTSTATUS +NTSTATUS STDCALL NtW32Call(IN ULONG RoutineIndex, IN PVOID Argument, @@ -253,22 +253,22 @@ NtW32Call(IN ULONG RoutineIndex, OUT PULONG ResultLength OPTIONAL) { NTSTATUS CallbackStatus; - + DPRINT("NtW32Call(RoutineIndex %d, Argument %X, ArgumentLength %d)\n", RoutineIndex, Argument, ArgumentLength); - + /* FIXME: SEH!!! */ - + /* Call kernel function */ CallbackStatus = KeUserModeCallback(RoutineIndex, Argument, ArgumentLength, Result, ResultLength); - + /* Return the result */ return(CallbackStatus); -} +} #ifndef ALEX_CB_REWRITE NTSTATUS STDCALL @@ -289,7 +289,7 @@ NtCallbackReturn (PVOID Result, PKTRAP_FRAME SavedTrapFrame; PVOID SavedCallbackStack; PVOID SavedExceptionStack; - + PAGED_CODE(); Thread = PsGetCurrentThread(); @@ -303,7 +303,7 @@ NtCallbackReturn (PVOID Result, /* * Get the values that NtW32Call left on the inactive stack for us. */ - State = (PNTW32CALL_SAVED_STATE)OldStack[0]; + State = (PNTW32CALL_SAVED_STATE)OldStack[0]; CallbackStatus = State->CallbackStatus; CallerResultLength = State->CallerResultLength; CallerResult = State->CallerResult; diff --git a/reactos/ntoskrnl/rtl/atom.c b/reactos/ntoskrnl/rtl/atom.c index d3f897fe3ed..00500c58cbe 100644 --- a/reactos/ntoskrnl/rtl/atom.c +++ b/reactos/ntoskrnl/rtl/atom.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/rtl/atom.c * PURPOSE: Atom managment - * + * * PROGRAMMERS: No programmer listed. */ @@ -594,7 +594,7 @@ RtlQueryAtomInAtomTable(IN PRTL_ATOM_TABLE AtomTable, *PinCount = 1; } - Length = swprintf(TempAtomName, L"#%lu", (ULONG)Atom); + Length = swprintf(TempAtomName, L"#%lu", (ULONG)Atom); if (NameLength != NULL) { diff --git a/reactos/ntoskrnl/rtl/capture.c b/reactos/ntoskrnl/rtl/capture.c index f569d232762..b138d8bd1ca 100644 --- a/reactos/ntoskrnl/rtl/capture.c +++ b/reactos/ntoskrnl/rtl/capture.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/rtl/capture.c * PURPOSE: Helper routines for system calls. - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -25,17 +25,17 @@ RtlCaptureUnicodeString(OUT PUNICODE_STRING Dest, { UNICODE_STRING Src; NTSTATUS Status = STATUS_SUCCESS; - + ASSERT(Dest != NULL); - + /* * Copy the source string structure to kernel space. */ - + if(CurrentMode == UserMode) { RtlZeroMemory(&Src, sizeof(Src)); - + _SEH_TRY { ProbeForRead(UnsafeSrc, @@ -54,7 +54,7 @@ RtlCaptureUnicodeString(OUT PUNICODE_STRING Dest, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -71,7 +71,7 @@ RtlCaptureUnicodeString(OUT PUNICODE_STRING Dest, /* capture the string even though it is considered to be valid */ Src = *UnsafeSrc; } - + /* * Initialize the destination string. */ @@ -99,7 +99,7 @@ RtlCaptureUnicodeString(OUT PUNICODE_STRING Dest, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { ExFreePool(Dest->Buffer); @@ -112,7 +112,7 @@ RtlCaptureUnicodeString(OUT PUNICODE_STRING Dest, Dest->MaximumLength = 0; Dest->Buffer = NULL; } - + return Status; } diff --git a/reactos/ntoskrnl/rtl/ctype.c b/reactos/ntoskrnl/rtl/ctype.c index 3366e1b4b6b..79004133168 100644 --- a/reactos/ntoskrnl/rtl/ctype.c +++ b/reactos/ntoskrnl/rtl/ctype.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/rtl/ctype.c * PURPOSE: Character type and conversion functions - * + * * PROGRAMMERS: Eric Kohl */ #undef __MSVCRT__ diff --git a/reactos/ntoskrnl/rtl/debug.c b/reactos/ntoskrnl/rtl/debug.c index e6c6b127e73..5d6246a4ce0 100644 --- a/reactos/ntoskrnl/rtl/debug.c +++ b/reactos/ntoskrnl/rtl/debug.c @@ -3,7 +3,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/rtl/dbgprint.c * PURPOSE: Debug output - * + * * PROGRAMMERS: Eric Kohl (ekohl@abo.rhein-zeitung.de) */ @@ -23,7 +23,7 @@ /* * @implemented */ -ULONG +ULONG DbgPrint(PCH Format, ...) { ANSI_STRING DebugString; @@ -129,7 +129,7 @@ DbgPrintReturnControlC(PCH Format, /* * @unimplemented */ -VOID +VOID STDCALL DbgPrompt(PCH OutputString, PCH InputString, @@ -137,11 +137,11 @@ DbgPrompt(PCH OutputString, { ANSI_STRING Output; ANSI_STRING Input; - + Input.Length = 0; Input.MaximumLength = InputSize; Input.Buffer = InputString; - + Output.Length = strlen (OutputString); Output.MaximumLength = Output.Length + 1; Output.Buffer = OutputString; @@ -181,7 +181,7 @@ DbgSetDebugFilterState(IN ULONG ComponentId, NTSTATUS STDCALL DbgLoadImageSymbols(IN PUNICODE_STRING Name, - IN ULONG Base, + IN ULONG Base, IN ULONG Unknown3) { UNIMPLEMENTED; diff --git a/reactos/ntoskrnl/rtl/handle.c b/reactos/ntoskrnl/rtl/handle.c index 3765367ee7c..8bd7df97b25 100644 --- a/reactos/ntoskrnl/rtl/handle.c +++ b/reactos/ntoskrnl/rtl/handle.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/rtl/handle.c * PURPOSE: Handle table - * + * * PROGRAMMERS: Eric Kohl */ @@ -114,14 +114,14 @@ RtlpFreeHandle(PRTL_HANDLE_TABLE HandleTable, &Handle, Index)) return FALSE; - + /* clear handle */ memset(Handle, 0, sizeof(RTL_HANDLE)); - + /* add handle to free list */ Handle->Next = HandleTable->FirstFree; HandleTable->FirstFree = Handle; - + return TRUE; } diff --git a/reactos/ntoskrnl/rtl/libsupp.c b/reactos/ntoskrnl/rtl/libsupp.c index 900ba741139..9256456c087 100644 --- a/reactos/ntoskrnl/rtl/libsupp.c +++ b/reactos/ntoskrnl/rtl/libsupp.c @@ -23,8 +23,8 @@ KPROCESSOR_MODE RtlpGetMode() -{ - return KernelMode; +{ + return KernelMode; } /* @@ -53,7 +53,7 @@ RtlpCurrentPeb(VOID) return ((PEPROCESS)(KeGetCurrentThread()->ApcState.Process))->Peb; } -NTSTATUS +NTSTATUS STDCALL RtlDeleteCriticalSection( PRTL_CRITICAL_SECTION CriticalSection) @@ -98,7 +98,7 @@ RtlLeaveCriticalSection( return STATUS_SUCCESS; } -BOOLEAN +BOOLEAN STDCALL RtlTryEnterCriticalSection( PRTL_CRITICAL_SECTION CriticalSection) diff --git a/reactos/ntoskrnl/rtl/misc.c b/reactos/ntoskrnl/rtl/misc.c index 311db1df9de..72432f498ea 100644 --- a/reactos/ntoskrnl/rtl/misc.c +++ b/reactos/ntoskrnl/rtl/misc.c @@ -1,10 +1,10 @@ -/* $Id:$ +/* $Id$ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/rtl/misc.c * PURPOSE: Various functions - * + * * PROGRAMMERS: Hartmut Birr */ diff --git a/reactos/ntoskrnl/rtl/nls.c b/reactos/ntoskrnl/rtl/nls.c index 82e6729f645..3b85ea6156e 100644 --- a/reactos/ntoskrnl/rtl/nls.c +++ b/reactos/ntoskrnl/rtl/nls.c @@ -35,31 +35,31 @@ ULONG NlsUnicodeTableOffset = 0; /* FUNCTIONS *****************************************************************/ -VOID +VOID INIT_FUNCTION STDCALL RtlpInitNls(VOID) { ULONG_PTR BaseAddress; - - /* Import NLS Data */ + + /* Import NLS Data */ BaseAddress = CachedModules[AnsiCodepage]->ModStart; RtlpImportAnsiCodePage((PUSHORT)BaseAddress, CachedModules[AnsiCodepage]->ModEnd - BaseAddress); - + BaseAddress = CachedModules[OemCodepage]->ModStart; RtlpImportOemCodePage((PUSHORT)BaseAddress, CachedModules[OemCodepage]->ModEnd - BaseAddress); - + BaseAddress = CachedModules[UnicodeCasemap]->ModStart; RtlpImportUnicodeCasemap((PUSHORT)BaseAddress, CachedModules[UnicodeCasemap]->ModEnd - BaseAddress); - + /* Create initial NLS tables */ RtlpCreateInitialNlsTables(); - + /* Create the NLS section */ - RtlpCreateNlsSection(); + RtlpCreateNlsSection(); } VOID INIT_FUNCTION @@ -149,7 +149,7 @@ RtlpCreateNlsSection(VOID) KEBUGCHECKEX(0x32, Status, 1, 3, 0); } - DPRINT("NlsSection: Base %p Size %lx\n", + DPRINT("NlsSection: Base %p Size %lx\n", NlsSectionBase, NlsSectionViewSize); diff --git a/reactos/ntoskrnl/rtl/purecall.c b/reactos/ntoskrnl/rtl/purecall.c index 43012472012..e905dd0226b 100644 --- a/reactos/ntoskrnl/rtl/purecall.c +++ b/reactos/ntoskrnl/rtl/purecall.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/rtl/purecall.c * PURPOSE: No purpose listed. - * + * * PROGRAMMERS: Eric Kohl */ diff --git a/reactos/ntoskrnl/rtl/regio.c b/reactos/ntoskrnl/rtl/regio.c index 826ec431daf..1f6162da4c1 100644 --- a/reactos/ntoskrnl/rtl/regio.c +++ b/reactos/ntoskrnl/rtl/regio.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/rtl/regio.c * PURPOSE: Register io functions - * + * * PROGRAMMERS: Eric Kohl (ekohl@abo.rhein-zeitung.de) */ diff --git a/reactos/ntoskrnl/rtl/sprintf.c b/reactos/ntoskrnl/rtl/sprintf.c index 8faa8ca70b9..504ef8fc271 100644 --- a/reactos/ntoskrnl/rtl/sprintf.c +++ b/reactos/ntoskrnl/rtl/sprintf.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/rtl/sprintf.c * PURPOSE: Single byte sprintf functions - * + * * PROGRAMMERS: David Welch * Eric Kohl */ @@ -163,7 +163,7 @@ number(char *buf, char *end, __int64 num, int base, int size, int precision, int return buf; } -static char* +static char* string(char* buf, char* end, const char* s, int len, int field_width, int precision, int flags) { int i; @@ -208,7 +208,7 @@ string(char* buf, char* end, const char* s, int len, int field_width, int precis return buf; } -static char* +static char* stringw(char* buf, char* end, const wchar_t* sw, int len, int field_width, int precision, int flags) { int i; @@ -234,7 +234,7 @@ stringw(char* buf, char* end, const wchar_t* sw, int len, int field_width, int p if (!(flags & LEFT)) while (len < field_width--) { - if (buf <= end) + if (buf <= end) *buf = ' '; ++buf; } @@ -544,7 +544,7 @@ int _vsnprintf(char *buf, size_t cnt, const char *fmt, va_list args) else if (cnt > 0) /* don't write out a null byte if the buf size is zero */ *end = '\0'; - + return str-buf; } diff --git a/reactos/ntoskrnl/rtl/stdlib.c b/reactos/ntoskrnl/rtl/stdlib.c index e77e58b3dff..a27402a210c 100644 --- a/reactos/ntoskrnl/rtl/stdlib.c +++ b/reactos/ntoskrnl/rtl/stdlib.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/rtl/stdlib.c * PURPOSE: Standard library functions - * + * * PROGRAMMERS: Eric Kohl (ekohl@abo.rhein-zeitung.de) */ @@ -30,7 +30,7 @@ int atoi(const char *str) /* - * NOTE: no error + * NOTE: no error * * @implemented */ diff --git a/reactos/ntoskrnl/rtl/string.c b/reactos/ntoskrnl/rtl/string.c index 1def14a1f0f..67012306fe5 100644 --- a/reactos/ntoskrnl/rtl/string.c +++ b/reactos/ntoskrnl/rtl/string.c @@ -1,10 +1,10 @@ -/* $Id:$ - * +/* $Id$ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/rtl/string.c * PURPOSE: Ascii string functions - * + * * PROGRAMMERS: Eric Kohl (ekohl@abo.rhein-zeitung.de) */ @@ -74,7 +74,7 @@ char* _strnset(char* szToFill, int szFill, size_t sizeMaxFill) *szToFill = szFill; szToFill++; i++; - + } return t; } @@ -83,7 +83,7 @@ char* _strnset(char* szToFill, int szFill, size_t sizeMaxFill) /* * @implemented */ -char * _strrev(char *s) +char * _strrev(char *s) { char *e; char a; @@ -114,7 +114,7 @@ char* _strset(char* szToFill, int szFill) { *szToFill = szFill; szToFill++; - + } return t; } diff --git a/reactos/ntoskrnl/rtl/strtok.c b/reactos/ntoskrnl/rtl/strtok.c index c0e0b02f87c..70a31d2126b 100644 --- a/reactos/ntoskrnl/rtl/strtok.c +++ b/reactos/ntoskrnl/rtl/strtok.c @@ -1,10 +1,10 @@ -/* $Id:$ - * +/* $Id$ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/rtl/strtok.c * PURPOSE: Unicode and thread safe implementation of strtok - * + * * PROGRAMMERS: David Welch (welch@mcmail.com) */ @@ -22,7 +22,7 @@ char* strtok(char *s, const char *delim) int c, sc; char *tok; static char *last; - + if (s == NULL && (s = last) == NULL) return (NULL); @@ -78,7 +78,7 @@ PWSTR RtlStrtok(PUNICODE_STRING _string, PWSTR _sep, PWSTR string; PWSTR sep; PWSTR start; - + if (_string!=NULL) { string = _string->Buffer; @@ -87,9 +87,9 @@ PWSTR RtlStrtok(PUNICODE_STRING _string, PWSTR _sep, { string = *temp; } - + start = string; - + while ((*string)!=0) { sep = _sep; diff --git a/reactos/ntoskrnl/rtl/swprintf.c b/reactos/ntoskrnl/rtl/swprintf.c index b543e05f924..9c9cc7d6d65 100644 --- a/reactos/ntoskrnl/rtl/swprintf.c +++ b/reactos/ntoskrnl/rtl/swprintf.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/rtl/swprintf.c * PURPOSE: Unicode sprintf functions - * + * * PROGRAMMERS: David Welch * Eric Kohl */ @@ -222,7 +222,7 @@ string(wchar_t* buf, wchar_t* end, const char* s, int len, int field_width, int return buf; } -static wchar_t* +static wchar_t* stringw(wchar_t* buf, wchar_t* end, const wchar_t* sw, int len, int field_width, int precision, int flags) { int i; diff --git a/reactos/ntoskrnl/rtl/wstring.c b/reactos/ntoskrnl/rtl/wstring.c index 0e2939b781a..deb4ae38160 100644 --- a/reactos/ntoskrnl/rtl/wstring.c +++ b/reactos/ntoskrnl/rtl/wstring.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/rtl/wstring.c * PURPOSE: Wide string functions - * + * * PROGRAMMERS: David Welch (welch@cwcom.net) */ @@ -123,12 +123,12 @@ size_t wcscspn(const wchar_t *str,const wchar_t *reject) s=(wchar_t *)str; do { t=(wchar_t *)reject; - while (*t) { - if (*t==*s) + while (*t) { + if (*t==*s) break; t++; } - if (*t) + if (*t) break; s++; } while (*s); diff --git a/reactos/ntoskrnl/se/acl.c b/reactos/ntoskrnl/se/acl.c index 2d2e50feb46..4e2c732b6a7 100644 --- a/reactos/ntoskrnl/se/acl.c +++ b/reactos/ntoskrnl/se/acl.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/se/acl.c * PURPOSE: Security manager - * + * * PROGRAMMERS: David Welch */ @@ -218,14 +218,14 @@ SepInitDACLs(VOID) return(TRUE); } -NTSTATUS STDCALL -SepCreateImpersonationTokenDacl(PTOKEN Token, +NTSTATUS STDCALL +SepCreateImpersonationTokenDacl(PTOKEN Token, PTOKEN PrimaryToken, PACL *Dacl) { ULONG AclLength; PVOID TokenDacl; - + PAGED_CODE(); AclLength = sizeof(ACL) + diff --git a/reactos/ntoskrnl/se/audit.c b/reactos/ntoskrnl/se/audit.c index 710d635b850..da09e57bc97 100644 --- a/reactos/ntoskrnl/se/audit.c +++ b/reactos/ntoskrnl/se/audit.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/se/audit.c * PURPOSE: Audit functions - * + * * PROGRAMMERS: Eric Kohl */ diff --git a/reactos/ntoskrnl/se/lsa.c b/reactos/ntoskrnl/se/lsa.c index 3cc917170a6..a59b90a3b4e 100644 --- a/reactos/ntoskrnl/se/lsa.c +++ b/reactos/ntoskrnl/se/lsa.c @@ -1,5 +1,5 @@ -/* $Id:$ - * +/* $Id$ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/se/lsa.c @@ -48,7 +48,7 @@ NTSTATUS STDCALL LsaDeregisterLogonProcess ( NTSTATUS STDCALL LsaFreeReturnBuffer (PVOID Buffer) { ULONG Size = 0; /* required by MEM_RELEASE */ - + return ZwFreeVirtualMemory ( NtCurrentProcess(), & Buffer, diff --git a/reactos/ntoskrnl/se/luid.c b/reactos/ntoskrnl/se/luid.c index a7c516e6bf7..a24717421c9 100644 --- a/reactos/ntoskrnl/se/luid.c +++ b/reactos/ntoskrnl/se/luid.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/se/luid.c * PURPOSE: Security manager - * + * * PROGRAMMERS: No programmer listed. */ @@ -24,7 +24,7 @@ VOID INIT_FUNCTION SepInitLuid(VOID) { LUID DummyLuidValue = SYSTEM_LUID; - + LuidValue.u.HighPart = DummyLuidValue.HighPart; LuidValue.u.LowPart = DummyLuidValue.LowPart; LuidIncrement.QuadPart = 1; @@ -35,7 +35,7 @@ NTSTATUS ExpAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId) { LARGE_INTEGER NewLuid, PrevLuid; - + /* atomically increment the luid */ do { @@ -48,7 +48,7 @@ ExpAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId) LocallyUniqueId->LowPart = NewLuid.u.LowPart; LocallyUniqueId->HighPart = NewLuid.u.HighPart; - + return STATUS_SUCCESS; } @@ -62,11 +62,11 @@ NtAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId) LUID NewLuid; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); - + if(PreviousMode != KernelMode) { _SEH_TRY @@ -80,7 +80,7 @@ NtAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId) Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; diff --git a/reactos/ntoskrnl/se/priv.c b/reactos/ntoskrnl/se/priv.c index a3b813766d2..a61fc8438a0 100644 --- a/reactos/ntoskrnl/se/priv.c +++ b/reactos/ntoskrnl/se/priv.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/se/priv.c * PURPOSE: Security manager - * + * * PROGRAMMERS: No programmer listed. */ @@ -108,7 +108,7 @@ SepPrivilegeCheck (PTOKEN Token, ULONG k; DPRINT ("SepPrivilegeCheck() called\n"); - + PAGED_CODE(); if (PreviousMode == KernelMode) @@ -169,7 +169,7 @@ SeCaptureLuidAndAttributesArray (PLUID_AND_ATTRIBUTES Src, { PLUID_AND_ATTRIBUTES* NewMem; ULONG SrcLength; - + PAGED_CODE(); if (PrivilegeCount == 0) @@ -217,7 +217,7 @@ SeReleaseLuidAndAttributesArray (PLUID_AND_ATTRIBUTES Privilege, ULONG a) { PAGED_CODE(); - + ExFreePool (Privilege); } @@ -233,7 +233,7 @@ NtPrivilegeCheck (IN HANDLE ClientToken, ULONG PrivilegeControl; ULONG Length; NTSTATUS Status; - + PAGED_CODE(); Status = ObReferenceObjectByHandle (ClientToken, @@ -299,7 +299,7 @@ SePrivilegeCheck (PPRIVILEGE_SET Privileges, KPROCESSOR_MODE PreviousMode) { PACCESS_TOKEN Token = NULL; - + PAGED_CODE(); if (SubjectContext->ClientToken == NULL) @@ -333,7 +333,7 @@ SeSinglePrivilegeCheck (IN LUID PrivilegeValue, SECURITY_SUBJECT_CONTEXT SubjectContext; PRIVILEGE_SET Priv; BOOLEAN Result; - + PAGED_CODE(); SeCaptureSubjectContext (&SubjectContext); diff --git a/reactos/ntoskrnl/se/sd.c b/reactos/ntoskrnl/se/sd.c index 9f55266f969..983cc984bbc 100644 --- a/reactos/ntoskrnl/se/sd.c +++ b/reactos/ntoskrnl/se/sd.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/se/sd.c * PURPOSE: Security manager - * + * * PROGRAMMERS: David Welch */ @@ -296,13 +296,13 @@ SeCaptureSecurityDescriptor( ULONG SaclSize = 0, DaclSize = 0; ULONG DescriptorSize = 0; NTSTATUS Status = STATUS_SUCCESS; - + if(OriginalSecurityDescriptor != NULL) { if(CurrentMode != KernelMode) { RtlZeroMemory(&DescriptorCopy, sizeof(DescriptorCopy)); - + _SEH_TRY { /* first only probe and copy until the control field of the descriptor @@ -319,7 +319,7 @@ SeCaptureSecurityDescriptor( Status = STATUS_UNKNOWN_REVISION; _SEH_LEAVE; } - + /* make a copy on the stack */ DescriptorCopy.Revision = OriginalSecurityDescriptor->Revision; DescriptorCopy.Sbz1 = OriginalSecurityDescriptor->Sbz1; @@ -335,7 +335,7 @@ SeCaptureSecurityDescriptor( if(DescriptorCopy.Control & SE_SELF_RELATIVE) { PSECURITY_DESCRIPTOR_RELATIVE RelSD = (PSECURITY_DESCRIPTOR_RELATIVE)OriginalSecurityDescriptor; - + DescriptorCopy.Owner = (PSID)RelSD->Owner; DescriptorCopy.Group = (PSID)RelSD->Group; DescriptorCopy.Sacl = (PACL)RelSD->Sacl; @@ -354,7 +354,7 @@ SeCaptureSecurityDescriptor( Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -366,7 +366,7 @@ SeCaptureSecurityDescriptor( { return STATUS_UNKNOWN_REVISION; } - + *CapturedSecurityDescriptor = OriginalSecurityDescriptor; return STATUS_SUCCESS; } @@ -376,7 +376,7 @@ SeCaptureSecurityDescriptor( { return STATUS_UNKNOWN_REVISION; } - + /* make a copy on the stack */ DescriptorCopy.Revision = OriginalSecurityDescriptor->Revision; DescriptorCopy.Sbz1 = OriginalSecurityDescriptor->Sbz1; @@ -400,7 +400,7 @@ SeCaptureSecurityDescriptor( DescriptorCopy.Dacl = OriginalSecurityDescriptor->Dacl; } } - + if(DescriptorCopy.Control & SE_SELF_RELATIVE) { /* in case we're dealing with a self-relative descriptor, do a basic convert @@ -424,7 +424,7 @@ SeCaptureSecurityDescriptor( DescriptorCopy.Sacl = (PACL)((ULONG_PTR)OriginalSecurityDescriptor + (ULONG_PTR)DescriptorCopy.Sacl); } } - + /* determine the size of the SIDs */ #define DetermineSIDSize(SidType) \ do { \ @@ -470,10 +470,10 @@ SeCaptureSecurityDescriptor( } \ } \ } while(0) - + DetermineSIDSize(Owner); DetermineSIDSize(Group); - + /* determine the size of the ACLs */ #define DetermineACLSize(AclType, AclFlag) \ do { \ @@ -522,10 +522,10 @@ SeCaptureSecurityDescriptor( DescriptorCopy.AclType = NULL; \ } \ } while(0) - + DetermineACLSize(Sacl, SACL); DetermineACLSize(Dacl, DACL); - + /* allocate enough memory to store a complete copy of a self-relative security descriptor */ NewDescriptor = ExAllocatePool(PoolType, @@ -533,11 +533,11 @@ SeCaptureSecurityDescriptor( if(NewDescriptor != NULL) { ULONG_PTR Offset = sizeof(SECURITY_DESCRIPTOR); - + NewDescriptor->Revision = DescriptorCopy.Revision; NewDescriptor->Sbz1 = DescriptorCopy.Sbz1; NewDescriptor->Control = DescriptorCopy.Control | SE_SELF_RELATIVE; - + _SEH_TRY { /* setup the offsets and copy the SIDs and ACLs to the new @@ -555,7 +555,7 @@ SeCaptureSecurityDescriptor( Offset += ROUND_UP(Type##Size, sizeof(ULONG)); \ } \ } while(0) - + CopySIDOrACL(Owner); CopySIDOrACL(Group); CopySIDOrACL(Sacl); @@ -566,7 +566,7 @@ SeCaptureSecurityDescriptor( Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(NT_SUCCESS(Status)) { /* we're finally done! copy the pointer to the captured descriptor to @@ -590,7 +590,7 @@ SeCaptureSecurityDescriptor( /* nothing to do... */ *CapturedSecurityDescriptor = NULL; } - + return Status; } @@ -616,7 +616,7 @@ SeQuerySecurityDescriptorInfo(IN PSECURITY_INFORMATION SecurityInformation, ULONG Control = 0; ULONG_PTR Current; ULONG SdLength; - + RelSD = (PSECURITY_DESCRIPTOR_RELATIVE)SecurityDescriptor; if (*ObjectsSecurityDescriptor == NULL) diff --git a/reactos/ntoskrnl/se/semgr.c b/reactos/ntoskrnl/se/semgr.c index 017e480f705..de5962989a6 100644 --- a/reactos/ntoskrnl/se/semgr.c +++ b/reactos/ntoskrnl/se/semgr.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/se/semgr.c * PURPOSE: Security manager - * + * * PROGRAMMERS: No programmer listed. */ @@ -198,7 +198,7 @@ SeCaptureSubjectContext(OUT PSECURITY_SUBJECT_CONTEXT SubjectContext) PETHREAD Thread; BOOLEAN CopyOnOpen; BOOLEAN EffectiveOnly; - + PAGED_CODE(); Thread = PsGetCurrentThread(); @@ -212,7 +212,7 @@ SeCaptureSubjectContext(OUT PSECURITY_SUBJECT_CONTEXT SubjectContext) else { SubjectContext->ProcessAuditId = Thread->ThreadsProcess; - SubjectContext->ClientToken = + SubjectContext->ClientToken = PsReferenceImpersonationToken(Thread, &CopyOnOpen, &EffectiveOnly, @@ -229,7 +229,7 @@ VOID STDCALL SeLockSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext) { PAGED_CODE(); - + KeEnterCriticalRegion(); ExAcquireResourceExclusiveLite(&SepSubjectContextLock, TRUE); } @@ -242,7 +242,7 @@ VOID STDCALL SeUnlockSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext) { PAGED_CODE(); - + ExReleaseResourceLite(&SepSubjectContextLock); KeLeaveCriticalRegion(); } @@ -255,7 +255,7 @@ VOID STDCALL SeReleaseSubjectContext(IN PSECURITY_SUBJECT_CONTEXT SubjectContext) { PAGED_CODE(); - + if (SubjectContext->PrimaryToken != NULL) { ObDereferenceObject(SubjectContext->PrimaryToken); @@ -275,7 +275,7 @@ NTSTATUS STDCALL SeDeassignSecurity(PSECURITY_DESCRIPTOR *SecurityDescriptor) { PAGED_CODE(); - + if (*SecurityDescriptor != NULL) { ExFreePool(*SecurityDescriptor); @@ -308,13 +308,13 @@ SeAssignSecurityEx(IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, /* * FUNCTION: Creates a security descriptor for a new object. * ARGUMENTS: - * ParentDescriptor = - * ExplicitDescriptor = - * NewDescriptor = - * IsDirectoryObject = - * SubjectContext = - * GeneralMapping = - * PoolType = + * ParentDescriptor = + * ExplicitDescriptor = + * NewDescriptor = + * IsDirectoryObject = + * SubjectContext = + * GeneralMapping = + * PoolType = * RETURNS: Status * * @implemented @@ -341,7 +341,7 @@ SeAssignSecurity(PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, PSID Group = NULL; PACL Dacl = NULL; PACL Sacl = NULL; - + PAGED_CODE(); /* Lock subject context */ @@ -489,10 +489,10 @@ SeAssignSecurity(PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, /* Allocate and initialize the new security descriptor */ - Length = sizeof(SECURITY_DESCRIPTOR) + + Length = sizeof(SECURITY_DESCRIPTOR) + OwnerLength + GroupLength + DaclLength + SaclLength; - DPRINT("L: sizeof(SECURITY_DESCRIPTOR) %d OwnerLength %d GroupLength %d DaclLength %d SaclLength %d\n", + DPRINT("L: sizeof(SECURITY_DESCRIPTOR) %d OwnerLength %d GroupLength %d DaclLength %d SaclLength %d\n", sizeof(SECURITY_DESCRIPTOR), OwnerLength, GroupLength, @@ -573,7 +573,7 @@ SepSidInToken(PACCESS_TOKEN _Token, { ULONG i; PTOKEN Token = (PTOKEN)_Token; - + PAGED_CODE(); if (Token->UserAndGroupCount == 0) @@ -638,7 +638,7 @@ SeAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, PACE CurrentAce; PSID Sid; NTSTATUS Status; - + PAGED_CODE(); CurrentAccess = PreviouslyGrantedAccess; @@ -811,7 +811,7 @@ NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, KPROCESSOR_MODE PreviousMode; PTOKEN Token; NTSTATUS Status; - + PAGED_CODE(); DPRINT("NtAccessCheck() called\n"); diff --git a/reactos/ntoskrnl/se/sid.c b/reactos/ntoskrnl/se/sid.c index 019072a4d15..de59741a876 100644 --- a/reactos/ntoskrnl/se/sid.c +++ b/reactos/ntoskrnl/se/sid.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/se/sid.c * PURPOSE: Security manager - * + * * PROGRAMMERS: David Welch */ @@ -476,7 +476,7 @@ SepCaptureSid(IN PSID InputSid, ULONG SidSize = 0; PISID NewSid, Sid = (PISID)InputSid; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); if(AccessMode != KernelMode) @@ -496,7 +496,7 @@ SepCaptureSid(IN PSID InputSid, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(NT_SUCCESS(Status)) { /* allocate a SID and copy it */ @@ -560,7 +560,7 @@ SepReleaseSid(IN PSID CapturedSid, IN BOOLEAN CaptureIfKernel) { PAGED_CODE(); - + if(CapturedSid != NULL && (AccessMode == UserMode || (AccessMode == KernelMode && CaptureIfKernel))) diff --git a/reactos/ntoskrnl/se/token.c b/reactos/ntoskrnl/se/token.c index 67da059658b..c9d77236de2 100644 --- a/reactos/ntoskrnl/se/token.c +++ b/reactos/ntoskrnl/se/token.c @@ -4,7 +4,7 @@ * PROJECT: ReactOS kernel * FILE: ntoskrnl/se/token.c * PURPOSE: Security manager - * + * * PROGRAMMERS: David Welch */ @@ -79,31 +79,31 @@ NTSTATUS SepCopyProxyData(PVOID* Dest, PVOID Src) return(STATUS_NOT_IMPLEMENTED); } -NTSTATUS +NTSTATUS SeExchangePrimaryToken(PEPROCESS Process, PACCESS_TOKEN NewTokenP, PACCESS_TOKEN* OldTokenP) { PTOKEN OldToken; PTOKEN NewToken = (PTOKEN)NewTokenP; - + PAGED_CODE(); - + if (NewToken->TokenType != TokenPrimary) return(STATUS_BAD_TOKEN_TYPE); if (NewToken->TokenInUse) return(STATUS_TOKEN_ALREADY_IN_USE); - + /* Mark new token in use */ NewToken->TokenInUse = 1; - + /* Reference the New Token */ ObReferenceObject(NewToken); - + /* Replace the old with the new */ OldToken = ObFastReplaceObject(&Process->Token, NewToken); - + /* Mark the Old Token as free */ OldToken->TokenInUse = 0; - + *OldTokenP = (PACCESS_TOKEN)OldToken; return STATUS_SUCCESS; } @@ -112,10 +112,10 @@ VOID SeDeassignPrimaryToken(PEPROCESS Process) { PTOKEN OldToken; - + /* Remove the Token */ OldToken = ObFastReplaceObject(&Process->Token, NULL); - + /* Mark the Old Token as free */ OldToken->TokenInUse = 0; } @@ -126,7 +126,7 @@ RtlLengthSidAndAttributes(ULONG Count, { ULONG i; ULONG uLength; - + PAGED_CODE(); uLength = Count * sizeof(SID_AND_ATTRIBUTES); @@ -195,7 +195,7 @@ SepDuplicateToken(PTOKEN Token, PVOID EndMem; PTOKEN AccessToken; NTSTATUS Status; - + PAGED_CODE(); Status = ObCreateObject(PreviousMode, @@ -247,7 +247,7 @@ SepDuplicateToken(PTOKEN Token, for (i = 0; i < Token->UserAndGroupCount; i++) uLength += RtlLengthSid(Token->UserAndGroups[i].Sid); - AccessToken->UserAndGroups = + AccessToken->UserAndGroups = (PSID_AND_ATTRIBUTES)ExAllocatePoolWithTag(PagedPool, uLength, TAG('T', 'O', 'K', 'u')); @@ -283,7 +283,7 @@ SepDuplicateToken(PTOKEN Token, { RtlCopyLuid(&AccessToken->Privileges[i].Luid, &Token->Privileges[i].Luid); - AccessToken->Privileges[i].Attributes = + AccessToken->Privileges[i].Attributes = Token->Privileges[i].Attributes; } @@ -336,9 +336,9 @@ SeCopyClientToken(PACCESS_TOKEN Token, { NTSTATUS Status; OBJECT_ATTRIBUTES ObjectAttributes; - + PAGED_CODE(); - + InitializeObjectAttributes(&ObjectAttributes, NULL, 0, @@ -351,7 +351,7 @@ SeCopyClientToken(PACCESS_TOKEN Token, Level, PreviousMode, (PTOKEN*)NewToken); - + return(Status); } @@ -371,9 +371,9 @@ SeCreateClientSecurity(IN struct _ETHREAD *Thread, PACCESS_TOKEN Token; ULONG g; PACCESS_TOKEN NewToken; - + PAGED_CODE(); - + Token = PsReferenceEffectiveToken(Thread, &TokenType, &b, @@ -412,7 +412,7 @@ SeCreateClientSecurity(IN struct _ETHREAD *Thread, ClientContext->DirectAccessEffectiveOnly = FALSE; } } - + if (Qos->ContextTrackingMode == 0) { ClientContext->DirectlyAccessClientToken = FALSE; @@ -518,9 +518,9 @@ SeImpersonateClient(IN PSECURITY_CLIENT_CONTEXT ClientContext, IN PETHREAD ServerThread OPTIONAL) { UCHAR b; - + PAGED_CODE(); - + if (ClientContext->DirectlyAccessClientToken == FALSE) { b = ClientContext->SecurityQos.EffectiveOnly; @@ -607,11 +607,11 @@ NtQueryInformationToken(IN HANDLE TokenHandle, ULONG RequiredLength; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); - + /* Check buffers and class validity */ DefaultQueryInfoBufferCheck(TokenInformationClass, SeTokenInformationClass, @@ -640,7 +640,7 @@ NtQueryInformationToken(IN HANDLE TokenHandle, case TokenUser: { PTOKEN_USER tu = (PTOKEN_USER)TokenInformation; - + DPRINT("NtQueryInformationToken(TokenUser)\n"); RequiredLength = sizeof(TOKEN_USER) + RtlLengthSid(Token->UserAndGroups[0].Sid); @@ -661,7 +661,7 @@ NtQueryInformationToken(IN HANDLE TokenHandle, { Status = STATUS_BUFFER_TOO_SMALL; } - + if(ReturnLength != NULL) { *ReturnLength = RequiredLength; @@ -672,14 +672,14 @@ NtQueryInformationToken(IN HANDLE TokenHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + break; } - + case TokenGroups: { PTOKEN_GROUPS tg = (PTOKEN_GROUPS)TokenInformation; - + DPRINT("NtQueryInformationToken(TokenGroups)\n"); RequiredLength = sizeof(tg->GroupCount) + RtlLengthSidAndAttributes(Token->UserAndGroupCount - 1, &Token->UserAndGroups[1]); @@ -717,14 +717,14 @@ NtQueryInformationToken(IN HANDLE TokenHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + break; } - + case TokenPrivileges: { PTOKEN_PRIVILEGES tp = (PTOKEN_PRIVILEGES)TokenInformation; - + DPRINT("NtQueryInformationToken(TokenPrivileges)\n"); RequiredLength = sizeof(tp->PrivilegeCount) + (Token->PrivilegeCount * sizeof(LUID_AND_ATTRIBUTES)); @@ -742,7 +742,7 @@ NtQueryInformationToken(IN HANDLE TokenHandle, { Status = STATUS_BUFFER_TOO_SMALL; } - + if(ReturnLength != NULL) { *ReturnLength = RequiredLength; @@ -753,15 +753,15 @@ NtQueryInformationToken(IN HANDLE TokenHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + break; } - + case TokenOwner: { ULONG SidLen; PTOKEN_OWNER to = (PTOKEN_OWNER)TokenInformation; - + DPRINT("NtQueryInformationToken(TokenOwner)\n"); SidLen = RtlLengthSid(Token->UserAndGroups[Token->DefaultOwnerIndex].Sid); RequiredLength = sizeof(TOKEN_OWNER) + SidLen; @@ -779,7 +779,7 @@ NtQueryInformationToken(IN HANDLE TokenHandle, { Status = STATUS_BUFFER_TOO_SMALL; } - + if(ReturnLength != NULL) { *ReturnLength = RequiredLength; @@ -790,10 +790,10 @@ NtQueryInformationToken(IN HANDLE TokenHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + break; } - + case TokenPrimaryGroup: { ULONG SidLen; @@ -830,14 +830,14 @@ NtQueryInformationToken(IN HANDLE TokenHandle, break; } - + case TokenDefaultDacl: { PTOKEN_DEFAULT_DACL tdd = (PTOKEN_DEFAULT_DACL)TokenInformation; DPRINT("NtQueryInformationToken(TokenDefaultDacl)\n"); RequiredLength = sizeof(TOKEN_DEFAULT_DACL); - + if(Token->DefaultDacl != NULL) { RequiredLength += Token->DefaultDacl->AclSize; @@ -877,7 +877,7 @@ NtQueryInformationToken(IN HANDLE TokenHandle, break; } - + case TokenSource: { PTOKEN_SOURCE ts = (PTOKEN_SOURCE)TokenInformation; @@ -909,7 +909,7 @@ NtQueryInformationToken(IN HANDLE TokenHandle, break; } - + case TokenType: { PTOKEN_TYPE tt = (PTOKEN_TYPE)TokenInformation; @@ -941,7 +941,7 @@ NtQueryInformationToken(IN HANDLE TokenHandle, break; } - + case TokenImpersonationLevel: { PSECURITY_IMPERSONATION_LEVEL sil = (PSECURITY_IMPERSONATION_LEVEL)TokenInformation; @@ -973,7 +973,7 @@ NtQueryInformationToken(IN HANDLE TokenHandle, break; } - + case TokenStatistics: { PTOKEN_STATISTICS ts = (PTOKEN_STATISTICS)TokenInformation; @@ -1014,7 +1014,7 @@ NtQueryInformationToken(IN HANDLE TokenHandle, break; } - + case TokenOrigin: { PTOKEN_ORIGIN to = (PTOKEN_ORIGIN)TokenInformation; @@ -1068,7 +1068,7 @@ NtQueryInformationToken(IN HANDLE TokenHandle, ULONG SessionId = 0; DPRINT("NtQueryInformationToken(TokenSessionId)\n"); - + Status = SeQuerySessionIdToken(Token, &SessionId); @@ -1090,7 +1090,7 @@ NtQueryInformationToken(IN HANDLE TokenHandle, } _SEH_END; } - + break; } @@ -1151,11 +1151,11 @@ NtSetInformationToken(IN HANDLE TokenHandle, KPROCESSOR_MODE PreviousMode; ULONG NeededAccess = TOKEN_ADJUST_DEFAULT; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); - + DefaultSetInfoBufferCheck(TokenInformationClass, SeTokenInformationClass, TokenInformation, @@ -1169,7 +1169,7 @@ NtSetInformationToken(IN HANDLE TokenHandle, DPRINT("NtSetInformationToken() failed, Status: 0x%x\n", Status); return Status; } - + if(TokenInformationClass == TokenSessionId) { NeededAccess |= TOKEN_ADJUST_SESSIONID; @@ -1191,7 +1191,7 @@ NtSetInformationToken(IN HANDLE TokenHandle, { PTOKEN_OWNER to = (PTOKEN_OWNER)TokenInformation; PSID InputSid = NULL; - + _SEH_TRY { InputSid = to->Owner; @@ -1201,11 +1201,11 @@ NtSetInformationToken(IN HANDLE TokenHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(NT_SUCCESS(Status)) { PSID CapturedSid; - + Status = SepCaptureSid(InputSid, PreviousMode, PagedPool, @@ -1228,7 +1228,7 @@ NtSetInformationToken(IN HANDLE TokenHandle, } break; } - + case TokenPrimaryGroup: { if(TokenInformationLength >= sizeof(TOKEN_PRIMARY_GROUP)) @@ -1272,7 +1272,7 @@ NtSetInformationToken(IN HANDLE TokenHandle, } break; } - + case TokenDefaultDacl: { if(TokenInformationLength >= sizeof(TOKEN_DEFAULT_DACL)) @@ -1309,7 +1309,7 @@ NtSetInformationToken(IN HANDLE TokenHandle, { ExFreePool(Token->DefaultDacl); } - + /* set the new dacl */ Token->DefaultDacl = CapturedAcl; } @@ -1331,7 +1331,7 @@ NtSetInformationToken(IN HANDLE TokenHandle, } break; } - + case TokenSessionId: { ULONG SessionId = 0; @@ -1398,11 +1398,11 @@ NtDuplicateToken(IN HANDLE ExistingTokenHandle, PSECURITY_QUALITY_OF_SERVICE CapturedSecurityQualityOfService; BOOLEAN QoSPresent; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); PreviousMode = KeGetPreviousMode(); - + if(PreviousMode != KernelMode) { _SEH_TRY @@ -1422,7 +1422,7 @@ NtDuplicateToken(IN HANDLE ExistingTokenHandle, return Status; } } - + Status = SepCaptureSecurityQualityOfService(ObjectAttributes, PreviousMode, PagedPool, @@ -1434,7 +1434,7 @@ NtDuplicateToken(IN HANDLE ExistingTokenHandle, DPRINT1("NtDuplicateToken() failed to capture QoS! Status: 0x%x\n", Status); return Status; } - + Status = ObReferenceObjectByHandle(ExistingTokenHandle, TOKEN_DUPLICATE, SepTokenObjectType, @@ -1478,7 +1478,7 @@ NtDuplicateToken(IN HANDLE ExistingTokenHandle, } } } - + /* free the captured structure */ SepReleaseSecurityQualityOfService(CapturedSecurityQualityOfService, PreviousMode, @@ -1517,17 +1517,17 @@ NtAdjustGroupsToken(IN HANDLE TokenHandle, ULONG a; ULONG b; ULONG c; - + PAGED_CODE(); - + Status = ObReferenceObjectByHandle(TokenHandle, ?, SepTokenObjectType, UserMode, (PVOID*)&Token, NULL); - - + + SepAdjustGroups(Token, 0, ResetToDefault, @@ -1625,7 +1625,7 @@ NtAdjustPrivilegesToken (IN HANDLE TokenHandle, ULONG c; #endif NTSTATUS Status; - + PAGED_CODE(); DPRINT ("NtAdjustPrivilegesToken() called\n"); @@ -1751,7 +1751,7 @@ NtAdjustPrivilegesToken (IN HANDLE TokenHandle, /* Update current privlege */ Token->Privileges[i].Attributes &= ~SE_PRIVILEGE_ENABLED; - Token->Privileges[i].Attributes |= + Token->Privileges[i].Attributes |= (NewState->Privileges[j].Attributes & SE_PRIVILEGE_ENABLED); DPRINT ("New attributes %lx\n", Token->Privileges[i].Attributes); @@ -1787,7 +1787,7 @@ SepCreateSystemProcessToken(VOID) NTSTATUS Status; ULONG uSize; ULONG i; - + PAGED_CODE(); ULONG uLocalSystemLength = RtlLengthSid(SeLocalSystemSid); @@ -1853,7 +1853,7 @@ SepCreateSystemProcessToken(VOID) uSize += uAuthUserLength; uSize += uAdminsLength; - AccessToken->UserAndGroups = + AccessToken->UserAndGroups = (PSID_AND_ATTRIBUTES)ExAllocatePoolWithTag(NonPagedPool, uSize, TAG('T', 'O', 'K', 'u')); @@ -1899,55 +1899,55 @@ SepCreateSystemProcessToken(VOID) AccessToken->Privileges[i].Attributes = 0; AccessToken->Privileges[i++].Luid = SeTakeOwnershipPrivilege; - + AccessToken->Privileges[i].Attributes = SE_PRIVILEGE_ENABLED_BY_DEFAULT|SE_PRIVILEGE_ENABLED; AccessToken->Privileges[i++].Luid = SeCreatePagefilePrivilege; - + AccessToken->Privileges[i].Attributes = SE_PRIVILEGE_ENABLED_BY_DEFAULT|SE_PRIVILEGE_ENABLED; AccessToken->Privileges[i++].Luid = SeLockMemoryPrivilege; - + AccessToken->Privileges[i].Attributes = 0; AccessToken->Privileges[i++].Luid = SeAssignPrimaryTokenPrivilege; - + AccessToken->Privileges[i].Attributes = 0; AccessToken->Privileges[i++].Luid = SeIncreaseQuotaPrivilege; - + AccessToken->Privileges[i].Attributes = SE_PRIVILEGE_ENABLED_BY_DEFAULT|SE_PRIVILEGE_ENABLED; AccessToken->Privileges[i++].Luid = SeIncreaseBasePriorityPrivilege; - + AccessToken->Privileges[i].Attributes = SE_PRIVILEGE_ENABLED_BY_DEFAULT|SE_PRIVILEGE_ENABLED; AccessToken->Privileges[i++].Luid = SeCreatePermanentPrivilege; - + AccessToken->Privileges[i].Attributes = SE_PRIVILEGE_ENABLED_BY_DEFAULT|SE_PRIVILEGE_ENABLED; AccessToken->Privileges[i++].Luid = SeDebugPrivilege; - + AccessToken->Privileges[i].Attributes = SE_PRIVILEGE_ENABLED_BY_DEFAULT|SE_PRIVILEGE_ENABLED; AccessToken->Privileges[i++].Luid = SeAuditPrivilege; - + AccessToken->Privileges[i].Attributes = 0; AccessToken->Privileges[i++].Luid = SeSecurityPrivilege; - + AccessToken->Privileges[i].Attributes = 0; AccessToken->Privileges[i++].Luid = SeSystemEnvironmentPrivilege; - + AccessToken->Privileges[i].Attributes = SE_PRIVILEGE_ENABLED_BY_DEFAULT|SE_PRIVILEGE_ENABLED; AccessToken->Privileges[i++].Luid = SeChangeNotifyPrivilege; - + AccessToken->Privileges[i].Attributes = 0; AccessToken->Privileges[i++].Luid = SeBackupPrivilege; - + AccessToken->Privileges[i].Attributes = 0; AccessToken->Privileges[i++].Luid = SeRestorePrivilege; - + AccessToken->Privileges[i].Attributes = 0; AccessToken->Privileges[i++].Luid = SeShutdownPrivilege; - + AccessToken->Privileges[i].Attributes = 0; AccessToken->Privileges[i++].Luid = SeLoadDriverPrivilege; - + AccessToken->Privileges[i].Attributes = SE_PRIVILEGE_ENABLED_BY_DEFAULT|SE_PRIVILEGE_ENABLED; AccessToken->Privileges[i++].Luid = SeProfileSingleProcessPrivilege; - + AccessToken->Privileges[i].Attributes = 0; AccessToken->Privileges[i++].Luid = SeSystemtimePrivilege; #if 0 @@ -2013,11 +2013,11 @@ NtCreateToken(OUT PHANDLE TokenHandle, ULONG i; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); - + if(PreviousMode != KernelMode) { _SEH_TRY @@ -2058,7 +2058,7 @@ NtCreateToken(OUT PHANDLE TokenHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -2121,7 +2121,7 @@ NtCreateToken(OUT PHANDLE TokenHandle, for (i = 0; i < TokenGroups->GroupCount; i++) uLength += RtlLengthSid(TokenGroups->Groups[i].Sid); - AccessToken->UserAndGroups = + AccessToken->UserAndGroups = (PSID_AND_ATTRIBUTES)ExAllocatePoolWithTag(PagedPool, uLength, TAG('T', 'O', 'K', 'u')); @@ -2149,7 +2149,7 @@ NtCreateToken(OUT PHANDLE TokenHandle, if (NT_SUCCESS(Status)) { Status = SepFindPrimaryGroupAndDefaultOwner( - AccessToken, + AccessToken, TokenPrimaryGroup->PrimaryGroup, TokenOwner->Owner); } @@ -2221,7 +2221,7 @@ SeQueryAuthenticationIdToken(IN PACCESS_TOKEN Token, OUT PLUID LogonId) { PAGED_CODE(); - + *LogonId = ((PTOKEN)Token)->AuthenticationId; return STATUS_SUCCESS; @@ -2236,7 +2236,7 @@ STDCALL SeTokenImpersonationLevel(IN PACCESS_TOKEN Token) { PAGED_CODE(); - + return ((PTOKEN)Token)->ImpersonationLevel; } @@ -2248,7 +2248,7 @@ TOKEN_TYPE STDCALL SeTokenType(IN PACCESS_TOKEN Token) { PAGED_CODE(); - + return ((PTOKEN)Token)->TokenType; } @@ -2315,11 +2315,11 @@ NtOpenThreadTokenEx(IN HANDLE ThreadHandle, PACL Dacl = NULL; KPROCESSOR_MODE PreviousMode; NTSTATUS Status = STATUS_SUCCESS; - + PAGED_CODE(); - + PreviousMode = ExGetPreviousMode(); - + if(PreviousMode != KernelMode) { _SEH_TRY @@ -2333,7 +2333,7 @@ NtOpenThreadTokenEx(IN HANDLE ThreadHandle, Status = _SEH_GetExceptionCode(); } _SEH_END; - + if(!NT_SUCCESS(Status)) { return Status; @@ -2392,7 +2392,7 @@ NtOpenThreadTokenEx(IN HANDLE ThreadHandle, } return Status; } - + PrimaryToken = PsReferencePrimaryToken(Thread->ThreadsProcess); Status = SepCreateImpersonationTokenDacl(Token, PrimaryToken, &Dacl); ObfDereferenceObject(PrimaryToken); @@ -2406,7 +2406,7 @@ NtOpenThreadTokenEx(IN HANDLE ThreadHandle, } return Status; } - + RtlCreateSecurityDescriptor(&SecurityDescriptor, SECURITY_DESCRIPTOR_REVISION); RtlSetDaclSecurityDescriptor(&SecurityDescriptor, TRUE, Dacl, diff --git a/reactos/ntoskrnl/tests/setup.c b/reactos/ntoskrnl/tests/setup.c index 184ccc9af80..f8c558a6655 100644 --- a/reactos/ntoskrnl/tests/setup.c +++ b/reactos/ntoskrnl/tests/setup.c @@ -1,5 +1,5 @@ -/* $Id:$ - * +/* $Id$ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/tests/setup.c diff --git a/reactos/ntoskrnl/tests/tests/VirtualMemory.c b/reactos/ntoskrnl/tests/tests/VirtualMemory.c index c6bca976d83..aa24cf863c1 100644 --- a/reactos/ntoskrnl/tests/tests/VirtualMemory.c +++ b/reactos/ntoskrnl/tests/tests/VirtualMemory.c @@ -1,5 +1,5 @@ -/* $Id:$ - * +/* $Id$ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/tests/tests/VirtualMemory.c