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
October 2018
----- 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
21 participants
354 discussions
Start a n
N
ew thread
01/09: [CMLIB] Adjust parameter types and annotations. Add diagnostic assertions.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bf8a7d2db000cd54c92f2…
commit bf8a7d2db000cd54c92f25ad6b0329659c7bd93f Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sun Oct 14 00:16:04 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Oct 14 15:59:31 2018 +0200 [CMLIB] Adjust parameter types and annotations. Add diagnostic assertions. --- sdk/lib/cmlib/cmlib.h | 6 +++--- sdk/lib/cmlib/cmname.c | 2 +- sdk/lib/cmlib/cmvalue.c | 9 ++++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/sdk/lib/cmlib/cmlib.h b/sdk/lib/cmlib/cmlib.h index 46676a2122..b9431c750b 100644 --- a/sdk/lib/cmlib/cmlib.h +++ b/sdk/lib/cmlib/cmlib.h @@ -595,7 +595,7 @@ CmpFindNameInList( IN PHHIVE Hive, IN PCHILD_LIST ChildList, IN PUNICODE_STRING Name, - OUT PULONG ChildIndex, + OUT PULONG ChildIndex OPTIONAL, OUT PHCELL_INDEX CellIndex ); @@ -625,7 +625,7 @@ CmpSetValueDataNew( IN PHHIVE Hive, IN PVOID Data, IN ULONG DataSize, - IN ULONG StorageType, + IN HSTORAGE_TYPE StorageType, IN HCELL_INDEX ValueCell, OUT PHCELL_INDEX DataCell ); @@ -636,7 +636,7 @@ CmpAddValueToList( IN PHHIVE Hive, IN HCELL_INDEX ValueCell, IN ULONG Index, - IN ULONG Type, + IN HSTORAGE_TYPE StorageType, IN OUT PCHILD_LIST ChildList ); diff --git a/sdk/lib/cmlib/cmname.c b/sdk/lib/cmlib/cmname.c index 918cbb282d..b12374023c 100644 --- a/sdk/lib/cmlib/cmname.c +++ b/sdk/lib/cmlib/cmname.c @@ -149,7 +149,7 @@ NTAPI CmpFindNameInList(IN PHHIVE Hive, IN PCHILD_LIST ChildList, IN PUNICODE_STRING Name, - OUT PULONG ChildIndex, + OUT PULONG ChildIndex OPTIONAL, OUT PHCELL_INDEX CellIndex) { PCELL_DATA CellData; diff --git a/sdk/lib/cmlib/cmvalue.c b/sdk/lib/cmlib/cmvalue.c index a038c776f3..86344a7707 100644 --- a/sdk/lib/cmlib/cmvalue.c +++ b/sdk/lib/cmlib/cmvalue.c @@ -207,7 +207,7 @@ NTAPI CmpAddValueToList(IN PHHIVE Hive, IN HCELL_INDEX ValueCell, IN ULONG Index, - IN ULONG Type, + IN HSTORAGE_TYPE StorageType, IN OUT PCHILD_LIST ChildList) { HCELL_INDEX ListCell; @@ -223,6 +223,8 @@ CmpAddValueToList(IN PHHIVE Hive, ChildCount++; if (ChildCount > 1) { + ASSERT(ChildList->List != HCELL_NIL); + /* The cell should be dirty at this point */ ASSERT(HvIsCellDirty(Hive, ChildList->List)); @@ -249,7 +251,8 @@ CmpAddValueToList(IN PHHIVE Hive, else { /* This is our first child, so allocate a single cell */ - ListCell = HvAllocateCell(Hive, sizeof(HCELL_INDEX), Type, HCELL_NIL); + ASSERT(ChildList->List == HCELL_NIL); + ListCell = HvAllocateCell(Hive, sizeof(HCELL_INDEX), StorageType, HCELL_NIL); } /* Fail if we couldn't get a cell */ @@ -286,7 +289,7 @@ NTAPI CmpSetValueDataNew(IN PHHIVE Hive, IN PVOID Data, IN ULONG DataSize, - IN ULONG StorageType, + IN HSTORAGE_TYPE StorageType, IN HCELL_INDEX ValueCell, OUT PHCELL_INDEX DataCell) {
6 years, 2 months
1
0
0
0
01/01: [FONT][WIN32SS] Use ExFreePoolWithTag instead of ExFreePool (#941)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=801b71b9bfbcb23daf59d…
commit 801b71b9bfbcb23daf59da30f2e399193bd6ce28 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Sun Oct 14 16:47:52 2018 +0900 Commit: Thomas Faber <18138474+ThFabba(a)users.noreply.github.com> CommitDate: Sun Oct 14 09:47:52 2018 +0200 [FONT][WIN32SS] Use ExFreePoolWithTag instead of ExFreePool (#941) --- win32ss/gdi/ntgdi/freetype.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win32ss/gdi/ntgdi/freetype.c b/win32ss/gdi/ntgdi/freetype.c index 7bacfb66ec..10fb8655d7 100644 --- a/win32ss/gdi/ntgdi/freetype.c +++ b/win32ss/gdi/ntgdi/freetype.c @@ -5150,7 +5150,7 @@ IntGdiGetFontResourceInfo( /* Free the buffers */ ExFreePoolWithTag(NameInfo1, TAG_FINF); - ExFreePool(NameInfo2); + ExFreePoolWithTag(NameInfo2, TAG_FINF); if (Count == 0 && dwType != 5) {
6 years, 2 months
1
0
0
0
02/02: [NTOSKRNL] Add the CcPinMappedDataCount counter
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3d13a464f7b12534f3200…
commit 3d13a464f7b12534f32008f8c6eb3509cc1e456b Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Sat Oct 13 22:50:49 2018 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Sat Oct 13 22:51:44 2018 +0200 [NTOSKRNL] Add the CcPinMappedDataCount counter --- ntoskrnl/cc/pin.c | 4 ++++ ntoskrnl/ex/sysinfo.c | 2 +- ntoskrnl/include/internal/cc.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ntoskrnl/cc/pin.c b/ntoskrnl/cc/pin.c index 37eca96de1..4f0e4f5a82 100644 --- a/ntoskrnl/cc/pin.c +++ b/ntoskrnl/cc/pin.c @@ -23,11 +23,13 @@ extern NPAGED_LOOKASIDE_LIST iBcbLookasideList; * - Number of calls to CcMapData that couldn't wait * - Number of calls to CcPinRead that could wait * - Number of calls to CcPinRead that couldn't wait + * - Number of calls to CcPinMappedDataCount */ ULONG CcMapDataWait = 0; ULONG CcMapDataNoWait = 0; ULONG CcPinReadWait = 0; ULONG CcPinReadNoWait = 0; +ULONG CcPinMappedDataCount = 0; /* FUNCTIONS *****************************************************************/ @@ -429,6 +431,8 @@ CcPinMappedData ( iBcb = *Bcb; + ++CcPinMappedDataCount; + Result = CcpPinData(SharedCacheMap, FileOffset, Length, Flags, Bcb, &Buffer); if (Result) { diff --git a/ntoskrnl/ex/sysinfo.c b/ntoskrnl/ex/sysinfo.c index ab8481b328..09b9a6359c 100644 --- a/ntoskrnl/ex/sysinfo.c +++ b/ntoskrnl/ex/sysinfo.c @@ -767,7 +767,7 @@ QSI_DEF(SystemPerformanceInformation) Spi->CcMapDataNoWaitMiss = 0; /* FIXME */ Spi->CcMapDataWaitMiss = 0; /* FIXME */ - Spi->CcPinMappedDataCount = 0; /* FIXME */ + Spi->CcPinMappedDataCount = CcPinMappedDataCount; Spi->CcPinReadNoWait = CcPinReadNoWait; Spi->CcPinReadWait = CcPinReadWait; Spi->CcPinReadNoWaitMiss = 0; /* FIXME */ diff --git a/ntoskrnl/include/internal/cc.h b/ntoskrnl/include/internal/cc.h index 16dd1f67f0..8a5fb73838 100644 --- a/ntoskrnl/include/internal/cc.h +++ b/ntoskrnl/include/internal/cc.h @@ -62,6 +62,7 @@ extern ULONG CcMapDataWait; extern ULONG CcMapDataNoWait; extern ULONG CcPinReadWait; extern ULONG CcPinReadNoWait; +extern ULONG CcPinMappedDataCount; extern ULONG CcDataPages; extern ULONG CcDataFlushes;
6 years, 2 months
1
0
0
0
01/02: [NTOSKRNL] Rewrite the way we create BCB for pinning
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1afcbbd12539577fb7bb6…
commit 1afcbbd12539577fb7bb6df61378d8dd12a4f727 Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Sat Oct 13 22:46:10 2018 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Sat Oct 13 22:51:44 2018 +0200 [NTOSKRNL] Rewrite the way we create BCB for pinning We won't reuse a BCB created for mapping, we will now have our own dedicated BCB. This allows having a bit more cleaner implementation of CcPinMappedData() --- ntoskrnl/cc/pin.c | 306 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 170 insertions(+), 136 deletions(-) diff --git a/ntoskrnl/cc/pin.c b/ntoskrnl/cc/pin.c index b3906a9321..37eca96de1 100644 --- a/ntoskrnl/cc/pin.c +++ b/ntoskrnl/cc/pin.c @@ -73,17 +73,14 @@ CcpMapData( IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, - IN BOOLEAN ToPin, - OUT PVOID *pBcb, + OUT PROS_VACB *pVacb, OUT PVOID *pBuffer) { LONGLONG ReadOffset; BOOLEAN Valid; PROS_VACB Vacb; NTSTATUS Status; - PINTERNAL_BCB iBcb, DupBcb; LONGLONG ROffset; - KIRQL OldIrql; ReadOffset = FileOffset->QuadPart; @@ -146,14 +143,30 @@ CcpMapData( } *pBuffer = (PUCHAR)*pBuffer + ReadOffset % VACB_MAPPING_GRANULARITY; + *pVacb = Vacb; + + return TRUE; +} + +static +PVOID +CcpGetAppropriateBcb( + IN PROS_SHARED_CACHE_MAP SharedCacheMap, + IN PROS_VACB Vacb, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG PinFlags, + IN BOOLEAN ToPin) +{ + KIRQL OldIrql; + BOOLEAN Result; + PINTERNAL_BCB iBcb, DupBcb; + iBcb = ExAllocateFromNPagedLookasideList(&iBcbLookasideList); if (iBcb == NULL) { CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE); - CCTRACE(CC_API_DEBUG, "FileObject=%p FileOffset=%p Length=%lu Flags=0x%lx -> FALSE\n", - SharedCacheMap->FileObject, FileOffset, Length, Flags); - ExRaiseStatus(STATUS_INSUFFICIENT_RESOURCES); - return FALSE; + return NULL; } RtlZeroMemory(iBcb, sizeof(*iBcb)); @@ -166,44 +179,147 @@ CcpMapData( iBcb->PinCount = 0; iBcb->RefCount = 1; ExInitializeResourceLite(&iBcb->Lock); - *pBcb = (PVOID)iBcb; - /* Only insert if we're not to pin data */ - if (!ToPin) + KeAcquireSpinLock(&SharedCacheMap->BcbSpinLock, &OldIrql); + + /* Check if we raced with another BCB creation */ + DupBcb = CcpFindBcb(SharedCacheMap, FileOffset, Length, ToPin); + /* Yes, and we've lost */ + if (DupBcb != NULL) { - KeAcquireSpinLock(&SharedCacheMap->BcbSpinLock, &OldIrql); + Result = TRUE; + + if (ToPin) + { + DupBcb->PinCount++; + + if (BooleanFlagOn(PinFlags, PIN_EXCLUSIVE)) + { + Result = ExAcquireResourceExclusiveLite(&iBcb->Lock, BooleanFlagOn(PinFlags, PIN_WAIT)); + } + else + { + Result = ExAcquireSharedStarveExclusive(&iBcb->Lock, BooleanFlagOn(PinFlags, PIN_WAIT)); + } + + if (!Result) + { + DupBcb->PinCount--; + DupBcb = NULL; + } + } - /* Check if we raced with another BCB creation */ - DupBcb = CcpFindBcb(SharedCacheMap, FileOffset, Length, FALSE); - /* Yes, and we've lost */ - if (DupBcb != NULL) + if (Result) { /* We'll return that BCB */ ++DupBcb->RefCount; + } - /* Delete the loser */ - CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE); - ExDeleteResourceLite(&iBcb->Lock); - ExFreeToNPagedLookasideList(&iBcbLookasideList, iBcb); + /* Delete the loser */ + CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE); + ExDeleteResourceLite(&iBcb->Lock); + ExFreeToNPagedLookasideList(&iBcbLookasideList, iBcb); - /* Return the winner - no need to update buffer address, it's - * relative to the VACB, which is unchanged. - */ - *pBcb = DupBcb; + /* Return the winner - no need to update buffer address, it's + * relative to the VACB, which is unchanged. + */ + iBcb = DupBcb; + } + /* Nope, insert ourselves */ + else + { + if (ToPin) + { + iBcb->PinCount++; + + if (BooleanFlagOn(PinFlags, PIN_EXCLUSIVE)) + { + Result = ExAcquireResourceExclusiveLite(&iBcb->Lock, BooleanFlagOn(PinFlags, PIN_WAIT)); + } + else + { + Result = ExAcquireSharedStarveExclusive(&iBcb->Lock, BooleanFlagOn(PinFlags, PIN_WAIT)); + } + + ASSERT(Result); + } + + InsertTailList(&SharedCacheMap->BcbList, &iBcb->BcbEntry); + } + KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql); + + return iBcb; +} + +static +BOOLEAN +CcpPinData( + IN PROS_SHARED_CACHE_MAP SharedCacheMap, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG Flags, + OUT PVOID * Bcb, + OUT PVOID * Buffer) +{ + PINTERNAL_BCB NewBcb; + BOOLEAN Result; + PROS_VACB Vacb; + KIRQL OldIrql; + + KeAcquireSpinLock(&SharedCacheMap->BcbSpinLock, &OldIrql); + NewBcb = CcpFindBcb(SharedCacheMap, FileOffset, Length, TRUE); + KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql); + + if (NewBcb != NULL) + { + NewBcb->PinCount++; + + if (BooleanFlagOn(Flags, PIN_EXCLUSIVE)) + { + Result = ExAcquireResourceExclusiveLite(&NewBcb->Lock, BooleanFlagOn(Flags, PIN_WAIT)); } - /* Nope, insert ourselves */ else { - InsertTailList(&SharedCacheMap->BcbList, &iBcb->BcbEntry); + Result = ExAcquireSharedStarveExclusive(&NewBcb->Lock, BooleanFlagOn(Flags, PIN_WAIT)); } - KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql); + + if (!Result) + { + NewBcb->PinCount--; + } + else + { + NewBcb->RefCount++; + *Bcb = NewBcb; + *Buffer = (PUCHAR)NewBcb->Vacb->BaseAddress + FileOffset->QuadPart % VACB_MAPPING_GRANULARITY; + } + + return Result; } else { - InitializeListHead(&iBcb->BcbEntry); + if (BooleanFlagOn(Flags, PIN_IF_BCB)) + { + return FALSE; + } + + Result = CcpMapData(SharedCacheMap, FileOffset, Length, Flags, &Vacb, Buffer); + if (Result) + { + NewBcb = CcpGetAppropriateBcb(SharedCacheMap, Vacb, FileOffset, Length, Flags, TRUE); + if (NewBcb == NULL) + { + CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE); + Result = FALSE; + } + else + { + *Bcb = NewBcb; + } + } } - return TRUE; + return Result; } /* @@ -222,6 +338,7 @@ CcMapData ( BOOLEAN Ret; KIRQL OldIrql; PINTERNAL_BCB iBcb; + PROS_VACB Vacb; PROS_SHARED_CACHE_MAP SharedCacheMap; DPRINT("CcMapData(FileObject 0x%p, FileOffset %I64x, Length %lu, Flags 0x%lx," @@ -250,7 +367,20 @@ CcMapData ( if (iBcb == NULL) { - Ret = CcpMapData(SharedCacheMap, FileOffset, Length, Flags, FALSE, pBcb, pBuffer); + Ret = CcpMapData(SharedCacheMap, FileOffset, Length, Flags, &Vacb, pBuffer); + if (Ret) + { + iBcb = CcpGetAppropriateBcb(SharedCacheMap, Vacb, FileOffset, Length, 0, FALSE); + if (iBcb == NULL) + { + CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE); + Ret = FALSE; + } + else + { + *pBcb = iBcb; + } + } } else { @@ -278,6 +408,7 @@ CcPinMappedData ( OUT PVOID * Bcb) { BOOLEAN Result; + PVOID Buffer; PINTERNAL_BCB iBcb; PROS_SHARED_CACHE_MAP SharedCacheMap; @@ -297,22 +428,11 @@ CcPinMappedData ( } iBcb = *Bcb; - ASSERT(iBcb->PinCount == 0); - - iBcb->PinCount++; - - if (BooleanFlagOn(Flags, PIN_EXCLUSIVE)) - { - Result = ExAcquireResourceExclusiveLite(&iBcb->Lock, BooleanFlagOn(Flags, PIN_WAIT)); - } - else - { - Result = ExAcquireSharedStarveExclusive(&iBcb->Lock, BooleanFlagOn(Flags, PIN_WAIT)); - } - if (!Result) + Result = CcpPinData(SharedCacheMap, FileOffset, Length, Flags, Bcb, &Buffer); + if (Result) { - iBcb->PinCount--; + CcUnpinData(iBcb); } return Result; @@ -331,9 +451,6 @@ CcPinRead ( OUT PVOID * Bcb, OUT PVOID * Buffer) { - KIRQL OldIrql; - BOOLEAN Result; - PINTERNAL_BCB iBcb; PROS_SHARED_CACHE_MAP SharedCacheMap; CCTRACE(CC_API_DEBUG, "FileOffset=%p FileOffset=%p Length=%lu Flags=0x%lx\n", @@ -345,6 +462,11 @@ CcPinRead ( SharedCacheMap = FileObject->SectionObjectPointer->SharedCacheMap; ASSERT(SharedCacheMap); + if (!SharedCacheMap->PinAccess) + { + DPRINT1("FIXME: Pinning a file with no pin access!\n"); + return FALSE; + } if (Flags & PIN_WAIT) { @@ -355,95 +477,7 @@ CcPinRead ( ++CcPinReadNoWait; } - KeAcquireSpinLock(&SharedCacheMap->BcbSpinLock, &OldIrql); - iBcb = CcpFindBcb(SharedCacheMap, FileOffset, Length, TRUE); - KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql); - - if (iBcb == NULL) - { - /* We failed to find an already existing BCB */ - if (BooleanFlagOn(Flags, PIN_IF_BCB)) - { - return FALSE; - } - - /* Map first */ - if (!CcpMapData(SharedCacheMap, FileOffset, Length, Flags, TRUE, Bcb, Buffer)) - { - return FALSE; - } - - /* Pin then */ - if (!CcPinMappedData(FileObject, FileOffset, Length, Flags, Bcb)) - { - CcUnpinData(*Bcb); - return FALSE; - } - - /* Did we race for the BCB creation? */ - KeAcquireSpinLock(&SharedCacheMap->BcbSpinLock, &OldIrql); - iBcb = CcpFindBcb(SharedCacheMap, FileOffset, Length, TRUE); - if (iBcb != NULL) - { - KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql); - - /* Free our now unused BCB */ - CcUnpinData(*Bcb); - - /* Lock the found BCB and return it */ - if (BooleanFlagOn(Flags, PIN_EXCLUSIVE)) - { - Result = ExAcquireResourceExclusiveLite(&iBcb->Lock, BooleanFlagOn(Flags, PIN_WAIT)); - } - else - { - Result = ExAcquireSharedStarveExclusive(&iBcb->Lock, BooleanFlagOn(Flags, PIN_WAIT)); - } - - if (!Result) - { - return FALSE; - } - - ++iBcb->PinCount; - ++iBcb->RefCount; - - *Bcb = iBcb; - } - else - { - iBcb = *Bcb; - - /* Insert ourselves in the linked list */ - InsertTailList(&SharedCacheMap->BcbList, &iBcb->BcbEntry); - KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql); - } - } - /* We found a BCB, lock it and return it */ - else - { - if (BooleanFlagOn(Flags, PIN_EXCLUSIVE)) - { - Result = ExAcquireResourceExclusiveLite(&iBcb->Lock, BooleanFlagOn(Flags, PIN_WAIT)); - } - else - { - Result = ExAcquireSharedStarveExclusive(&iBcb->Lock, BooleanFlagOn(Flags, PIN_WAIT)); - } - - if (!Result) - { - return FALSE; - } - - ++iBcb->PinCount; - ++iBcb->RefCount; - - *Bcb = iBcb; - *Buffer = (PUCHAR)iBcb->Vacb->BaseAddress + FileOffset->QuadPart % VACB_MAPPING_GRANULARITY; - } - - return TRUE; + return CcpPinData(SharedCacheMap, FileOffset, Length, Flags, Bcb, Buffer); } /*
6 years, 2 months
1
0
0
0
01/01: [CRT] spawn: define a unicode environment when needed CORE-9182
by Mark Jansen
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2d47c3be2987662333573…
commit 2d47c3be2987662333573b65051f498f92d90dc3 Author: Mark Jansen <mark.jansen(a)reactos.org> AuthorDate: Sat Oct 13 00:20:58 2018 +0200 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sat Oct 13 20:30:07 2018 +0200 [CRT] spawn: define a unicode environment when needed CORE-9182 --- sdk/lib/crt/process/process.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sdk/lib/crt/process/process.c b/sdk/lib/crt/process/process.c index f607c2eed3..ef6ad4d8fa 100644 --- a/sdk/lib/crt/process/process.c +++ b/sdk/lib/crt/process/process.c @@ -203,6 +203,7 @@ do_spawnT(int mode, const _TCHAR* cmdname, const _TCHAR* args, const _TCHAR* env BOOL bResult; DWORD dwExitCode; DWORD dwError; + DWORD dwFlags = 0; TRACE(MK_STR(do_spawnT)"(%i,'%"sT"','%"sT"','%"sT"')",mode,cmdname,args,envp); @@ -286,12 +287,20 @@ do_spawnT(int mode, const _TCHAR* cmdname, const _TCHAR* args, const _TCHAR* env create_io_inherit_block(&StartupInfo.cbReserved2, &StartupInfo.lpReserved2); + if (mode == _P_DETACH) + { + dwFlags |= DETACHED_PROCESS; + } +#ifdef _UNICODE + dwFlags |= CREATE_UNICODE_ENVIRONMENT; +#endif + bResult = CreateProcess((_TCHAR *)cmdname, (_TCHAR *)args, NULL, NULL, TRUE, - mode == _P_DETACH ? DETACHED_PROCESS : 0, + dwFlags, (LPVOID)envp, NULL, &StartupInfo,
6 years, 2 months
1
0
0
0
01/01: [SHELL32] CDefView: Query SFVM_DEFVIEWMODE before creating the list view. CORE-14976
by Mark Jansen
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=80c53821c9616538b0a8a…
commit 80c53821c9616538b0a8a4a8d29bc03aa13afce4 Author: Mark Jansen <mark.jansen(a)reactos.org> AuthorDate: Tue Oct 9 20:57:23 2018 +0200 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Sat Oct 13 20:28:49 2018 +0200 [SHELL32] CDefView: Query SFVM_DEFVIEWMODE before creating the list view. CORE-14976 --- dll/win32/shell32/CDefView.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/dll/win32/shell32/CDefView.cpp b/dll/win32/shell32/CDefView.cpp index 32f7e153e7..9e67b441df 100644 --- a/dll/win32/shell32/CDefView.cpp +++ b/dll/win32/shell32/CDefView.cpp @@ -114,7 +114,7 @@ class CDefView : private: HRESULT _MergeToolbar(); BOOL _Sort(); - VOID _DoFolderViewCB(UINT uMsg, WPARAM wParam, LPARAM lParam); + HRESULT _DoFolderViewCB(UINT uMsg, WPARAM wParam, LPARAM lParam); public: CDefView(); @@ -520,7 +520,9 @@ void CDefView::SetStyle(DWORD dwAdd, DWORD dwRemove) */ BOOL CDefView::CreateList() { + HRESULT hr; DWORD dwStyle, dwExStyle; + UINT ViewMode; TRACE("%p\n", this); @@ -533,6 +535,16 @@ BOOL CDefView::CreateList() else dwStyle |= LVS_ALIGNTOP | LVS_SHOWSELALWAYS; + ViewMode = m_FolderSettings.ViewMode; + hr = _DoFolderViewCB(SFVM_DEFVIEWMODE, NULL, (LPARAM)&ViewMode); + if (SUCCEEDED(hr)) + { + if (ViewMode >= FVM_FIRST && ViewMode <= FVM_LAST) + m_FolderSettings.ViewMode = ViewMode; + else + ERR("Ignoring invalid ViewMode from SFVM_DEFVIEWMODE: %u (was: %u)\n", ViewMode, m_FolderSettings.ViewMode); + } + switch (m_FolderSettings.ViewMode) { case FVM_ICON: @@ -3245,12 +3257,13 @@ HRESULT CDefView::_MergeToolbar() return S_OK; } -VOID CDefView::_DoFolderViewCB(UINT uMsg, WPARAM wParam, LPARAM lParam) +HRESULT CDefView::_DoFolderViewCB(UINT uMsg, WPARAM wParam, LPARAM lParam) { if (m_pShellFolderViewCB) { - m_pShellFolderViewCB->MessageSFVCB(uMsg, wParam, lParam); + return m_pShellFolderViewCB->MessageSFVCB(uMsg, wParam, lParam); } + return E_NOINTERFACE; } HRESULT CDefView_CreateInstance(IShellFolder *pFolder, REFIID riid, LPVOID * ppvOut)
6 years, 2 months
1
0
0
0
01/01: [FASTFAT] Don't mess my debug log when partition SysType is printed! (when invalid chars are printed)
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8c0c90112e8f9a289ecc1…
commit 8c0c90112e8f9a289ecc10a07a1042be2f700db5 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sat Oct 13 19:57:24 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Sat Oct 13 19:57:24 2018 +0200 [FASTFAT] Don't mess my debug log when partition SysType is printed! (when invalid chars are printed) --- drivers/filesystems/fastfat/fsctl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/filesystems/fastfat/fsctl.c b/drivers/filesystems/fastfat/fsctl.c index b7e576d2d8..6523487368 100644 --- a/drivers/filesystems/fastfat/fsctl.c +++ b/drivers/filesystems/fastfat/fsctl.c @@ -280,8 +280,14 @@ VfatHasFileSystem( BootFatX->SysType[2] != 'T' || BootFatX->SysType[3] != 'X') { - DPRINT1("SysType %c%c%c%c\n", BootFatX->SysType[0], BootFatX->SysType[1], BootFatX->SysType[2], BootFatX->SysType[3]); - *RecognizedFS=FALSE; + DPRINT1("SysType %02X%02X%02X%02X (%c%c%c%c)\n", + BootFatX->SysType[0], BootFatX->SysType[1], BootFatX->SysType[2], BootFatX->SysType[3], + isprint(BootFatX->SysType[0]) ? BootFatX->SysType[0] : '.', + isprint(BootFatX->SysType[1]) ? BootFatX->SysType[1] : '.', + isprint(BootFatX->SysType[2]) ? BootFatX->SysType[2] : '.', + isprint(BootFatX->SysType[3]) ? BootFatX->SysType[3] : '.'); + + *RecognizedFS = FALSE; } if (*RecognizedFS &&
6 years, 2 months
1
0
0
0
01/01: [RTL] Make a RtlQueryEnvironmentVariable_U() DPRINT a little bit more useful.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=47d539e6e00bd04d21af5…
commit 47d539e6e00bd04d21af5ff42f0815efc423facd Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sat Oct 13 19:44:13 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Sat Oct 13 19:44:13 2018 +0200 [RTL] Make a RtlQueryEnvironmentVariable_U() DPRINT a little bit more useful. --- sdk/lib/rtl/path.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/lib/rtl/path.c b/sdk/lib/rtl/path.c index b52b24cd8b..7639424d0a 100644 --- a/sdk/lib/rtl/path.c +++ b/sdk/lib/rtl/path.c @@ -681,7 +681,7 @@ RtlGetFullPathName_Ustr( goto Quit; default: - DPRINT1("RtlQueryEnvironmentVariable_U returned 0x%08lx\n", Status); + DPRINT1("RtlQueryEnvironmentVariable_U(\"%wZ\") returned 0x%08lx\n", &EnvVarName, Status); EnvVarNameBuffer[0] = NewDrive; EnvVarNameBuffer[1] = L':';
6 years, 2 months
1
0
0
0
01/01: [KMTESTS:CC] Add more tests for CcPinMappedData()
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f3ea47d94da0f1c2a1559…
commit f3ea47d94da0f1c2a1559a0facb61e9726907bab Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Sat Oct 13 19:24:07 2018 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Sat Oct 13 19:24:29 2018 +0200 [KMTESTS:CC] Add more tests for CcPinMappedData() --- .../rostests/kmtests/ntos_cc/CcPinMappedData_drv.c | 81 ++++++++++++++++++++++ .../kmtests/ntos_cc/CcPinMappedData_user.c | 2 +- 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/modules/rostests/kmtests/ntos_cc/CcPinMappedData_drv.c b/modules/rostests/kmtests/ntos_cc/CcPinMappedData_drv.c index 1a41bf144f..79bbf8168d 100644 --- a/modules/rostests/kmtests/ntos_cc/CcPinMappedData_drv.c +++ b/modules/rostests/kmtests/ntos_cc/CcPinMappedData_drv.c @@ -144,6 +144,57 @@ MapAndLockUserBuffer( return MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority); } +static +VOID +NTAPI +PinInAnotherThread(IN PVOID Context) +{ + BOOLEAN Ret; + PULONG Buffer; + PVOID Bcb, PinBcb; + LARGE_INTEGER Offset; + PTEST_CONTEXT TestContext; + + ok(TestFileObject != NULL, "Called in invalid context!\n"); + ok_eq_ulong(TestTestId, 4); + + TestContext = Context; + ok(TestContext != NULL, "Called in invalid context!\n"); + ok(TestContext->Bcb != NULL, "Called in invalid context!\n"); + ok(TestContext->Buffer != NULL, "Called in invalid context!\n"); + ok(TestContext->Length != 0, "Called in invalid context!\n"); + + Ret = FALSE; + Offset.QuadPart = 0; + + KmtStartSeh(); + Ret = CcMapData(TestFileObject, &Offset, TestContext->Length, MAP_WAIT, &Bcb, (PVOID *)&Buffer); + KmtEndSeh(STATUS_SUCCESS); + + if (!skip(Ret == TRUE, "CcMapData failed\n")) + { + ok(Bcb != TestContext->Bcb, "Returned same BCB!\n"); + ok_eq_pointer(Buffer, TestContext->Buffer); + + Ret = FALSE; + PinBcb = Bcb; + + KmtStartSeh(); + Ret = CcPinMappedData(TestFileObject, &Offset, FileSizes.FileSize.QuadPart - Offset.QuadPart, 0, &PinBcb); + KmtEndSeh(STATUS_SUCCESS); + + if (!skip(Ret == TRUE, "CcPinMappedData failed\n")) + { + ok(Bcb != PinBcb, "Returned same BCB!\n"); + ok_eq_pointer(PinBcb, TestContext->Bcb); + + Bcb = PinBcb; + } + + CcUnpinData(Bcb); + } +} + static VOID NTAPI @@ -383,6 +434,36 @@ PerformTest( CcUnpinData(Bcb); } } + else if (TestId == 4) + { + PTEST_CONTEXT TestContext; + + TestContext = ExAllocatePool(NonPagedPool, sizeof(TEST_CONTEXT)); + if (!skip(TestContext != NULL, "ExAllocatePool failed\n")) + { + Ret = FALSE; + Offset.QuadPart = 0; + KmtStartSeh(); + Ret = CcPinRead(TestFileObject, &Offset, FileSizes.FileSize.QuadPart - Offset.QuadPart, PIN_WAIT, &TestContext->Bcb, (PVOID *)&TestContext->Buffer); + KmtEndSeh(STATUS_SUCCESS); + + if (!skip(Ret == TRUE, "CcPinRead failed\n")) + { + PKTHREAD ThreadHandle; + + ok(*(PUSHORT)TestContext->Bcb == 0x2FD, "Not a BCB: %x\n", *(PUSHORT)TestContext->Bcb); + ok_eq_ulong(TestContext->Buffer[0x3000 / sizeof(ULONG)], 0xDEADBABE); + + TestContext->Length = FileSizes.FileSize.QuadPart - Offset.QuadPart; + ThreadHandle = KmtStartThread(PinInAnotherThread, TestContext); + KmtFinishThread(ThreadHandle, NULL); + + CcUnpinData(TestContext->Bcb); + } + + ExFreePool(TestContext); + } + } } } } diff --git a/modules/rostests/kmtests/ntos_cc/CcPinMappedData_user.c b/modules/rostests/kmtests/ntos_cc/CcPinMappedData_user.c index 21fe904bb9..e0fdcfda15 100644 --- a/modules/rostests/kmtests/ntos_cc/CcPinMappedData_user.c +++ b/modules/rostests/kmtests/ntos_cc/CcPinMappedData_user.c @@ -19,7 +19,7 @@ START_TEST(CcPinMappedData) KmtOpenDriver(); /* 1 basic test */ - for (TestId = 0; TestId < 4; ++TestId) + for (TestId = 0; TestId < 5; ++TestId) { Ret = KmtSendUlongToDriver(IOCTL_START_TEST, TestId); ok(Ret == ERROR_SUCCESS, "KmtSendUlongToDriver failed: %lx\n", Ret);
6 years, 2 months
1
0
0
0
01/01: [NETCFGX] Move the NetClassInstaller to a separate file.
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a5172b46995472112b815…
commit a5172b46995472112b8152f0185ca1dc95bb9cdd Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Sat Oct 13 19:17:56 2018 +0200 Commit: Eric Kohl <eric.kohl(a)reactos.org> CommitDate: Sat Oct 13 19:18:37 2018 +0200 [NETCFGX] Move the NetClassInstaller to a separate file. --- dll/win32/netcfgx/CMakeLists.txt | 1 + dll/win32/netcfgx/{netcfgx.c => installer.c} | 131 +------ dll/win32/netcfgx/netcfgx.c | 564 +-------------------------- 3 files changed, 5 insertions(+), 691 deletions(-) diff --git a/dll/win32/netcfgx/CMakeLists.txt b/dll/win32/netcfgx/CMakeLists.txt index f192cc8d18..edbc3509b5 100644 --- a/dll/win32/netcfgx/CMakeLists.txt +++ b/dll/win32/netcfgx/CMakeLists.txt @@ -7,6 +7,7 @@ spec2def(netcfgx.dll netcfgx.spec) list(APPEND SOURCE netcfgx.c classfactory.c + installer.c netcfg_iface.c inetcfgcomp_iface.c tcpipconf_notify.c diff --git a/dll/win32/netcfgx/netcfgx.c b/dll/win32/netcfgx/installer.c similarity index 86% copy from dll/win32/netcfgx/netcfgx.c copy to dll/win32/netcfgx/installer.c index 7438632ad2..995b85d618 100644 --- a/dll/win32/netcfgx/netcfgx.c +++ b/dll/win32/netcfgx/installer.c @@ -1,7 +1,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS Configuration of network devices - * FILE: dll/win32/netcfgx/netcfgx.c + * FILE: dll/win32/netcfgx/installer.c * PURPOSE: Network devices installer * * PROGRAMMERS: Herv� Poussineau (hpoussin(a)reactos.org) @@ -9,135 +9,6 @@ #include "precomp.h" -#include <olectl.h> - -#define NTOS_MODE_USER -#include <ndk/iofuncs.h> -#include <ndk/rtlfuncs.h> - - -HINSTANCE netcfgx_hInstance; -const GUID CLSID_TcpipConfigNotifyObject = {0xA907657F, 0x6FDF, 0x11D0, {0x8E, 0xFB, 0x00, 0xC0, 0x4F, 0xD9, 0x12, 0xB2}}; - -static INTERFACE_TABLE InterfaceTable[] = -{ - { - &CLSID_CNetCfg, - INetCfg_Constructor - }, - { - &CLSID_TcpipConfigNotifyObject, - TcpipConfigNotify_Constructor - }, - { - NULL, - NULL - } -}; - -BOOL -WINAPI -DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) -{ - switch (fdwReason) - { - case DLL_PROCESS_ATTACH: - netcfgx_hInstance = hinstDLL; - DisableThreadLibraryCalls(netcfgx_hInstance); - InitCommonControls(); - break; - default: - break; - } - - return TRUE; -} - -HRESULT -WINAPI -DllCanUnloadNow(void) -{ - return S_FALSE; -} - -STDAPI -DllRegisterServer(void) -{ - HKEY hKey, hSubKey; - LPOLESTR pStr; - WCHAR szName[MAX_PATH] = L"CLSID\\"; - - if (FAILED(StringFromCLSID(&CLSID_CNetCfg, &pStr))) - return SELFREG_E_CLASS; - - wcscpy(&szName[6], pStr); - CoTaskMemFree(pStr); - - if (RegCreateKeyExW(HKEY_CLASSES_ROOT, szName, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) != ERROR_SUCCESS) - return SELFREG_E_CLASS; - - if (RegCreateKeyExW(hKey, L"InProcServer32", 0, NULL, 0, KEY_WRITE, NULL, &hSubKey, NULL) == ERROR_SUCCESS) - { - if (!GetModuleFileNameW(netcfgx_hInstance, szName, sizeof(szName)/sizeof(WCHAR))) - { - RegCloseKey(hSubKey); - RegCloseKey(hKey); - return SELFREG_E_CLASS; - } - szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0'; - RegSetValueW(hSubKey, NULL, REG_SZ, szName, (wcslen(szName)+1) * sizeof(WCHAR)); - RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (LPBYTE)L"Both", 10); - RegCloseKey(hSubKey); - } - - RegCloseKey(hKey); - return S_OK; -} - -STDAPI -DllUnregisterServer(void) -{ - //FIXME - // implement unregistering services - // - return S_OK; -} - -STDAPI -DllGetClassObject( - REFCLSID rclsid, - REFIID riid, - LPVOID* ppv) -{ - UINT i; - HRESULT hres = E_OUTOFMEMORY; - IClassFactory * pcf = NULL; - - if (!ppv) - return E_INVALIDARG; - - *ppv = NULL; - - for (i = 0; InterfaceTable[i].riid; i++) - { - if (IsEqualIID(InterfaceTable[i].riid, rclsid)) - { - pcf = IClassFactory_fnConstructor(InterfaceTable[i].lpfnCI, NULL, NULL); - break; - } - } - - if (!pcf) - { - return CLASS_E_CLASSNOTAVAILABLE; - } - - hres = IClassFactory_QueryInterface(pcf, riid, ppv); - IClassFactory_Release(pcf); - - return hres; -} - /* Append a REG_SZ to an existing REG_MULTI_SZ string in the registry. * If the value doesn't exist, create it. diff --git a/dll/win32/netcfgx/netcfgx.c b/dll/win32/netcfgx/netcfgx.c index 7438632ad2..a6d52ec97e 100644 --- a/dll/win32/netcfgx/netcfgx.c +++ b/dll/win32/netcfgx/netcfgx.c @@ -11,10 +11,6 @@ #include <olectl.h> -#define NTOS_MODE_USER -#include <ndk/iofuncs.h> -#include <ndk/rtlfuncs.h> - HINSTANCE netcfgx_hInstance; const GUID CLSID_TcpipConfigNotifyObject = {0xA907657F, 0x6FDF, 0x11D0, {0x8E, 0xFB, 0x00, 0xC0, 0x4F, 0xD9, 0x12, 0xB2}}; @@ -46,8 +42,9 @@ DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) DisableThreadLibraryCalls(netcfgx_hInstance); InitCommonControls(); break; - default: - break; + + default: + break; } return TRUE; @@ -137,558 +134,3 @@ DllGetClassObject( return hres; } - - -/* Append a REG_SZ to an existing REG_MULTI_SZ string in the registry. - * If the value doesn't exist, create it. - * Returns ERROR_SUCCESS if success. Otherwise, returns an error code - */ -static -LONG -AppendStringToMultiSZ( - IN HKEY hKey, - IN PCWSTR ValueName, - IN PCWSTR ValueToAppend) -{ - PWSTR Buffer = NULL; - DWORD dwRegType; - DWORD dwRequired, dwLength; - DWORD dwTmp; - LONG rc; - - rc = RegQueryValueExW(hKey, - ValueName, - NULL, - &dwRegType, - NULL, - &dwRequired); - if (rc != ERROR_FILE_NOT_FOUND) - { - if (rc != ERROR_SUCCESS) - goto cleanup; - if (dwRegType != REG_MULTI_SZ) - { - rc = ERROR_GEN_FAILURE; - goto cleanup; - } - - dwTmp = dwLength = dwRequired + wcslen(ValueToAppend) * sizeof(WCHAR) + sizeof(UNICODE_NULL); - Buffer = HeapAlloc(GetProcessHeap(), 0, dwLength); - if (!Buffer) - { - rc = ERROR_NOT_ENOUGH_MEMORY; - goto cleanup; - } - - rc = RegQueryValueExW(hKey, - ValueName, - NULL, - NULL, - (BYTE*)Buffer, - &dwTmp); - if (rc != ERROR_SUCCESS) - goto cleanup; - } - else - { - dwRequired = sizeof(WCHAR); - dwLength = wcslen(ValueToAppend) * sizeof(WCHAR) + 2 * sizeof(UNICODE_NULL); - Buffer = HeapAlloc(GetProcessHeap(), 0, dwLength); - if (!Buffer) - { - rc = ERROR_NOT_ENOUGH_MEMORY; - goto cleanup; - } - } - - /* Append the value */ - wcscpy(&Buffer[dwRequired / sizeof(WCHAR) - 1], ValueToAppend); - /* Terminate the REG_MULTI_SZ string */ - Buffer[dwLength / sizeof(WCHAR) - 1] = UNICODE_NULL; - - rc = RegSetValueExW(hKey, - ValueName, - 0, - REG_MULTI_SZ, - (const BYTE*)Buffer, - dwLength); - -cleanup: - HeapFree(GetProcessHeap(), 0, Buffer); - return rc; -} - - -static -DWORD -InstallNetDevice( - IN HDEVINFO DeviceInfoSet, - IN PSP_DEVINFO_DATA DeviceInfoData, - LPCWSTR UuidString, - DWORD Characteristics, - LPCWSTR BusType) -{ - LPWSTR InstanceId = NULL; - LPWSTR DeviceName = NULL; - LPWSTR ExportName = NULL; - LONG rc; - HKEY hKey = NULL; - HKEY hNetworkKey = NULL; - HKEY hLinkageKey = NULL; - HKEY hConnectionKey = NULL; - DWORD dwShowIcon, dwLength, dwValue; - WCHAR szBuffer[300]; - - /* Get Instance ID */ - if (SetupDiGetDeviceInstanceIdW(DeviceInfoSet, DeviceInfoData, NULL, 0, &dwLength)) - { - ERR("SetupDiGetDeviceInstanceIdW() returned TRUE. FALSE expected\n"); - rc = ERROR_GEN_FAILURE; - goto cleanup; - } - - InstanceId = HeapAlloc(GetProcessHeap(), 0, dwLength * sizeof(WCHAR)); - if (!InstanceId) - { - ERR("HeapAlloc() failed\n"); - rc = ERROR_NOT_ENOUGH_MEMORY; - goto cleanup; - } - - if (!SetupDiGetDeviceInstanceIdW(DeviceInfoSet, DeviceInfoData, InstanceId, dwLength, NULL)) - { - rc = GetLastError(); - ERR("SetupDiGetDeviceInstanceIdW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - /* Create device name */ - DeviceName = HeapAlloc(GetProcessHeap(), 0, (wcslen(L"\\Device\\") + wcslen(UuidString)) * sizeof(WCHAR) + sizeof(UNICODE_NULL)); - if (!DeviceName) - { - ERR("HeapAlloc() failed\n"); - rc = ERROR_NOT_ENOUGH_MEMORY; - goto cleanup; - } - wcscpy(DeviceName, L"\\Device\\"); - wcscat(DeviceName, UuidString); - - /* Create export name */ - ExportName = HeapAlloc(GetProcessHeap(), 0, (wcslen(L"\\Device\\Tcpip_") + wcslen(UuidString)) * sizeof(WCHAR) + sizeof(UNICODE_NULL)); - if (!ExportName) - { - ERR("HeapAlloc() failed\n"); - rc = ERROR_NOT_ENOUGH_MEMORY; - goto cleanup; - } - wcscpy(ExportName, L"\\Device\\Tcpip_"); - wcscat(ExportName, UuidString); - - /* Write Tcpip parameters in new service Key */ - rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY, NULL, &hKey, NULL); - if (rc != ERROR_SUCCESS) - { - ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - rc = RegCreateKeyExW(hKey, UuidString, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY, NULL, &hNetworkKey, NULL); - if (rc != ERROR_SUCCESS) - { - ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - RegCloseKey(hKey); - hKey = NULL; - - rc = RegCreateKeyExW(hNetworkKey, L"Parameters\\Tcpip", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, NULL); - if (rc != ERROR_SUCCESS) - { - ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - RegCloseKey(hNetworkKey); - hNetworkKey = NULL; - - rc = RegSetValueExW(hKey, L"DefaultGateway", 0, REG_SZ, (const BYTE*)L"0.0.0.0", (wcslen(L"0.0.0.0") + 1) * sizeof(WCHAR)); - if (rc != ERROR_SUCCESS) - { - ERR("RegSetValueExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - rc = RegSetValueExW(hKey, L"IPAddress", 0, REG_SZ, (const BYTE*)L"0.0.0.0", (wcslen(L"0.0.0.0") + 1) * sizeof(WCHAR)); - if (rc != ERROR_SUCCESS) - { - ERR("RegSetValueExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - rc = RegSetValueExW(hKey, L"SubnetMask", 0, REG_SZ, (const BYTE*)L"0.0.0.0", (wcslen(L"0.0.0.0") + 1) * sizeof(WCHAR)); - if (rc != ERROR_SUCCESS) - { - ERR("RegSetValueExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - dwValue = 1; - rc = RegSetValueExW(hKey, L"EnableDHCP", 0, REG_DWORD, (const BYTE*)&dwValue, sizeof(DWORD)); - if (rc != ERROR_SUCCESS) - { - ERR("RegSetValueExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - RegCloseKey(hKey); - hKey = NULL; - - /* Write 'Linkage' key in hardware key */ -#if _WIN32_WINNT >= 0x502 - hKey = SetupDiOpenDevRegKey(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DRV, KEY_READ | KEY_WRITE); -#else - hKey = SetupDiOpenDevRegKey(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DRV, KEY_ALL_ACCESS); -#endif - if (hKey == INVALID_HANDLE_VALUE && GetLastError() == ERROR_FILE_NOT_FOUND) - hKey = SetupDiCreateDevRegKeyW(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DRV, NULL, NULL); - if (hKey == INVALID_HANDLE_VALUE) - { - hKey = NULL; - rc = GetLastError(); - ERR("SetupDiCreateDevRegKeyW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - rc = RegSetValueExW(hKey, L"NetCfgInstanceId", 0, REG_SZ, (const BYTE*)UuidString, (wcslen(UuidString) + 1) * sizeof(WCHAR)); - if (rc != ERROR_SUCCESS) - { - ERR("RegSetValueExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - rc = RegSetValueExW(hKey, L"Characteristics", 0, REG_DWORD, (const BYTE*)&Characteristics, sizeof(DWORD)); - if (rc != ERROR_SUCCESS) - { - ERR("RegSetValueExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - if (BusType) - { - rc = RegSetValueExW(hKey, L"BusType", 0, REG_SZ, (const BYTE*)BusType, (wcslen(BusType) + 1) * sizeof(WCHAR)); - if (rc != ERROR_SUCCESS) - { - ERR("RegSetValueExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - } - - rc = RegCreateKeyExW(hKey, L"Linkage", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hLinkageKey, NULL); - if (rc != ERROR_SUCCESS) - { - ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - rc = RegSetValueExW(hLinkageKey, L"Export", 0, REG_SZ, (const BYTE*)DeviceName, (wcslen(DeviceName) + 1) * sizeof(WCHAR)); - if (rc != ERROR_SUCCESS) - { - ERR("RegSetValueExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - rc = RegSetValueExW(hLinkageKey, L"RootDevice", 0, REG_SZ, (const BYTE*)UuidString, (wcslen(UuidString) + 1) * sizeof(WCHAR)); - if (rc != ERROR_SUCCESS) - { - ERR("RegSetValueExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - rc = RegSetValueExW(hLinkageKey, L"UpperBind", 0, REG_SZ, (const BYTE*)L"Tcpip", (wcslen(L"Tcpip") + 1) * sizeof(WCHAR)); - if (rc != ERROR_SUCCESS) - { - ERR("RegSetValueExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - RegCloseKey(hKey); - hKey = NULL; - - /* Write connection information in network subkey */ - rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY, NULL, &hNetworkKey, NULL); - if (rc != ERROR_SUCCESS) - { - ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - rc = RegCreateKeyExW(hNetworkKey, UuidString, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY, NULL, &hKey, NULL); - if (rc != ERROR_SUCCESS) - { - ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - rc = RegCreateKeyExW(hKey, L"Connection", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hConnectionKey, NULL); - RegCloseKey(hKey); - hKey = NULL; - if (rc != ERROR_SUCCESS) - { - ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - if (!LoadStringW(netcfgx_hInstance, IDS_NET_CONNECT, szBuffer, sizeof(szBuffer)/sizeof(WCHAR))) - { - wcscpy(szBuffer, L"Network Connection"); - } - - rc = RegSetValueExW(hConnectionKey, L"Name", 0, REG_SZ, (const BYTE*)szBuffer, (wcslen(szBuffer) + 1) * sizeof(WCHAR)); - if (rc != ERROR_SUCCESS) - { - ERR("RegSetValueExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - rc = RegSetValueExW(hConnectionKey, L"PnpInstanceId", 0, REG_SZ, (const BYTE*)InstanceId, (wcslen(InstanceId) + 1) * sizeof(WCHAR)); - if (rc != ERROR_SUCCESS) - { - ERR("RegSetValueExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - dwShowIcon = 1; - rc = RegSetValueExW(hConnectionKey, L"ShowIcon", 0, REG_DWORD, (const BYTE*)&dwShowIcon, sizeof(dwShowIcon)); - if (rc != ERROR_SUCCESS) - { - ERR("RegSetValueExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - /* Write linkage information in Tcpip service */ - rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Linkage", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_QUERY_VALUE | KEY_SET_VALUE, NULL, &hKey, NULL); - if (rc != ERROR_SUCCESS) - { - ERR("RegCreateKeyExW() failed with error 0x%lx\n", rc); - goto cleanup; - } - rc = AppendStringToMultiSZ(hKey, L"Bind", DeviceName); - if (rc != ERROR_SUCCESS) - { - ERR("AppendStringToMultiSZ() failed with error 0x%lx\n", rc); - goto cleanup; - } - rc = AppendStringToMultiSZ(hKey, L"Export", ExportName); - if (rc != ERROR_SUCCESS) - { - ERR("AppendStringToMultiSZ() failed with error 0x%lx\n", rc); - goto cleanup; - } - rc = AppendStringToMultiSZ(hKey, L"Route", UuidString); - if (rc != ERROR_SUCCESS) - { - ERR("AppendStringToMultiSZ() failed with error 0x%lx\n", rc); - goto cleanup; - } - - rc = ERROR_SUCCESS; - -cleanup: - HeapFree(GetProcessHeap(), 0, InstanceId); - HeapFree(GetProcessHeap(), 0, DeviceName); - HeapFree(GetProcessHeap(), 0, ExportName); - if (hKey != NULL) - RegCloseKey(hKey); - if (hNetworkKey != NULL) - RegCloseKey(hNetworkKey); - if (hLinkageKey != NULL) - RegCloseKey(hLinkageKey); - if (hConnectionKey != NULL) - RegCloseKey(hConnectionKey); - return rc; -} - -static -DWORD -InstallNetClient(VOID) -{ - FIXME("Installation of network clients is not yet supported\n"); - return ERROR_GEN_FAILURE; -} - -static -DWORD -InstallNetService(VOID) -{ - FIXME("Installation of network services is not yet supported\n"); - return ERROR_GEN_FAILURE; -} - -static -DWORD -InstallNetTransport(VOID) -{ - FIXME("Installation of network protocols is not yet supported\n"); - return ERROR_GEN_FAILURE; -} - -DWORD -WINAPI -NetClassInstaller( - IN DI_FUNCTION InstallFunction, - IN HDEVINFO DeviceInfoSet, - IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL) -{ - SP_DRVINFO_DATA_W DriverInfoData; - SP_DRVINFO_DETAIL_DATA_W DriverInfoDetail; - WCHAR SectionName[LINE_LEN]; - HINF hInf = INVALID_HANDLE_VALUE; - INFCONTEXT InfContext; - UINT ErrorLine; - INT CharacteristicsInt; - DWORD Characteristics; - LPWSTR BusType = NULL; - RPC_STATUS RpcStatus; - UUID Uuid; - LPWSTR UuidRpcString = NULL; - LPWSTR UuidString = NULL; - LONG rc; - DWORD dwLength; - - if (InstallFunction != DIF_INSTALLDEVICE) - return ERROR_DI_DO_DEFAULT; - - TRACE("%lu %p %p\n", InstallFunction, DeviceInfoSet, DeviceInfoData); - - /* Get driver info details */ - DriverInfoData.cbSize = sizeof(SP_DRVINFO_DATA_W); - if (!SetupDiGetSelectedDriverW(DeviceInfoSet, DeviceInfoData, &DriverInfoData)) - { - rc = GetLastError(); - ERR("SetupDiGetSelectedDriverW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - DriverInfoDetail.cbSize = sizeof(SP_DRVINFO_DETAIL_DATA_W); - if (!SetupDiGetDriverInfoDetailW(DeviceInfoSet, DeviceInfoData, &DriverInfoData, &DriverInfoDetail, sizeof(DriverInfoDetail), NULL) - && GetLastError() != ERROR_INSUFFICIENT_BUFFER) - { - rc = GetLastError(); - ERR("SetupDiGetDriverInfoDetailW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - hInf = SetupOpenInfFileW(DriverInfoDetail.InfFileName, NULL, INF_STYLE_WIN4, &ErrorLine); - if (hInf == INVALID_HANDLE_VALUE) - { - rc = GetLastError(); - ERR("SetupOpenInfFileW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - if (!SetupDiGetActualSectionToInstallW(hInf, DriverInfoDetail.SectionName, SectionName, LINE_LEN, NULL, NULL)) - { - rc = GetLastError(); - ERR("SetupDiGetActualSectionToInstallW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - /* Get Characteristics and BusType (optional) from .inf file */ - if (!SetupFindFirstLineW(hInf, SectionName, L"Characteristics", &InfContext)) - { - rc = GetLastError(); - ERR("Unable to find key %S in section %S of file %S (error 0x%lx)\n", - L"Characteristics", SectionName, DriverInfoDetail.InfFileName, rc); - goto cleanup; - } - - if (!SetupGetIntField(&InfContext, 1, &CharacteristicsInt)) - { - rc = GetLastError(); - ERR("SetupGetIntField() failed with error 0x%lx\n", rc); - goto cleanup; - } - - Characteristics = (DWORD)CharacteristicsInt; - if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NET)) - { - if (SetupFindFirstLineW(hInf, SectionName, L"BusType", &InfContext)) - { - if (!SetupGetStringFieldW(&InfContext, 1, NULL, 0, &dwLength)) - { - rc = GetLastError(); - ERR("SetupGetStringFieldW() failed with error 0x%lx\n", rc); - goto cleanup; - } - - BusType = HeapAlloc(GetProcessHeap(), 0, dwLength * sizeof(WCHAR)); - if (!BusType) - { - ERR("HeapAlloc() failed\n"); - rc = ERROR_NOT_ENOUGH_MEMORY; - goto cleanup; - } - - if (!SetupGetStringFieldW(&InfContext, 1, BusType, dwLength, NULL)) - { - rc = GetLastError(); - ERR("SetupGetStringFieldW() failed with error 0x%lx\n", rc); - goto cleanup; - } - } - } - - /* Create a new UUID */ - RpcStatus = UuidCreate(&Uuid); - if (RpcStatus != RPC_S_OK && RpcStatus != RPC_S_UUID_LOCAL_ONLY) - { - ERR("UuidCreate() failed with RPC status 0x%lx\n", RpcStatus); - rc = ERROR_GEN_FAILURE; - goto cleanup; - } - - RpcStatus = UuidToStringW(&Uuid, &UuidRpcString); - if (RpcStatus != RPC_S_OK) - { - ERR("UuidToStringW() failed with RPC status 0x%lx\n", RpcStatus); - rc = ERROR_GEN_FAILURE; - goto cleanup; - } - - /* Add curly braces around Uuid */ - UuidString = HeapAlloc(GetProcessHeap(), 0, (2 + wcslen(UuidRpcString)) * sizeof(WCHAR) + sizeof(UNICODE_NULL)); - if (!UuidString) - { - ERR("HeapAlloc() failed\n"); - rc = ERROR_NOT_ENOUGH_MEMORY; - goto cleanup; - } - - wcscpy(UuidString, L"{"); - wcscat(UuidString, UuidRpcString); - wcscat(UuidString, L"}"); - - if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NET)) - rc = InstallNetDevice(DeviceInfoSet, DeviceInfoData, UuidString, Characteristics, BusType); - else if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NETCLIENT)) - rc = InstallNetClient(); - else if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NETSERVICE)) - rc = InstallNetService(); - else if (IsEqualIID(&DeviceInfoData->ClassGuid, &GUID_DEVCLASS_NETTRANS)) - rc = InstallNetTransport(); - else - { - ERR("Invalid class guid\n"); - rc = ERROR_GEN_FAILURE; - } - -cleanup: - if (hInf != INVALID_HANDLE_VALUE) - SetupCloseInfFile(hInf); - if (UuidRpcString != NULL) - RpcStringFreeW(&UuidRpcString); - HeapFree(GetProcessHeap(), 0, BusType); - HeapFree(GetProcessHeap(), 0, UuidString); - - if (rc == ERROR_SUCCESS) - rc = ERROR_DI_DO_DEFAULT; - TRACE("Returning 0x%lx\n", rc); - return rc; -}
6 years, 2 months
1
0
0
0
← Newer
1
...
20
21
22
23
24
25
26
...
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