- Fix default buffer size for user-mode RtlQueryRegistryValues queries, this removes...
authorAleksey Bragin <aleksey@reactos.org>
Tue, 11 Dec 2007 21:52:12 +0000 (21:52 +0000)
committerAleksey Bragin <aleksey@reactos.org>
Tue, 11 Dec 2007 21:52:12 +0000 (21:52 +0000)
- Remove ARC tree dump since this code has now been proven to work.
- Sync PointerFree with WINE, removing the unhandled data type=warning.

svn path=/trunk/; revision=31172

reactos/dll/ntdll/rtl/libsupp.c
reactos/dll/win32/rpcrt4/ndr_marshall.c
reactos/lib/rtl/registry.c
reactos/ntoskrnl/config/cmconfig.c
reactos/ntoskrnl/rtl/libsupp.c

index 58a57df..ae0b29c 100644 (file)
@@ -13,6 +13,8 @@
 #define NDEBUG
 #include <debug.h>
 
+SIZE_T RtlpAllocDeallocQueryBufferSize = PAGE_SIZE;
+
 /* FUNCTIONS ***************************************************************/
 
 /*
index c0c6876..9dcb8ca 100644 (file)
@@ -904,36 +904,24 @@ void WINAPI PointerFree(PMIDL_STUB_MESSAGE pStubMsg,
   pFormat += 2;
   if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
   else desc = pFormat + *(const SHORT*)pFormat;
-  if (attr & RPC_FC_P_DEREF) {
-    Pointer = *(unsigned char**)Pointer;
-    TRACE("deref => %p\n", Pointer);
-  }
 
   if (!Pointer) return;
 
+  if (attr & RPC_FC_P_DEREF) {
+      Pointer = *(unsigned char**)Pointer;
+      TRACE("deref => %p\n", Pointer);
+  }
+  
   m = NdrFreer[*desc & NDR_TABLE_MASK];
   if (m) m(pStubMsg, Pointer, desc);
 
-  /* hmm... is this sensible?
-   * perhaps we should check if the memory comes from NdrAllocate,
+  /* we should check if the memory comes from NdrAllocate,
    * and deallocate only if so - checking if the pointer is between
-   * BufferStart and BufferEnd is probably no good since the buffer
+   * BufferStart and BufferEnd will not always work since the buffer
    * may be reallocated when the server wants to marshal the reply */
