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
May 2016
----- 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
260 discussions
Start a n
N
ew thread
[jgardou] 71389: [NEWCC] - Create section object when creating the file shared cache map - Map the said section PsInitialSystemProcess address space and map it in kernel space using MmProbeAndLockP...
by jgardou@svn.reactos.org
Author: jgardou Date: Mon May 23 20:15:54 2016 New Revision: 71389 URL:
http://svn.reactos.org/svn/reactos?rev=71389&view=rev
Log: [NEWCC] - Create section object when creating the file shared cache map - Map the said section PsInitialSystemProcess address space and map it in kernel space using MmProbeAndLockProcessPages - Implement CcSetFileSizes on top of MmExtendSection Modified: branches/TransitionPte/ntoskrnl/cache/cachesub.c branches/TransitionPte/ntoskrnl/cache/fssup.c branches/TransitionPte/ntoskrnl/cache/newcc.h branches/TransitionPte/ntoskrnl/cache/pinsup.c branches/TransitionPte/ntoskrnl/cache/section/data.c Modified: branches/TransitionPte/ntoskrnl/cache/cachesub.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/ntoskrnl/cache/ca…
============================================================================== --- branches/TransitionPte/ntoskrnl/cache/cachesub.c [iso-8859-1] (original) +++ branches/TransitionPte/ntoskrnl/cache/cachesub.c [iso-8859-1] Mon May 23 20:15:54 2016 @@ -64,6 +64,10 @@ PLIST_ENTRY ListEntry; volatile char *chptr; PNOCC_BCB Bcb; + KAPC_STATE ApcState; + + KeStackAttachProcess(&PsInitialSystemProcess->Pcb, &ApcState); + for (ListEntry = Map->AssociatedBcb.Flink; ListEntry != &Map->AssociatedBcb; ListEntry = ListEntry->Flink) @@ -81,6 +85,8 @@ *chptr ^= 0; } } + + KeUnstackDetachProcess(&ApcState); } ObDereferenceObject(WorkItem->FileObject); ExFreePool(WorkItem); @@ -306,13 +312,13 @@ for (i = 0; i < CACHE_NUM_SECTIONS; i++) { PNOCC_BCB Bcb = &CcCacheSections[i]; - if (Bcb->SectionObject) + if (Bcb->Map->SectionObject) { DPRINT1("Evicting #%02x %08x%08x %wZ\n", i, Bcb->FileOffset.u.HighPart, Bcb->FileOffset.u.LowPart, - &MmGetFileObjectForSection((PROS_SECTION_OBJECT)Bcb->SectionObject)->FileName); + &MmGetFileObjectForSection(Bcb->Map->SectionObject)->FileName); CcpFlushCache(Bcb->Map, NULL, 0, NULL, TRUE); Bcb->Dirty = FALSE; Modified: branches/TransitionPte/ntoskrnl/cache/fssup.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/ntoskrnl/cache/fs…
============================================================================== --- branches/TransitionPte/ntoskrnl/cache/fssup.c [iso-8859-1] (original) +++ branches/TransitionPte/ntoskrnl/cache/fssup.c [iso-8859-1] Mon May 23 20:15:54 2016 @@ -218,6 +218,9 @@ /* We still don't have a shared cache map. We need to create one. */ if (!Map) { + NTSTATUS Status; + LARGE_INTEGER MaxSize = FileSizes->AllocationSize; + DPRINT("Initializing file object for (%p) %wZ\n", FileObject, &FileObject->FileName); @@ -237,6 +240,20 @@ InitializeListHead(&Map->PrivateCacheMaps); InsertTailList(&CcpAllSharedCacheMaps, &Map->Entry); DPRINT("New Map %p\n", Map); + + Status = MmCreateSection(&Map->SectionObject, + STANDARD_RIGHTS_REQUIRED | SECTION_EXTEND_SIZE, + NULL, + &MaxSize, + PAGE_READWRITE, + SEC_RESERVE, // Use ARM3 implementation + NULL, + FileObject); + if (!NT_SUCCESS(Status)) + { + ExFreePool(Map); + RtlRaiseStatus(Status); + } } /* We don't have a private cache map. Link it with the shared cache map to serve as a held reference. When the list in the shared cache map @@ -325,6 +342,7 @@ CcpDereferenceCache(Bcb - CcCacheSections, TRUE); } RemoveEntryList(&PrivateCacheMap->Map->Entry); + ObDereferenceObject(PrivateCacheMap->Map->SectionObject); ExFreePool(PrivateCacheMap->Map); FileObject->SectionObjectPointer->SharedCacheMap = NULL; LastMap = TRUE; @@ -354,18 +372,36 @@ CcSetFileSizes(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes) { - PNOCC_CACHE_MAP Map = (PNOCC_CACHE_MAP)FileObject->SectionObjectPointer->SharedCacheMap; - PNOCC_BCB Bcb; - - if (!Map) return; + PNOCC_CACHE_MAP Map; + + CcpLock(); + + Map = FileObject->SectionObjectPointer->SharedCacheMap; + + if (!Map) + { + CcpUnlock(); + return; + } + + /* FS should have unmapped the whole thing. */ + //ASSERT(IsListEmpty(&Map->AssociatedBcb)); + + if (Map->FileSizes.AllocationSize.QuadPart != FileSizes->AllocationSize.QuadPart) + { + LARGE_INTEGER SectionSize = FileSizes->AllocationSize; + NTSTATUS Status = MmExtendSection(Map->SectionObject, &SectionSize); + + if (!NT_SUCCESS(Status)) + { + CcpUnlock(); + ExRaiseStatus(Status); + } + } + Map->FileSizes = *FileSizes; - Bcb = Map->AssociatedBcb.Flink == &Map->AssociatedBcb ? - NULL : CONTAINING_RECORD(Map->AssociatedBcb.Flink, NOCC_BCB, ThisFileList); - if (!Bcb) return; - MmExtendCacheSection(Bcb->SectionObject, &FileSizes->FileSize, FALSE); - DPRINT("FileSizes->FileSize %x\n", FileSizes->FileSize.LowPart); - DPRINT("FileSizes->AllocationSize %x\n", FileSizes->AllocationSize.LowPart); - DPRINT("FileSizes->ValidDataLength %x\n", FileSizes->ValidDataLength.LowPart); + + CcpUnlock(); } BOOLEAN @@ -612,7 +648,7 @@ NOCC_BCB, ThisFileList); - Result = MmGetFileObjectForSection((PROS_SECTION_OBJECT)Bcb->SectionObject); + Result = MmGetFileObjectForSection(Bcb->Map->SectionObject); } CcpUnlock(); return Result; @@ -624,7 +660,7 @@ { PNOCC_BCB RealBcb = (PNOCC_BCB)Bcb; DPRINT("BCB #%x\n", RealBcb - CcCacheSections); - return MmGetFileObjectForSection((PROS_SECTION_OBJECT)RealBcb->SectionObject); + return MmGetFileObjectForSection(RealBcb->Map->SectionObject); } /* EOF */ Modified: branches/TransitionPte/ntoskrnl/cache/newcc.h URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/ntoskrnl/cache/ne…
============================================================================== --- branches/TransitionPte/ntoskrnl/cache/newcc.h [iso-8859-1] (original) +++ branches/TransitionPte/ntoskrnl/cache/newcc.h [iso-8859-1] Mon May 23 20:15:54 2016 @@ -6,12 +6,14 @@ PUBLIC_BCB Bcb; struct _NOCC_CACHE_MAP *Map; - PROS_SECTION_OBJECT SectionObject; LARGE_INTEGER FileOffset; ULONG Length; PVOID BaseAddress; BOOLEAN Dirty; PVOID OwnerPointer; + + PMDL Mdl; + PVOID MdlAddress; /* Reference counts */ ULONG RefCount; @@ -36,6 +38,7 @@ PVOID LogHandle; PFLUSH_TO_LSN FlushToLsn; ULONG ReadAheadGranularity; + PVOID SectionObject; } NOCC_CACHE_MAP, *PNOCC_CACHE_MAP; VOID Modified: branches/TransitionPte/ntoskrnl/cache/pinsup.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/ntoskrnl/cache/pi…
============================================================================== --- branches/TransitionPte/ntoskrnl/cache/pinsup.c [iso-8859-1] (original) +++ branches/TransitionPte/ntoskrnl/cache/pinsup.c [iso-8859-1] Mon May 23 20:15:54 2016 @@ -12,7 +12,7 @@ #include <ntoskrnl.h> #include "newcc.h" #include "section/newmm.h" -#define NDEBUG +//#define NDEBUG #include <debug.h> /* The following is a test mode that only works with modified filesystems. @@ -128,47 +128,12 @@ NTAPI MmGetDeviceObjectForFile(IN PFILE_OBJECT FileObject); -/* - -Allocate an almost ordinary section object for use by the cache system. -The special internal SEC_CACHE flag is used to indicate that the section -should not count when determining whether the file can be resized. - -*/ - -NTSTATUS -CcpAllocateSection(PFILE_OBJECT FileObject, - ULONG Length, - ULONG Protect, - PROS_SECTION_OBJECT *Result) -{ - NTSTATUS Status; - LARGE_INTEGER MaxSize; - - MaxSize.QuadPart = Length; - - DPRINT("Making Section for File %x\n", FileObject); - DPRINT("File name %wZ\n", &FileObject->FileName); - - Status = MmCreateSection((PVOID*)Result, - STANDARD_RIGHTS_REQUIRED, - NULL, - &MaxSize, - Protect, - SEC_RESERVE | SEC_CACHE, - NULL, - FileObject); - - return Status; -} - typedef struct _WORK_QUEUE_WITH_CONTEXT { WORK_QUEUE_ITEM WorkItem; PVOID ToUnmap; LARGE_INTEGER FileOffset; LARGE_INTEGER MapSize; - PROS_SECTION_OBJECT ToDeref; PACQUIRE_FOR_LAZY_WRITE AcquireForLazyWrite; PRELEASE_FROM_LAZY_WRITE ReleaseFromLazyWrite; PVOID LazyContext; @@ -188,8 +153,7 @@ { PWORK_QUEUE_WITH_CONTEXT WorkItem = (PWORK_QUEUE_WITH_CONTEXT)Context; DPRINT("Unmapping (finally) %x\n", WorkItem->ToUnmap); - MmUnmapCacheViewInSystemSpace(WorkItem->ToUnmap); - ObDereferenceObject(WorkItem->ToDeref); + MmUnmapViewOfSection(PsInitialSystemProcess, WorkItem->ToUnmap); ExFreePool(WorkItem); DPRINT("Done\n"); } @@ -230,7 +194,7 @@ MappedSize = Bcb->Map->FileSizes.ValidDataLength; DPRINT("Dereference #%x (count %d)\n", Start, Bcb->RefCount); - ASSERT(Bcb->SectionObject); + ASSERT(Bcb->Map->SectionObject); ASSERT(Bcb->RefCount == 1); DPRINT("Firing work item for %x\n", Bcb->BaseAddress); @@ -245,9 +209,7 @@ if (Immediate) { - PROS_SECTION_OBJECT ToDeref = Bcb->SectionObject; Bcb->Map = NULL; - Bcb->SectionObject = NULL; Bcb->BaseAddress = NULL; Bcb->FileOffset.QuadPart = 0; Bcb->Length = 0; @@ -256,8 +218,7 @@ RemoveEntryList(&Bcb->ThisFileList); CcpUnlock(); - MmUnmapCacheViewInSystemSpace(ToUnmap); - ObDereferenceObject(ToDeref); + MmUnmapViewOfSection(PsInitialSystemProcess, ToUnmap); CcpLock(); } else @@ -268,7 +229,6 @@ WorkItem->FileOffset = Bcb->FileOffset; WorkItem->Dirty = Bcb->Dirty; WorkItem->MapSize = MappedSize; - WorkItem->ToDeref = Bcb->SectionObject; WorkItem->AcquireForLazyWrite = Bcb->Map->Callbacks.AcquireForLazyWrite; WorkItem->ReleaseFromLazyWrite = Bcb->Map->Callbacks.ReleaseFromLazyWrite; WorkItem->LazyContext = Bcb->Map->LazyContext; @@ -278,7 +238,6 @@ WorkItem); Bcb->Map = NULL; - Bcb->SectionObject = NULL; Bcb->BaseAddress = NULL; Bcb->FileOffset.QuadPart = 0; Bcb->Length = 0; @@ -308,7 +267,7 @@ /* Needs mutex */ ULONG CcpAllocateCacheSections(PFILE_OBJECT FileObject, - PROS_SECTION_OBJECT SectionObject) + PVOID SectionObject) { ULONG i = INVALID_CACHE; PNOCC_CACHE_MAP Map; @@ -369,7 +328,6 @@ { PNOCC_BCB Bcb; Bcb = &CcCacheSections[Start]; - ASSERT(Bcb->SectionObject); Bcb->RefCount++; RtlSetBit(CcCacheBitmap, Start); @@ -405,7 +363,6 @@ CcpLock(); ASSERT(Bcb->ExclusiveWaiter); - ASSERT(Bcb->SectionObject); Bcb->Exclusive = TRUE; Bcb->ExclusiveWaiter--; RtlSetBit(CcCacheBitmap, Start); @@ -469,13 +426,12 @@ OUT PVOID *BcbResult, OUT PVOID *Buffer) { - BOOLEAN Success = FALSE, FaultIn = FALSE; + BOOLEAN Success = FALSE; /* Note: windows 2000 drivers treat this as a bool */ //BOOLEAN Wait = (Flags & MAP_WAIT) || (Flags == TRUE); LARGE_INTEGER Target, EndInterval; ULONG BcbHead, SectionSize, ViewSize; PNOCC_BCB Bcb = NULL; - PROS_SECTION_OBJECT SectionObject = NULL; NTSTATUS Status; PNOCC_CACHE_MAP Map = (PNOCC_CACHE_MAP)FileObject->SectionObjectPointer->SharedCacheMap; ViewSize = CACHE_STRIPE; @@ -486,8 +442,9 @@ return FALSE; } - DPRINT("CcMapData(F->%x, %I64x:%d)\n", + DPRINT("CcMapData(F->%x, %S, %I64x:%d)\n", FileObject, + FileObject->FileName.Buffer, FileOffset->QuadPart, Length); @@ -506,8 +463,6 @@ { Bcb = &CcCacheSections[BcbHead]; Success = TRUE; - *BcbResult = Bcb; - *Buffer = ((PCHAR)Bcb->BaseAddress) + (int)(FileOffset->QuadPart - Bcb->FileOffset.QuadPart); DPRINT("Bcb #%x Buffer maps (%I64x) At %x Length %x (Getting %p:%x) %wZ\n", Bcb - CcCacheSections, @@ -545,31 +500,10 @@ //ASSERT(SectionSize <= CACHE_STRIPE); - CcpUnlock(); - /* CcpAllocateSection doesn't need the lock, so we'll give other action - a chance in here. */ - Status = CcpAllocateSection(FileObject, - SectionSize, -#ifdef PIN_WRITE_ONLY - PAGE_READONLY, -#else - PAGE_READWRITE, -#endif - &SectionObject); - CcpLock(); - - if (!NT_SUCCESS(Status)) - { - *BcbResult = NULL; - *Buffer = NULL; - DPRINT1("End %08x\n", Status); - goto cleanup; - } - retry: /* Returns a reference */ DPRINT("Allocating cache sections: %wZ\n", &FileObject->FileName); - BcbHead = CcpAllocateCacheSections(FileObject, SectionObject); + BcbHead = CcpAllocateCacheSections(FileObject, Map->SectionObject); /* XXX todo: we should handle the immediate fail case here, but don't */ if (BcbHead == INVALID_CACHE) { @@ -603,24 +537,27 @@ } DPRINT("Selected BCB #%x\n", BcbHead); - ViewSize = CACHE_STRIPE; + ViewSize = SectionSize; Bcb = &CcCacheSections[BcbHead]; - /* MmMapCacheViewInSystemSpaceAtOffset is one of three methods of Mm - that are specific to NewCC. In this case, it's implementation - exactly mirrors MmMapViewInSystemSpace, but allows an offset to - be specified. */ - Status = MmMapCacheViewInSystemSpaceAtOffset(SectionObject->Segment, - &Bcb->BaseAddress, - &Target, - &ViewSize); + Status = MmMapViewOfSection(Map->SectionObject, + PsInitialSystemProcess, + &Bcb->BaseAddress, + 0, + ViewSize, + &Target, + &ViewSize, + ViewShare, + 0, + PAGE_READWRITE); + + DPRINT("MmMapViewOfSection, Status 0x%08x.\n", Status); /* Summary: Failure. Dereference our section and tell the user we failed */ if (!NT_SUCCESS(Status)) { *BcbResult = NULL; *Buffer = NULL; - ObDereferenceObject(SectionObject); RemoveEntryList(&Bcb->ThisFileList); RtlZeroMemory(Bcb, sizeof(*Bcb)); RtlClearBit(CcCacheBitmap, BcbHead); @@ -636,14 +573,9 @@ Bcb->Length = MIN(Map->FileSizes.ValidDataLength.QuadPart - Target.QuadPart, CACHE_STRIPE); - Bcb->SectionObject = SectionObject; Bcb->Map = Map; Bcb->FileOffset = Target; InsertTailList(&Map->AssociatedBcb, &Bcb->ThisFileList); - - *BcbResult = &CcCacheSections[BcbHead]; - *Buffer = ((PCHAR)Bcb->BaseAddress) + (int)(FileOffset->QuadPart - Bcb->FileOffset.QuadPart); - FaultIn = TRUE; DPRINT("Bcb #%x Buffer maps (%I64x) At %x Length %x (Getting %p:%lx) %wZ\n", Bcb - CcCacheSections, @@ -659,32 +591,48 @@ (Bcb->FileOffset.QuadPart & ~(CACHE_STRIPE - 1))); cleanup: - CcpUnlock(); if (Success) { - if (FaultIn) + if (!Bcb->Mdl) { - /* Fault in the pages. This forces reads to happen now. */ - ULONG i; - PCHAR FaultIn = Bcb->BaseAddress; - - DPRINT("Faulting in pages at this point: file %wZ %I64x:%x\n", - &FileObject->FileName, - Bcb->FileOffset.QuadPart, - Bcb->Length); - - for (i = 0; i < Bcb->Length; i += PAGE_SIZE) + PMDL Mdl; + PVOID MdlAddress; + CcpUnlock(); + + DPRINT("Allocating MDL for Bcb #%x.\n", Bcb - CcCacheSections); + + Mdl = IoAllocateMdl(Bcb->BaseAddress, Bcb->Length, FALSE, FALSE, NULL); + if (!Mdl) + RtlRaiseStatus(STATUS_INSUFFICIENT_RESOURCES); + + MmProbeAndLockProcessPages(Mdl, PsInitialSystemProcess, KernelMode, IoModifyAccess); + MdlAddress = MmGetSystemAddressForMdlSafe(Mdl, NormalPagePriority); + + CcpLock(); + if (Bcb->Mdl) { - FaultIn[i] ^= 0; + /* Someone beat us */ + MmUnlockPages(Mdl); + IoFreeMdl(Mdl); + } + else + { + Bcb->Mdl = Mdl; + Bcb->MdlAddress = MdlAddress; } } ASSERT(Bcb >= CcCacheSections && Bcb < (CcCacheSections + CACHE_NUM_SECTIONS)); + + *BcbResult = Bcb; + *Buffer = ((PCHAR)Bcb->MdlAddress) + (int)(FileOffset->QuadPart - Bcb->FileOffset.QuadPart); } else { ASSERT(FALSE); } + + CcpUnlock(); return Success; } @@ -815,7 +763,7 @@ { CcpLock(); RealBcb = *Bcb; - *Buffer = ((PCHAR)RealBcb->BaseAddress) + (int)(FileOffset->QuadPart - RealBcb->FileOffset.QuadPart); + *Buffer = ((PCHAR)RealBcb->MdlAddress) + (int)(FileOffset->QuadPart - RealBcb->FileOffset.QuadPart); CcpUnlock(); } @@ -934,6 +882,14 @@ RtlClearBit(CcCacheBitmap, RealBcb - CcCacheSections); + if(RealBcb->Mdl) + { + MmUnlockPages(RealBcb->Mdl); + IoFreeMdl(RealBcb->Mdl); + RealBcb->Mdl = NULL; + RealBcb->MdlAddress = NULL; + } + #ifdef PIN_WRITE_ONLY PVOID BaseAddress = RealBcb->BaseAddress; SIZE_T NumberOfBytes = RealBcb->Length; Modified: branches/TransitionPte/ntoskrnl/cache/section/data.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/ntoskrnl/cache/se…
============================================================================== --- branches/TransitionPte/ntoskrnl/cache/section/data.c [iso-8859-1] (original) +++ branches/TransitionPte/ntoskrnl/cache/section/data.c [iso-8859-1] Mon May 23 20:15:54 2016 @@ -77,7 +77,7 @@ #include <ntoskrnl.h> #include "newmm.h" #include <cache/newcc.h> -#define NDEBUG +// #define NDEBUG #include <debug.h> #include <mm/ARM3/miarm.h> @@ -157,7 +157,7 @@ if (!MemoryArea || MemoryArea->Type != MEMORY_AREA_CACHE || MemoryArea->DeleteInProgress) { MmUnlockAddressSpace(AddressSpace); - DPRINT("STATUS_NOT_MAPPED_DATA\n"); + DPRINT1("STATUS_NOT_MAPPED_DATA\n"); return STATUS_NOT_MAPPED_DATA; } BeginningAddress = PAGE_ROUND_DOWN(MA_GetStartingAddress(MemoryArea));
8 years, 7 months
1
0
0
0
[jgardou] 71388: [CDFS_NEW] - "Convert" to PSEH2 + unix compilation friendliness - Use
by jgardou@svn.reactos.org
Author: jgardou Date: Mon May 23 20:07:45 2016 New Revision: 71388 URL:
http://svn.reactos.org/svn/reactos?rev=71388&view=rev
Log: [CDFS_NEW] - "Convert" to PSEH2 + unix compilation friendliness - Use Modified: branches/TransitionPte/drivers/filesystems/CMakeLists.txt branches/TransitionPte/drivers/filesystems/cdfs_new/allocsup.c branches/TransitionPte/drivers/filesystems/cdfs_new/cachesup.c branches/TransitionPte/drivers/filesystems/cdfs_new/cddata.c branches/TransitionPte/drivers/filesystems/cdfs_new/cdinit.c branches/TransitionPte/drivers/filesystems/cdfs_new/cdprocs.h branches/TransitionPte/drivers/filesystems/cdfs_new/cleanup.c branches/TransitionPte/drivers/filesystems/cdfs_new/close.c branches/TransitionPte/drivers/filesystems/cdfs_new/create.c branches/TransitionPte/drivers/filesystems/cdfs_new/devctrl.c branches/TransitionPte/drivers/filesystems/cdfs_new/deviosup.c branches/TransitionPte/drivers/filesystems/cdfs_new/dirctrl.c branches/TransitionPte/drivers/filesystems/cdfs_new/dirsup.c branches/TransitionPte/drivers/filesystems/cdfs_new/fieldoff.c branches/TransitionPte/drivers/filesystems/cdfs_new/fileinfo.c branches/TransitionPte/drivers/filesystems/cdfs_new/filobsup.c branches/TransitionPte/drivers/filesystems/cdfs_new/fsctrl.c branches/TransitionPte/drivers/filesystems/cdfs_new/fspdisp.c branches/TransitionPte/drivers/filesystems/cdfs_new/lockctrl.c branches/TransitionPte/drivers/filesystems/cdfs_new/namesup.c branches/TransitionPte/drivers/filesystems/cdfs_new/nodetype.h branches/TransitionPte/drivers/filesystems/cdfs_new/pathsup.c branches/TransitionPte/drivers/filesystems/cdfs_new/pnp.c branches/TransitionPte/drivers/filesystems/cdfs_new/prefxsup.c branches/TransitionPte/drivers/filesystems/cdfs_new/read.c branches/TransitionPte/drivers/filesystems/cdfs_new/resrcsup.c branches/TransitionPte/drivers/filesystems/cdfs_new/strucsup.c branches/TransitionPte/drivers/filesystems/cdfs_new/verfysup.c branches/TransitionPte/drivers/filesystems/cdfs_new/volinfo.c branches/TransitionPte/drivers/filesystems/cdfs_new/workque.c Modified: branches/TransitionPte/drivers/filesystems/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/CMakeLists.txt [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/CMakeLists.txt [iso-8859-1] Mon May 23 20:07:45 2016 @@ -1,5 +1,6 @@ -add_subdirectory(cdfs) +#add_subdirectory(cdfs) +add_subdirectory(cdfs_new) add_subdirectory(ext2) add_subdirectory(fastfat) #add_subdirectory(fastfat_new) Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/allocsup.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/allocsup.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/allocsup.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -44,7 +44,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -149,7 +149,7 @@ // Use a try finally to facilitate cleanup. // - try { + _SEH2_TRY { // // We use a loop to perform the lookup. If we don't find the mapping in the @@ -296,7 +296,7 @@ FirstPass = FALSE; } - } finally { + } _SEH2_FINALLY { if (CleanupParent) { @@ -311,7 +311,7 @@ } if (UnlockFcb) { CdUnlockFcb( IrpContext, Fcb ); } - } + } _SEH2_END return; } Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/cachesup.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/cachesup.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/cachesup.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -14,7 +14,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -94,7 +94,7 @@ // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Create the internal stream. The Vpb should be pointing at our volume @@ -272,7 +272,7 @@ } } - } finally { + } _SEH2_FINALLY { // // Cleanup any dirent structures we may have used. @@ -306,7 +306,7 @@ } CdUnlockFcb( IrpContext, Fcb ); - } + } _SEH2_END return; } Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/cddata.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/cddata.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/cddata.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -17,7 +17,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" #ifdef CD_SANITY BOOLEAN CdTestTopLevel = TRUE; @@ -259,7 +259,7 @@ // Use a try-except to handle the exception cases. // - try { + _SEH2_TRY { // // If the IrpContext is NULL then this is the first pass through @@ -398,10 +398,10 @@ CdCompleteRequest( IrpContext, Irp, Status ); } - } except( CdExceptionFilter( IrpContext, GetExceptionInformation() )) { - - Status = CdProcessException( IrpContext, Irp, GetExceptionCode() ); - } + } _SEH2_EXCEPT( CdExceptionFilter( IrpContext, _exception_info() )) { + + Status = CdProcessException( IrpContext, Irp, _exception_code() ); + } _SEH2_END } while (Status == STATUS_CANT_WAIT); @@ -653,7 +653,7 @@ // Note that (children of) CdFsdPostRequest can raise (Mdl allocation). // - try { + _SEH2_TRY { if (ExceptionCode == STATUS_CANT_WAIT) { @@ -670,10 +670,10 @@ } } } - except( CdExceptionFilter( IrpContext, GetExceptionInformation() )) { + _SEH2_EXCEPT( CdExceptionFilter( IrpContext, _exception_info() )) { - ExceptionCode = GetExceptionCode(); - } + ExceptionCode = _exception_code(); + } _SEH2_END // // If we posted the request or our caller will retry then just return here. Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/cdinit.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/cdinit.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/cdinit.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -13,7 +13,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/cdprocs.h URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/cdprocs.h [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/cdprocs.h [iso-8859-1] Mon May 23 20:07:45 2016 @@ -28,9 +28,11 @@ #endif #include "nodetype.h" -#include "Cd.h" -#include "CdStruc.h" -#include "CdData.h" +#include "cd.h" +#include "cdstruc.h" +#include "cddata.h" + +#include <pseh/pseh2.h> //**** x86 compiler bug **** @@ -44,30 +46,28 @@ // Here are the different pool tags. // -/* ReactOS Change: GCC doesn't understand this, use TAG macro */ -#include <reactos/helper.h> -#define TAG_CCB TAG('c','c','d','C') // Ccb -#define TAG_CDROM_TOC TAG('c','t','d','C') // TOC -#define TAG_DIRENT_NAME TAG('n','d','d','C') // CdName in dirent -#define TAG_ENUM_EXPRESSION TAG('e','e','d','C') // Search expression for enumeration -#define TAG_FCB_DATA TAG('d','f','d','C') // Data Fcb -#define TAG_FCB_INDEX TAG('i','f','d','C') // Index Fcb -#define TAG_FCB_NONPAGED TAG('n','f','d','C') // Nonpaged Fcb -#define TAG_FCB_TABLE TAG('t','f','d','C') // Fcb Table entry -#define TAG_FILE_NAME TAG('n','F','d','C') // Filename buffer -#define TAG_GEN_SHORT_NAME TAG('s','g','d','C') // Generated short name -#define TAG_IO_BUFFER TAG('f','b','d','C') // Temporary IO buffer -#define TAG_IO_CONTEXT TAG('o','i','d','C') // Io context for async reads -#define TAG_IRP_CONTEXT TAG('c','i','d','C') // Irp Context -#define TAG_IRP_CONTEXT_LITE TAG('l','i','d','C') // Irp Context lite -#define TAG_MCB_ARRAY TAG('a','m','d','C') // Mcb array -#define TAG_PATH_ENTRY_NAME TAG('n','P','d','C') // CdName in path entry -#define TAG_PREFIX_ENTRY TAG('e','p','d','C') // Prefix Entry -#define TAG_PREFIX_NAME TAG('n','p','d','C') // Prefix Entry name -#define TAG_SPANNING_PATH_TABLE TAG('p','s','d','C') // Buffer for spanning path table -#define TAG_UPCASE_NAME TAG('n','u','d','C') // Buffer for upcased name -#define TAG_VOL_DESC TAG('d','v','d','C') // Buffer for volume descriptor -#define TAG_VPB TAG('p','v','d','C') // Vpb allocated in filesystem +#define TAG_CCB 'ccdC' // Ccb +#define TAG_CDROM_TOC 'ctdC' // TOC +#define TAG_DIRENT_NAME 'nddC' // CdName in dirent +#define TAG_ENUM_EXPRESSION 'eedC' // Search expression for enumeration +#define TAG_FCB_DATA 'dfdC' // Data Fcb +#define TAG_FCB_INDEX 'ifdC' // Index Fcb +#define TAG_FCB_NONPAGED 'nfdC' // Nonpaged Fcb +#define TAG_FCB_TABLE 'tfdC' // Fcb Table entry +#define TAG_FILE_NAME 'nFdC' // Filename buffer +#define TAG_GEN_SHORT_NAME 'sgdC' // Generated short name +#define TAG_IO_BUFFER 'fbdC' // Temporary IO buffer +#define TAG_IO_CONTEXT 'oidC' // Io context for async reads +#define TAG_IRP_CONTEXT 'cidC' // Irp Context +#define TAG_IRP_CONTEXT_LITE 'lidC' // Irp Context lite +#define TAG_MCB_ARRAY 'amdC' // Mcb array +#define TAG_PATH_ENTRY_NAME 'nPdC' // CdName in path entry +#define TAG_PREFIX_ENTRY 'epdC' // Prefix Entry +#define TAG_PREFIX_NAME 'npdC' // Prefix Entry name +#define TAG_SPANNING_PATH_TABLE 'psdC' // Buffer for spanning path table +#define TAG_UPCASE_NAME 'nudC' // Buffer for upcased name +#define TAG_VOL_DESC 'dvdC' // Buffer for volume descriptor +#define TAG_VPB 'pvdC' // Vpb allocated in filesystem // // Tag all of our allocations if tagging is turned on @@ -1883,16 +1883,9 @@ // // #define try_return(S) { S; goto try_exit; } // -/* ReactOS Change: Remove SEH */ -#define try -#define leave goto exitLabel; -#define finally if (0) goto exitLabel; exitLabel: -#define except(x) while (0) -#define GetExceptionCode() 0 -#define AbnormalTermination() 0 - -#define try_return(S) { goto try_exit; } -#define try_leave(S) { leave; } + +#define try_return(S) {S; goto try_exit; } +#define try_leave(S) {S; _SEH2_LEAVE; } // Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/cleanup.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/cleanup.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/cleanup.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -14,7 +14,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -159,7 +159,7 @@ // Use a try-finally to facilitate cleanup. // - //try { /* ReactOS Change: Manual removal of SEH since macros to hack around it don't allow multiple SEH usage within one function */ + _SEH2_TRY { // // Case on the type of open that we are trying to cleanup. @@ -279,7 +279,7 @@ IoRemoveShareAccess( FileObject, &Fcb->ShareAccess ); - //} finally { /* ReactOS Change: Manual removal of SEH since macros to hack around it don't allow multiple SEH usage within one function */ + } _SEH2_FINALLY { CdReleaseFcb( IrpContext, Fcb ); @@ -287,7 +287,7 @@ FsRtlNotifyVolumeEvent( FileObject, FSRTL_VOLUME_UNLOCK ); } - //} /* ReactOS Change: Manual removal of SEH since macros to hack around it don't allow multiple SEH usage within one function */ + } _SEH2_END // // If appropriate, try to spark teardown by purging the volume. Should @@ -305,19 +305,19 @@ CdAcquireCdData( IrpContext); - try { + _SEH2_TRY { CdAcquireVcbExclusive( IrpContext, Vcb, FALSE ); VcbAcquired = TRUE; CdPurgeVolume( IrpContext, Vcb, FALSE ); - } finally { + } _SEH2_FINALLY { if (VcbAcquired) { CdReleaseVcb( IrpContext, Vcb ); } CdReleaseCdData( IrpContext); - } + } _SEH2_END } // Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/close.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/close.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/close.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -42,7 +42,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/create.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/create.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/create.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -14,7 +14,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -222,13 +222,15 @@ PAGED_CODE(); + DbgPrint("CdCommonCreate(%p)\n", IrpSp->FileObject); + // // If we were called with our file system device object instead of a // volume device object, just complete this request with STATUS_SUCCESS. // if (IrpContext->Vcb == NULL) { - + DbgPrint("IrpContext->Vcb == NULL\n"); CdCompleteRequest( IrpContext, Irp, STATUS_SUCCESS ); return STATUS_SUCCESS; } @@ -315,7 +317,7 @@ // in the IrpContext will indicate whether we removed the // backslash. // - + DbgPrint("Avant CdNormalizeFileNames.\n"); Status = CdNormalizeFileNames( IrpContext, Vcb, OpenByFileId, @@ -357,7 +359,7 @@ // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Verify that the Vcb is not in an unusable condition. This routine @@ -490,6 +492,7 @@ if (RemainingName.FileName.Length == 0) { + DbgPrint("RemainingName.FileName.Length == 0\n"); // // If this is a file so verify the user didn't want to open // a directory. @@ -499,7 +502,7 @@ if (FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_TRAIL_BACKSLASH ) || FlagOn( IrpSp->Parameters.Create.Options, FILE_DIRECTORY_FILE )) { - + DbgPrint("STATUS_NOT_A_DIRECTORY.\n"); try_return( Status = STATUS_NOT_A_DIRECTORY ); } @@ -574,7 +577,7 @@ // if (!FlagOn( IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT )) { - + DbgPrint("IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT\n"); CdRaiseStatus( IrpContext, STATUS_CANT_WAIT ); } @@ -584,6 +587,7 @@ FinalName.VersionString.Length = 0; + DbgPrint("Avant la boucle.\n"); while (TRUE) { ShortNameMatch = FALSE; @@ -761,7 +765,7 @@ try_return( Status = STATUS_ACCESS_DENIED ); } - + DbgPrint("CdOpenDirectoryFromPathEntry\n"); try_return( Status = CdOpenDirectoryFromPathEntry( IrpContext, IrpSp, Vcb, @@ -792,6 +796,7 @@ CdCleanupCompoundPathEntry( IrpContext, &CompoundPathEntry ); CleanupCompoundPathEntry = FALSE; } + DbgPrint("Apres la boucle.\n"); // // We need to scan the current directory for a matching file name @@ -890,6 +895,7 @@ // first and last dirents. // + DbgPrint("Avant CdOpenFileFromFileContext.\n"); try_return( Status = CdOpenFileFromFileContext( IrpContext, IrpSp, Vcb, @@ -901,7 +907,7 @@ RelatedCcb )); try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { // // Cleanup the PathEntry if initialized. @@ -926,7 +932,7 @@ // condition. // - if (AbnormalTermination()) { + if (_abnormal_termination()) { // @@ -985,7 +991,7 @@ // CdCompleteRequest( IrpContext, Irp, Status ); - } + } _SEH2_END return Status; } @@ -1508,11 +1514,13 @@ RtlCopyMemory( &FileId, IrpSp->FileObject->FileName.Buffer, sizeof( FILE_ID )); + DbgPrint("CdOpenByFileId (%p)", IrpSp->FileObject); + // // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Go ahead and figure out the TypeOfOpen and NodeType. We can @@ -1524,7 +1532,7 @@ TypeOfOpen = UserDirectoryOpen; NodeTypeCode = CDFS_NTC_FCB_INDEX; - // + //CdQueryFidDirentOffset // If the offset isn't zero then the file Id is bad. // @@ -1546,7 +1554,7 @@ // request can't wait. // - CdLockVcb( IrpContext, Vcb ); + CdLockVcb( CdQueryFidDirentOffsetIrpContext, Vcb ); UnlockVcb = TRUE; NextFcb = CdLookupFcbTable( IrpContext, Vcb, FileId ); @@ -1723,7 +1731,7 @@ // if (NextFcb->FileObject == NULL) { - + DbgPrint("NextFcb->FileObject == NULL\n"); CdCreateInternalStream( IrpContext, Vcb, NextFcb ); } @@ -1905,7 +1913,7 @@ } try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { if (UnlockVcb) { @@ -1921,7 +1929,7 @@ CdCleanupCompoundPathEntry( IrpContext, &CompoundPathEntry ); } - } + } _SEH2_END return Status; } @@ -1977,6 +1985,8 @@ NTSTATUS Status = STATUS_ACCESS_DENIED; PAGED_CODE(); + + DbgPrint("CdOpenExistingFcb(%p)", IrpSp->FileObject); // // Check that the desired access is legal. @@ -2110,6 +2120,8 @@ PAGED_CODE(); + DbgPrint("CdOpenDirectoryFromPathEntry(%p)", IrpSp->FileObject); + // // Check for illegal access to this file. // @@ -2126,7 +2138,7 @@ // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Check the related Ccb to see if this was an OpenByFileId. @@ -2281,7 +2293,7 @@ IrpSp->Parameters.Create.SecurityContext->DesiredAccess ); } - } finally { + } _SEH2_FINALLY { // // Unlock the Vcb if held. @@ -2300,7 +2312,7 @@ CdReleaseFcb( IrpContext, ParentFcb ); } - } + } _SEH2_END return Status; } @@ -2384,6 +2396,8 @@ PAGED_CODE(); + DbgPrint("CdOpenFileFromFileContext(%p)\n", IrpSp); + // // Check for illegal access to this file. // @@ -2399,7 +2413,7 @@ // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Check if a version number was used to open this file. @@ -2569,7 +2583,7 @@ CcbFlags, IrpSp->Parameters.Create.SecurityContext->DesiredAccess ); - } finally { + } _SEH2_FINALLY { // // Unlock the Vcb if held. @@ -2588,7 +2602,7 @@ CdReleaseFcb( IrpContext, ParentFcb ); } - } + } _SEH2_END return Status; } @@ -2652,6 +2666,8 @@ PCCB Ccb; PAGED_CODE(); + + DbgPrint("CdCompleteFcbOpen(%p).\n", IrpSp->FileObject); // // Expand maximum allowed to something sensible for share access checking Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/devctrl.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/devctrl.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/devctrl.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -14,7 +14,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -27,6 +27,7 @@ // NTSTATUS +NTAPI CdDevCtrlCompletionRoutine ( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, @@ -165,12 +166,13 @@ return Status; } - + // // Local support routine // NTSTATUS +NTAPI CdDevCtrlCompletionRoutine ( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/deviosup.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/deviosup.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/deviosup.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -13,7 +13,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -355,7 +355,7 @@ // Use a try-finally to perform the final cleanup. // - try { + _SEH2_TRY { // // Loop while there are more bytes to transfer. @@ -518,7 +518,7 @@ } try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { // // Perform final cleanup on the IoRuns if necessary. @@ -528,7 +528,7 @@ CdFinishBuffers( IrpContext, IoRuns, CleanupRunCount, TRUE, FALSE ); } - } + } _SEH2_END return Status; } @@ -624,7 +624,7 @@ // Use a try-finally to perform the final cleanup. // - try { + _SEH2_TRY { // // If the initial offset lies within the RIFF header then copy the @@ -960,7 +960,7 @@ KeFlushIoBuffers( IrpContext->Irp->MdlAddress, TRUE, FALSE ); try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { // // Perform final cleanup on the IoRuns if necessary. @@ -970,7 +970,7 @@ CdFinishBuffers( IrpContext, IoRuns, CleanupRunCount, TRUE, FALSE ); } - } + } _SEH2_END return Status; } @@ -1176,15 +1176,15 @@ // deallocate the Mdl and return the appropriate "expected" status. // - try { + _SEH2_TRY { MmProbeAndLockPages( Mdl, IrpContext->Irp->RequestorMode, IoWriteAccess ); Status = STATUS_SUCCESS; - } except(EXCEPTION_EXECUTE_HANDLER) { - - Status = GetExceptionCode(); + } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { + + Status = _exception_code(); IoFreeMdl( Mdl ); IrpContext->Irp->MdlAddress = NULL; @@ -1193,7 +1193,7 @@ Status = STATUS_INVALID_USER_BUFFER; } - } + } _SEH2_END } // Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/dirctrl.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/dirctrl.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/dirctrl.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -14,7 +14,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -287,7 +287,7 @@ // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Verify the Fcb is still good. @@ -499,7 +499,7 @@ // such trickery. // - try { + _SEH2_TRY { // // Zero and initialize the base part of the current entry. @@ -715,7 +715,7 @@ LastEntry = NextEntry; NextEntry = QuadAlign( Information ); - } except (EXCEPTION_EXECUTE_HANDLER) { + } _SEH2_EXCEPT (EXCEPTION_EXECUTE_HANDLER) { // // We had a problem filling in the user's buffer, so stop and @@ -724,13 +724,13 @@ // Information = 0; - try_leave( Status = GetExceptionCode()); - } + try_leave( Status = _exception_code()); + } _SEH2_END } DoCcbUpdate = TRUE; - } finally { + } _SEH2_FINALLY { // // Cleanup our search context - *before* aquiring the FCB mutex exclusive, @@ -769,7 +769,7 @@ // CdReleaseFile( IrpContext, Fcb ); - } + } _SEH2_END // // Complete the request here. @@ -837,7 +837,7 @@ // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Verify the Vcb. @@ -862,14 +862,14 @@ NULL, NULL ); - } finally { + } _SEH2_FINALLY { // // Release the Vcb. // CdReleaseVcb( IrpContext, IrpContext->Vcb ); - } + } _SEH2_END // // Cleanup the IrpContext. Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/dirsup.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/dirsup.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/dirsup.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -65,7 +65,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/fieldoff.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/fieldoff.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/fieldoff.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -1,4 +1,4 @@ -#include "CdProcs.h" +#include "cdprocs.h" #include <stdio.h> #define doit(a,b) { printf("%s %04lx %4lx %s\n", #a, FIELD_OFFSET(a,b), sizeof(d.b), #b); } Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/fileinfo.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/fileinfo.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/fileinfo.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -14,7 +14,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -165,7 +165,7 @@ // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // We only support query on file and directory handles. @@ -325,7 +325,7 @@ Irp->IoStatus.Information = IrpSp->Parameters.QueryFile.Length - Length; - } finally { + } _SEH2_FINALLY { // // Release the file. @@ -335,7 +335,7 @@ CdReleaseFile( IrpContext, Fcb ); } - } + } _SEH2_END // // Complete the request if we didn't raise. @@ -406,7 +406,7 @@ CdAcquireFileShared( IrpContext, Fcb ); - try { + _SEH2_TRY { // // Make sure the Fcb is in a usable condition. This @@ -445,10 +445,10 @@ Status = STATUS_SUCCESS; try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { CdReleaseFile( IrpContext, Fcb ); - } + } _SEH2_END // // Complete the request if there was no raise. @@ -536,7 +536,7 @@ // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Only deal with 'good' Fcb's. @@ -566,12 +566,12 @@ Result = TRUE; } - } finally { + } _SEH2_FINALLY { ExReleaseResourceLite( Fcb->Resource ); FsRtlExitFileSystem(); - } + } _SEH2_END return Result; } @@ -654,7 +654,7 @@ // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Only deal with 'good' Fcb's. @@ -694,12 +694,12 @@ Result = TRUE; } - } finally { + } _SEH2_FINALLY { ExReleaseResourceLite( Fcb->Resource ); FsRtlExitFileSystem(); - } + } _SEH2_END return Result; } @@ -782,7 +782,7 @@ // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Only deal with 'good' Fcb's. @@ -827,12 +827,12 @@ Result = TRUE; } - } finally { + } _SEH2_FINALLY { ExReleaseResourceLite( Fcb->Resource ); FsRtlExitFileSystem(); - } + } _SEH2_END return Result; } @@ -1278,7 +1278,7 @@ // Use a try-finally to cleanup the structures. // - try { + _SEH2_TRY { ParentFcb = Fcb->ParentFcb; CdAcquireFileShared( IrpContext, ParentFcb ); @@ -1396,7 +1396,7 @@ RtlCopyMemory( Buffer->FileName, ShortNameBuffer, Buffer->FileNameLength ); try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { if (CleanupFileLookup) { @@ -1413,7 +1413,7 @@ CdReleaseFile( IrpContext, ParentFcb ); } - } + } _SEH2_END // // Reduce the available bytes by the amount stored into this buffer. Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/filobsup.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/filobsup.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/filobsup.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -13,7 +13,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/fsctrl.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/fsctrl.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/fsctrl.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -14,7 +14,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -702,7 +702,7 @@ // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Allocate a buffer to query the TOC. @@ -1019,7 +1019,7 @@ Status = STATUS_SUCCESS; - } finally { + } _SEH2_FINALLY { // // Free the TOC buffer if not in the Vcb. @@ -1043,7 +1043,7 @@ // If we are not mounting the device, then set the verify bit again. // - if ((AbnormalTermination() || (Status != STATUS_SUCCESS)) && + if ((_abnormal_termination() || (Status != STATUS_SUCCESS)) && SetDoVerifyOnFail) { CdMarkRealDevForVerify( IrpContext->RealDevice); @@ -1080,7 +1080,7 @@ // CdReleaseCdData( IrpContext ); - } + } _SEH2_END // // Now send mount notification. @@ -1182,7 +1182,7 @@ CdAcquireCdData( IrpContext ); - try { + _SEH2_TRY { CdAcquireVcbExclusive( IrpContext, Vcb, FALSE ); ReleaseVcb = TRUE; @@ -1506,7 +1506,7 @@ } } - } finally { + } _SEH2_FINALLY { // // Free the TOC buffer if allocated. @@ -1528,7 +1528,7 @@ } CdReleaseCdData( IrpContext ); - } + } _SEH2_END // // Now send mount notification. @@ -1653,7 +1653,7 @@ // Use a try finally to free the Fcb. // - try { + _SEH2_TRY { // // Verify the Fcb. @@ -1683,14 +1683,14 @@ Irp = NULL; - } finally { + } _SEH2_FINALLY { // // Release all of our resources // CdReleaseFcb( IrpContext, Fcb ); - } + } _SEH2_END // // Complete the request if there was no exception. @@ -1765,7 +1765,7 @@ Vcb = Fcb->Vcb; CdAcquireVcbExclusive( IrpContext, Vcb, FALSE ); - try { + _SEH2_TRY { // // Verify the Vcb. @@ -1775,7 +1775,7 @@ Status = CdLockVolumeInternal( IrpContext, Vcb, IrpSp->FileObject ); - } finally { + } _SEH2_FINALLY { // // Release the Vcb. @@ -1783,11 +1783,11 @@ CdReleaseVcb( IrpContext, Vcb ); - if (AbnormalTermination() || !NT_SUCCESS( Status )) { + if (_abnormal_termination() || !NT_SUCCESS( Status )) { FsRtlNotifyVolumeEvent( IrpSp->FileObject, FSRTL_VOLUME_LOCK_FAILED ); } - } + } _SEH2_END // // Complete the request if there haven't been any exceptions. @@ -2295,7 +2295,7 @@ Status = ObReferenceObjectByHandle( Handle, 0, - IoFileObjectType, /* ReactOS Change: GCC/LD Incompatibily with exported kernel data */ + *IoFileObjectType, KernelMode, (PVOID*)&FileToMarkBad, /* ReactOS Change: GCC "passing argument 5 of 'ObReferenceObjectByHandle' from incompatible pointer type" */ NULL ); @@ -2591,7 +2591,7 @@ // Check for whether this device supports XA and multi-session. // - try { + _SEH2_TRY { // // Allocate a buffer for the last session information. @@ -2669,10 +2669,10 @@ ThisPass += 1; } - } finally { + } _SEH2_FINALLY { if (CdromToc != NULL) { CdFreePool( &CdromToc ); } - } + } _SEH2_END } // Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/fspdisp.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/fspdisp.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/fspdisp.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -14,7 +14,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -94,7 +94,7 @@ while (TRUE) { - try { + _SEH2_TRY { // // Reinitialize for the next try at completing this @@ -184,10 +184,10 @@ CdCompleteRequest( IrpContext, Irp, Status ); } - } except( CdExceptionFilter( IrpContext, GetExceptionInformation() )) { - - Status = CdProcessException( IrpContext, Irp, GetExceptionCode() ); - } + } _SEH2_EXCEPT( CdExceptionFilter( IrpContext, _exception_info() )) { + + Status = CdProcessException( IrpContext, Irp, _exception_code() ); + } _SEH2_END // // Break out of the loop if we didn't get CANT_WAIT. Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/lockctrl.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/lockctrl.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/lockctrl.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -14,7 +14,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -224,7 +224,7 @@ // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // We check whether we can proceed based on the state of the file oplocks. @@ -275,10 +275,10 @@ } try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { FsRtlExitFileSystem(); - } + } _SEH2_END return Results; } @@ -366,7 +366,7 @@ FsRtlEnterFileSystem(); - try { + _SEH2_TRY { // // We check whether we can proceed based on the state of the file oplocks. @@ -416,10 +416,10 @@ } try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { FsRtlExitFileSystem(); - } + } _SEH2_END return Results; } @@ -498,7 +498,7 @@ FsRtlEnterFileSystem(); - try { + _SEH2_TRY { // // We check whether we can proceed based on the state of the file oplocks. @@ -539,10 +539,10 @@ CdUnlockFcb( IrpContext, Fcb ); try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { FsRtlExitFileSystem(); - } + } _SEH2_END return Results; } @@ -624,7 +624,7 @@ FsRtlEnterFileSystem(); - try { + _SEH2_TRY { // // We check whether we can proceed based on the state of the file oplocks. @@ -666,10 +666,10 @@ CdUnlockFcb( IrpContext, Fcb ); try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { FsRtlExitFileSystem(); - } + } _SEH2_END return Results; } Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/namesup.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/namesup.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/namesup.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -13,7 +13,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/nodetype.h URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/nodetype.h [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/nodetype.h [iso-8859-1] Mon May 23 20:07:45 2016 @@ -97,8 +97,6 @@ #define CDFS_BUG_CHECK_VOLINFO (0x001b0000) #define CDFS_BUG_CHECK_WORKQUE (0x001c0000) -/* ReactOS Change: Need to add to reactos.mc */ -#define CDFS_FILE_SYSTEM ((ULONG)0x00000026L) #define CdBugCheck(A,B,C) { KeBugCheckEx(CDFS_FILE_SYSTEM, BugCheckFileId | __LINE__, A, B, C ); } #endif // _NODETYPE_ Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/pathsup.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/pathsup.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/pathsup.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -73,7 +73,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/pnp.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/pnp.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/pnp.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -14,7 +14,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -51,6 +51,7 @@ ); NTSTATUS +NTAPI CdPnpCompletionRoutine ( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, @@ -774,6 +775,7 @@ // NTSTATUS +NTAPI CdPnpCompletionRoutine ( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/prefxsup.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/prefxsup.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/prefxsup.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -13,7 +13,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/read.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/read.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/read.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -14,7 +14,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -35,11 +35,11 @@ // #define SafeZeroMemory(IC,AT,BYTE_COUNT) { \ - try { \ + _SEH2_TRY { \ RtlZeroMemory( (AT), (BYTE_COUNT) ); \ - } except( EXCEPTION_EXECUTE_HANDLER ) { \ + } _SEH2_EXCEPT( EXCEPTION_EXECUTE_HANDLER ) { \ CdRaiseStatus( IC, STATUS_INVALID_USER_BUFFER ); \ - } \ + } _SEH2_END \ } // @@ -180,7 +180,7 @@ // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Verify the Fcb. Allow reads if this is a DASD handle that is @@ -515,7 +515,7 @@ } try_exit: NOTHING; - } finally { + } _SEH2_FINALLY { // // Release the Fcb. @@ -525,7 +525,7 @@ CdReleaseFile( IrpContext, Fcb ); } - } + } _SEH2_END // // Post the request if we got CANT_WAIT. Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/resrcsup.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/resrcsup.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/resrcsup.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -13,7 +13,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/strucsup.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/strucsup.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/strucsup.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -14,7 +14,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -298,19 +298,19 @@ // uninitialize the notify structures before returning. // - try { + _SEH2_TRY { Vcb->SwapVpb = FsRtlAllocatePoolWithTag( NonPagedPool, sizeof( VPB ), TAG_VPB ); } - finally { - - if (AbnormalTermination()) { + _SEH2_FINALLY { + + if (_abnormal_termination()) { FsRtlNotifyUninitializeSync( &Vcb->NotifySync ); } - } + } _SEH2_END // // Nothing beyond this point should raise. @@ -456,7 +456,7 @@ // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Copy the block size and compute the various block masks. @@ -843,10 +843,10 @@ SetFlag( Vcb->VcbState, VCB_STATE_ISO ); } - } finally { + } _SEH2_FINALLY { if (UnlockVcb) { CdUnlockVcb( IrpContext, Vcb ); } - } + } _SEH2_END } @@ -1238,7 +1238,7 @@ CdLockFcb( IrpContext, Fcb ); - try { + _SEH2_TRY { // // Initialize the common header in the Fcb. The node type is already @@ -1361,10 +1361,10 @@ CdInsertFcbTable( IrpContext, Fcb ); SetFlag( Fcb->FcbState, FCB_STATE_IN_FCB_TABLE ); - } finally { + } _SEH2_FINALLY { CdUnlockFcb( IrpContext, Fcb ); - } + } _SEH2_END return; } @@ -1927,7 +1927,7 @@ // Use a try-finally to safely clear the top-level field. // - try { + _SEH2_TRY { // // Loop until we find an Fcb we can't remove. @@ -2031,7 +2031,7 @@ } while (CurrentFcb != NULL); - } finally { + } _SEH2_FINALLY { // // Release the current Fcb if we have acquired it. @@ -2047,7 +2047,7 @@ // ClearFlag( IrpContext->TopLevel->Flags, IRP_CONTEXT_FLAG_IN_TEARDOWN ); - } + } _SEH2_END *RemovedStartingFcb = (CurrentFcb != StartingFcb); return; Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/verfysup.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/verfysup.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/verfysup.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -13,7 +13,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -92,7 +92,7 @@ Vcb = &CONTAINING_RECORD( IrpSp->DeviceObject, VOLUME_DEVICE_OBJECT, DeviceObject )->Vcb; - try { + _SEH2_TRY { // // Send down the verify FSCTL. Note that this is sent to the @@ -206,7 +206,7 @@ Status = CdFsdPostRequest( IrpContext, Irp ); } - } except(CdExceptionFilter( IrpContext, GetExceptionInformation() )) { + } _SEH2_EXCEPT(CdExceptionFilter( IrpContext, _exception_info() )) { // // We had some trouble trying to perform the verify or raised @@ -214,8 +214,8 @@ // the error status that we get back from the execption code. // - Status = CdProcessException( IrpContext, Irp, GetExceptionCode() ); - } + Status = CdProcessException( IrpContext, Irp, _exception_code() ); + } _SEH2_END return Status; } Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/volinfo.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/volinfo.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/volinfo.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -14,7 +14,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module @@ -130,7 +130,7 @@ // Use a try-finally to facilitate cleanup. // - try { + _SEH2_TRY { // // Verify the Vcb. @@ -177,14 +177,14 @@ Irp->IoStatus.Information = IrpSp->Parameters.QueryVolume.Length - Length; - } finally { + } _SEH2_FINALLY { // // Release the Vcb. // CdReleaseVcb( IrpContext, Fcb->Vcb ); - } + } _SEH2_END // // Complete the request if we didn't raise. Modified: branches/TransitionPte/drivers/filesystems/cdfs_new/workque.c URL:
http://svn.reactos.org/svn/reactos/branches/TransitionPte/drivers/filesyste…
============================================================================== --- branches/TransitionPte/drivers/filesystems/cdfs_new/workque.c [iso-8859-1] (original) +++ branches/TransitionPte/drivers/filesystems/cdfs_new/workque.c [iso-8859-1] Mon May 23 20:07:45 2016 @@ -14,7 +14,7 @@ --*/ -#include "CdProcs.h" +#include "cdprocs.h" // // The Bug check file id for this module
8 years, 7 months
1
0
0
0
[pschweitzer] 71387: [NTOSKRNL] In Cc, replace the Vacb mutex by a Bcb resource. Note that the resource is still placed in the Vacb by it belongs to the Bcb. This is required to really implement Cc...
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Mon May 23 19:47:39 2016 New Revision: 71387 URL:
http://svn.reactos.org/svn/reactos?rev=71387&view=rev
Log: [NTOSKRNL] In Cc, replace the Vacb mutex by a Bcb resource. Note that the resource is still placed in the Vacb by it belongs to the Bcb. This is required to really implement CcSetBcbOwnerPointer(). CORE-11310 Modified: trunk/reactos/ntoskrnl/cc/pin.c trunk/reactos/ntoskrnl/cc/view.c trunk/reactos/ntoskrnl/include/internal/cc.h trunk/reactos/ntoskrnl/mm/section.c Modified: trunk/reactos/ntoskrnl/cc/pin.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/pin.c?rev=7138…
============================================================================== --- trunk/reactos/ntoskrnl/cc/pin.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cc/pin.c [iso-8859-1] Mon May 23 19:47:39 2016 @@ -290,11 +290,7 @@ IoStatus->Information = 0; if (WriteThrough) { - KeWaitForSingleObject(&iBcb->Vacb->Mutex, - Executive, - KernelMode, - FALSE, - NULL); + ExAcquireResourceExclusiveLite(&iBcb->Vacb->Lock, TRUE); if (iBcb->Vacb->Dirty) { IoStatus->Status = CcRosFlushVacb(iBcb->Vacb); @@ -303,7 +299,7 @@ { IoStatus->Status = STATUS_SUCCESS; } - KeReleaseMutex(&iBcb->Vacb->Mutex, FALSE); + ExReleaseResourceLite(&iBcb->Vacb->Lock); } else { Modified: trunk/reactos/ntoskrnl/cc/view.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/view.c?rev=713…
============================================================================== --- trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] Mon May 23 19:47:39 2016 @@ -166,12 +166,10 @@ PROS_VACB current; BOOLEAN Locked; NTSTATUS Status; - LARGE_INTEGER ZeroTimeout; DPRINT("CcRosFlushDirtyPages(Target %lu)\n", Target); (*Count) = 0; - ZeroTimeout.QuadPart = 0; KeEnterCriticalRegion(); KeAcquireGuardedMutex(&ViewLock); @@ -199,12 +197,8 @@ continue; } - Status = KeWaitForSingleObject(¤t->Mutex, - Executive, - KernelMode, - FALSE, - Wait ? NULL : &ZeroTimeout); - if (Status != STATUS_SUCCESS) + Locked = ExAcquireResourceExclusiveLite(¤t->Lock, Wait); + if (!Locked) { current->SharedCacheMap->Callbacks->ReleaseFromLazyWrite( current->SharedCacheMap->LazyWriteContext); @@ -217,7 +211,7 @@ /* One reference is added above */ if (current->ReferenceCount > 2) { - KeReleaseMutex(¤t->Mutex, FALSE); + ExReleaseResourceLite(¤t->Lock); current->SharedCacheMap->Callbacks->ReleaseFromLazyWrite( current->SharedCacheMap->LazyWriteContext); CcRosVacbDecRefCount(current); @@ -228,7 +222,7 @@ Status = CcRosFlushVacb(current); - KeReleaseMutex(¤t->Mutex, FALSE); + ExReleaseResourceLite(¤t->Lock); current->SharedCacheMap->Callbacks->ReleaseFromLazyWrite( current->SharedCacheMap->LazyWriteContext); @@ -425,7 +419,7 @@ KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql); KeReleaseGuardedMutex(&ViewLock); - KeReleaseMutex(&Vacb->Mutex, FALSE); + ExReleaseResourceLite(&Vacb->Lock); return STATUS_SUCCESS; } @@ -462,11 +456,7 @@ CcRosVacbIncRefCount(current); KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql); KeReleaseGuardedMutex(&ViewLock); - KeWaitForSingleObject(¤t->Mutex, - Executive, - KernelMode, - FALSE, - NULL); + ExAcquireResourceExclusiveLite(¤t->Lock, TRUE); return current; } if (current->FileOffset.QuadPart > FileOffset) @@ -521,7 +511,7 @@ KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql); KeReleaseGuardedMutex(&ViewLock); - KeReleaseMutex(&Vacb->Mutex, FALSE); + ExReleaseResourceLite(&Vacb->Lock); return STATUS_SUCCESS; } @@ -574,7 +564,7 @@ KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql); KeReleaseGuardedMutex(&ViewLock); - KeReleaseMutex(&Vacb->Mutex, FALSE); + ExReleaseResourceLite(&Vacb->Lock); return STATUS_SUCCESS; } @@ -675,12 +665,8 @@ current->DirtyVacbListEntry.Flink = NULL; current->DirtyVacbListEntry.Blink = NULL; current->ReferenceCount = 1; - KeInitializeMutex(¤t->Mutex, 0); - KeWaitForSingleObject(¤t->Mutex, - Executive, - KernelMode, - FALSE, - NULL); + ExInitializeResourceLite(¤t->Lock); + ExAcquireResourceExclusiveLite(¤t->Lock, TRUE); KeAcquireGuardedMutex(&ViewLock); *Vacb = current; @@ -712,15 +698,11 @@ current); } #endif - KeReleaseMutex(&(*Vacb)->Mutex, FALSE); + ExReleaseResourceLite(&(*Vacb)->Lock); KeReleaseGuardedMutex(&ViewLock); ExFreeToNPagedLookasideList(&VacbLookasideList, *Vacb); *Vacb = current; - KeWaitForSingleObject(¤t->Mutex, - Executive, - KernelMode, - FALSE, - NULL); + ExAcquireResourceExclusiveLite(¤t->Lock, TRUE); return STATUS_SUCCESS; } if (current->FileOffset.QuadPart < FileOffset) @@ -886,6 +868,7 @@ CcFreeCachePage, NULL); MmUnlockAddressSpace(MmGetKernelAddressSpace()); + ExDeleteResourceLite(&Vacb->Lock); ExFreeToNPagedLookasideList(&VacbLookasideList, Vacb); return STATUS_SUCCESS; @@ -949,7 +932,7 @@ IoStatus->Status = Status; } } - KeReleaseMutex(¤t->Mutex, FALSE); + ExReleaseResourceLite(¤t->Lock); KeAcquireGuardedMutex(&ViewLock); KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &oldIrql); Modified: trunk/reactos/ntoskrnl/include/internal/cc.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/cc.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/cc.h [iso-8859-1] Mon May 23 19:47:39 2016 @@ -164,6 +164,8 @@ PVOID BaseAddress; /* Memory area representing the region where the view's data is mapped. */ struct _MEMORY_AREA* MemoryArea; + /* Lock */ + ERESOURCE Lock; /* Are the contents of the view valid. */ BOOLEAN Valid; /* Are the contents of the view newer than those on disk. */ @@ -179,8 +181,6 @@ LIST_ENTRY VacbLruListEntry; /* Offset in the file which this view maps. */ LARGE_INTEGER FileOffset; - /* Mutex */ - KMUTEX Mutex; /* Number of references. */ ULONG ReferenceCount; /* Pointer to the shared cache map for the file which this view maps data for. */ Modified: trunk/reactos/ntoskrnl/mm/section.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] Mon May 23 19:47:39 2016 @@ -1110,6 +1110,7 @@ * filesystems do because it is safe for us to use an offset with an * alignment less than the file system block size. */ + KeEnterCriticalRegion(); Status = CcRosGetVacb(SharedCacheMap, FileOffset, &BaseOffset, @@ -1118,6 +1119,7 @@ &Vacb); if (!NT_SUCCESS(Status)) { + KeLeaveCriticalRegion(); return(Status); } if (!UptoDate) @@ -1130,6 +1132,7 @@ if (!NT_SUCCESS(Status)) { CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE); + KeLeaveCriticalRegion(); return Status; } } @@ -1144,6 +1147,7 @@ FileOffset - BaseOffset).LowPart >> PAGE_SHIFT; CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, TRUE); + KeLeaveCriticalRegion(); } else { @@ -1163,6 +1167,7 @@ { return(Status); } + KeEnterCriticalRegion(); Status = CcRosGetVacb(SharedCacheMap, FileOffset, &BaseOffset, @@ -1171,6 +1176,7 @@ &Vacb); if (!NT_SUCCESS(Status)) { + KeLeaveCriticalRegion(); return(Status); } if (!UptoDate) @@ -1183,6 +1189,7 @@ if (!NT_SUCCESS(Status)) { CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE); + KeLeaveCriticalRegion(); return Status; } } @@ -1212,6 +1219,7 @@ &Vacb); if (!NT_SUCCESS(Status)) { + KeLeaveCriticalRegion(); return(Status); } if (!UptoDate) @@ -1224,6 +1232,7 @@ if (!NT_SUCCESS(Status)) { CcRosReleaseVacb(SharedCacheMap, Vacb, FALSE, FALSE, FALSE); + KeLeaveCriticalRegion(); return Status; } } @@ -1239,6 +1248,7 @@ } MiUnmapPageInHyperSpace(Process, PageAddr, Irql); CcRosReleaseVacb(SharedCacheMap, Vacb, TRUE, FALSE, FALSE); + KeLeaveCriticalRegion(); } return(STATUS_SUCCESS); } @@ -3232,10 +3242,12 @@ BufferSize = PAGE_ROUND_UP(BufferSize); /* Flush data since we're about to perform a non-cached read */ + KeEnterCriticalRegion(); CcFlushCache(FileObject->SectionObjectPointer, &FileOffset, BufferSize, &Iosb); + KeLeaveCriticalRegion(); /* * It's ok to use paged pool, because this is a temporary buffer only used in
8 years, 7 months
1
0
0
0
[ekohl] 71386: [SERVICES] RCreateServiceW: Store a given password as a secret.
by ekohl@svn.reactos.org
Author: ekohl Date: Mon May 23 15:02:37 2016 New Revision: 71386 URL:
http://svn.reactos.org/svn/reactos?rev=71386&view=rev
Log: [SERVICES] RCreateServiceW: Store a given password as a secret. Modified: trunk/reactos/base/system/services/config.c trunk/reactos/base/system/services/rpcserver.c trunk/reactos/base/system/services/services.h Modified: trunk/reactos/base/system/services/config.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/confi…
============================================================================== --- trunk/reactos/base/system/services/config.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/config.c [iso-8859-1] Mon May 23 15:02:37 2016 @@ -10,6 +10,7 @@ /* INCLUDES *****************************************************************/ #include "services.h" +#include <ntsecapi.h> #define NDEBUG #include <debug.h> @@ -443,4 +444,58 @@ return ERROR_SUCCESS; } + +DWORD +ScmSetServicePassword( + IN PCWSTR pszServiceName, + IN PCWSTR pszPassword) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + LSA_HANDLE PolicyHandle = NULL; + UNICODE_STRING ServiceName = {0, 0, NULL}; + UNICODE_STRING Password; + NTSTATUS Status; + DWORD dwError = ERROR_SUCCESS; + + RtlZeroMemory(&ObjectAttributes, sizeof(OBJECT_ATTRIBUTES)); + + Status = LsaOpenPolicy(NULL, + &ObjectAttributes, + POLICY_CREATE_SECRET, + &PolicyHandle); + if (!NT_SUCCESS(Status)) + return RtlNtStatusToDosError(Status); + + ServiceName.Length = (wcslen(pszServiceName) + 4) * sizeof(WCHAR); + ServiceName.MaximumLength = ServiceName.Length + sizeof(WCHAR); + ServiceName.Buffer = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + ServiceName.MaximumLength); + if (ServiceName.Buffer == NULL) + return ERROR_NOT_ENOUGH_MEMORY; + + wcscpy(ServiceName.Buffer, L"_SC_"); + wcscat(ServiceName.Buffer, pszServiceName); + + RtlInitUnicodeString(&Password, pszPassword); + + Status = LsaStorePrivateData(PolicyHandle, + &ServiceName, + &Password); + if (!NT_SUCCESS(Status)) + { + dwError = RtlNtStatusToDosError(Status); + goto done; + } + +done: + if (ServiceName.Buffer != NULL) + HeapFree(GetProcessHeap(), 0, ServiceName.Buffer); + + if (PolicyHandle != NULL) + LsaClose(PolicyHandle); + + return dwError; +} + /* EOF */ Modified: trunk/reactos/base/system/services/rpcserver.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/rpcse…
============================================================================== --- trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] Mon May 23 15:02:37 2016 @@ -2323,6 +2323,7 @@ goto done; } + /* Set the service tag */ if (lpdwTagId != NULL) { dwError = RegSetValueExW(hServiceKey, @@ -2345,9 +2346,10 @@ goto done; } - /* Write service start name */ + /* Start name and password are only used by Win32 services */ if (dwServiceType & SERVICE_WIN32) { + /* Write service start name */ lpObjectName = (lpServiceStartName != NULL) ? (LPWSTR)lpServiceStartName : L"LocalSystem"; dwError = RegSetValueExW(hServiceKey, L"ObjectName", @@ -2357,11 +2359,17 @@ (DWORD)((wcslen(lpObjectName) + 1) * sizeof(WCHAR))); if (dwError != ERROR_SUCCESS) goto done; - } - - if (lpPassword != NULL) - { - /* FIXME: Decrypt and write password */ + + if (lpPassword != NULL && wcslen((LPWSTR)lpPassword) != 0) + { + /* FIXME: Decrypt the password */ + + /* Write the password */ + dwError = ScmSetServicePassword(lpServiceName, + (LPCWSTR)lpPassword); + if (dwError != ERROR_SUCCESS) + goto done; + } } dwError = ScmCreateServiceHandle(lpService, Modified: trunk/reactos/base/system/services/services.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servi…
============================================================================== --- trunk/reactos/base/system/services/services.h [iso-8859-1] (original) +++ trunk/reactos/base/system/services/services.h [iso-8859-1] Mon May 23 15:02:37 2016 @@ -126,6 +126,10 @@ LPWSTR *lpDependencies, DWORD *lpdwDependenciesLength); +DWORD +ScmSetServicePassword( + IN PCWSTR pszServiceName, + IN PCWSTR pszPassword); /* controlset.c */
8 years, 7 months
1
0
0
0
[ekohl] 71385: [ADVAPI32] Implement LogonUserEx[A/W].
by ekohl@svn.reactos.org
Author: ekohl Date: Mon May 23 13:53:24 2016 New Revision: 71385 URL:
http://svn.reactos.org/svn/reactos?rev=71385&view=rev
Log: [ADVAPI32] Implement LogonUserEx[A/W]. Modified: trunk/reactos/dll/win32/advapi32/advapi32.spec trunk/reactos/dll/win32/advapi32/misc/logon.c trunk/reactos/sdk/include/psdk/winbase.h Modified: trunk/reactos/dll/win32/advapi32/advapi32.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/advapi3…
============================================================================== --- trunk/reactos/dll/win32/advapi32/advapi32.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/advapi32.spec [iso-8859-1] Mon May 23 13:53:24 2016 @@ -322,8 +322,8 @@ 322 stdcall IsWellKnownSid(ptr long) 323 stdcall LockServiceDatabase(ptr) 324 stdcall LogonUserA(str str str long long ptr) -325 stub LogonUserExA -326 stub LogonUserExW +325 stdcall LogonUserExA(str str str long long ptr ptr ptr ptr ptr) +326 stdcall LogonUserExW(wstr wstr wstr long long ptr ptr ptr ptr ptr) 327 stdcall LogonUserW(wstr wstr wstr long long ptr) 328 stdcall LookupAccountNameA(str str ptr ptr ptr ptr ptr) 329 stdcall LookupAccountNameW(wstr wstr ptr ptr ptr ptr ptr) Modified: trunk/reactos/dll/win32/advapi32/misc/logon.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/misc/lo…
============================================================================== --- trunk/reactos/dll/win32/advapi32/misc/logon.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/misc/logon.c [iso-8859-1] Mon May 23 13:53:24 2016 @@ -221,16 +221,49 @@ return TRUE; } + /* * @implemented */ -BOOL WINAPI -LogonUserA(LPSTR lpszUsername, - LPSTR lpszDomain, - LPSTR lpszPassword, - DWORD dwLogonType, - DWORD dwLogonProvider, - PHANDLE phToken) +BOOL +WINAPI +LogonUserA( + _In_ LPSTR lpszUsername, + _In_opt_ LPSTR lpszDomain, + _In_opt_ LPSTR lpszPassword, + _In_ DWORD dwLogonType, + _In_ DWORD dwLogonProvider, + _Out_opt_ PHANDLE phToken) +{ + return LogonUserExA(lpszUsername, + lpszDomain, + lpszPassword, + dwLogonType, + dwLogonProvider, + phToken, + NULL, + NULL, + NULL, + NULL); +} + + +/* + * @implemented + */ +BOOL +WINAPI +LogonUserExA( + _In_ LPSTR lpszUsername, + _In_opt_ LPSTR lpszDomain, + _In_opt_ LPSTR lpszPassword, + _In_ DWORD dwLogonType, + _In_ DWORD dwLogonProvider, + _Out_opt_ PHANDLE phToken, + _Out_opt_ PSID *ppLogonSid, + _Out_opt_ PVOID *ppProfileBuffer, + _Out_opt_ LPDWORD pdwProfileLength, + _Out_opt_ PQUOTA_LIMITS pQuotaLimits) { UNICODE_STRING UserName; UNICODE_STRING Domain; @@ -259,12 +292,16 @@ goto PasswordDone; } - ret = LogonUserW(UserName.Buffer, - Domain.Buffer, - Password.Buffer, - dwLogonType, - dwLogonProvider, - phToken); + ret = LogonUserExW(UserName.Buffer, + Domain.Buffer, + Password.Buffer, + dwLogonType, + dwLogonProvider, + phToken, + ppLogonSid, + ppProfileBuffer, + pdwProfileLength, + pQuotaLimits); if (Password.Buffer != NULL) RtlFreeUnicodeString(&Password); @@ -285,13 +322,45 @@ /* * @implemented */ -BOOL WINAPI -LogonUserW(LPWSTR lpszUsername, - LPWSTR lpszDomain, - LPWSTR lpszPassword, - DWORD dwLogonType, - DWORD dwLogonProvider, - PHANDLE phToken) +BOOL +WINAPI +LogonUserW( + _In_ LPWSTR lpszUsername, + _In_opt_ LPWSTR lpszDomain, + _In_opt_ LPWSTR lpszPassword, + _In_ DWORD dwLogonType, + _In_ DWORD dwLogonProvider, + _Out_opt_ PHANDLE phToken) +{ + return LogonUserExW(lpszUsername, + lpszDomain, + lpszPassword, + dwLogonType, + dwLogonProvider, + phToken, + NULL, + NULL, + NULL, + NULL); +} + + +/* + * @implemented + */ +BOOL +WINAPI +LogonUserExW( + _In_ LPWSTR lpszUsername, + _In_opt_ LPWSTR lpszDomain, + _In_opt_ LPWSTR lpszPassword, + _In_ DWORD dwLogonType, + _In_ DWORD dwLogonProvider, + _Out_opt_ PHANDLE phToken, + _Out_opt_ PSID *ppLogonSid, + _Out_opt_ PVOID *ppProfileBuffer, + _Out_opt_ LPDWORD pdwProfileLength, + _Out_opt_ PQUOTA_LIMITS pQuotaLimits) { SID_IDENTIFIER_AUTHORITY LocalAuthority = {SECURITY_LOCAL_SID_AUTHORITY}; SID_IDENTIFIER_AUTHORITY SystemAuthority = {SECURITY_NT_AUTHORITY}; @@ -503,6 +572,8 @@ *phToken = TokenHandle; + /* FIXME: return ppLogonSid, ppProfileBuffer, pdwProfileLength and pQuotaLimits */ + done: if (ProfileBuffer != NULL) LsaFreeReturnBuffer(ProfileBuffer); Modified: trunk/reactos/sdk/include/psdk/winbase.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/psdk/winbase.h…
============================================================================== --- trunk/reactos/sdk/include/psdk/winbase.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/psdk/winbase.h [iso-8859-1] Mon May 23 13:53:24 2016 @@ -2569,6 +2569,36 @@ _Success_(return != FALSE) BOOL WINAPI +LogonUserExA( + _In_ LPSTR lpszUsername, + _In_opt_ LPSTR lpszDomain, + _In_opt_ LPSTR lpszPassword, + _In_ DWORD dwLogonType, + _In_ DWORD dwLogonProvider, + _Out_opt_ PHANDLE phToken, + _Out_opt_ PSID *ppLogonSid, + _Out_opt_ PVOID *ppProfileBuffer, + _Out_opt_ LPDWORD pdwProfileLength, + _Out_opt_ PQUOTA_LIMITS pQuotaLimits); + +_Success_(return != FALSE) +BOOL +WINAPI +LogonUserExW( + _In_ LPWSTR lpszUsername, + _In_opt_ LPWSTR lpszDomain, + _In_opt_ LPWSTR lpszPassword, + _In_ DWORD dwLogonType, + _In_ DWORD dwLogonProvider, + _Out_opt_ PHANDLE phToken, + _Out_opt_ PSID *ppLogonSid, + _Out_opt_ PVOID *ppProfileBuffer, + _Out_opt_ LPDWORD pdwProfileLength, + _Out_opt_ PQUOTA_LIMITS pQuotaLimits); + +_Success_(return != FALSE) +BOOL +WINAPI LookupAccountNameA( _In_opt_ LPCSTR lpSystemName, _In_ LPCSTR lpAccountName, @@ -3359,6 +3389,7 @@ #define LoadLibrary LoadLibraryW #define LoadLibraryEx LoadLibraryExW #define LogonUser LogonUserW +#define LogonUserEx LogonUserExW #define LookupAccountName LookupAccountNameW #define LookupAccountSid LookupAccountSidW #define LookupPrivilegeDisplayName LookupPrivilegeDisplayNameW @@ -3567,6 +3598,7 @@ #define LoadLibrary LoadLibraryA #define LoadLibraryEx LoadLibraryExA #define LogonUser LogonUserA +#define LogonUserEx LogonUserExA #define LookupAccountName LookupAccountNameA #define LookupAccountSid LookupAccountSidA #define LookupPrivilegeDisplayName LookupPrivilegeDisplayNameA
8 years, 7 months
1
0
0
0
[hbelusca] 71384: [ADVAPI32]: Implement all the Elf*** event log APIs as wrappers around the corresponding RPC calls, and the Win32 APIs just become calls to the Elf*** APIs.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Mon May 23 02:03:49 2016 New Revision: 71384 URL:
http://svn.reactos.org/svn/reactos?rev=71384&view=rev
Log: [ADVAPI32]: Implement all the Elf*** event log APIs as wrappers around the corresponding RPC calls, and the Win32 APIs just become calls to the Elf*** APIs. Modified: trunk/reactos/dll/win32/advapi32/advapi32.spec trunk/reactos/dll/win32/advapi32/service/eventlog.c Modified: trunk/reactos/dll/win32/advapi32/advapi32.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/advapi3…
============================================================================== --- trunk/reactos/dll/win32/advapi32/advapi32.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/advapi32.spec [iso-8859-1] Mon May 23 02:03:49 2016 @@ -180,27 +180,27 @@ 180 stub DuplicateEncryptionInfoFile 181 stdcall DuplicateToken(long long ptr) 182 stdcall DuplicateTokenEx(long long ptr long long ptr) -183 stub ElfBackupEventLogFileA -184 stub ElfBackupEventLogFileW -185 stub ElfChangeNotify -186 stub ElfClearEventLogFileA -187 stub ElfClearEventLogFileW -188 stub ElfCloseEventLog +183 stdcall ElfBackupEventLogFileA(long ptr) +184 stdcall ElfBackupEventLogFileW(long ptr) +185 stdcall ElfChangeNotify(long long) +186 stdcall ElfClearEventLogFileA(long ptr) +187 stdcall ElfClearEventLogFileW(long ptr) +188 stdcall ElfCloseEventLog(long) 189 stdcall ElfDeregisterEventSource(long) -190 stub ElfFlushEventLog -191 stub ElfNumberOfRecords -192 stub ElfOldestRecord -193 stub ElfOpenBackupEventLogA -194 stub ElfOpenBackupEventLogW -195 stub ElfOpenEventLogA -196 stub ElfOpenEventLogW -197 stub ElfReadEventLogA -198 stub ElfReadEventLogW -199 stub ElfRegisterEventSourceA +190 stdcall ElfFlushEventLog(long) +191 stdcall ElfNumberOfRecords(long ptr) +192 stdcall ElfOldestRecord(long ptr) +193 stdcall ElfOpenBackupEventLogA(ptr ptr ptr) +194 stdcall ElfOpenBackupEventLogW(ptr ptr ptr) +195 stdcall ElfOpenEventLogA(ptr ptr ptr) +196 stdcall ElfOpenEventLogW(ptr ptr ptr) +197 stdcall ElfReadEventLogA(long long long ptr long ptr ptr) +198 stdcall ElfReadEventLogW(long long long ptr long ptr ptr) +199 stdcall ElfRegisterEventSourceA(ptr ptr ptr) 200 stdcall ElfRegisterEventSourceW(ptr ptr ptr) -201 stub ElfReportEventA -202 stub ElfReportEventAndSourceW -203 stdcall ElfReportEventW(long long long long ptr long long ptr ptr ptr ptr ptr) +201 stdcall ElfReportEventA(long long long long ptr long long ptr ptr long ptr ptr) +202 stdcall ElfReportEventAndSourceW(long long ptr long long long ptr ptr long long ptr ptr long ptr ptr) +203 stdcall ElfReportEventW(long long long long ptr long long ptr ptr long ptr ptr) 204 stdcall EnableTrace(long long long ptr double) ntdll.EtwEnableTrace 205 stdcall EncryptFileA(str) 206 stdcall EncryptFileW(wstr) Modified: trunk/reactos/dll/win32/advapi32/service/eventlog.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/service…
============================================================================== --- trunk/reactos/dll/win32/advapi32/service/eventlog.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/service/eventlog.c [iso-8859-1] Mon May 23 02:03:49 2016 @@ -21,6 +21,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/* INCLUDES ******************************************************************/ + #include <advapi32.h> #include <ndk/kefuncs.h> @@ -31,6 +33,8 @@ static RPC_UNICODE_STRING EmptyStringU = { 0, 0, L"" }; static RPC_STRING EmptyStringA = { 0, 0, "" }; + +/* FUNCTIONS *****************************************************************/ handle_t __RPC_USER EVENTLOG_HANDLE_A_bind(EVENTLOG_HANDLE_A UNCServerName) @@ -56,13 +60,13 @@ /* Set the binding handle that will be used to bind to the server. */ status = RpcBindingFromStringBindingA(pszStringBinding, &hBinding); - if (status) + if (status != RPC_S_OK) { ERR("RpcBindingFromStringBinding returned 0x%x\n", status); } status = RpcStringFreeA(&pszStringBinding); - if (status) + if (status != RPC_S_OK) { ERR("RpcStringFree returned 0x%x\n", status); } @@ -80,7 +84,7 @@ TRACE("EVENTLOG_HANDLE_A_unbind() called\n"); status = RpcBindingFree(&hBinding); - if (status) + if (status != RPC_S_OK) { ERR("RpcBindingFree returned 0x%x\n", status); } @@ -98,11 +102,11 @@ status = RpcStringBindingComposeW(NULL, L"ncacn_np", - (LPWSTR)UNCServerName, + UNCServerName, L"\\pipe\\EventLog", NULL, &pszStringBinding); - if (status) + if (status != RPC_S_OK) { ERR("RpcStringBindingCompose returned 0x%x\n", status); return NULL; @@ -111,13 +115,13 @@ /* Set the binding handle that will be used to bind to the server. */ status = RpcBindingFromStringBindingW(pszStringBinding, &hBinding); - if (status) + if (status != RPC_S_OK) { ERR("RpcBindingFromStringBinding returned 0x%x\n", status); } status = RpcStringFreeW(&pszStringBinding); - if (status) + if (status != RPC_S_OK) { ERR("RpcStringFree returned 0x%x\n", status); } @@ -135,7 +139,7 @@ TRACE("EVENTLOG_HANDLE_W_unbind() called\n"); status = RpcBindingFree(&hBinding); - if (status) + if (status != RPC_S_OK) { ERR("RpcBindingFree returned 0x%x\n", status); } @@ -145,14 +149,38 @@ /****************************************************************************** * BackupEventLogA [ADVAPI32.@] */ +NTSTATUS +NTAPI +ElfBackupEventLogFileA(IN HANDLE hEventLog, + IN PANSI_STRING BackupFileNameA) +{ + NTSTATUS Status; + + if (!BackupFileNameA || (BackupFileNameA->Length == 0)) + return STATUS_INVALID_PARAMETER; + + RpcTryExcept + { + Status = ElfrBackupELFA(hEventLog, + (PRPC_STRING)BackupFileNameA); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + BOOL WINAPI BackupEventLogA(IN HANDLE hEventLog, IN LPCSTR lpBackupFileName) { + BOOL Success; + NTSTATUS Status; ANSI_STRING BackupFileNameA; UNICODE_STRING BackupFileNameW; - NTSTATUS Status; - BOOL Result; TRACE("%p, %s\n", hEventLog, lpBackupFileName); @@ -173,12 +201,12 @@ return FALSE; } - Result = BackupEventLogW(hEventLog, - BackupFileNameW.Buffer); + Success = BackupEventLogW(hEventLog, + BackupFileNameW.Buffer); RtlFreeUnicodeString(&BackupFileNameW); - return(Result); + return Success; } @@ -189,12 +217,36 @@ * hEventLog [] * lpBackupFileName [] */ +NTSTATUS +NTAPI +ElfBackupEventLogFileW(IN HANDLE hEventLog, + IN PUNICODE_STRING BackupFileNameU) +{ + NTSTATUS Status; + + if (!BackupFileNameU || (BackupFileNameU->Length == 0)) + return STATUS_INVALID_PARAMETER; + + RpcTryExcept + { + Status = ElfrBackupELFW(hEventLog, + (PRPC_UNICODE_STRING)BackupFileNameU); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + BOOL WINAPI BackupEventLogW(IN HANDLE hEventLog, IN LPCWSTR lpBackupFileName) { - UNICODE_STRING BackupFileNameW; - NTSTATUS Status; + NTSTATUS Status; + UNICODE_STRING BackupFileName; TRACE("%p, %s\n", hEventLog, debugstr_w(lpBackupFileName)); @@ -204,25 +256,16 @@ return FALSE; } - if (!RtlDosPathNameToNtPathName_U(lpBackupFileName, &BackupFileNameW, + if (!RtlDosPathNameToNtPathName_U(lpBackupFileName, &BackupFileName, NULL, NULL)) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } - RpcTryExcept - { - Status = ElfrBackupELFW(hEventLog, - (PRPC_UNICODE_STRING)&BackupFileNameW); - } - RpcExcept(EXCEPTION_EXECUTE_HANDLER) - { - Status = I_RpcMapWin32Status(RpcExceptionCode()); - } - RpcEndExcept; - - RtlFreeHeap(RtlGetProcessHeap(), 0, BackupFileNameW.Buffer); + Status = ElfBackupEventLogFileW(hEventLog, &BackupFileName); + + RtlFreeHeap(RtlGetProcessHeap(), 0, BackupFileName.Buffer); if (!NT_SUCCESS(Status)) { @@ -237,14 +280,35 @@ /****************************************************************************** * ClearEventLogA [ADVAPI32.@] */ +NTSTATUS +NTAPI +ElfClearEventLogFileA(IN HANDLE hEventLog, + IN PANSI_STRING BackupFileNameA) +{ + NTSTATUS Status; + + RpcTryExcept + { + Status = ElfrClearELFA(hEventLog, + (PRPC_STRING)BackupFileNameA); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + BOOL WINAPI ClearEventLogA(IN HANDLE hEventLog, IN LPCSTR lpBackupFileName) { + BOOL Success; + NTSTATUS Status; ANSI_STRING BackupFileNameA; UNICODE_STRING BackupFileNameW; - NTSTATUS Status; - BOOL Result; TRACE("%p, %s\n", hEventLog, lpBackupFileName); @@ -266,34 +330,55 @@ } } - Result = ClearEventLogW(hEventLog, - BackupFileNameW.Buffer); + Success = ClearEventLogW(hEventLog, + BackupFileNameW.Buffer); RtlFreeUnicodeString(&BackupFileNameW); - return Result; + return Success; } /****************************************************************************** * ClearEventLogW [ADVAPI32.@] */ +NTSTATUS +NTAPI +ElfClearEventLogFileW(IN HANDLE hEventLog, + IN PUNICODE_STRING BackupFileNameU) +{ + NTSTATUS Status; + + RpcTryExcept + { + Status = ElfrClearELFW(hEventLog, + (PRPC_UNICODE_STRING)BackupFileNameU); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + BOOL WINAPI ClearEventLogW(IN HANDLE hEventLog, IN LPCWSTR lpBackupFileName) { - UNICODE_STRING BackupFileNameW; - NTSTATUS Status; + NTSTATUS Status; + UNICODE_STRING BackupFileName; TRACE("%p, %s\n", hEventLog, debugstr_w(lpBackupFileName)); if (lpBackupFileName == NULL) { - RtlInitUnicodeString(&BackupFileNameW, NULL); + RtlInitUnicodeString(&BackupFileName, NULL); } else { - if (!RtlDosPathNameToNtPathName_U(lpBackupFileName, &BackupFileNameW, + if (!RtlDosPathNameToNtPathName_U(lpBackupFileName, &BackupFileName, NULL, NULL)) { SetLastError(ERROR_INVALID_PARAMETER); @@ -301,19 +386,10 @@ } } - RpcTryExcept - { - Status = ElfrClearELFW(hEventLog, - (PRPC_UNICODE_STRING)&BackupFileNameW); - } - RpcExcept(EXCEPTION_EXECUTE_HANDLER) - { - Status = I_RpcMapWin32Status(RpcExceptionCode()); - } - RpcEndExcept; + Status = ElfClearEventLogFileW(hEventLog, &BackupFileName); if (lpBackupFileName != NULL) - RtlFreeHeap(RtlGetProcessHeap(), 0, BackupFileNameW.Buffer); + RtlFreeHeap(RtlGetProcessHeap(), 0, BackupFileName.Buffer); if (!NT_SUCCESS(Status)) { @@ -328,6 +404,25 @@ /****************************************************************************** * CloseEventLog [ADVAPI32.@] */ +NTSTATUS +NTAPI +ElfCloseEventLog(IN HANDLE hEventLog) +{ + NTSTATUS Status; + + RpcTryExcept + { + Status = ElfrCloseEL(&hEventLog); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + BOOL WINAPI CloseEventLog(IN HANDLE hEventLog) { @@ -335,16 +430,7 @@ TRACE("%p\n", hEventLog); - RpcTryExcept - { - Status = ElfrCloseEL(&hEventLog); - } - RpcExcept(EXCEPTION_EXECUTE_HANDLER) - { - Status = I_RpcMapWin32Status(RpcExceptionCode()); - } - RpcEndExcept; - + Status = ElfCloseEventLog(hEventLog); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); @@ -364,6 +450,25 @@ * * RETURNS STD */ +NTSTATUS +NTAPI +ElfDeregisterEventSource(IN HANDLE hEventLog) +{ + NTSTATUS Status; + + RpcTryExcept + { + Status = ElfrDeregisterEventSource(&hEventLog); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + BOOL WINAPI DeregisterEventSource(IN HANDLE hEventLog) { @@ -371,16 +476,7 @@ TRACE("%p\n", hEventLog); - RpcTryExcept - { - Status = ElfrDeregisterEventSource(&hEventLog); - } - RpcExcept(EXCEPTION_EXECUTE_HANDLER) - { - Status = I_RpcMapWin32Status(RpcExceptionCode()); - } - RpcEndExcept; - + Status = ElfDeregisterEventSource(hEventLog); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); @@ -447,39 +543,43 @@ * hEventLog [] * NumberOfRecords [] */ +NTSTATUS +NTAPI +ElfNumberOfRecords(IN HANDLE hEventLog, + OUT PULONG NumberOfRecords) +{ + NTSTATUS Status; + + if (!NumberOfRecords) + return STATUS_INVALID_PARAMETER; + + RpcTryExcept + { + Status = ElfrNumberOfRecords(hEventLog, NumberOfRecords); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + BOOL WINAPI GetNumberOfEventLogRecords(IN HANDLE hEventLog, OUT PDWORD NumberOfRecords) { NTSTATUS Status; - DWORD Records; TRACE("%p, %p\n", hEventLog, NumberOfRecords); - if (NumberOfRecords == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - RpcTryExcept - { - Status = ElfrNumberOfRecords(hEventLog, - &Records); - } - RpcExcept(EXCEPTION_EXECUTE_HANDLER) - { - Status = I_RpcMapWin32Status(RpcExceptionCode()); - } - RpcEndExcept; - - if (!NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; - } - - *NumberOfRecords = Records; + Status = ElfNumberOfRecords(hEventLog, NumberOfRecords); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } return TRUE; } @@ -492,39 +592,43 @@ * hEventLog [] * OldestRecord [] */ +NTSTATUS +NTAPI +ElfOldestRecord(IN HANDLE hEventLog, + OUT PULONG OldestRecordNumber) +{ + NTSTATUS Status; + + if (!OldestRecordNumber) + return STATUS_INVALID_PARAMETER; + + RpcTryExcept + { + Status = ElfrOldestRecord(hEventLog, OldestRecordNumber); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + BOOL WINAPI GetOldestEventLogRecord(IN HANDLE hEventLog, OUT PDWORD OldestRecord) { NTSTATUS Status; - DWORD Oldest; TRACE("%p, %p\n", hEventLog, OldestRecord); - if (OldestRecord == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - RpcTryExcept - { - Status = ElfrOldestRecord(hEventLog, - &Oldest); - } - RpcExcept(EXCEPTION_EXECUTE_HANDLER) - { - Status = I_RpcMapWin32Status(RpcExceptionCode()); - } - RpcEndExcept; - - if (!NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; - } - - *OldestRecord = Oldest; + Status = ElfOldestRecord(hEventLog, OldestRecord); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } return TRUE; } @@ -537,30 +641,96 @@ * hEventLog [] * hEvent [] */ +NTSTATUS +NTAPI +ElfChangeNotify(IN HANDLE hEventLog, + IN HANDLE hEvent) +{ + NTSTATUS Status; + CLIENT_ID ClientId = NtCurrentTeb()->ClientId; + RPC_CLIENT_ID RpcClientId; + + RpcClientId.UniqueProcess = HandleToUlong(ClientId.UniqueProcess); + RpcClientId.UniqueThread = HandleToUlong(ClientId.UniqueThread); + + RpcTryExcept + { + Status = ElfrChangeNotify(hEventLog, RpcClientId, (DWORD)hEvent); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + BOOL WINAPI NotifyChangeEventLog(IN HANDLE hEventLog, IN HANDLE hEvent) { - /* Use ElfrChangeNotify */ - UNIMPLEMENTED; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + NTSTATUS Status; + + TRACE("%p, %p\n", hEventLog, hEvent); + + Status = ElfChangeNotify(hEventLog, hEvent); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + } + + return TRUE; } /****************************************************************************** * OpenBackupEventLogA [ADVAPI32.@] */ +NTSTATUS +NTAPI +ElfOpenBackupEventLogA(IN PANSI_STRING UNCServerNameA, + IN PANSI_STRING BackupFileNameA, + OUT PHANDLE phEventLog) +{ + NTSTATUS Status; + PSTR pUNCServerName = NULL; + + if (!phEventLog || !BackupFileNameA || (BackupFileNameA->Length == 0)) + return STATUS_INVALID_PARAMETER; + + if (UNCServerNameA && (UNCServerNameA->Length != 0)) + pUNCServerName = UNCServerNameA->Buffer; + + *phEventLog = NULL; + + RpcTryExcept + { + Status = ElfrOpenBELA(pUNCServerName, + (PRPC_STRING)BackupFileNameA, + 1, 1, + (IELF_HANDLE*)phEventLog); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + HANDLE WINAPI OpenBackupEventLogA(IN LPCSTR lpUNCServerName, IN LPCSTR lpFileName) { + NTSTATUS Status; + HANDLE LogHandle; ANSI_STRING UNCServerNameA; UNICODE_STRING UNCServerNameW; ANSI_STRING FileNameA; UNICODE_STRING FileNameW; - HANDLE LogHandle; - NTSTATUS Status; TRACE("%s, %s\n", lpUNCServerName, lpFileName); @@ -622,13 +792,46 @@ * lpUNCServerName [] * lpFileName [] */ +NTSTATUS +NTAPI +ElfOpenBackupEventLogW(IN PUNICODE_STRING UNCServerNameU, + IN PUNICODE_STRING BackupFileNameU, + OUT PHANDLE phEventLog) +{ + NTSTATUS Status; + PWSTR pUNCServerName = NULL; + + if (!phEventLog || !BackupFileNameU || (BackupFileNameU->Length == 0)) + return STATUS_INVALID_PARAMETER; + + if (UNCServerNameU && (UNCServerNameU->Length != 0)) + pUNCServerName = UNCServerNameU->Buffer; + + *phEventLog = NULL; + + RpcTryExcept + { + Status = ElfrOpenBELW(pUNCServerName, + (PRPC_UNICODE_STRING)BackupFileNameU, + 1, 1, + (IELF_HANDLE*)phEventLog); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + HANDLE WINAPI OpenBackupEventLogW(IN LPCWSTR lpUNCServerName, IN LPCWSTR lpFileName) { - UNICODE_STRING FileNameW; - IELF_HANDLE LogHandle; - NTSTATUS Status; + NTSTATUS Status; + HANDLE hEventLog; + UNICODE_STRING UNCServerName, FileName; TRACE("%s, %s\n", debugstr_w(lpUNCServerName), debugstr_w(lpFileName)); @@ -638,29 +841,19 @@ return NULL; } - if (!RtlDosPathNameToNtPathName_U(lpFileName, &FileNameW, + if (!RtlDosPathNameToNtPathName_U(lpFileName, &FileName, NULL, NULL)) { SetLastError(ERROR_INVALID_PARAMETER); return NULL; } - RpcTryExcept - { - Status = ElfrOpenBELW((LPWSTR)lpUNCServerName, - (PRPC_UNICODE_STRING)&FileNameW, - 1, - 1, - &LogHandle); - } - RpcExcept(EXCEPTION_EXECUTE_HANDLER) - { - Status = I_RpcMapWin32Status(RpcExceptionCode()); - } - RpcEndExcept; - - if (FileNameW.Buffer != NULL) - RtlFreeHeap(RtlGetProcessHeap(), 0, FileNameW.Buffer); + RtlInitUnicodeString(&UNCServerName, lpUNCServerName); + + Status = ElfOpenBackupEventLogW(&UNCServerName, &FileName, &hEventLog); + + if (FileName.Buffer != NULL) + RtlFreeHeap(RtlGetProcessHeap(), 0, FileName.Buffer); if (!NT_SUCCESS(Status)) { @@ -668,7 +861,7 @@ return NULL; } - return (HANDLE)LogHandle; + return hEventLog; } @@ -686,52 +879,61 @@ * Success: Handle to an event log. * Failure: NULL */ +NTSTATUS +NTAPI +ElfOpenEventLogA(IN PANSI_STRING UNCServerNameA, + IN PANSI_STRING SourceNameA, + OUT PHANDLE phEventLog) +{ + NTSTATUS Status; + PSTR pUNCServerName = NULL; + + if (!phEventLog || !SourceNameA || (SourceNameA->Length == 0)) + return STATUS_INVALID_PARAMETER; + + if (UNCServerNameA && (UNCServerNameA->Length != 0)) + pUNCServerName = UNCServerNameA->Buffer; + + *phEventLog = NULL; + + RpcTryExcept + { + Status = ElfrOpenELA(pUNCServerName, + (PRPC_STRING)SourceNameA, + &EmptyStringA, + 1, 1, + (IELF_HANDLE*)phEventLog); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + HANDLE WINAPI OpenEventLogA(IN LPCSTR lpUNCServerName, IN LPCSTR lpSourceName) { - LPSTR UNCServerName; - ANSI_STRING SourceName; - IELF_HANDLE LogHandle = NULL; - NTSTATUS Status; + NTSTATUS Status; + HANDLE hEventLog; + ANSI_STRING UNCServerName, SourceName; TRACE("%s, %s\n", lpUNCServerName, lpSourceName); - if (lpSourceName == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); + RtlInitAnsiString(&UNCServerName, lpUNCServerName); + RtlInitAnsiString(&SourceName, lpSourceName); + + Status = ElfOpenEventLogA(&UNCServerName, &SourceName, &hEventLog); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); return NULL; } - if (lpUNCServerName == NULL || *lpUNCServerName == 0) - UNCServerName = NULL; - else - UNCServerName = (LPSTR)lpUNCServerName; - - RtlInitAnsiString(&SourceName, lpSourceName); - - RpcTryExcept - { - Status = ElfrOpenELA(UNCServerName, - (PRPC_STRING)&SourceName, - &EmptyStringA, - 1, - 1, - &LogHandle); - } - RpcExcept(EXCEPTION_EXECUTE_HANDLER) - { - Status = I_RpcMapWin32Status(RpcExceptionCode()); - } - RpcEndExcept; - - if (!NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return NULL; - } - - return (HANDLE)LogHandle; + return hEventLog; } @@ -742,58 +944,116 @@ * lpUNCServerName [] * lpSourceName [] */ +NTSTATUS +NTAPI +ElfOpenEventLogW(IN PUNICODE_STRING UNCServerNameU, + IN PUNICODE_STRING SourceNameU, + OUT PHANDLE phEventLog) +{ + NTSTATUS Status; + PWSTR pUNCServerName = NULL; + + if (!phEventLog || !SourceNameU || (SourceNameU->Length == 0)) + return STATUS_INVALID_PARAMETER; + + if (UNCServerNameU && (UNCServerNameU->Length != 0)) + pUNCServerName = UNCServerNameU->Buffer; + + *phEventLog = NULL; + + RpcTryExcept + { + Status = ElfrOpenELW(pUNCServerName, + (PRPC_UNICODE_STRING)SourceNameU, + &EmptyStringU, + 1, 1, + (IELF_HANDLE*)phEventLog); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + HANDLE WINAPI OpenEventLogW(IN LPCWSTR lpUNCServerName, IN LPCWSTR lpSourceName) { - LPWSTR UNCServerName; - UNICODE_STRING SourceName; - IELF_HANDLE LogHandle; - NTSTATUS Status; + NTSTATUS Status; + HANDLE hEventLog; + UNICODE_STRING UNCServerName, SourceName; TRACE("%s, %s\n", debugstr_w(lpUNCServerName), debugstr_w(lpSourceName)); - if (lpSourceName == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); + RtlInitUnicodeString(&UNCServerName, lpUNCServerName); + RtlInitUnicodeString(&SourceName, lpSourceName); + + Status = ElfOpenEventLogW(&UNCServerName, &SourceName, &hEventLog); + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); return NULL; } - if (lpUNCServerName == NULL || *lpUNCServerName == 0) - UNCServerName = NULL; - else - UNCServerName = (LPWSTR)lpUNCServerName; - - RtlInitUnicodeString(&SourceName, lpSourceName); - - RpcTryExcept - { - Status = ElfrOpenELW(UNCServerName, - (PRPC_UNICODE_STRING)&SourceName, - &EmptyStringU, - 1, - 1, - &LogHandle); - } - RpcExcept(EXCEPTION_EXECUTE_HANDLER) - { - Status = I_RpcMapWin32Status(RpcExceptionCode()); - } - RpcEndExcept; - - if (!NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return NULL; - } - - return (HANDLE)LogHandle; + return hEventLog; } /****************************************************************************** * ReadEventLogA [ADVAPI32.@] */ +NTSTATUS +NTAPI +ElfReadEventLogA(IN HANDLE hEventLog, + IN ULONG ReadFlags, + IN ULONG RecordOffset, + OUT LPVOID Buffer, + IN ULONG NumberOfBytesToRead, + OUT PULONG NumberOfBytesRead, + OUT PULONG MinNumberOfBytesNeeded) +{ + NTSTATUS Status; + ULONG Flags; + + if (!Buffer || !NumberOfBytesRead || !MinNumberOfBytesNeeded) + { + return STATUS_INVALID_PARAMETER; + } + + Flags = ReadFlags & (EVENTLOG_SEQUENTIAL_READ | EVENTLOG_SEEK_READ); + if (Flags == (EVENTLOG_SEQUENTIAL_READ | EVENTLOG_SEEK_READ)) + { + return STATUS_INVALID_PARAMETER; + } + + Flags = ReadFlags & (EVENTLOG_FORWARDS_READ | EVENTLOG_BACKWARDS_READ); + if (Flags == (EVENTLOG_FORWARDS_READ | EVENTLOG_BACKWARDS_READ)) + { + return STATUS_INVALID_PARAMETER; + } + + RpcTryExcept + { + Status = ElfrReadELA(hEventLog, + ReadFlags, + RecordOffset, + NumberOfBytesToRead, + Buffer, + NumberOfBytesRead, + MinNumberOfBytesNeeded); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + BOOL WINAPI ReadEventLogA(IN HANDLE hEventLog, IN DWORD dwReadFlags, @@ -804,54 +1064,18 @@ OUT DWORD *pnMinNumberOfBytesNeeded) { NTSTATUS Status; - DWORD bytesRead, minNumberOfBytesNeeded; - DWORD dwFlags; TRACE("%p, %lu, %lu, %p, %lu, %p, %p\n", hEventLog, dwReadFlags, dwRecordOffset, lpBuffer, nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded); - if (lpBuffer == NULL || - pnBytesRead == NULL || - pnMinNumberOfBytesNeeded == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - dwFlags = dwReadFlags & (EVENTLOG_SEQUENTIAL_READ | EVENTLOG_SEEK_READ); - if (dwFlags == (EVENTLOG_SEQUENTIAL_READ | EVENTLOG_SEEK_READ)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - dwFlags = dwReadFlags & (EVENTLOG_FORWARDS_READ | EVENTLOG_BACKWARDS_READ); - if (dwFlags == (EVENTLOG_FORWARDS_READ | EVENTLOG_BACKWARDS_READ)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - RpcTryExcept - { - Status = ElfrReadELA(hEventLog, - dwReadFlags, - dwRecordOffset, - nNumberOfBytesToRead, - lpBuffer, - &bytesRead, - &minNumberOfBytesNeeded); - } - RpcExcept(EXCEPTION_EXECUTE_HANDLER) - { - Status = I_RpcMapWin32Status(RpcExceptionCode()); - } - RpcEndExcept; - - *pnBytesRead = (DWORD)bytesRead; - *pnMinNumberOfBytesNeeded = (DWORD)minNumberOfBytesNeeded; - + Status = ElfReadEventLogA(hEventLog, + dwReadFlags, + dwRecordOffset, + lpBuffer, + nNumberOfBytesToRead, + pnBytesRead, + pnMinNumberOfBytesNeeded); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); @@ -874,6 +1098,55 @@ * pnBytesRead [] * pnMinNumberOfBytesNeeded [] */ +NTSTATUS +NTAPI +ElfReadEventLogW(IN HANDLE hEventLog, + IN ULONG ReadFlags, + IN ULONG RecordOffset, + OUT LPVOID Buffer, + IN ULONG NumberOfBytesToRead, + OUT PULONG NumberOfBytesRead, + OUT PULONG MinNumberOfBytesNeeded) +{ + NTSTATUS Status; + ULONG Flags; + + if (!Buffer || !NumberOfBytesRead || !MinNumberOfBytesNeeded) + { + return STATUS_INVALID_PARAMETER; + } + + Flags = ReadFlags & (EVENTLOG_SEQUENTIAL_READ | EVENTLOG_SEEK_READ); + if (Flags == (EVENTLOG_SEQUENTIAL_READ | EVENTLOG_SEEK_READ)) + { + return STATUS_INVALID_PARAMETER; + } + + Flags = ReadFlags & (EVENTLOG_FORWARDS_READ | EVENTLOG_BACKWARDS_READ); + if (Flags == (EVENTLOG_FORWARDS_READ | EVENTLOG_BACKWARDS_READ)) + { + return STATUS_INVALID_PARAMETER; + } + + RpcTryExcept + { + Status = ElfrReadELW(hEventLog, + ReadFlags, + RecordOffset, + NumberOfBytesToRead, + Buffer, + NumberOfBytesRead, + MinNumberOfBytesNeeded); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + BOOL WINAPI ReadEventLogW(IN HANDLE hEventLog, IN DWORD dwReadFlags, @@ -884,54 +1157,18 @@ OUT DWORD *pnMinNumberOfBytesNeeded) { NTSTATUS Status; - DWORD bytesRead, minNumberOfBytesNeeded; - DWORD dwFlags; TRACE("%p, %lu, %lu, %p, %lu, %p, %p\n", hEventLog, dwReadFlags, dwRecordOffset, lpBuffer, nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded); - if (lpBuffer == NULL || - pnBytesRead == NULL || - pnMinNumberOfBytesNeeded == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - dwFlags = dwReadFlags & (EVENTLOG_SEQUENTIAL_READ | EVENTLOG_SEEK_READ); - if (dwFlags == (EVENTLOG_SEQUENTIAL_READ | EVENTLOG_SEEK_READ)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - dwFlags = dwReadFlags & (EVENTLOG_FORWARDS_READ | EVENTLOG_BACKWARDS_READ); - if (dwFlags == (EVENTLOG_FORWARDS_READ | EVENTLOG_BACKWARDS_READ)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - RpcTryExcept - { - Status = ElfrReadELW(hEventLog, - dwReadFlags, - dwRecordOffset, - nNumberOfBytesToRead, - lpBuffer, - &bytesRead, - &minNumberOfBytesNeeded); - } - RpcExcept(EXCEPTION_EXECUTE_HANDLER) - { - Status = I_RpcMapWin32Status(RpcExceptionCode()); - } - RpcEndExcept; - - *pnBytesRead = (DWORD)bytesRead; - *pnMinNumberOfBytesNeeded = (DWORD)minNumberOfBytesNeeded; - + Status = ElfReadEventLogW(hEventLog, + dwReadFlags, + dwRecordOffset, + lpBuffer, + nNumberOfBytesToRead, + pnBytesRead, + pnMinNumberOfBytesNeeded); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); @@ -945,40 +1182,61 @@ /****************************************************************************** * RegisterEventSourceA [ADVAPI32.@] */ +NTSTATUS +NTAPI +ElfRegisterEventSourceA(IN PANSI_STRING UNCServerNameA, + IN PANSI_STRING SourceNameA, + OUT PHANDLE phEventLog) +{ + NTSTATUS Status; + PSTR pUNCServerName = NULL; + + if (!phEventLog || !SourceNameA || (SourceNameA->Length == 0)) + return STATUS_INVALID_PARAMETER; + + if (UNCServerNameA && (UNCServerNameA->Length != 0)) + pUNCServerName = UNCServerNameA->Buffer; + + *phEventLog = NULL; + + RpcTryExcept + { + Status = ElfrRegisterEventSourceA(pUNCServerName, + (PRPC_STRING)SourceNameA, + &EmptyStringA, + 1, 1, + (IELF_HANDLE*)phEventLog); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + HANDLE WINAPI RegisterEventSourceA(IN LPCSTR lpUNCServerName, IN LPCSTR lpSourceName) { - ANSI_STRING SourceName; - IELF_HANDLE LogHandle; - NTSTATUS Status; + NTSTATUS Status; + HANDLE hEventLog; + ANSI_STRING UNCServerName, SourceName; TRACE("%s, %s\n", lpUNCServerName, lpSourceName); + RtlInitAnsiString(&UNCServerName, lpUNCServerName); RtlInitAnsiString(&SourceName, lpSourceName); - RpcTryExcept - { - Status = ElfrRegisterEventSourceA((LPSTR)lpUNCServerName, - (PRPC_STRING)&SourceName, - &EmptyStringA, - 1, - 1, - &LogHandle); - } - RpcExcept(EXCEPTION_EXECUTE_HANDLER) - { - Status = I_RpcMapWin32Status(RpcExceptionCode()); - } - RpcEndExcept; - + Status = ElfRegisterEventSourceA(&UNCServerName, &SourceName, &hEventLog); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); return NULL; } - return (HANDLE)LogHandle; + return hEventLog; } @@ -994,46 +1252,122 @@ * Success: Handle * Failure: NULL */ +NTSTATUS +NTAPI +ElfRegisterEventSourceW(IN PUNICODE_STRING UNCServerNameU, + IN PUNICODE_STRING SourceNameU, + OUT PHANDLE phEventLog) +{ + NTSTATUS Status; + PWSTR pUNCServerName = NULL; + + if (!phEventLog || !SourceNameU || (SourceNameU->Length == 0)) + return STATUS_INVALID_PARAMETER; + + if (UNCServerNameU && (UNCServerNameU->Length != 0)) + pUNCServerName = UNCServerNameU->Buffer; + + *phEventLog = NULL; + + RpcTryExcept + { + Status = ElfrRegisterEventSourceW(pUNCServerName, + (PRPC_UNICODE_STRING)SourceNameU, + &EmptyStringU, + 1, 1, + (IELF_HANDLE*)phEventLog); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + HANDLE WINAPI RegisterEventSourceW(IN LPCWSTR lpUNCServerName, IN LPCWSTR lpSourceName) { - UNICODE_STRING SourceName; - IELF_HANDLE LogHandle; - NTSTATUS Status; + NTSTATUS Status; + HANDLE hEventLog; + UNICODE_STRING UNCServerName, SourceName; TRACE("%s, %s\n", debugstr_w(lpUNCServerName), debugstr_w(lpSourceName)); + RtlInitUnicodeString(&UNCServerName, lpUNCServerName); RtlInitUnicodeString(&SourceName, lpSourceName); - RpcTryExcept - { - Status = ElfrRegisterEventSourceW((LPWSTR)lpUNCServerName, - (PRPC_UNICODE_STRING)&SourceName, - &EmptyStringU, - 1, - 1, - &LogHandle); - } - RpcExcept(EXCEPTION_EXECUTE_HANDLER) - { - Status = I_RpcMapWin32Status(RpcExceptionCode()); - } - RpcEndExcept; - + Status = ElfRegisterEventSourceW(&UNCServerName, &SourceName, &hEventLog); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); return NULL; } - return (HANDLE)LogHandle; + return hEventLog; } /****************************************************************************** * ReportEventA [ADVAPI32.@] */ +NTSTATUS +NTAPI +ElfReportEventA(IN HANDLE hEventLog, + IN USHORT EventType, + IN USHORT EventCategory, + IN ULONG EventID, + IN PSID UserSID, + IN USHORT NumStrings, + IN ULONG DataSize, + IN PANSI_STRING* Strings, + IN PVOID Data, + IN USHORT Flags, + IN OUT PULONG RecordNumber, + IN OUT PULONG TimeWritten) +{ + NTSTATUS Status; + LARGE_INTEGER SystemTime; + ULONG Time; + ULONG dwSize; + ANSI_STRING ComputerName; + CHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1]; + + dwSize = ARRAYSIZE(szComputerName); + GetComputerNameA(szComputerName, &dwSize); + RtlInitAnsiString(&ComputerName, szComputerName); + + NtQuerySystemTime(&SystemTime); + RtlTimeToSecondsSince1970(&SystemTime, &Time); + + RpcTryExcept + { + Status = ElfrReportEventA(hEventLog, + Time, + EventType, + EventCategory, + EventID, + NumStrings, + DataSize, + (PRPC_STRING)&ComputerName, + UserSID, + (PRPC_STRING*)Strings, + Data, + Flags, + RecordNumber, + TimeWritten); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + BOOL WINAPI ReportEventA(IN HANDLE hEventLog, IN WORD wType, @@ -1047,12 +1381,7 @@ { NTSTATUS Status; PANSI_STRING *Strings; - ANSI_STRING ComputerName; WORD i; - CHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1]; - DWORD dwSize; - LARGE_INTEGER SystemTime; - ULONG Seconds; TRACE("%p, %u, %u, %lu, %p, %u, %lu, %p, %p\n", hEventLog, wType, wCategory, dwEventID, lpUserSid, @@ -1078,35 +1407,18 @@ } } - dwSize = MAX_COMPUTERNAME_LENGTH + 1; - GetComputerNameA(szComputerName, &dwSize); - RtlInitAnsiString(&ComputerName, szComputerName); - - NtQuerySystemTime(&SystemTime); - RtlTimeToSecondsSince1970(&SystemTime, &Seconds); - - RpcTryExcept - { - Status = ElfrReportEventA(hEventLog, - Seconds, - wType, - wCategory, - dwEventID, - wNumStrings, - dwDataSize, - (PRPC_STRING)&ComputerName, - lpUserSid, - (PRPC_STRING*)Strings, - lpRawData, - 0, - NULL, - NULL); - } - RpcExcept(EXCEPTION_EXECUTE_HANDLER) - { - Status = I_RpcMapWin32Status(RpcExceptionCode()); - } - RpcEndExcept; + Status = ElfReportEventA(hEventLog, + wType, + wCategory, + dwEventID, + lpUserSid, + wNumStrings, + dwDataSize, + Strings, + lpRawData, + 0, + NULL, + NULL); for (i = 0; i < wNumStrings; i++) { @@ -1140,6 +1452,61 @@ * lpStrings [] * lpRawData [] */ +NTSTATUS +NTAPI +ElfReportEventW(IN HANDLE hEventLog, + IN USHORT EventType, + IN USHORT EventCategory, + IN ULONG EventID, + IN PSID UserSID, + IN USHORT NumStrings, + IN ULONG DataSize, + IN PUNICODE_STRING* Strings, + IN PVOID Data, + IN USHORT Flags, + IN OUT PULONG RecordNumber, + IN OUT PULONG TimeWritten) +{ + NTSTATUS Status; + LARGE_INTEGER SystemTime; + ULONG Time; + ULONG dwSize; + UNICODE_STRING ComputerName; + WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1]; + + dwSize = ARRAYSIZE(szComputerName); + GetComputerNameW(szComputerName, &dwSize); + RtlInitUnicodeString(&ComputerName, szComputerName); + + NtQuerySystemTime(&SystemTime); + RtlTimeToSecondsSince1970(&SystemTime, &Time); + + RpcTryExcept + { + Status = ElfrReportEventW(hEventLog, + Time, + EventType, + EventCategory, + EventID, + NumStrings, + DataSize, + (PRPC_UNICODE_STRING)&ComputerName, + UserSID, + (PRPC_UNICODE_STRING*)Strings, + Data, + Flags, + RecordNumber, + TimeWritten); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + BOOL WINAPI ReportEventW(IN HANDLE hEventLog, IN WORD wType, @@ -1153,19 +1520,14 @@ { NTSTATUS Status; PUNICODE_STRING *Strings; - UNICODE_STRING ComputerName; WORD i; - WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1]; - DWORD dwSize; - LARGE_INTEGER SystemTime; - ULONG Seconds; TRACE("%p, %u, %u, %lu, %p, %u, %lu, %p, %p\n", hEventLog, wType, wCategory, dwEventID, lpUserSid, wNumStrings, dwDataSize, lpStrings, lpRawData); Strings = HeapAlloc(GetProcessHeap(), - 0, + HEAP_ZERO_MEMORY, wNumStrings * sizeof(PUNICODE_STRING)); if (!Strings) { @@ -1177,42 +1539,25 @@ { Strings[i] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof(ANSI_STRING)); + sizeof(UNICODE_STRING)); if (Strings[i]) { RtlInitUnicodeString(Strings[i], lpStrings[i]); } } - dwSize = MAX_COMPUTERNAME_LENGTH + 1; - GetComputerNameW(szComputerName, &dwSize); - RtlInitUnicodeString(&ComputerName, szComputerName); - - NtQuerySystemTime(&SystemTime); - RtlTimeToSecondsSince1970(&SystemTime, &Seconds); - - RpcTryExcept - { - Status = ElfrReportEventW(hEventLog, - Seconds, - wType, - wCategory, - dwEventID, - wNumStrings, - dwDataSize, - (PRPC_UNICODE_STRING)&ComputerName, - lpUserSid, - (PRPC_UNICODE_STRING*)Strings, - lpRawData, - 0, - NULL, - NULL); - } - RpcExcept(EXCEPTION_EXECUTE_HANDLER) - { - Status = I_RpcMapWin32Status(RpcExceptionCode()); - } - RpcEndExcept; + Status = ElfReportEventW(hEventLog, + wType, + wCategory, + dwEventID, + lpUserSid, + wNumStrings, + dwDataSize, + Strings, + lpRawData, + 0, + NULL, + NULL); for (i = 0; i < wNumStrings; i++) { @@ -1231,33 +1576,68 @@ return TRUE; } -BOOL WINAPI -ElfReportEventW(DWORD param1, - DWORD param2, - DWORD param3, - DWORD param4, - DWORD param5, - DWORD param6, - DWORD param7, - DWORD param8, - DWORD param9, - DWORD param10, - DWORD param11, - DWORD param12) -{ - return TRUE; -} - -HANDLE WINAPI -ElfRegisterEventSourceW(DWORD param1, - DWORD param2, - DWORD param3) -{ - return (HANDLE)1; -} - -BOOL WINAPI -ElfDeregisterEventSource(IN HANDLE hEventLog) -{ - return TRUE; -} +NTSTATUS +NTAPI +ElfReportEventAndSourceW(IN HANDLE hEventLog, + IN ULONG Time, + IN PUNICODE_STRING ComputerName, + IN USHORT EventType, + IN USHORT EventCategory, + IN ULONG EventID, + IN PSID UserSID, + IN PUNICODE_STRING SourceName, + IN USHORT NumStrings, + IN ULONG DataSize, + IN PUNICODE_STRING* Strings, + IN PVOID Data, + IN USHORT Flags, + IN OUT PULONG RecordNumber, + IN OUT PULONG TimeWritten) +{ + NTSTATUS Status; + + RpcTryExcept + { + Status = ElfrReportEventAndSourceW(hEventLog, + Time, + EventType, + EventCategory, + EventID, + (PRPC_UNICODE_STRING)SourceName, + NumStrings, + DataSize, + (PRPC_UNICODE_STRING)ComputerName, + (PRPC_SID)UserSID, + (PRPC_UNICODE_STRING*)Strings, + (PBYTE)Data, + Flags, + RecordNumber, + TimeWritten); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + +NTSTATUS +NTAPI +ElfFlushEventLog(IN HANDLE hEventLog) +{ + NTSTATUS Status; + + RpcTryExcept + { + Status = ElfrFlushEL(hEventLog); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +}
8 years, 7 months
1
0
0
0
[hbelusca] 71383: [IDL]: Whitespace fixes only.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sun May 22 22:20:25 2016 New Revision: 71383 URL:
http://svn.reactos.org/svn/reactos?rev=71383&view=rev
Log: [IDL]: Whitespace fixes only. Modified: trunk/reactos/sdk/include/reactos/idl/eventlogrpc.acf trunk/reactos/sdk/include/reactos/idl/lsa.acf trunk/reactos/sdk/include/reactos/idl/pnp.acf trunk/reactos/sdk/include/reactos/idl/sam.acf trunk/reactos/sdk/include/reactos/idl/svcctl.acf trunk/reactos/sdk/include/reactos/idl/winreg.acf Modified: trunk/reactos/sdk/include/reactos/idl/eventlogrpc.acf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/reactos/idl/ev…
============================================================================== --- trunk/reactos/sdk/include/reactos/idl/eventlogrpc.acf [iso-8859-1] (original) +++ trunk/reactos/sdk/include/reactos/idl/eventlogrpc.acf [iso-8859-1] Sun May 22 22:20:25 2016 @@ -1,5 +1,5 @@ [ - implicit_handle(handle_t bindhandle), strict_context_handle + implicit_handle(handle_t bindhandle), strict_context_handle ] interface eventlog { Modified: trunk/reactos/sdk/include/reactos/idl/lsa.acf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/reactos/idl/ls…
============================================================================== --- trunk/reactos/sdk/include/reactos/idl/lsa.acf [iso-8859-1] (original) +++ trunk/reactos/sdk/include/reactos/idl/lsa.acf [iso-8859-1] Sun May 22 22:20:25 2016 @@ -1,5 +1,5 @@ [ - explicit_handle + explicit_handle ] interface lsarpc { Modified: trunk/reactos/sdk/include/reactos/idl/pnp.acf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/reactos/idl/pn…
============================================================================== --- trunk/reactos/sdk/include/reactos/idl/pnp.acf [iso-8859-1] (original) +++ trunk/reactos/sdk/include/reactos/idl/pnp.acf [iso-8859-1] Sun May 22 22:20:25 2016 @@ -1,5 +1,5 @@ [ - explicit_handle + explicit_handle ] interface pnp { Modified: trunk/reactos/sdk/include/reactos/idl/sam.acf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/reactos/idl/sa…
============================================================================== --- trunk/reactos/sdk/include/reactos/idl/sam.acf [iso-8859-1] (original) +++ trunk/reactos/sdk/include/reactos/idl/sam.acf [iso-8859-1] Sun May 22 22:20:25 2016 @@ -1,5 +1,5 @@ [ - explicit_handle + explicit_handle ] interface samr { Modified: trunk/reactos/sdk/include/reactos/idl/svcctl.acf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/reactos/idl/sv…
============================================================================== --- trunk/reactos/sdk/include/reactos/idl/svcctl.acf [iso-8859-1] (original) +++ trunk/reactos/sdk/include/reactos/idl/svcctl.acf [iso-8859-1] Sun May 22 22:20:25 2016 @@ -1,5 +1,5 @@ [ - explicit_handle + explicit_handle ] interface svcctl { Modified: trunk/reactos/sdk/include/reactos/idl/winreg.acf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/reactos/idl/wi…
============================================================================== --- trunk/reactos/sdk/include/reactos/idl/winreg.acf [iso-8859-1] (original) +++ trunk/reactos/sdk/include/reactos/idl/winreg.acf [iso-8859-1] Sun May 22 22:20:25 2016 @@ -1,5 +1,5 @@ [ - explicit_handle + explicit_handle ] interface winreg {
8 years, 7 months
1
0
0
0
[tfaber] 71382: [RTL] - Return the ACE pointer from RtlFirstFreeAce also if it is at the end of the ACL buffer. CORE-11304 #resolve
by tfaber@svn.reactos.org
Author: tfaber Date: Sun May 22 22:11:54 2016 New Revision: 71382 URL:
http://svn.reactos.org/svn/reactos?rev=71382&view=rev
Log: [RTL] - Return the ACE pointer from RtlFirstFreeAce also if it is at the end of the ACL buffer. CORE-11304 #resolve Added: trunk/rostests/apitests/ntdll/RtlDeleteAce.c (with props) trunk/rostests/apitests/ntdll/RtlFirstFreeAce.c (with props) Modified: trunk/reactos/sdk/lib/rtl/acl.c trunk/rostests/apitests/ntdll/CMakeLists.txt trunk/rostests/apitests/ntdll/testlist.c Modified: trunk/reactos/sdk/lib/rtl/acl.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/rtl/acl.c?rev=7138…
============================================================================== --- trunk/reactos/sdk/lib/rtl/acl.c [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/rtl/acl.c [iso-8859-1] Sun May 22 22:11:54 2016 @@ -41,7 +41,7 @@ } /* If the last spot is empty and still valid, return it */ - if ((ULONG_PTR)Current < AclEnd) *FirstFreeAce = Current; + if ((ULONG_PTR)Current <= AclEnd) *FirstFreeAce = Current; return TRUE; } Modified: trunk/rostests/apitests/ntdll/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/CMakeLists…
============================================================================== --- trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] Sun May 22 22:11:54 2016 @@ -22,11 +22,13 @@ RtlAllocateHeap.c RtlBitmap.c RtlCopyMappedMemory.c + RtlDeleteAce.c RtlDetermineDosPathNameType.c RtlDoesFileExists.c RtlDosPathNameToNtPathName_U.c RtlDosSearchPath_U.c RtlDosSearchPath_Ustr.c + RtlFirstFreeAce.c RtlGenerate8dot3Name.c RtlGetFullPathName_U.c RtlGetFullPathName_Ustr.c Added: trunk/rostests/apitests/ntdll/RtlDeleteAce.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/RtlDeleteA…
============================================================================== --- trunk/rostests/apitests/ntdll/RtlDeleteAce.c (added) +++ trunk/rostests/apitests/ntdll/RtlDeleteAce.c [iso-8859-1] Sun May 22 22:11:54 2016 @@ -0,0 +1,260 @@ +/* + * PROJECT: ReactOS API tests + * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory + * PURPOSE: Test for RtlDeleteAce + * PROGRAMMERS: Thomas Faber <thomas.faber(a)reactos.org> + */ + +#include <apitest.h> +#include <ndk/mmfuncs.h> +#include <ndk/rtlfuncs.h> + +static +PVOID +AllocateGuarded( + _In_ SIZE_T SizeRequested) +{ + NTSTATUS Status; + SIZE_T Size = PAGE_ROUND_UP(SizeRequested + PAGE_SIZE); + PVOID VirtualMemory = NULL; + PCHAR StartOfBuffer; + + Status = NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory, 0, &Size, MEM_RESERVE, PAGE_NOACCESS); + + if (!NT_SUCCESS(Status)) + return NULL; + + Size -= PAGE_SIZE; + if (Size) + { + Status = NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory, 0, &Size, MEM_COMMIT, PAGE_READWRITE); + if (!NT_SUCCESS(Status)) + { + Size = 0; + Status = NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory, &Size, MEM_RELEASE); + ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status); + return NULL; + } + } + + StartOfBuffer = VirtualMemory; + StartOfBuffer += Size - SizeRequested; + + return StartOfBuffer; +} + +static +VOID +FreeGuarded( + _In_ PVOID Pointer) +{ + NTSTATUS Status; + PVOID VirtualMemory = (PVOID)PAGE_ROUND_DOWN((SIZE_T)Pointer); + SIZE_T Size = 0; + + Status = NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory, &Size, MEM_RELEASE); + ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status); +} + +static +PACL +MakeAcl( + _In_ ULONG AceCount, + ...) +{ + PACL Acl; + PACE_HEADER AceHeader; + ULONG AclSize; + ULONG AceSizes[10]; + ULONG i; + va_list Args; + + ASSERT(AceCount <= RTL_NUMBER_OF(AceSizes)); + AclSize = sizeof(ACL); + va_start(Args, AceCount); + for (i = 0; i < AceCount; i++) + { + AceSizes[i] = va_arg(Args, int); + AclSize += AceSizes[i]; + } + va_end(Args); + + Acl = AllocateGuarded(AclSize); + if (!Acl) + { + skip("Failed to allocate %lu bytes\n", AclSize); + return NULL; + } + + Acl->AclRevision = ACL_REVISION; + Acl->Sbz1 = 0; + Acl->AclSize = AclSize; + Acl->AceCount = AceCount; + Acl->Sbz2 = 0; + + AceHeader = (PACE_HEADER)(Acl + 1); + for (i = 0; i < AceCount; i++) + { + AceHeader->AceType = 0; + AceHeader->AceFlags = 0; + AceHeader->AceSize = AceSizes[i]; + AceHeader = (PACE_HEADER)((PCHAR)AceHeader + AceHeader->AceSize); + } + + return Acl; +} + +START_TEST(RtlDeleteAce) +{ + PACL Acl; + PACCESS_ALLOWED_ACE Ace; + ULONG AceSize; + PISID Sid; + NTSTATUS Status; + int i; + + Acl = MakeAcl(0); + if (Acl) + { + ok(RtlValidAcl(Acl), "Acl is invalid\n"); + + /* There is no first ACE -- should stay untouched */ + Status = RtlDeleteAce(Acl, 0); + ok(Status == STATUS_INVALID_PARAMETER, "Status = %lx\n", Status); + ok(Acl->AclSize == sizeof(ACL), "AclSize = %u\n", Acl->AclSize); + ok(Acl->AceCount == 0, "AceCount = %u\n", Acl->AceCount); + + /* Index -1 -- should stay untouched */ + Status = RtlDeleteAce(Acl, 0xFFFFFFFF); + ok(Status == STATUS_INVALID_PARAMETER, "Status = %lx\n", Status); + FreeGuarded(Acl); + } + + AceSize = FIELD_OFFSET(ACCESS_ALLOWED_ACE, SidStart) + FIELD_OFFSET(SID, SubAuthority); + Acl = MakeAcl(1, (int)AceSize); + if (Acl) + { + Ace = (PACCESS_ALLOWED_ACE)(Acl + 1); + Ace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE; + Sid = (PISID)&Ace->SidStart; + Sid->Revision = SID_REVISION; + Sid->SubAuthorityCount = 0; + RtlZeroMemory(&Sid->IdentifierAuthority, sizeof(Sid->IdentifierAuthority)); + + ok(RtlValidAcl(Acl), "Acl is invalid\n"); + + /* Out of bounds delete -- should stay untouched */ + Status = RtlDeleteAce(Acl, 1); + ok(Status == STATUS_INVALID_PARAMETER, "Status = %lx\n", Status); + ok(Acl->AclSize == sizeof(ACL) + AceSize, "AclSize = %u\n", Acl->AclSize); + ok(Acl->AceCount == 1, "AceCount = %u\n", Acl->AceCount); + ok(Ace->Header.AceSize == AceSize, "AceSize = %u\n", Ace->Header.AceSize); + + /* Index -1 -- should stay untouched */ + Status = RtlDeleteAce(Acl, 0xFFFFFFFF); + ok(Status == STATUS_INVALID_PARAMETER, "Status = %lx\n", Status); + ok(Acl->AclSize == sizeof(ACL) + AceSize, "AclSize = %u\n", Acl->AclSize); + ok(Acl->AceCount == 1, "AceCount = %u\n", Acl->AceCount); + ok(Ace->Header.AceSize == AceSize, "AceSize = %u\n", Ace->Header.AceSize); + + /* Delete the first (and only) ACE */ + Status = RtlDeleteAce(Acl, 0); + ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status); + ok(Acl->AclSize == sizeof(ACL) + AceSize, "AclSize = %u\n", Acl->AclSize); + ok(Acl->AceCount == 0, "AceCount = %u\n", Acl->AceCount); + ok(Ace->Header.AceSize == 0, "AceSize = %u\n", Ace->Header.AceSize); + FreeGuarded(Acl); + } + + AceSize = FIELD_OFFSET(ACCESS_ALLOWED_ACE, SidStart) + FIELD_OFFSET(SID, SubAuthority[1]); + Acl = MakeAcl(4, (int)AceSize, (int)AceSize + 4, (int)AceSize + 8, (int)AceSize + 12); + if (Acl) + { + Ace = (PACCESS_ALLOWED_ACE)(Acl + 1); + for (i = 0; i < 4; i++) + { + Ace->Header.AceType = ACCESS_ALLOWED_ACE_TYPE; + Sid = (PISID)&Ace->SidStart; + Sid->Revision = SID_REVISION; + Sid->SubAuthorityCount = 0; + RtlZeroMemory(&Sid->IdentifierAuthority, sizeof(Sid->IdentifierAuthority)); + Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize); + } + + ok(RtlValidAcl(Acl), "Acl is invalid\n"); + + /* Out of bounds delete -- should stay untouched */ + Status = RtlDeleteAce(Acl, 4); + ok(Status == STATUS_INVALID_PARAMETER, "Status = %lx\n", Status); + ok(Acl->AclSize == sizeof(ACL) + 4 * AceSize + 24, "AclSize = %u\n", Acl->AclSize); + ok(Acl->AceCount == 4, "AceCount = %u\n", Acl->AceCount); + Ace = (PACCESS_ALLOWED_ACE)(Acl + 1); + ok(Ace->Header.AceSize == AceSize, "AceSize = %u\n", Ace->Header.AceSize); + Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize); + ok(Ace->Header.AceSize == AceSize + 4, "AceSize = %u\n", Ace->Header.AceSize); + Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize); + ok(Ace->Header.AceSize == AceSize + 8, "AceSize = %u\n", Ace->Header.AceSize); + Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize); + ok(Ace->Header.AceSize == AceSize + 12, "AceSize = %u\n", Ace->Header.AceSize); + + /* Index -1 -- should stay untouched */ + Status = RtlDeleteAce(Acl, 0xFFFFFFFF); + ok(Status == STATUS_INVALID_PARAMETER, "Status = %lx\n", Status); + ok(Acl->AclSize == sizeof(ACL) + 4 * AceSize + 24, "AclSize = %u\n", Acl->AclSize); + ok(Acl->AceCount == 4, "AceCount = %u\n", Acl->AceCount); + Ace = (PACCESS_ALLOWED_ACE)(Acl + 1); + ok(Ace->Header.AceSize == AceSize, "AceSize = %u\n", Ace->Header.AceSize); + Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize); + ok(Ace->Header.AceSize == AceSize + 4, "AceSize = %u\n", Ace->Header.AceSize); + Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize); + ok(Ace->Header.AceSize == AceSize + 8, "AceSize = %u\n", Ace->Header.AceSize); + Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize); + ok(Ace->Header.AceSize == AceSize + 12, "AceSize = %u\n", Ace->Header.AceSize); + + /* Delete the last ACE */ + Status = RtlDeleteAce(Acl, 3); + ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status); + ok(Acl->AclSize == sizeof(ACL) + 4 * AceSize + 24, "AclSize = %u\n", Acl->AclSize); + ok(Acl->AceCount == 3, "AceCount = %u\n", Acl->AceCount); + Ace = (PACCESS_ALLOWED_ACE)(Acl + 1); + ok(Ace->Header.AceSize == AceSize, "AceSize = %u\n", Ace->Header.AceSize); + Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize); + ok(Ace->Header.AceSize == AceSize + 4, "AceSize = %u\n", Ace->Header.AceSize); + Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize); + ok(Ace->Header.AceSize == AceSize + 8, "AceSize = %u\n", Ace->Header.AceSize); + Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize); + ok(Ace->Header.AceSize == 0, "AceSize = %u\n", Ace->Header.AceSize); + + /* Delete the second ACE */ + Status = RtlDeleteAce(Acl, 1); + ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status); + ok(Acl->AclSize == sizeof(ACL) + 4 * AceSize + 24, "AclSize = %u\n", Acl->AclSize); + ok(Acl->AceCount == 2, "AceCount = %u\n", Acl->AceCount); + Ace = (PACCESS_ALLOWED_ACE)(Acl + 1); + ok(Ace->Header.AceSize == AceSize, "AceSize = %u\n", Ace->Header.AceSize); + Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize); + ok(Ace->Header.AceSize == AceSize + 8, "AceSize = %u\n", Ace->Header.AceSize); + Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize); + ok(Ace->Header.AceSize == 0, "AceSize = %u\n", Ace->Header.AceSize); + + /* Delete the first ACE */ + Status = RtlDeleteAce(Acl, 0); + ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status); + ok(Acl->AclSize == sizeof(ACL) + 4 * AceSize + 24, "AclSize = %u\n", Acl->AclSize); + ok(Acl->AceCount == 1, "AceCount = %u\n", Acl->AceCount); + Ace = (PACCESS_ALLOWED_ACE)(Acl + 1); + ok(Ace->Header.AceSize == AceSize + 8, "AceSize = %u\n", Ace->Header.AceSize); + Ace = (PACCESS_ALLOWED_ACE)((PCHAR)Ace + Ace->Header.AceSize); + ok(Ace->Header.AceSize == 0, "AceSize = %u\n", Ace->Header.AceSize); + + /* Delete the remaining ACE */ + Status = RtlDeleteAce(Acl, 0); + ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status); + ok(Acl->AclSize == sizeof(ACL) + 4 * AceSize + 24, "AclSize = %u\n", Acl->AclSize); + ok(Acl->AceCount == 0, "AceCount = %u\n", Acl->AceCount); + Ace = (PACCESS_ALLOWED_ACE)(Acl + 1); + ok(Ace->Header.AceSize == 0, "AceSize = %u\n", Ace->Header.AceSize); + + FreeGuarded(Acl); + } +} Propchange: trunk/rostests/apitests/ntdll/RtlDeleteAce.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rostests/apitests/ntdll/RtlFirstFreeAce.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/RtlFirstFr…
============================================================================== --- trunk/rostests/apitests/ntdll/RtlFirstFreeAce.c (added) +++ trunk/rostests/apitests/ntdll/RtlFirstFreeAce.c [iso-8859-1] Sun May 22 22:11:54 2016 @@ -0,0 +1,234 @@ +/* + * PROJECT: ReactOS API tests + * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory + * PURPOSE: Test for RtlFirstFreeAce + * PROGRAMMERS: Thomas Faber <thomas.faber(a)reactos.org> + */ + +#include <apitest.h> +#include <ndk/mmfuncs.h> +#include <ndk/rtlfuncs.h> + +static +PVOID +AllocateGuarded( + _In_ SIZE_T SizeRequested) +{ + NTSTATUS Status; + SIZE_T Size = PAGE_ROUND_UP(SizeRequested + PAGE_SIZE); + PVOID VirtualMemory = NULL; + PCHAR StartOfBuffer; + + Status = NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory, 0, &Size, MEM_RESERVE, PAGE_NOACCESS); + + if (!NT_SUCCESS(Status)) + return NULL; + + Size -= PAGE_SIZE; + if (Size) + { + Status = NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory, 0, &Size, MEM_COMMIT, PAGE_READWRITE); + if (!NT_SUCCESS(Status)) + { + Size = 0; + Status = NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory, &Size, MEM_RELEASE); + ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status); + return NULL; + } + } + + StartOfBuffer = VirtualMemory; + StartOfBuffer += Size - SizeRequested; + + return StartOfBuffer; +} + +static +VOID +FreeGuarded( + _In_ PVOID Pointer) +{ + NTSTATUS Status; + PVOID VirtualMemory = (PVOID)PAGE_ROUND_DOWN((SIZE_T)Pointer); + SIZE_T Size = 0; + + Status = NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory, &Size, MEM_RELEASE); + ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status); +} + +static +PACL +MakeAcl( + _In_ ULONG AceCount, + ...) +{ + PACL Acl; + PACE_HEADER AceHeader; + ULONG AclSize; + ULONG AceSizes[10]; + ULONG i; + va_list Args; + + ASSERT(AceCount <= RTL_NUMBER_OF(AceSizes)); + AclSize = sizeof(ACL); + va_start(Args, AceCount); + for (i = 0; i < AceCount; i++) + { + AceSizes[i] = va_arg(Args, int); + AclSize += AceSizes[i]; + } + va_end(Args); + + Acl = AllocateGuarded(AclSize); + if (!Acl) + { + skip("Failed to allocate %lu bytes\n", AclSize); + return NULL; + } + + Acl->AclRevision = ACL_REVISION; + Acl->Sbz1 = 0; + Acl->AclSize = AclSize; + Acl->AceCount = AceCount; + Acl->Sbz2 = 0; + + AceHeader = (PACE_HEADER)(Acl + 1); + for (i = 0; i < AceCount; i++) + { + AceHeader->AceType = 0; + AceHeader->AceFlags = 0; + AceHeader->AceSize = AceSizes[i]; + AceHeader = (PACE_HEADER)((PCHAR)AceHeader + AceHeader->AceSize); + } + + return Acl; +} + +START_TEST(RtlFirstFreeAce) +{ + PACL Acl; + PACE FirstAce; + BOOLEAN Found; + + Acl = MakeAcl(0); + if (Acl) + { + /* Simple empty ACL */ + FirstAce = InvalidPointer; + Found = RtlFirstFreeAce(Acl, &FirstAce); + ok(Found == TRUE, "Found = %u\n", Found); + ok(FirstAce == (PACE)(Acl + 1), "FirstAce = %p (Acl was %p)\n", FirstAce, Acl); + + /* Not enough space */ + Acl->AclSize = sizeof(ACL) - 1; + FirstAce = InvalidPointer; + Found = RtlFirstFreeAce(Acl, &FirstAce); + ok(Found == TRUE, "Found = %u\n", Found); + ok(FirstAce == NULL, "FirstAce = %p (Acl was %p)\n", FirstAce, Acl); + + /* Invalid values for all the other fields */ + Acl->AclRevision = 76; + Acl->Sbz1 = 0x55; + Acl->AclSize = sizeof(ACL); + Acl->Sbz2 = 0x55; + FirstAce = InvalidPointer; + Found = RtlFirstFreeAce(Acl, &FirstAce); + ok(Found == TRUE, "Found = %u\n", Found); + ok(FirstAce == (PACE)(Acl + 1), "FirstAce = %p (Acl was %p)\n", FirstAce, Acl); + + FreeGuarded(Acl); + } + + Acl = MakeAcl(1, (int)sizeof(ACE_HEADER)); + if (Acl) + { + /* ACL with one ACE */ + FirstAce = InvalidPointer; + Found = RtlFirstFreeAce(Acl, &FirstAce); + ok(Found == TRUE, "Found = %u\n", Found); + ok(FirstAce == (PACE)((PACE_HEADER)(Acl + 1) + 1), "FirstAce = %p (Acl was %p)\n", FirstAce, Acl); + + /* The one ACE doesn't actually fit */ + Acl->AclSize = sizeof(ACL); + FirstAce = InvalidPointer; + Found = RtlFirstFreeAce(Acl, &FirstAce); + ok(Found == FALSE, "Found = %u\n", Found); + ok(FirstAce == NULL, "FirstAce = %p (Acl was %p)\n", FirstAce, Acl); + + /* Only the first byte fits */ + Acl->AclSize = sizeof(ACL) + 1; + FirstAce = InvalidPointer; + Found = RtlFirstFreeAce(Acl, &FirstAce); + ok(Found == TRUE, "Found = %u\n", Found); + ok(FirstAce == NULL, "FirstAce = %p (Acl was %p)\n", FirstAce, Acl); + + /* Until we cover the whole size we get NULL */ + Acl->AclSize = sizeof(ACL) + sizeof(ACE_HEADER) - 1; + FirstAce = InvalidPointer; + Found = RtlFirstFreeAce(Acl, &FirstAce); + ok(Found == TRUE, "Found = %u\n", Found); + ok(FirstAce == NULL, "FirstAce = %p (Acl was %p)\n", FirstAce, Acl); + + FreeGuarded(Acl); + } + + /* Same but bigger */ + Acl = MakeAcl(1, (int)sizeof(ACE_HEADER) + 4); + if (Acl) + { + /* ACL with one ACE */ + FirstAce = InvalidPointer; + Found = RtlFirstFreeAce(Acl, &FirstAce); + ok(Found == TRUE, "Found = %u\n", Found); + ok(FirstAce == (PACE)((PCHAR)(Acl + 1) + sizeof(ACE_HEADER) + 4), "FirstAce = %p (Acl was %p)\n", FirstAce, Acl); + + /* The one ACE doesn't actually fit */ + Acl->AclSize = sizeof(ACL); + FirstAce = InvalidPointer; + Found = RtlFirstFreeAce(Acl, &FirstAce); + ok(Found == FALSE, "Found = %u\n", Found); + ok(FirstAce == NULL, "FirstAce = %p (Acl was %p)\n", FirstAce, Acl); + + /* Only the first byte fits */ + Acl->AclSize = sizeof(ACL) + 1; + FirstAce = InvalidPointer; + Found = RtlFirstFreeAce(Acl, &FirstAce); + ok(Found == TRUE, "Found = %u\n", Found); + ok(FirstAce == NULL, "FirstAce = %p (Acl was %p)\n", FirstAce, Acl); + + /* Until we cover the whole size we get NULL */ + Acl->AclSize = sizeof(ACL) + sizeof(ACE_HEADER) - 3; + FirstAce = InvalidPointer; + Found = RtlFirstFreeAce(Acl, &FirstAce); + ok(Found == TRUE, "Found = %u\n", Found); + ok(FirstAce == NULL, "FirstAce = %p (Acl was %p)\n", FirstAce, Acl); + + FreeGuarded(Acl); + } + + Acl = MakeAcl(4, (int)sizeof(ACE_HEADER), (int)sizeof(ACE_HEADER), (int)sizeof(ACCESS_ALLOWED_ACE), (int)sizeof(ACCESS_ALLOWED_ACE)); + if (Acl) + { + /* ACL with one ACE */ + FirstAce = InvalidPointer; + Found = RtlFirstFreeAce(Acl, &FirstAce); + ok(Found == TRUE, "Found = %u\n", Found); + ok(FirstAce == (PACE)((PCHAR)(Acl + 1) + 2 * sizeof(ACE_HEADER) + 2 * sizeof(ACCESS_ALLOWED_ACE)), "FirstAce = %p (Acl was %p)\n", FirstAce, Acl); + + /* One less gives us NULL */ + Acl->AclSize = sizeof(ACL) + 2 * sizeof(ACE_HEADER) + 2 * sizeof(ACCESS_ALLOWED_ACE) - 1; + FirstAce = InvalidPointer; + Found = RtlFirstFreeAce(Acl, &FirstAce); + ok(Found == TRUE, "Found = %u\n", Found); + ok(FirstAce == NULL, "FirstAce = %p (Acl was %p)\n", FirstAce, Acl); + + /* One ACE less also gives us FALSE */ + Acl->AclSize = sizeof(ACL) + 2 * sizeof(ACE_HEADER) + sizeof(ACCESS_ALLOWED_ACE); + FirstAce = InvalidPointer; + Found = RtlFirstFreeAce(Acl, &FirstAce); + ok(Found == FALSE, "Found = %u\n", Found); + ok(FirstAce == NULL, "FirstAce = %p (Acl was %p)\n", FirstAce, Acl); + + FreeGuarded(Acl); + } +} Propchange: trunk/rostests/apitests/ntdll/RtlFirstFreeAce.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/rostests/apitests/ntdll/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/testlist.c…
============================================================================== --- trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] Sun May 22 22:11:54 2016 @@ -26,11 +26,13 @@ extern void func_RtlAllocateHeap(void); extern void func_RtlBitmap(void); extern void func_RtlCopyMappedMemory(void); +extern void func_RtlDeleteAce(void); extern void func_RtlDetermineDosPathNameType(void); extern void func_RtlDoesFileExists(void); extern void func_RtlDosPathNameToNtPathName_U(void); extern void func_RtlDosSearchPath_U(void); extern void func_RtlDosSearchPath_Ustr(void); +extern void func_RtlFirstFreeAce(void); extern void func_RtlGenerate8dot3Name(void); extern void func_RtlGetFullPathName_U(void); extern void func_RtlGetFullPathName_Ustr(void); @@ -69,11 +71,13 @@ { "RtlAllocateHeap", func_RtlAllocateHeap }, { "RtlBitmapApi", func_RtlBitmap }, { "RtlCopyMappedMemory", func_RtlCopyMappedMemory }, + { "RtlDeleteAce", func_RtlDeleteAce }, { "RtlDetermineDosPathNameType", func_RtlDetermineDosPathNameType }, { "RtlDoesFileExists", func_RtlDoesFileExists }, { "RtlDosPathNameToNtPathName_U", func_RtlDosPathNameToNtPathName_U }, { "RtlDosSearchPath_U", func_RtlDosSearchPath_U }, { "RtlDosSearchPath_Ustr", func_RtlDosSearchPath_Ustr }, + { "RtlFirstFreeAce", func_RtlFirstFreeAce }, { "RtlGenerate8dot3Name", func_RtlGenerate8dot3Name }, { "RtlGetFullPathName_U", func_RtlGetFullPathName_U }, { "RtlGetFullPathName_Ustr", func_RtlGetFullPathName_Ustr },
8 years, 7 months
1
0
0
0
[mjansen] 71381: [APPHELP][APPHELP_APITEST] Add more db tests and implement SdbGetDatabaseVersion. CORE-10367
by mjansen@svn.reactos.org
Author: mjansen Date: Sun May 22 20:39:41 2016 New Revision: 71381 URL:
http://svn.reactos.org/svn/reactos?rev=71381&view=rev
Log: [APPHELP][APPHELP_APITEST] Add more db tests and implement SdbGetDatabaseVersion. CORE-10367 Modified: trunk/reactos/dll/appcompat/apphelp/apphelp.spec trunk/reactos/dll/appcompat/apphelp/sdbapi.c trunk/rostests/apitests/apphelp/data.c trunk/rostests/apitests/apphelp/db.c Modified: trunk/reactos/dll/appcompat/apphelp/apphelp.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/appcompat/apphelp/apph…
============================================================================== --- trunk/reactos/dll/appcompat/apphelp/apphelp.spec [iso-8859-1] (original) +++ trunk/reactos/dll/appcompat/apphelp/apphelp.spec [iso-8859-1] Sun May 22 20:39:41 2016 @@ -58,7 +58,7 @@ @ stub SdbGetDatabaseInformation @ stub SdbGetDatabaseInformationByName @ stub SdbGetDatabaseMatch -@ stub SdbGetDatabaseVersion +@ stdcall SdbGetDatabaseVersion(wstr ptr ptr) @ stub SdbGetDllPath @ stub SdbGetEntryFlags @ stdcall SdbGetFileAttributes(wstr ptr ptr) Modified: trunk/reactos/dll/appcompat/apphelp/sdbapi.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/appcompat/apphelp/sdba…
============================================================================== --- trunk/reactos/dll/appcompat/apphelp/sdbapi.c [iso-8859-1] (original) +++ trunk/reactos/dll/appcompat/apphelp/sdbapi.c [iso-8859-1] Sun May 22 20:39:41 2016 @@ -313,6 +313,78 @@ return SdbpCheckTagType(tag, type); } +PDB SdbpOpenDatabase(LPCWSTR path, PATH_TYPE type, PDWORD major, PDWORD minor) +{ + UNICODE_STRING str; + OBJECT_ATTRIBUTES attr; + IO_STATUS_BLOCK io; + PDB db; + NTSTATUS Status; + BYTE header[12]; + + if (type == DOS_PATH) + { + if (!RtlDosPathNameToNtPathName_U(path, &str, NULL, NULL)) + return NULL; + } + else + RtlInitUnicodeString(&str, path); + + db = SdbpCreate(); + if (!db) + { + SHIM_ERR("Failed to allocate memory for shim database\n"); + return NULL; + } + + InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, NULL, NULL); + + Status = NtCreateFile(&db->file, FILE_GENERIC_READ | SYNCHRONIZE, + &attr, &io, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ, + FILE_OPEN, FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0); + + if (type == DOS_PATH) + RtlFreeUnicodeString(&str); + + if (!NT_SUCCESS(Status)) + { + SdbCloseDatabase(db); + SHIM_ERR("Failed to open shim database file: 0x%lx\n", Status); + return NULL; + } + + db->size = GetFileSize(db->file, NULL); + db->data = SdbAlloc(db->size); + Status = NtReadFile(db->file, NULL, NULL, NULL, &io, db->data, db->size, NULL, NULL); + + if (!NT_SUCCESS(Status)) + { + SdbCloseDatabase(db); + SHIM_ERR("Failed to open shim database file: 0x%lx\n", Status); + return NULL; + } + + if (!SdbpReadData(db, &header, 0, 12)) + { + SdbCloseDatabase(db); + SHIM_ERR("Failed to read shim database header\n"); + return NULL; + } + + if (memcmp(&header[8], "sdbf", 4) != 0) + { + SdbCloseDatabase(db); + SHIM_ERR("Shim database header is invalid\n"); + return NULL; + } + + *major = *(DWORD*)&header[0]; + *minor = *(DWORD*)&header[4]; + + return db; +} + + /** * Opens specified shim database file. * @@ -323,64 +395,14 @@ */ PDB WINAPI SdbOpenDatabase(LPCWSTR path, PATH_TYPE type) { - NTSTATUS Status; - IO_STATUS_BLOCK io; - OBJECT_ATTRIBUTES attr; - UNICODE_STRING str; PDB db; - BYTE header[12]; - DWORD dwRead = 0; - - if (type == DOS_PATH) - { - if (!RtlDosPathNameToNtPathName_U(path, &str, NULL, NULL)) - return NULL; - } - else - RtlInitUnicodeString(&str, path); - - db = SdbpCreate(); + DWORD major, minor; + + db = SdbpOpenDatabase(path, type, &major, &minor); if (!db) - { - SHIM_ERR("Failed to allocate memory for shim database\n"); return NULL; - } - - InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, NULL, NULL); - - Status = NtCreateFile(&db->file, FILE_GENERIC_READ | SYNCHRONIZE, - &attr, &io, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ, - FILE_OPEN, FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0); - - if (type == DOS_PATH) - RtlFreeUnicodeString(&str); - - if (!NT_SUCCESS(Status)) - { - SdbCloseDatabase(db); - SHIM_ERR("Failed to open shim database file: 0x%lx\n", Status); - return NULL; - } - - db->size = GetFileSize(db->file, NULL); - db->data = SdbAlloc(db->size); - ReadFile(db->file, db->data, db->size, &dwRead, NULL); - - if (!SdbpReadData(db, &header, 0, 12)) - { - SdbCloseDatabase(db); - SHIM_ERR("Failed to read shim database header\n"); - return NULL; - } - - if (memcmp(&header[8], "sdbf", 4) != 0) - { - SdbCloseDatabase(db); - SHIM_ERR("Shim database header is invalid\n"); - return NULL; - } - - if (*(DWORD*)&header[0] != (DWORD)2) + + if (major != 2) { SdbCloseDatabase(db); SHIM_ERR("Invalid shim database version\n"); @@ -490,6 +512,26 @@ { memcpy(Guid, copy_from, sizeof(GUID)); } + return TRUE; +} + +/** + * Read the database version from the specified database. + * + * @param [in] database The database. + * @param [out] VersionHi The first part of the version number. + * @param [out] VersionLo The second part of the version number. + * + * @return TRUE if it succeeds or fails, FALSE if ??? + */ +BOOL WINAPI SdbGetDatabaseVersion(LPCWSTR database, PDWORD VersionHi, PDWORD VersionLo) +{ + PDB db; + + db = SdbpOpenDatabase(database, DOS_PATH, VersionHi, VersionLo); + if (db) + SdbCloseDatabase(db); + return TRUE; } Modified: trunk/rostests/apitests/apphelp/data.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/apphelp/data.c?r…
============================================================================== --- trunk/rostests/apitests/apphelp/data.c [iso-8859-1] (original) +++ trunk/rostests/apitests/apphelp/data.c [iso-8859-1] Sun May 22 20:39:41 2016 @@ -571,3 +571,215 @@ } } +static unsigned char rawData[2356] = { + 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x73, 0x64, 0x62, 0x66, + 0x02, 0x78, 0x3E, 0x01, 0x00, 0x00, 0x03, 0x78, 0x44, 0x00, 0x00, 0x00, + 0x02, 0x38, 0x07, 0x70, 0x03, 0x38, 0x01, 0x60, 0x16, 0x40, 0x01, 0x00, + 0x00, 0x00, 0x01, 0x98, 0x30, 0x00, 0x00, 0x00, 0x4C, 0x4C, 0x41, 0x5F, + 0x54, 0x53, 0x45, 0x54, 0xC6, 0x01, 0x00, 0x00, 0x53, 0x49, 0x44, 0x5F, + 0x54, 0x53, 0x45, 0x54, 0x56, 0x02, 0x00, 0x00, 0x57, 0x45, 0x4E, 0x5F, + 0x54, 0x53, 0x45, 0x54, 0xEC, 0x02, 0x00, 0x00, 0x4B, 0x32, 0x57, 0x5F, + 0x54, 0x53, 0x45, 0x54, 0x7C, 0x03, 0x00, 0x00, 0x03, 0x78, 0x0E, 0x00, + 0x00, 0x00, 0x02, 0x38, 0x07, 0x70, 0x03, 0x38, 0x0B, 0x60, 0x01, 0x98, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x78, 0x0E, 0x00, 0x00, 0x00, 0x02, 0x38, + 0x07, 0x70, 0x03, 0x38, 0x20, 0x60, 0x01, 0x98, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x78, 0x0E, 0x00, 0x00, 0x00, 0x02, 0x38, 0x04, 0x70, 0x03, 0x38, + 0x01, 0x60, 0x01, 0x98, 0x00, 0x00, 0x00, 0x00, 0x03, 0x78, 0x26, 0x00, + 0x00, 0x00, 0x02, 0x38, 0x0D, 0x70, 0x03, 0x38, 0x15, 0x40, 0x01, 0x98, + 0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x74, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x50, 0x04, 0x00, 0x00, 0x03, 0x78, 0x14, 0x00, 0x00, 0x00, 0x02, 0x38, + 0x10, 0x70, 0x03, 0x38, 0x01, 0x60, 0x16, 0x40, 0x01, 0x00, 0x00, 0x00, + 0x01, 0x98, 0x00, 0x00, 0x00, 0x00, 0x03, 0x78, 0x0E, 0x00, 0x00, 0x00, + 0x02, 0x38, 0x12, 0x70, 0x03, 0x38, 0x06, 0x90, 0x01, 0x98, 0x00, 0x00, + 0x00, 0x00, 0x03, 0x78, 0x14, 0x00, 0x00, 0x00, 0x02, 0x38, 0x12, 0x70, + 0x03, 0x38, 0x04, 0x90, 0x16, 0x40, 0x01, 0x00, 0x00, 0x00, 0x01, 0x98, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x78, 0x3E, 0x00, 0x00, 0x00, 0x02, 0x38, + 0x07, 0x70, 0x03, 0x38, 0x04, 0x90, 0x01, 0x98, 0x30, 0x00, 0x00, 0x00, + 0xB5, 0x16, 0xDD, 0x96, 0xC9, 0x6B, 0xC5, 0x04, 0x7C, 0x03, 0x00, 0x00, + 0xCA, 0xA0, 0x3C, 0x5A, 0xDD, 0xFC, 0x99, 0x19, 0xC6, 0x01, 0x00, 0x00, + 0x72, 0xC6, 0xBB, 0xB9, 0x20, 0x71, 0xE3, 0x27, 0xEC, 0x02, 0x00, 0x00, + 0xBF, 0x27, 0xFB, 0xFF, 0x09, 0xB0, 0x4D, 0x8E, 0x56, 0x02, 0x00, 0x00, + 0x01, 0x70, 0x42, 0x03, 0x00, 0x00, 0x01, 0x50, 0x3E, 0x96, 0x3F, 0x00, + 0xE6, 0xF3, 0xD0, 0x01, 0x22, 0x60, 0x06, 0x00, 0x00, 0x00, 0x01, 0x60, + 0x1C, 0x00, 0x00, 0x00, 0x23, 0x40, 0x01, 0x00, 0x00, 0x00, 0x07, 0x90, + 0x10, 0x00, 0x00, 0x00, 0xB7, 0x9A, 0x98, 0x6E, 0x4D, 0x86, 0x75, 0x45, + 0x87, 0x34, 0x90, 0x36, 0x4A, 0xC6, 0x4F, 0xBD, 0x02, 0x70, 0x00, 0x00, + 0x00, 0x00, 0x0B, 0x70, 0x32, 0x00, 0x00, 0x00, 0x01, 0x60, 0x3E, 0x00, + 0x00, 0x00, 0x09, 0x70, 0x26, 0x00, 0x00, 0x00, 0x01, 0x60, 0x5C, 0x00, + 0x00, 0x00, 0x08, 0x60, 0x82, 0x00, 0x00, 0x00, 0x03, 0x70, 0x08, 0x00, + 0x00, 0x00, 0x01, 0x10, 0x03, 0x60, 0xA0, 0x00, 0x00, 0x00, 0x03, 0x70, + 0x06, 0x00, 0x00, 0x00, 0x03, 0x60, 0xBE, 0x00, 0x00, 0x00, 0x07, 0x70, + 0x8A, 0x00, 0x00, 0x00, 0x01, 0x60, 0xDC, 0x00, 0x00, 0x00, 0x06, 0x60, + 0x00, 0x01, 0x00, 0x00, 0x05, 0x60, 0x2C, 0x01, 0x00, 0x00, 0x04, 0x90, + 0x10, 0x00, 0x00, 0x00, 0x52, 0x35, 0x26, 0x1A, 0x04, 0xE9, 0xB2, 0x41, + 0x98, 0x95, 0x1A, 0x40, 0xD9, 0x15, 0x2B, 0x58, 0x0D, 0x70, 0x24, 0x00, + 0x00, 0x00, 0x17, 0x40, 0x01, 0x00, 0x00, 0x00, 0x10, 0x40, 0x01, 0x00, + 0x00, 0x00, 0x15, 0x40, 0x04, 0x00, 0x00, 0x00, 0x24, 0x40, 0x78, 0x00, + 0x30, 0x00, 0x25, 0x40, 0x22, 0x00, 0x20, 0x00, 0x26, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x08, 0x70, 0x32, 0x00, 0x00, 0x00, 0x01, 0x60, 0x5C, 0x01, + 0x00, 0x00, 0x09, 0x60, 0x66, 0x01, 0x00, 0x00, 0x10, 0x60, 0x84, 0x01, + 0x00, 0x00, 0x11, 0x60, 0xA2, 0x01, 0x00, 0x00, 0x13, 0x60, 0xB8, 0x01, + 0x00, 0x00, 0x06, 0x50, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x0D, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0x70, + 0x90, 0x00, 0x00, 0x00, 0x01, 0x60, 0xCE, 0x01, 0x00, 0x00, 0x06, 0x60, + 0xF8, 0x01, 0x00, 0x00, 0x05, 0x60, 0x2A, 0x02, 0x00, 0x00, 0x04, 0x90, + 0x10, 0x00, 0x00, 0x00, 0x2D, 0xE0, 0x94, 0xAE, 0x00, 0x63, 0xE3, 0x4E, + 0x92, 0xC7, 0x6F, 0x51, 0x09, 0xD3, 0xAE, 0xC0, 0x0D, 0x70, 0x24, 0x00, + 0x00, 0x00, 0x17, 0x40, 0x01, 0x00, 0x00, 0x00, 0x10, 0x40, 0x02, 0x00, + 0x00, 0x00, 0x15, 0x40, 0x03, 0x00, 0x00, 0x00, 0x24, 0x40, 0x65, 0x00, + 0x20, 0x00, 0x25, 0x40, 0x00, 0x00, 0x00, 0x00, 0x26, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x08, 0x70, 0x38, 0x00, 0x00, 0x00, 0x01, 0x60, 0x5C, 0x01, + 0x00, 0x00, 0x09, 0x60, 0x66, 0x01, 0x00, 0x00, 0x10, 0x60, 0x84, 0x01, + 0x00, 0x00, 0x11, 0x60, 0xA2, 0x01, 0x00, 0x00, 0x02, 0x50, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x50, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x0B, 0x40, 0x48, 0x18, 0x00, 0x00, 0x13, 0x60, + 0xB8, 0x01, 0x00, 0x00, 0x07, 0x70, 0x8A, 0x00, 0x00, 0x00, 0x01, 0x60, + 0x60, 0x02, 0x00, 0x00, 0x06, 0x60, 0x80, 0x02, 0x00, 0x00, 0x05, 0x60, + 0x9E, 0x02, 0x00, 0x00, 0x04, 0x90, 0x10, 0x00, 0x00, 0x00, 0xC0, 0x58, + 0x69, 0x5B, 0x84, 0x60, 0x7B, 0x4F, 0xB2, 0x9E, 0xD2, 0xE2, 0xA4, 0x11, + 0x98, 0x68, 0x08, 0x70, 0x32, 0x00, 0x00, 0x00, 0x01, 0x60, 0x5C, 0x01, + 0x00, 0x00, 0x09, 0x60, 0x66, 0x01, 0x00, 0x00, 0x10, 0x60, 0x84, 0x01, + 0x00, 0x00, 0x11, 0x60, 0xA2, 0x01, 0x00, 0x00, 0x02, 0x50, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x50, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x13, 0x60, 0xB8, 0x01, 0x00, 0x00, 0x08, 0x70, + 0x12, 0x00, 0x00, 0x00, 0x01, 0x60, 0xC0, 0x02, 0x00, 0x00, 0x01, 0x40, + 0x04, 0x00, 0x00, 0x00, 0x03, 0x40, 0xB0, 0xB0, 0xB0, 0xB0, 0x0B, 0x70, + 0x0C, 0x00, 0x00, 0x00, 0x01, 0x60, 0x3E, 0x00, 0x00, 0x00, 0x1A, 0x40, + 0x8E, 0x01, 0x00, 0x00, 0x07, 0x70, 0xCE, 0x00, 0x00, 0x00, 0x01, 0x60, + 0xEC, 0x02, 0x00, 0x00, 0x06, 0x60, 0x0E, 0x03, 0x00, 0x00, 0x05, 0x60, + 0x26, 0x03, 0x00, 0x00, 0x04, 0x90, 0x10, 0x00, 0x00, 0x00, 0x36, 0x9B, + 0x3E, 0x8A, 0xD0, 0xAF, 0xD0, 0x42, 0x83, 0x8D, 0xE3, 0x1C, 0x19, 0xC4, + 0x15, 0x46, 0x08, 0x70, 0x94, 0x00, 0x00, 0x00, 0x01, 0x60, 0x5C, 0x01, + 0x00, 0x00, 0x01, 0x40, 0x00, 0x08, 0x00, 0x00, 0x03, 0x40, 0xFE, 0x26, + 0x08, 0x55, 0x09, 0x60, 0x66, 0x01, 0x00, 0x00, 0x10, 0x60, 0x84, 0x01, + 0x00, 0x00, 0x11, 0x60, 0xA2, 0x01, 0x00, 0x00, 0x12, 0x60, 0x42, 0x03, + 0x00, 0x00, 0x02, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x03, 0x50, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, 0x40, + 0x03, 0x00, 0x00, 0x00, 0x09, 0x40, 0x04, 0x00, 0x00, 0x00, 0x0A, 0x40, + 0x01, 0x00, 0x00, 0x00, 0x0B, 0x40, 0x48, 0x18, 0x00, 0x00, 0x1C, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x13, 0x60, 0xB8, 0x01, 0x00, 0x00, 0x14, 0x60, + 0x68, 0x03, 0x00, 0x00, 0x15, 0x60, 0x90, 0x03, 0x00, 0x00, 0x16, 0x60, + 0xB0, 0x03, 0x00, 0x00, 0x06, 0x50, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x0D, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x1D, 0x40, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x0B, 0x70, 0x06, 0x00, 0x00, 0x00, 0x01, 0x60, 0xD4, 0x03, 0x00, 0x00, + 0x0D, 0x70, 0x1E, 0x00, 0x00, 0x00, 0x15, 0x40, 0x04, 0x00, 0x00, 0x00, + 0x0E, 0x70, 0x06, 0x00, 0x00, 0x00, 0x19, 0x60, 0xEC, 0x03, 0x00, 0x00, + 0x1B, 0x60, 0x00, 0x01, 0x00, 0x00, 0x18, 0x60, 0x24, 0x04, 0x00, 0x00, + 0x0D, 0x70, 0x1E, 0x00, 0x00, 0x00, 0x15, 0x40, 0x03, 0x00, 0x00, 0x00, + 0x0E, 0x70, 0x06, 0x00, 0x00, 0x00, 0x19, 0x60, 0x3E, 0x04, 0x00, 0x00, + 0x1B, 0x60, 0xF8, 0x01, 0x00, 0x00, 0x18, 0x60, 0x7C, 0x04, 0x00, 0x00, + 0x01, 0x78, 0x96, 0x04, 0x00, 0x00, 0x01, 0x88, 0x10, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x2E, 0x00, 0x31, 0x00, 0x2E, 0x00, 0x30, 0x00, 0x2E, 0x00, + 0x33, 0x00, 0x00, 0x00, 0x01, 0x88, 0x1C, 0x00, 0x00, 0x00, 0x61, 0x00, + 0x70, 0x00, 0x70, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x70, 0x00, + 0x5F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x31, 0x00, + 0x00, 0x00, 0x01, 0x88, 0x18, 0x00, 0x00, 0x00, 0x54, 0x00, 0x65, 0x00, + 0x73, 0x00, 0x74, 0x00, 0x4E, 0x00, 0x65, 0x00, 0x77, 0x00, 0x4D, 0x00, + 0x6F, 0x00, 0x64, 0x00, 0x65, 0x00, 0x00, 0x00, 0x01, 0x88, 0x20, 0x00, + 0x00, 0x00, 0x56, 0x00, 0x69, 0x00, 0x72, 0x00, 0x74, 0x00, 0x75, 0x00, + 0x61, 0x00, 0x6C, 0x00, 0x52, 0x00, 0x65, 0x00, 0x67, 0x00, 0x69, 0x00, + 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x79, 0x00, 0x00, 0x00, 0x01, 0x88, + 0x18, 0x00, 0x00, 0x00, 0x54, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6D, 0x00, + 0x65, 0x00, 0x41, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x76, 0x00, + 0x65, 0x00, 0x00, 0x00, 0x01, 0x88, 0x18, 0x00, 0x00, 0x00, 0x69, 0x00, + 0x6E, 0x00, 0x63, 0x00, 0x6C, 0x00, 0x75, 0x00, 0x64, 0x00, 0x65, 0x00, + 0x2E, 0x00, 0x64, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x01, 0x88, + 0x18, 0x00, 0x00, 0x00, 0x65, 0x00, 0x78, 0x00, 0x63, 0x00, 0x6C, 0x00, + 0x75, 0x00, 0x64, 0x00, 0x65, 0x00, 0x2E, 0x00, 0x64, 0x00, 0x6C, 0x00, + 0x6C, 0x00, 0x00, 0x00, 0x01, 0x88, 0x1E, 0x00, 0x00, 0x00, 0x74, 0x00, + 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x5F, 0x00, 0x61, 0x00, 0x6C, 0x00, + 0x6C, 0x00, 0x6F, 0x00, 0x77, 0x00, 0x2E, 0x00, 0x65, 0x00, 0x78, 0x00, + 0x65, 0x00, 0x00, 0x00, 0x01, 0x88, 0x26, 0x00, 0x00, 0x00, 0x61, 0x00, + 0x70, 0x00, 0x70, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x70, 0x00, + 0x5F, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x5F, 0x00, + 0x61, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x77, 0x00, 0x00, 0x00, + 0x01, 0x88, 0x2A, 0x00, 0x00, 0x00, 0x61, 0x00, 0x70, 0x00, 0x70, 0x00, + 0x68, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x70, 0x00, 0x5F, 0x00, 0x76, 0x00, + 0x65, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x5F, 0x00, + 0x61, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x77, 0x00, 0x00, 0x00, + 0x01, 0x88, 0x04, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x00, 0x00, 0x01, 0x88, + 0x18, 0x00, 0x00, 0x00, 0x43, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x70, 0x00, + 0x61, 0x00, 0x6E, 0x00, 0x79, 0x00, 0x4E, 0x00, 0x61, 0x00, 0x6D, 0x00, + 0x65, 0x00, 0x00, 0x00, 0x01, 0x88, 0x18, 0x00, 0x00, 0x00, 0x50, 0x00, + 0x72, 0x00, 0x6F, 0x00, 0x64, 0x00, 0x75, 0x00, 0x63, 0x00, 0x74, 0x00, + 0x4E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00, 0x00, 0x01, 0x88, + 0x10, 0x00, 0x00, 0x00, 0x31, 0x00, 0x2E, 0x00, 0x30, 0x00, 0x2E, 0x00, + 0x30, 0x00, 0x2E, 0x00, 0x31, 0x00, 0x00, 0x00, 0x01, 0x88, 0x10, 0x00, + 0x00, 0x00, 0x31, 0x00, 0x2E, 0x00, 0x30, 0x00, 0x2E, 0x00, 0x30, 0x00, + 0x2E, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x88, 0x24, 0x00, 0x00, 0x00, + 0x74, 0x00, 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x5F, 0x00, 0x64, 0x00, + 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, + 0x77, 0x00, 0x2E, 0x00, 0x65, 0x00, 0x78, 0x00, 0x65, 0x00, 0x00, 0x00, + 0x01, 0x88, 0x2C, 0x00, 0x00, 0x00, 0x61, 0x00, 0x70, 0x00, 0x70, 0x00, + 0x68, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x70, 0x00, 0x5F, 0x00, 0x6E, 0x00, + 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x5F, 0x00, 0x64, 0x00, 0x69, 0x00, + 0x73, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x77, 0x00, + 0x00, 0x00, 0x01, 0x88, 0x30, 0x00, 0x00, 0x00, 0x61, 0x00, 0x70, 0x00, + 0x70, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x70, 0x00, 0x5F, 0x00, + 0x76, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x6F, 0x00, 0x72, 0x00, + 0x5F, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x6C, 0x00, + 0x6C, 0x00, 0x6F, 0x00, 0x77, 0x00, 0x00, 0x00, 0x01, 0x88, 0x1A, 0x00, + 0x00, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x5F, 0x00, + 0x6E, 0x00, 0x65, 0x00, 0x77, 0x00, 0x2E, 0x00, 0x65, 0x00, 0x78, 0x00, + 0x65, 0x00, 0x00, 0x00, 0x01, 0x88, 0x18, 0x00, 0x00, 0x00, 0x66, 0x00, + 0x69, 0x00, 0x78, 0x00, 0x6E, 0x00, 0x65, 0x00, 0x77, 0x00, 0x5F, 0x00, + 0x6E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00, 0x00, 0x01, 0x88, + 0x1C, 0x00, 0x00, 0x00, 0x66, 0x00, 0x69, 0x00, 0x78, 0x00, 0x6E, 0x00, + 0x65, 0x00, 0x77, 0x00, 0x5F, 0x00, 0x76, 0x00, 0x65, 0x00, 0x6E, 0x00, + 0x64, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x00, 0x00, 0x01, 0x88, 0x26, 0x00, + 0x00, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x5F, 0x00, + 0x63, 0x00, 0x68, 0x00, 0x65, 0x00, 0x63, 0x00, 0x6B, 0x00, 0x66, 0x00, + 0x69, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x2E, 0x00, 0x74, 0x00, 0x78, 0x00, + 0x74, 0x00, 0x00, 0x00, 0x01, 0x88, 0x1C, 0x00, 0x00, 0x00, 0x74, 0x00, + 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x5F, 0x00, 0x77, 0x00, 0x32, 0x00, + 0x6B, 0x00, 0x33, 0x00, 0x2E, 0x00, 0x65, 0x00, 0x78, 0x00, 0x65, 0x00, + 0x00, 0x00, 0x01, 0x88, 0x12, 0x00, 0x00, 0x00, 0x66, 0x00, 0x69, 0x00, + 0x78, 0x00, 0x5F, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, + 0x00, 0x00, 0x01, 0x88, 0x16, 0x00, 0x00, 0x00, 0x66, 0x00, 0x69, 0x00, + 0x78, 0x00, 0x5F, 0x00, 0x76, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x64, 0x00, + 0x6F, 0x00, 0x72, 0x00, 0x00, 0x00, 0x01, 0x88, 0x20, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x69, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x44, 0x00, 0x65, 0x00, + 0x73, 0x00, 0x63, 0x00, 0x72, 0x00, 0x69, 0x00, 0x70, 0x00, 0x74, 0x00, + 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x00, 0x00, 0x01, 0x88, 0x22, 0x00, + 0x00, 0x00, 0x4F, 0x00, 0x72, 0x00, 0x69, 0x00, 0x67, 0x00, 0x69, 0x00, + 0x6E, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x46, 0x00, 0x69, 0x00, 0x6C, 0x00, + 0x65, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00, 0x00, + 0x01, 0x88, 0x1A, 0x00, 0x00, 0x00, 0x49, 0x00, 0x6E, 0x00, 0x74, 0x00, + 0x65, 0x00, 0x72, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x4E, 0x00, + 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00, 0x00, 0x01, 0x88, 0x1E, 0x00, + 0x00, 0x00, 0x4C, 0x00, 0x65, 0x00, 0x67, 0x00, 0x61, 0x00, 0x6C, 0x00, + 0x43, 0x00, 0x6F, 0x00, 0x70, 0x00, 0x79, 0x00, 0x72, 0x00, 0x69, 0x00, + 0x67, 0x00, 0x68, 0x00, 0x74, 0x00, 0x00, 0x00, 0x01, 0x88, 0x12, 0x00, + 0x00, 0x00, 0x57, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x53, 0x00, 0x72, 0x00, + 0x76, 0x00, 0x30, 0x00, 0x33, 0x00, 0x00, 0x00, 0x01, 0x88, 0x32, 0x00, + 0x00, 0x00, 0x68, 0x00, 0x74, 0x00, 0x74, 0x00, 0x70, 0x00, 0x3A, 0x00, + 0x2F, 0x00, 0x2F, 0x00, 0x72, 0x00, 0x65, 0x00, 0x61, 0x00, 0x63, 0x00, + 0x74, 0x00, 0x6F, 0x00, 0x73, 0x00, 0x2E, 0x00, 0x6F, 0x00, 0x72, 0x00, + 0x67, 0x00, 0x2F, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, + 0x77, 0x00, 0x00, 0x00, 0x01, 0x88, 0x14, 0x00, 0x00, 0x00, 0x41, 0x00, + 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x77, 0x00, 0x20, 0x00, 0x69, 0x00, + 0x74, 0x00, 0x21, 0x00, 0x00, 0x00, 0x01, 0x88, 0x38, 0x00, 0x00, 0x00, + 0x68, 0x00, 0x74, 0x00, 0x74, 0x00, 0x70, 0x00, 0x3A, 0x00, 0x2F, 0x00, + 0x2F, 0x00, 0x72, 0x00, 0x65, 0x00, 0x61, 0x00, 0x63, 0x00, 0x74, 0x00, + 0x6F, 0x00, 0x73, 0x00, 0x2E, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x67, 0x00, + 0x2F, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x6C, 0x00, + 0x6C, 0x00, 0x6F, 0x00, 0x77, 0x00, 0x00, 0x00, 0x01, 0x88, 0x1A, 0x00, + 0x00, 0x00, 0x4E, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x20, 0x00, 0x61, 0x00, + 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x77, 0x00, 0x65, 0x00, 0x64, 0x00, + 0x21, 0x00, 0x00, 0x00 +}; + +void test_create_db(const char* name) +{ + HANDLE file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + ok(file != INVALID_HANDLE_VALUE, "can't create file\n"); + if(file != INVALID_HANDLE_VALUE) + { + DWORD size; + WriteFile(file, rawData, sizeof(rawData), &size, NULL); + CloseHandle(file); + } +} + Modified: trunk/rostests/apitests/apphelp/db.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/apphelp/db.c?rev…
============================================================================== --- trunk/rostests/apitests/apphelp/db.c [iso-8859-1] (original) +++ trunk/rostests/apitests/apphelp/db.c [iso-8859-1] Sun May 22 20:39:41 2016 @@ -36,6 +36,9 @@ #include "wine/test.h" +/* data.c */ +void test_create_db(const char* name); + typedef WORD TAG; typedef DWORD TAGID; typedef DWORD TAGREF; @@ -61,21 +64,72 @@ #define TAG_TYPE_STRING 0x8000 #define TAG_TYPE_BINARY 0x9000 #define TAG_NULL 0x0 + +#define TAG_INCLUDE (0x1 | TAG_TYPE_NULL) + +#define TAG_MATCH_MODE (0x1 | TAG_TYPE_WORD) + #define TAG_SIZE (0x1 | TAG_TYPE_DWORD) - -#define TAG_MATCH_MODE (0x1 | TAG_TYPE_WORD) - +#define TAG_CHECKSUM (0x3 | TAG_TYPE_DWORD) +#define TAG_MODULE_TYPE (0x6 | TAG_TYPE_DWORD) +#define TAG_VERFILEOS (0x9 | TAG_TYPE_DWORD) +#define TAG_VERFILETYPE (0xA | TAG_TYPE_DWORD) +#define TAG_PE_CHECKSUM (0xB | TAG_TYPE_DWORD) +#define TAG_PROBLEMSEVERITY (0x10 | TAG_TYPE_DWORD) +#define TAG_HTMLHELPID (0x15 | TAG_TYPE_DWORD) +#define TAG_FLAGS (0x17 | TAG_TYPE_DWORD) +#define TAG_LAYER_TAGID (0x1A | TAG_TYPE_DWORD) +#define TAG_LINKER_VERSION (0x1C | TAG_TYPE_DWORD) +#define TAG_LINK_DATE (0x1D | TAG_TYPE_DWORD) +#define TAG_UPTO_LINK_DATE (0x1E | TAG_TYPE_DWORD) +#define TAG_APP_NAME_RC_ID (0x24 | TAG_TYPE_DWORD) +#define TAG_VENDOR_NAME_RC_ID (0x25 | TAG_TYPE_DWORD) +#define TAG_SUMMARY_MSG_RC_ID (0x26 | TAG_TYPE_DWORD) +#define TAG_OS_PLATFORM (0x23 | TAG_TYPE_DWORD) + +#define TAG_TIME (0x1 | TAG_TYPE_QWORD) +#define TAG_BIN_FILE_VERSION (0x2 | TAG_TYPE_QWORD) +#define TAG_BIN_PRODUCT_VERSION (0x3 | TAG_TYPE_QWORD) +#define TAG_UPTO_BIN_PRODUCT_VERSION (0x6 | TAG_TYPE_QWORD) +#define TAG_UPTO_BIN_FILE_VERSION (0xD | TAG_TYPE_QWORD) #define TAG_FLAG_LUA (0x10 | TAG_TYPE_QWORD) +#define TAG_DATABASE (0x1 | TAG_TYPE_LIST) +#define TAG_INEXCLUD (0x3 | TAG_TYPE_LIST) +#define TAG_EXE (0x7 | TAG_TYPE_LIST) +#define TAG_MATCHING_FILE (0x8 | TAG_TYPE_LIST) +#define TAG_SHIM_REF (0x9| TAG_TYPE_LIST) +#define TAG_LAYER (0xB | TAG_TYPE_LIST) +#define TAG_APPHELP (0xD | TAG_TYPE_LIST) +#define TAG_LINK (0xE | TAG_TYPE_LIST) #define TAG_STRINGTABLE (0x801 | TAG_TYPE_LIST) +#define TAG_STRINGTABLE_ITEM (0x801 | TAG_TYPE_STRING) + #define TAG_NAME (0x1 | TAG_TYPE_STRINGREF) -#define TAG_STRINGTABLE_ITEM (0x801 | TAG_TYPE_STRING) - +#define TAG_MODULE (0x3 | TAG_TYPE_STRINGREF) +#define TAG_VENDOR (0x5 | TAG_TYPE_STRINGREF) +#define TAG_APP_NAME (0x6 | TAG_TYPE_STRINGREF) +#define TAG_COMMAND_LINE (0x8 | TAG_TYPE_STRINGREF) +#define TAG_COMPANY_NAME (0x9 | TAG_TYPE_STRINGREF) +#define TAG_PRODUCT_NAME (0x10 | TAG_TYPE_STRINGREF) +#define TAG_PRODUCT_VERSION (0x11 | TAG_TYPE_STRINGREF) +#define TAG_FILE_DESCRIPTION (0x12 | TAG_TYPE_STRINGREF) +#define TAG_FILE_VERSION (0x13 | TAG_TYPE_STRINGREF) +#define TAG_ORIGINAL_FILENAME (0x14 | TAG_TYPE_STRINGREF) +#define TAG_INTERNAL_NAME (0x15 | TAG_TYPE_STRINGREF) +#define TAG_LEGAL_COPYRIGHT (0x16 | TAG_TYPE_STRINGREF) +#define TAG_APPHELP_DETAILS (0x18 | TAG_TYPE_STRINGREF) +#define TAG_LINK_URL (0x19 | TAG_TYPE_STRINGREF) +#define TAG_APPHELP_TITLE (0x1B | TAG_TYPE_STRINGREF) + +#define TAG_COMPILER_VERSION (0x22 | TAG_TYPE_STRINGREF) #define TAG_GENERAL (0x2 | TAG_TYPE_NULL) +#define TAG_EXE_ID (0x4 | TAG_TYPE_BINARY) #define TAG_DATA_BITS (0x5 | TAG_TYPE_BINARY) +#define TAG_DATABASE_ID (0x7 | TAG_TYPE_BINARY) @@ -83,6 +137,7 @@ static LPCWSTR (WINAPI *pSdbTagToString)(TAG); static PDB (WINAPI *pSdbOpenDatabase)(LPCWSTR, PATH_TYPE); static PDB (WINAPI *pSdbCreateDatabase)(LPCWSTR, PATH_TYPE); +static BOOL (WINAPI *pSdbGetDatabaseVersion)(LPCWSTR, PDWORD, PDWORD); static void (WINAPI *pSdbCloseDatabase)(PDB); static void (WINAPI *pSdbCloseDatabaseWrite)(PDB); static TAG (WINAPI *pSdbGetTagFromTagID)(PDB, TAGID); @@ -95,6 +150,8 @@ static BOOL (WINAPI *pSdbWriteStringRefTag)(PDB, TAG, TAGID); static TAGID (WINAPI *pSdbBeginWriteListTag)(PDB, TAG); static BOOL (WINAPI *pSdbEndWriteListTag)(PDB, TAGID); +static TAGID (WINAPI *pSdbFindFirstTag)(PDB, TAGID, TAG); +static TAGID (WINAPI *pSdbFindNextTag)(PDB, TAGID, TAGID); static WORD (WINAPI *pSdbReadWORDTag)(PDB, TAGID, WORD); static DWORD (WINAPI *pSdbReadDWORDTag)(PDB, TAGID, DWORD); static QWORD (WINAPI *pSdbReadQWORDTag)(PDB, TAGID, QWORD); @@ -105,6 +162,8 @@ static LPWSTR (WINAPI *pSdbGetStringTagPtr)(PDB, TAGID); static TAGID (WINAPI *pSdbGetFirstChild)(PDB, TAGID); static TAGID (WINAPI *pSdbGetNextChild)(PDB, TAGID, TAGID); +static BOOL (WINAPI *pSdbGetDatabaseID)(PDB, GUID*); +static BOOL (WINAPI *pSdbGUIDToString)(CONST GUID *, PCWSTR, SIZE_T); static void Write(HANDLE file, LPCVOID buffer, DWORD size) { @@ -114,8 +173,9 @@ static void test_Sdb(void) { - static const WCHAR path[] = {'t','e','m','p',0}; - static const WCHAR path2[] = {'t','e','m','p','2',0}; + static const WCHAR temp[] = {'t','e','m','p',0}; + static const WCHAR path1[] = {'t','e','m','p','.','s','d','b',0}; + static const WCHAR path2[] = {'t','e','m','p','2','.','b','i','n',0}; static const WCHAR tag_size_string[] = {'S','I','Z','E',0}; static const WCHAR tag_flag_lua_string[] = {'F','L','A','G','_','L','U','A',0}; static const TAG tags[5] = { @@ -134,7 +194,7 @@ LPCWSTR string; PBYTE binary; - pdb = pSdbCreateDatabase(path, DOS_PATH); + pdb = pSdbCreateDatabase(path1, DOS_PATH); ok (pdb != NULL, "failed to create database\n"); if(pdb != NULL) { @@ -146,7 +206,7 @@ ok (ret, "failed to write stringref tag\n"); tagid = pSdbBeginWriteListTag(pdb, tags[3]); ok (tagid != TAGID_NULL, "unexpected NULL tagid\n"); - ret = pSdbWriteStringTag(pdb, tags[4], path); + ret = pSdbWriteStringTag(pdb, tags[4], temp); ok (ret, "failed to write string tag\n"); ret = pSdbWriteNULLTag(pdb, TAG_GENERAL); ok (ret, "failed to write NULL tag\n"); @@ -159,7 +219,7 @@ } /* [Err ][SdbGetDatabaseID ] Failed to get root tag */ - pdb = pSdbOpenDatabase(path, DOS_PATH); + pdb = pSdbOpenDatabase(path1, DOS_PATH); ok(pdb != NULL, "unexpected NULL handle\n"); if(pdb) @@ -193,15 +253,15 @@ tagid = pSdbGetNextChild(pdb, TAGID_ROOT, tagid); string = pSdbGetStringTagPtr(pdb, tagid); - ok (string && (lstrcmpW(string, path) == 0), "unexpected string %s, expected %s\n", - wine_dbgstr_w(string), wine_dbgstr_w(path)); + ok (string && (lstrcmpW(string, temp) == 0), "unexpected string %s, expected %s\n", + wine_dbgstr_w(string), wine_dbgstr_w(temp)); ptagid = pSdbGetNextChild(pdb, TAGID_ROOT, tagid); tagid = pSdbGetFirstChild(pdb, ptagid); string = pSdbGetStringTagPtr(pdb, tagid); - ok (string && (lstrcmpW(string, path) == 0), "unexpected string %s, expected %s\n", - wine_dbgstr_w(string), wine_dbgstr_w(path)); + ok (string && (lstrcmpW(string, temp) == 0), "unexpected string %s, expected %s\n", + wine_dbgstr_w(string), wine_dbgstr_w(temp)); ok (pSdbReadStringTag(pdb, tagid, buffer, 6), "failed to write string to buffer\n"); /* [Err ][SdbpReadTagData ] Buffer too small. Avail: 6, Need: 10. */ @@ -219,14 +279,14 @@ pSdbCloseDatabase(pdb); } - DeleteFileW(path); + DeleteFileW(path1); file = CreateFileW(path2, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); ok (file != INVALID_HANDLE_VALUE, "failed to open file\n"); Write(file, &qword, 8); CloseHandle(file); - pdb = pSdbCreateDatabase(path, DOS_PATH); + pdb = pSdbCreateDatabase(path1, DOS_PATH); ok(pdb != NULL, "unexpected NULL handle\n"); if(pdb) @@ -236,7 +296,7 @@ pSdbCloseDatabaseWrite(pdb); /* [Err ][SdbCloseDatabase ] Failed to close the file. */ DeleteFileW(path2); - pdb = pSdbOpenDatabase(path, DOS_PATH); + pdb = pSdbOpenDatabase(path1, DOS_PATH); ok(pdb != NULL, "unexpected NULL handle\n"); binary = pSdbGetBinaryTagData(pdb, _TAGID_ROOT); ok(memcmp(binary, &qword, 8) == 0, "binary data is corrupt\n"); @@ -245,7 +305,447 @@ ok(memcmp(buffer, &qword, 8) == 0, "binary data is corrupt\n"); pSdbCloseDatabase(pdb); } - DeleteFileW(path); + DeleteFileW(path1); +} + +static void match_str_attr_imp(PDB pdb, TAGID parent, TAG find, const char* compare) +{ + TAGID attr = pSdbFindFirstTag(pdb, parent, find); + winetest_ok(attr != TAG_NULL, "Could not find: %x\n", find); + if (attr != TAG_NULL) + { + LPWSTR name = pSdbGetStringTagPtr(pdb, attr); + winetest_ok(name != NULL, "Could not convert attr to str.\n"); + if (name) + { + char name_a[100]; + WideCharToMultiByte(CP_ACP, 0, name, -1, name_a, sizeof(name_a), NULL, NULL); + winetest_ok(strcmp(name_a, compare) == 0, "Expected tagid %x to be %s, was %s\n", attr, compare, name_a); + } + } +} + +static void match_dw_attr_imp(PDB pdb, TAGID parent, TAG find, DWORD compare) +{ + TAGID attr = pSdbFindFirstTag(pdb, parent, find); + winetest_ok(attr != TAG_NULL, "Could not find: %x\n", find); + if (attr != TAG_NULL) + { + DWORD val = pSdbReadDWORDTag(pdb, attr, 0x1234567); + winetest_ok(val == compare, "Expected tagid %x to be 0x%x, was 0x%x\n", attr, compare, val); + } +} + +static void match_qw_attr_imp(PDB pdb, TAGID parent, TAG find, QWORD compare) +{ + TAGID attr = pSdbFindFirstTag(pdb, parent, find); + winetest_ok(attr != TAG_NULL, "Could not find: %x\n", find); + if (attr != TAG_NULL) + { + QWORD val = pSdbReadQWORDTag(pdb, attr, 0x123456789abcdef); + winetest_ok(val == compare, "Expected tagid %x to be 0x%I64x, was 0x%I64x\n", attr, compare, val); + } +} + +static void match_guid_attr_imp(PDB pdb, TAGID parent, TAG find, const GUID* compare) +{ + TAGID attr = pSdbFindFirstTag(pdb, parent, find); + winetest_ok(attr != TAG_NULL, "Could not find: %x\n", find); + if (attr != TAG_NULL) + { + GUID guid = {0}; + BOOL result = pSdbReadBinaryTag(pdb, attr, (PBYTE)&guid, sizeof(guid)); + winetest_ok(result, "expected pSdbReadBinaryTag not to fail.\n"); + winetest_ok(IsEqualGUID(&guid, compare), "expected guids to be equal(%s:%s)\n", wine_dbgstr_guid(&guid), wine_dbgstr_guid(compare)); + } +} + +#define match_str_attr (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : match_str_attr_imp +#define match_dw_attr (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : match_dw_attr_imp +#define match_qw_attr (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : match_qw_attr_imp +#define match_guid_attr (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : match_guid_attr_imp + + +//The application name cannot contain any of the following characters: +// \ / < > : * ? | " + +static void check_db_properties(PDB pdb, TAGID root) +{ + TAGID iter = pSdbFindFirstTag(pdb, root, TAG_DATABASE_ID); + ok(iter != TAGID_NULL, "expected a result, got TAGID_NULL\n"); + if(iter != TAGID_NULL) + { + GUID guid = {0}, guid2 = {0}; + BOOL result = pSdbReadBinaryTag(pdb, iter, (PBYTE)&guid, sizeof(guid)); + ok(result, "expected SdbReadBinaryTag not to fail.\n"); + if(result) + { + WCHAR guid_wstr[50]; + result = pSdbGUIDToString(&guid, guid_wstr, 50); + ok(result, "expected SdbGUIDToString not to fail.\n"); + if(result) + { + char guid_str[50]; + WideCharToMultiByte( CP_ACP, 0, guid_wstr, -1, guid_str, sizeof(guid_str), NULL, NULL ); + ok_str(guid_str, "{6e989ab7-864d-4575-8734-90364ac64fbd}"); + } + ok(pSdbGetDatabaseID(pdb, &guid2),"expected SdbGetDatabaseID not to fail.\n"); + ok(IsEqualGUID(&guid, &guid2), "expected guids to be equal(%s:%s)\n", wine_dbgstr_guid(&guid), wine_dbgstr_guid(&guid2)); + } + } + match_qw_attr(pdb, root, TAG_TIME, 0x1d0f3e6003f963e); + match_str_attr(pdb, root, TAG_COMPILER_VERSION, "2.1.0.3"); + match_str_attr(pdb, root, TAG_NAME, "apphelp_test1"); + match_dw_attr(pdb, root, TAG_OS_PLATFORM, 1); +} + +static void check_db_layer(PDB pdb, TAGID layer) +{ + TAGID shimref, inexclude, is_include; + ok(layer != TAGID_NULL, "Expected a valid layer, got NULL\n"); + if(!layer) + return; + + match_str_attr(pdb, layer, TAG_NAME, "TestNewMode"); + shimref = pSdbFindFirstTag(pdb, layer, TAG_SHIM_REF); + ok(shimref != TAGID_NULL, "Expected a valid shim ref, got NULL\n"); + if(!shimref) + return; + + match_str_attr(pdb, shimref, TAG_NAME, "VirtualRegistry"); + match_str_attr(pdb, shimref, TAG_COMMAND_LINE, "ThemeActive"); + inexclude = pSdbFindFirstTag(pdb, shimref, TAG_INEXCLUD); + ok(inexclude != TAGID_NULL, "Expected a valid in/exclude ref, got NULL\n"); + if(!inexclude) + return; + + is_include = pSdbFindFirstTag(pdb, inexclude, TAG_INCLUDE); + ok(is_include != TAGID_NULL, "Expected a valid include ref, got NULL\n"); + match_str_attr(pdb, inexclude, TAG_MODULE, "include.dll"); + + inexclude = pSdbFindNextTag(pdb, shimref, inexclude); + ok(inexclude != TAGID_NULL, "Expected a valid in/exclude ref, got NULL\n"); + if(!inexclude) + return; + + is_include = pSdbFindFirstTag(pdb, inexclude, TAG_INCLUDE); + ok(is_include == TAGID_NULL, "Expected a NULL include ref, but got one anyway.\n"); + match_str_attr(pdb, inexclude, TAG_MODULE, "exclude.dll"); +} + +static void check_matching_file(PDB pdb, TAGID exe, TAGID matching_file, int num) +{ + ok(matching_file != TAGID_NULL, "Expected to find atleast 1 matching file.\n"); + if(matching_file == TAGID_NULL) + return; + + ok(num < 4, "Too many matches, expected only 4!\n"); + if (num >= 4) + return; + + + match_str_attr(pdb, matching_file, TAG_NAME, "*"); + match_str_attr(pdb, matching_file, TAG_COMPANY_NAME, "CompanyName"); + match_str_attr(pdb, matching_file, TAG_PRODUCT_NAME, "ProductName"); + match_str_attr(pdb, matching_file, TAG_PRODUCT_VERSION, "1.0.0.1"); + match_str_attr(pdb, matching_file, TAG_FILE_VERSION, "1.0.0.0"); + + if( num == 0 || num == 3) + { + match_qw_attr(pdb, matching_file, TAG_UPTO_BIN_PRODUCT_VERSION, 0x1000000000001); + match_qw_attr(pdb, matching_file, TAG_UPTO_BIN_FILE_VERSION, 0x1000000000000); + } + if(num == 1 || num == 3) + { + match_dw_attr(pdb, matching_file, TAG_PE_CHECKSUM, 0x1848); + } + if(num != 0) + { + match_qw_attr(pdb, matching_file, TAG_BIN_PRODUCT_VERSION, 0x1000000000001); + match_qw_attr(pdb, matching_file, TAG_BIN_FILE_VERSION, 0x1000000000000); + } + if(num == 3) + { + match_dw_attr(pdb, matching_file, TAG_SIZE, 0x800); + match_dw_attr(pdb, matching_file, TAG_CHECKSUM, 0x550826fe); + match_str_attr(pdb, matching_file, TAG_FILE_DESCRIPTION, "FileDescription"); + match_dw_attr(pdb, matching_file, TAG_MODULE_TYPE, 3); + match_dw_attr(pdb, matching_file, TAG_VERFILEOS, 4); + match_dw_attr(pdb, matching_file, TAG_VERFILETYPE, 1); + match_dw_attr(pdb, matching_file, TAG_LINKER_VERSION, 0); + match_str_attr(pdb, matching_file, TAG_ORIGINAL_FILENAME, "OriginalFilename"); + match_str_attr(pdb, matching_file, TAG_INTERNAL_NAME, "InternalName"); + match_str_attr(pdb, matching_file, TAG_LEGAL_COPYRIGHT, "LegalCopyright"); + match_dw_attr(pdb, matching_file, TAG_LINK_DATE, 0); + match_dw_attr(pdb, matching_file, TAG_UPTO_LINK_DATE, 0); + } + if(num > 3) + { + ok(0, "unknown case: %d\n", num); + } + matching_file = pSdbFindNextTag(pdb, exe, matching_file); + if(num == 2) + { + ok(matching_file != TAGID_NULL, "Did expect a secondary match on %d\n", num); + match_str_attr(pdb, matching_file, TAG_NAME, "test_checkfile.txt"); + match_dw_attr(pdb, matching_file, TAG_SIZE, 0x4); + match_dw_attr(pdb, matching_file, TAG_CHECKSUM, 0xb0b0b0b0); + } + else + { + ok(matching_file == TAGID_NULL, "Did not expect a secondary match on %d\n", num); + } +} + +static void check_matching_apphelp(PDB pdb, TAGID apphelp, int num) +{ + if(num == 0) + { +/* +[Window Title] +Program Compatibility Assistant + +[Main Instruction] +This program has known compatibility issues + +[Expanded Information] +Allow it! + +[^] Hide details [ ] Don't show this message again [Check for solutions online] [Run program] [Cancel] +*/ + match_dw_attr(pdb, apphelp, TAG_FLAGS, 1); + match_dw_attr(pdb, apphelp, TAG_PROBLEMSEVERITY, 1); + match_dw_attr(pdb, apphelp, TAG_HTMLHELPID, 4); + match_dw_attr(pdb, apphelp, TAG_APP_NAME_RC_ID, 0x300078); + match_dw_attr(pdb, apphelp, TAG_VENDOR_NAME_RC_ID, 0x200022); + match_dw_attr(pdb, apphelp, TAG_SUMMARY_MSG_RC_ID, 0); + } + else + { +/* +[Window Title] +Program Compatibility Assistant + +[Main Instruction] +This program is blocked due to compatibility issues + +[Expanded Information] +Not allowed! + +[^] Hide details [Check for solutions online] [Cancel] +*/ + match_dw_attr(pdb, apphelp, TAG_FLAGS, 1); + match_dw_attr(pdb, apphelp, TAG_PROBLEMSEVERITY, 2); + match_dw_attr(pdb, apphelp, TAG_HTMLHELPID, 3); + match_dw_attr(pdb, apphelp, TAG_APP_NAME_RC_ID, 0x200065); + match_dw_attr(pdb, apphelp, TAG_VENDOR_NAME_RC_ID, 0); + match_dw_attr(pdb, apphelp, TAG_SUMMARY_MSG_RC_ID, 0); + } + apphelp = pSdbFindNextTag(pdb, apphelp, apphelp); + ok(apphelp == TAGID_NULL, "Did not expect a secondary match on %d\n", num); +} + +static void check_matching_layer(PDB pdb, TAGID layer, int num) +{ + if(num == 2) + { + match_dw_attr(pdb, layer, TAG_LAYER_TAGID, 0x18e); + match_str_attr(pdb, layer, TAG_NAME, "TestNewMode"); + } + else + { + TAGID layer_tagid = pSdbFindFirstTag(pdb, layer, TAG_LAYER_TAGID); + ok(layer_tagid == TAGID_NULL, "expected not to find a layer tagid, got %x\n", layer_tagid); + match_str_attr(pdb, layer, TAG_NAME, "WinSrv03"); + } +} + +static struct +{ + const char* name; + const char* app_name; + const char* vendor; + GUID exe_id; + const char* extra_file; + DWORD dwLayerCount; + TAGREF atrExes_0; + TAGREF atrLayers_0; +} test_exedata[4] = { + { + "test_allow.exe", + "apphelp_name_allow", + "apphelp_vendor_allow", + {0x1a263552,0xe904,0x41b2,{0x98,0x95,0x1a,0x40,0xd9,0x15,0x2b,0x58}}, + NULL, + 0, + 0x1c6, + 0, + }, + { + "test_disallow.exe", + "apphelp_name_disallow", + "apphelp_vendor_disallow", + {0xae94e02d,0x6300,0x4ee3,{0x92,0xc7,0x6f,0x51,0x09,0xd3,0xae,0xc0}}, + NULL, + 0, + 0x256, + 0, + }, + { + "test_new.exe", + "fixnew_name", + "fixnew_vendor", + {0x5b6958c0,0x6084,0x4f7b,{0xb2,0x9e,0xd2,0xe2,0xa4,0x11,0x98,0x68}}, + "test_checkfile.txt", + 1, + 0x2ec, + 0x18e, + }, + { + "test_w2k3.exe", + "fix_name", + "fix_vendor", + {0x8a3e9b36,0xafd0,0x42d0,{0x83,0x8d,0xe3,0x1c,0x19,0xc4,0x15,0x46}}, + NULL, + 0, + 0x37c, + 0, + }, +}; + +static void check_db_exes(PDB pdb, TAGID root) +{ + int num = 0; + TAGID exe = pSdbFindFirstTag(pdb, root, TAG_EXE); + while (exe != TAGID_NULL) + { + TAGID apphelp, layer; + ok(num < 4, "Too many matches, expected only 4!\n"); + if(num >= 4) + break; + match_str_attr(pdb, exe, TAG_NAME, test_exedata[num].name); + match_str_attr(pdb, exe, TAG_APP_NAME, test_exedata[num].app_name); + match_str_attr(pdb, exe, TAG_VENDOR, test_exedata[num].vendor); + match_guid_attr(pdb, exe, TAG_EXE_ID, &test_exedata[num].exe_id); + check_matching_file(pdb, exe, pSdbFindFirstTag(pdb, exe, TAG_MATCHING_FILE), num); + apphelp = pSdbFindFirstTag(pdb, exe, TAG_APPHELP); + if(num == 0 || num == 1) + { + ok(apphelp != TAGID_NULL, "Expected to find a valid apphelp match on %d.\n", num); + if(apphelp) + check_matching_apphelp(pdb, apphelp, num); + } + else + { + ok(apphelp == TAGID_NULL, "Did not expect an apphelp match on %d\n", num); + } + layer = pSdbFindFirstTag(pdb, exe, TAG_LAYER); + if(num == 2 || num == 3) + { + ok(layer != TAGID_NULL, "Expected to find a valid layer match on %d.\n", num); + if(layer) + check_matching_layer(pdb, layer, num); + } + else + { + ok(layer == TAGID_NULL, "Did not expect a layer match on %d\n", num); + } + ++num; + exe = pSdbFindNextTag(pdb, root, exe); + } + ok(num == 4, "Expected to find 4 exe tags, found: %d\n", num); +} + +static struct +{ + DWORD htmlhelpid; + const char* link; + const char* apphelp_title; + const char* apphelp_details; +} test_layerdata[2] = { + { + 4, + "
http://reactos.org/allow
", + "apphelp_name_allow", + "Allow it!", + }, + { + 3, + "
http://reactos.org/disallow
", + "apphelp_name_disallow", + "Not allowed!", + }, +}; + +static void check_db_apphelp(PDB pdb, TAGID root) +{ + int num = 0; + TAGID apphelp = pSdbFindFirstTag(pdb, root, TAG_APPHELP); + while (apphelp != TAGID_NULL) + { + TAGID link; + ok(num < 2, "Too many matches, expected only 4!\n"); + if(num >= 2) + break; + match_dw_attr(pdb, apphelp, TAG_HTMLHELPID, test_layerdata[num].htmlhelpid); + link = pSdbFindFirstTag(pdb, apphelp, TAG_LINK); + ok(link != TAGID_NULL, "expected to find a link tag\n"); + if (link != TAGID_NULL) + { + match_str_attr(pdb, link, TAG_LINK_URL, test_layerdata[num].link); + } + match_str_attr(pdb, apphelp, TAG_APPHELP_TITLE, test_layerdata[num].apphelp_title); + match_str_attr(pdb, apphelp, TAG_APPHELP_DETAILS, test_layerdata[num].apphelp_details); + apphelp = pSdbFindNextTag(pdb, root, apphelp); + num++; + } + ok(num == 2, "Expected to find 2 layer tags, found: %d\n", num); +} + +static void test_CheckDatabaseManually(void) +{ + static const WCHAR path[] = {'t','e','s','t','_','d','b','.','s','d','b',0}; + TAGID root; + PDB pdb; + BOOL ret; + DWORD ver_hi, ver_lo; + + test_create_db("test_db.sdb"); + + /* both ver_hi and ver_lo cannot be null, it'll crash. */ + ver_hi = ver_lo = 0x12345678; + ret = pSdbGetDatabaseVersion(path, &ver_hi, &ver_lo); + ok(ret,"Expected SdbGetDatabaseVersion to succeed\n"); + ok(ver_hi == 2,"Expected ver_hi to be 2, was: %d\n", ver_hi); + ok(ver_lo == 1,"Expected ver_lo to be 1, was: %d\n", ver_lo); + + ver_hi = ver_lo = 0x12345678; + ret = pSdbGetDatabaseVersion(NULL, &ver_hi, &ver_lo); + ok(ret,"Expected SdbGetDatabaseVersion to succeed\n"); + ok(ver_hi == 0x12345678,"Expected ver_hi to be 0x12345678, was: 0x%x\n", ver_hi); + ok(ver_lo == 0x12345678,"Expected ver_lo to be 0x12345678, was: 0x%x\n", ver_lo); + + ver_hi = ver_lo = 0x12345678; + ret = pSdbGetDatabaseVersion(path + 1, &ver_hi, &ver_lo); + ok(ret,"Expected SdbGetDatabaseVersion to succeed\n"); + ok(ver_hi == 0x12345678,"Expected ver_hi to be 0x12345678, was: 0x%x\n", ver_hi); + ok(ver_lo == 0x12345678,"Expected ver_lo to be 0x12345678, was: 0x%x\n", ver_lo); + + pdb = pSdbOpenDatabase(path, DOS_PATH); + ok(pdb != NULL, "unexpected NULL handle\n"); + + root = pSdbFindFirstTag(pdb, TAGID_ROOT, TAG_DATABASE); + ok(root != TAGID_NULL, "expected to find a root tag\n"); + if (root != TAGID_NULL) + { + check_db_properties(pdb, root); + check_db_layer(pdb, pSdbFindFirstTag(pdb, root, TAG_LAYER)); + check_db_exes(pdb, root); + check_db_apphelp(pdb, root); + } + + pSdbCloseDatabase(pdb); + DeleteFileA("test_db.sdb"); } START_TEST(db) @@ -256,6 +756,7 @@ pSdbTagToString = (void *) GetProcAddress(hdll, "SdbTagToString"); pSdbOpenDatabase = (void *) GetProcAddress(hdll, "SdbOpenDatabase"); pSdbCreateDatabase = (void *) GetProcAddress(hdll, "SdbCreateDatabase"); + pSdbGetDatabaseVersion = (void *) GetProcAddress(hdll, "SdbGetDatabaseVersion"); pSdbCloseDatabase = (void *) GetProcAddress(hdll, "SdbCloseDatabase"); pSdbCloseDatabaseWrite = (void *) GetProcAddress(hdll, "SdbCloseDatabaseWrite"); pSdbGetTagFromTagID = (void *) GetProcAddress(hdll, "SdbGetTagFromTagID"); @@ -268,6 +769,8 @@ pSdbWriteStringRefTag = (void *) GetProcAddress(hdll, "SdbWriteStringRefTag"); pSdbBeginWriteListTag = (void *)GetProcAddress(hdll, "SdbBeginWriteListTag"); pSdbEndWriteListTag = (void *) GetProcAddress(hdll, "SdbEndWriteListTag"); + pSdbFindFirstTag = (void *) GetProcAddress(hdll, "SdbFindFirstTag"); + pSdbFindNextTag = (void *) GetProcAddress(hdll, "SdbFindNextTag"); pSdbReadWORDTag = (void *) GetProcAddress(hdll, "SdbReadWORDTag"); pSdbReadDWORDTag = (void *) GetProcAddress(hdll, "SdbReadDWORDTag"); pSdbReadQWORDTag = (void *) GetProcAddress(hdll, "SdbReadQWORDTag"); @@ -278,6 +781,9 @@ pSdbGetStringTagPtr = (void *) GetProcAddress(hdll, "SdbGetStringTagPtr"); pSdbGetFirstChild = (void *) GetProcAddress(hdll, "SdbGetFirstChild"); pSdbGetNextChild = (void *) GetProcAddress(hdll, "SdbGetNextChild"); + pSdbGetDatabaseID = (void *) GetProcAddress(hdll, "SdbGetDatabaseID"); + pSdbGUIDToString = (void *) GetProcAddress(hdll, "SdbGUIDToString"); test_Sdb(); -} + test_CheckDatabaseManually(); +}
8 years, 7 months
1
0
0
0
[mjansen] 71380: [APPHELP][APPHELP_APITEST] Implement most of sdbread and sdbwrite, mainly the work of Mislav Blaževic, with some small additions from me. CORE-10367
by mjansen@svn.reactos.org
Author: mjansen Date: Sun May 22 20:27:02 2016 New Revision: 71380 URL:
http://svn.reactos.org/svn/reactos?rev=71380&view=rev
Log: [APPHELP][APPHELP_APITEST] Implement most of sdbread and sdbwrite, mainly the work of Mislav Blaževic, with some small additions from me. CORE-10367 Added: trunk/reactos/dll/appcompat/apphelp/sdbread.c (with props) trunk/reactos/dll/appcompat/apphelp/sdbwrite.c (with props) trunk/rostests/apitests/apphelp/db.c (with props) Modified: trunk/reactos/dll/appcompat/apphelp/CMakeLists.txt trunk/reactos/dll/appcompat/apphelp/apphelp.h trunk/reactos/dll/appcompat/apphelp/apphelp.spec trunk/reactos/dll/appcompat/apphelp/sdbapi.c trunk/rostests/apitests/apphelp/CMakeLists.txt trunk/rostests/apitests/apphelp/testlist.c Modified: trunk/reactos/dll/appcompat/apphelp/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/appcompat/apphelp/CMak…
============================================================================== --- trunk/reactos/dll/appcompat/apphelp/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/dll/appcompat/apphelp/CMakeLists.txt [iso-8859-1] Sun May 22 20:27:02 2016 @@ -5,6 +5,8 @@ apphelp.c layer.c sdbapi.c + sdbread.c + sdbwrite.c sdbfileattr.c apphelp.spec apphelp.h Modified: trunk/reactos/dll/appcompat/apphelp/apphelp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/appcompat/apphelp/apph…
============================================================================== --- trunk/reactos/dll/appcompat/apphelp/apphelp.h [iso-8859-1] (original) +++ trunk/reactos/dll/appcompat/apphelp/apphelp.h [iso-8859-1] Sun May 22 20:27:02 2016 @@ -32,6 +32,19 @@ #define TAGREF_NULL (0) #define TAGREF_ROOT (0) +typedef struct _DB { + HANDLE file; + DWORD size; + PBYTE data; + TAGID stringtable; + DWORD write_iter; + GUID database_id; +} DB, *PDB; + +/* Flags for SdbInitDatabase */ +#define HID_DOS_PATHS 0x1 +#define HID_DATABASE_FULLPATH 0x2 +#define HID_NO_DATABASE 0x4 #define HID_DATABASE_TYPE_MASK 0xF00F0000 #define SDB_DATABASE_MAIN_MSI 0x80020000 #define SDB_DATABASE_MAIN_SHIM 0x80030000 @@ -47,6 +60,11 @@ }; } ATTRINFO, *PATTRINFO; +typedef enum _PATH_TYPE { + DOS_PATH, + NT_PATH +} PATH_TYPE; + typedef enum _SHIM_LOG_LEVEL { SHIM_ERR = 1, SHIM_WARN = 2, @@ -99,6 +117,18 @@ void WINAPI SdbpCloseMemMappedFile(PMEMMAPPED mapping); DWORD SdbpStrlen(LPCWSTR string); PWSTR SdbpStrDup(LPCWSTR string); +BOOL WINAPI SdbpCheckTagType(TAG tag, WORD type); +BOOL WINAPI SdbpCheckTagIDType(PDB db, TAGID tagid, WORD type); +PDB WINAPI SdbpCreate(void); +PDB WINAPI SdbOpenDatabase(LPCWSTR path, PATH_TYPE type); +void WINAPI SdbCloseDatabase(PDB); +BOOL WINAPI SdbIsNullGUID(CONST GUID *Guid); + +/* sdbread.c */ +BOOL WINAPI SdbpReadData(PDB db, PVOID dest, DWORD offset, DWORD num); +TAG WINAPI SdbGetTagFromTagID(PDB db, TAGID tagid); +TAGID WINAPI SdbFindFirstTag(PDB db, TAGID parent, TAG tag); +BOOL WINAPI SdbGetDatabaseID(PDB db, GUID* Guid); /* layer.c */ Modified: trunk/reactos/dll/appcompat/apphelp/apphelp.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/appcompat/apphelp/apph…
============================================================================== --- trunk/reactos/dll/appcompat/apphelp/apphelp.spec [iso-8859-1] (original) +++ trunk/reactos/dll/appcompat/apphelp/apphelp.spec [iso-8859-1] Sun May 22 20:27:02 2016 @@ -20,32 +20,32 @@ @ stub SdbAddLayerTagRefToQuery @ stub SdbApphelpNotify @ stub SdbApphelpNotifyExSdbApphelpNotifyEx -@ stub SdbBeginWriteListTag +@ stdcall SdbBeginWriteListTag(ptr long) @ stub SdbBuildCompatEnvVariables @ stub SdbCloseApphelpInformation -@ stub SdbCloseDatabase -@ stub SdbCloseDatabaseWrite +@ stdcall SdbCloseDatabase(ptr) +@ stdcall SdbCloseDatabaseWrite(ptr) @ stub SdbCloseLocalDatabase @ stub SdbCommitIndexes -@ stub SdbCreateDatabase +@ stdcall SdbCreateDatabase(wstr long) @ stub SdbCreateHelpCenterURL @ stub SdbCreateMsiTransformFile @ stub SdbDeclareIndex @ stub SdbDumpSearchPathPartCaches @ stub SdbEnumMsiTransforms -@ stub SdbEndWriteListTag +@ stdcall SdbEndWriteListTag(ptr long) @ stub SdbEscapeApphelpURL @ stub SdbFindFirstDWORDIndexedTag @ stub SdbFindFirstMsiPackage @ stub SdbFindFirstMsiPackage_Str @ stub SdbFindFirstNamedTag @ stub SdbFindFirstStringIndexedTag -@ stub SdbFindFirstTag +@ stdcall SdbFindFirstTag(ptr long long) @ stub SdbFindFirstTagRef @ stub SdbFindNextDWORDIndexedTag @ stub SdbFindNextMsiPackage @ stub SdbFindNextStringIndexedTag -@ stub SdbFindNextTag +@ stdcall SdbFindNextTag(ptr long long) @ stub SdbFindNextTagRef @ stub SdbFreeDatabaseInformation @ stdcall SdbFreeFileAttributes(ptr) @@ -53,8 +53,8 @@ @ stub SdbFreeFlagInfo @ stub SdbGetAppCompatDataSize @ stub SdbGetAppPatchDir -@ stub SdbGetBinaryTagData -@ stub SdbGetDatabaseID +@ stdcall SdbGetBinaryTagData(ptr long) +@ stdcall SdbGetDatabaseID(ptr ptr) @ stub SdbGetDatabaseInformation @ stub SdbGetDatabaseInformationByName @ stub SdbGetDatabaseMatch @@ -65,7 +65,7 @@ @ stub SdbGetFileImageType @ stub SdbGetFileImageTypeEx @ stub SdbGetFileInfo -@ stub SdbGetFirstChild +@ stdcall SdbGetFirstChild(ptr long) @ stub SdbGetIndex @ stub SdbGetItemFromItemRef @ stub SdbGetLayerName @@ -74,15 +74,15 @@ @ stub SdbGetMatchingExe @ stub SdbGetMsiPackageInformation @ stub SdbGetNamedLayer -@ stub SdbGetNextChild +@ stdcall SdbGetNextChild(ptr long long) @ stub SdbGetNthUserSdb @ stdcall SdbGetPermLayerKeys(wstr wstr ptr long) @ stub SdbGetShowDebugInfoOption @ stub SdbGetShowDebugInfoOptionValue @ stdcall SdbGetStandardDatabaseGUID(long ptr) -@ stub SdbGetStringTagPtr -@ stub SdbGetTagDataSize -@ stub SdbGetTagFromTagID +@ stdcall SdbGetStringTagPtr(ptr long) +@ stdcall SdbGetTagDataSize(ptr long) +@ stdcall SdbGetTagFromTagID(ptr long) @ stub SdbGrabMatchingInfo @ stub SdbGrabMatchingInfoEx @ stdcall SdbGUIDFromString(wstr ptr) @@ -100,7 +100,7 @@ @ stub SdbOpenApphelpInformation @ stub SdbOpenApphelpInformationByID @ stub SdbOpenApphelpResourceFile -@ stub SdbOpenDatabase +@ stdcall SdbOpenDatabase(wstr long) @ stub SdbOpenDbFromGuid @ stub SdbOpenLocalDatabase @ stub SdbPackAppCompatData @@ -115,18 +115,18 @@ @ stub SdbQueryReinstallUpgrade @ stub SdbReadApphelpData @ stub SdbReadApphelpDetailsData -@ stub SdbReadBinaryTag +@ stdcall SdbReadBinaryTag(ptr long ptr long) @ stub SdbReadBYTETag -@ stub SdbReadDWORDTag +@ stdcall SdbReadDWORDTag(ptr long long) @ stub SdbReadDWORDTagRef @ stub SdbReadEntryInformation @ stub SdbReadMsiTransformInfo @ stub SdbReadPatchBits -@ stub SdbReadQWORDTag +@ stdcall SdbReadQWORDTag(ptr long int64) @ stub SdbReadQWORDTagRef -@ stub SdbReadStringTag +@ stdcall SdbReadStringTag(ptr long wstr long) @ stub SdbReadStringTagRef -@ stub SdbReadWORDTag +@ stdcall SdbReadWORDTag(ptr long long) @ stub SdbReadWORDTagRef @ stub SdbRegisterDatabase @ stub SdbReleaseDatabase @@ -147,16 +147,16 @@ @ stub SdbTagRefToTagID @ stdcall SdbTagToString(long) @ stub SdbUnregisterDatabase -@ stub SdbWriteBinaryTag -@ stub SdbWriteBinaryTagFromFile +@ stdcall SdbWriteBinaryTag(ptr long ptr long) +@ stdcall SdbWriteBinaryTagFromFile(ptr long wstr) @ stub SdbWriteBYTETag -@ stub SdbWriteDWORDTag -@ stub SdbWriteNULLTag -@ stub SdbWriteQWORDTag -@ stub SdbWriteStringRefTag -@ stub SdbWriteStringTag +@ stdcall SdbWriteDWORDTag(ptr long long) +@ stdcall SdbWriteNULLTag(ptr long) +@ stdcall SdbWriteQWORDTag(ptr long int64) +@ stdcall SdbWriteStringRefTag(ptr long long) +@ stdcall SdbWriteStringTag(ptr long wstr) @ stub SdbWriteStringTagDirect -@ stub SdbWriteWORDTag +@ stdcall SdbWriteWORDTag(ptr long long) @ stub SE_DllLoaded @ stub SE_DllUnloaded @ stub SE_GetHookAPIs Modified: trunk/reactos/dll/appcompat/apphelp/sdbapi.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/appcompat/apphelp/sdba…
============================================================================== --- trunk/reactos/dll/appcompat/apphelp/sdbapi.c [iso-8859-1] (original) +++ trunk/reactos/dll/appcompat/apphelp/sdbapi.c [iso-8859-1] Sun May 22 20:27:02 2016 @@ -1,7 +1,7 @@ /* * Copyright 2011 André Hentschel * Copyright 2013 Mislav BlaževiÄ - * Copyright 2015 Mark Jansen + * Copyright 2015,2016 Mark Jansen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -202,6 +202,12 @@ HeapFree(SdbpHeap(), 0, mem); } +PDB WINAPI SdbpCreate(void) +{ + PDB db = (PDB)SdbAlloc(sizeof(DB)); + /* SdbAlloc zeroes the memory. */ + return db; +} DWORD SdbpStrlen(PCWSTR string) { return (lstrlenW(string) + 1) * sizeof(WCHAR); @@ -290,6 +296,119 @@ NtClose(mapping->section); NtClose(mapping->file); RtlZeroMemory(mapping, sizeof(*mapping)); +} + +BOOL WINAPI SdbpCheckTagType(TAG tag, WORD type) +{ + if ((tag & TAG_TYPE_MASK) != type) + return FALSE; + return TRUE; +} + +BOOL WINAPI SdbpCheckTagIDType(PDB db, TAGID tagid, WORD type) +{ + TAG tag = SdbGetTagFromTagID(db, tagid); + if (tag == TAG_NULL) + return FALSE; + return SdbpCheckTagType(tag, type); +} + +/** + * Opens specified shim database file. + * + * @param [in] path Path to the shim database. + * @param [in] type Type of path. Either DOS_PATH or NT_PATH. + * + * @return Success: Handle to the shim database, NULL otherwise. + */ +PDB WINAPI SdbOpenDatabase(LPCWSTR path, PATH_TYPE type) +{ + NTSTATUS Status; + IO_STATUS_BLOCK io; + OBJECT_ATTRIBUTES attr; + UNICODE_STRING str; + PDB db; + BYTE header[12]; + DWORD dwRead = 0; + + if (type == DOS_PATH) + { + if (!RtlDosPathNameToNtPathName_U(path, &str, NULL, NULL)) + return NULL; + } + else + RtlInitUnicodeString(&str, path); + + db = SdbpCreate(); + if (!db) + { + SHIM_ERR("Failed to allocate memory for shim database\n"); + return NULL; + } + + InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, NULL, NULL); + + Status = NtCreateFile(&db->file, FILE_GENERIC_READ | SYNCHRONIZE, + &attr, &io, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ, + FILE_OPEN, FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0); + + if (type == DOS_PATH) + RtlFreeUnicodeString(&str); + + if (!NT_SUCCESS(Status)) + { + SdbCloseDatabase(db); + SHIM_ERR("Failed to open shim database file: 0x%lx\n", Status); + return NULL; + } + + db->size = GetFileSize(db->file, NULL); + db->data = SdbAlloc(db->size); + ReadFile(db->file, db->data, db->size, &dwRead, NULL); + + if (!SdbpReadData(db, &header, 0, 12)) + { + SdbCloseDatabase(db); + SHIM_ERR("Failed to read shim database header\n"); + return NULL; + } + + if (memcmp(&header[8], "sdbf", 4) != 0) + { + SdbCloseDatabase(db); + SHIM_ERR("Shim database header is invalid\n"); + return NULL; + } + + if (*(DWORD*)&header[0] != (DWORD)2) + { + SdbCloseDatabase(db); + SHIM_ERR("Invalid shim database version\n"); + return NULL; + } + + db->stringtable = SdbFindFirstTag(db, TAGID_ROOT, TAG_STRINGTABLE); + if(!SdbGetDatabaseID(db, &db->database_id)) + { + SHIM_INFO("Failed to get the database id\n"); + } + return db; +} + +/** + * Closes specified database and frees its memory. + * + * @param [in] db Handle to the shim database. + */ +void WINAPI SdbCloseDatabase(PDB db) +{ + if (!db) + return; + + if (db->file) + NtClose(db->file); + SdbFree(db->data); + SdbFree(db); } /** @@ -380,6 +499,8 @@ * @param [in] tag The tag which will be converted to a string. * * @return Success: Pointer to the string matching specified tag, or L"InvalidTag" on failure. + * + * @todo: Convert this into a lookup table, this is wasting alot of space. */ LPCWSTR WINAPI SdbTagToString(TAG tag) { Added: trunk/reactos/dll/appcompat/apphelp/sdbread.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/appcompat/apphelp/sdbr…
============================================================================== --- trunk/reactos/dll/appcompat/apphelp/sdbread.c (added) +++ trunk/reactos/dll/appcompat/apphelp/sdbread.c [iso-8859-1] Sun May 22 20:27:02 2016 @@ -0,0 +1,439 @@ +/* + * Copyright 2011 André Hentschel + * Copyright 2013 Mislav Blaevic + * Copyright 2015,2016 Mark Jansen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "windef.h" +#include "winbase.h" +#include "apphelp.h" + +#include "wine/unicode.h" + + +DWORD WINAPI SdbGetTagDataSize(PDB db, TAGID tagid); + + +BOOL WINAPI SdbpReadData(PDB db, PVOID dest, DWORD offset, DWORD num) +{ + DWORD size = offset + num; + + /* Either overflow or no data to read */ + if (size <= offset) + return FALSE; + + /* Overflow */ + if (db->size < size) + return FALSE; + + memcpy(dest, db->data + offset, num); + return TRUE; +} + +static DWORD WINAPI SdbpGetTagSize(PDB db, TAGID tagid) +{ + WORD type; + DWORD size; + + type = SdbGetTagFromTagID(db, tagid) & TAG_TYPE_MASK; + if (type == TAG_NULL) + return 0; + + size = SdbGetTagDataSize(db, tagid); + if (type <= TAG_TYPE_STRINGREF) + return size += sizeof(TAG); + else size += (sizeof(TAG) + sizeof(DWORD)); + + return size; +} + +static LPWSTR WINAPI SdbpGetString(PDB db, TAGID tagid, PDWORD size) +{ + TAG tag; + TAGID offset; + + tag = SdbGetTagFromTagID(db, tagid); + if (tag == TAG_NULL) + return NULL; + + if ((tag & TAG_TYPE_MASK) == TAG_TYPE_STRINGREF) + { + /* No stringtable; all references are invalid */ + if (db->stringtable == TAGID_NULL) + return NULL; + + /* TAG_TYPE_STRINGREF contains offset of string relative to stringtable */ + if (!SdbpReadData(db, &tagid, tagid + sizeof(TAG), sizeof(TAGID))) + return NULL; + + offset = db->stringtable + tagid + sizeof(TAG) + sizeof(TAGID); + } + else if ((tag & TAG_TYPE_MASK) == TAG_TYPE_STRING) + { + offset = tagid + sizeof(TAG) + sizeof(TAGID); + } + else + { + SHIM_ERR("Tag 0x%u at tagid %u is neither a string or reference to string\n", tag, tagid); + return NULL; + } + + /* Optionally read string size */ + if (size && !SdbpReadData(db, size, tagid + sizeof(TAG), sizeof(*size))) + return FALSE; + + return (LPWSTR)(&db->data[offset]); +} + +/** + * Searches shim database for the tag associated with specified tagid. + * + * @param [in] db Handle to the shim database. + * @param [in] tagid The TAGID of the tag. + * + * @return Success: The tag associated with specified tagid, Failure: TAG_NULL. + */ +TAG WINAPI SdbGetTagFromTagID(PDB db, TAGID tagid) +{ + TAG data; + if (!SdbpReadData(db, &data, tagid, sizeof(data))) + return TAG_NULL; + return data; +} + +/** + * Retrieves size of data at specified tagid. + * + * @param [in] db Handle to the shim database. + * @param [in] tagid Tagid of tag whose size is queried. + * + * @return Success: Size of data at specified tagid, Failure: 0. + */ +DWORD WINAPI SdbGetTagDataSize(PDB db, TAGID tagid) +{ + /* sizes of data types with fixed size */ + static const SIZE_T sizes[6] = { + 0, /* NULL */ 1, /* BYTE */ + 2, /* WORD */ 4, /* DWORD */ + 8, /* QWORD */ 4 /* STRINGREF */ + }; + WORD type; + DWORD size; + + type = SdbGetTagFromTagID(db, tagid) & TAG_TYPE_MASK; + if (type == TAG_NULL) + return 0; + + if (type <= TAG_TYPE_STRINGREF) + return sizes[(type >> 12) - 1]; + + /* tag with dynamic size (e.g. list): must read size */ + if (!SdbpReadData(db, &size, tagid + sizeof(TAG), sizeof(size))) + return 0; + + return size; +} + +/** + * Searches shim database for a child of specified parent tag. + * + * @param [in] db Handle to the shim database. + * @param [in] parent TAGID of parent. + * + * @return Success: TAGID of child tag, Failure: TAGID_NULL. + */ +TAGID WINAPI SdbGetFirstChild(PDB db, TAGID parent) +{ + /* if we are at beginning of database */ + if (parent == TAGID_ROOT) + { + /* header only database: no tags */ + if (db->size <= _TAGID_ROOT) + return TAGID_NULL; + /* return *real* root tagid */ + else return _TAGID_ROOT; + } + + /* only list tag can have children */ + if ((SdbGetTagFromTagID(db, parent) & TAG_TYPE_MASK) != TAG_TYPE_LIST) + return TAGID_NULL; + + /* first child is sizeof(TAG) + sizeof(DWORD) bytes after beginning of list */ + return parent + sizeof(TAG) + sizeof(DWORD); +} + +/** + * Searches shim database for next child of specified parent tag. + * + * @param [in] db Handle to the shim database. + * @param [in] parent TAGID of parent. + * @param [in] prev_child TAGID of previous child. + * + * @return Success: TAGID of next child tag, Failure: TAGID_NULL. + */ +TAGID WINAPI SdbGetNextChild(PDB db, TAGID parent, TAGID prev_child) +{ + TAGID next_child; + DWORD prev_child_size, parent_size; + + prev_child_size = SdbpGetTagSize(db, prev_child); + if (prev_child_size == 0) + return TAGID_NULL; + + /* Bound check */ + next_child = prev_child + prev_child_size; + if (next_child >= db->size) + return TAGID_NULL; + + if (parent == TAGID_ROOT) + return next_child; + + parent_size = SdbpGetTagSize(db, parent); + if (parent_size == 0) + return TAGID_NULL; + + /* Specified parent has no more children */ + if (next_child >= parent + parent_size) + return TAGID_NULL; + + return next_child; +} + +/** + * Searches shim database for a tag within specified domain. + * + * @param [in] db Handle to the shim database. + * @param [in] parent TAGID of parent. + * @param [in] tag TAG to be located. + * + * @return Success: TAGID of first matching tag, Failure: TAGID_NULL. + */ +TAGID WINAPI SdbFindFirstTag(PDB db, TAGID parent, TAG tag) +{ + TAGID iter; + + iter = SdbGetFirstChild(db, parent); + while (iter != TAGID_NULL) + { + if (SdbGetTagFromTagID(db, iter) == tag) + return iter; + iter = SdbGetNextChild(db, parent, iter); + } + return TAGID_NULL; +} + +/** + * Searches shim database for a next tag which matches prev_child within parent's domain. + * + * @param [in] db Handle to the shim database. + * @param [in] parent TAGID of parent. + * @param [in] prev_child TAGID of previous match. + * + * @return Success: TAGID of next match, Failure: TAGID_NULL. + */ +TAGID WINAPI SdbFindNextTag(PDB db, TAGID parent, TAGID prev_child) +{ + TAG tag; + TAGID iter; + + tag = SdbGetTagFromTagID(db, prev_child); + iter = SdbGetNextChild(db, parent, prev_child); + + while (iter != TAGID_NULL) + { + if (SdbGetTagFromTagID(db, iter) == tag) + return iter; + iter = SdbGetNextChild(db, parent, iter); + } + return TAGID_NULL; +} + +/** + * Searches shim database for string associated with specified tagid and copies string into a + * buffer. + * + * If size parameter is less than number of characters in string, this function shall fail and + * no data shall be copied. + * + * @param [in] db Handle to the shim database. + * @param [in] tagid TAGID of string or stringref associated with the string. + * @param [out] buffer Buffer in which string will be copied. + * @param [in] size Number of characters to copy. + * + * @return TRUE if string was successfully copied to the buffer FALSE if string was not copied + * to the buffer. + */ +BOOL WINAPI SdbReadStringTag(PDB db, TAGID tagid, LPWSTR buffer, DWORD size) +{ + LPWSTR string; + DWORD string_size; + + string = SdbpGetString(db, tagid, &string_size); + if (!string) + return FALSE; + + /* Check if buffer is too small */ + if (size * sizeof(WCHAR) < string_size) + return FALSE; + + memcpy(buffer, string, string_size); + return TRUE; +} + +/** + * Reads WORD value at specified tagid. + * + * @param [in] db Handle to the shim database. + * @param [in] tagid TAGID of WORD value. + * @param [in] ret Default return value in case function fails. + * + * @return Success: WORD value at specified tagid, or ret on failure. + */ +WORD WINAPI SdbReadWORDTag(PDB db, TAGID tagid, WORD ret) +{ + if (SdbpCheckTagIDType(db, tagid, TAG_TYPE_WORD)) + SdbpReadData(db, &ret, tagid + 2, sizeof(WORD)); + return ret; +} + +/** + * Reads DWORD value at specified tagid. + * + * @param [in] db Handle to the shim database. + * @param [in] tagid TAGID of DWORD value. + * @param [in] ret Default return value in case function fails. + * + * @return Success: DWORD value at specified tagid, otherwise ret. + */ +DWORD WINAPI SdbReadDWORDTag(PDB db, TAGID tagid, DWORD ret) +{ + if (SdbpCheckTagIDType(db, tagid, TAG_TYPE_DWORD)) + SdbpReadData(db, &ret, tagid + 2, sizeof(DWORD)); + return ret; +} + +/** + * Reads QWORD value at specified tagid. + * + * @param [in] db Handle to the shim database. + * @param [in] tagid TAGID of QWORD value. + * @param [in] ret Default return value in case function fails. + * + * @return Success: QWORD value at specified tagid, otherwise ret. + */ +QWORD WINAPI SdbReadQWORDTag(PDB db, TAGID tagid, QWORD ret) +{ + if (SdbpCheckTagIDType(db, tagid, TAG_TYPE_QWORD)) + SdbpReadData(db, &ret, tagid + sizeof(TAG), sizeof(QWORD)); + return ret; +} + +/** + * Reads binary data at specified tagid. + * + * @param [in] db Handle to the shim database. + * @param [in] tagid TAGID of binary data. + * @param [out] buffer Buffer in which data will be copied. + * @param [in] size Size of the buffer. + * + * @return TRUE if data was successfully written, or FALSE otherwise. + */ +BOOL WINAPI SdbReadBinaryTag(PDB db, TAGID tagid, PBYTE buffer, DWORD size) +{ + DWORD data_size = 0; + + if (SdbpCheckTagIDType(db, tagid, TAG_TYPE_BINARY)) + { + SdbpReadData(db, &data_size, tagid + sizeof(TAG), sizeof(data_size)); + if (size >= data_size) + return SdbpReadData(db, buffer, tagid + sizeof(TAG) + sizeof(data_size), data_size); + } + + return FALSE; +} + +/** + * Retrieves binary data at specified tagid. + * + * @param [in] db Handle to the shim database. + * @param [in] tagid TAGID of binary data. + * + * @return Success: Pointer to binary data at specified tagid, or NULL on failure. + */ +PVOID WINAPI SdbGetBinaryTagData(PDB db, TAGID tagid) +{ + if (!SdbpCheckTagIDType(db, tagid, TAG_TYPE_BINARY)) + return NULL; + return &db->data[tagid + sizeof(TAG) + sizeof(DWORD)]; +} + +/** + * Searches shim database for string associated with specified tagid. + * + * @param [in] db Handle to the shim database. + * @param [in] tagid TAGID of string or stringref associated with the string. + * + * @return the LPWSTR associated with specified tagid, or NULL on failure. + */ +LPWSTR WINAPI SdbGetStringTagPtr(PDB db, TAGID tagid) +{ + return SdbpGetString(db, tagid, NULL); +} + +/** + * Reads binary data at specified tagid. + * + * @param [in] db Handle to the shim database. + * @param [out] Guid Database ID. + * + * @return true if the ID was found FALSE otherwise. + */ +BOOL WINAPI SdbGetDatabaseID(PDB db, GUID* Guid) +{ + if(SdbIsNullGUID(&db->database_id)) + { + TAGID root = SdbFindFirstTag(db, TAGID_ROOT, TAG_DATABASE); + if(root != TAGID_NULL) + { + TAGID id = SdbFindFirstTag(db, root, TAG_DATABASE_ID); + if(id != TAGID_NULL) + { + if(!SdbReadBinaryTag(db, id, (PBYTE)&db->database_id, sizeof(db->database_id))) + { + memset(&db->database_id, 0, sizeof(db->database_id)); + } + } + else + { + /* Should we silence this if we are opening a system db? */ + SHIM_ERR("Failed to get the database id\n"); + } + } + else + { + /* Should we silence this if we are opening a system db? */ + SHIM_ERR("Failed to get root tag\n"); + } + } + if(!SdbIsNullGUID(&db->database_id)) + { + memcpy(Guid, &db->database_id, sizeof(db->database_id)); + return TRUE; + } + return FALSE; +} + Propchange: trunk/reactos/dll/appcompat/apphelp/sdbread.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/dll/appcompat/apphelp/sdbwrite.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/appcompat/apphelp/sdbw…
============================================================================== --- trunk/reactos/dll/appcompat/apphelp/sdbwrite.c (added) +++ trunk/reactos/dll/appcompat/apphelp/sdbwrite.c [iso-8859-1] Sun May 22 20:27:02 2016 @@ -0,0 +1,328 @@ +/* + * Copyright 2011 André Hentschel + * Copyright 2013 Mislav Blaevic + * Copyright 2015,2016 Mark Jansen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define WIN32_NO_STATUS +#include "windows.h" +#include "ntndk.h" +#include "apphelp.h" + +#include "wine/unicode.h" + + +static void WINAPI SdbpFlush(PDB db) +{ + IO_STATUS_BLOCK io; + NTSTATUS Status = NtWriteFile(db->file, NULL, NULL, NULL, &io, + db->data, db->write_iter, NULL, NULL); + if( !NT_SUCCESS(Status)) + SHIM_WARN("failed with 0x%lx\n", Status); +} + +static void WINAPI SdbpWrite(PDB db, LPCVOID data, DWORD size) +{ + if (db->write_iter + size > db->size) + { + /* Round to powers of two to prevent too many reallocations */ + while (db->size < db->write_iter + size) db->size <<= 1; + db->data = SdbReAlloc(db->data, db->size); + } + + memcpy(db->data + db->write_iter, data, size); + db->write_iter += size; +} + +/** + * Creates new shim database file + * + * If a file already exists on specified path, that file shall be overwritten. + * + * @note Use SdbCloseDatabasWrite to close the database opened with this function. + * + * @param [in] path Path to the new shim database. + * @param [in] type Type of path. Either DOS_PATH or NT_PATH. + * + * @return Success: Handle to the newly created shim database, NULL otherwise. + */ +PDB WINAPI SdbCreateDatabase(LPCWSTR path, PATH_TYPE type) +{ + static const DWORD version_major = 2, version_minor = 1; + static const char* magic = "sdbf"; + NTSTATUS Status; + IO_STATUS_BLOCK io; + OBJECT_ATTRIBUTES attr; + UNICODE_STRING str; + PDB db; + + if (type == DOS_PATH) + { + if (!RtlDosPathNameToNtPathName_U(path, &str, NULL, NULL)) + return NULL; + } + else + RtlInitUnicodeString(&str, path); + + db = SdbpCreate(); + if (!db) + { + SHIM_ERR("Failed to allocate memory for shim database\n"); + return NULL; + } + + InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, NULL, NULL); + + Status = NtCreateFile(&db->file, FILE_GENERIC_WRITE | SYNCHRONIZE, + &attr, &io, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ, + FILE_SUPERSEDE, FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0); + + if (type == DOS_PATH) + RtlFreeUnicodeString(&str); + + if (!NT_SUCCESS(Status)) + { + SdbCloseDatabase(db); + SHIM_ERR("Failed to create shim database file: %lx\n", Status); + return NULL; + } + + db->size = sizeof(DWORD) + sizeof(DWORD) + strlen(magic); + db->data = SdbAlloc(db->size); + + SdbpWrite(db, &version_major, sizeof(DWORD)); + SdbpWrite(db, &version_minor, sizeof(DWORD)); + SdbpWrite(db, magic, strlen(magic)); + + return db; +} + +/** + * Closes specified database and writes data to file. + * + * @param [in] db Handle to the shim database. + */ +void WINAPI SdbCloseDatabaseWrite(PDB db) +{ + SdbpFlush(db); + SdbCloseDatabase(db); +} + +/** + * Writes a tag-only (NULL) entry to the specified shim database. + * + * @param [in] db Handle to the shim database. + * @param [in] tag A tag for the entry. + * + * @return TRUE if it succeeds, FALSE if it fails. + */ +BOOL WINAPI SdbWriteNULLTag(PDB db, TAG tag) +{ + if (!SdbpCheckTagType(tag, TAG_TYPE_NULL)) + return FALSE; + + SdbpWrite(db, &tag, sizeof(TAG)); + return TRUE; +} + +/** + * Writes a WORD entry to the specified shim database. + * + * @param [in] db Handle to the shim database. + * @param [in] tag A tag for the entry. + * @param [in] data WORD entry which will be written to the database. + * + * @return TRUE if it succeeds, FALSE if it fails. + */ +BOOL WINAPI SdbWriteWORDTag(PDB db, TAG tag, WORD data) +{ + if (!SdbpCheckTagType(tag, TAG_TYPE_WORD)) + return FALSE; + + SdbpWrite(db, &tag, sizeof(TAG)); + SdbpWrite(db, &data, sizeof(data)); + return TRUE; +} + +/** + * Writes a DWORD entry to the specified shim database. + * + * @param [in] db Handle to the shim database. + * @param [in] tag A tag for the entry. + * @param [in] data DWORD entry which will be written to the database. + * + * @return TRUE if it succeeds, FALSE if it fails. + */ +BOOL WINAPI SdbWriteDWORDTag(PDB db, TAG tag, DWORD data) +{ + if (!SdbpCheckTagType(tag, TAG_TYPE_DWORD)) + return FALSE; + + SdbpWrite(db, &tag, sizeof(TAG)); + SdbpWrite(db, &data, sizeof(data)); + return TRUE; +} + +/** + * Writes a DWORD entry to the specified shim database. + * + * @param [in] db Handle to the shim database. + * @param [in] tag A tag for the entry. + * @param [in] data QWORD entry which will be written to the database. + * + * @return TRUE if it succeeds, FALSE if it fails. + */ +BOOL WINAPI SdbWriteQWORDTag(PDB db, TAG tag, QWORD data) +{ + if (!SdbpCheckTagType(tag, TAG_TYPE_QWORD)) + return FALSE; + + SdbpWrite(db, &tag, sizeof(TAG)); + SdbpWrite(db, &data, sizeof(data)); + return TRUE; +} + +/** + * Writes a wide string entry to the specified shim database. + * + * @param [in] db Handle to the shim database. + * @param [in] tag A tag for the entry. + * @param [in] string Wide string entry which will be written to the database. + * + * @return TRUE if it succeeds, FALSE if it fails. + */ +BOOL WINAPI SdbWriteStringTag(PDB db, TAG tag, LPCWSTR string) +{ + DWORD size; + + if (!SdbpCheckTagType(tag, TAG_TYPE_STRING)) + return FALSE; + + size = SdbpStrlen(string); + SdbpWrite(db, &tag, sizeof(TAG)); + SdbpWrite(db, &size, sizeof(size)); + SdbpWrite(db, string, size); + return TRUE; +} + +/** + * Writes a stringref tag to specified database + * @note Reference (tagid) is not checked for validity. + * + * @param [in] db Handle to the shim database. + * @param [in] tag TAG which will be written. + * @param [in] tagid TAGID of the string tag refers to. + * + * @return TRUE if it succeeds, FALSE if it fails. + */ +BOOL WINAPI SdbWriteStringRefTag(PDB db, TAG tag, TAGID tagid) +{ + if (!SdbpCheckTagType(tag, TAG_TYPE_STRINGREF)) + return FALSE; + + SdbpWrite(db, &tag, sizeof(TAG)); + SdbpWrite(db, &tagid, sizeof(tagid)); + return TRUE; +} + +/** + * Writes data the specified shim database. + * + * @param [in] db Handle to the shim database. + * @param [in] tag A tag for the entry. + * @param [in] data Pointer to data. + * @param [in] size Number of bytes to write. + * + * @return TRUE if it succeeds, FALSE if it fails. + */ +BOOL WINAPI SdbWriteBinaryTag(PDB db, TAG tag, PBYTE data, DWORD size) +{ + if (!SdbpCheckTagType(tag, TAG_TYPE_BINARY)) + return FALSE; + + SdbpWrite(db, &tag, sizeof(TAG)); + SdbpWrite(db, &size, sizeof(size)); + SdbpWrite(db, data, size); + return TRUE; +} + +/** + * Writes data from a file to the specified shim database. + * + * @param [in] db Handle to the shim database. + * @param [in] tag A tag for the entry. + * @param [in] path Path of the input file. + * + * @return TRUE if it succeeds, FALSE if it fails. + */ +BOOL WINAPI SdbWriteBinaryTagFromFile(PDB db, TAG tag, LPCWSTR path) +{ + MEMMAPPED mapped; + + if (!SdbpCheckTagType(tag, TAG_TYPE_BINARY)) + return FALSE; + + if (!SdbpOpenMemMappedFile(path, &mapped)) + return FALSE; + + SdbWriteBinaryTag(db, tag, mapped.view, mapped.size); + SdbpCloseMemMappedFile(&mapped); + return TRUE; +} + +/** + * Writes a list tag to specified database All subsequent SdbWrite* functions shall write to + * newly created list untill TAGID of that list is passed to SdbEndWriteListTag. + * + * @param [in] db Handle to the shim database. + * @param [in] tag TAG for the list + * + * RETURNS Success: TAGID of the newly created list, or TAGID_NULL on failure. + * + * @return A TAGID. + */ +TAGID WINAPI SdbBeginWriteListTag(PDB db, TAG tag) +{ + TAGID list_id; + + if (!SdbpCheckTagType(tag, TAG_TYPE_LIST)) + return TAGID_NULL; + + list_id = db->write_iter; + SdbpWrite(db, &tag, sizeof(TAG)); + db->write_iter += sizeof(DWORD); /* reserve some memory for storing list size */ + return list_id; +} + +/** + * Marks end of the specified list. + * + * @param [in] db Handle to the shim database. + * @param [in] tagid TAGID of the list. + * + * @return TRUE if it succeeds, FALSE if it fails. + */ +BOOL WINAPI SdbEndWriteListTag(PDB db, TAGID tagid) +{ + if (!SdbpCheckTagIDType(db, tagid, TAG_TYPE_LIST)) + return FALSE; + + /* Write size of list to list tag header */ + *(DWORD*)&db->data[tagid + sizeof(TAG)] = db->write_iter - tagid - sizeof(TAG); + return TRUE; +} + Propchange: trunk/reactos/dll/appcompat/apphelp/sdbwrite.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/rostests/apitests/apphelp/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/apphelp/CMakeLis…
============================================================================== --- trunk/rostests/apitests/apphelp/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/apphelp/CMakeLists.txt [iso-8859-1] Sun May 22 20:27:02 2016 @@ -4,6 +4,7 @@ list(APPEND SOURCE apphelp.c data.c + db.c layerapi.c testlist.c) Added: trunk/rostests/apitests/apphelp/db.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/apphelp/db.c?rev…
============================================================================== --- trunk/rostests/apitests/apphelp/db.c (added) +++ trunk/rostests/apitests/apphelp/db.c [iso-8859-1] Sun May 22 20:27:02 2016 @@ -0,0 +1,283 @@ +/* + * Copyright 2012 Detlef Riekenberg + * Copyright 2013 Mislav BlaževiÄ + * Copyright 2015,2016 Mark Jansen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + + +#include <ntstatus.h> +#define WIN32_NO_STATUS +#include <windows.h> +#include <shlwapi.h> +#include <winnt.h> +#ifdef __REACTOS__ +#include <ntndk.h> +#else +#include <winternl.h> +#endif + +#include <winerror.h> +#include <stdio.h> +#include <initguid.h> + +#include "wine/test.h" + +typedef WORD TAG; +typedef DWORD TAGID; +typedef DWORD TAGREF; +typedef UINT64 QWORD; +typedef VOID* PDB; +typedef INT PATH_TYPE; +#define DOS_PATH 0 + +#define TAGID_NULL 0x0 +#define TAGID_ROOT 0x0 +#define _TAGID_ROOT 12 + + +#define TAG_TYPE_MASK 0xF000 + +#define TAG_TYPE_NULL 0x1000 +#define TAG_TYPE_BYTE 0x2000 +#define TAG_TYPE_WORD 0x3000 +#define TAG_TYPE_DWORD 0x4000 +#define TAG_TYPE_QWORD 0x5000 +#define TAG_TYPE_STRINGREF 0x6000 +#define TAG_TYPE_LIST 0x7000 +#define TAG_TYPE_STRING 0x8000 +#define TAG_TYPE_BINARY 0x9000 +#define TAG_NULL 0x0 +#define TAG_SIZE (0x1 | TAG_TYPE_DWORD) + +#define TAG_MATCH_MODE (0x1 | TAG_TYPE_WORD) + +#define TAG_FLAG_LUA (0x10 | TAG_TYPE_QWORD) + +#define TAG_STRINGTABLE (0x801 | TAG_TYPE_LIST) + +#define TAG_NAME (0x1 | TAG_TYPE_STRINGREF) +#define TAG_STRINGTABLE_ITEM (0x801 | TAG_TYPE_STRING) + + +#define TAG_GENERAL (0x2 | TAG_TYPE_NULL) + +#define TAG_DATA_BITS (0x5 | TAG_TYPE_BINARY) + + + +static HMODULE hdll; +static LPCWSTR (WINAPI *pSdbTagToString)(TAG); +static PDB (WINAPI *pSdbOpenDatabase)(LPCWSTR, PATH_TYPE); +static PDB (WINAPI *pSdbCreateDatabase)(LPCWSTR, PATH_TYPE); +static void (WINAPI *pSdbCloseDatabase)(PDB); +static void (WINAPI *pSdbCloseDatabaseWrite)(PDB); +static TAG (WINAPI *pSdbGetTagFromTagID)(PDB, TAGID); +static BOOL (WINAPI *pSdbWriteNULLTag)(PDB, TAG); +static BOOL (WINAPI *pSdbWriteWORDTag)(PDB, TAG, WORD); +static BOOL (WINAPI *pSdbWriteDWORDTag)(PDB, TAG, DWORD); +static BOOL (WINAPI *pSdbWriteQWORDTag)(PDB, TAG, QWORD); +static BOOL (WINAPI *pSdbWriteBinaryTagFromFile)(PDB, TAG, LPCWSTR); +static BOOL (WINAPI *pSdbWriteStringTag)(PDB, TAG, LPCWSTR); +static BOOL (WINAPI *pSdbWriteStringRefTag)(PDB, TAG, TAGID); +static TAGID (WINAPI *pSdbBeginWriteListTag)(PDB, TAG); +static BOOL (WINAPI *pSdbEndWriteListTag)(PDB, TAGID); +static WORD (WINAPI *pSdbReadWORDTag)(PDB, TAGID, WORD); +static DWORD (WINAPI *pSdbReadDWORDTag)(PDB, TAGID, DWORD); +static QWORD (WINAPI *pSdbReadQWORDTag)(PDB, TAGID, QWORD); +static BOOL (WINAPI *pSdbReadBinaryTag)(PDB, TAGID, PBYTE, DWORD); +static BOOL (WINAPI *pSdbReadStringTag)(PDB, TAGID, LPWSTR, DWORD); +static DWORD (WINAPI *pSdbGetTagDataSize)(PDB, TAGID); +static PVOID (WINAPI *pSdbGetBinaryTagData)(PDB, TAGID); +static LPWSTR (WINAPI *pSdbGetStringTagPtr)(PDB, TAGID); +static TAGID (WINAPI *pSdbGetFirstChild)(PDB, TAGID); +static TAGID (WINAPI *pSdbGetNextChild)(PDB, TAGID, TAGID); + +static void Write(HANDLE file, LPCVOID buffer, DWORD size) +{ + DWORD dwWritten = 0; + WriteFile(file, buffer, size, &dwWritten, NULL); +} + +static void test_Sdb(void) +{ + static const WCHAR path[] = {'t','e','m','p',0}; + static const WCHAR path2[] = {'t','e','m','p','2',0}; + static const WCHAR tag_size_string[] = {'S','I','Z','E',0}; + static const WCHAR tag_flag_lua_string[] = {'F','L','A','G','_','L','U','A',0}; + static const TAG tags[5] = { + TAG_SIZE, TAG_FLAG_LUA, TAG_NAME, + TAG_STRINGTABLE, TAG_STRINGTABLE_ITEM + }; + WCHAR buffer[6] = {0}; + PDB pdb; + QWORD qword; + DWORD dword; + WORD word; + BOOL ret; + HANDLE file; /* temp file created for testing purpose */ + TAG tag; + TAGID tagid, ptagid, stringref = 6; + LPCWSTR string; + PBYTE binary; + + pdb = pSdbCreateDatabase(path, DOS_PATH); + ok (pdb != NULL, "failed to create database\n"); + if(pdb != NULL) + { + ret = pSdbWriteDWORDTag(pdb, tags[0], 0xDEADBEEF); + ok (ret, "failed to write DWORD tag\n"); + ret = pSdbWriteQWORDTag(pdb, tags[1], 0xDEADBEEFBABE); + ok (ret, "failed to write QWORD tag\n"); + ret = pSdbWriteStringRefTag(pdb, tags[2], stringref); + ok (ret, "failed to write stringref tag\n"); + tagid = pSdbBeginWriteListTag(pdb, tags[3]); + ok (tagid != TAGID_NULL, "unexpected NULL tagid\n"); + ret = pSdbWriteStringTag(pdb, tags[4], path); + ok (ret, "failed to write string tag\n"); + ret = pSdbWriteNULLTag(pdb, TAG_GENERAL); + ok (ret, "failed to write NULL tag\n"); + ret = pSdbWriteWORDTag(pdb, TAG_MATCH_MODE, 0xACE); + ok (ret, "failed to write WORD tag\n"); + ret = pSdbEndWriteListTag(pdb, tagid); + ok (ret, "failed to update list size\n"); + /* [Err ][SdbCloseDatabase ] Failed to close the file. */ + pSdbCloseDatabaseWrite(pdb); + } + + /* [Err ][SdbGetDatabaseID ] Failed to get root tag */ + pdb = pSdbOpenDatabase(path, DOS_PATH); + ok(pdb != NULL, "unexpected NULL handle\n"); + + if(pdb) + { + tagid = pSdbGetFirstChild(pdb, TAGID_ROOT); + ok(tagid == _TAGID_ROOT, "unexpected tagid %u, expected %u\n", tagid, _TAGID_ROOT); + + tag = pSdbGetTagFromTagID(pdb, tagid); + ok(tag == TAG_SIZE, "unexpected tag 0x%x, expected 0x%x\n", tag, TAG_SIZE); + + string = pSdbTagToString(tag); + ok(lstrcmpW(string, tag_size_string) == 0, "unexpected string %s, expected %s\n", + wine_dbgstr_w(string), wine_dbgstr_w(tag_size_string)); + + dword = pSdbReadDWORDTag(pdb, tagid, 0); + ok(dword == 0xDEADBEEF, "unexpected value %u, expected 0xDEADBEEF\n", dword); + + tagid = pSdbGetNextChild(pdb, TAGID_ROOT, tagid); + ok(tagid == _TAGID_ROOT + sizeof(TAG) + sizeof(DWORD), "unexpected tagid %u, expected %u\n", + tagid, _TAGID_ROOT + sizeof(TAG) + sizeof(DWORD)); + + tag = pSdbGetTagFromTagID(pdb, tagid); + ok (tag == TAG_FLAG_LUA, "unexpected tag 0x%x, expected 0x%x\n", tag, TAG_FLAG_LUA); + + string = pSdbTagToString(tag); + ok(lstrcmpW(string, tag_flag_lua_string) == 0, "unexpected string %s, expected %s\n", + wine_dbgstr_w(string), wine_dbgstr_w(tag_flag_lua_string)); + + qword = pSdbReadQWORDTag(pdb, tagid, 0); + ok(qword == 0xDEADBEEFBABE, "unexpected value 0x%I64x, expected 0xDEADBEEFBABE\n", qword); + + tagid = pSdbGetNextChild(pdb, TAGID_ROOT, tagid); + string = pSdbGetStringTagPtr(pdb, tagid); + ok (string && (lstrcmpW(string, path) == 0), "unexpected string %s, expected %s\n", + wine_dbgstr_w(string), wine_dbgstr_w(path)); + + ptagid = pSdbGetNextChild(pdb, TAGID_ROOT, tagid); + tagid = pSdbGetFirstChild(pdb, ptagid); + + string = pSdbGetStringTagPtr(pdb, tagid); + ok (string && (lstrcmpW(string, path) == 0), "unexpected string %s, expected %s\n", + wine_dbgstr_w(string), wine_dbgstr_w(path)); + + ok (pSdbReadStringTag(pdb, tagid, buffer, 6), "failed to write string to buffer\n"); + /* [Err ][SdbpReadTagData ] Buffer too small. Avail: 6, Need: 10. */ + ok (!pSdbReadStringTag(pdb, tagid, buffer, 3), "string was written to buffer, but failure was expected"); + ok (pSdbGetTagDataSize(pdb, tagid) == 5 * sizeof(WCHAR), "string has unexpected size\n"); + + tagid = pSdbGetNextChild(pdb, ptagid, tagid); + tag = pSdbGetTagFromTagID(pdb, tagid); + ok (tag == TAG_GENERAL, "unexpected tag 0x%x, expected 0x%x\n", tag, TAG_GENERAL); + ok (pSdbGetTagDataSize(pdb, tagid) == 0, "null tag with size > 0\n"); + + tagid = pSdbGetNextChild(pdb, ptagid, tagid); + word = pSdbReadWORDTag(pdb, tagid, 0); + ok (word == 0xACE, "unexpected value 0x%x, expected 0x%x\n", word, 0xACE); + + pSdbCloseDatabase(pdb); + } + DeleteFileW(path); + + file = CreateFileW(path2, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + ok (file != INVALID_HANDLE_VALUE, "failed to open file\n"); + Write(file, &qword, 8); + CloseHandle(file); + + pdb = pSdbCreateDatabase(path, DOS_PATH); + ok(pdb != NULL, "unexpected NULL handle\n"); + + if(pdb) + { + ret = pSdbWriteBinaryTagFromFile(pdb, TAG_DATA_BITS, path2); + ok(ret, "failed to write tag from binary file\n"); + pSdbCloseDatabaseWrite(pdb); /* [Err ][SdbCloseDatabase ] Failed to close the file. */ + DeleteFileW(path2); + + pdb = pSdbOpenDatabase(path, DOS_PATH); + ok(pdb != NULL, "unexpected NULL handle\n"); + binary = pSdbGetBinaryTagData(pdb, _TAGID_ROOT); + ok(memcmp(binary, &qword, 8) == 0, "binary data is corrupt\n"); + ret = pSdbReadBinaryTag(pdb, _TAGID_ROOT, (PBYTE)buffer, 12); + ok(ret, "failed to read binary tag\n"); + ok(memcmp(buffer, &qword, 8) == 0, "binary data is corrupt\n"); + pSdbCloseDatabase(pdb); + } + DeleteFileW(path); +} + +START_TEST(db) +{ + //SetEnvironmentVariable("SHIM_DEBUG_LEVEL", "4"); + //SetEnvironmentVariable("DEBUGCHANNEL", "+apphelp"); + hdll = LoadLibraryA("apphelp.dll"); + pSdbTagToString = (void *) GetProcAddress(hdll, "SdbTagToString"); + pSdbOpenDatabase = (void *) GetProcAddress(hdll, "SdbOpenDatabase"); + pSdbCreateDatabase = (void *) GetProcAddress(hdll, "SdbCreateDatabase"); + pSdbCloseDatabase = (void *) GetProcAddress(hdll, "SdbCloseDatabase"); + pSdbCloseDatabaseWrite = (void *) GetProcAddress(hdll, "SdbCloseDatabaseWrite"); + pSdbGetTagFromTagID = (void *) GetProcAddress(hdll, "SdbGetTagFromTagID"); + pSdbWriteNULLTag = (void *) GetProcAddress(hdll, "SdbWriteNULLTag"); + pSdbWriteWORDTag = (void *) GetProcAddress(hdll, "SdbWriteWORDTag"); + pSdbWriteDWORDTag = (void *) GetProcAddress(hdll, "SdbWriteDWORDTag"); + pSdbWriteQWORDTag = (void *) GetProcAddress(hdll, "SdbWriteQWORDTag"); + pSdbWriteBinaryTagFromFile = (void *) GetProcAddress(hdll, "SdbWriteBinaryTagFromFile"); + pSdbWriteStringTag = (void *) GetProcAddress(hdll, "SdbWriteStringTag"); + pSdbWriteStringRefTag = (void *) GetProcAddress(hdll, "SdbWriteStringRefTag"); + pSdbBeginWriteListTag = (void *)GetProcAddress(hdll, "SdbBeginWriteListTag"); + pSdbEndWriteListTag = (void *) GetProcAddress(hdll, "SdbEndWriteListTag"); + pSdbReadWORDTag = (void *) GetProcAddress(hdll, "SdbReadWORDTag"); + pSdbReadDWORDTag = (void *) GetProcAddress(hdll, "SdbReadDWORDTag"); + pSdbReadQWORDTag = (void *) GetProcAddress(hdll, "SdbReadQWORDTag"); + pSdbReadBinaryTag = (void *) GetProcAddress(hdll, "SdbReadBinaryTag"); + pSdbReadStringTag = (void *) GetProcAddress(hdll, "SdbReadStringTag"); + pSdbGetTagDataSize = (void *) GetProcAddress(hdll, "SdbGetTagDataSize"); + pSdbGetBinaryTagData = (void *) GetProcAddress(hdll, "SdbGetBinaryTagData"); + pSdbGetStringTagPtr = (void *) GetProcAddress(hdll, "SdbGetStringTagPtr"); + pSdbGetFirstChild = (void *) GetProcAddress(hdll, "SdbGetFirstChild"); + pSdbGetNextChild = (void *) GetProcAddress(hdll, "SdbGetNextChild"); + + test_Sdb(); +} Propchange: trunk/rostests/apitests/apphelp/db.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/rostests/apitests/apphelp/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/apphelp/testlist…
============================================================================== --- trunk/rostests/apitests/apphelp/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/apphelp/testlist.c [iso-8859-1] Sun May 22 20:27:02 2016 @@ -4,11 +4,13 @@ #include <wine/test.h> extern void func_apphelp(void); +extern void func_db(void); extern void func_layerapi(void); const struct test winetest_testlist[] = { { "apphelp", func_apphelp }, + { "db", func_db }, { "layerapi", func_layerapi }, { 0, 0 } };
8 years, 7 months
1
0
0
0
← Newer
1
...
7
8
9
10
11
12
13
...
26
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
Results per page:
10
25
50
100
200