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
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
February 2011
----- 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
18 participants
352 discussions
Start a n
N
ew thread
[gadamopoulos] 50876: [kernel32] - Add some debug prints - Fix some cases where we didn't check for the return value of CsrAllocateCaptureBuffer
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Wed Feb 23 14:24:57 2011 New Revision: 50876 URL:
http://svn.reactos.org/svn/reactos?rev=50876&view=rev
Log: [kernel32] - Add some debug prints - Fix some cases where we didn't check for the return value of CsrAllocateCaptureBuffer Modified: trunk/reactos/dll/win32/kernel32/misc/console.c Modified: trunk/reactos/dll/win32/kernel32/misc/console.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/co…
============================================================================== --- trunk/reactos/dll/win32/kernel32/misc/console.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/misc/console.c [iso-8859-1] Wed Feb 23 14:24:57 2011 @@ -384,6 +384,7 @@ CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode)); if (!CaptureBuffer) { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -466,6 +467,7 @@ CaptureBuffer = CsrAllocateCaptureBuffer(1, TargetBufferLength); if (!CaptureBuffer) { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); RtlFreeHeap(GetProcessHeap(), 0, Request); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return 0; @@ -594,6 +596,7 @@ CaptureBuffer = CsrAllocateCaptureBuffer(1, ExeNameBufferLength); if (!CaptureBuffer) { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return 0; } @@ -849,6 +852,7 @@ HistoryLength); if (!CaptureBuffer) { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return 0; } @@ -927,6 +931,7 @@ CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode)); if (!CaptureBuffer) { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return 0; } @@ -1318,6 +1323,7 @@ CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode)); if (!CaptureBuffer) { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -1696,6 +1702,7 @@ CaptureBuffer = CsrAllocateCaptureBuffer(1, nNumberOfCharsToRead * CharSize); if (CaptureBuffer == NULL) { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -2052,6 +2059,12 @@ /* Allocate a Capture Buffer */ DPRINT("IntPeekConsoleInput: %lx %p\n", Size, lpNumberOfEventsRead); CaptureBuffer = CsrAllocateCaptureBuffer(1, Size); + if (CaptureBuffer == NULL) + { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } /* Allocate space in the Buffer */ CsrCaptureMessageBuffer(CaptureBuffer, @@ -2281,6 +2294,12 @@ /* Allocate a Capture Buffer */ DPRINT("IntWriteConsoleInput: %lx %p\n", Size, lpNumberOfEventsWritten); CaptureBuffer = CsrAllocateCaptureBuffer(1, Size); + if (CaptureBuffer == NULL) + { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } /* Allocate space in the Buffer */ CsrCaptureMessageBuffer(CaptureBuffer, @@ -2389,6 +2408,12 @@ /* Allocate a Capture Buffer */ DPRINT("IntReadConsoleOutput: %lx %p\n", Size, lpReadRegion); CaptureBuffer = CsrAllocateCaptureBuffer(1, Size); + if (CaptureBuffer == NULL) + { + DPRINT1("CsrAllocateCaptureBuffer failed with size 0x%x!\n", Size); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } /* Allocate space in the Buffer */ CsrCaptureMessageBuffer(CaptureBuffer, @@ -2505,6 +2530,12 @@ /* Allocate a Capture Buffer */ DPRINT("IntWriteConsoleOutput: %lx %p\n", Size, lpWriteRegion); CaptureBuffer = CsrAllocateCaptureBuffer(1, Size); + if (CaptureBuffer == NULL) + { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } /* Allocate space in the Buffer */ CsrCaptureMessageBuffer(CaptureBuffer, @@ -3561,6 +3592,7 @@ CaptureBuffer = CsrAllocateCaptureBuffer(1, Request.Data.GetTitleRequest.Length); if (CaptureBuffer == NULL) { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return 0; } @@ -3652,6 +3684,7 @@ CaptureBuffer = CsrAllocateCaptureBuffer(1, Request.Data.SetTitleRequest.Length); if (CaptureBuffer == NULL) { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } @@ -3866,6 +3899,7 @@ CaptureBuffer = CsrAllocateCaptureBuffer(1, dwProcessCount * sizeof(DWORD)); if (CaptureBuffer == NULL) { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; }
13 years, 10 months
1
0
0
0
[pschweitzer] 50875: [NTOSKRNL] Apply r50873 on FsRtlIsNameInExpression()
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Wed Feb 23 12:09:07 2011 New Revision: 50875 URL:
http://svn.reactos.org/svn/reactos?rev=50875&view=rev
Log: [NTOSKRNL] Apply r50873 on FsRtlIsNameInExpression() Modified: trunk/reactos/ntoskrnl/fsrtl/name.c Modified: trunk/reactos/ntoskrnl/fsrtl/name.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fsrtl/name.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/fsrtl/name.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/fsrtl/name.c [iso-8859-1] Wed Feb 23 12:09:07 2011 @@ -41,7 +41,7 @@ switch (Expression->Buffer[ExpressionPosition]) { case L'*': - StarFound = ExpressionPosition++; + StarFound = MAXUSHORT; break; case L'?': @@ -88,6 +88,7 @@ if (ExpressionPosition == Expression->Length / sizeof(WCHAR)) { NamePosition = Name->Length / sizeof(WCHAR); + break; } } else if (Expression->Buffer[ExpressionPosition] == DOS_STAR) @@ -109,14 +110,14 @@ ExpressionPosition = StarFound + 1; while ((IgnoreCase ? UpcaseTable[Name->Buffer[NamePosition]] : Name->Buffer[NamePosition]) != Expression->Buffer[ExpressionPosition] && - NamePosition < Name->Length / sizeof(WCHAR)) + NamePosition < Name->Length / sizeof(WCHAR)) { NamePosition++; } } else { - NamePosition = Name->Length / sizeof(WCHAR); + break; } } if (ExpressionPosition + 1 == Expression->Length / sizeof(WCHAR) && NamePosition == Name->Length / sizeof(WCHAR) &&
13 years, 10 months
1
0
0
0
[pschweitzer] 50874: [NTOSKRNL] Reverted changes commited to largemcb.c They weren't intended to be commited
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Wed Feb 23 12:08:16 2011 New Revision: 50874 URL:
http://svn.reactos.org/svn/reactos?rev=50874&view=rev
Log: [NTOSKRNL] Reverted changes commited to largemcb.c They weren't intended to be commited Modified: trunk/reactos/ntoskrnl/fsrtl/largemcb.c Modified: trunk/reactos/ntoskrnl/fsrtl/largemcb.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fsrtl/largemcb.c?…
============================================================================== --- trunk/reactos/ntoskrnl/fsrtl/largemcb.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/fsrtl/largemcb.c [iso-8859-1] Wed Feb 23 12:08:16 2011 @@ -2,10 +2,8 @@ * PROJECT: ReactOS Kernel * LICENSE: GPL - See COPYING in the top level directory * FILE: ntoskrnl/fsrtl/largemcb.c - * PURPOSE: Large Mapped Control Block (MCB) support for File System Drivers + * PURPOSE: Mapping Control Block (MCB) support for File System Drivers * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) - * Pierre Schweitzer (heis_spiter(a)hotmail.com) - * Art Yerkes (art.yerkes(a)gmail.com) */ /* INCLUDES ******************************************************************/ @@ -14,158 +12,10 @@ #define NDEBUG #include <debug.h> -/* GLOBALS *******************************************************************/ - -#define GET_LIST_HEAD(x) ((PLIST_ENTRY)(&((PRTL_GENERIC_TABLE)x)[1])) - -PAGED_LOOKASIDE_LIST FsRtlFirstMappingLookasideList; -NPAGED_LOOKASIDE_LIST FsRtlFastMutexLookasideList; - -typedef struct _LARGE_MCB_MAPPING_ENTRY -{ - LARGE_INTEGER RunStartVbn; - LARGE_INTEGER SectorCount; - LARGE_INTEGER StartingLbn; - LIST_ENTRY Sequence; -} LARGE_MCB_MAPPING_ENTRY, *PLARGE_MCB_MAPPING_ENTRY; - -static VOID McbPrintTree(PBASE_MCB Mcb) -{ - PLARGE_MCB_MAPPING_ENTRY Entry; - for (Entry = (PLARGE_MCB_MAPPING_ENTRY) - RtlEnumerateGenericTable(Mcb->Mapping, TRUE); - Entry; - Entry = (PLARGE_MCB_MAPPING_ENTRY) - RtlEnumerateGenericTable(Mcb->Mapping, FALSE)) - { - DPRINT1 - ("Vbn %x Lbn %x Count %x\n", - Entry->RunStartVbn.LowPart, - Entry->StartingLbn.LowPart, - Entry->SectorCount.LowPart); - } -} - -static PVOID NTAPI McbMappingAllocate(PRTL_GENERIC_TABLE Table, CLONG Bytes) -{ - PVOID Result; - PBASE_MCB Mcb = (PBASE_MCB)Table->TableContext; - Result = ExAllocatePoolWithTag(Mcb->PoolType, Bytes, 'LMCB'); - DPRINT("McbMappingAllocate(%d) => %p\n", Bytes, Result); - return Result; -} - -static VOID NTAPI McbMappingFree(PRTL_GENERIC_TABLE Table, PVOID Buffer) -{ - DPRINT("McbMappingFree(%p)\n", Buffer); - ExFreePoolWithTag(Buffer, 'LMCB'); -} - -static RTL_GENERIC_COMPARE_RESULTS NTAPI McbMappingCompare -(PRTL_GENERIC_TABLE Table, PVOID PtrA, PVOID PtrB) -{ - PLARGE_MCB_MAPPING_ENTRY A = PtrA, B = PtrB; - RTL_GENERIC_COMPARE_RESULTS Result; - DPRINT("Starting to compare element %x to element %x\n", PtrA, PtrB); - Result = - (A->RunStartVbn.QuadPart + A->SectorCount.QuadPart <= - B->RunStartVbn.QuadPart) ? GenericLessThan : - (A->RunStartVbn.QuadPart >= - B->RunStartVbn.QuadPart + B->SectorCount.QuadPart) ? - GenericGreaterThan : GenericEqual; - DPRINT("Compare(%x:%x): %x:%x to %x:%x => %d\n", - A,B, - A->RunStartVbn.LowPart, A->SectorCount.LowPart, - B->RunStartVbn.LowPart, B->SectorCount.LowPart, - Result); - return Result; -} - /* PUBLIC FUNCTIONS **********************************************************/ /* - * @implemented - */ -BOOLEAN -NTAPI -FsRtlAddBaseMcbEntry(IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Lbn, - IN LONGLONG SectorCount) -{ - LARGE_MCB_MAPPING_ENTRY Node; - PLARGE_MCB_MAPPING_ENTRY Existing = NULL; - BOOLEAN NewElement = FALSE; - - McbPrintTree(Mcb); - - Node.RunStartVbn.QuadPart = Vbn; - Node.StartingLbn.QuadPart = Lbn; - Node.SectorCount.QuadPart = SectorCount; - - DPRINT("RunStartVbn %x\n", Node.RunStartVbn.LowPart); - DPRINT("StartingLbn %x\n", Node.StartingLbn.LowPart); - DPRINT("SectorCount %x\n", Node.SectorCount.LowPart); - - while (!NewElement) - { - DPRINT("Inserting %x:%x\n", Node.RunStartVbn.LowPart, Node.SectorCount.LowPart); - Existing = RtlInsertElementGenericTable - (Mcb->Mapping, &Node, sizeof(Node), &NewElement); - DPRINT("Existing %x\n", Existing); - if (!Existing) break; - - DPRINT("NewElement %d\n", NewElement); - if (!NewElement) - { - // We merge the existing runs - LARGE_INTEGER StartVbn, FinalVbn; - DPRINT("Existing: %x:%x\n", - Existing->RunStartVbn.LowPart, Node.SectorCount.LowPart); - if (Existing->RunStartVbn.QuadPart < Node.RunStartVbn.QuadPart) - { - StartVbn = Existing->RunStartVbn; - Node.StartingLbn = Existing->StartingLbn; - } - else - { - StartVbn = Node.RunStartVbn; - } - DPRINT("StartVbn %x\n", StartVbn.LowPart); - if (Existing->RunStartVbn.QuadPart + Existing->SectorCount.QuadPart > - Node.RunStartVbn.QuadPart + Node.SectorCount.QuadPart) - { - FinalVbn.QuadPart = - Existing->RunStartVbn.QuadPart + Existing->SectorCount.QuadPart; - } - else - { - FinalVbn.QuadPart = - Node.RunStartVbn.QuadPart + Node.SectorCount.QuadPart; - } - DPRINT("FinalVbn %x\n", FinalVbn.LowPart); - Node.RunStartVbn.QuadPart = StartVbn.QuadPart; - Node.SectorCount.QuadPart = FinalVbn.QuadPart - StartVbn.QuadPart; - RemoveHeadList(&Existing->Sequence); - RtlDeleteElementGenericTable(Mcb->Mapping, Existing); - Mcb->PairCount--; - } - else - { - DPRINT("Mapping added %x\n", Existing); - Mcb->MaximumPairCount++; - Mcb->PairCount++; - InsertHeadList(GET_LIST_HEAD(Mcb->Mapping), &Existing->Sequence); - } - } - - DPRINT("!!Existing %d\n", !!Existing); - McbPrintTree(Mcb); - return !!Existing; -} - -/* - * @implemented + * @unimplemented */ BOOLEAN NTAPI @@ -174,59 +24,30 @@ IN LONGLONG Lbn, IN LONGLONG SectorCount) { - BOOLEAN Result; - - DPRINT - ("Mcb %x Vbn %x Lbn %x SectorCount %x\n", - Mcb, (ULONG)Vbn, (ULONG)Lbn, (ULONG)SectorCount); - - KeAcquireGuardedMutex(Mcb->GuardedMutex); - Result = FsRtlAddBaseMcbEntry(&(Mcb->BaseMcb), - Vbn, - Lbn, - SectorCount); - KeReleaseGuardedMutex(Mcb->GuardedMutex); - - DPRINT("Done %d\n", Result); - - return Result; -} - -/* - * @unimplemented - */ -BOOLEAN -NTAPI -FsRtlGetNextBaseMcbEntry(IN PBASE_MCB Mcb, - IN ULONG RunIndex, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn, - OUT PLONGLONG SectorCount) -{ - ULONG i = 0; - BOOLEAN Result = FALSE; - PLARGE_MCB_MAPPING_ENTRY Entry; - for (Entry = (PLARGE_MCB_MAPPING_ENTRY) - RtlEnumerateGenericTable(Mcb->Mapping, TRUE); - Entry && i < RunIndex; - Entry = (PLARGE_MCB_MAPPING_ENTRY) - RtlEnumerateGenericTable(Mcb->Mapping, FALSE), i++); - if (Entry) - { - Result = TRUE; - if (Vbn) - *Vbn = Entry->RunStartVbn.QuadPart; - if (Lbn) - *Lbn = Entry->StartingLbn.QuadPart; - if (SectorCount) - *SectorCount = Entry->SectorCount.QuadPart; - } - - return Result; -} - -/* - * @implemented + KeBugCheck(FILE_SYSTEM); + return FALSE; +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +FsRtlAddMcbEntry(IN PMCB Mcb, + IN VBN Vbn, + IN LBN Lbn, + IN ULONG SectorCount) +{ + /* Call the newer function */ + return FsRtlAddLargeMcbEntry(&Mcb-> + DummyFieldThatSizesThisStructureCorrectly, + (LONGLONG)Vbn, + (LONGLONG)Lbn, + (LONGLONG)SectorCount); +} + +/* + * @unimplemented */ BOOLEAN NTAPI @@ -236,162 +57,72 @@ OUT PLONGLONG Lbn, OUT PLONGLONG SectorCount) { - BOOLEAN Result; - - DPRINT("FsRtlGetNextLargeMcbEntry Mcb %x RunIndex %x\n", Mcb, RunIndex); - - KeAcquireGuardedMutex(Mcb->GuardedMutex); - Result = FsRtlGetNextBaseMcbEntry(&(Mcb->BaseMcb), - RunIndex, - Vbn, - Lbn, - SectorCount); - KeReleaseGuardedMutex(Mcb->GuardedMutex); - - DPRINT("Done %d\n", Result); - - return Result; -} - -/* - * @implemented - */ -VOID -NTAPI -FsRtlInitializeBaseMcb(IN PBASE_MCB Mcb, - IN POOL_TYPE PoolType) -{ - Mcb->PairCount = 0; - - if (PoolType == PagedPool) - { - Mcb->Mapping = ExAllocateFromPagedLookasideList(&FsRtlFirstMappingLookasideList); - DPRINT("Get from lookaside list\n"); - } - else - { - Mcb->Mapping = ExAllocatePoolWithTag(PoolType | POOL_RAISE_IF_ALLOCATION_FAILURE, - sizeof(RTL_GENERIC_TABLE) + sizeof(LIST_ENTRY), - 'FSBC'); - DPRINT("Allocate\n"); - } - - DPRINT("Mcb->Mapping %x\n", Mcb->Mapping); - Mcb->PoolType = PoolType; - Mcb->MaximumPairCount = MAXIMUM_PAIR_COUNT; - RtlInitializeGenericTable - (Mcb->Mapping, - McbMappingCompare, - McbMappingAllocate, - McbMappingFree, - Mcb); - InitializeListHead(GET_LIST_HEAD(Mcb->Mapping)); -} - -/* - * @implemented + KeBugCheck(FILE_SYSTEM); + *Vbn = 0; + *Lbn = 0; + *SectorCount= 0; + return FALSE; +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +FsRtlGetNextMcbEntry(IN PMCB Mcb, + IN ULONG RunIndex, + OUT PVBN Vbn, + OUT PLBN Lbn, + OUT PULONG SectorCount) +{ + BOOLEAN Return = FALSE; + LONGLONG llVbn; + LONGLONG llLbn; + LONGLONG llSectorCount; + + /* Call the Large version */ + Return = FsRtlGetNextLargeMcbEntry( + &Mcb->DummyFieldThatSizesThisStructureCorrectly, + RunIndex, + &llVbn, + &llLbn, + &llSectorCount); + + /* Return the lower 32 bits */ + *Vbn = (ULONG)llVbn; + *Lbn = (ULONG)llLbn; + *SectorCount = (ULONG)llSectorCount; + + /* And return the original value */ + return Return; +} + +/* + * @unimplemented */ VOID NTAPI FsRtlInitializeLargeMcb(IN PLARGE_MCB Mcb, IN POOL_TYPE PoolType) { - Mcb->GuardedMutex = ExAllocateFromNPagedLookasideList(&FsRtlFastMutexLookasideList); - - KeInitializeGuardedMutex(Mcb->GuardedMutex); - - _SEH2_TRY - { - FsRtlInitializeBaseMcb(&(Mcb->BaseMcb), PoolType); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - ExFreeToNPagedLookasideList(&FsRtlFastMutexLookasideList, - Mcb->GuardedMutex); - Mcb->GuardedMutex = NULL; - } - _SEH2_END; -} - -/* - * @implemented - */ -VOID -NTAPI -FsRtlInitializeLargeMcbs(VOID) -{ - /* Initialize the list for the MCB */ - ExInitializePagedLookasideList(&FsRtlFirstMappingLookasideList, - NULL, - NULL, - POOL_RAISE_IF_ALLOCATION_FAILURE, - sizeof(RTL_GENERIC_TABLE) + sizeof(LIST_ENTRY), - IFS_POOL_TAG, - 0); /* FIXME: Should be 4 */ - - /* Initialize the list for the guarded mutex */ - ExInitializeNPagedLookasideList(&FsRtlFastMutexLookasideList, - NULL, - NULL, - POOL_RAISE_IF_ALLOCATION_FAILURE, - sizeof(KGUARDED_MUTEX), - IFS_POOL_TAG, - 0); /* FIXME: Should be 32 */ -} - -/* - * @unimplemented - */ -BOOLEAN -NTAPI -FsRtlLookupBaseMcbEntry(IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - OUT PLONGLONG Lbn OPTIONAL, - OUT PLONGLONG SectorCountFromLbn OPTIONAL, - OUT PLONGLONG StartingLbn OPTIONAL, - OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, - OUT PULONG Index OPTIONAL) -{ - BOOLEAN Result = FALSE; - LARGE_MCB_MAPPING_ENTRY ToLookup; - PLARGE_MCB_MAPPING_ENTRY Entry; - - ToLookup.RunStartVbn.QuadPart = Vbn; - ToLookup.SectorCount.QuadPart = 1; - - Entry = RtlLookupElementGenericTable(Mcb->Mapping, &ToLookup); - if (!Entry) - { - // Find out if we have a following entry. The spec says we should return - // found with Lbn == -1 when we're beneath the largest map. - ToLookup.SectorCount.QuadPart = (1ull<<62) - ToLookup.RunStartVbn.QuadPart; - Entry = RtlLookupElementGenericTable(Mcb->Mapping, &ToLookup); - if (Entry) - { - Result = TRUE; - if (Lbn) *Lbn = ~0ull; - } - else - { - Result = FALSE; - } - } - else - { - LARGE_INTEGER Offset; - Offset.QuadPart = Vbn - Entry->RunStartVbn.QuadPart; - Result = TRUE; - if (Lbn) *Lbn = Entry->StartingLbn.QuadPart + Offset.QuadPart; - if (SectorCountFromLbn) *SectorCountFromLbn = Entry->SectorCount.QuadPart - Offset.QuadPart; - if (StartingLbn) *StartingLbn = Entry->StartingLbn.QuadPart; - if (SectorCountFromStartingLbn) *SectorCountFromStartingLbn = Entry->SectorCount.QuadPart; - } - - return Result; -} - -/* - * @implemented + KeBugCheck(FILE_SYSTEM); +} + +/* + * @implemented + */ +VOID +NTAPI +FsRtlInitializeMcb(IN PMCB Mcb, + IN POOL_TYPE PoolType) +{ + /* Call the newer function */ + FsRtlInitializeLargeMcb(&Mcb->DummyFieldThatSizesThisStructureCorrectly, + PoolType); +} + +/* + * @unimplemented */ BOOLEAN NTAPI @@ -403,61 +134,14 @@ OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, OUT PULONG Index OPTIONAL) { - BOOLEAN Result; - - DPRINT("FsRtlLookupLargeMcbEntry Mcb %x Vbn %x\n", Mcb, (ULONG)Vbn); - - KeAcquireGuardedMutex(Mcb->GuardedMutex); - Result = FsRtlLookupBaseMcbEntry(&(Mcb->BaseMcb), - Vbn, - Lbn, - SectorCountFromLbn, - StartingLbn, - SectorCountFromStartingLbn, - Index); - KeReleaseGuardedMutex(Mcb->GuardedMutex); - - DPRINT("Done %d (%x)\n", Result, Lbn ? (ULONG)*Lbn : 0); - - return Result; -} - -/* - * @unimplemented - */ -BOOLEAN -NTAPI -FsRtlLookupLastBaseMcbEntryAndIndex(IN PBASE_MCB OpaqueMcb, - IN OUT PLONGLONG LargeVbn, - IN OUT PLONGLONG LargeLbn, - IN OUT PULONG Index) -{ - ULONG i = 0; - BOOLEAN Result = FALSE; - PLIST_ENTRY ListEntry; - PLARGE_MCB_MAPPING_ENTRY Entry; - PLARGE_MCB_MAPPING_ENTRY CountEntry; - - ListEntry = GET_LIST_HEAD(OpaqueMcb->Mapping); - if (!IsListEmpty(ListEntry)) - { - Entry = CONTAINING_RECORD(ListEntry->Flink, LARGE_MCB_MAPPING_ENTRY, Sequence); - Result = TRUE; - *LargeVbn = Entry->RunStartVbn.QuadPart; - *LargeLbn = Entry->StartingLbn.QuadPart; - - for (i = 0, CountEntry = RtlEnumerateGenericTable(OpaqueMcb->Mapping, TRUE); - CountEntry != Entry; - CountEntry = RtlEnumerateGenericTable(OpaqueMcb->Mapping, FALSE)); - - *Index = i; - } - - return Result; -} - -/* - * @implemented + KeBugCheck(FILE_SYSTEM); + *Lbn = 0; + *SectorCountFromLbn = 0; + return FALSE; +} + +/* + * @unimplemented */ BOOLEAN NTAPI @@ -466,49 +150,15 @@ OUT PLONGLONG LargeLbn, OUT PULONG Index) { - BOOLEAN Result; - - DPRINT("FsRtlLookupLastLargeMcbEntryAndIndex %x\n", OpaqueMcb); - - KeAcquireGuardedMutex(OpaqueMcb->GuardedMutex); - Result = FsRtlLookupLastBaseMcbEntryAndIndex(&(OpaqueMcb->BaseMcb), - LargeVbn, - LargeLbn, - Index); - KeReleaseGuardedMutex(OpaqueMcb->GuardedMutex); - - DPRINT("Done %d\n", Result); - - return Result; -} - -/* - * @unimplemented - */ -BOOLEAN -NTAPI -FsRtlLookupLastBaseMcbEntry(IN PBASE_MCB Mcb, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn) -{ - BOOLEAN Result = FALSE; - PLIST_ENTRY ListEntry; - PLARGE_MCB_MAPPING_ENTRY Entry; - - ListEntry = GET_LIST_HEAD(Mcb->Mapping); - if (!IsListEmpty(ListEntry)) - { - Entry = CONTAINING_RECORD(ListEntry->Flink, LARGE_MCB_MAPPING_ENTRY, Sequence); - Result = TRUE; - *Vbn = Entry->RunStartVbn.QuadPart; - *Lbn = Entry->StartingLbn.QuadPart; - } - - return Result; -} - -/* - * @implemented + KeBugCheck(FILE_SYSTEM); + *LargeVbn = 0; + *LargeLbn = 0; + *Index = 0; + return FALSE; +} + +/* + * @unimplemented */ BOOLEAN NTAPI @@ -516,501 +166,8 @@ OUT PLONGLONG Vbn, OUT PLONGLONG Lbn) { - BOOLEAN Result; - - DPRINT("FsRtlLookupLastLargeMcbEntry Mcb %x\n", Mcb); - - KeAcquireGuardedMutex(Mcb->GuardedMutex); - Result = FsRtlLookupLastBaseMcbEntry(&(Mcb->BaseMcb), - Vbn, - Lbn); - KeReleaseGuardedMutex(Mcb->GuardedMutex); - - DPRINT("Done %d\n", Result); - - return Result; -} - -/* - * @implemented - */ -ULONG -NTAPI -FsRtlNumberOfRunsInBaseMcb(IN PBASE_MCB Mcb) -{ - /* Return the count */ - return Mcb->PairCount; -} - -/* - * @implemented - */ -ULONG -NTAPI -FsRtlNumberOfRunsInLargeMcb(IN PLARGE_MCB Mcb) -{ - ULONG NumberOfRuns; - - DPRINT("FsRtlNumberOfRunsInLargeMcb Mcb %x\n", Mcb); - - /* Read the number of runs while holding the MCB lock */ - KeAcquireGuardedMutex(Mcb->GuardedMutex); - NumberOfRuns = Mcb->BaseMcb.PairCount; - KeReleaseGuardedMutex(Mcb->GuardedMutex); - - DPRINT("Done %d\n", NumberOfRuns); - - /* Return the count */ - return NumberOfRuns; -} - -/* - * @unimplemented - */ -VOID -NTAPI -FsRtlRemoveBaseMcbEntry(IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG SectorCount) -{ - LARGE_MCB_MAPPING_ENTRY Node; - PLARGE_MCB_MAPPING_ENTRY Element; - - Node.RunStartVbn.QuadPart = Vbn; - Node.SectorCount.QuadPart = SectorCount; - - while ((Element = RtlLookupElementGenericTable(Mcb->Mapping, &Node))) - { - // Must split - if (Element->RunStartVbn.QuadPart < Node.RunStartVbn.QuadPart && - Element->SectorCount.QuadPart > Node.SectorCount.QuadPart) - { - LARGE_MCB_MAPPING_ENTRY Upper, Reinsert; - PLARGE_MCB_MAPPING_ENTRY Reinserted, Inserted; - LARGE_INTEGER StartHole = Node.RunStartVbn; - LARGE_INTEGER EndHole; - EndHole.QuadPart = Node.RunStartVbn.QuadPart + Node.SectorCount.QuadPart; - Upper.RunStartVbn.QuadPart = EndHole.QuadPart; - Upper.StartingLbn.QuadPart = - Element->StartingLbn.QuadPart + - EndHole.QuadPart - - Element->RunStartVbn.QuadPart; - Upper.SectorCount.QuadPart = - Element->SectorCount.QuadPart - - (EndHole.QuadPart - Element->RunStartVbn.QuadPart); - Reinsert = *Element; - Reinsert.SectorCount.QuadPart = - Element->RunStartVbn.QuadPart - StartHole.QuadPart; - RemoveEntryList(&Element->Sequence); - RtlDeleteElementGenericTable(Mcb->Mapping, Element); - Mcb->PairCount--; - - Reinserted = RtlInsertElementGenericTable - (Mcb->Mapping, &Reinsert, sizeof(Reinsert), NULL); - InsertHeadList(GET_LIST_HEAD(Mcb->Mapping), &Reinserted->Sequence); - Mcb->PairCount++; - - Inserted = RtlInsertElementGenericTable - (Mcb->Mapping, &Upper, sizeof(Upper), NULL); - InsertHeadList(GET_LIST_HEAD(Mcb->Mapping), &Inserted->Sequence); - Mcb->PairCount++; - } - else if (Element->RunStartVbn.QuadPart < Node.RunStartVbn.QuadPart) - { - LARGE_MCB_MAPPING_ENTRY NewElement; - PLARGE_MCB_MAPPING_ENTRY Reinserted; - LARGE_INTEGER StartHole = Node.RunStartVbn; - NewElement.RunStartVbn = Element->RunStartVbn; - NewElement.StartingLbn = Element->StartingLbn; - NewElement.SectorCount.QuadPart = StartHole.QuadPart - Element->StartingLbn.QuadPart; - - RemoveEntryList(&Element->Sequence); - RtlDeleteElementGenericTable(Mcb->Mapping, Element); - Mcb->PairCount--; - - Reinserted = RtlInsertElementGenericTable - (Mcb->Mapping, &NewElement, sizeof(NewElement), NULL); - InsertHeadList(GET_LIST_HEAD(Mcb->Mapping), &Reinserted->Sequence); - Mcb->PairCount++; - } - else - { - LARGE_MCB_MAPPING_ENTRY NewElement; - PLARGE_MCB_MAPPING_ENTRY Reinserted; - LARGE_INTEGER EndHole = Element->RunStartVbn; - LARGE_INTEGER EndRun; - EndRun.QuadPart = Element->RunStartVbn.QuadPart + Element->SectorCount.QuadPart; - NewElement.RunStartVbn = EndHole; - NewElement.StartingLbn.QuadPart = Element->StartingLbn.QuadPart + - (EndHole.QuadPart - Element->RunStartVbn.QuadPart); - NewElement.SectorCount.QuadPart = EndRun.QuadPart - EndHole.QuadPart; - - RemoveEntryList(&Element->Sequence); - RtlDeleteElementGenericTable(Mcb->Mapping, Element); - Mcb->PairCount--; - - Reinserted = RtlInsertElementGenericTable - (Mcb->Mapping, &NewElement, sizeof(NewElement), NULL); - InsertHeadList(GET_LIST_HEAD(Mcb->Mapping), &Reinserted->Sequence); - Mcb->PairCount++; - } - } -} - -/* - * @implemented - */ -VOID -NTAPI -FsRtlRemoveLargeMcbEntry(IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG SectorCount) -{ - DPRINT("FsRtlRemoveLargeMcbEntry Mcb %x, Vbn %x, SectorCount %x\n", Mcb, (ULONG)Vbn, (ULONG)SectorCount); - - KeAcquireGuardedMutex(Mcb->GuardedMutex); - FsRtlRemoveBaseMcbEntry(&(Mcb->BaseMcb), - Vbn, - SectorCount); - KeReleaseGuardedMutex(Mcb->GuardedMutex); - - DPRINT("Done\n"); -} - -/* - * @implemented - */ -VOID -NTAPI -FsRtlResetBaseMcb(IN PBASE_MCB Mcb) -{ - PLARGE_MCB_MAPPING_ENTRY Element; - - DPRINT("Reset MCB %x\n", Mcb); - while (RtlNumberGenericTableElements(Mcb->Mapping) && - (Element = (PLARGE_MCB_MAPPING_ENTRY)RtlGetElementGenericTable(Mcb->Mapping, 0))) - { - DPRINT("Deleting %x\n", Element); - RtlDeleteElementGenericTable(Mcb->Mapping, Element); - } - - Mcb->PairCount = 0; - Mcb->MaximumPairCount = 0; - DPRINT("Done\n"); -} - -/* - * @implemented - */ -VOID -NTAPI -FsRtlResetLargeMcb(IN PLARGE_MCB Mcb, - IN BOOLEAN SelfSynchronized) -{ - if (!SelfSynchronized) - { - KeAcquireGuardedMutex(Mcb->GuardedMutex); - } - - FsRtlResetBaseMcb(&Mcb->BaseMcb); - - - if (!SelfSynchronized) - { - KeReleaseGuardedMutex(Mcb->GuardedMutex); - } -} - -#define MCB_BUMP_NO_MORE 0 -#define MCB_BUMP_AGAIN 1 - -static ULONG NTAPI McbBump(PBASE_MCB Mcb, PLARGE_MCB_MAPPING_ENTRY FixedPart) -{ - LARGE_MCB_MAPPING_ENTRY Reimagined; - PLARGE_MCB_MAPPING_ENTRY Found = NULL; - - DPRINT("McbBump %x (%x:%x)\n", Mcb, FixedPart->RunStartVbn.LowPart, FixedPart->SectorCount.LowPart); - - Reimagined = *FixedPart; - while ((Found = RtlLookupElementGenericTable(Mcb->Mapping, &Reimagined))) - { - Reimagined = *Found; - Reimagined.RunStartVbn.QuadPart = - FixedPart->RunStartVbn.QuadPart + FixedPart->SectorCount.QuadPart; - DPRINT("Reimagined %x\n", Reimagined.RunStartVbn.LowPart); - } - - DPRINT("Found %x\n", Found); - if (!Found) return MCB_BUMP_NO_MORE; - DPRINT1 - ("Moving %x-%x to %x because %x-%x overlaps\n", - Found->RunStartVbn.LowPart, - Found->RunStartVbn.LowPart + Found->SectorCount.QuadPart, - Reimagined.RunStartVbn.LowPart + Reimagined.SectorCount.LowPart, - Reimagined.RunStartVbn.LowPart, - Reimagined.RunStartVbn.LowPart + Reimagined.SectorCount.LowPart); - Found->RunStartVbn.QuadPart = Reimagined.RunStartVbn.QuadPart + Reimagined.SectorCount.QuadPart; - Found->StartingLbn.QuadPart = Reimagined.StartingLbn.QuadPart + Reimagined.SectorCount.QuadPart; - - DPRINT("Again\n"); - return MCB_BUMP_AGAIN; -} - -/* - * @unimplemented - */ -BOOLEAN -NTAPI -FsRtlSplitBaseMcb(IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Amount) -{ - ULONG Result; - LARGE_MCB_MAPPING_ENTRY Node; - PLARGE_MCB_MAPPING_ENTRY Existing = NULL; - - Node.RunStartVbn.QuadPart = Vbn; - Node.SectorCount.QuadPart = 0; - - Existing = RtlLookupElementGenericTable(Mcb->Mapping, &Node); - - if (Existing) - { - // We're in the middle of a run - LARGE_MCB_MAPPING_ENTRY UpperPart; - LARGE_MCB_MAPPING_ENTRY LowerPart; - PLARGE_MCB_MAPPING_ENTRY InsertedUpper; - - UpperPart.RunStartVbn.QuadPart = Node.RunStartVbn.QuadPart + Amount; - UpperPart.SectorCount.QuadPart = Existing->RunStartVbn.QuadPart + - (Existing->SectorCount.QuadPart - Node.RunStartVbn.QuadPart); - UpperPart.StartingLbn.QuadPart = Existing->StartingLbn.QuadPart + - (Node.RunStartVbn.QuadPart - Existing->RunStartVbn.QuadPart); - LowerPart.RunStartVbn.QuadPart = Existing->RunStartVbn.QuadPart; - LowerPart.SectorCount.QuadPart = Node.RunStartVbn.QuadPart - Existing->RunStartVbn.QuadPart; - LowerPart.StartingLbn.QuadPart = Existing->StartingLbn.QuadPart; - - Node = UpperPart; - - DPRINT("Loop: %x\n", Node.RunStartVbn.LowPart); - while ((Result = McbBump(Mcb, &Node)) == MCB_BUMP_AGAIN) - { - DPRINT("Node: %x\n", Node.RunStartVbn.LowPart); - } - DPRINT("Done\n"); - - if (Result == MCB_BUMP_NO_MORE) - { - Node = *Existing; - RemoveHeadList(&Existing->Sequence); - RtlDeleteElementGenericTable(Mcb->Mapping, Existing); - Mcb->PairCount--; - - // Adjust the element we found. - Existing->SectorCount = LowerPart.SectorCount; - - InsertedUpper = RtlInsertElementGenericTable - (Mcb->Mapping, &UpperPart, sizeof(UpperPart), NULL); - if (!InsertedUpper) - { - // Just make it like it was - Existing->SectorCount = Node.SectorCount; - return FALSE; - } - InsertHeadList(GET_LIST_HEAD(Mcb->Mapping), &InsertedUpper->Sequence); - Mcb->PairCount++; - } - else - { - Node.RunStartVbn.QuadPart = Vbn; - Node.SectorCount.QuadPart = Amount; - while ((Result = McbBump(Mcb, &Node)) == MCB_BUMP_AGAIN); - return Result == MCB_BUMP_NO_MORE; - } - } - - DPRINT("Done\n"); - - return TRUE; -} - -/* - * @implemented - */ -BOOLEAN -NTAPI -FsRtlSplitLargeMcb(IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Amount) -{ - BOOLEAN Result; - - DPRINT("FsRtlSplitLargeMcb %x, Vbn %x, Amount %x\n", Mcb, (ULONG)Vbn, (ULONG)Amount); - - KeAcquireGuardedMutex(Mcb->GuardedMutex); - Result = FsRtlSplitBaseMcb(&(Mcb->BaseMcb), - Vbn, - Amount); - KeReleaseGuardedMutex(Mcb->GuardedMutex); - - DPRINT("Done %d\n", Result); - - return Result; -} - -/* - * @unimplemented - */ -VOID -NTAPI -FsRtlTruncateBaseMcb(IN PBASE_MCB Mcb, - IN LONGLONG Vbn) -{ - DPRINT("FsRtlTruncateBaseMcb(%x,%x)\n", Mcb, (ULONG)Vbn); - if (!Vbn) - { - DPRINT("Resetting\n"); - FsRtlResetBaseMcb(Mcb); - } - else - { - LARGE_MCB_MAPPING_ENTRY Truncate; - PLARGE_MCB_MAPPING_ENTRY Found; - Truncate.RunStartVbn.QuadPart = Vbn; - Truncate.SectorCount.QuadPart = (1ull<<62) - Truncate.RunStartVbn.QuadPart; - while ((Found = RtlLookupElementGenericTable(Mcb->Mapping, &Truncate))) - { - DPRINT("Deleting %x\n", Found); - RemoveEntryList(&Found->Sequence); - RtlDeleteElementGenericTable(Mcb->Mapping, Found); - Mcb->PairCount--; - } - } - DPRINT("Done\n"); -} - -/* - * @implemented - */ -VOID -NTAPI -FsRtlTruncateLargeMcb(IN PLARGE_MCB Mcb, - IN LONGLONG Vbn) -{ - DPRINT("FsRtlTruncateLargeMcb %x Vbn %x\n", Mcb, (ULONG)Vbn); - KeAcquireGuardedMutex(Mcb->GuardedMutex); - FsRtlTruncateBaseMcb(&(Mcb->BaseMcb), - Vbn); - KeReleaseGuardedMutex(Mcb->GuardedMutex); - DPRINT("Done\n"); -} - -/* - * @implemented - */ -VOID -NTAPI -FsRtlUninitializeBaseMcb(IN PBASE_MCB Mcb) -{ - DPRINT("FsRtlUninitializeBaseMcb(%x)\n", Mcb); - FsRtlResetBaseMcb(Mcb); - - DPRINT("Mcb->Mapping %x\n", Mcb->Mapping); - if (Mcb->PoolType == PagedPool) - { - DPRINT("Deallocate to lookaside list\n"); - ExFreeToPagedLookasideList(&FsRtlFirstMappingLookasideList, - Mcb->Mapping); - } - else - { - DPRINT("Deallocate\n"); - ExFreePoolWithTag(Mcb->Mapping, 'FSBC'); - } - Mcb->Mapping = NULL; - DPRINT("Done\n"); -} - -/* - * @implemented - */ -VOID -NTAPI -FsRtlUninitializeLargeMcb(IN PLARGE_MCB Mcb) -{ - if (Mcb->GuardedMutex) - { - ExFreeToNPagedLookasideList(&FsRtlFastMutexLookasideList, - Mcb->GuardedMutex); - Mcb->GuardedMutex = NULL; - FsRtlUninitializeBaseMcb(&(Mcb->BaseMcb)); - } -} - -// MCB - -/* - * @implemented - */ -BOOLEAN -NTAPI -FsRtlAddMcbEntry(IN PMCB Mcb, - IN VBN Vbn, - IN LBN Lbn, - IN ULONG SectorCount) -{ - /* Call the newer function */ - return FsRtlAddLargeMcbEntry(&Mcb-> - DummyFieldThatSizesThisStructureCorrectly, - (LONGLONG)Vbn, - (LONGLONG)Lbn, - (LONGLONG)SectorCount); -} - -/* - * @implemented - */ -BOOLEAN -NTAPI -FsRtlGetNextMcbEntry(IN PMCB Mcb, - IN ULONG RunIndex, - OUT PVBN Vbn, - OUT PLBN Lbn, - OUT PULONG SectorCount) -{ - BOOLEAN Return = FALSE; - LONGLONG llVbn; - LONGLONG llLbn; - LONGLONG llSectorCount; - - /* Call the Large version */ - Return = FsRtlGetNextLargeMcbEntry( - &Mcb->DummyFieldThatSizesThisStructureCorrectly, - RunIndex, - &llVbn, - &llLbn, - &llSectorCount); - - /* Return the lower 32 bits */ - *Vbn = (ULONG)llVbn; - *Lbn = (ULONG)llLbn; - *SectorCount = (ULONG)llSectorCount; - - /* And return the original value */ - return Return; -} - -/* - * @implemented - */ -VOID -NTAPI -FsRtlInitializeMcb(IN PMCB Mcb, - IN POOL_TYPE PoolType) -{ - /* Call the newer function */ - FsRtlInitializeLargeMcb(&Mcb->DummyFieldThatSizesThisStructureCorrectly, - PoolType); + KeBugCheck(FILE_SYSTEM); + return(FALSE); } /* @@ -1078,11 +235,41 @@ */ ULONG NTAPI -FsRtlNumberOfRunsInMcb(IN PMCB Mcb) +FsRtlNumberOfRunsInLargeMcb(IN PLARGE_MCB Mcb) +{ + ULONG NumberOfRuns; + + /* Read the number of runs while holding the MCB lock */ + KeAcquireGuardedMutex(Mcb->GuardedMutex); + NumberOfRuns = Mcb->BaseMcb.PairCount; + KeReleaseGuardedMutex(Mcb->GuardedMutex); + + /* Return the count */ + return NumberOfRuns; +} + +/* + * @implemented + */ +ULONG +NTAPI +FsRtlNumberOfRunsInMcb (IN PMCB Mcb) { /* Call the newer function */ return FsRtlNumberOfRunsInLargeMcb( &Mcb->DummyFieldThatSizesThisStructureCorrectly); +} + +/* + * @unimplemented + */ +VOID +NTAPI +FsRtlRemoveLargeMcbEntry(IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG SectorCount) +{ + KeBugCheck(FILE_SYSTEM); } /* @@ -1101,12 +288,47 @@ } /* - * @implemented - */ -VOID -NTAPI -FsRtlTruncateMcb(IN PMCB Mcb, - IN VBN Vbn) + * @unimplemented + */ +VOID +NTAPI +FsRtlResetLargeMcb(IN PLARGE_MCB Mcb, + IN BOOLEAN SelfSynchronized) +{ + KeBugCheck(FILE_SYSTEM); +} + +/* + * @unimplemented + */ +BOOLEAN +NTAPI +FsRtlSplitLargeMcb(IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Amount) +{ + KeBugCheck(FILE_SYSTEM); + return FALSE; +} + +/* + * @unimplemented + */ +VOID +NTAPI +FsRtlTruncateLargeMcb(IN PLARGE_MCB Mcb, + IN LONGLONG Vbn) +{ + KeBugCheck(FILE_SYSTEM); +} + +/* + * @implemented + */ +VOID +NTAPI +FsRtlTruncateMcb (IN PMCB Mcb, + IN VBN Vbn) { /* Call the newer function */ FsRtlTruncateLargeMcb(&Mcb->DummyFieldThatSizesThisStructureCorrectly, @@ -1114,6 +336,16 @@ } /* + * @unimplemented + */ +VOID +NTAPI +FsRtlUninitializeLargeMcb(IN PLARGE_MCB Mcb) +{ + KeBugCheck(FILE_SYSTEM); +} + +/* * @implemented */ VOID
13 years, 10 months
1
0
0
0
[pschweitzer] 50873: [NTOSKRNL] One-line fix for FsRtlIs*InExpression(). This fixes failing tests, but not overrun. Added some breaks to reach more quickly the end
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Wed Feb 23 12:04:08 2011 New Revision: 50873 URL:
http://svn.reactos.org/svn/reactos?rev=50873&view=rev
Log: [NTOSKRNL] One-line fix for FsRtlIs*InExpression(). This fixes failing tests, but not overrun. Added some breaks to reach more quickly the end Modified: trunk/reactos/ntoskrnl/fsrtl/dbcsname.c trunk/reactos/ntoskrnl/fsrtl/largemcb.c Modified: trunk/reactos/ntoskrnl/fsrtl/dbcsname.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fsrtl/dbcsname.c?…
============================================================================== --- trunk/reactos/ntoskrnl/fsrtl/dbcsname.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/fsrtl/dbcsname.c [iso-8859-1] Wed Feb 23 12:04:08 2011 @@ -181,7 +181,7 @@ switch (Expression->Buffer[ExpressionPosition]) { case '*': - StarFound = ExpressionPosition++; + StarFound = MAXUSHORT; break; case '?': @@ -226,6 +226,7 @@ if (ExpressionPosition == Expression->Length) { NamePosition = Name->Length; + break; } } else if (Expression->Buffer[ExpressionPosition] == ANSI_DOS_STAR) @@ -253,7 +254,7 @@ } else { - NamePosition = Name->Length; + break; } } if (ExpressionPosition + 1 == Expression->Length && NamePosition == Name->Length && Modified: trunk/reactos/ntoskrnl/fsrtl/largemcb.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fsrtl/largemcb.c?…
============================================================================== --- trunk/reactos/ntoskrnl/fsrtl/largemcb.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/fsrtl/largemcb.c [iso-8859-1] Wed Feb 23 12:04:08 2011 @@ -2,8 +2,10 @@ * PROJECT: ReactOS Kernel * LICENSE: GPL - See COPYING in the top level directory * FILE: ntoskrnl/fsrtl/largemcb.c - * PURPOSE: Mapping Control Block (MCB) support for File System Drivers + * PURPOSE: Large Mapped Control Block (MCB) support for File System Drivers * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) + * Pierre Schweitzer (heis_spiter(a)hotmail.com) + * Art Yerkes (art.yerkes(a)gmail.com) */ /* INCLUDES ******************************************************************/ @@ -12,10 +14,158 @@ #define NDEBUG #include <debug.h> +/* GLOBALS *******************************************************************/ + +#define GET_LIST_HEAD(x) ((PLIST_ENTRY)(&((PRTL_GENERIC_TABLE)x)[1])) + +PAGED_LOOKASIDE_LIST FsRtlFirstMappingLookasideList; +NPAGED_LOOKASIDE_LIST FsRtlFastMutexLookasideList; + +typedef struct _LARGE_MCB_MAPPING_ENTRY +{ + LARGE_INTEGER RunStartVbn; + LARGE_INTEGER SectorCount; + LARGE_INTEGER StartingLbn; + LIST_ENTRY Sequence; +} LARGE_MCB_MAPPING_ENTRY, *PLARGE_MCB_MAPPING_ENTRY; + +static VOID McbPrintTree(PBASE_MCB Mcb) +{ + PLARGE_MCB_MAPPING_ENTRY Entry; + for (Entry = (PLARGE_MCB_MAPPING_ENTRY) + RtlEnumerateGenericTable(Mcb->Mapping, TRUE); + Entry; + Entry = (PLARGE_MCB_MAPPING_ENTRY) + RtlEnumerateGenericTable(Mcb->Mapping, FALSE)) + { + DPRINT1 + ("Vbn %x Lbn %x Count %x\n", + Entry->RunStartVbn.LowPart, + Entry->StartingLbn.LowPart, + Entry->SectorCount.LowPart); + } +} + +static PVOID NTAPI McbMappingAllocate(PRTL_GENERIC_TABLE Table, CLONG Bytes) +{ + PVOID Result; + PBASE_MCB Mcb = (PBASE_MCB)Table->TableContext; + Result = ExAllocatePoolWithTag(Mcb->PoolType, Bytes, 'LMCB'); + DPRINT("McbMappingAllocate(%d) => %p\n", Bytes, Result); + return Result; +} + +static VOID NTAPI McbMappingFree(PRTL_GENERIC_TABLE Table, PVOID Buffer) +{ + DPRINT("McbMappingFree(%p)\n", Buffer); + ExFreePoolWithTag(Buffer, 'LMCB'); +} + +static RTL_GENERIC_COMPARE_RESULTS NTAPI McbMappingCompare +(PRTL_GENERIC_TABLE Table, PVOID PtrA, PVOID PtrB) +{ + PLARGE_MCB_MAPPING_ENTRY A = PtrA, B = PtrB; + RTL_GENERIC_COMPARE_RESULTS Result; + DPRINT("Starting to compare element %x to element %x\n", PtrA, PtrB); + Result = + (A->RunStartVbn.QuadPart + A->SectorCount.QuadPart <= + B->RunStartVbn.QuadPart) ? GenericLessThan : + (A->RunStartVbn.QuadPart >= + B->RunStartVbn.QuadPart + B->SectorCount.QuadPart) ? + GenericGreaterThan : GenericEqual; + DPRINT("Compare(%x:%x): %x:%x to %x:%x => %d\n", + A,B, + A->RunStartVbn.LowPart, A->SectorCount.LowPart, + B->RunStartVbn.LowPart, B->SectorCount.LowPart, + Result); + return Result; +} + /* PUBLIC FUNCTIONS **********************************************************/ /* - * @unimplemented + * @implemented + */ +BOOLEAN +NTAPI +FsRtlAddBaseMcbEntry(IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Lbn, + IN LONGLONG SectorCount) +{ + LARGE_MCB_MAPPING_ENTRY Node; + PLARGE_MCB_MAPPING_ENTRY Existing = NULL; + BOOLEAN NewElement = FALSE; + + McbPrintTree(Mcb); + + Node.RunStartVbn.QuadPart = Vbn; + Node.StartingLbn.QuadPart = Lbn; + Node.SectorCount.QuadPart = SectorCount; + + DPRINT("RunStartVbn %x\n", Node.RunStartVbn.LowPart); + DPRINT("StartingLbn %x\n", Node.StartingLbn.LowPart); + DPRINT("SectorCount %x\n", Node.SectorCount.LowPart); + + while (!NewElement) + { + DPRINT("Inserting %x:%x\n", Node.RunStartVbn.LowPart, Node.SectorCount.LowPart); + Existing = RtlInsertElementGenericTable + (Mcb->Mapping, &Node, sizeof(Node), &NewElement); + DPRINT("Existing %x\n", Existing); + if (!Existing) break; + + DPRINT("NewElement %d\n", NewElement); + if (!NewElement) + { + // We merge the existing runs + LARGE_INTEGER StartVbn, FinalVbn; + DPRINT("Existing: %x:%x\n", + Existing->RunStartVbn.LowPart, Node.SectorCount.LowPart); + if (Existing->RunStartVbn.QuadPart < Node.RunStartVbn.QuadPart) + { + StartVbn = Existing->RunStartVbn; + Node.StartingLbn = Existing->StartingLbn; + } + else + { + StartVbn = Node.RunStartVbn; + } + DPRINT("StartVbn %x\n", StartVbn.LowPart); + if (Existing->RunStartVbn.QuadPart + Existing->SectorCount.QuadPart > + Node.RunStartVbn.QuadPart + Node.SectorCount.QuadPart) + { + FinalVbn.QuadPart = + Existing->RunStartVbn.QuadPart + Existing->SectorCount.QuadPart; + } + else + { + FinalVbn.QuadPart = + Node.RunStartVbn.QuadPart + Node.SectorCount.QuadPart; + } + DPRINT("FinalVbn %x\n", FinalVbn.LowPart); + Node.RunStartVbn.QuadPart = StartVbn.QuadPart; + Node.SectorCount.QuadPart = FinalVbn.QuadPart - StartVbn.QuadPart; + RemoveHeadList(&Existing->Sequence); + RtlDeleteElementGenericTable(Mcb->Mapping, Existing); + Mcb->PairCount--; + } + else + { + DPRINT("Mapping added %x\n", Existing); + Mcb->MaximumPairCount++; + Mcb->PairCount++; + InsertHeadList(GET_LIST_HEAD(Mcb->Mapping), &Existing->Sequence); + } + } + + DPRINT("!!Existing %d\n", !!Existing); + McbPrintTree(Mcb); + return !!Existing; +} + +/* + * @implemented */ BOOLEAN NTAPI @@ -24,9 +174,780 @@ IN LONGLONG Lbn, IN LONGLONG SectorCount) { - KeBugCheck(FILE_SYSTEM); - return FALSE; -} + BOOLEAN Result; + + DPRINT + ("Mcb %x Vbn %x Lbn %x SectorCount %x\n", + Mcb, (ULONG)Vbn, (ULONG)Lbn, (ULONG)SectorCount); + + KeAcquireGuardedMutex(Mcb->GuardedMutex); + Result = FsRtlAddBaseMcbEntry(&(Mcb->BaseMcb), + Vbn, + Lbn, + SectorCount); + KeReleaseGuardedMutex(Mcb->GuardedMutex); + + DPRINT("Done %d\n", Result); + + return Result; +} + +/* + * @unimplemented + */ +BOOLEAN +NTAPI +FsRtlGetNextBaseMcbEntry(IN PBASE_MCB Mcb, + IN ULONG RunIndex, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn, + OUT PLONGLONG SectorCount) +{ + ULONG i = 0; + BOOLEAN Result = FALSE; + PLARGE_MCB_MAPPING_ENTRY Entry; + for (Entry = (PLARGE_MCB_MAPPING_ENTRY) + RtlEnumerateGenericTable(Mcb->Mapping, TRUE); + Entry && i < RunIndex; + Entry = (PLARGE_MCB_MAPPING_ENTRY) + RtlEnumerateGenericTable(Mcb->Mapping, FALSE), i++); + if (Entry) + { + Result = TRUE; + if (Vbn) + *Vbn = Entry->RunStartVbn.QuadPart; + if (Lbn) + *Lbn = Entry->StartingLbn.QuadPart; + if (SectorCount) + *SectorCount = Entry->SectorCount.QuadPart; + } + + return Result; +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +FsRtlGetNextLargeMcbEntry(IN PLARGE_MCB Mcb, + IN ULONG RunIndex, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn, + OUT PLONGLONG SectorCount) +{ + BOOLEAN Result; + + DPRINT("FsRtlGetNextLargeMcbEntry Mcb %x RunIndex %x\n", Mcb, RunIndex); + + KeAcquireGuardedMutex(Mcb->GuardedMutex); + Result = FsRtlGetNextBaseMcbEntry(&(Mcb->BaseMcb), + RunIndex, + Vbn, + Lbn, + SectorCount); + KeReleaseGuardedMutex(Mcb->GuardedMutex); + + DPRINT("Done %d\n", Result); + + return Result; +} + +/* + * @implemented + */ +VOID +NTAPI +FsRtlInitializeBaseMcb(IN PBASE_MCB Mcb, + IN POOL_TYPE PoolType) +{ + Mcb->PairCount = 0; + + if (PoolType == PagedPool) + { + Mcb->Mapping = ExAllocateFromPagedLookasideList(&FsRtlFirstMappingLookasideList); + DPRINT("Get from lookaside list\n"); + } + else + { + Mcb->Mapping = ExAllocatePoolWithTag(PoolType | POOL_RAISE_IF_ALLOCATION_FAILURE, + sizeof(RTL_GENERIC_TABLE) + sizeof(LIST_ENTRY), + 'FSBC'); + DPRINT("Allocate\n"); + } + + DPRINT("Mcb->Mapping %x\n", Mcb->Mapping); + Mcb->PoolType = PoolType; + Mcb->MaximumPairCount = MAXIMUM_PAIR_COUNT; + RtlInitializeGenericTable + (Mcb->Mapping, + McbMappingCompare, + McbMappingAllocate, + McbMappingFree, + Mcb); + InitializeListHead(GET_LIST_HEAD(Mcb->Mapping)); +} + +/* + * @implemented + */ +VOID +NTAPI +FsRtlInitializeLargeMcb(IN PLARGE_MCB Mcb, + IN POOL_TYPE PoolType) +{ + Mcb->GuardedMutex = ExAllocateFromNPagedLookasideList(&FsRtlFastMutexLookasideList); + + KeInitializeGuardedMutex(Mcb->GuardedMutex); + + _SEH2_TRY + { + FsRtlInitializeBaseMcb(&(Mcb->BaseMcb), PoolType); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + ExFreeToNPagedLookasideList(&FsRtlFastMutexLookasideList, + Mcb->GuardedMutex); + Mcb->GuardedMutex = NULL; + } + _SEH2_END; +} + +/* + * @implemented + */ +VOID +NTAPI +FsRtlInitializeLargeMcbs(VOID) +{ + /* Initialize the list for the MCB */ + ExInitializePagedLookasideList(&FsRtlFirstMappingLookasideList, + NULL, + NULL, + POOL_RAISE_IF_ALLOCATION_FAILURE, + sizeof(RTL_GENERIC_TABLE) + sizeof(LIST_ENTRY), + IFS_POOL_TAG, + 0); /* FIXME: Should be 4 */ + + /* Initialize the list for the guarded mutex */ + ExInitializeNPagedLookasideList(&FsRtlFastMutexLookasideList, + NULL, + NULL, + POOL_RAISE_IF_ALLOCATION_FAILURE, + sizeof(KGUARDED_MUTEX), + IFS_POOL_TAG, + 0); /* FIXME: Should be 32 */ +} + +/* + * @unimplemented + */ +BOOLEAN +NTAPI +FsRtlLookupBaseMcbEntry(IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + OUT PLONGLONG Lbn OPTIONAL, + OUT PLONGLONG SectorCountFromLbn OPTIONAL, + OUT PLONGLONG StartingLbn OPTIONAL, + OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, + OUT PULONG Index OPTIONAL) +{ + BOOLEAN Result = FALSE; + LARGE_MCB_MAPPING_ENTRY ToLookup; + PLARGE_MCB_MAPPING_ENTRY Entry; + + ToLookup.RunStartVbn.QuadPart = Vbn; + ToLookup.SectorCount.QuadPart = 1; + + Entry = RtlLookupElementGenericTable(Mcb->Mapping, &ToLookup); + if (!Entry) + { + // Find out if we have a following entry. The spec says we should return + // found with Lbn == -1 when we're beneath the largest map. + ToLookup.SectorCount.QuadPart = (1ull<<62) - ToLookup.RunStartVbn.QuadPart; + Entry = RtlLookupElementGenericTable(Mcb->Mapping, &ToLookup); + if (Entry) + { + Result = TRUE; + if (Lbn) *Lbn = ~0ull; + } + else + { + Result = FALSE; + } + } + else + { + LARGE_INTEGER Offset; + Offset.QuadPart = Vbn - Entry->RunStartVbn.QuadPart; + Result = TRUE; + if (Lbn) *Lbn = Entry->StartingLbn.QuadPart + Offset.QuadPart; + if (SectorCountFromLbn) *SectorCountFromLbn = Entry->SectorCount.QuadPart - Offset.QuadPart; + if (StartingLbn) *StartingLbn = Entry->StartingLbn.QuadPart; + if (SectorCountFromStartingLbn) *SectorCountFromStartingLbn = Entry->SectorCount.QuadPart; + } + + return Result; +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +FsRtlLookupLargeMcbEntry(IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + OUT PLONGLONG Lbn OPTIONAL, + OUT PLONGLONG SectorCountFromLbn OPTIONAL, + OUT PLONGLONG StartingLbn OPTIONAL, + OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, + OUT PULONG Index OPTIONAL) +{ + BOOLEAN Result; + + DPRINT("FsRtlLookupLargeMcbEntry Mcb %x Vbn %x\n", Mcb, (ULONG)Vbn); + + KeAcquireGuardedMutex(Mcb->GuardedMutex); + Result = FsRtlLookupBaseMcbEntry(&(Mcb->BaseMcb), + Vbn, + Lbn, + SectorCountFromLbn, + StartingLbn, + SectorCountFromStartingLbn, + Index); + KeReleaseGuardedMutex(Mcb->GuardedMutex); + + DPRINT("Done %d (%x)\n", Result, Lbn ? (ULONG)*Lbn : 0); + + return Result; +} + +/* + * @unimplemented + */ +BOOLEAN +NTAPI +FsRtlLookupLastBaseMcbEntryAndIndex(IN PBASE_MCB OpaqueMcb, + IN OUT PLONGLONG LargeVbn, + IN OUT PLONGLONG LargeLbn, + IN OUT PULONG Index) +{ + ULONG i = 0; + BOOLEAN Result = FALSE; + PLIST_ENTRY ListEntry; + PLARGE_MCB_MAPPING_ENTRY Entry; + PLARGE_MCB_MAPPING_ENTRY CountEntry; + + ListEntry = GET_LIST_HEAD(OpaqueMcb->Mapping); + if (!IsListEmpty(ListEntry)) + { + Entry = CONTAINING_RECORD(ListEntry->Flink, LARGE_MCB_MAPPING_ENTRY, Sequence); + Result = TRUE; + *LargeVbn = Entry->RunStartVbn.QuadPart; + *LargeLbn = Entry->StartingLbn.QuadPart; + + for (i = 0, CountEntry = RtlEnumerateGenericTable(OpaqueMcb->Mapping, TRUE); + CountEntry != Entry; + CountEntry = RtlEnumerateGenericTable(OpaqueMcb->Mapping, FALSE)); + + *Index = i; + } + + return Result; +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +FsRtlLookupLastLargeMcbEntryAndIndex(IN PLARGE_MCB OpaqueMcb, + OUT PLONGLONG LargeVbn, + OUT PLONGLONG LargeLbn, + OUT PULONG Index) +{ + BOOLEAN Result; + + DPRINT("FsRtlLookupLastLargeMcbEntryAndIndex %x\n", OpaqueMcb); + + KeAcquireGuardedMutex(OpaqueMcb->GuardedMutex); + Result = FsRtlLookupLastBaseMcbEntryAndIndex(&(OpaqueMcb->BaseMcb), + LargeVbn, + LargeLbn, + Index); + KeReleaseGuardedMutex(OpaqueMcb->GuardedMutex); + + DPRINT("Done %d\n", Result); + + return Result; +} + +/* + * @unimplemented + */ +BOOLEAN +NTAPI +FsRtlLookupLastBaseMcbEntry(IN PBASE_MCB Mcb, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn) +{ + BOOLEAN Result = FALSE; + PLIST_ENTRY ListEntry; + PLARGE_MCB_MAPPING_ENTRY Entry; + + ListEntry = GET_LIST_HEAD(Mcb->Mapping); + if (!IsListEmpty(ListEntry)) + { + Entry = CONTAINING_RECORD(ListEntry->Flink, LARGE_MCB_MAPPING_ENTRY, Sequence); + Result = TRUE; + *Vbn = Entry->RunStartVbn.QuadPart; + *Lbn = Entry->StartingLbn.QuadPart; + } + + return Result; +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +FsRtlLookupLastLargeMcbEntry(IN PLARGE_MCB Mcb, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn) +{ + BOOLEAN Result; + + DPRINT("FsRtlLookupLastLargeMcbEntry Mcb %x\n", Mcb); + + KeAcquireGuardedMutex(Mcb->GuardedMutex); + Result = FsRtlLookupLastBaseMcbEntry(&(Mcb->BaseMcb), + Vbn, + Lbn); + KeReleaseGuardedMutex(Mcb->GuardedMutex); + + DPRINT("Done %d\n", Result); + + return Result; +} + +/* + * @implemented + */ +ULONG +NTAPI +FsRtlNumberOfRunsInBaseMcb(IN PBASE_MCB Mcb) +{ + /* Return the count */ + return Mcb->PairCount; +} + +/* + * @implemented + */ +ULONG +NTAPI +FsRtlNumberOfRunsInLargeMcb(IN PLARGE_MCB Mcb) +{ + ULONG NumberOfRuns; + + DPRINT("FsRtlNumberOfRunsInLargeMcb Mcb %x\n", Mcb); + + /* Read the number of runs while holding the MCB lock */ + KeAcquireGuardedMutex(Mcb->GuardedMutex); + NumberOfRuns = Mcb->BaseMcb.PairCount; + KeReleaseGuardedMutex(Mcb->GuardedMutex); + + DPRINT("Done %d\n", NumberOfRuns); + + /* Return the count */ + return NumberOfRuns; +} + +/* + * @unimplemented + */ +VOID +NTAPI +FsRtlRemoveBaseMcbEntry(IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG SectorCount) +{ + LARGE_MCB_MAPPING_ENTRY Node; + PLARGE_MCB_MAPPING_ENTRY Element; + + Node.RunStartVbn.QuadPart = Vbn; + Node.SectorCount.QuadPart = SectorCount; + + while ((Element = RtlLookupElementGenericTable(Mcb->Mapping, &Node))) + { + // Must split + if (Element->RunStartVbn.QuadPart < Node.RunStartVbn.QuadPart && + Element->SectorCount.QuadPart > Node.SectorCount.QuadPart) + { + LARGE_MCB_MAPPING_ENTRY Upper, Reinsert; + PLARGE_MCB_MAPPING_ENTRY Reinserted, Inserted; + LARGE_INTEGER StartHole = Node.RunStartVbn; + LARGE_INTEGER EndHole; + EndHole.QuadPart = Node.RunStartVbn.QuadPart + Node.SectorCount.QuadPart; + Upper.RunStartVbn.QuadPart = EndHole.QuadPart; + Upper.StartingLbn.QuadPart = + Element->StartingLbn.QuadPart + + EndHole.QuadPart - + Element->RunStartVbn.QuadPart; + Upper.SectorCount.QuadPart = + Element->SectorCount.QuadPart - + (EndHole.QuadPart - Element->RunStartVbn.QuadPart); + Reinsert = *Element; + Reinsert.SectorCount.QuadPart = + Element->RunStartVbn.QuadPart - StartHole.QuadPart; + RemoveEntryList(&Element->Sequence); + RtlDeleteElementGenericTable(Mcb->Mapping, Element); + Mcb->PairCount--; + + Reinserted = RtlInsertElementGenericTable + (Mcb->Mapping, &Reinsert, sizeof(Reinsert), NULL); + InsertHeadList(GET_LIST_HEAD(Mcb->Mapping), &Reinserted->Sequence); + Mcb->PairCount++; + + Inserted = RtlInsertElementGenericTable + (Mcb->Mapping, &Upper, sizeof(Upper), NULL); + InsertHeadList(GET_LIST_HEAD(Mcb->Mapping), &Inserted->Sequence); + Mcb->PairCount++; + } + else if (Element->RunStartVbn.QuadPart < Node.RunStartVbn.QuadPart) + { + LARGE_MCB_MAPPING_ENTRY NewElement; + PLARGE_MCB_MAPPING_ENTRY Reinserted; + LARGE_INTEGER StartHole = Node.RunStartVbn; + NewElement.RunStartVbn = Element->RunStartVbn; + NewElement.StartingLbn = Element->StartingLbn; + NewElement.SectorCount.QuadPart = StartHole.QuadPart - Element->StartingLbn.QuadPart; + + RemoveEntryList(&Element->Sequence); + RtlDeleteElementGenericTable(Mcb->Mapping, Element); + Mcb->PairCount--; + + Reinserted = RtlInsertElementGenericTable + (Mcb->Mapping, &NewElement, sizeof(NewElement), NULL); + InsertHeadList(GET_LIST_HEAD(Mcb->Mapping), &Reinserted->Sequence); + Mcb->PairCount++; + } + else + { + LARGE_MCB_MAPPING_ENTRY NewElement; + PLARGE_MCB_MAPPING_ENTRY Reinserted; + LARGE_INTEGER EndHole = Element->RunStartVbn; + LARGE_INTEGER EndRun; + EndRun.QuadPart = Element->RunStartVbn.QuadPart + Element->SectorCount.QuadPart; + NewElement.RunStartVbn = EndHole; + NewElement.StartingLbn.QuadPart = Element->StartingLbn.QuadPart + + (EndHole.QuadPart - Element->RunStartVbn.QuadPart); + NewElement.SectorCount.QuadPart = EndRun.QuadPart - EndHole.QuadPart; + + RemoveEntryList(&Element->Sequence); + RtlDeleteElementGenericTable(Mcb->Mapping, Element); + Mcb->PairCount--; + + Reinserted = RtlInsertElementGenericTable + (Mcb->Mapping, &NewElement, sizeof(NewElement), NULL); + InsertHeadList(GET_LIST_HEAD(Mcb->Mapping), &Reinserted->Sequence); + Mcb->PairCount++; + } + } +} + +/* + * @implemented + */ +VOID +NTAPI +FsRtlRemoveLargeMcbEntry(IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG SectorCount) +{ + DPRINT("FsRtlRemoveLargeMcbEntry Mcb %x, Vbn %x, SectorCount %x\n", Mcb, (ULONG)Vbn, (ULONG)SectorCount); + + KeAcquireGuardedMutex(Mcb->GuardedMutex); + FsRtlRemoveBaseMcbEntry(&(Mcb->BaseMcb), + Vbn, + SectorCount); + KeReleaseGuardedMutex(Mcb->GuardedMutex); + + DPRINT("Done\n"); +} + +/* + * @implemented + */ +VOID +NTAPI +FsRtlResetBaseMcb(IN PBASE_MCB Mcb) +{ + PLARGE_MCB_MAPPING_ENTRY Element; + + DPRINT("Reset MCB %x\n", Mcb); + while (RtlNumberGenericTableElements(Mcb->Mapping) && + (Element = (PLARGE_MCB_MAPPING_ENTRY)RtlGetElementGenericTable(Mcb->Mapping, 0))) + { + DPRINT("Deleting %x\n", Element); + RtlDeleteElementGenericTable(Mcb->Mapping, Element); + } + + Mcb->PairCount = 0; + Mcb->MaximumPairCount = 0; + DPRINT("Done\n"); +} + +/* + * @implemented + */ +VOID +NTAPI +FsRtlResetLargeMcb(IN PLARGE_MCB Mcb, + IN BOOLEAN SelfSynchronized) +{ + if (!SelfSynchronized) + { + KeAcquireGuardedMutex(Mcb->GuardedMutex); + } + + FsRtlResetBaseMcb(&Mcb->BaseMcb); + + + if (!SelfSynchronized) + { + KeReleaseGuardedMutex(Mcb->GuardedMutex); + } +} + +#define MCB_BUMP_NO_MORE 0 +#define MCB_BUMP_AGAIN 1 + +static ULONG NTAPI McbBump(PBASE_MCB Mcb, PLARGE_MCB_MAPPING_ENTRY FixedPart) +{ + LARGE_MCB_MAPPING_ENTRY Reimagined; + PLARGE_MCB_MAPPING_ENTRY Found = NULL; + + DPRINT("McbBump %x (%x:%x)\n", Mcb, FixedPart->RunStartVbn.LowPart, FixedPart->SectorCount.LowPart); + + Reimagined = *FixedPart; + while ((Found = RtlLookupElementGenericTable(Mcb->Mapping, &Reimagined))) + { + Reimagined = *Found; + Reimagined.RunStartVbn.QuadPart = + FixedPart->RunStartVbn.QuadPart + FixedPart->SectorCount.QuadPart; + DPRINT("Reimagined %x\n", Reimagined.RunStartVbn.LowPart); + } + + DPRINT("Found %x\n", Found); + if (!Found) return MCB_BUMP_NO_MORE; + DPRINT1 + ("Moving %x-%x to %x because %x-%x overlaps\n", + Found->RunStartVbn.LowPart, + Found->RunStartVbn.LowPart + Found->SectorCount.QuadPart, + Reimagined.RunStartVbn.LowPart + Reimagined.SectorCount.LowPart, + Reimagined.RunStartVbn.LowPart, + Reimagined.RunStartVbn.LowPart + Reimagined.SectorCount.LowPart); + Found->RunStartVbn.QuadPart = Reimagined.RunStartVbn.QuadPart + Reimagined.SectorCount.QuadPart; + Found->StartingLbn.QuadPart = Reimagined.StartingLbn.QuadPart + Reimagined.SectorCount.QuadPart; + + DPRINT("Again\n"); + return MCB_BUMP_AGAIN; +} + +/* + * @unimplemented + */ +BOOLEAN +NTAPI +FsRtlSplitBaseMcb(IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Amount) +{ + ULONG Result; + LARGE_MCB_MAPPING_ENTRY Node; + PLARGE_MCB_MAPPING_ENTRY Existing = NULL; + + Node.RunStartVbn.QuadPart = Vbn; + Node.SectorCount.QuadPart = 0; + + Existing = RtlLookupElementGenericTable(Mcb->Mapping, &Node); + + if (Existing) + { + // We're in the middle of a run + LARGE_MCB_MAPPING_ENTRY UpperPart; + LARGE_MCB_MAPPING_ENTRY LowerPart; + PLARGE_MCB_MAPPING_ENTRY InsertedUpper; + + UpperPart.RunStartVbn.QuadPart = Node.RunStartVbn.QuadPart + Amount; + UpperPart.SectorCount.QuadPart = Existing->RunStartVbn.QuadPart + + (Existing->SectorCount.QuadPart - Node.RunStartVbn.QuadPart); + UpperPart.StartingLbn.QuadPart = Existing->StartingLbn.QuadPart + + (Node.RunStartVbn.QuadPart - Existing->RunStartVbn.QuadPart); + LowerPart.RunStartVbn.QuadPart = Existing->RunStartVbn.QuadPart; + LowerPart.SectorCount.QuadPart = Node.RunStartVbn.QuadPart - Existing->RunStartVbn.QuadPart; + LowerPart.StartingLbn.QuadPart = Existing->StartingLbn.QuadPart; + + Node = UpperPart; + + DPRINT("Loop: %x\n", Node.RunStartVbn.LowPart); + while ((Result = McbBump(Mcb, &Node)) == MCB_BUMP_AGAIN) + { + DPRINT("Node: %x\n", Node.RunStartVbn.LowPart); + } + DPRINT("Done\n"); + + if (Result == MCB_BUMP_NO_MORE) + { + Node = *Existing; + RemoveHeadList(&Existing->Sequence); + RtlDeleteElementGenericTable(Mcb->Mapping, Existing); + Mcb->PairCount--; + + // Adjust the element we found. + Existing->SectorCount = LowerPart.SectorCount; + + InsertedUpper = RtlInsertElementGenericTable + (Mcb->Mapping, &UpperPart, sizeof(UpperPart), NULL); + if (!InsertedUpper) + { + // Just make it like it was + Existing->SectorCount = Node.SectorCount; + return FALSE; + } + InsertHeadList(GET_LIST_HEAD(Mcb->Mapping), &InsertedUpper->Sequence); + Mcb->PairCount++; + } + else + { + Node.RunStartVbn.QuadPart = Vbn; + Node.SectorCount.QuadPart = Amount; + while ((Result = McbBump(Mcb, &Node)) == MCB_BUMP_AGAIN); + return Result == MCB_BUMP_NO_MORE; + } + } + + DPRINT("Done\n"); + + return TRUE; +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +FsRtlSplitLargeMcb(IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Amount) +{ + BOOLEAN Result; + + DPRINT("FsRtlSplitLargeMcb %x, Vbn %x, Amount %x\n", Mcb, (ULONG)Vbn, (ULONG)Amount); + + KeAcquireGuardedMutex(Mcb->GuardedMutex); + Result = FsRtlSplitBaseMcb(&(Mcb->BaseMcb), + Vbn, + Amount); + KeReleaseGuardedMutex(Mcb->GuardedMutex); + + DPRINT("Done %d\n", Result); + + return Result; +} + +/* + * @unimplemented + */ +VOID +NTAPI +FsRtlTruncateBaseMcb(IN PBASE_MCB Mcb, + IN LONGLONG Vbn) +{ + DPRINT("FsRtlTruncateBaseMcb(%x,%x)\n", Mcb, (ULONG)Vbn); + if (!Vbn) + { + DPRINT("Resetting\n"); + FsRtlResetBaseMcb(Mcb); + } + else + { + LARGE_MCB_MAPPING_ENTRY Truncate; + PLARGE_MCB_MAPPING_ENTRY Found; + Truncate.RunStartVbn.QuadPart = Vbn; + Truncate.SectorCount.QuadPart = (1ull<<62) - Truncate.RunStartVbn.QuadPart; + while ((Found = RtlLookupElementGenericTable(Mcb->Mapping, &Truncate))) + { + DPRINT("Deleting %x\n", Found); + RemoveEntryList(&Found->Sequence); + RtlDeleteElementGenericTable(Mcb->Mapping, Found); + Mcb->PairCount--; + } + } + DPRINT("Done\n"); +} + +/* + * @implemented + */ +VOID +NTAPI +FsRtlTruncateLargeMcb(IN PLARGE_MCB Mcb, + IN LONGLONG Vbn) +{ + DPRINT("FsRtlTruncateLargeMcb %x Vbn %x\n", Mcb, (ULONG)Vbn); + KeAcquireGuardedMutex(Mcb->GuardedMutex); + FsRtlTruncateBaseMcb(&(Mcb->BaseMcb), + Vbn); + KeReleaseGuardedMutex(Mcb->GuardedMutex); + DPRINT("Done\n"); +} + +/* + * @implemented + */ +VOID +NTAPI +FsRtlUninitializeBaseMcb(IN PBASE_MCB Mcb) +{ + DPRINT("FsRtlUninitializeBaseMcb(%x)\n", Mcb); + FsRtlResetBaseMcb(Mcb); + + DPRINT("Mcb->Mapping %x\n", Mcb->Mapping); + if (Mcb->PoolType == PagedPool) + { + DPRINT("Deallocate to lookaside list\n"); + ExFreeToPagedLookasideList(&FsRtlFirstMappingLookasideList, + Mcb->Mapping); + } + else + { + DPRINT("Deallocate\n"); + ExFreePoolWithTag(Mcb->Mapping, 'FSBC'); + } + Mcb->Mapping = NULL; + DPRINT("Done\n"); +} + +/* + * @implemented + */ +VOID +NTAPI +FsRtlUninitializeLargeMcb(IN PLARGE_MCB Mcb) +{ + if (Mcb->GuardedMutex) + { + ExFreeToNPagedLookasideList(&FsRtlFastMutexLookasideList, + Mcb->GuardedMutex); + Mcb->GuardedMutex = NULL; + FsRtlUninitializeBaseMcb(&(Mcb->BaseMcb)); + } +} + +// MCB /* * @implemented @@ -44,24 +965,6 @@ (LONGLONG)Vbn, (LONGLONG)Lbn, (LONGLONG)SectorCount); -} - -/* - * @unimplemented - */ -BOOLEAN -NTAPI -FsRtlGetNextLargeMcbEntry(IN PLARGE_MCB Mcb, - IN ULONG RunIndex, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn, - OUT PLONGLONG SectorCount) -{ - KeBugCheck(FILE_SYSTEM); - *Vbn = 0; - *Lbn = 0; - *SectorCount= 0; - return FALSE; } /* @@ -98,17 +1001,6 @@ } /* - * @unimplemented - */ -VOID -NTAPI -FsRtlInitializeLargeMcb(IN PLARGE_MCB Mcb, - IN POOL_TYPE PoolType) -{ - KeBugCheck(FILE_SYSTEM); -} - -/* * @implemented */ VOID @@ -119,55 +1011,6 @@ /* Call the newer function */ FsRtlInitializeLargeMcb(&Mcb->DummyFieldThatSizesThisStructureCorrectly, PoolType); -} - -/* - * @unimplemented - */ -BOOLEAN -NTAPI -FsRtlLookupLargeMcbEntry(IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - OUT PLONGLONG Lbn OPTIONAL, - OUT PLONGLONG SectorCountFromLbn OPTIONAL, - OUT PLONGLONG StartingLbn OPTIONAL, - OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, - OUT PULONG Index OPTIONAL) -{ - KeBugCheck(FILE_SYSTEM); - *Lbn = 0; - *SectorCountFromLbn = 0; - return FALSE; -} - -/* - * @unimplemented - */ -BOOLEAN -NTAPI -FsRtlLookupLastLargeMcbEntryAndIndex(IN PLARGE_MCB OpaqueMcb, - OUT PLONGLONG LargeVbn, - OUT PLONGLONG LargeLbn, - OUT PULONG Index) -{ - KeBugCheck(FILE_SYSTEM); - *LargeVbn = 0; - *LargeLbn = 0; - *Index = 0; - return FALSE; -} - -/* - * @unimplemented - */ -BOOLEAN -NTAPI -FsRtlLookupLastLargeMcbEntry(IN PLARGE_MCB Mcb, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn) -{ - KeBugCheck(FILE_SYSTEM); - return(FALSE); } /* @@ -235,41 +1078,11 @@ */ ULONG NTAPI -FsRtlNumberOfRunsInLargeMcb(IN PLARGE_MCB Mcb) -{ - ULONG NumberOfRuns; - - /* Read the number of runs while holding the MCB lock */ - KeAcquireGuardedMutex(Mcb->GuardedMutex); - NumberOfRuns = Mcb->BaseMcb.PairCount; - KeReleaseGuardedMutex(Mcb->GuardedMutex); - - /* Return the count */ - return NumberOfRuns; -} - -/* - * @implemented - */ -ULONG -NTAPI -FsRtlNumberOfRunsInMcb (IN PMCB Mcb) +FsRtlNumberOfRunsInMcb(IN PMCB Mcb) { /* Call the newer function */ return FsRtlNumberOfRunsInLargeMcb( &Mcb->DummyFieldThatSizesThisStructureCorrectly); -} - -/* - * @unimplemented - */ -VOID -NTAPI -FsRtlRemoveLargeMcbEntry(IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG SectorCount) -{ - KeBugCheck(FILE_SYSTEM); } /* @@ -288,47 +1101,12 @@ } /* - * @unimplemented - */ -VOID -NTAPI -FsRtlResetLargeMcb(IN PLARGE_MCB Mcb, - IN BOOLEAN SelfSynchronized) -{ - KeBugCheck(FILE_SYSTEM); -} - -/* - * @unimplemented - */ -BOOLEAN -NTAPI -FsRtlSplitLargeMcb(IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Amount) -{ - KeBugCheck(FILE_SYSTEM); - return FALSE; -} - -/* - * @unimplemented - */ -VOID -NTAPI -FsRtlTruncateLargeMcb(IN PLARGE_MCB Mcb, - IN LONGLONG Vbn) -{ - KeBugCheck(FILE_SYSTEM); -} - -/* - * @implemented - */ -VOID -NTAPI -FsRtlTruncateMcb (IN PMCB Mcb, - IN VBN Vbn) + * @implemented + */ +VOID +NTAPI +FsRtlTruncateMcb(IN PMCB Mcb, + IN VBN Vbn) { /* Call the newer function */ FsRtlTruncateLargeMcb(&Mcb->DummyFieldThatSizesThisStructureCorrectly, @@ -336,16 +1114,6 @@ } /* - * @unimplemented - */ -VOID -NTAPI -FsRtlUninitializeLargeMcb(IN PLARGE_MCB Mcb) -{ - KeBugCheck(FILE_SYSTEM); -} - -/* * @implemented */ VOID
13 years, 10 months
1
0
0
0
[fireball] 50872: [RTL/DPH] - Implement DPH version of ReAllocateHeap. Scenario of falling back to normal heap is stubbed everywhere now. - Fix a bug in POINTER_ADD_BIAS which noone noticed.
by fireball@svn.reactos.org
Author: fireball Date: Wed Feb 23 11:08:37 2011 New Revision: 50872 URL:
http://svn.reactos.org/svn/reactos?rev=50872&view=rev
Log: [RTL/DPH] - Implement DPH version of ReAllocateHeap. Scenario of falling back to normal heap is stubbed everywhere now. - Fix a bug in POINTER_ADD_BIAS which noone noticed. Modified: trunk/reactos/lib/rtl/heap.c trunk/reactos/lib/rtl/heappage.c Modified: trunk/reactos/lib/rtl/heap.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heap.c?rev=50872&r…
============================================================================== --- trunk/reactos/lib/rtl/heap.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/heap.c [iso-8859-1] Wed Feb 23 11:08:37 2011 @@ -1362,12 +1362,11 @@ Heap = RtlpPageHeapCreate(Flags, Addr, TotalSize, CommitSize, Lock, Parameters); if (Heap) return Heap; - //ASSERT(FALSE); - DPRINT1("Enabling page heap failed\n"); - /* Reset a special Parameters == -1 hack */ if ((ULONG_PTR)Parameters == (ULONG_PTR)-1) Parameters = NULL; + else + DPRINT1("Enabling page heap failed\n"); } /* Check validation flags */ Modified: trunk/reactos/lib/rtl/heappage.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heappage.c?rev=508…
============================================================================== --- trunk/reactos/lib/rtl/heappage.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/heappage.c [iso-8859-1] Wed Feb 23 11:08:37 2011 @@ -174,7 +174,7 @@ /* Biased pointer macros */ #define IS_BIASED_POINTER(ptr) ((ULONG_PTR)(ptr) & 1) #define POINTER_REMOVE_BIAS(ptr) ((ULONG_PTR)(ptr) & ~(ULONG_PTR)1) -#define POINTER_ADD_BIAS(ptr) ((ULONG_PTR)(ptr) & 1) +#define POINTER_ADD_BIAS(ptr) ((ULONG_PTR)(ptr) | 1) ULONG RtlpDphBreakOptions = 0;//0xFFFFFFFF; @@ -1896,8 +1896,167 @@ PVOID Ptr, SIZE_T Size) { - UNIMPLEMENTED; - return NULL; + PDPH_HEAP_ROOT DphRoot; + PDPH_HEAP_BLOCK Node = NULL, AllocatedNode; + BOOLEAN Biased = FALSE, UseNormalHeap = FALSE, OldBlockPageHeap = TRUE; + ULONG DataSize, ValidationInfo; + PVOID NewAlloc = NULL; + + /* Check requested size */ + if (Size > 0x7FF00000) + { + DPRINT1("extreme size request\n"); + + /* Generate an exception if needed */ + if (Flags & HEAP_GENERATE_EXCEPTIONS) RtlpDphRaiseException(STATUS_NO_MEMORY); + + return NULL; + } + + /* Unbias the pointer if necessary */ + if (IS_BIASED_POINTER(HeapPtr)) + { + HeapPtr = (PVOID)POINTER_REMOVE_BIAS(HeapPtr); + Biased = TRUE; + } + + /* Get a pointer to the heap root */ + DphRoot = RtlpDphPointerFromHandle(HeapPtr); + if (!DphRoot) return NULL; + + /* Acquire the heap lock */ + RtlpDphPreProcessing(DphRoot, Flags); + + /* Perform internal validation if specified by flags */ + if (RtlpDphDebugOptions & DPH_DEBUG_INTERNAL_VALIDATE) + { + RtlpDphInternalValidatePageHeap(DphRoot, NULL, 0); + } + + /* Add heap flags */ + Flags |= DphRoot->HeapFlags; + + /* Exit with NULL right away if inplace is specified */ + if (Flags & HEAP_REALLOC_IN_PLACE_ONLY) + { + /* Release the lock */ + RtlpDphPostProcessing(DphRoot); + + /* Generate an exception if needed */ + if (Flags & HEAP_GENERATE_EXCEPTIONS) RtlpDphRaiseException(STATUS_NO_MEMORY); + + return NULL; + } + + /* Try to get node of the allocated block */ + AllocatedNode = RtlpDphFindBusyMemory(DphRoot, Ptr); + + if (!AllocatedNode) + { + /* This block was not found in page heap, try a normal heap instead */ + //RtlpDphNormalHeapFree(); + ASSERT(FALSE); + OldBlockPageHeap = FALSE; + } + + /* Check the block */ + if (!(DphRoot->ExtraFlags & DPH_EXTRA_CHECK_UNDERRUN)) + { + if (!RtlpDphIsPageHeapBlock(DphRoot, AllocatedNode->pUserAllocation, &ValidationInfo, TRUE)) + { + RtlpDphReportCorruptedBlock(DphRoot, 3, AllocatedNode->pUserAllocation, ValidationInfo); + } + } + + /* Remove old one from the busy list */ + RtlpDphRemoveFromBusyList(DphRoot, AllocatedNode); + + if (!Biased && !RtlpDphShouldAllocateInPageHeap(DphRoot, Size)) + { + // FIXME: Use normal heap + ASSERT(FALSE); + UseNormalHeap = TRUE; + } + else + { + /* Now do a trick: bias the pointer and call our allocate routine */ + NewAlloc = RtlpPageHeapAllocate((PVOID)POINTER_ADD_BIAS(HeapPtr), Flags, Size); + } + + if (!NewAlloc) + { + /* New allocation failed, put the block back (if it was found in page heap) */ + RtlpDphPlaceOnBusyList(DphRoot, AllocatedNode); + + /* Release the lock */ + RtlpDphPostProcessing(DphRoot); + + /* Perform validation again if required */ + if (RtlpDphDebugOptions & DPH_DEBUG_INTERNAL_VALIDATE) + { + RtlpDphInternalValidatePageHeap(DphRoot, NULL, 0); + } + + /* Generate an exception if needed */ + if (Flags & HEAP_GENERATE_EXCEPTIONS) RtlpDphRaiseException(STATUS_NO_MEMORY); + + return NULL; + } + + /* Copy contents of the old block */ + if (AllocatedNode->nUserRequestedSize > Size) + DataSize = Size; + else + DataSize = AllocatedNode->nUserRequestedSize; + + if (DataSize != 0) RtlCopyMemory(NewAlloc, Ptr, DataSize); + + /* Copy user flags and values */ + if (!UseNormalHeap) + { + /* Get the node of the new block */ + Node = RtlpDphFindBusyMemory(DphRoot, NewAlloc); + ASSERT(Node != NULL); + + /* Set its values/flags */ + Node->UserValue = AllocatedNode->UserValue; + if (Flags & HEAP_SETTABLE_USER_FLAGS) + Node->UserFlags = Flags & HEAP_SETTABLE_USER_FLAGS; + else + Node->UserFlags = AllocatedNode->UserFlags; + } + + if (!OldBlockPageHeap) + { + /* Weird scenario, investigate */ + ASSERT(FALSE); + } + + /* Mark the old block as no access */ + if (AllocatedNode->nVirtualAccessSize != 0) + { + RtlpDphProtectVm(AllocatedNode->pVirtualBlock, AllocatedNode->nVirtualAccessSize, PAGE_NOACCESS); + } + + /* And place it on the free list */ + RtlpDphPlaceOnFreeList(DphRoot, AllocatedNode); + + // FIXME: Capture stack traces if needed + AllocatedNode->StackTrace = NULL; + + /* Finally allocation is done, perform validation again if required */ + if (RtlpDphDebugOptions & DPH_DEBUG_INTERNAL_VALIDATE && !Biased) + { + RtlpDphInternalValidatePageHeap(DphRoot, NULL, 0); + } + + /* Release the lock */ + RtlpDphPostProcessing(DphRoot); + + DPRINT("Allocated new user block pointer: %p\n", NewAlloc); + + /* Return pointer to user allocation */ + return NewAlloc; } BOOLEAN NTAPI
13 years, 10 months
1
0
0
0
[janderwald] 50871: [MPLAY32] - Hackfix playback See issue #5867 for more details.
by janderwald@svn.reactos.org
Author: janderwald Date: Wed Feb 23 10:32:56 2011 New Revision: 50871 URL:
http://svn.reactos.org/svn/reactos?rev=50871&view=rev
Log: [MPLAY32] - Hackfix playback See issue #5867 for more details. Modified: trunk/reactos/base/applications/mplay32/mplay32.c Modified: trunk/reactos/base/applications/mplay32/mplay32.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mplay32/…
============================================================================== --- trunk/reactos/base/applications/mplay32/mplay32.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/mplay32/mplay32.c [iso-8859-1] Wed Feb 23 10:32:56 2011 @@ -455,7 +455,7 @@ mciPlay.dwFrom = 0; mciPlay.dwTo = MaxFilePos; - mciError = mciSendCommand(wDeviceId, MCI_PLAY, MCI_NOTIFY | MCI_FROM | MCI_TO, (DWORD_PTR)&mciPlay); + mciError = mciSendCommand(wDeviceId, MCI_PLAY, MCI_NOTIFY | MCI_FROM /*| MCI_TO*/, (DWORD_PTR)&mciPlay); if (mciError != 0) { MessageBox(hwnd, _T("Can't play!"), NULL, MB_OK);
13 years, 10 months
1
0
0
0
[pschweitzer] 50870: [KMTEST] Adding more tests for FsRtlIs*InExpression() functions. All are failing (overrun / wrong result). Based on Thomas Faber's C program. See bug #5923
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Wed Feb 23 10:20:23 2011 New Revision: 50870 URL:
http://svn.reactos.org/svn/reactos?rev=50870&view=rev
Log: [KMTEST] Adding more tests for FsRtlIs*InExpression() functions. All are failing (overrun / wrong result). Based on Thomas Faber's C program. See bug #5923 Modified: trunk/rostests/drivers/kmtest/ntos_fsrtl.c Modified: trunk/rostests/drivers/kmtest/ntos_fsrtl.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/drivers/kmtest/ntos_fsrtl…
============================================================================== --- trunk/rostests/drivers/kmtest/ntos_fsrtl.c [iso-8859-1] (original) +++ trunk/rostests/drivers/kmtest/ntos_fsrtl.c [iso-8859-1] Wed Feb 23 10:20:23 2011 @@ -161,6 +161,22 @@ ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); RtlInitUnicodeString(&Name, L"aaaa"); ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); + + /* Tests from #5923 */ + RtlInitUnicodeString(&Expression, L"C:\\ReactOS\\**"); + RtlInitUnicodeString(&Name, L"C:\\ReactOS\\dings.bmp"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); + RtlInitUnicodeString(&Expression, L"C:\\ReactOS\\***"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == TRUE, "expected TRUE, got FALSE"); + RtlInitUnicodeString(&Expression, L"C:\\Windows\\*a*"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + + RtlInitUnicodeString(&Expression, L"C:\\ReactOS\\*.bmp"); + RtlInitUnicodeString(&Name, L"C:\\Windows\\explorer.exe"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); + RtlInitUnicodeString(&Expression, L"*.bmp;*.dib"); + RtlInitUnicodeString(&Name, L"winhlp32.exe"); + ok(FsRtlIsNameInExpression(&Expression, &Name, FALSE, NULL) == FALSE, "expected FALSE, got TRUE"); } VOID FsRtlIsDbcsInExpressionTest() @@ -295,6 +311,22 @@ ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); RtlInitAnsiString(&Name, "aaaa"); ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); + + /* Tests from #5923 */ + RtlInitAnsiString(&Expression, "C:\\ReactOS\\**"); + RtlInitAnsiString(&Name, "C:\\ReactOS\\dings.bmp"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); + RtlInitAnsiString(&Expression, "C:\\ReactOS\\***"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == TRUE, "expected TRUE, got FALSE"); + RtlInitAnsiString(&Expression, "C:\\Windows\\*a*"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + + RtlInitAnsiString(&Expression, "C:\\ReactOS\\*.bmp"); + RtlInitAnsiString(&Name, "C:\\Windows\\explorer.exe"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); + RtlInitAnsiString(&Expression, "*.bmp;*.dib"); + RtlInitAnsiString(&Name, "winhlp32.exe"); + ok(FsRtlIsDbcsInExpression(&Expression, &Name) == FALSE, "expected FALSE, got TRUE"); } /* PUBLIC FUNCTIONS ***********************************************************/
13 years, 10 months
1
0
0
0
[pschweitzer] 50869: [KERNEL32] Don't make CopyFileExA() rely on Wine's strings conversions functions
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Tue Feb 22 19:07:45 2011 New Revision: 50869 URL:
http://svn.reactos.org/svn/reactos?rev=50869&view=rev
Log: [KERNEL32] Don't make CopyFileExA() rely on Wine's strings conversions functions Modified: trunk/reactos/dll/win32/kernel32/file/copy.c Modified: trunk/reactos/dll/win32/kernel32/file/copy.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/co…
============================================================================== --- trunk/reactos/dll/win32/kernel32/file/copy.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/file/copy.c [iso-8859-1] Tue Feb 22 19:07:45 2011 @@ -314,37 +314,36 @@ */ BOOL WINAPI -CopyFileExA ( - LPCSTR lpExistingFileName, - LPCSTR lpNewFileName, - LPPROGRESS_ROUTINE lpProgressRoutine, - LPVOID lpData, - BOOL *pbCancel, - DWORD dwCopyFlags - ) -{ - PWCHAR ExistingFileNameW; - PWCHAR NewFileNameW; - BOOL Result; - - if (!(ExistingFileNameW = FilenameA2W(lpExistingFileName, FALSE))) - return FALSE; - - if (!(NewFileNameW = FilenameA2W(lpNewFileName, TRUE))) - return FALSE; - - Result = CopyFileExW (ExistingFileNameW , - NewFileNameW , - lpProgressRoutine, - lpData, - pbCancel, - dwCopyFlags); - - RtlFreeHeap (RtlGetProcessHeap (), - 0, - NewFileNameW); - - return Result; +CopyFileExA(IN LPCSTR lpExistingFileName, + IN LPCSTR lpNewFileName, + IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL, + IN LPVOID lpData OPTIONAL, + IN LPBOOL pbCancel OPTIONAL, + IN DWORD dwCopyFlags) +{ + BOOL Result = FALSE; + UNICODE_STRING lpNewFileNameW; + PUNICODE_STRING lpExistingFileNameW; + + lpExistingFileNameW = Basep8BitStringToStaticUnicodeString(lpExistingFileName); + if (!lpExistingFileName) + { + return FALSE; + } + + if (Basep8BitStringToDynamicUnicodeString(&lpNewFileNameW, lpNewFileName)) + { + Result = CopyFileExW(lpExistingFileNameW->Buffer, + lpNewFileNameW.Buffer, + lpProgressRoutine, + lpData, + pbCancel, + dwCopyFlags); + + RtlFreeUnicodeString(&lpNewFileNameW); + } + + return Result; }
13 years, 10 months
1
0
0
0
[pschweitzer] 50868: [KERNEL32] Don't make FindFirstChangeNotificationA() rely on Wine's strings conversions functions
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Tue Feb 22 18:56:46 2011 New Revision: 50868 URL:
http://svn.reactos.org/svn/reactos?rev=50868&view=rev
Log: [KERNEL32] Don't make FindFirstChangeNotificationA() rely on Wine's strings conversions functions Modified: trunk/reactos/dll/win32/kernel32/file/cnotify.c Modified: trunk/reactos/dll/win32/kernel32/file/cnotify.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/cn…
============================================================================== --- trunk/reactos/dll/win32/kernel32/file/cnotify.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/file/cnotify.c [iso-8859-1] Tue Feb 22 18:56:46 2011 @@ -9,10 +9,14 @@ * Created 01/11/98 */ +/* INCLUDES *****************************************************************/ + #include <k32.h> #define NDEBUG #include <debug.h> +/* FUNCTIONS ****************************************************************/ + /* * @implemented */ @@ -35,20 +39,30 @@ */ HANDLE WINAPI -FindFirstChangeNotificationA ( - LPCSTR lpPathName, - BOOL bWatchSubtree, - DWORD dwNotifyFilter - ) -{ - PWCHAR PathNameW; - - if (!(PathNameW = FilenameA2W(lpPathName, FALSE))) - return INVALID_HANDLE_VALUE; - - return FindFirstChangeNotificationW (PathNameW , - bWatchSubtree, - dwNotifyFilter); +FindFirstChangeNotificationA(IN LPCSTR lpPathName, + IN BOOL bWatchSubtree, + IN DWORD dwNotifyFilter) +{ + NTSTATUS Status; + ANSI_STRING PathNameString; + + RtlInitAnsiString(&PathNameString, lpPathName); + Status = RtlAnsiStringToUnicodeString(&(NtCurrentTeb()->StaticUnicodeString), &PathNameString, FALSE); + if (!NT_SUCCESS(Status)) + { + if (Status != STATUS_BUFFER_OVERFLOW) + { + SetLastError(ERROR_FILENAME_EXCED_RANGE); + } + else + { + BaseSetLastNTError(Status); + } + return INVALID_HANDLE_VALUE; + } + + return FindFirstChangeNotificationW(NtCurrentTeb()->StaticUnicodeString.Buffer, + bWatchSubtree, dwNotifyFilter); }
13 years, 10 months
1
0
0
0
[pschweitzer] 50867: [KERNEL32] Don't make GetBinaryTypeA() rely on Wine's strings conversions functions
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Tue Feb 22 18:43:38 2011 New Revision: 50867 URL:
http://svn.reactos.org/svn/reactos?rev=50867&view=rev
Log: [KERNEL32] Don't make GetBinaryTypeA() rely on Wine's strings conversions functions Modified: trunk/reactos/dll/win32/kernel32/file/bintype.c Modified: trunk/reactos/dll/win32/kernel32/file/bintype.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/bi…
============================================================================== --- trunk/reactos/dll/win32/kernel32/file/bintype.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/file/bintype.c [iso-8859-1] Tue Feb 22 18:43:38 2011 @@ -301,23 +301,43 @@ */ BOOL WINAPI -GetBinaryTypeA ( - LPCSTR lpApplicationName, - LPDWORD lpBinaryType - ) +GetBinaryTypeA(IN LPCSTR lpApplicationName, + OUT LPDWORD lpBinaryType) { - PWCHAR ApplicationNameW; - - if(!lpApplicationName || !lpBinaryType) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - if (!(ApplicationNameW = FilenameA2W(lpApplicationName, FALSE))) - return FALSE; - - return GetBinaryTypeW(ApplicationNameW, lpBinaryType); + ANSI_STRING ApplicationNameString; + UNICODE_STRING ApplicationNameW; + BOOL StringAllocated = FALSE, Result; + NTSTATUS Status; + + RtlInitAnsiString(&ApplicationNameString, lpApplicationName); + + if (ApplicationNameString.Length * sizeof(WCHAR) >= NtCurrentTeb()->StaticUnicodeString.MaximumLength) + { + StringAllocated = TRUE; + Status = RtlAnsiStringToUnicodeString(&ApplicationNameW, &ApplicationNameString, TRUE); + } + else + { + Status = RtlAnsiStringToUnicodeString(&(NtCurrentTeb()->StaticUnicodeString), &ApplicationNameString, FALSE); + } + + if (!NT_SUCCESS(Status)) + { + BaseSetLastNTError(Status); + return FALSE; + } + + if (StringAllocated) + { + Result = GetBinaryTypeW(ApplicationNameW.Buffer, lpBinaryType); + RtlFreeUnicodeString(&ApplicationNameW); + } + else + { + Result = GetBinaryTypeW(NtCurrentTeb()->StaticUnicodeString.Buffer, lpBinaryType); + } + + return Result; } /* EOF */
13 years, 10 months
1
0
0
0
← Newer
1
...
4
5
6
7
8
9
10
...
36
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
Results per page:
10
25
50
100
200