-  switch (*desc) {
-  case RPC_FC_BOGUS_STRUCT:
-  case RPC_FC_BOGUS_ARRAY:
-  case RPC_FC_USER_MARSHAL:
-    break;
-  default:
-    FIXME("unhandled data type=%02x\n", *desc);
-  case RPC_FC_CARRAY:
-  case RPC_FC_C_CSTRING:
-  case RPC_FC_C_WSTRING:
-    if (pStubMsg->ReuseBuffer) goto notfree;
-    break;
-  case RPC_FC_IP:
-    goto notfree;
-  }
+  if (Pointer >= (unsigned char *)pStubMsg->RpcMsg->Buffer ||
+      Pointer <= (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
+      goto notfree;
 
   if (attr & RPC_FC_P_ONSTACK) {
     TRACE("not freeing stack ptr %p\n", Pointer);
index 377fdf3..86fe418 100644 (file)
@@ -15,6 +15,8 @@
 
 #define TAG_RTLREGISTRY TAG('R', 'q', 'r', 'v')
 
+extern SIZE_T RtlpAllocDeallocQueryBufferSize;
+
 /* DATA **********************************************************************/
 
 PCWSTR RtlpRegPaths[RTL_REGISTRY_MAXIMUM] =
@@ -970,7 +972,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
     NTSTATUS Status;
     PKEY_VALUE_FULL_INFORMATION KeyValueInfo = NULL;
     HANDLE KeyHandle, CurrentKey;
-    SIZE_T BufferSize = 128, InfoSize;
+    SIZE_T BufferSize, InfoSize;
     UNICODE_STRING KeyPath, KeyValueName;
     OBJECT_ATTRIBUTES ObjectAttributes;
     ULONG i, Value;
@@ -985,6 +987,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
                          (RelativeTo & RTL_REGISTRY_HANDLE) ? NULL : Path);
 
     /* Allocate a query buffer */
+    BufferSize = RtlpAllocDeallocQueryBufferSize;
     KeyValueInfo = RtlpAllocDeallocQueryBuffer(&BufferSize, NULL, 0, &Status);
     if (!KeyValueInfo)
     {
index aeb68a8..5bfe768 100644 (file)
@@ -207,37 +207,10 @@ CmpSetupConfigurationTree(IN PCONFIGURATION_COMPONENT_DATA CurrentEntry,
     ULONG Interface = InterfaceType, Bus = BusNumber, i;\r
     NTSTATUS Status;\r
     HANDLE NewHandle;\r
-    static ULONG t, tabLevel;\r
-    PCHAR InterfaceStrings[MaximumInterfaceType + 1] =\r
-    {\r
-        "Internal",\r
-        "Isa",\r
-        "Eisa",\r
-        "MicroChannel",\r
-        "TurboChannel",\r
-        "PCIBus",\r
-        "VMEBus",\r
-        "NuBus",\r
-        "PCMCIABus",\r
-        "CBus",\r
-        "MPIBus",\r
-        "MPSABus",\r
-        "ProcessorInternal",\r
-        "InternalPowerBus",\r
-        "PNPISABus",\r
-        "PNPBus",\r
-        "Unknown"\r
-    };\r
 \r
     /* Loop each entry */\r
     while (CurrentEntry)\r
     {\r
-        for (t = 0; t < tabLevel; t++) DbgPrint("\t");\r
-        DbgPrint("Dumping node @ 0x%p\n", CurrentEntry);\r
-        for (t = 0; t < tabLevel; t++) DbgPrint("\t");\r
-        DbgPrint("Parent @ 0x%p Sibling @ 0x%p Child @ 0x%p\n",\r
-                 CurrentEntry->Parent, CurrentEntry->Sibling, CurrentEntry->Child);\r
-\r
         /* Check if this is an adapter */\r
         Component = &CurrentEntry->ComponentEntry;\r
         if ((Component->Class == AdapterClass) &&\r
@@ -303,35 +276,7 @@ CmpSetupConfigurationTree(IN PCONFIGURATION_COMPONENT_DATA CurrentEntry,
         }\r
         \r
         /* Dump information on the component */\r
-        for (t = 0; t < tabLevel; t++) DbgPrint("\t");\r
-        DbgPrint("Component Type: %wZ\n", &CmTypeName[Component->Type]);\r
-        for (t = 0; t < tabLevel; t++) DbgPrint("\t");\r
-        DbgPrint("Class: %wZ\n", &CmClassName[Component->Class]);\r
-        if (Component->Class != SystemClass)\r
-        {\r
-            for (t = 0; t < tabLevel; t++) DbgPrint("\t");\r
-            DbgPrint("Device Index: %lx\n", DeviceIndexTable[Component->Type]);    \r
-        }\r
-        for (t = 0; t < tabLevel; t++) DbgPrint("\t");\r
-        DbgPrint("Component Information:\n");\r
-        for (t = 0; t < tabLevel; t++) DbgPrint("\t");\r
-        DbgPrint("\tFlags: %lx\n", Component->Flags);\r
-        for (t = 0; t < tabLevel; t++) DbgPrint("\t");\r
-        DbgPrint("\tVersion: %lx\n", Component->Version);\r
-        for (t = 0; t < tabLevel; t++) DbgPrint("\t");\r
-        DbgPrint("\tAffinity: %lx\n", Component->AffinityMask);\r
-        if (Component->IdentifierLength)\r
-        {\r
-            for (t = 0; t < tabLevel; t++) DbgPrint("\t");\r
-            DbgPrint("Identifier: %S\n", Component->Identifier);\r
-        }\r
-        for (t = 0; t < tabLevel; t++) DbgPrint("\t");\r
-        DbgPrint("Configuration Data: %p\n", CurrentEntry->ConfigurationData);    \r
-        for (t = 0; t < tabLevel; t++) DbgPrint("\t");\r
-        DbgPrint("Interface Type: %s Bus Number: %d\n\n",\r
-                 InterfaceStrings[Interface],\r
-                 Bus);\r
-        \r
+\r
         /* Setup the hardware node */\r
         Status = CmpInitializeRegistryNode(CurrentEntry,\r
                                            ParentHandle,\r
@@ -345,12 +290,10 @@ CmpSetupConfigurationTree(IN PCONFIGURATION_COMPONENT_DATA CurrentEntry,
         if (CurrentEntry->Child)\r
         {\r
             /* Recurse child */\r
-            tabLevel++;\r
             Status = CmpSetupConfigurationTree(CurrentEntry->Child,\r
                                                NewHandle,\r
                                                Interface,\r
                                                Bus);\r
-            tabLevel--;\r
             if (!NT_SUCCESS(Status))\r
             {\r
                 /* Fail */\r
@@ -433,8 +376,6 @@ CmpInitializeHardwareConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
     if (LoaderBlock->ConfigurationRoot)\r
     {\r
         /* Setup the configuration tree */\r
-        DPRINT1("ARC Hardware Tree Received @ 0x%p. Dumping HW Info:\n\n",\r
-                LoaderBlock->ConfigurationRoot);\r
         Status = CmpSetupConfigurationTree(LoaderBlock->ConfigurationRoot,\r
                                            KeyHandle,\r
                                            -1,\r
@@ -455,3 +396,4 @@ CmpInitializeHardwareConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 \r
 \r
 \r
+\r
index bf9adb0..a229835 100644 (file)
@@ -22,6 +22,7 @@ typedef struct _RTL_RANGE_ENTRY
 } RTL_RANGE_ENTRY, *PRTL_RANGE_ENTRY;
 
 PAGED_LOOKASIDE_LIST RtlpRangeListEntryLookasideList;
+SIZE_T RtlpAllocDeallocQueryBufferSize = 128;
 
 /* FUNCTIONS *****************************************************************/