ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
August 2005
----- 2025 -----
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
23 participants
669 discussions
Start a n
N
ew thread
[weiden] 17188: RtlFreeHandle only should call RtlIsValidHandle in debug builds.
by weiden@svn.reactos.com
RtlFreeHandle only should call RtlIsValidHandle in debug builds. Modified: trunk/reactos/lib/ntdll/rtl/handle.c _____ Modified: trunk/reactos/lib/ntdll/rtl/handle.c --- trunk/reactos/lib/ntdll/rtl/handle.c 2005-08-07 23:18:40 UTC (rev 17187) +++ trunk/reactos/lib/ntdll/rtl/handle.c 2005-08-07 23:19:15 UTC (rev 17188) @@ -126,9 +126,11 @@ RtlFreeHandle(PRTL_HANDLE_TABLE HandleTable, PRTL_HANDLE_TABLE_ENTRY Handle) { +#if DBG /* check if handle is valid */ if (RtlIsValidHandle(HandleTable, Handle)) return FALSE; +#endif /* clear handle */ memset(Handle, 0, HandleTable->SizeOfHandleTableEntry);
19 years, 4 months
1
0
0
0
[ion] 17187: Fix horridly wrong SignalObjectAndWait return values, should make more wine tests pass
by ion@svn.reactos.com
Fix horridly wrong SignalObjectAndWait return values, should make more wine tests pass Modified: trunk/reactos/lib/kernel32/synch/wait.c _____ Modified: trunk/reactos/lib/kernel32/synch/wait.c --- trunk/reactos/lib/kernel32/synch/wait.c 2005-08-07 23:08:07 UTC (rev 17186) +++ trunk/reactos/lib/kernel32/synch/wait.c 2005-08-07 23:18:40 UTC (rev 17187) @@ -266,7 +266,7 @@ { DPRINT1("Console handles are not supported yet!\n"); SetLastError(ERROR_INVALID_HANDLE); - return FALSE; + return WAIT_FAILED; } } @@ -280,6 +280,7 @@ TimePtr = &Time; } +WaitAgain: Status = NtSignalAndWaitForSingleObject (hObjectToSignal, hObjectToWaitOn, (BOOLEAN)bAlertable, @@ -287,10 +288,12 @@ if (!NT_SUCCESS(Status)) { SetLastErrorByStatus (Status); - return FALSE; + return WAIT_FAILED; } + if (Status == STATUS_ALERTED && bAlertable) goto WaitAgain; - return TRUE; + /* STATUS_SUCCESS maps to WAIT_OBJECT_0 */ + return Status; } /* EOF */
19 years, 4 months
1
0
0
0
[hbirr] 17186: Allocate the map registers according to the dma controllers properties (boundary and highest possible address).
by hbirr@svn.reactos.com
Allocate the map registers according to the dma controllers properties (boundary and highest possible address). Modified: trunk/reactos/hal/halx86/generic/adapter.c Modified: trunk/reactos/hal/halx86/generic/dma.c _____ Modified: trunk/reactos/hal/halx86/generic/adapter.c --- trunk/reactos/hal/halx86/generic/adapter.c 2005-08-07 23:07:17 UTC (rev 17185) +++ trunk/reactos/hal/halx86/generic/adapter.c 2005-08-07 23:08:07 UTC (rev 17186) @@ -68,11 +68,6 @@ if(KeInsertDeviceQueue(&AdapterObject->ChannelWaitQueue, &WaitContextBlock->WaitQueueEntry)) return STATUS_SUCCESS; - /* 24-bit max address due to 16-bit dma controllers */ - MinAddress.QuadPart = 0x0000000; - MaxAddress.QuadPart = 0x1000000; - BoundryAddressMultiple.QuadPart = 0; - /* why 64K alignment? */ /* * X86 lacks map registers, so for now, we allocate a contiguous @@ -83,13 +78,35 @@ * buffer transfers. See a comment in IoMapTransfer about common buffer * support. */ - AdapterObject->MapRegisterBase = MmAllocateContiguousAlignedMemory( + + MinAddress.QuadPart = 0; + BoundryAddressMultiple.QuadPart = 0; + if ((AdapterObject->Dma64BitAddresses) && (AdapterObject->MasterDevice)) + { + MaxAddress.QuadPart = 0xFFFFFFFFFFFFFFFFLL; /* 64Bit: >4GB address range */ + } + else if ((AdapterObject->Dma32BitAddresses) && (AdapterObject->MasterDevice)) + { + MaxAddress.QuadPart = 0xFFFFFFFF; /* 32Bit: 4GB address range */ + } + else + { + MaxAddress.QuadPart = 0x00FFFFFF; /* 24Bit: 16MB address range */ + if (AdapterObject->Width16Bits) + { + BoundryAddressMultiple.QuadPart = 0x20000; /* 128k boundary */ + } + else + { + BoundryAddressMultiple.QuadPart = 0x10000; /* 64k boundary */ + } + } + AdapterObject->MapRegisterBase = MmAllocateContiguousMemorySpecifyCache( NumberOfMapRegisters * PAGE_SIZE, MinAddress, MaxAddress, BoundryAddressMultiple, - MmCached, - 0x10000 ); + MmCached); if(!AdapterObject->MapRegisterBase) return STATUS_INSUFFICIENT_RESOURCES; @@ -387,18 +404,35 @@ * function really can't return an error code. FIXME. */ - /* 24-bit max address due to 16-bit dma controllers */ - MinAddress.QuadPart = 0x0000000; - MaxAddress.QuadPart = 0x1000000; + MinAddress.QuadPart = 0; BoundryAddressMultiple.QuadPart = 0; + if ((AdapterObject->Dma64BitAddresses) && (AdapterObject->MasterDevice)) + { + MaxAddress.QuadPart = 0xFFFFFFFFFFFFFFFFLL; /* 64Bit: >4GB address range */ + } + else if ((AdapterObject->Dma32BitAddresses) && (AdapterObject->MasterDevice)) + { + MaxAddress.QuadPart = 0xFFFFFFFF; /* 32Bit: 4GB address range */ + } + else + { + MaxAddress.QuadPart = 0x00FFFFFF; /* 24Bit: 16MB address range */ + if (AdapterObject->Width16Bits) + { + BoundryAddressMultiple.QuadPart = 0x20000; /* 128k boundary */ + } + else + { + BoundryAddressMultiple.QuadPart = 0x10000; /* 64k boundary */ + } + } - AdapterObject->MapRegisterBase = MmAllocateContiguousAlignedMemory( + AdapterObject->MapRegisterBase = MmAllocateContiguousMemorySpecifyCache( WaitContextBlock->NumberOfMapRegisters * PAGE_SIZE, MinAddress, MaxAddress, BoundryAddressMultiple, - MmCached, - 0x10000 ); + MmCached); if(!AdapterObject->MapRegisterBase) return; _____ Modified: trunk/reactos/hal/halx86/generic/dma.c --- trunk/reactos/hal/halx86/generic/dma.c 2005-08-07 23:07:17 UTC (rev 17185) +++ trunk/reactos/hal/halx86/generic/dma.c 2005-08-07 23:08:07 UTC (rev 17186) @@ -54,20 +54,29 @@ LowestAddress.QuadPart = 0; BoundryAddressMultiple.QuadPart = 0; - HighestAddress.u.HighPart = 0; - if ((AdapterObject->Dma32BitAddresses) && (AdapterObject->MasterDevice)) { - HighestAddress.u.LowPart = 0xFFFFFFFF; /* 32Bit: 4GB address range */ + if ((AdapterObject->Dma64BitAddresses) && (AdapterObject->MasterDevice)) { + HighestAddress.QuadPart = 0xFFFFFFFFFFFFFFFFLL; /* 64Bit: >4GB address range */ + + } else if ((AdapterObject->Dma32BitAddresses) && (AdapterObject->MasterDevice)) { + HighestAddress.QuadPart = 0xFFFFFFFF; /* 32Bit: 4GB address range */ } else { - HighestAddress.u.LowPart = 0x00FFFFFF; /* 24Bit: 16MB address range */ + HighestAddress.QuadPart = 0x00FFFFFF; /* 24Bit: 16MB address range */ + if (AdapterObject->Width16Bits) + { + BoundryAddressMultiple.QuadPart = 0x20000; /* 128k boundary */ + } + else + { + BoundryAddressMultiple.QuadPart = 0x10000; /* 64k boundary */ + } } - BaseAddress = MmAllocateContiguousAlignedMemory( + BaseAddress = MmAllocateContiguousMemorySpecifyCache( Length, LowestAddress, HighestAddress, BoundryAddressMultiple, - CacheEnabled ? MmCached : MmNonCached, - 0x10000 ); + CacheEnabled ? MmCached : MmNonCached); if (!BaseAddress) return 0;
19 years, 4 months
1
0
0
0
[hbirr] 17185: - Changed MmGetContinuousPages from using an alignment to using a boundary.
by hbirr@svn.reactos.com
- Changed MmGetContinuousPages from using an alignment to using a boundary. - Removed MmAllocateContiguousAlignedMemory. Modified: trunk/reactos/ntoskrnl/include/internal/mm.h Modified: trunk/reactos/ntoskrnl/mm/cont.c Modified: trunk/reactos/ntoskrnl/mm/freelist.c Modified: trunk/reactos/ntoskrnl/ntoskrnl.def _____ Modified: trunk/reactos/ntoskrnl/include/internal/mm.h --- trunk/reactos/ntoskrnl/include/internal/mm.h 2005-08-07 23:05:57 UTC (rev 17184) +++ trunk/reactos/ntoskrnl/include/internal/mm.h 2005-08-07 23:07:17 UTC (rev 17185) @@ -667,7 +667,7 @@ PFN_TYPE MmGetContinuousPages(ULONG NumberOfBytes, PHYSICAL_ADDRESS LowestAcceptableAddress, PHYSICAL_ADDRESS HighestAcceptableAddress, - ULONG Alignment); + PHYSICAL_ADDRESS BoundaryAddressMultiple); NTSTATUS MmInitZeroPageThread(VOID); @@ -795,12 +795,11 @@ /* cont.c ********************************************************************/ PVOID STDCALL -MmAllocateContiguousAlignedMemory(IN ULONG NumberOfBytes, - IN PHYSICAL_ADDRESS LowestAcceptableAddress, - IN PHYSICAL_ADDRESS HighestAcceptableAddress, - IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, - IN MEMORY_CACHING_TYPE CacheType OPTIONAL, - IN ULONG Alignment); +MmAllocateContiguousMemorySpecifyCache(IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType OPTIONAL); /* region.c ************************************************************/ _____ Modified: trunk/reactos/ntoskrnl/mm/cont.c --- trunk/reactos/ntoskrnl/mm/cont.c 2005-08-07 23:05:57 UTC (rev 17184) +++ trunk/reactos/ntoskrnl/mm/cont.c 2005-08-07 23:07:17 UTC (rev 17185) @@ -28,16 +28,44 @@ } } -/* +/********************************************************************** + * NAME EXPORTED + * MmAllocateContiguousMemorySpecifyCache@32 + * + * 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. + * + * REVISIONS + * * @implemented */ PVOID STDCALL -MmAllocateContiguousAlignedMemory(IN ULONG NumberOfBytes, - IN PHYSICAL_ADDRESS LowestAcceptableAddress OPTIONAL, - IN PHYSICAL_ADDRESS HighestAcceptableAddress, - IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, - IN MEMORY_CACHING_TYPE CacheType OPTIONAL, - IN ULONG Alignment) +MmAllocateContiguousMemorySpecifyCache(IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress OPTIONAL, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType OPTIONAL) { PMEMORY_AREA MArea; NTSTATUS Status; @@ -66,7 +94,7 @@ &MArea, FALSE, FALSE, - BoundaryAddressMultiple); + (PHYSICAL_ADDRESS)0LL); MmUnlockAddressSpace(MmGetKernelAddressSpace()); if (!NT_SUCCESS(Status)) @@ -77,7 +105,7 @@ PBase = MmGetContinuousPages(NumberOfBytes, LowestAcceptableAddress, HighestAcceptableAddress, - Alignment); + BoundaryAddressMultiple); if (PBase == 0) { MmLockAddressSpace(MmGetKernelAddressSpace()); @@ -91,7 +119,7 @@ for (i = 0; i < (PAGE_ROUND_UP(NumberOfBytes) / PAGE_SIZE); i++, PBase++) { MmCreateVirtualMapping(NULL, - (char*)BaseAddress + (i * 4096), + (char*)BaseAddress + (i * PAGE_SIZE), Attributes, &PBase, 1); @@ -130,18 +158,11 @@ MmAllocateContiguousMemory (IN ULONG NumberOfBytes, IN PHYSICAL_ADDRESS HighestAcceptableAddress) { - PHYSICAL_ADDRESS LowestAcceptableAddress; - PHYSICAL_ADDRESS BoundaryAddressMultiple; - - LowestAcceptableAddress.QuadPart = 0; - BoundaryAddressMultiple.QuadPart = 0; - - return(MmAllocateContiguousAlignedMemory(NumberOfBytes, - LowestAcceptableAddress, - HighestAcceptableAddress, - BoundaryAddressMultiple, - MmCached, - PAGE_SIZE)); + return MmAllocateContiguousMemorySpecifyCache(NumberOfBytes, + (PHYSICAL_ADDRESS)0LL, + HighestAcceptableAddress, + (PHYSICAL_ADDRESS)0LL, + MmCached); } @@ -181,53 +202,6 @@ /********************************************************************** * NAME EXPORTED - * MmAllocateContiguousMemorySpecifyCache@32 - * - * 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. - * - * REVISIONS - * - * @implemented - */ -PVOID STDCALL -MmAllocateContiguousMemorySpecifyCache (IN ULONG NumberOfBytes, - IN PHYSICAL_ADDRESS LowestAcceptableAddress, - IN PHYSICAL_ADDRESS HighestAcceptableAddress, - IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, - IN MEMORY_CACHING_TYPE CacheType) -{ - return(MmAllocateContiguousAlignedMemory(NumberOfBytes, - LowestAcceptableAddress, - HighestAcceptableAddress, - BoundaryAddressMultiple, - CacheType, - PAGE_SIZE)); -} - -/********************************************************************** - * NAME EXPORTED * MmFreeContiguousMemorySpecifyCache@12 * * DESCRIPTION _____ Modified: trunk/reactos/ntoskrnl/mm/freelist.c --- trunk/reactos/ntoskrnl/mm/freelist.c 2005-08-07 23:05:57 UTC (rev 17184) +++ trunk/reactos/ntoskrnl/mm/freelist.c 2005-08-07 23:07:17 UTC (rev 17185) @@ -161,85 +161,102 @@ MmGetContinuousPages(ULONG NumberOfBytes, PHYSICAL_ADDRESS LowestAcceptableAddress, PHYSICAL_ADDRESS HighestAcceptableAddress, - ULONG Alignment) + PHYSICAL_ADDRESS BoundaryAddressMultiple) { ULONG NrPages; - ULONG i; + ULONG i, j; ULONG start; + ULONG last; ULONG length; + ULONG boundary; KIRQL oldIrql; NrPages = PAGE_ROUND_UP(NumberOfBytes) / PAGE_SIZE; KeAcquireSpinLock(&PageListLock, &oldIrql); - start = -1; - length = 0; - for (i = (LowestAcceptableAddress.QuadPart / PAGE_SIZE); i < (HighestAcceptableAddress.QuadPart / PAGE_SIZE); ) + last = min(HighestAcceptableAddress.QuadPart / PAGE_SIZE, MmPageArraySize - 1); + boundary = BoundaryAddressMultiple.QuadPart / PAGE_SIZE; + + for (j = 0; j < 2; j++) { - if (MmPageArray[i].Flags.Type == MM_PHYSICAL_PAGE_FREE) + start = -1; + length = 0; + /* First try to allocate the pages above the 16MB area. This may fail + * because there are not enough continuous pages or we cannot allocate + * pages above the 16MB area because the caller has specify an upper limit. + * The second try uses the specified lower limit. + */ + for (i = j == 0 ? 0x100000 / PAGE_SIZE : LowestAcceptableAddress.QuadPart / PAGE_SIZE; i <= last; ) { - if (start == (ULONG)-1) + if (MmPageArray[i].Flags.Type == MM_PHYSICAL_PAGE_FREE) { - start = i; - length = 1; + if (start == (ULONG)-1) + { + start = i; + length = 1; + } + else + { + length++; + if (boundary) + { + if (start / boundary != i / boundary) + { + start = i; + length = 1; + } + } + } + if (length == NrPages) + { + break; + } } else { - length++; + start = (ULONG)-1; } i++; - if (length == NrPages) + } + + if (start != (ULONG)-1 && length == NrPages) + { + for (i = start; i < (start + length); i++) { - break; + RemoveEntryList(&MmPageArray[i].ListEntry); + if (MmPageArray[i].Flags.Zero == 0) + { + UnzeroedPageCount--; + } + MmStats.NrFreePages--; + MmStats.NrSystemPages++; + MmPageArray[i].Flags.Type = MM_PHYSICAL_PAGE_USED; + MmPageArray[i].Flags.Consumer = MC_NPPOOL; + MmPageArray[i].ReferenceCount = 1; + MmPageArray[i].LockCount = 0; + MmPageArray[i].MapCount = 0; + MmPageArray[i].SavedSwapEntry = 0; + InsertTailList(&UsedPageListHeads[MC_NPPOOL], + &MmPageArray[i].ListEntry); } + KeReleaseSpinLock(&PageListLock, oldIrql); + for (i = start; i < (start + length); i++) + { + if (MmPageArray[i].Flags.Zero == 0) + { + MiZeroPage(i); + } + else + { + MmPageArray[i].Flags.Zero = 0; + } + } + return start; } - else - { - start = -1; - /* - * Fast forward to the base of the next aligned region - */ - i = ROUND_UP((i + 1), (Alignment / PAGE_SIZE)); - } } - if (start == (ULONG)-1 || length != NrPages) - { - KeReleaseSpinLock(&PageListLock, oldIrql); - return 0; - } - for (i = start; i < (start + length); i++) - { - RemoveEntryList(&MmPageArray[i].ListEntry); - if (MmPageArray[i].Flags.Zero == 0) - { - UnzeroedPageCount--; - } - MmStats.NrFreePages--; - MmStats.NrSystemPages++; - MmPageArray[i].Flags.Type = MM_PHYSICAL_PAGE_USED; - MmPageArray[i].Flags.Consumer = MC_NPPOOL; - MmPageArray[i].ReferenceCount = 1; - MmPageArray[i].LockCount = 0; - MmPageArray[i].MapCount = 0; - MmPageArray[i].SavedSwapEntry = 0; - InsertTailList(&UsedPageListHeads[MC_NPPOOL], - &MmPageArray[i].ListEntry); - } KeReleaseSpinLock(&PageListLock, oldIrql); - for (i = start; i < (start + length); i++) - { - if (MmPageArray[i].Flags.Zero == 0) - { - MiZeroPage(i); - } - else - { - MmPageArray[i].Flags.Zero = 0; - } - } - - return start; + return 0; } _____ Modified: trunk/reactos/ntoskrnl/ntoskrnl.def --- trunk/reactos/ntoskrnl/ntoskrnl.def 2005-08-07 23:05:57 UTC (rev 17184) +++ trunk/reactos/ntoskrnl/ntoskrnl.def 2005-08-07 23:07:17 UTC (rev 17185) @@ -680,7 +680,6 @@ MmAddVerifierThunks@8 MmAdjustWorkingSetSize@12 MmAdvanceMdl@8 -MmAllocateContiguousAlignedMemory@36 MmAllocateContiguousMemory@12 MmAllocateContiguousMemorySpecifyCache@32 MmAllocateMappingAddress@8
19 years, 4 months
1
0
0
0
[weiden] 17184: fixed differences in signedness warnings
by weiden@svn.reactos.com
fixed differences in signedness warnings Modified: trunk/reactos/drivers/storage/atapi/atapi.c _____ Modified: trunk/reactos/drivers/storage/atapi/atapi.c --- trunk/reactos/drivers/storage/atapi/atapi.c 2005-08-07 23:00:51 UTC (rev 17183) +++ trunk/reactos/drivers/storage/atapi/atapi.c 2005-08-07 23:05:57 UTC (rev 17184) @@ -293,10 +293,10 @@ // ---------------------------------------------------------------- Inlines void -IDESwapBytePairs(char *Buf, +IDESwapBytePairs(UCHAR *Buf, int Cnt) { - char t; + UCHAR t; int i; for (i = 0; i < Cnt; i += 2)
19 years, 4 months
1
0
0
0
[ion] 17183: - Fix return value.
by ion@svn.reactos.com
- Fix return value. Modified: trunk/reactos/ntoskrnl/ps/process.c _____ Modified: trunk/reactos/ntoskrnl/ps/process.c --- trunk/reactos/ntoskrnl/ps/process.c 2005-08-07 22:48:07 UTC (rev 17182) +++ trunk/reactos/ntoskrnl/ps/process.c 2005-08-07 23:00:51 UTC (rev 17183) @@ -513,7 +513,7 @@ { PHANDLE_TABLE_ENTRY CidEntry; PETHREAD FoundThread; - NTSTATUS Status = STATUS_INVALID_PARAMETER; + NTSTATUS Status = STATUS_INVALID_CID; PAGED_CODE(); /* Get the CID Handle Entry */
19 years, 4 months
1
0
0
0
[ion] 17182: - Remove cid.c
by ion@svn.reactos.com
- Remove cid.c - Do direct handle creation/deletion where needed. Modified: trunk/reactos/ntoskrnl/include/internal/ps.h Modified: trunk/reactos/ntoskrnl/ntoskrnl.xml Modified: trunk/reactos/ntoskrnl/ps/cid.c Modified: trunk/reactos/ntoskrnl/ps/kill.c Modified: trunk/reactos/ntoskrnl/ps/process.c Modified: trunk/reactos/ntoskrnl/ps/psmgr.c Modified: trunk/reactos/ntoskrnl/ps/thread.c _____ Modified: trunk/reactos/ntoskrnl/include/internal/ps.h --- trunk/reactos/ntoskrnl/include/internal/ps.h 2005-08-07 21:48:14 UTC (rev 17181) +++ trunk/reactos/ntoskrnl/include/internal/ps.h 2005-08-07 22:48:07 UTC (rev 17182) @@ -216,10 +216,6 @@ /* CLIENT ID */ -NTSTATUS PsCreateCidHandle(PVOID Object, POBJECT_TYPE ObjectType, PHANDLE Handle); -NTSTATUS PsDeleteCidHandle(HANDLE CidHandle, POBJECT_TYPE ObjectType); -PHANDLE_TABLE_ENTRY PsLookupCidHandle(HANDLE CidHandle, POBJECT_TYPE ObjectType, PVOID *Object); -VOID PsUnlockCidHandle(PHANDLE_TABLE_ENTRY CidEntry); NTSTATUS PsLockProcess(PEPROCESS Process, BOOLEAN Timeout); VOID PsUnlockProcess(PEPROCESS Process); _____ Modified: trunk/reactos/ntoskrnl/ntoskrnl.xml --- trunk/reactos/ntoskrnl/ntoskrnl.xml 2005-08-07 21:48:14 UTC (rev 17181) +++ trunk/reactos/ntoskrnl/ntoskrnl.xml 2005-08-07 22:48:07 UTC (rev 17182) @@ -290,7 +290,6 @@ <file>continue.c</file> </directory> </if> - <file>cid.c</file> <file>debug.c</file> <file>idle.c</file> <file>job.c</file> _____ Modified: trunk/reactos/ntoskrnl/ps/cid.c --- trunk/reactos/ntoskrnl/ps/cid.c 2005-08-07 21:48:14 UTC (rev 17181) +++ trunk/reactos/ntoskrnl/ps/cid.c 2005-08-07 22:48:07 UTC (rev 17182) @@ -18,117 +18,16 @@ PHANDLE_TABLE PspCidTable = NULL; -#define CID_FLAG_PROCESS 0x1 -#define CID_FLAG_THREAD 0x2 -#define CID_FLAGS_MASK (CID_FLAG_PROCESS | CID_FLAG_THREAD) - /* FUNCTIONS *****************************************************************/ -VOID INIT_FUNCTION +VOID +INIT_FUNCTION PsInitClientIDManagment(VOID) { PspCidTable = ExCreateHandleTable(NULL); ASSERT(PspCidTable); } -NTSTATUS -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; - else if(ObjectType == PsProcessType) - NewEntry.u2.GrantedAccess = CID_FLAG_PROCESS; - else - { - DPRINT1("Can't create CID handles for %wZ objects\n", &ObjectType->Name); - KEBUGCHECK(0); - } - - ExHandle = ExCreateHandle(PspCidTable, - &NewEntry); - if(ExHandle != EX_INVALID_HANDLE) - { - *Handle = EX_HANDLE_TO_HANDLE(ExHandle); - return STATUS_SUCCESS; - } - - return STATUS_UNSUCCESSFUL; -} - -NTSTATUS -PsDeleteCidHandle(HANDLE CidHandle, POBJECT_TYPE ObjectType) -{ - PHANDLE_TABLE_ENTRY Entry; - LONG ExHandle = HANDLE_TO_EX_HANDLE(CidHandle); - - PAGED_CODE(); - - KeEnterCriticalRegion(); - - Entry = ExMapHandleToPointer(PspCidTable, - ExHandle); - if(Entry != NULL) - { - if((ObjectType == PsThreadType && ((Entry->u2.GrantedAccess & CID_FLAGS_MASK) == CID_FLAG_THREAD)) || - (ObjectType == PsProcessType && ((Entry->u2.GrantedAccess & CID_FLAGS_MASK) == CID_FLAG_PROCESS))) - { - ExDestroyHandleByEntry(PspCidTable, - Entry, - ExHandle); - KeLeaveCriticalRegion(); - return STATUS_SUCCESS; - } - else - { - ExUnlockHandleTableEntry(PspCidTable, - Entry); - KeLeaveCriticalRegion(); - return STATUS_OBJECT_TYPE_MISMATCH; - } - } - KeLeaveCriticalRegion(); - return STATUS_INVALID_HANDLE; -} - -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) - { - if((ObjectType == PsProcessType && ((Entry->u2.GrantedAccess & CID_FLAGS_MASK) == CID_FLAG_PROCESS)) || - (ObjectType == PsThreadType && ((Entry->u2.GrantedAccess & CID_FLAGS_MASK) == CID_FLAG_THREAD))) - { - *Object = Entry->u1.Object; - return Entry; - } - else - { - DPRINT1("CID Obj type mismatch handle 0x%x %wZ vs 0x%x\n", CidHandle, - &ObjectType->Name, Entry->u2.GrantedAccess); - ExUnlockHandleTableEntry(PspCidTable, - Entry); - } - } - - KeLeaveCriticalRegion(); - - return NULL; -} - /* * @implemented */ _____ Modified: trunk/reactos/ntoskrnl/ps/kill.c --- trunk/reactos/ntoskrnl/ps/kill.c 2005-08-07 21:48:14 UTC (rev 17181) +++ trunk/reactos/ntoskrnl/ps/kill.c 2005-08-07 22:48:07 UTC (rev 17182) @@ -21,6 +21,7 @@ BOOLEAN PspReaping = FALSE; extern LIST_ENTRY PsActiveProcessHead; extern FAST_MUTEX PspActiveProcessMutex; +extern PHANDLE_TABLE PspCidTable; /* FUNCTIONS *****************************************************************/ @@ -153,9 +154,9 @@ ExReleaseFastMutex(&PspActiveProcessMutex); /* Delete the CID Handle */ - if(Process->UniqueProcessId != NULL) { - - PsDeleteCidHandle(Process->UniqueProcessId, PsProcessType); + if(Process->UniqueProcessId) + { + ExDestroyHandle(PspCidTable, Process->UniqueProcessId); } /* KDB hook */ @@ -184,9 +185,9 @@ Thread->ThreadsProcess = NULL; /* Delete the CID Handle */ - if(Thread->Cid.UniqueThread != NULL) { - - PsDeleteCidHandle(Thread->Cid.UniqueThread, PsThreadType); + if(Thread->Cid.UniqueThread) + { + ExDestroyHandle(PspCidTable, Thread->Cid.UniqueThread); } /* Free the W32THREAD structure if present */ _____ Modified: trunk/reactos/ntoskrnl/ps/process.c --- trunk/reactos/ntoskrnl/ps/process.c 2005-08-07 21:48:14 UTC (rev 17181) +++ trunk/reactos/ntoskrnl/ps/process.c 2005-08-07 22:48:07 UTC (rev 17182) @@ -19,6 +19,7 @@ PEPROCESS EXPORTED PsInitialSystemProcess = NULL; PEPROCESS PsIdleProcess = NULL; POBJECT_TYPE EXPORTED PsProcessType = NULL; +extern PHANDLE_TABLE PspCidTable; EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock; @@ -189,6 +190,7 @@ KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); PHYSICAL_ADDRESS DirectoryTableBase; KAFFINITY Affinity; + HANDLE_TABLE_ENTRY CidEntry; DirectoryTableBase.QuadPart = (ULONGLONG)0; DPRINT("PspCreateProcess(ObjectAttributes %x)\n", ObjectAttributes); @@ -362,13 +364,13 @@ /* Create a handle for the Process */ DPRINT("Initialzing Process CID Handle\n"); - Status = PsCreateCidHandle(Process, - PsProcessType, - &Process->UniqueProcessId); + CidEntry.u1.Object = Process; + CidEntry.u2.GrantedAccess = 0; + Process->UniqueProcessId = (ExCreateHandle(PspCidTable, &CidEntry)); DPRINT("Created CID: %d\n", Process->UniqueProcessId); - if(!NT_SUCCESS(Status)) + if(!Process->UniqueProcessId) { - DPRINT1("Failed to create CID handle (unique process ID)! Status: 0x%x\n", Status); + DPRINT1("Failed to create CID handle\n"); ObDereferenceObject(Process); goto exitdereferenceobjects; } @@ -471,25 +473,80 @@ PsLookupProcessByProcessId(IN HANDLE ProcessId, OUT PEPROCESS *Process) { - PHANDLE_TABLE_ENTRY CidEntry; - PEPROCESS FoundProcess; + PHANDLE_TABLE_ENTRY CidEntry; + PEPROCESS FoundProcess; + NTSTATUS Status = STATUS_INVALID_PARAMETER; + PAGED_CODE(); - PAGED_CODE(); + /* Get the CID Handle Entry */ + if (!(CidEntry = ExMapHandleToPointer(PspCidTable, + HANDLE_TO_EX_HANDLE(ProcessId)))) + { + /* Get the Process */ + FoundProcess = CidEntry->u1.Object; - ASSERT(Process); + /* Make sure it's really a process */ + if (FoundProcess->Pcb.Header.Type == ProcessObject) + { + /* Reference and return it */ + ObReferenceObject(FoundProcess); + *Process = FoundProcess; + Status = STATUS_SUCCESS; + } - CidEntry = PsLookupCidHandle(ProcessId, PsProcessType, (PVOID*)&FoundProcess); - if(CidEntry != NULL) - { - ObReferenceObject(FoundProcess); + /* Unlock the Entry */ + ExUnlockHandleTableEntry(PspCidTable, CidEntry); + } - PsUnlockCidHandle(CidEntry); + /* Return to caller */ + return Status; +} - *Process = FoundProcess; - return STATUS_SUCCESS; +/* + * @implemented + */ +NTSTATUS +STDCALL +PsLookupProcessThreadByCid(IN PCLIENT_ID Cid, + OUT PEPROCESS *Process OPTIONAL, + OUT PETHREAD *Thread) +{ + PHANDLE_TABLE_ENTRY CidEntry; + PETHREAD FoundThread; + NTSTATUS Status = STATUS_INVALID_PARAMETER; + PAGED_CODE(); + + /* Get the CID Handle Entry */ + if (!(CidEntry = ExMapHandleToPointer(PspCidTable, + HANDLE_TO_EX_HANDLE(Cid->UniqueThread)))) + { + /* Get the Process */ + FoundThread = CidEntry->u1.Object; + + /* Make sure it's really a thread and this process' */ + if ((FoundThread->Tcb.DispatcherHeader.Type == ThreadObject) && + (FoundThread->Cid.UniqueProcess == Cid->UniqueProcess)) + { + /* Reference and return it */ + ObReferenceObject(FoundThread); + *Thread = FoundThread; + Status = STATUS_SUCCESS; + + /* Check if we should return the Process too */ + if (Process) + { + /* Return it and reference it */ + *Process = FoundThread->ThreadsProcess; + ObReferenceObject(*Process); + } + } + + /* Unlock the Entry */ + ExUnlockHandleTableEntry(PspCidTable, CidEntry); } - return STATUS_INVALID_PARAMETER; + /* Return to caller */ + return Status; } /* _____ Modified: trunk/reactos/ntoskrnl/ps/psmgr.c --- trunk/reactos/ntoskrnl/ps/psmgr.c 2005-08-07 21:48:14 UTC (rev 17181) +++ trunk/reactos/ntoskrnl/ps/psmgr.c 2005-08-07 22:48:07 UTC (rev 17182) @@ -44,11 +44,7 @@ PVOID PspSystemDllBase = NULL; PVOID PspSystemDllSection = NULL; PVOID PspSystemDllEntryPoint = NULL; - -VOID -INIT_FUNCTION -PsInitClientIDManagment(VOID); - +PHANDLE_TABLE PspCidTable = NULL; VOID STDCALL PspKillMostProcesses(); /* FUNCTIONS ***************************************************************/ @@ -72,6 +68,14 @@ VOID INIT_FUNCTION +PsInitClientIDManagment(VOID) +{ + PspCidTable = ExCreateHandleTable(NULL); + ASSERT(PspCidTable); +} + +VOID +INIT_FUNCTION PsInitThreadManagment(VOID) /* * FUNCTION: Initialize thread managment @@ -261,7 +265,7 @@ VOID PspPostInitSystemProcess(VOID) { - NTSTATUS Status; + HANDLE_TABLE_ENTRY CidEntry; /* 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 @@ -271,10 +275,11 @@ ObCreateHandleTable(NULL, FALSE, PsInitialSystemProcess); ObpKernelHandleTable = PsInitialSystemProcess->ObjectTable; - Status = PsCreateCidHandle(PsInitialSystemProcess, - PsProcessType, - &PsInitialSystemProcess->UniqueProcessId); - if(!NT_SUCCESS(Status)) + CidEntry.u1.Object = PsInitialSystemProcess; + CidEntry.u2.GrantedAccess = 0; + PsInitialSystemProcess->UniqueProcessId = ExCreateHandle(PspCidTable, &CidEntry); + + if(!PsInitialSystemProcess->UniqueProcessId) { DPRINT1("Failed to create CID handle (unique process id) for the system process!\n"); KEBUGCHECK(0); _____ Modified: trunk/reactos/ntoskrnl/ps/thread.c --- trunk/reactos/ntoskrnl/ps/thread.c 2005-08-07 21:48:14 UTC (rev 17181) +++ trunk/reactos/ntoskrnl/ps/thread.c 2005-08-07 22:48:07 UTC (rev 17182) @@ -19,6 +19,7 @@ extern LIST_ENTRY PsActiveProcessHead; extern PEPROCESS PsIdleProcess; extern PVOID PspSystemDllEntryPoint; +extern PHANDLE_TABLE PspCidTable; POBJECT_TYPE EXPORTED PsThreadType = NULL; @@ -114,6 +115,7 @@ KIRQL OldIrql; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); NTSTATUS Status; + HANDLE_TABLE_ENTRY CidEntry; PVOID KernelStack; /* Reference the Process by handle or pointer, depending on what we got */ @@ -180,12 +182,15 @@ /* Create Cid Handle */ DPRINT("Creating Thread Handle (CID)\n"); - if (!(NT_SUCCESS(PsCreateCidHandle(Thread, PsThreadType, &Thread->Cid.UniqueThread)))) { + CidEntry.u1.Object = Thread; + CidEntry.u2.GrantedAccess = 0; + Thread->Cid.UniqueThread = ExCreateHandle(PspCidTable, &CidEntry); + if (!Thread->Cid.UniqueThread) { DPRINT1("Failed to create Thread Handle (CID)\n"); ObDereferenceObject(Process); ObDereferenceObject(Thread); - return Status; + return STATUS_INSUFFICIENT_RESOURCES; } /* Initialize Lists */ @@ -360,6 +365,43 @@ /* * @implemented */ +NTSTATUS +STDCALL +PsLookupThreadByThreadId(IN HANDLE ThreadId, + OUT PETHREAD *Thread) +{ + PHANDLE_TABLE_ENTRY CidEntry; + PETHREAD FoundThread; + NTSTATUS Status = STATUS_INVALID_PARAMETER; + PAGED_CODE(); + + /* Get the CID Handle Entry */ + if (!(CidEntry = ExMapHandleToPointer(PspCidTable, + HANDLE_TO_EX_HANDLE(ThreadId)))) + { + /* Get the Process */ + FoundThread = CidEntry->u1.Object; + + /* Make sure it's really a process */ + if (FoundThread->Tcb.DispatcherHeader.Type == ThreadObject) + { + /* Reference and return it */ + ObReferenceObject(FoundThread); + *Thread = FoundThread; + Status = STATUS_SUCCESS; + } + + /* Unlock the Entry */ + ExUnlockHandleTableEntry(PspCidTable, CidEntry); + } + + /* Return to caller */ + return Status; +} + +/* + * @implemented + */ HANDLE STDCALL PsGetCurrentThreadId(VOID)
19 years, 4 months
1
0
0
0
[ion] 17181: - Return correct error. Spotted by Thomas.
by ion@svn.reactos.com
- Return correct error. Spotted by Thomas. Modified: trunk/reactos/ntoskrnl/ps/cid.c _____ Modified: trunk/reactos/ntoskrnl/ps/cid.c --- trunk/reactos/ntoskrnl/ps/cid.c 2005-08-07 21:45:12 UTC (rev 17180) +++ trunk/reactos/ntoskrnl/ps/cid.c 2005-08-07 21:48:14 UTC (rev 17181) @@ -139,6 +139,7 @@ { PHANDLE_TABLE_ENTRY CidEntry; PETHREAD FoundThread; + NTSTATUS Status = STATUS_INVALID_CID; PAGED_CODE(); @@ -157,10 +158,10 @@ *Process = FoundThread->ThreadsProcess; } *Thread = FoundThread; - return STATUS_SUCCESS; + Status = STATUS_SUCCESS; } - return STATUS_INVALID_PARAMETER; + return Status; } @@ -173,6 +174,7 @@ { PHANDLE_TABLE_ENTRY CidEntry; PETHREAD FoundThread; + NTSTATUS Status = STATUS_INVALID_CID; PAGED_CODE(); @@ -186,10 +188,10 @@ PsUnlockCidHandle(CidEntry); *Thread = FoundThread; - return STATUS_SUCCESS; + Status = STATUS_SUCCESS; } - return STATUS_INVALID_PARAMETER; + return Status; } VOID
19 years, 4 months
1
0
0
0
[ion] 17180: - Send proper ClientID structure
by ion@svn.reactos.com
- Send proper ClientID structure Modified: trunk/reactos/lib/kernel32/thread/thread.c _____ Modified: trunk/reactos/lib/kernel32/thread/thread.c --- trunk/reactos/lib/kernel32/thread/thread.c 2005-08-07 21:29:51 UTC (rev 17179) +++ trunk/reactos/lib/kernel32/thread/thread.c 2005-08-07 21:45:12 UTC (rev 17180) @@ -267,7 +267,7 @@ OBJECT_ATTRIBUTES ObjectAttributes; CLIENT_ID ClientId ; - ClientId.UniqueProcess = INVALID_HANDLE_VALUE; + ClientId.UniqueProcess = 0; ClientId.UniqueThread = (HANDLE)dwThreadId; InitializeObjectAttributes (&ObjectAttributes,
19 years, 4 months
1
0
0
0
[ion] 17179: - Completely reimplement NtWaitForMultipleObjects:
by ion@svn.reactos.com
- Completely reimplement NtWaitForMultipleObjects: - Check for invalid Objectcount and wait type - Don't use 2.6KB of stack space (kernel threads only get 4...) - Don't call ObReferenceObjectByHandle since it does a lot of superflous checks, continous locking/unlocking and makes us extremly slow for a large wait and also doesn't give us the full flexibility we need. - Detect if a Waitall is being done with the same object duplicated. - Protect wait with SEH. - General fixes for all NtWaitXXX: - Use DefaultObject from Object Header and remove all previous associated hacks, including the IO_TYPE hack. The DefaultObject will either be NULL, an offset to an internal Object Event, or a pointer to a default event. We handle all three. - Guard the KeWaitXXX call with SEH since it can raise exceptions. - Fix all object type intiailizers regarding DefaultObject. Modified: trunk/reactos/ntoskrnl/ex/callback.c Modified: trunk/reactos/ntoskrnl/ex/event.c Modified: trunk/reactos/ntoskrnl/ex/mutant.c Modified: trunk/reactos/ntoskrnl/ex/profile.c Modified: trunk/reactos/ntoskrnl/ex/win32k.c Modified: trunk/reactos/ntoskrnl/include/internal/ex.h Modified: trunk/reactos/ntoskrnl/include/ntoskrnl.h Modified: trunk/reactos/ntoskrnl/io/iomgr.c Modified: trunk/reactos/ntoskrnl/ke/wait.c Modified: trunk/reactos/ntoskrnl/ob/handle.c Modified: trunk/reactos/ntoskrnl/ob/wait.c Modified: trunk/reactos/ntoskrnl/ps/psmgr.c _____ Modified: trunk/reactos/ntoskrnl/ex/callback.c --- trunk/reactos/ntoskrnl/ex/callback.c 2005-08-07 20:33:11 UTC (rev 17178) +++ trunk/reactos/ntoskrnl/ex/callback.c 2005-08-07 21:29:51 UTC (rev 17179) @@ -91,7 +91,6 @@ ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(CALLBACK_OBJECT); ObjectTypeInitializer.GenericMapping = ExpCallbackMapping; ObjectTypeInitializer.PoolType = NonPagedPool; - ObjectTypeInitializer.UseDefaultObject = TRUE; Status = ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ExCallbackObjectType); _____ Modified: trunk/reactos/ntoskrnl/ex/event.c --- trunk/reactos/ntoskrnl/ex/event.c 2005-08-07 20:33:11 UTC (rev 17178) +++ trunk/reactos/ntoskrnl/ex/event.c 2005-08-07 21:29:51 UTC (rev 17179) @@ -50,7 +50,6 @@ ObjectTypeInitializer.GenericMapping = ExpEventMapping; ObjectTypeInitializer.PoolType = NonPagedPool; ObjectTypeInitializer.ValidAccessMask = EVENT_ALL_ACCESS; - ObjectTypeInitializer.UseDefaultObject = TRUE; ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ExEventObjectType); } _____ Modified: trunk/reactos/ntoskrnl/ex/mutant.c --- trunk/reactos/ntoskrnl/ex/mutant.c 2005-08-07 20:33:11 UTC (rev 17178) +++ trunk/reactos/ntoskrnl/ex/mutant.c 2005-08-07 21:29:51 UTC (rev 17179) @@ -68,7 +68,6 @@ ObjectTypeInitializer.PoolType = NonPagedPool; ObjectTypeInitializer.DeleteProcedure = ExpDeleteMutant; ObjectTypeInitializer.ValidAccessMask = MUTANT_ALL_ACCESS; - ObjectTypeInitializer.UseDefaultObject = TRUE; ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ExMutantObjectType); } _____ Modified: trunk/reactos/ntoskrnl/ex/profile.c --- trunk/reactos/ntoskrnl/ex/profile.c 2005-08-07 20:33:11 UTC (rev 17178) +++ trunk/reactos/ntoskrnl/ex/profile.c 2005-08-07 21:29:51 UTC (rev 17179) @@ -94,7 +94,6 @@ ObjectTypeInitializer.PoolType = NonPagedPool; ObjectTypeInitializer.DeleteProcedure = ExpDeleteProfile; ObjectTypeInitializer.ValidAccessMask = STANDARD_RIGHTS_ALL; - ObjectTypeInitializer.UseDefaultObject = TRUE; ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ExProfileObjectType); } _____ Modified: trunk/reactos/ntoskrnl/ex/win32k.c --- trunk/reactos/ntoskrnl/ex/win32k.c 2005-08-07 20:33:11 UTC (rev 17178) +++ trunk/reactos/ntoskrnl/ex/win32k.c 2005-08-07 21:29:51 UTC (rev 17179) @@ -133,7 +133,6 @@ ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer); ObjectTypeInitializer.GenericMapping = ExpWindowStationMapping; ObjectTypeInitializer.PoolType = NonPagedPool; - ObjectTypeInitializer.UseDefaultObject = TRUE; ObjectTypeInitializer.OpenProcedure = ExpWinStaObjectOpen; ObjectTypeInitializer.DeleteProcedure = ExpWinStaObjectDelete; ObjectTypeInitializer.ParseProcedure = ExpWinStaObjectParse; _____ Modified: trunk/reactos/ntoskrnl/include/internal/ex.h --- trunk/reactos/ntoskrnl/include/internal/ex.h 2005-08-07 20:33:11 UTC (rev 17178) +++ trunk/reactos/ntoskrnl/include/internal/ex.h 2005-08-07 21:29:51 UTC (rev 17179) @@ -8,6 +8,13 @@ extern ULONG ExpTimeZoneId; extern POBJECT_TYPE ExEventPairObjectType; +#define EX_OBJ_TO_HDR(eob) ((POBJECT_HEADER)((ULONG_PTR)(eob) & \ + ~(EX_HANDLE_ENTRY_PROTECTFROMCLOSE | EX_HANDLE_ENTRY_INHERITABLE | \ + EX_HANDLE_ENTRY_AUDITONCLOSE))) +#define EX_HTE_TO_HDR(hte) ((POBJECT_HEADER)((ULONG_PTR)((hte)->u1.Object) & \ + ~(EX_HANDLE_ENTRY_PROTECTFROMCLOSE | EX_HANDLE_ENTRY_INHERITABLE | \ + EX_HANDLE_ENTRY_AUDITONCLOSE))) + /* INITIALIZATION FUNCTIONS *************************************************/ VOID _____ Modified: trunk/reactos/ntoskrnl/include/ntoskrnl.h --- trunk/reactos/ntoskrnl/include/ntoskrnl.h 2005-08-07 20:33:11 UTC (rev 17178) +++ trunk/reactos/ntoskrnl/include/ntoskrnl.h 2005-08-07 21:29:51 UTC (rev 17179) @@ -18,8 +18,6 @@ #include <ndk/ntndk.h> #include <ndk/sysguid.h> #include <ndk/asm.h> -#undef IO_TYPE_FILE -#define IO_TYPE_FILE 0x0F5L /* Temp Hack */ /* FIXME: Temporary until CC Ros is gone */ #include <ccros.h> _____ Modified: trunk/reactos/ntoskrnl/io/iomgr.c --- trunk/reactos/ntoskrnl/io/iomgr.c 2005-08-07 20:33:11 UTC (rev 17178) +++ trunk/reactos/ntoskrnl/io/iomgr.c 2005-08-07 21:29:51 UTC (rev 17179) @@ -217,6 +217,7 @@ ObjectTypeInitializer.DeleteProcedure = IopDeleteFile; ObjectTypeInitializer.SecurityProcedure = IopSecurityFile; ObjectTypeInitializer.QueryNameProcedure = IopQueryNameFile; + ObjectTypeInitializer.UseDefaultObject = FALSE; ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &IoFileObjectType); /* _____ Modified: trunk/reactos/ntoskrnl/ke/wait.c --- trunk/reactos/ntoskrnl/ke/wait.c 2005-08-07 20:33:11 UTC (rev 17178) +++ trunk/reactos/ntoskrnl/ke/wait.c 2005-08-07 21:29:51 UTC (rev 17179) @@ -225,22 +225,6 @@ /* Get the Current Object */ CurrentObject = (PDISPATCHER_HEADER)Object; - /* 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, - * by using pretty much the same kind of hack as us. Normal objects point to themselves - * in that pointer. Then, NtWaitForXXX will populate the WaitList that gets sent to us by - * using ->DefaultObject, so the proper actual objects will be sent to us. Until then however, - * I will keep this hack here, since there's no need to make an interim hack until the rewrite - * -- 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)) { @@ -441,21 +425,6 @@ /* Get the Current Object */ CurrentObject = (PDISPATCHER_HEADER)Object[WaitIndex]; - /* 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, - * by using pretty much the same kind of hack as us. Normal objects point to themselves - * in that pointer. Then, NtWaitForXXX will populate the WaitList that gets sent to us by - * using ->DefaultObject, so the proper actual objects will be sent to us. Until then however, - * I will keep this hack here, since there's no need to make an interim hack until the rewrite - * -- 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)) { @@ -807,31 +776,6 @@ return (!Object->SignalState <= 0); } -BOOL -inline -FASTCALL -KiIsObjectWaitable(PVOID Object) -{ - POBJECT_HEADER Header; - Header = BODY_TO_HEADER(Object); - - if (Header->Type == ExEventObjectType || - Header->Type == IoCompletionType || - Header->Type == ExMutantObjectType || - Header->Type == ExSemaphoreObjectType || - Header->Type == ExTimerType || - Header->Type == PsProcessType || - Header->Type == PsThreadType || - Header->Type == IoFileObjectType) { - - return TRUE; - - } else { - - return FALSE; - } -} - VOID inline FASTCALL _____ Modified: trunk/reactos/ntoskrnl/ob/handle.c --- trunk/reactos/ntoskrnl/ob/handle.c 2005-08-07 20:33:11 UTC (rev 17178) +++ trunk/reactos/ntoskrnl/ob/handle.c 2005-08-07 21:29:51 UTC (rev 17179) @@ -33,13 +33,6 @@ #define NDEBUG #include <internal/debug.h> -#define EX_OBJ_TO_HDR(eob) ((POBJECT_HEADER)((ULONG_PTR)(eob) & \ - ~(EX_HANDLE_ENTRY_PROTECTFROMCLOSE | EX_HANDLE_ENTRY_INHERITABLE | \ - EX_HANDLE_ENTRY_AUDITONCLOSE))) -#define EX_HTE_TO_HDR(hte) ((POBJECT_HEADER)((ULONG_PTR)((hte)->u1.Object) & \ - ~(EX_HANDLE_ENTRY_PROTECTFROMCLOSE | EX_HANDLE_ENTRY_INHERITABLE | \ - EX_HANDLE_ENTRY_AUDITONCLOSE))) - #define GENERIC_ANY (GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL) /* GLOBALS *****************************************************************/ _____ Modified: trunk/reactos/ntoskrnl/ob/wait.c --- trunk/reactos/ntoskrnl/ob/wait.c 2005-08-07 20:33:11 UTC (rev 17178) +++ trunk/reactos/ntoskrnl/ob/wait.c 2005-08-07 21:29:51 UTC (rev 17179) @@ -4,7 +4,7 @@ * FILE: ntoskrnl/ob/wait.c * PURPOSE: Handles Waiting on Objects * - * PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net) - Created file + * PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net) * David Welch (welch(a)mcmail.com) */ @@ -14,188 +14,322 @@ #define NDEBUG #include <internal/debug.h> +#define TAG_WAIT TAG('W', 'a', 'i', 't') + /* FUNCTIONS *****************************************************************/ -BOOL inline FASTCALL KiIsObjectWaitable(PVOID Object); - -NTSTATUS STDCALL +NTSTATUS +STDCALL NtWaitForMultipleObjects(IN ULONG ObjectCount, - IN PHANDLE ObjectsArray, - IN WAIT_TYPE WaitType, - IN BOOLEAN Alertable, - IN PLARGE_INTEGER TimeOut OPTIONAL) + IN PHANDLE HandleArray, + IN WAIT_TYPE WaitType, + IN BOOLEAN Alertable, + IN PLARGE_INTEGER TimeOut OPTIONAL) { - KWAIT_BLOCK WaitBlockArray[MAXIMUM_WAIT_OBJECTS]; - HANDLE SafeObjectsArray[MAXIMUM_WAIT_OBJECTS]; - PVOID ObjectPtrArray[MAXIMUM_WAIT_OBJECTS]; - ULONG i, j; - KPROCESSOR_MODE PreviousMode; - LARGE_INTEGER SafeTimeOut; - NTSTATUS Status = STATUS_SUCCESS; + PKWAIT_BLOCK WaitBlockArray = NULL; + HANDLE Handles[MAXIMUM_WAIT_OBJECTS]; + PVOID Objects[MAXIMUM_WAIT_OBJECTS]; + PVOID WaitObjects[MAXIMUM_WAIT_OBJECTS]; + ULONG i = 0, ReferencedObjects = 0, j; + KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); + LARGE_INTEGER SafeTimeOut; + BOOLEAN LockInUse; + PHANDLE_TABLE_ENTRY HandleEntry; + POBJECT_HEADER ObjectHeader; + PHANDLE_TABLE HandleTable; + ACCESS_MASK GrantedAccess; + LONG ExHandle; + PVOID DefaultObject; + NTSTATUS Status = STATUS_SUCCESS; - DPRINT("NtWaitForMultipleObjects(ObjectCount %lu ObjectsArray[] %x, Alertable %d, " - "TimeOut %x)\n", ObjectCount,ObjectsArray,Alertable,TimeOut); + DPRINT("NtWaitForMultipleObjects(ObjectCount %lu HandleArray[] %x, Alertable %d, " + "TimeOut %x)\n", ObjectCount, HandleArray, Alertable, TimeOut); - PreviousMode = ExGetPreviousMode(); + /* Enter a critical region since we'll play with handles */ + LockInUse = TRUE; + KeEnterCriticalRegion(); - if (ObjectCount > MAXIMUM_WAIT_OBJECTS) - return STATUS_UNSUCCESSFUL; - if (0 == ObjectCount) - return STATUS_INVALID_PARAMETER; + /* Check for valid Object Count */ + if ((ObjectCount > MAXIMUM_WAIT_OBJECTS) || !ObjectCount) + { + Status = STATUS_INVALID_PARAMETER_1; + DPRINT1("No object count, or too many objects\n"); + goto Quickie; + } - if(PreviousMode != KernelMode) - { - _SEH_TRY - { - ProbeForRead(ObjectsArray, - ObjectCount * sizeof(ObjectsArray[0]), - sizeof(ULONG)); - /* make a copy so we don't have to guard with SEH later and keep track of - what objects we referenced in case dereferencing pointers suddenly fails */ - RtlCopyMemory(SafeObjectsArray, ObjectsArray, ObjectCount * sizeof(ObjectsArray[0])); - ObjectsArray = SafeObjectsArray; + /* Check for valid Wait Type */ + if ((WaitType != WaitAll) && (WaitType != WaitAny)) + { + Status = STATUS_INVALID_PARAMETER_3; + DPRINT1("Invalid wait type\n"); + goto Quickie; + } - if(TimeOut != NULL) - { - ProbeForRead(TimeOut, - sizeof(LARGE_INTEGER), - sizeof(ULONG)); - /* make a local copy of the timeout on the stack */ - SafeTimeOut = *TimeOut; - TimeOut = &SafeTimeOut; - } - } - _SEH_HANDLE - { - Status = _SEH_GetExceptionCode(); - } - _SEH_END; + /* Capture arguments */ + _SEH_TRY + { + if(PreviousMode != KernelMode) + { + ProbeForRead(HandleArray, + ObjectCount * sizeof(HANDLE), + sizeof(HANDLE)); + + if(TimeOut) + { + ProbeForRead(TimeOut, + sizeof(LARGE_INTEGER), + sizeof(ULONG)); - if(!NT_SUCCESS(Status)) - { - return Status; - } - } + /* Make a local copy of the timeout on the stack */ + SafeTimeOut = *TimeOut; + TimeOut = &SafeTimeOut; + } + } - /* reference all objects */ - for (i = 0; i < ObjectCount; i++) - { - Status = ObReferenceObjectByHandle(ObjectsArray[i], - SYNCHRONIZE, - NULL, - PreviousMode, - &ObjectPtrArray[i], - NULL); - if (!NT_SUCCESS(Status) || !KiIsObjectWaitable(ObjectPtrArray[i])) - { - if (NT_SUCCESS(Status)) - { - DPRINT1("Waiting for object type '%wZ' is not supported\n", - &BODY_TO_HEADER(ObjectPtrArray[i])->Type->Name); - Status = STATUS_INVALID_HANDLE; - i++; - } - /* dereference all referenced objects */ - for (j = 0; j < i; j++) - { - ObDereferenceObject(ObjectPtrArray[j]); - } + /* + * Make a copy so we don't have to guard with SEH later and keep + * track of what objects we referenced if dereferencing pointers + * suddenly fails + */ + RtlCopyMemory(Handles, + HandleArray, + ObjectCount * sizeof(HANDLE)); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; - return(Status); - } - } + if(!NT_SUCCESS(Status)) goto Quickie; - Status = KeWaitForMultipleObjects(ObjectCount, - ObjectPtrArray, - WaitType, - UserRequest, - PreviousMode, - Alertable, - TimeOut, - WaitBlockArray); + /* Check if we can use the internal Wait Array */ + if (ObjectCount > THREAD_WAIT_OBJECTS) + { + /* Allocate from Pool */ + WaitBlockArray = ExAllocatePoolWithTag(NonPagedPool, + ObjectCount * sizeof(KWAIT_BLOCK), + TAG_WAIT); + } - /* dereference all objects */ - for (i = 0; i < ObjectCount; i++) - { - ObDereferenceObject(ObjectPtrArray[i]); - } + /* Start the loop */ + do + { + /* Use the right Executive Handle */ + if(ObIsKernelHandle(Handles[i], PreviousMode)) + { + /* Use the System Handle Table and decode */ + HandleTable = ObpKernelHandleTable; + ExHandle = HANDLE_TO_EX_HANDLE(ObKernelHandleToHandle(Handles[i])); + } + else + { + /* Use the Process' Handle table and get the Ex Handle */ + HandleTable = PsGetCurrentProcess()->ObjectTable; + ExHandle = HANDLE_TO_EX_HANDLE(Handles[i]); + } - return(Status); + /* Get a pointer to it */ + if (!(HandleEntry = ExMapHandleToPointer(HandleTable, ExHandle))) + { + DPRINT1("Invalid handle\n"); + Status = STATUS_INVALID_HANDLE; + goto Quickie; + } + + /* Check for synchronize access */ + GrantedAccess = HandleEntry->u2.GrantedAccess; + if ((PreviousMode != KernelMode) && (!(GrantedAccess & SYNCHRONIZE))) + { + /* Unlock the entry and fail */ + ExUnlockHandleTableEntry(HandleTable, HandleEntry); + Status = STATUS_ACCESS_DENIED; + DPRINT1("Handle doesn't have SYNCH access\n"); + goto Quickie; + } + + /* Get the Object Header */ + ObjectHeader = EX_HTE_TO_HDR(HandleEntry); + + /* Get default Object */ + DefaultObject = ObjectHeader->Type->DefaultObject; + + /* Check if it's the internal offset */ + if ((LONG_PTR)DefaultObject >= 0) + { + /* Increase reference count */ + InterlockedIncrement(&ObjectHeader->PointerCount); + ReferencedObjects++; + + /* Save the Object and Wait Object, this is a relative offset */ + Objects[i] = &ObjectHeader->Body; + WaitObjects[i] = (PVOID)((ULONG_PTR)&ObjectHeader->Body + + (ULONG_PTR)DefaultObject); + } + else + { + /* This is our internal Object */ + ReferencedObjects++; + Objects[i] = NULL; + WaitObjects[i] = DefaultObject; + } + + /* Unlock the Handle Table Entry */ + ExUnlockHandleTableEntry(HandleTable, HandleEntry); + + /* Keep looping */ + i++; + } while (i < ObjectCount); + + /* For a Waitall, we can't have the same object more then once */ + if (WaitType == WaitAll) + { + /* Start the loop */ + do + { + /* Check the current and forward object */ + for (i = 0, j = i + 1; j < ObjectCount; j++) + { + /* Make sure they don't match */ + if (WaitObjects[i] == WaitObjects[j]) + { + /* Fail */ + Status = STATUS_INVALID_PARAMETER_MIX; + DPRINT1("Objects duplicated with WaitAll\n"); + goto Quickie; + } + } + + /* Keep looping */ + i++; + } while (i < ObjectCount); + } + + /* Now we can finally wait. Use SEH since it can raise an exception */ + _SEH_TRY + { + /* We're done playing with handles */ + LockInUse = FALSE; + KeLeaveCriticalRegion(); + + /* Do the kernel wait */ + Status = KeWaitForMultipleObjects(ObjectCount, + WaitObjects, + WaitType, + UserRequest, + PreviousMode, + Alertable, + TimeOut, + WaitBlockArray); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + +Quickie: + /* First derefence */ + while (ReferencedObjects) + { + ReferencedObjects--; + if (Objects[ReferencedObjects]) + { + ObDereferenceObject(Objects[ReferencedObjects]); + } + } + + /* Free wait block array */ + if (WaitBlockArray) ExFreePool(WaitBlockArray); + + /* Re-enable APCs if needed */ + if (LockInUse) KeLeaveCriticalRegion(); + + /* Return status */ + return Status; } - /* * @implemented */ -NTSTATUS STDCALL +NTSTATUS +STDCALL NtWaitForSingleObject(IN HANDLE ObjectHandle, - IN BOOLEAN Alertable, - IN PLARGE_INTEGER TimeOut OPTIONAL) + IN BOOLEAN Alertable, + IN PLARGE_INTEGER TimeOut OPTIONAL) { - PVOID ObjectPtr; - KPROCESSOR_MODE PreviousMode; - LARGE_INTEGER SafeTimeOut; - NTSTATUS Status = STATUS_SUCCESS; + PVOID Object, WaitableObject; + KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); + LARGE_INTEGER SafeTimeOut; + NTSTATUS Status = STATUS_SUCCESS; - DPRINT("NtWaitForSingleObject(ObjectHandle %x, Alertable %d, TimeOut %x)\n", - ObjectHandle,Alertable,TimeOut); + DPRINT("NtWaitForSingleObject(ObjectHandle %x, Alertable %d, TimeOut %x)\n", + ObjectHandle,Alertable,TimeOut); - PreviousMode = ExGetPreviousMode(); + /* Capture timeout */ + if(TimeOut && PreviousMode != KernelMode) + { + _SEH_TRY + { + ProbeForRead(TimeOut, + sizeof(LARGE_INTEGER), + sizeof(ULONG)); + /* Make a copy on the stack */ + SafeTimeOut = *TimeOut; + TimeOut = &SafeTimeOut; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; - if(TimeOut != NULL && PreviousMode != KernelMode) - { - _SEH_TRY - { - ProbeForRead(TimeOut, - sizeof(LARGE_INTEGER), - sizeof(ULONG)); - /* make a copy on the stack */ - SafeTimeOut = *TimeOut; - TimeOut = &SafeTimeOut; - } - _SEH_HANDLE - { - Status = _SEH_GetExceptionCode(); - } - _SEH_END; + if(!NT_SUCCESS(Status)) return Status; + } - if(!NT_SUCCESS(Status)) - { - return Status; - } - } + /* Get the Object */ + Status = ObReferenceObjectByHandle(ObjectHandle, + SYNCHRONIZE, + NULL, + PreviousMode, + &Object, + NULL); + if (NT_SUCCESS(Status)) + { + /* Get the Waitable Object */ + WaitableObject = BODY_TO_HEADER(Object)->Type->DefaultObject; - Status = ObReferenceObjectByHandle(ObjectHandle, - SYNCHRONIZE, - NULL, - PreviousMode, - &ObjectPtr, - NULL); - if (!NT_SUCCESS(Status)) - { - return(Status); - } - if (!KiIsObjectWaitable(ObjectPtr)) - { - DPRINT1("Waiting for object type '%wZ' is not supported\n", - &BODY_TO_HEADER(ObjectPtr)->Type->Name); - Status = STATUS_INVALID_HANDLE; - } - else - { - Status = KeWaitForSingleObject(ObjectPtr, - UserRequest, - PreviousMode, - Alertable, - TimeOut); - } + /* Is it an offset for internal objects? */ + if ((LONG_PTR)WaitableObject >= 0) + { + /* Turn it into a pointer */ + WaitableObject = (PVOID)((ULONG_PTR)Object + + (ULONG_PTR)WaitableObject); + } - ObDereferenceObject(ObjectPtr); + /* Now wait. Also SEH this since it can also raise an exception */ + _SEH_TRY + { + Status = KeWaitForSingleObject(WaitableObject, + UserRequest, + PreviousMode, + Alertable, + TimeOut); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; - return(Status); + /* Dereference the Object */ + ObDereferenceObject(Object); + } + + /* Return the status */ + return Status; } - NTSTATUS STDCALL NtSignalAndWaitForSingleObject(IN HANDLE ObjectHandleToSignal, @@ -204,15 +338,17 @@ IN PLARGE_INTEGER TimeOut OPTIONAL) { KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); - PDISPATCHER_HEADER Header; + POBJECT_TYPE Type; PVOID SignalObj; PVOID WaitObj; + PVOID WaitableObject; LARGE_INTEGER SafeTimeOut; OBJECT_HANDLE_INFORMATION HandleInfo; NTSTATUS Status = STATUS_SUCCESS; /* Capture timeout */ - if(!TimeOut && PreviousMode != KernelMode) + DPRINT("NtSignalAndWaitForSingleObject\n"); + if(TimeOut && PreviousMode != KernelMode) { _SEH_TRY { @@ -257,58 +393,65 @@ return Status; } - /* FIXME: Use DefaultObject from ObjectHeader */ - Header = (PDISPATCHER_HEADER)SignalObj; + /* Get the real waitable object */ + WaitableObject = BODY_TO_HEADER(WaitObj)->Type->DefaultObject; + + /* Handle internal offset */ + if ((LONG_PTR)WaitableObject >= 0) + { + /* Get real pointer */ + WaitableObject = (PVOID)((ULONG_PTR)WaitObj + + (ULONG_PTR)WaitableObject); + } - /* Check dispatcher type */ - /* FIXME: Check Object Type instead! */ - switch (Header->Type) + /* Check Signal Object Type */ + Type = BODY_TO_HEADER(WaitObj)->Type; + if (Type == ExEventObjectType) { - case EventNotificationObject: - case EventSynchronizationObject: - /* Set the Event */ - /* FIXME: Check permissions */ - KeSetEvent(SignalObj, EVENT_INCREMENT, TRUE); - break; - - case MutantObject: - /* Release the Mutant. This can raise an exception*/ - _SEH_TRY - { - KeReleaseMutant(SignalObj, MUTANT_INCREMENT, FALSE, TRUE); - } - _SEH_HANDLE - { - Status = _SEH_GetExceptionCode(); - goto Quickie; - } - _SEH_END; - break; - - case SemaphoreObject: - /* Release the Semaphore. This can raise an exception*/ - /* FIXME: Check permissions */ - _SEH_TRY - { - KeReleaseSemaphore(SignalObj, SEMAPHORE_INCREMENT, 1, TRUE); - } - _SEH_HANDLE - { - Status = _SEH_GetExceptionCode(); - goto Quickie; - } - _SEH_END; - break; - - default: - Status = STATUS_OBJECT_TYPE_MISMATCH; + /* Set the Event */ + /* FIXME: Check permissions */ + KeSetEvent(SignalObj, EVENT_INCREMENT, TRUE); + } + else if (Type == ExMutantObjectType) + { + /* Release the Mutant. This can raise an exception*/ + _SEH_TRY + { + KeReleaseMutant(SignalObj, MUTANT_INCREMENT, FALSE, TRUE); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); goto Quickie; + } + _SEH_END; } + else if (Type == ExSemaphoreObjectType) + { + /* Release the Semaphore. This can raise an exception*/ + /* FIXME: Check permissions */ + _SEH_TRY + { + KeReleaseSemaphore(SignalObj, SEMAPHORE_INCREMENT, 1, TRUE); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + goto Quickie; + } + _SEH_END; + } + else + { + Status = STATUS_OBJECT_TYPE_MISMATCH; + DPRINT1("Waiting on invalid object type\n"); + goto Quickie; + } /* Now wait. Also SEH this since it can also raise an exception */ _SEH_TRY { - Status = KeWaitForSingleObject(WaitObj, + Status = KeWaitForSingleObject(WaitableObject, UserRequest, PreviousMode, Alertable, _____ Modified: trunk/reactos/ntoskrnl/ps/psmgr.c --- trunk/reactos/ntoskrnl/ps/psmgr.c 2005-08-07 20:33:11 UTC (rev 17178) +++ trunk/reactos/ntoskrnl/ps/psmgr.c 2005-08-07 21:29:51 UTC (rev 17179) @@ -97,7 +97,6 @@ ObjectTypeInitializer.GenericMapping = PiThreadMapping; ObjectTypeInitializer.PoolType = NonPagedPool; ObjectTypeInitializer.ValidAccessMask = THREAD_ALL_ACCESS; - ObjectTypeInitializer.UseDefaultObject = TRUE; ObjectTypeInitializer.DeleteProcedure = PspDeleteThread; ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &PsThreadType); @@ -138,7 +137,6 @@ ObjectTypeInitializer.GenericMapping = PiProcessMapping; ObjectTypeInitializer.PoolType = NonPagedPool; ObjectTypeInitializer.ValidAccessMask = PROCESS_ALL_ACCESS; - ObjectTypeInitializer.UseDefaultObject = TRUE; ObjectTypeInitializer.DeleteProcedure = PspDeleteProcess; ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &PsProcessType);
19 years, 4 months
1
0
0
0
← Newer
1
...
39
40
41
42
43
44
45
...
67
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Results per page:
10
25
50
100
200