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
September 2005
----- 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
22 participants
582 discussions
Start a n
N
ew thread
[hbirr] 18031: - Moved the definition of REG_NOTIFY_CLASS from cm.h to winddk.h.
by hbirr@svn.reactos.com
- Moved the definition of REG_NOTIFY_CLASS from cm.h to winddk.h. - Release the rundown protection if the callback function returns an error (in CmiCallRegisteredCallbacks). - Call the registry callback functions in most of the Nt/ZW registry functions. Modified: trunk/reactos/ntoskrnl/cm/cm.h Modified: trunk/reactos/ntoskrnl/cm/ntfunc.c Modified: trunk/reactos/w32api/include/ddk/winddk.h _____ Modified: trunk/reactos/ntoskrnl/cm/cm.h --- trunk/reactos/ntoskrnl/cm/cm.h 2005-09-24 18:28:04 UTC (rev 18030) +++ trunk/reactos/ntoskrnl/cm/cm.h 2005-09-24 18:42:37 UTC (rev 18031) @@ -378,55 +378,11 @@ extern ERESOURCE CmiRegistryLock; -typedef enum _REG_NOTIFY_CLASS -{ - RegNtDeleteKey, - RegNtPreDeleteKey = RegNtDeleteKey, - RegNtSetValueKey, - RegNtPreSetValueKey = RegNtSetValueKey, - RegNtDeleteValueKey, - RegNtPreDeleteValueKey = RegNtDeleteValueKey, - RegNtSetInformationKey, - RegNtPreSetInformationKey = RegNtSetInformationKey, - RegNtRenameKey, - RegNtPreRenameKey = RegNtRenameKey, - RegNtEnumerateKey, - RegNtPreEnumerateKey = RegNtEnumerateKey, - RegNtEnumerateValueKey, - RegNtPreEnumerateValueKey = RegNtEnumerateValueKey, - RegNtQueryKey, - RegNtPreQueryKey = RegNtQueryKey, - RegNtQueryValueKey, - RegNtPreQueryValueKey = RegNtQueryValueKey, - RegNtQueryMultipleValueKey, - RegNtPreQueryMultipleValueKey = RegNtQueryMultipleValueKey, - RegNtPreCreateKey, - RegNtPostCreateKey, - RegNtPreOpenKey, - RegNtPostOpenKey, - RegNtKeyHandleClose, - RegNtPreKeyHandleClose = RegNtKeyHandleClose, - RegNtPostDeleteKey, - RegNtPostSetValueKey, - RegNtPostDeleteValueKey, - RegNtPostSetInformationKey, - RegNtPostRenameKey, - RegNtPostEnumerateKey, - RegNtPostEnumerateValueKey, - RegNtPostQueryKey, - RegNtPostQueryValueKey, - RegNtPostQueryMultipleValueKey, - RegNtPostKeyHandleClose, - RegNtPreCreateKeyEx, - RegNtPostCreateKeyEx, - RegNtPreOpenKeyEx, - RegNtPostOpenKeyEx -} REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS; /* Registry Callback Function */ typedef NTSTATUS (STDCALL *PEX_CALLBACK_FUNCTION ) ( IN PVOID CallbackContext, - IN PVOID Argument1, + IN REG_NOTIFY_CLASS Argument1, IN PVOID Argument2 ); _____ Modified: trunk/reactos/ntoskrnl/cm/ntfunc.c --- trunk/reactos/ntoskrnl/cm/ntfunc.c 2005-09-24 18:28:04 UTC (rev 18030) +++ trunk/reactos/ntoskrnl/cm/ntfunc.c 2005-09-24 18:42:37 UTC (rev 18031) @@ -133,6 +133,7 @@ IN PVOID Argument2) { PLIST_ENTRY CurrentEntry; + NTSTATUS Status = STATUS_SUCCESS; PAGED_CODE(); @@ -148,31 +149,29 @@ if(!CurrentCallback->PendingDelete && ExAcquireRundownProtectionEx(&CurrentCallback->RundownRef, 1)) { - NTSTATUS Status; - /* don't hold locks during the callbacks! */ ExReleaseFastMutex(&CmiCallbackLock); Status = CurrentCallback->Function(CurrentCallback->Context, - (PVOID)Argument1, + Argument1, Argument2); - if(!NT_SUCCESS(Status)) - { - /* one callback returned failure, don't call any more callbacks */ - return Status; - } ExAcquireFastMutex(&CmiCallbackLock); /* don't release the rundown protection before holding the callback lock so the pointer to the next callback isn't cleared in case this callback get's deleted */ ExReleaseRundownProtectionEx(&CurrentCallback->RundownRef, 1); + if(!NT_SUCCESS(Status)) + { + /* one callback returned failure, don't call any more callbacks */ + break; + } } } ExReleaseFastMutex(&CmiCallbackLock); - return STATUS_SUCCESS; + return Status; } @@ -193,6 +192,8 @@ UNICODE_STRING ObjectName; OBJECT_CREATE_INFORMATION ObjectCreateInfo; unsigned i; + REG_PRE_CREATE_KEY_INFORMATION PreCreateKeyInfo; + REG_POST_CREATE_KEY_INFORMATION PostCreateKeyInfo; PAGED_CODE(); @@ -201,28 +202,41 @@ KeyHandle, ObjectAttributes->RootDirectory); - /* Capture all the info */ - DPRINT("Capturing Create Info\n"); - Status = ObpCaptureObjectAttributes(ObjectAttributes, - KeGetPreviousMode(), - CmiKeyType, - &ObjectCreateInfo, - &ObjectName); - if (!NT_SUCCESS(Status)) - { - DPRINT("ObpCaptureObjectAttributes() failed (Status %lx)\n", Status); - return Status; - } + /* Capture all the info */ + DPRINT("Capturing Create Info\n"); + Status = ObpCaptureObjectAttributes(ObjectAttributes, + KeGetPreviousMode(), + CmiKeyType, + &ObjectCreateInfo, + &ObjectName); + if (!NT_SUCCESS(Status)) + { + DPRINT("ObpCaptureObjectAttributes() failed (Status %lx)\n", Status); + return Status; + } + PostCreateKeyInfo.CompleteName = &ObjectName; + PreCreateKeyInfo.CompleteName = &ObjectName; + Status = CmiCallRegisteredCallbacks(RegNtPreCreateKey, &PreCreateKeyInfo); + if (!NT_SUCCESS(Status)) + { + ObpReleaseCapturedAttributes(&ObjectCreateInfo); + if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); + return Status; + } + Status = ObFindObject(&ObjectCreateInfo, &ObjectName, - (PVOID*)&Object, + (PVOID*)&Object, &RemainingPath, CmiKeyType); - ObpReleaseCapturedAttributes(&ObjectCreateInfo); - if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); + ObpReleaseCapturedAttributes(&ObjectCreateInfo); if (!NT_SUCCESS(Status)) { + PostCreateKeyInfo.Object = NULL; + PostCreateKeyInfo.Status = Status; + CmiCallRegisteredCallbacks(RegNtPostCreateKey, &PostCreateKeyInfo); + if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); DPRINT("CmpFindObject failed, Status: 0x%x\n", Status); return(Status); } @@ -236,6 +250,10 @@ { ObDereferenceObject(Object); RtlFreeUnicodeString(&RemainingPath); + PostCreateKeyInfo.Object = NULL; + PostCreateKeyInfo.Status = STATUS_UNSUCCESSFUL; + CmiCallRegisteredCallbacks(RegNtPostCreateKey, &PostCreateKeyInfo); + if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); DPRINT("Object marked for delete!\n"); return(STATUS_UNSUCCESSFUL); } @@ -252,6 +270,10 @@ DPRINT("ObpCreateHandle failed Status 0x%x\n", Status); ObDereferenceObject(Object); RtlFreeUnicodeString(&RemainingPath); + PostCreateKeyInfo.Object = NULL; + PostCreateKeyInfo.Status = Status; + CmiCallRegisteredCallbacks(RegNtPostCreateKey, &PostCreateKeyInfo); + if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); return Status; } @@ -268,6 +290,10 @@ ObDereferenceObject(Object); DPRINT1("NtCreateKey() doesn't create trees! (found \'\\\' in remaining path: \"%wZ\"!)\n", &RemainingPath); RtlFreeUnicodeString(&RemainingPath); + PostCreateKeyInfo.Object = NULL; + PostCreateKeyInfo.Status = STATUS_OBJECT_NAME_NOT_FOUND; + CmiCallRegisteredCallbacks(RegNtPostCreateKey, &PostCreateKeyInfo); + if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); return STATUS_OBJECT_NAME_NOT_FOUND; } } @@ -286,6 +312,10 @@ if (!NT_SUCCESS(Status)) { DPRINT1("ObCreateObject() failed!\n"); + PostCreateKeyInfo.Object = NULL; + PostCreateKeyInfo.Status = Status; + CmiCallRegisteredCallbacks(RegNtPostCreateKey, &PostCreateKeyInfo); + if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); return(Status); } @@ -300,6 +330,10 @@ ObDereferenceObject(KeyObject); RtlFreeUnicodeString(&RemainingPath); DPRINT1("ObInsertObject() failed!\n"); + PostCreateKeyInfo.Object = NULL; + PostCreateKeyInfo.Status = Status; + CmiCallRegisteredCallbacks(RegNtPostCreateKey, &PostCreateKeyInfo); + if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); return(Status); } @@ -338,6 +372,10 @@ ObDereferenceObject(KeyObject); ObDereferenceObject(Object); RtlFreeUnicodeString(&RemainingPath); + PostCreateKeyInfo.Object = NULL; + PostCreateKeyInfo.Status = STATUS_UNSUCCESSFUL; + CmiCallRegisteredCallbacks(RegNtPostCreateKey, &PostCreateKeyInfo); + if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); return STATUS_UNSUCCESSFUL; } @@ -382,6 +420,11 @@ if (Disposition) *Disposition = REG_CREATED_NEW_KEY; + PostCreateKeyInfo.Object = KeyObject; + PostCreateKeyInfo.Status = Status; + CmiCallRegisteredCallbacks(RegNtPostCreateKey, &PostCreateKeyInfo); + if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); + CmiSyncHives(); return Status; @@ -394,6 +437,8 @@ KPROCESSOR_MODE PreviousMode; PKEY_OBJECT KeyObject; NTSTATUS Status; + REG_DELETE_KEY_INFORMATION DeleteKeyInfo; + REG_POST_OPERATION_INFORMATION PostOperationInfo; PAGED_CODE(); @@ -414,6 +459,17 @@ return Status; } + PostOperationInfo.Object = (PVOID)KeyObject; + DeleteKeyInfo.Object = (PVOID)KeyObject; + Status = CmiCallRegisteredCallbacks(RegNtPreSetValueKey, &DeleteKeyInfo); + if (!NT_SUCCESS(Status)) + { + PostOperationInfo.Status = Status; + CmiCallRegisteredCallbacks(RegNtDeleteKey, &PostOperationInfo); + ObDereferenceObject(KeyObject); + return Status; + } + /* Acquire hive lock */ KeEnterCriticalRegion(); ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE); @@ -438,14 +494,18 @@ DPRINT("PointerCount %lu\n", ObGetObjectPointerCount((PVOID)KeyObject)); - /* Dereference the object */ - ObDereferenceObject(KeyObject); /* Remove the keep-alive reference */ ObDereferenceObject(KeyObject); if (KeyObject->RegistryHive != KeyObject->ParentKey->RegistryHive) ObDereferenceObject(KeyObject); + PostOperationInfo.Status = Status; + CmiCallRegisteredCallbacks(RegNtPostDeleteKey, &PostOperationInfo); + + /* Dereference the object */ + ObDereferenceObject(KeyObject); + DPRINT("PointerCount %lu\n", ObGetObjectPointerCount((PVOID)KeyObject)); DPRINT("HandleCount %lu\n", ObGetObjectHandleCount((PVOID)KeyObject)); @@ -480,6 +540,8 @@ ULONG NameSize, ClassSize; KPROCESSOR_MODE PreviousMode; NTSTATUS Status; + REG_ENUMERATE_KEY_INFORMATION EnumerateKeyInfo; + REG_POST_OPERATION_INFORMATION PostOperationInfo; PAGED_CODE(); @@ -506,6 +568,20 @@ return(Status); } + PostOperationInfo.Object = (PVOID)KeyObject; + EnumerateKeyInfo.Object = (PVOID)KeyObject; + EnumerateKeyInfo.Index = Index; + EnumerateKeyInfo.KeyInformationClass = KeyInformationClass; + EnumerateKeyInfo.Length = Length; + EnumerateKeyInfo.ResultLength = ResultLength; + + Status = CmiCallRegisteredCallbacks(RegNtEnumerateKey, &EnumerateKeyInfo); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject(KeyObject); + return Status; + } + /* Acquire hive lock */ KeEnterCriticalRegion(); ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE); @@ -523,6 +599,8 @@ { ExReleaseResourceLite(&CmiRegistryLock); KeLeaveCriticalRegion(); + PostOperationInfo.Status = STATUS_NO_MORE_ENTRIES; + CmiCallRegisteredCallbacks(RegNtPostDeleteKey, &PostOperationInfo); ObDereferenceObject(KeyObject); DPRINT("No more volatile entries\n"); return STATUS_NO_MORE_ENTRIES; @@ -552,6 +630,8 @@ { ExReleaseResourceLite(&CmiRegistryLock); KeLeaveCriticalRegion(); + PostOperationInfo.Status = STATUS_NO_MORE_ENTRIES; + CmiCallRegisteredCallbacks(RegNtPostEnumerateKey, &PostOperationInfo); ObDereferenceObject(KeyObject); DPRINT("No more non-volatile entries\n"); return STATUS_NO_MORE_ENTRIES; @@ -566,6 +646,8 @@ { ExReleaseResourceLite(&CmiRegistryLock); KeLeaveCriticalRegion(); + PostOperationInfo.Status = STATUS_NO_MORE_ENTRIES; + CmiCallRegisteredCallbacks(RegNtPostEnumerateKey, &PostOperationInfo); ObDereferenceObject(KeyObject); return STATUS_NO_MORE_ENTRIES; } @@ -576,6 +658,8 @@ DPRINT("CmiGetBlock() failed\n"); ExReleaseResourceLite(&CmiRegistryLock); KeLeaveCriticalRegion(); + PostOperationInfo.Status = STATUS_UNSUCCESSFUL; + CmiCallRegisteredCallbacks(RegNtPostEnumerateKey, &PostOperationInfo); ObDereferenceObject(KeyObject); return STATUS_UNSUCCESSFUL; } @@ -589,6 +673,8 @@ { ExReleaseResourceLite(&CmiRegistryLock); KeLeaveCriticalRegion(); + PostOperationInfo.Status = STATUS_NO_MORE_ENTRIES; + CmiCallRegisteredCallbacks(RegNtPostEnumerateKey, &PostOperationInfo); ObDereferenceObject(KeyObject); DPRINT("No more entries\n"); return STATUS_NO_MORE_ENTRIES; @@ -804,6 +890,10 @@ ExReleaseResourceLite(&CmiRegistryLock); KeLeaveCriticalRegion(); + + PostOperationInfo.Status = Status; + CmiCallRegisteredCallbacks(RegNtPostEnumerateKey, &PostOperationInfo); + ObDereferenceObject(KeyObject); DPRINT("Returning status %x\n", Status); @@ -1121,11 +1211,13 @@ { UNICODE_STRING RemainingPath; KPROCESSOR_MODE PreviousMode; - PVOID Object; + PVOID Object = NULL; HANDLE hKey; NTSTATUS Status = STATUS_SUCCESS; UNICODE_STRING ObjectName; OBJECT_CREATE_INFORMATION ObjectCreateInfo; + REG_PRE_OPEN_KEY_INFORMATION PreOpenKeyInfo; + REG_POST_OPEN_KEY_INFORMATION PostOpenKeyInfo; PAGED_CODE(); @@ -1176,21 +1268,31 @@ return Status; } + PostOpenKeyInfo.CompleteName = &ObjectName; + PreOpenKeyInfo.CompleteName = &ObjectName; + Status = CmiCallRegisteredCallbacks(RegNtPreOpenKey, &PreOpenKeyInfo); + if (!NT_SUCCESS(Status)) + { + ObpReleaseCapturedAttributes(&ObjectCreateInfo); + if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); + return Status; + } + + RemainingPath.Buffer = NULL; Status = ObFindObject(&ObjectCreateInfo, &ObjectName, - (PVOID*)&Object, + (PVOID*)&Object, &RemainingPath, CmiKeyType); - ObpReleaseCapturedAttributes(&ObjectCreateInfo); - if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); + ObpReleaseCapturedAttributes(&ObjectCreateInfo); if (!NT_SUCCESS(Status)) { DPRINT("CmpFindObject() returned 0x%08lx\n", Status); - Status = STATUS_INVALID_HANDLE; /* Because CmpFindObject returns STATUS_UNSUCCESSFUL */ - hKey = *KeyHandle; /* Preserve hkResult value */ - goto openkey_cleanup; + Status = STATUS_INVALID_HANDLE; /* Because CmpFindObject returns STATUS_UNSUCCESSFUL */ + hKey = *KeyHandle; /* Preserve hkResult value */ + goto openkey_cleanup; } VERIFY_KEY_OBJECT((PKEY_OBJECT) Object); @@ -1199,11 +1301,10 @@ if ((RemainingPath.Buffer != NULL) && (RemainingPath.Buffer[0] != 0)) { - ObDereferenceObject(Object); RtlFreeUnicodeString(&RemainingPath); Status = STATUS_OBJECT_NAME_NOT_FOUND; hKey = NULL; - goto openkey_cleanup; + goto openkey_cleanup; } RtlFreeUnicodeString(&RemainingPath); @@ -1211,10 +1312,9 @@ /* Fail if the key has been deleted */ if (((PKEY_OBJECT)Object)->Flags & KO_MARKED_FOR_DELETE) { - ObDereferenceObject(Object); - Status = STATUS_UNSUCCESSFUL; + Status = STATUS_UNSUCCESSFUL; hKey = NULL; - goto openkey_cleanup; + goto openkey_cleanup; } Status = ObpCreateHandle(PsGetCurrentProcess(), @@ -1222,12 +1322,22 @@ DesiredAccess, TRUE, &hKey); - ObDereferenceObject(Object); if (!NT_SUCCESS(Status)) hKey = NULL; openkey_cleanup: + + PostOpenKeyInfo.Object = NT_SUCCESS(Status) ? (PVOID)Object : NULL; + PostOpenKeyInfo.Status = Status; + CmiCallRegisteredCallbacks (RegNtPostOpenKey, &PostOpenKeyInfo); + if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); + + if (Object) + { + ObDereferenceObject(Object); + } + _SEH_TRY { *KeyHandle = hKey; @@ -1258,6 +1368,8 @@ PKEY_CELL KeyCell; ULONG NameSize, ClassSize; NTSTATUS Status; + REG_QUERY_KEY_INFORMATION QueryKeyInfo; + REG_POST_OPERATION_INFORMATION PostOperationInfo; PAGED_CODE(); @@ -1280,6 +1392,20 @@ return Status; } + PostOperationInfo.Object = (PVOID)KeyObject; + QueryKeyInfo.Object = (PVOID)KeyObject; + QueryKeyInfo.KeyInformationClass = KeyInformationClass; + QueryKeyInfo.KeyInformation = KeyInformation; + QueryKeyInfo.Length = Length; + QueryKeyInfo.ResultLength = ResultLength; + + Status = CmiCallRegisteredCallbacks(RegNtQueryKey, &QueryKeyInfo); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject(KeyObject); + return Status; + } + /* Acquire hive lock */ KeEnterCriticalRegion(); ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE); @@ -1444,6 +1570,10 @@ ExReleaseResourceLite(&CmiRegistryLock); KeLeaveCriticalRegion(); + + PostOperationInfo.Status = Status; + CmiCallRegisteredCallbacks(RegNtPostQueryKey, &PostOperationInfo); + ObDereferenceObject(KeyObject); return(Status); @@ -1468,6 +1598,8 @@ PKEY_VALUE_BASIC_INFORMATION ValueBasicInformation; PKEY_VALUE_PARTIAL_INFORMATION ValuePartialInformation; PKEY_VALUE_FULL_INFORMATION ValueFullInformation; + REG_QUERY_VALUE_KEY_INFORMATION QueryValueKeyInfo; + REG_POST_OPERATION_INFORMATION PostOperationInfo; PAGED_CODE(); @@ -1487,7 +1619,21 @@ DPRINT1("ObReferenceObjectByHandle() failed with status %x\n", Status); return Status; } + + PostOperationInfo.Object = (PVOID)KeyObject; + QueryValueKeyInfo.Object = (PVOID)KeyObject; + QueryValueKeyInfo.ValueName = ValueName; + QueryValueKeyInfo.KeyValueInformationClass = KeyValueInformationClass; + QueryValueKeyInfo.Length = Length; + QueryValueKeyInfo.ResultLength = ResultLength; + Status = CmiCallRegisteredCallbacks(RegNtPreQueryValueKey, &QueryValueKeyInfo); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject(KeyObject); + return Status; + } + /* Acquire hive lock */ KeEnterCriticalRegion(); ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE); @@ -1686,6 +1832,9 @@ ByeBye:; ExReleaseResourceLite(&CmiRegistryLock); KeLeaveCriticalRegion(); + + PostOperationInfo.Status = Status; + CmiCallRegisteredCallbacks(RegNtPostQueryValueKey, &PostOperationInfo); ObDereferenceObject(KeyObject); return Status; @@ -1710,6 +1859,8 @@ PDATA_CELL NewDataCell; PHBIN pBin; ULONG DesiredAccess; + REG_SET_VALUE_KEY_INFORMATION SetValueKeyInfo; + REG_POST_OPERATION_INFORMATION PostOperationInfo; PAGED_CODE(); @@ -1728,6 +1879,20 @@ if (!NT_SUCCESS(Status)) return(Status); + PostOperationInfo.Object = (PVOID)KeyObject; + SetValueKeyInfo.Object = (PVOID)KeyObject; + SetValueKeyInfo.ValueName = ValueName; + SetValueKeyInfo.TitleIndex = TitleIndex; + SetValueKeyInfo.Type = Type; + SetValueKeyInfo.Data = Data; + SetValueKeyInfo.DataSize = DataSize; + Status = CmiCallRegisteredCallbacks(RegNtPreSetValueKey, &SetValueKeyInfo); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject(KeyObject); + return Status; + } + /* Acquire hive lock exclucively */ KeEnterCriticalRegion(); ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE); @@ -1759,6 +1924,8 @@ ExReleaseResourceLite(&CmiRegistryLock); KeLeaveCriticalRegion(); + PostOperationInfo.Status = Status; + CmiCallRegisteredCallbacks(RegNtPostSetValueKey, &PostOperationInfo); ObDereferenceObject(KeyObject); return Status; } @@ -1824,6 +1991,8 @@ ExReleaseResourceLite(&CmiRegistryLock); KeLeaveCriticalRegion(); + PostOperationInfo.Status = Status; + CmiCallRegisteredCallbacks(RegNtPostSetValueKey, &PostOperationInfo); ObDereferenceObject(KeyObject); return Status; @@ -1849,6 +2018,8 @@ ExReleaseResourceLite(&CmiRegistryLock); KeLeaveCriticalRegion(); + PostOperationInfo.Status = Status; + CmiCallRegisteredCallbacks(RegNtPostSetValueKey, &PostOperationInfo); ObDereferenceObject(KeyObject); CmiSyncHives(); @@ -1865,6 +2036,8 @@ { PKEY_OBJECT KeyObject; NTSTATUS Status; + REG_DELETE_VALUE_KEY_INFORMATION DeleteValueKeyInfo; + REG_POST_OPERATION_INFORMATION PostOperationInfo; PAGED_CODE(); @@ -1879,7 +2052,17 @@ { return Status; } + + DeleteValueKeyInfo.Object = (PVOID)KeyObject; + DeleteValueKeyInfo.ValueName = ValueName; + Status = CmiCallRegisteredCallbacks(RegNtPreDeleteValueKey, &DeleteValueKeyInfo); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject(KeyObject); + return Status; + } + /* Acquire hive lock */ KeEnterCriticalRegion(); ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE); @@ -1898,6 +2081,11 @@ ExReleaseResourceLite(&CmiRegistryLock); KeLeaveCriticalRegion(); + PostOperationInfo.Object = (PVOID)KeyObject; + PostOperationInfo.Status = Status; + + CmiCallRegisteredCallbacks(RegNtPostDeleteValueKey, &PostOperationInfo); + ObDereferenceObject (KeyObject); CmiSyncHives (); @@ -2106,6 +2294,8 @@ NTSTATUS Status; PUCHAR DataPtr; ULONG i; + REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION QueryMultipleValueKeyInfo; + REG_POST_OPERATION_INFORMATION PostOperationInfo; PAGED_CODE(); @@ -2122,6 +2312,21 @@ return(Status); } + PostOperationInfo.Object = (PVOID)KeyObject; + QueryMultipleValueKeyInfo.Object = (PVOID)KeyObject; + QueryMultipleValueKeyInfo.ValueEntries = ValueList; + QueryMultipleValueKeyInfo.EntryCount = NumberOfValues; + QueryMultipleValueKeyInfo.ValueBuffer = Buffer; + QueryMultipleValueKeyInfo.BufferLength = Length; + QueryMultipleValueKeyInfo.RequiredBufferLength = ReturnLength; + + Status = CmiCallRegisteredCallbacks(RegNtPreQueryMultipleValueKey, &QueryMultipleValueKeyInfo); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject(KeyObject); + return Status; + } + /* Acquire hive lock */ KeEnterCriticalRegion(); ExAcquireResourceSharedLite(&CmiRegistryLock, TRUE); @@ -2201,6 +2406,9 @@ ExReleaseResourceLite(&CmiRegistryLock); KeLeaveCriticalRegion(); + PostOperationInfo.Status = Status; + CmiCallRegisteredCallbacks(RegNtPostQueryMultipleValueKey, &PostOperationInfo); + ObDereferenceObject(KeyObject); DPRINT("Return Status 0x%X\n", Status); @@ -2340,15 +2548,11 @@ { PKEY_OBJECT KeyObject; NTSTATUS Status; + REG_SET_INFORMATION_KEY_INFORMATION SetInformationKeyInfo; + REG_POST_OPERATION_INFORMATION PostOperationInfo; PAGED_CODE(); - if (KeyInformationClass != KeyWriteTimeInformation) - return STATUS_INVALID_INFO_CLASS; - - if (KeyInformationLength != sizeof (KEY_WRITE_TIME_INFORMATION)) - return STATUS_INFO_LENGTH_MISMATCH; - /* Verify that the handle is valid and is a registry key */ Status = ObReferenceObjectByHandle (KeyHandle, KEY_SET_VALUE, @@ -2362,25 +2566,56 @@ return Status; } - /* Acquire hive lock */ - KeEnterCriticalRegion(); - ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE); + PostOperationInfo.Object = (PVOID)KeyObject; + SetInformationKeyInfo.Object = (PVOID)KeyObject; + SetInformationKeyInfo.KeySetInformationClass = KeyInformationClass; + SetInformationKeyInfo.KeySetInformation = KeyInformation; + SetInformationKeyInfo.KeySetInformationLength = KeyInformationLength; - VERIFY_KEY_OBJECT(KeyObject); + Status = CmiCallRegisteredCallbacks(RegNtSetInformationKey, &SetInformationKeyInfo); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject (KeyObject); + return Status; + } - KeyObject->KeyCell->LastWriteTime.QuadPart = - ((PKEY_WRITE_TIME_INFORMATION)KeyInformation)->LastWriteTime.QuadPart; + if (KeyInformationClass != KeyWriteTimeInformation) + { + Status = STATUS_INVALID_INFO_CLASS; + } - CmiMarkBlockDirty (KeyObject->RegistryHive, - KeyObject->KeyCellOffset); + else if (KeyInformationLength != sizeof (KEY_WRITE_TIME_INFORMATION)) + { + Status = STATUS_INFO_LENGTH_MISMATCH; + } + else + { + /* Acquire hive lock */ + KeEnterCriticalRegion(); + ExAcquireResourceExclusiveLite(&CmiRegistryLock, TRUE); - /* Release hive lock */ - ExReleaseResourceLite(&CmiRegistryLock); - KeLeaveCriticalRegion(); + VERIFY_KEY_OBJECT(KeyObject); + KeyObject->KeyCell->LastWriteTime.QuadPart = + ((PKEY_WRITE_TIME_INFORMATION)KeyInformation)->LastWriteTime.QuadPart; + + CmiMarkBlockDirty (KeyObject->RegistryHive, + KeyObject->KeyCellOffset); + + /* Release hive lock */ + ExReleaseResourceLite(&CmiRegistryLock); + KeLeaveCriticalRegion(); + } + + PostOperationInfo.Status = Status; + CmiCallRegisteredCallbacks(RegNtPostSetInformationKey, &PostOperationInfo); + ObDereferenceObject (KeyObject); - CmiSyncHives (); + if (NT_SUCCESS(Status)) + { + CmiSyncHives (); + } DPRINT ("NtSaveKey() done\n"); _____ Modified: trunk/reactos/w32api/include/ddk/winddk.h --- trunk/reactos/w32api/include/ddk/winddk.h 2005-09-24 18:28:04 UTC (rev 18030) +++ trunk/reactos/w32api/include/ddk/winddk.h 2005-09-24 18:42:37 UTC (rev 18031) @@ -4512,10 +4512,55 @@ TraceHandleByNameClass } TRACE_INFORMATION_CLASS; +typedef enum _REG_NOTIFY_CLASS +{ + RegNtDeleteKey, + RegNtPreDeleteKey = RegNtDeleteKey, + RegNtSetValueKey, + RegNtPreSetValueKey = RegNtSetValueKey, + RegNtDeleteValueKey, + RegNtPreDeleteValueKey = RegNtDeleteValueKey, + RegNtSetInformationKey, + RegNtPreSetInformationKey = RegNtSetInformationKey, + RegNtRenameKey, + RegNtPreRenameKey = RegNtRenameKey, + RegNtEnumerateKey, + RegNtPreEnumerateKey = RegNtEnumerateKey, + RegNtEnumerateValueKey, + RegNtPreEnumerateValueKey = RegNtEnumerateValueKey, + RegNtQueryKey, + RegNtPreQueryKey = RegNtQueryKey, + RegNtQueryValueKey, + RegNtPreQueryValueKey = RegNtQueryValueKey, + RegNtQueryMultipleValueKey, + RegNtPreQueryMultipleValueKey = RegNtQueryMultipleValueKey, + RegNtPreCreateKey, + RegNtPostCreateKey, + RegNtPreOpenKey, + RegNtPostOpenKey, + RegNtKeyHandleClose, + RegNtPreKeyHandleClose = RegNtKeyHandleClose, + RegNtPostDeleteKey, + RegNtPostSetValueKey, + RegNtPostDeleteValueKey, + RegNtPostSetInformationKey, + RegNtPostRenameKey, + RegNtPostEnumerateKey, + RegNtPostEnumerateValueKey, + RegNtPostQueryKey, + RegNtPostQueryValueKey, + RegNtPostQueryMultipleValueKey, + RegNtPostKeyHandleClose, + RegNtPreCreateKeyEx, + RegNtPostCreateKeyEx, + RegNtPreOpenKeyEx, + RegNtPostOpenKeyEx +} REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS; + typedef NTSTATUS (DDKAPI *PEX_CALLBACK_FUNCTION)( IN PVOID CallbackContext, - IN PVOID Argument1, + IN REG_NOTIFY_CLASS Argument1, IN PVOID Argument2);
19 years, 3 months
1
0
0
0
[hbirr] 18030: - Use the given buffer for getting the name of the parent.
by hbirr@svn.reactos.com
- Use the given buffer for getting the name of the parent. - Check the length of the buffer. - Intialise the name string if it is necessary. Modified: trunk/reactos/ntoskrnl/cm/regobj.c _____ Modified: trunk/reactos/ntoskrnl/cm/regobj.c --- trunk/reactos/ntoskrnl/cm/regobj.c 2005-09-24 18:09:06 UTC (rev 18029) +++ trunk/reactos/ntoskrnl/cm/regobj.c 2005-09-24 18:28:04 UTC (rev 18030) @@ -490,50 +490,50 @@ ULONG Length, PULONG ReturnLength) { - POBJECT_NAME_INFORMATION LocalInfo; PKEY_OBJECT KeyObject; - ULONG LocalReturnLength; NTSTATUS Status; DPRINT ("CmiObjectQueryName() called\n"); KeyObject = (PKEY_OBJECT)ObjectBody; - LocalInfo = ExAllocatePool (NonPagedPool, - sizeof(OBJECT_NAME_INFORMATION) + - MAX_PATH * sizeof(WCHAR)); - if (LocalInfo == NULL) - return STATUS_INSUFFICIENT_RESOURCES; - if (KeyObject->ParentKey != KeyObject) { Status = ObQueryNameString (KeyObject->ParentKey, - LocalInfo, - MAX_PATH * sizeof(WCHAR), - &LocalReturnLength); + ObjectNameInfo, + Length, + ReturnLength); } else { /* KeyObject is the root key */ Status = ObQueryNameString (HEADER_TO_OBJECT_NAME(BODY_TO_HEADER(KeyObject))->Directory, - LocalInfo, - MAX_PATH * sizeof(WCHAR), - &LocalReturnLength); + ObjectNameInfo, + Length, + ReturnLength); } - if (!NT_SUCCESS (Status)) + if (!NT_SUCCESS(Status) && Status != STATUS_INFO_LENGTH_MISMATCH) { - ExFreePool (LocalInfo); return Status; } - DPRINT ("Parent path: %wZ\n", &LocalInfo->Name); + (*ReturnLength) += sizeof(WCHAR) + KeyObject->Name.Length; - Status = RtlAppendUnicodeStringToString (&ObjectNameInfo->Name, - &LocalInfo->Name); - ExFreePool (LocalInfo); - if (!NT_SUCCESS (Status)) - return Status; + if (Status == STATUS_INFO_LENGTH_MISMATCH || *ReturnLength > Length) + { + return STATUS_INFO_LENGTH_MISMATCH; + } + if (ObjectNameInfo->Name.Buffer == NULL) + { + ObjectNameInfo->Name.Buffer = (PWCHAR)(ObjectNameInfo + 1); + ObjectNameInfo->Name.Length = 0; + ObjectNameInfo->Name.MaximumLength = Length - sizeof(OBJECT_NAME_INFORMATION); + } + + + DPRINT ("Parent path: %wZ\n", ObjectNameInfo->Name); + Status = RtlAppendUnicodeToString (&ObjectNameInfo->Name, L"\\"); if (!NT_SUCCESS (Status))
19 years, 3 months
1
0
0
0
[hbirr] 18029: Used NtQueryFullAttributesFile instead of NtOpenFile/NtQueryInformationFile/NtClose in GetFileAttributesExW (suggested by Thomas Weidenmueller).
by hbirr@svn.reactos.com
Used NtQueryFullAttributesFile instead of NtOpenFile/NtQueryInformationFile/NtClose in GetFileAttributesExW (suggested by Thomas Weidenmueller). Modified: trunk/reactos/lib/kernel32/file/file.c _____ Modified: trunk/reactos/lib/kernel32/file/file.c --- trunk/reactos/lib/kernel32/file/file.c 2005-09-24 18:04:13 UTC (rev 18028) +++ trunk/reactos/lib/kernel32/file/file.c 2005-09-24 18:09:06 UTC (rev 18029) @@ -835,9 +835,7 @@ { FILE_NETWORK_OPEN_INFORMATION FileInformation; OBJECT_ATTRIBUTES ObjectAttributes; - IO_STATUS_BLOCK IoStatusBlock; UNICODE_STRING FileName; - HANDLE FileHandle; NTSTATUS Status; WIN32_FILE_ATTRIBUTE_DATA* FileAttributeData; @@ -868,36 +866,18 @@ NULL, NULL); - /* Open the file */ - Status = NtOpenFile (&FileHandle, - SYNCHRONIZE | FILE_READ_ATTRIBUTES, - &ObjectAttributes, - &IoStatusBlock, - 0, - FILE_SYNCHRONOUS_IO_NONALERT); + /* Get file attributes */ + Status = NtQueryFullAttributesFile(&ObjectAttributes, + &FileInformation); + RtlFreeUnicodeString (&FileName); if (!NT_SUCCESS (Status)) { - DPRINT ("NtOpenFile() failed %x (Status %lx)\n", &ObjectAttributes, Status); + DPRINT ("NtQueryFullAttributesFile() failed (Status %lx)\n", Status); SetLastErrorByStatus (Status); return FALSE; } - /* Get file attributes */ - Status = NtQueryInformationFile (FileHandle, - &IoStatusBlock, - &FileInformation, - sizeof(FILE_NETWORK_OPEN_INFORMATION), - FileNetworkOpenInformation); - NtClose (FileHandle); - - if (!NT_SUCCESS (Status)) - { - DPRINT1 ("NtQueryInformationFile() failed (Status %lx)\n", Status); - SetLastErrorByStatus (Status); - return FALSE; - } - FileAttributeData = (WIN32_FILE_ATTRIBUTE_DATA*)lpFileInformation; FileAttributeData->dwFileAttributes = FileInformation.FileAttributes; FileAttributeData->ftCreationTime.dwLowDateTime = FileInformation.CreationTime.u.LowPart;
19 years, 3 months
1
0
0
0
[hbirr] 18028: Merged the main code from NtQueryAttributesFile and NtQueryFullAttributesFile to IopQueryAttributesFile.
by hbirr@svn.reactos.com
Merged the main code from NtQueryAttributesFile and NtQueryFullAttributesFile to IopQueryAttributesFile. Check the access to parameters in IopQueryAttributesFile if we are called from user mode because calling Zw functions from kernel mode will bypass all checks. Modified: trunk/reactos/ntoskrnl/io/file.c _____ Modified: trunk/reactos/ntoskrnl/io/file.c --- trunk/reactos/ntoskrnl/io/file.c 2005-09-24 17:34:09 UTC (rev 18027) +++ trunk/reactos/ntoskrnl/io/file.c 2005-09-24 18:04:13 UTC (rev 18028) @@ -2155,21 +2155,84 @@ } NTSTATUS -STDCALL -NtQueryAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes, - OUT PFILE_BASIC_INFORMATION FileInformation) +IopQueryAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes, + IN FILE_INFORMATION_CLASS FileInformationClass, + OUT PVOID FileInformation) { IO_STATUS_BLOCK IoStatusBlock; HANDLE FileHandle; NTSTATUS Status; + KPROCESSOR_MODE AccessMode; + UNICODE_STRING ObjectName; + OBJECT_CREATE_INFORMATION ObjectCreateInfo; + OBJECT_ATTRIBUTES LocalObjectAttributes; + ULONG BufferSize; + union + { + FILE_BASIC_INFORMATION BasicInformation; + FILE_NETWORK_OPEN_INFORMATION NetworkOpenInformation; + }LocalFileInformation; + if (FileInformationClass == FileBasicInformation) + { + BufferSize = sizeof(FILE_BASIC_INFORMATION); + } + else if (FileInformationClass == FileNetworkOpenInformation) + { + BufferSize = sizeof(FILE_NETWORK_OPEN_INFORMATION); + } + else + { + return STATUS_INVALID_PARAMETER; + } + + AccessMode = ExGetPreviousMode(); + + if (AccessMode != KernelMode) + { + Status = STATUS_SUCCESS; + _SEH_TRY + { + ProbeForWrite(FileInformation, + BufferSize, + sizeof(ULONG)); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + if (NT_SUCCESS(Status)) + { + Status = ObpCaptureObjectAttributes(ObjectAttributes, + AccessMode, + NULL, + &ObjectCreateInfo, + &ObjectName); + } + if (!NT_SUCCESS(Status)) + { + return Status; + } + InitializeObjectAttributes(&LocalObjectAttributes, + &ObjectName, + ObjectCreateInfo.Attributes, + ObjectCreateInfo.RootDirectory, + ObjectCreateInfo.SecurityDescriptor); + } + /* Open the file */ Status = ZwOpenFile(&FileHandle, SYNCHRONIZE | FILE_READ_ATTRIBUTES, - ObjectAttributes, + AccessMode == KernelMode ? ObjectAttributes : &LocalObjectAttributes, &IoStatusBlock, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + 0, FILE_SYNCHRONOUS_IO_NONALERT); + if (AccessMode != KernelMode) + { + ObpReleaseCapturedAttributes(&ObjectCreateInfo); + ExFreePool(ObjectName.Buffer); + } if (!NT_SUCCESS (Status)) { DPRINT ("ZwOpenFile() failed (Status %lx)\n", Status); @@ -2179,18 +2242,41 @@ /* Get file attributes */ Status = ZwQueryInformationFile(FileHandle, &IoStatusBlock, - FileInformation, - sizeof(FILE_BASIC_INFORMATION), - FileBasicInformation); + AccessMode == KernelMode ? FileInformation : &LocalFileInformation, + BufferSize, + FileInformationClass); if (!NT_SUCCESS (Status)) { DPRINT ("ZwQueryInformationFile() failed (Status %lx)\n", Status); } + ZwClose(FileHandle); - ZwClose(FileHandle); + if (NT_SUCCESS(Status) && AccessMode != KernelMode) + { + _SEH_TRY + { + memcpy(FileInformation, &LocalFileInformation, BufferSize); + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + } return Status; } +NTSTATUS +STDCALL +NtQueryAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PFILE_BASIC_INFORMATION FileInformation) +{ + return IopQueryAttributesFile(ObjectAttributes, + FileBasicInformation, + FileInformation); +} + + /* * @implemented * @@ -2383,36 +2469,9 @@ NtQueryFullAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PFILE_NETWORK_OPEN_INFORMATION FileInformation) { - IO_STATUS_BLOCK IoStatusBlock; - HANDLE FileHandle; - NTSTATUS Status; - - /* Open the file */ - Status = ZwOpenFile(&FileHandle, - SYNCHRONIZE | FILE_READ_ATTRIBUTES, - ObjectAttributes, - &IoStatusBlock, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - FILE_SYNCHRONOUS_IO_NONALERT); - if (!NT_SUCCESS (Status)) - { - DPRINT ("ZwOpenFile() failed (Status %lx)\n", Status); - return Status; - } - - /* Get file attributes */ - Status = ZwQueryInformationFile(FileHandle, - &IoStatusBlock, - FileInformation, - sizeof(FILE_NETWORK_OPEN_INFORMATION), - FileNetworkOpenInformation); - if (!NT_SUCCESS (Status)) - { - DPRINT ("ZwQueryInformationFile() failed (Status %lx)\n", Status); - } - - ZwClose (FileHandle); - return Status; + return IopQueryAttributesFile(ObjectAttributes, + FileNetworkOpenInformation, + FileInformation); } /*
19 years, 3 months
1
0
0
0
[navaraf] 18027: Port the system message queue WM_MOUSEDOWN coalesce fix from win32k rewrite branch.
by navaraf@svn.reactos.com
Port the system message queue WM_MOUSEDOWN coalesce fix from win32k rewrite branch. Modified: trunk/reactos/subsys/win32k/ntuser/msgqueue.c _____ Modified: trunk/reactos/subsys/win32k/ntuser/msgqueue.c --- trunk/reactos/subsys/win32k/ntuser/msgqueue.c 2005-09-24 17:08:13 UTC (rev 18026) +++ trunk/reactos/subsys/win32k/ntuser/msgqueue.c 2005-09-24 17:34:09 UTC (rev 18027) @@ -42,7 +42,6 @@ static ULONG SystemMessageQueueHead = 0; static ULONG SystemMessageQueueTail = 0; static ULONG SystemMessageQueueCount = 0; -static ULONG SystemMessageQueueMouseMove = -1; static KSPIN_LOCK SystemMessageQueueLock; static ULONG volatile HardwareMessageQueueStamp = 0; @@ -148,45 +147,54 @@ { LARGE_INTEGER LargeTickCount; KIRQL OldIrql; - ULONG mmov = (ULONG)-1; + ULONG Prev; - KeQueryTickCount(&LargeTickCount); - Msg->time = LargeTickCount.u.LowPart; - IntLockSystemMessageQueue(OldIrql); - /* only insert WM_MOUSEMOVE messages if not already in system message queue */ - if(Msg->message == WM_MOUSEMOVE) - mmov = SystemMessageQueueMouseMove; + /* + * Bail out if the queue is full. FIXME: We should handle this case + * more gracefully. + */ - if(mmov != (ULONG)-1) + if (SystemMessageQueueCount == SYSTEM_MESSAGE_QUEUE_SIZE) { - /* insert message at the queue head */ - while (mmov != SystemMessageQueueHead ) - { - ULONG prev = mmov ? mmov - 1 : SYSTEM_MESSAGE_QUEUE_SIZE - 1; - ASSERT((LONG) mmov >= 0); - ASSERT(mmov < SYSTEM_MESSAGE_QUEUE_SIZE); - SystemMessageQueue[mmov] = SystemMessageQueue[prev]; - mmov = prev; - } - SystemMessageQueue[SystemMessageQueueHead] = *Msg; + IntUnLockSystemMessageQueue(OldIrql); + return; } - else + + KeQueryTickCount(&LargeTickCount); + Msg->time = LargeTickCount.u.LowPart; + + /* + * If we got WM_MOUSEMOVE and there are already messages in the + * system message queue, check if the last message is mouse move + * and if it is then just overwrite it. + */ + + if (Msg->message == WM_MOUSEMOVE && SystemMessageQueueCount) { - if (SystemMessageQueueCount == SYSTEM_MESSAGE_QUEUE_SIZE) + if (SystemMessageQueueTail == 0) + Prev = SYSTEM_MESSAGE_QUEUE_SIZE - 1; + else + Prev = SystemMessageQueueTail - 1; + if (SystemMessageQueue[Prev].message == WM_MOUSEMOVE) { - IntUnLockSystemMessageQueue(OldIrql); - return; + SystemMessageQueueTail = Prev; + SystemMessageQueueCount--; } - SystemMessageQueue[SystemMessageQueueTail] = *Msg; - if(Msg->message == WM_MOUSEMOVE) - SystemMessageQueueMouseMove = SystemMessageQueueTail; - SystemMessageQueueTail = - (SystemMessageQueueTail + 1) % SYSTEM_MESSAGE_QUEUE_SIZE; - SystemMessageQueueCount++; } + + /* + * Actually insert the message into the system message queue. + */ + + SystemMessageQueue[SystemMessageQueueTail] = *Msg; + SystemMessageQueueTail = + (SystemMessageQueueTail + 1) % SYSTEM_MESSAGE_QUEUE_SIZE; + SystemMessageQueueCount++; + IntUnLockSystemMessageQueue(OldIrql); + KeSetEvent(&HardwareMessageEvent, IO_NO_INCREMENT, FALSE); } @@ -583,11 +591,6 @@ } IntLockSystemMessageQueue(OldIrql); } - /* - * we could set this to -1 conditionally if we find one, but - * this is more efficient and just as effective. - */ - SystemMessageQueueMouseMove = -1; HardwareMessageQueueStamp++; IntUnLockSystemMessageQueue(OldIrql);
19 years, 3 months
1
0
0
0
[weiden] 18026: implemented RegCopyTreeW() (untested!)
by weiden@svn.reactos.com
implemented RegCopyTreeW() (untested!) Modified: trunk/reactos/lib/advapi32/reg/reg.c _____ Modified: trunk/reactos/lib/advapi32/reg/reg.c --- trunk/reactos/lib/advapi32/reg/reg.c 2005-09-24 13:19:25 UTC (rev 18025) +++ trunk/reactos/lib/advapi32/reg/reg.c 2005-09-24 17:08:13 UTC (rev 18026) @@ -319,10 +319,294 @@ } +static NTSTATUS +RegpCopyTree(IN HKEY hKeySrc, + IN HKEY hKeyDest) +{ + typedef struct + { + LIST_ENTRY ListEntry; + HANDLE hKeySrc; + HANDLE hKeyDest; + } REGP_COPY_KEYS, *PREGP_COPY_KEYS; + + LIST_ENTRY copyQueueHead; + PREGP_COPY_KEYS copyKeys, newCopyKeys; + union + { + KEY_VALUE_FULL_INFORMATION *KeyValue; + KEY_NODE_INFORMATION *KeyNode; + PVOID Buffer; + } Info; + ULONG Index, BufferSizeRequired, BufferSize = 0x200; + NTSTATUS Status = STATUS_SUCCESS; + NTSTATUS Status2 = STATUS_SUCCESS; + + InitializeListHead(©QueueHead); + + Info.Buffer = RtlAllocateHeap(ProcessHeap, + 0, + BufferSize); + if (Info.Buffer == NULL) + { + return STATUS_INSUFFICIENT_RESOURCES; + } + + copyKeys = RtlAllocateHeap(ProcessHeap, + 0, + sizeof(REGP_COPY_KEYS)); + if (copyKeys != NULL) + { + copyKeys->hKeySrc = hKeySrc; + copyKeys->hKeyDest = hKeyDest; + InsertHeadList(©QueueHead, + ©Keys->ListEntry); + + /* FIXME - copy security from hKeySrc to hKeyDest or just for the subkeys? */ + + do + { + copyKeys = CONTAINING_RECORD(copyQueueHead.Flink, + REGP_COPY_KEYS, + ListEntry); + + /* enumerate all values and copy them */ + Index = 0; + for (;;) + { + Status2 = NtEnumerateValueKey(copyKeys->hKeySrc, + Index, + KeyValueFullInformation, + Info.KeyValue, + BufferSize, + &BufferSizeRequired); + if (NT_SUCCESS(Status2)) + { + UNICODE_STRING ValueName; + PVOID Data; + + /* don't use RtlInitUnicodeString as the string is not NULL-terminated! */ + ValueName.Length = Info.KeyValue->NameLength; + ValueName.MaximumLength = ValueName.Length; + ValueName.Buffer = Info.KeyValue->Name; + + Data = (PVOID)((ULONG_PTR)Info.KeyValue + Info.KeyValue->DataOffset); + + Status2 = NtSetValueKey(copyKeys->hKeyDest, + &ValueName, + Info.KeyValue->TitleIndex, + Info.KeyValue->Type, + Data, + Info.KeyValue->DataLength); + + /* don't break, let's try to copy as many values as possible */ + if (!NT_SUCCESS(Status2) && NT_SUCCESS(Status)) + { + Status = Status2; + } + + Index++; + } + else if (Status2 == STATUS_BUFFER_OVERFLOW) + { + PVOID Buffer; + + ASSERT(BufferSize < BufferSizeRequired); + + Buffer = RtlReAllocateHeap(ProcessHeap, + 0, + Info.Buffer, + BufferSizeRequired); + if (Buffer != NULL) + { + Info.Buffer = Buffer; + /* try again */ + } + else + { + /* don't break, let's try to copy as many values as possible */ + Status2 = STATUS_INSUFFICIENT_RESOURCES; + Index++; + + if (NT_SUCCESS(Status)) + { + Status = Status2; + } + } + } + else + { + /* break to avoid an infinite loop in case of denied access or + other errors! */ + if (Status2 != STATUS_NO_MORE_ENTRIES && NT_SUCCESS(Status)) + { + Status = Status2; + } + + break; + } + } + + /* enumerate all subkeys and open and enqueue them */ + Index = 0; + for (;;) + { + Status2 = NtEnumerateKey(copyKeys->hKeySrc, + Index, + KeyNodeInformation, + Info.KeyNode, + BufferSize, + &BufferSizeRequired); + if (NT_SUCCESS(Status2)) + { + HANDLE KeyHandle, NewKeyHandle; + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING SubKeyName, ClassName; + + /* don't use RtlInitUnicodeString as the string is not NULL-terminated! */ + SubKeyName.Length = Info.KeyNode->NameLength; + SubKeyName.MaximumLength = SubKeyName.Length; + SubKeyName.Buffer = Info.KeyNode->Name; + ClassName.Length = Info.KeyNode->ClassLength; + ClassName.MaximumLength = ClassName.Length; + ClassName.Buffer = (PWSTR)((ULONG_PTR)Info.KeyNode + Info.KeyNode->ClassOffset); + + /* open the subkey with sufficient rights */ + + InitializeObjectAttributes(&ObjectAttributes, + &SubKeyName, + OBJ_CASE_INSENSITIVE, + copyKeys->hKeySrc, + NULL); + + Status2 = NtOpenKey(&KeyHandle, + KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, + &ObjectAttributes); + if (NT_SUCCESS(Status2)) + { + /* FIXME - attempt to query the security information */ + + InitializeObjectAttributes(&ObjectAttributes, + &SubKeyName, + OBJ_CASE_INSENSITIVE, + copyKeys->hKeyDest, + NULL); + + Status2 = NtCreateKey(&NewKeyHandle, + KEY_ALL_ACCESS, + &ObjectAttributes, + Info.KeyNode->TitleIndex, + &ClassName, + 0, + NULL); + if (NT_SUCCESS(Status2)) + { + newCopyKeys = RtlAllocateHeap(ProcessHeap, + 0, + sizeof(REGP_COPY_KEYS)); + if (newCopyKeys != NULL) + { + /* save the handles and enqueue the subkey */ + newCopyKeys->hKeySrc = KeyHandle; + newCopyKeys->hKeyDest = NewKeyHandle; + InsertTailList(©QueueHead, + &newCopyKeys->ListEntry); + } + else + { + NtClose(KeyHandle); + NtClose(NewKeyHandle); + + Status2 = STATUS_INSUFFICIENT_RESOURCES; + goto GoNextKey; + } + } + else + { + NtClose(KeyHandle); + } + } + +GoNextKey: + if (!NT_SUCCESS(Status2) && NT_SUCCESS(Status)) + { + Status = Status2; + } + + Index++; + } + else if (Status2 == STATUS_BUFFER_OVERFLOW) + { + PVOID Buffer; + + ASSERT(BufferSize < BufferSizeRequired); + + Buffer = RtlReAllocateHeap(ProcessHeap, + 0, + Info.Buffer, + BufferSizeRequired); + if (Buffer != NULL) + { + Info.Buffer = Buffer; + /* try again */ + } + else + { + /* don't break, let's try to copy as many keys as possible */ + Status2 = STATUS_INSUFFICIENT_RESOURCES; + Index++; + + if (NT_SUCCESS(Status)) + { + Status = Status2; + } + } + } + else + { + /* break to avoid an infinite loop in case of denied access or + other errors! */ + if (Status2 != STATUS_NO_MORE_ENTRIES && NT_SUCCESS(Status)) + { + Status = Status2; + } + + break; + } + } + + /* close the handles and remove the entry from the list */ + if (copyKeys->hKeySrc != hKeySrc) + { + NtClose(copyKeys->hKeySrc); + } + if (copyKeys->hKeyDest != hKeyDest) + { + NtClose(copyKeys->hKeyDest); + } + + RemoveEntryList(©Keys->ListEntry); + + RtlFreeHeap(ProcessHeap, + 0, + copyKeys); + } while (!IsListEmpty(©QueueHead)); + } + else + Status = STATUS_INSUFFICIENT_RESOURCES; + + RtlFreeHeap(ProcessHeap, + 0, + Info.Buffer); + + return Status; +} + + /*********************************************************************** * * RegCopyTreeW * - * @unimplemented + * @implemented */ LONG STDCALL RegCopyTreeW(IN HKEY hKeySrc, @@ -361,7 +645,7 @@ NULL); Status = NtOpenKey(&SubKeyHandle, - KEY_READ, + KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, &ObjectAttributes); if (!NT_SUCCESS(Status)) { @@ -373,8 +657,8 @@ else CurKey = KeyHandle; - /* FIXME - copy all keys and values recursively */ - Status = STATUS_NOT_IMPLEMENTED; + Status = RegpCopyTree(CurKey, + hKeyDest); if (SubKeyHandle != NULL) { @@ -1135,7 +1419,7 @@ NtClose(delKeys->KeyHandle); } - if (!NT_SUCCESS(Status)) + if (NT_SUCCESS(Status)) { /* don't break, let's try to delete as many keys as possible */ Status = Status2;
19 years, 3 months
1
0
0
0
[hpoussin] 18025: If device instance id is not unique, prepend information from parent bus device
by hpoussin@svn.reactos.com
If device instance id is not unique, prepend information from parent bus device Modified: trunk/reactos/ntoskrnl/io/pnpmgr.c _____ Modified: trunk/reactos/ntoskrnl/io/pnpmgr.c --- trunk/reactos/ntoskrnl/io/pnpmgr.c 2005-09-24 11:43:23 UTC (rev 18024) +++ trunk/reactos/ntoskrnl/io/pnpmgr.c 2005-09-24 13:19:25 UTC (rev 18025) @@ -1294,6 +1294,7 @@ HANDLE InstanceKey = NULL; UNICODE_STRING ValueName; DEVICE_CAPABILITIES DeviceCapabilities; + PKEY_VALUE_PARTIAL_INFORMATION ParentPrefixIdInformation = NULL; DPRINT("IopActionInterrogateDeviceStack(%p, %p)\n", DeviceNode, Context); DPRINT("PDO 0x%p\n", DeviceNode->PhysicalDeviceObject); @@ -1351,6 +1352,69 @@ DPRINT("IopInitiatePnpIrp() failed (Status %x)\n", Status); } + DPRINT("Sending IRP_MN_QUERY_CAPABILITIES to device stack\n"); + + Status = IopQueryDeviceCapabilities(DeviceNode, &DeviceCapabilities); + if (!NT_SUCCESS(Status)) + { + DPRINT("IopInitiatePnpIrp() failed (Status 0x%08lx)\n", Status); + } + + DeviceNode->CapabilityFlags = *(PULONG)((ULONG_PTR)&DeviceCapabilities + 4); + + if (!DeviceCapabilities.UniqueID) + { + /* Device has not a unique ID. We need to prepend parent bus unique identifier */ + DPRINT("Instance ID is not unique\n"); + if (DeviceNode->Parent->InstancePath.Length > 0) + { + /* Parent device node exists */ + HANDLE hKey; + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING KeyName; + ULONG KeyNameBufferLength; + PWSTR KeyNameBuffer = NULL; + + KeyNameBufferLength = FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[0]) + MAX_PATH * sizeof(WCHAR); + ParentPrefixIdInformation = ExAllocatePool(PagedPool, KeyNameBufferLength + sizeof(WCHAR)); + KeyNameBuffer = ExAllocatePool(PagedPool, (49 * sizeof(WCHAR)) + DeviceNode->Parent->InstancePath.Length); + if (ParentPrefixIdInformation && KeyNameBuffer) + { + /* Memory is allocated, let's try to read registry settings */ + wcscpy(KeyNameBuffer, L"\\Registry\\Machine\\System\\CurrentControlSet\\Enum\\"); + wcscat(KeyNameBuffer, DeviceNode->Parent->InstancePath.Buffer); + RtlInitUnicodeString(&KeyName, KeyNameBuffer); + InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL); + Status = ZwOpenKey(&hKey, KEY_READ, &ObjectAttributes); + if (NT_SUCCESS(Status)) + { + RtlInitUnicodeString(&ValueName, L"ParentIdPrefix"); + Status = ZwQueryValueKey( + hKey, &ValueName, + KeyValuePartialInformation, ParentPrefixIdInformation, + KeyNameBufferLength, &KeyNameBufferLength); + if (NT_SUCCESS(Status)) + { + /* NULL-terminate the string, as we have allocated enough place for it */ + ((PWSTR)ParentPrefixIdInformation->Data)[ParentPrefixIdInformation->Data Length / sizeof(WCHAR)] = 0; + } + else + { + ExFreePool(ParentPrefixIdInformation); + ParentPrefixIdInformation = NULL; + } + ZwClose(hKey); + } + else + { + ExFreePool(ParentPrefixIdInformation); + ParentPrefixIdInformation = NULL; + } + } + ExFreePool(KeyNameBuffer); + } + } + DPRINT("Sending IRP_MN_QUERY_ID.BusQueryInstanceID to device stack\n"); Stack.Parameters.QueryId.IdType = BusQueryInstanceID; @@ -1363,6 +1427,13 @@ { /* Append the instance id string */ wcscat(InstancePath, L"\\"); + if (ParentPrefixIdInformation && ParentPrefixIdInformation->Type == REG_SZ) + { + /* Add information from parent bus device to InstancePath */ + wcscat(InstancePath, (PWSTR)ParentPrefixIdInformation->Data); + if (*(PWSTR)IoStatusBlock.Information) + wcscat(InstancePath, L"&"); + } wcscat(InstancePath, (PWSTR)IoStatusBlock.Information); /* @@ -1374,21 +1445,8 @@ { DPRINT("IopInitiatePnpIrp() failed (Status %x)\n", Status); } + ExFreePool(ParentPrefixIdInformation); - Status = IopQueryDeviceCapabilities(DeviceNode, &DeviceCapabilities); - if (!NT_SUCCESS(Status)) - { - DPRINT("IopInitiatePnpIrp() failed (Status 0x%08lx)\n", Status); - } - - DeviceNode->CapabilityFlags = *(PULONG)((ULONG_PTR)&DeviceCapabilities + 4); - - if (!DeviceCapabilities.UniqueID) - { - DPRINT("Instance ID is not unique\n"); - /* FIXME: Add information from parent bus driver to InstancePath */ - } - if (!RtlCreateUnicodeString(&DeviceNode->InstancePath, InstancePath)) { DPRINT("No resources\n");
19 years, 3 months
1
0
0
0
[gdalsnes] 18024: uncomment and add mutex asserts
by gdalsnes@svn.reactos.com
uncomment and add mutex asserts Modified: trunk/reactos/ntoskrnl/ex/fmutex.c _____ Modified: trunk/reactos/ntoskrnl/ex/fmutex.c --- trunk/reactos/ntoskrnl/ex/fmutex.c 2005-09-24 09:30:43 UTC (rev 18023) +++ trunk/reactos/ntoskrnl/ex/fmutex.c 2005-09-24 11:43:23 UTC (rev 18024) @@ -21,7 +21,11 @@ VOID FASTCALL ExAcquireFastMutexUnsafe(PFAST_MUTEX FastMutex) { - //ASSERT(FastMutex->Owner != KeGetCurrentThread()); + ASSERT(KeGetCurrentThread() == NULL || FastMutex->Owner != KeGetCurrentThread()); + ASSERT(KeGetCurrentIrql() == APC_LEVEL || + KeGetCurrentThread() == NULL || + KeGetCurrentThread()->KernelApcDisable); + InterlockedIncrementUL(&FastMutex->Contention); while (InterlockedExchange(&FastMutex->Count, 0) == 0) { @@ -41,7 +45,11 @@ VOID FASTCALL ExReleaseFastMutexUnsafe(PFAST_MUTEX FastMutex) { - //ASSERT(FastMutex->Owner == KeGetCurrentThread()); + ASSERT(KeGetCurrentThread() == NULL || FastMutex->Owner == KeGetCurrentThread()); + ASSERT(KeGetCurrentIrql() == APC_LEVEL || + KeGetCurrentThread() == NULL || + KeGetCurrentThread()->KernelApcDisable); + FastMutex->Owner = NULL; InterlockedExchange(&FastMutex->Count, 1); if (FastMutex->Contention > 0)
19 years, 3 months
1
0
0
0
[ekohl] 18023: - Implement CM_Get_Device_List_Size_ExW
by ekohl@svn.reactos.com
- Implement CM_Get_Device_List_Size_ExW Modified: trunk/reactos/include/idl/pnp.idl Modified: trunk/reactos/include/wine/cfgmgr32.h Modified: trunk/reactos/lib/setupapi/cfgmgr.c Modified: trunk/reactos/services/umpnpmgr/umpnpmgr.c _____ Modified: trunk/reactos/include/idl/pnp.idl --- trunk/reactos/include/idl/pnp.idl 2005-09-24 02:50:02 UTC (rev 18022) +++ trunk/reactos/include/idl/pnp.idl 2005-09-24 09:30:43 UTC (rev 18023) @@ -49,6 +49,17 @@ [out] unsigned long *RequiredLength, [in] DWORD Flags); +// CONFIGRET PNP_GetDeviceList(handle_t BindingHandle, +// [in, unique, string] wchar_t *Filter, +// [out, string, size_is(*Length)] unsigned char *Buffer +// [in, out] unsigned long *Length, +// [in] DWORD Flags); + + CONFIGRET PNP_GetDeviceListSize(handle_t BindingHandle, + [in, unique, string] wchar_t *Filter, + [out] unsigned long *Length, + [in] DWORD Flags); + CONFIGRET PNP_GetDepth(handle_t BindingHandle, [in, string] wchar_t *DeviceInstance, [out] unsigned long *Depth, _____ Modified: trunk/reactos/include/wine/cfgmgr32.h --- trunk/reactos/include/wine/cfgmgr32.h 2005-09-24 02:50:02 UTC (rev 18022) +++ trunk/reactos/include/wine/cfgmgr32.h 2005-09-24 09:30:43 UTC (rev 18023) @@ -128,7 +128,18 @@ #define CM_DELETE_CLASS_SUBKEYS 0x00000001 #define CM_DELETE_CLASS_BITS 0x00000001 +/* ulFlags for CM_Get_Device_ID_List and CM_Get_Device_ID_List_Size */ +#define CM_GETIDLIST_FILTER_NONE (0x00000000) +#define CM_GETIDLIST_FILTER_ENUMERATOR (0x00000001) +#define CM_GETIDLIST_FILTER_SERVICE (0x00000002) +#define CM_GETIDLIST_FILTER_EJECTRELATIONS (0x00000004) +#define CM_GETIDLIST_FILTER_REMOVALRELATIONS (0x00000008) +#define CM_GETIDLIST_FILTER_POWERRELATIONS (0x00000010) +#define CM_GETIDLIST_FILTER_BUSRELATIONS (0x00000020) +#define CM_GETIDLIST_DONOTGENERATE (0x10000040) +#define CM_GETIDLIST_FILTER_BITS (0x1000007F) + CONFIGRET WINAPI CM_Connect_MachineA( PCSTR, PHMACHINE ); CONFIGRET WINAPI CM_Connect_MachineW( PCWSTR, PHMACHINE ); #define CM_Connect_Machine WINELIB_NAME_AW(CM_Connect_Machine) _____ Modified: trunk/reactos/lib/setupapi/cfgmgr.c --- trunk/reactos/lib/setupapi/cfgmgr.c 2005-09-24 02:50:02 UTC (rev 18022) +++ trunk/reactos/lib/setupapi/cfgmgr.c 2005-09-24 09:30:43 UTC (rev 18023) @@ -1195,9 +1195,34 @@ CONFIGRET WINAPI CM_Get_Device_ID_List_Size_ExW( PULONG pulLen, PCWSTR pszFilter, ULONG ulFlags, HMACHINE hMachine) { + RPC_BINDING_HANDLE BindingHandle = NULL; + FIXME("%p %s %ld %lx\n", pulLen, debugstr_w(pszFilter), ulFlags, hMachine); - *pulLen = 2; - return CR_SUCCESS; + + if (pulLen == NULL) + return CR_INVALID_POINTER; + + if (ulFlags & ~CM_GETIDLIST_FILTER_BITS) + return CR_INVALID_FLAG; + + if (hMachine != NULL) + { + BindingHandle = ((PMACHINE_INFO)hMachine)->BindingHandle; + if (BindingHandle == NULL) + return CR_FAILURE; + } + else + { + if (!PnpGetLocalHandles(&BindingHandle, NULL)) + return CR_FAILURE; + } + + *pulLen = 0; + + return PNP_GetDeviceListSize(BindingHandle, + (LPWSTR)pszFilter, + pulLen, + ulFlags); } _____ Modified: trunk/reactos/services/umpnpmgr/umpnpmgr.c --- trunk/reactos/services/umpnpmgr/umpnpmgr.c 2005-09-24 02:50:02 UTC (rev 18022) +++ trunk/reactos/services/umpnpmgr/umpnpmgr.c 2005-09-24 09:30:43 UTC (rev 18023) @@ -303,6 +303,21 @@ CONFIGRET +PNP_GetDeviceListSize(handle_t BindingHandle, + wchar_t *Filter, + unsigned long *Length, + DWORD Flags) +{ + DPRINT("PNP_GetDeviceListSize() called\n"); + + /* FIXME */ + *Length = 2; + + return CR_SUCCESS; +} + + +CONFIGRET PNP_GetDepth(handle_t BindingHandle, wchar_t *DeviceInstance, unsigned long *Depth, @@ -635,6 +650,22 @@ CONFIGRET +PNP_CreateKey(handle_t BindingHandle, + wchar_t *SubKey, + unsigned long samDesired, + unsigned long Flags) +{ + CONFIGRET ret = CR_SUCCESS; + + DPRINT("PNP_CreateKey() called\n"); + + DPRINT("PNP_CreateKey() done (returns %lx)\n", ret); + + return ret; +} + + +CONFIGRET PNP_GetClassName(handle_t BindingHandle, wchar_t *ClassGuid, wchar_t *Buffer,
19 years, 3 months
1
0
0
0
[gdalsnes] 18022: -include/ndk/rtltypes.h: add MAX_ATOM_LEN define
by gdalsnes@svn.reactos.com
-include/ndk/rtltypes.h: add MAX_ATOM_LEN define -win32k: remove some NtUser syscalls and merge some NtUser syscalls -crt/include/internal/file.h: correct spelling -RtlAddAtomToAtomTable: check for max atom len -RtlQueryAtomInAtomTable: fix bug. somehow lock wasnt always released. -fix/reword windows classes impl. based on Wine. All but 2 winetests pass. -ntoskrnl/rtl/atom.c: add fixme about global atom table -remove desktop object lock -dont link windows into the class object -co_IntShellHookNotify: safely send notify messages -misc win32k reorg/cleanup Modified: trunk/reactos/include/ndk/rtltypes.h Modified: trunk/reactos/include/win32k/ntuser.h Modified: trunk/reactos/lib/crt/include/internal/file.h Modified: trunk/reactos/lib/rtl/atom.c Modified: trunk/reactos/lib/user32/windows/caret.c Modified: trunk/reactos/lib/user32/windows/class.c Modified: trunk/reactos/lib/user32/windows/paint.c Modified: trunk/reactos/lib/user32/windows/window.c Modified: trunk/reactos/ntoskrnl/rtl/atom.c Modified: trunk/reactos/subsys/win32k/include/class.h Modified: trunk/reactos/subsys/win32k/include/desktop.h Modified: trunk/reactos/subsys/win32k/include/win32.h Modified: trunk/reactos/subsys/win32k/include/window.h Modified: trunk/reactos/subsys/win32k/main/dllmain.c Modified: trunk/reactos/subsys/win32k/ntuser/caret.c Modified: trunk/reactos/subsys/win32k/ntuser/class.c Modified: trunk/reactos/subsys/win32k/ntuser/cursoricon.c Modified: trunk/reactos/subsys/win32k/ntuser/desktop.c Modified: trunk/reactos/subsys/win32k/ntuser/misc.c Modified: trunk/reactos/subsys/win32k/ntuser/painting.c Modified: trunk/reactos/subsys/win32k/ntuser/window.c Modified: trunk/reactos/subsys/win32k/ntuser/winsta.c Modified: trunk/reactos/tools/nci/w32ksvc.db _____ Modified: trunk/reactos/include/ndk/rtltypes.h --- trunk/reactos/include/ndk/rtltypes.h 2005-09-23 21:46:54 UTC (rev 18021) +++ trunk/reactos/include/ndk/rtltypes.h 2005-09-24 02:50:02 UTC (rev 18022) @@ -107,6 +107,8 @@ #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag #define NLS_OEM_LEAD_BYTE_INFO NlsOemLeadByteInfo +#define MAX_ATOM_LEN 255 /* TCHARS not including nullterm */ + /* List Macros */ static __inline VOID _____ Modified: trunk/reactos/include/win32k/ntuser.h --- trunk/reactos/include/win32k/ntuser.h 2005-09-23 21:46:54 UTC (rev 18021) +++ trunk/reactos/include/win32k/ntuser.h 2005-09-24 02:50:02 UTC (rev 18022) @@ -212,7 +212,6 @@ #define TWOPARAM_ROUTINE_UNKNOWN 0x54 #define TWOPARAM_ROUTINE_SHOWOWNEDPOPUPS 0x55 #define TWOPARAM_ROUTINE_SWITCHTOTHISWINDOW 0x56 -#define TWOPARAM_ROUTINE_VALIDATERGN 0x57 #define TWOPARAM_ROUTINE_SETWNDCONTEXTHLPID 0x58 #define TWOPARAM_ROUTINE_SETCARETPOS 0x60 #define TWOPARAM_ROUTINE_GETWINDOWINFO 0x61 @@ -894,11 +893,6 @@ DWORD Unknown0, DWORD Unknown1); -BOOL -STDCALL -NtUserHideCaret( - HWND hWnd); - DWORD STDCALL NtUserImpersonateDdeClientWindow( @@ -935,21 +929,7 @@ LPWSTR lpString, INT nMaxCount); -DWORD -STDCALL -NtUserInvalidateRect( -HWND hWnd, -CONST RECT *lpRect, -BOOL bErase); -DWORD -STDCALL - NtUserInvalidateRgn( - HWND hWnd, - HRGN hRgn, - BOOL bErase); - - BOOL STDCALL NtUserIsClipboardFormatAvailable( @@ -1575,7 +1555,8 @@ BOOL STDCALL NtUserShowCaret( - HWND hWnd); + HWND hWnd, + BOOL bShow); DWORD STDCALL @@ -1681,9 +1662,6 @@ DWORD Unknown1, DWORD Unknown2); -BOOL STDCALL -NtUserUpdateWindow( HWND hWnd ); - DWORD STDCALL NtUserUpdateLayeredWindow( @@ -1715,10 +1693,6 @@ NtUserValidateHandleSecure( DWORD Unknown0); -VOID STDCALL -NtUserValidateRect(HWND Wnd, const RECT* Rect); - - DWORD STDCALL NtUserVkKeyScanEx( _____ Modified: trunk/reactos/lib/crt/include/internal/file.h --- trunk/reactos/lib/crt/include/internal/file.h 2005-09-23 21:46:54 UTC (rev 18021) +++ trunk/reactos/lib/crt/include/internal/file.h 2005-09-24 02:50:02 UTC (rev 18022) @@ -102,7 +102,7 @@ #define fdinfo_bucket_idx(i) ((i) >> FDINFO_ENTRIES_PER_BUCKET_SHIFT) /* get position inside a bucket (0-31) from an fd */ #define fdinfo_bucket_entry_idx(i) ((i) & (FDINFO_ENTRIES_PER_BUCKET - 1)) -/* get bucket ptr. (ptr. to fist fdinfo inside a bucket) from an fd */ +/* get bucket ptr. (ptr. to first fdinfo inside a bucket) from an fd */ #define fdinfo_bucket(i) ( __pioinfo[fdinfo_bucket_idx(i)]) /* get fdinfo ptr. from an fd */ #define fdinfo(i) (fdinfo_bucket(i) + fdinfo_bucket_entry_idx(i)) _____ Modified: trunk/reactos/lib/rtl/atom.c --- trunk/reactos/lib/rtl/atom.c 2005-09-23 21:46:54 UTC (rev 18021) +++ trunk/reactos/lib/rtl/atom.c 2005-09-24 02:50:02 UTC (rev 18022) @@ -347,6 +347,12 @@ if (HashLink != NULL) { ULONG AtomNameLen = wcslen(AtomName); + + if (AtomNameLen > MAX_ATOM_LEN) + { + Status = STATUS_INVALID_PARAMETER; + goto end; + } Entry = RtlpAllocAtomTableEntry(sizeof(RTL_ATOM_TABLE_ENTRY) - sizeof(Entry->Name) + @@ -390,7 +396,7 @@ Status = STATUS_OBJECT_NAME_INVALID; } } - +end: RtlpUnlockAtomTable(AtomTable); return Status; @@ -592,6 +598,8 @@ PULONG NameLength) { ULONG Length; + BOOL Unlock = FALSE; + union { /* A RTL_ATOM_TABLE_ENTRY has a "WCHAR Name[1]" entry at the end. @@ -616,6 +624,7 @@ else { RtlpLockAtomTable(AtomTable); + Unlock = TRUE; Entry = RtlpGetAtomEntry(AtomTable, (ULONG)((USHORT)Atom - 0xC000)); @@ -676,10 +685,7 @@ Status = STATUS_INVALID_HANDLE; } - if (NULL != Entry && Entry != &NumberEntry.AtomTableEntry) - { - RtlpUnlockAtomTable(AtomTable); - } + if (Unlock) RtlpUnlockAtomTable(AtomTable); return Status; } _____ Modified: trunk/reactos/lib/user32/windows/caret.c --- trunk/reactos/lib/user32/windows/caret.c 2005-09-23 21:46:54 UTC (rev 18021) +++ trunk/reactos/lib/user32/windows/caret.c 2005-09-24 02:50:02 UTC (rev 18022) @@ -108,7 +108,7 @@ BOOL STDCALL HideCaret(HWND hWnd) { - return (BOOL)NtUserHideCaret(hWnd); + return NtUserShowCaret(hWnd, FALSE); } @@ -139,7 +139,7 @@ BOOL STDCALL ShowCaret(HWND hWnd) { - return (BOOL)NtUserShowCaret(hWnd); + return NtUserShowCaret(hWnd, TRUE); } /* EOF */ _____ Modified: trunk/reactos/lib/user32/windows/class.c --- trunk/reactos/lib/user32/windows/class.c 2005-09-23 21:46:54 UTC (rev 18021) +++ trunk/reactos/lib/user32/windows/class.c 2005-09-24 02:50:02 UTC (rev 18022) @@ -87,7 +87,14 @@ w.lpszMenuName = (LPCWSTR)&str2; w.lpszClassName = (LPCWSTR)&str3; + + /* get info about system classes? */ + if (!hInst) hInst = User32Instance; + retval = (BOOL)NtUserGetClassInfo(hInst, str, &w, TRUE, 0); + + w.hInstance = (hInst == User32Instance) ? 0 : hInst; + if ( !IS_ATOM(str) ) HEAP_free(str); _____ Modified: trunk/reactos/lib/user32/windows/paint.c --- trunk/reactos/lib/user32/windows/paint.c 2005-09-23 21:46:54 UTC (rev 18021) +++ trunk/reactos/lib/user32/windows/paint.c 2005-09-24 02:50:02 UTC (rev 18022) @@ -157,7 +157,7 @@ CONST RECT *lpRect, BOOL bErase) { - return NtUserInvalidateRect( hWnd, lpRect, bErase ); + return RedrawWindow( hWnd, lpRect, 0, RDW_INVALIDATE | (bErase ? RDW_ERASE : 0) ); } @@ -171,7 +171,7 @@ HRGN hRgn, BOOL bErase) { - return NtUserInvalidateRgn( hWnd, hRgn, bErase ); + return RedrawWindow(hWnd, NULL, hRgn, RDW_INVALIDATE | (bErase ? RDW_ERASE : 0) ); } @@ -224,7 +224,7 @@ UpdateWindow( HWND hWnd) { - return NtUserUpdateWindow( hWnd ); + return RedrawWindow( hWnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN ); } @@ -237,6 +237,8 @@ HWND hWnd, CONST RECT *lpRect) { + /* FIXME: should RDW_NOCHILDREN be included too? Ros used to, + but Wine dont so i removed it... */ return RedrawWindow(hWnd, lpRect, 0, RDW_VALIDATE); } @@ -250,7 +252,9 @@ HWND hWnd, HRGN hRgn) { - return NtUserValidateRgn(hWnd, hRgn); + /* FIXME: should RDW_NOCHILDREN be included too? Ros used to, + but Wine dont so i removed it... */ + return RedrawWindow( hWnd, NULL, hRgn, RDW_VALIDATE ); } _____ Modified: trunk/reactos/lib/user32/windows/window.c --- trunk/reactos/lib/user32/windows/window.c 2005-09-23 21:46:54 UTC (rev 18021) +++ trunk/reactos/lib/user32/windows/window.c 2005-09-24 02:50:02 UTC (rev 18022) @@ -221,7 +221,7 @@ nHeight, hWndParent, hMenu, - hInstance, + hInstance, lpParam, SW_SHOW, FALSE); @@ -304,7 +304,7 @@ nHeight, hWndParent, hMenu, - hInstance, + hInstance, lpParam, SW_SHOW, TRUE); _____ Modified: trunk/reactos/ntoskrnl/rtl/atom.c --- trunk/reactos/ntoskrnl/rtl/atom.c 2005-09-23 21:46:54 UTC (rev 18021) +++ trunk/reactos/ntoskrnl/rtl/atom.c 2005-09-24 02:50:02 UTC (rev 18022) @@ -14,6 +14,7 @@ #define NDEBUG #include <internal/debug.h> + /* PROTOTYPES ****************************************************************/ static PRTL_ATOM_TABLE RtlpGetGlobalAtomTable(VOID); @@ -38,6 +39,12 @@ /* GLOBALS *******************************************************************/ +/* FIXME: this is WRONG! The global atom table should live in the WinSta struct + * and accessed thru win32k callouts. + * NOTE: There is a session/win32k global atom table also, but its private to + * win32k. Its used for RegisterWindowMessage() and for window classes. + * -Gunnar + */ static PRTL_ATOM_TABLE GlobalAtomTable = NULL; /* FUNCTIONS *****************************************************************/ _____ Modified: trunk/reactos/subsys/win32k/include/class.h --- trunk/reactos/subsys/win32k/include/class.h 2005-09-23 21:46:54 UTC (rev 18021) +++ trunk/reactos/subsys/win32k/include/class.h 2005-09-24 02:50:02 UTC (rev 18022) @@ -7,6 +7,7 @@ typedef struct _WNDCLASS_OBJECT { UINT cbSize; + LONG refs; /* windows using this class (is 0 after class creation) */ UINT style; WNDPROC lpfnWndProcA; WNDPROC lpfnWndProcW; @@ -21,10 +22,8 @@ HICON hIconSm; BOOL Unicode; BOOL Global; - LIST_ENTRY ListEntry; + LIST_ENTRY ListEntry; /* linked into owning process */ PCHAR ExtraData; - /* list of windows */ - LIST_ENTRY ClassWindowsListHead; } WNDCLASS_OBJECT, *PWNDCLASS_OBJECT; NTSTATUS FASTCALL @@ -33,24 +32,26 @@ NTSTATUS FASTCALL CleanupClassImpl(VOID); -#define ClassDereferenceObject(ClassObj) \ - ObmDereferenceObject(ClassObj) +void FASTCALL DestroyProcessClasses(PW32PROCESS Process ); -BOOL FASTCALL -ClassReferenceClassByAtom( - PWNDCLASS_OBJECT* Class, +inline VOID FASTCALL +ClassDerefObject(PWNDCLASS_OBJECT Class); + +inline VOID FASTCALL +ClassRefObject(PWNDCLASS_OBJECT Class); + +PWNDCLASS_OBJECT FASTCALL +ClassGetClassByAtom( RTL_ATOM Atom, HINSTANCE hInstance); -BOOL FASTCALL -ClassReferenceClassByName( - PWNDCLASS_OBJECT *Class, +PWNDCLASS_OBJECT FASTCALL +ClassGetClassByName( LPCWSTR ClassName, HINSTANCE hInstance); -BOOL FASTCALL -ClassReferenceClassByNameOrAtom( - PWNDCLASS_OBJECT *Class, +PWNDCLASS_OBJECT FASTCALL +ClassGetClassByNameOrAtom( LPCWSTR ClassNameOrAtom, HINSTANCE hInstance); _____ Modified: trunk/reactos/subsys/win32k/include/desktop.h --- trunk/reactos/subsys/win32k/include/desktop.h 2005-09-23 21:46:54 UTC (rev 18021) +++ trunk/reactos/subsys/win32k/include/desktop.h 2005-09-24 02:50:02 UTC (rev 18022) @@ -11,7 +11,7 @@ CSHORT Type; CSHORT Size; LIST_ENTRY ListEntry; - KSPIN_LOCK Lock; + UNICODE_STRING Name; /* Pointer to the associated window station. */ struct _WINSTATION_OBJECT *WindowStation; _____ Modified: trunk/reactos/subsys/win32k/include/win32.h --- trunk/reactos/subsys/win32k/include/win32.h 2005-09-23 21:46:54 UTC (rev 18021) +++ trunk/reactos/subsys/win32k/include/win32.h 2005-09-24 02:50:02 UTC (rev 18022) @@ -22,7 +22,7 @@ typedef struct _W32PROCESS { - LIST_ENTRY ClassListHead; + LIST_ENTRY ClassList; LIST_ENTRY MenuListHead; FAST_MUTEX PrivateFontListLock; LIST_ENTRY PrivateFontListHead; _____ Modified: trunk/reactos/subsys/win32k/include/window.h --- trunk/reactos/subsys/win32k/include/window.h 2005-09-23 21:46:54 UTC (rev 18021) +++ trunk/reactos/subsys/win32k/include/window.h 2005-09-24 02:50:02 UTC (rev 18022) @@ -28,8 +28,6 @@ { /* Pointer to the window class. */ PWNDCLASS_OBJECT Class; - /* entry in the window list of the class object */ - LIST_ENTRY ClassListEntry; /* Extended style. */ DWORD ExStyle; /* Window name. */ _____ Modified: trunk/reactos/subsys/win32k/main/dllmain.c --- trunk/reactos/subsys/win32k/main/dllmain.c 2005-09-23 21:46:54 UTC (rev 18021) +++ trunk/reactos/subsys/win32k/main/dllmain.c 2005-09-24 02:50:02 UTC (rev 18022) @@ -70,7 +70,7 @@ { DPRINT("Creating W32 process PID:%d at IRQ level: %lu\n", Process->UniqueProcessId, KeGetCurrentIrql()); - InitializeListHead(&Win32Process->ClassListHead); + InitializeListHead(&Win32Process->ClassList); InitializeListHead(&Win32Process->MenuListHead); @@ -99,8 +99,10 @@ IntCleanupCurIcons(Process, Win32Process); IntEngCleanupDriverObjs(Process, Win32Process); CleanupMonitorImpl(); + + /* no process windows should exist at this point, or the function will assert! */ + DestroyProcessClasses(Win32Process); - GDI_CleanupForProcess(Process); co_IntGraphicsCheck(FALSE); _____ Modified: trunk/reactos/subsys/win32k/ntuser/caret.c --- trunk/reactos/subsys/win32k/ntuser/caret.c 2005-09-23 21:46:54 UTC (rev 18021) +++ trunk/reactos/subsys/win32k/ntuser/caret.c 2005-09-24 02:50:02 UTC (rev 18022) @@ -9,17 +9,24 @@ * 10/15/2003 Created */ +/* INCLUDES ******************************************************************/ + #include <w32k.h> #define NDEBUG #include <debug.h> +/* DEFINES *****************************************************************/ + #define MIN_CARETBLINKRATE 100 #define MAX_CARETBLINKRATE 10000 #define DEFAULT_CARETBLINKRATE 530 #define CARET_REGKEY L"\\Registry\\User\\.Default\\Control Panel\\Desktop" #define CARET_VALUENAME L"CursorBlinkRate" +/* FUNCTIONS *****************************************************************/ + +static BOOL FASTCALL co_IntHideCaret(PTHRDCARETINFO CaretInfo) { @@ -69,6 +76,7 @@ return TRUE; } +static UINT FASTCALL IntQueryCaretBlinkRate(VOID) { @@ -134,6 +142,7 @@ return (UINT)Val; } +static UINT FASTCALL IntGetCaretBlinkTime(VOID) { @@ -158,6 +167,7 @@ return Ret; } + BOOL FASTCALL co_IntSetCaretPos(int X, int Y) { @@ -197,6 +207,8 @@ return FALSE; } +#if 0 //unused +static VOID FASTCALL co_IntDrawCaret(HWND hWnd) { @@ -210,9 +222,79 @@ ThreadQueue->CaretInfo->Showing = 1; } } +#endif +BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT Window OPTIONAL) +{ + PUSER_MESSAGE_QUEUE ThreadQueue; + + if (Window) ASSERT_REFS_CO(Window); + + if(Window && Window->OwnerThread != PsGetCurrentThread()) + { + SetLastWin32Error(ERROR_ACCESS_DENIED); + return FALSE; + } + + ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; + + if(Window && ThreadQueue->CaretInfo->hWnd != Window->hSelf) + { + SetLastWin32Error(ERROR_ACCESS_DENIED); + return FALSE; + } + + if(ThreadQueue->CaretInfo->Visible) + { + IntKillTimer(ThreadQueue->CaretInfo->hWnd, IDCARETTIMER, TRUE); + + co_IntHideCaret(ThreadQueue->CaretInfo); + ThreadQueue->CaretInfo->Visible = 0; + ThreadQueue->CaretInfo->Showing = 0; + } + + return TRUE; +} + + +BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT Window OPTIONAL) +{ + PUSER_MESSAGE_QUEUE ThreadQueue; + + if (Window) ASSERT_REFS_CO(Window); + + if(Window && Window->OwnerThread != PsGetCurrentThread()) + { + SetLastWin32Error(ERROR_ACCESS_DENIED); + return FALSE; + } + + ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; + + if(Window && ThreadQueue->CaretInfo->hWnd != Window->hSelf) + { + SetLastWin32Error(ERROR_ACCESS_DENIED); + return FALSE; + } + + if(!ThreadQueue->CaretInfo->Visible) + { + ThreadQueue->CaretInfo->Visible = 1; + if(!ThreadQueue->CaretInfo->Showing) + { + co_IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0); + } + IntSetTimer(ThreadQueue->CaretInfo->hWnd, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE); + } + + return TRUE; +} + + +/* SYSCALLS *****************************************************************/ + BOOL STDCALL NtUserCreateCaret( @@ -317,110 +399,15 @@ } -BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT Window OPTIONAL) -{ - PUSER_MESSAGE_QUEUE ThreadQueue; - if (Window) ASSERT_REFS_CO(Window); - - if(Window && Window->OwnerThread != PsGetCurrentThread()) - { - SetLastWin32Error(ERROR_ACCESS_DENIED); - return FALSE; - } - - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; - - if(Window && ThreadQueue->CaretInfo->hWnd != Window->hSelf) - { - SetLastWin32Error(ERROR_ACCESS_DENIED); - return FALSE; - } - - if(ThreadQueue->CaretInfo->Visible) - { - IntKillTimer((Window ? Window->hSelf : 0), IDCARETTIMER, TRUE); - - co_IntHideCaret(ThreadQueue->CaretInfo); - ThreadQueue->CaretInfo->Visible = 0; - ThreadQueue->CaretInfo->Showing = 0; - } - - return TRUE; -} - - BOOL STDCALL -NtUserHideCaret(HWND hWnd OPTIONAL) +NtUserShowCaret(HWND hWnd OPTIONAL, BOOL bShow) { PWINDOW_OBJECT Window = NULL; DECLARE_RETURN(BOOL); BOOL ret; - DPRINT("Enter NtUserHideCaret\n"); - UserEnterExclusive(); - - if(hWnd && !(Window = UserGetWindowObject(hWnd))) - { - RETURN(FALSE); - } - - if (Window) UserRefObjectCo(Window); - ret = co_UserHideCaret(Window); - if (Window) UserDerefObjectCo(Window); - - RETURN(ret); - -CLEANUP: - DPRINT("Leave NtUserHideCaret, ret=%i\n",_ret_); - UserLeave(); - END_CLEANUP; -} - - -BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT Window OPTIONAL) -{ - PUSER_MESSAGE_QUEUE ThreadQueue; - - if (Window) ASSERT_REFS_CO(Window); - - if(Window && Window->OwnerThread != PsGetCurrentThread()) - { - SetLastWin32Error(ERROR_ACCESS_DENIED); - return FALSE; - } - - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; - - if(Window && ThreadQueue->CaretInfo->hWnd != Window->hSelf) - { - SetLastWin32Error(ERROR_ACCESS_DENIED); - return FALSE; - } - - if(!ThreadQueue->CaretInfo->Visible) - { - ThreadQueue->CaretInfo->Visible = 1; - if(!ThreadQueue->CaretInfo->Showing) - { - co_IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0); - } - IntSetTimer((Window ? Window->hSelf : 0), IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE); - } - - return TRUE; -} - - -BOOL -STDCALL -NtUserShowCaret(HWND hWnd OPTIONAL) -{ - PWINDOW_OBJECT Window = NULL; - DECLARE_RETURN(BOOL); - BOOL ret; - DPRINT("Enter NtUserShowCaret\n"); UserEnterExclusive(); @@ -430,7 +417,12 @@ } if (Window) UserRefObjectCo(Window); - ret = co_UserShowCaret(Window); + + if (bShow) + ret = co_UserShowCaret(Window); + else + ret = co_UserHideCaret(Window); + if (Window) UserDerefObjectCo(Window); RETURN(ret); _____ Modified: trunk/reactos/subsys/win32k/ntuser/class.c --- trunk/reactos/subsys/win32k/ntuser/class.c 2005-09-23 21:46:54 UTC (rev 18021) +++ trunk/reactos/subsys/win32k/ntuser/class.c 2005-09-24 02:50:02 UTC (rev 18022) @@ -47,434 +47,222 @@ return(STATUS_SUCCESS); } -BOOL FASTCALL -ClassReferenceClassByAtom( - PWNDCLASS_OBJECT* Class, - RTL_ATOM Atom, - HINSTANCE hInstance) + +/* return TRUE if class became destroyed */ +inline VOID FASTCALL +ClassDerefObject(PWNDCLASS_OBJECT Class) { - PWNDCLASS_OBJECT Current, BestMatch = NULL; - PLIST_ENTRY CurrentEntry; - PW32PROCESS Process = PsGetWin32Process(); + ASSERT(Class->refs >= 1); + Class->refs--; +} - CurrentEntry = Process->ClassListHead.Flink; - while (CurrentEntry != &Process->ClassListHead) - { - Current = CONTAINING_RECORD(CurrentEntry, WNDCLASS_OBJECT, ListEntry); - if (Current->Atom == Atom && (hInstance == NULL || Current->hInstance == hInstance)) - { - *Class = Current; - ObmReferenceObject(Current); - return TRUE; - } +inline VOID FASTCALL +ClassRefObject(PWNDCLASS_OBJECT Class) +{ + ASSERT(Class->refs >= 0); + Class->refs++; +} - if (Current->Atom == Atom && Current->Global) - BestMatch = Current; - CurrentEntry = CurrentEntry->Flink; - } +VOID FASTCALL DestroyClass(PWNDCLASS_OBJECT Class) +{ + PWINSTATION_OBJECT WinSta; + WinSta = PsGetWin32Thread()->Desktop->WindowStation; + + ASSERT(Class->refs == 0); + RemoveEntryList(&Class->ListEntry); + //FIXME: release ATOM + RtlDeleteAtomFromAtomTable(WinSta->AtomTable, Class->Atom); + ExFreePool(Class); +} - if (BestMatch != NULL) - { - *Class = BestMatch; - ObmReferenceObject(BestMatch); - return TRUE; - } - return FALSE; -} - -BOOL FASTCALL -ClassReferenceClassByName( - PWNDCLASS_OBJECT *Class, - LPCWSTR ClassName, - HINSTANCE hInstance) +/* clean all process classes. all process windows must cleaned first!! */ +void FASTCALL DestroyProcessClasses(PW32PROCESS Process ) { - PWINSTATION_OBJECT WinStaObject; - NTSTATUS Status; - BOOL Found; - RTL_ATOM ClassAtom; + PWNDCLASS_OBJECT Class; - if (!ClassName || !PsGetWin32Thread()->Desktop) - return FALSE; - - WinStaObject = PsGetWin32Thread()->Desktop->WindowStation; - - Status = RtlLookupAtomInAtomTable( - WinStaObject->AtomTable, - (LPWSTR)ClassName, - &ClassAtom); - - if (!NT_SUCCESS(Status)) + while (!IsListEmpty(&Process->ClassList)) { - DPRINT1("Failed to lookup class atom!\n"); - return FALSE; + Class = CONTAINING_RECORD(RemoveHeadList(&Process->ClassList), WNDCLASS_OBJECT, ListEntry); + DestroyClass(Class); } - - Found = ClassReferenceClassByAtom(Class, ClassAtom, hInstance); - - return Found; } -BOOL FASTCALL -ClassReferenceClassByNameOrAtom( - PWNDCLASS_OBJECT *Class, - LPCWSTR ClassNameOrAtom, - HINSTANCE hInstance) -{ - BOOL Found; - if (IS_ATOM(ClassNameOrAtom)) - Found = ClassReferenceClassByAtom(Class, (RTL_ATOM)((ULONG_PTR)ClassNameOrAtom), hInstance); - else - Found = ClassReferenceClassByName(Class, ClassNameOrAtom, hInstance); - return Found; -} -DWORD STDCALL -NtUserGetClassInfo( - HINSTANCE hInstance, - LPCWSTR lpClassName, - LPWNDCLASSEXW lpWndClassEx, - BOOL Ansi, - DWORD unknown3) +PWNDCLASS_OBJECT FASTCALL +ClassGetClassByAtom(RTL_ATOM Atom, HINSTANCE hInstance) { PWNDCLASS_OBJECT Class; - RTL_ATOM Atom; - DECLARE_RETURN(DWORD); + PW32PROCESS Process = PsGetWin32Process(); - if (IS_ATOM(lpClassName)) - DPRINT("NtUserGetClassInfo - %x (%lx)\n", lpClassName, hInstance); - else - DPRINT("NtUserGetClassInfo - %S (%lx)\n", lpClassName, hInstance); + LIST_FOR_EACH(Class, &Process->ClassList, WNDCLASS_OBJECT, ListEntry) + { + if (Class->Atom != Atom) continue; - UserEnterExclusive(); - - if (!ClassReferenceClassByNameOrAtom(&Class, lpClassName, hInstance)) - { - SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST); - RETURN(0); + if (!hInstance || Class->Global || Class->hInstance == hInstance) return Class; } + + return NULL; +} - lpWndClassEx->cbSize = sizeof(WNDCLASSEXW); - lpWndClassEx->style = Class->style; - if (Ansi) - lpWndClassEx->lpfnWndProc = Class->lpfnWndProcA; - else - lpWndClassEx->lpfnWndProc = Class->lpfnWndProcW; - lpWndClassEx->cbClsExtra = Class->cbClsExtra; - lpWndClassEx->cbWndExtra = Class->cbWndExtra; - /* This is not typo, we're really not going to use Class->hInstance here. */ - lpWndClassEx->hInstance = hInstance; - lpWndClassEx->hIcon = Class->hIcon; - lpWndClassEx->hCursor = Class->hCursor; - lpWndClassEx->hbrBackground = Class->hbrBackground; - if (Class->lpszMenuName.MaximumLength) - RtlCopyUnicodeString((PUNICODE_STRING)lpWndClassEx->lpszMenuName, &Class->lpszMenuName); - else - lpWndClassEx->lpszMenuName = Class->lpszMenuName.Buffer; - lpWndClassEx->lpszClassName = lpClassName; - lpWndClassEx->hIconSm = Class->hIconSm; - Atom = Class->Atom; - ObmDereferenceObject(Class); - - RETURN(Atom); - -CLEANUP: - DPRINT("Leave NtUserGetClassInfo, ret=%i\n",_ret_); - UserLeave(); - END_CLEANUP; -} - -ULONG FASTCALL -IntGetClassName(struct _WINDOW_OBJECT *WindowObject, LPWSTR lpClassName, - ULONG nMaxCount) +PWNDCLASS_OBJECT FASTCALL +ClassGetClassByName(LPCWSTR ClassName, HINSTANCE hInstance) { - ULONG Length; - LPWSTR Name; - PWINSTATION_OBJECT WinStaObject; + PWINSTATION_OBJECT WinSta; NTSTATUS Status; + RTL_ATOM Atom; - if(!PsGetWin32Thread()->Desktop) - { - return 0; - } + if (!ClassName || !PsGetWin32Thread()->Desktop) + return FALSE; - WinStaObject = PsGetWin32Thread()->Desktop->WindowStation; + WinSta = PsGetWin32Thread()->Desktop->WindowStation; - Length = 0; - Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable, - WindowObject->Class->Atom, NULL, NULL, - NULL, &Length); - Length += sizeof(WCHAR); - Name = ExAllocatePoolWithTag(PagedPool, Length, TAG_STRING); - Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable, - WindowObject->Class->Atom, NULL, NULL, - Name, &Length); + Status = RtlLookupAtomInAtomTable( + WinSta->AtomTable, + (LPWSTR)ClassName, + &Atom); + if (!NT_SUCCESS(Status)) { - DPRINT("IntGetClassName: RtlQueryAtomInAtomTable failed\n"); - return 0; + DPRINT1("Failed to lookup class atom!\n"); + return FALSE; } - Length /= sizeof(WCHAR); - if (Length > nMaxCount) - { - Length = nMaxCount; - } - wcsncpy(lpClassName, Name, Length); - /* FIXME: Check buffer size before doing this! */ - *(lpClassName + Length) = 0; - ExFreePool(Name); - return Length; + return ClassGetClassByAtom(Atom, hInstance); } -DWORD STDCALL -NtUserGetClassName ( - HWND hWnd, - LPWSTR lpClassName, - ULONG nMaxCount) -{ - PWINDOW_OBJECT Window; - DECLARE_RETURN(DWORD); - UserEnterShared(); - DPRINT("Enter NtUserGetClassName\n"); - - if (!(Window = UserGetWindowObject(hWnd))) - { - RETURN(0); - } - - RETURN( IntGetClassName(Window, lpClassName, nMaxCount)); - -CLEANUP: - DPRINT("Leave NtUserGetClassName, ret=%i\n",_ret_); - UserLeave(); - END_CLEANUP; -} - -DWORD STDCALL -NtUserGetWOWClass(DWORD Unknown0, - DWORD Unknown1) +PWNDCLASS_OBJECT FASTCALL +ClassGetClassByNameOrAtom(LPCWSTR ClassNameOrAtom, HINSTANCE hInstance) { - UNIMPLEMENTED; - return(0); + if (!ClassNameOrAtom) return NULL; + + if (IS_ATOM(ClassNameOrAtom)) + return ClassGetClassByAtom((RTL_ATOM)((ULONG_PTR)ClassNameOrAtom), hInstance); + else + return ClassGetClassByName(ClassNameOrAtom, hInstance); } -PWNDCLASS_OBJECT FASTCALL -IntCreateClass( + +static +BOOL FASTCALL +IntRegisterClass( CONST WNDCLASSEXW *lpwcx, DWORD Flags, WNDPROC wpExtra, PUNICODE_STRING MenuName, RTL_ATOM Atom) { - PWNDCLASS_OBJECT ClassObject; + PWNDCLASS_OBJECT Class; ULONG objectSize; BOOL Global; - Global = (Flags & REGISTERCLASS_SYSTEM) || (lpwcx->style & CS_GLOBALCLASS) ? TRUE : FALSE; + ASSERT(lpwcx); + ASSERT(Atom); [truncated at 1000 lines; 1785 more skipped]
19 years, 3 months
1
0
0
0
← Newer
1
...
13
14
15
16
17
18
19
...
59
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Results per page:
10
25
50
100
200