[ros-dev] IoCheckEaBufferValidity

netzimme at aim.com netzimme at aim.com
Tue Aug 21 23:28:32 CEST 2007


Hello


  Have wrote a test program for IoCheckEaBufferValidity that i used to 
investigate
  the function. I attached the file and patch with comments and the 
right coding style (i hope).
  Perhaps there is a better place to put it but i don't see a special 
mailing list to put this contents (new function).
  More information on this function on 
http://msdn2.microsoft.com/en-us/library/ms795740.aspx
  The only different to the Win-version is when the parameter PULONG 
ErrorOffset = NULL and
  the result is not STATUS_OK Win will bug check. I think this i not 
really good.

 Thank
 Daniel Zimmermann


 -----Original Message-----
 From: aleksey at reactos.org
 To: ros-dev at reactos.org
 Sent: Tue, 21 Aug 2007 9:47 AM
 Subject: Re: [ros-dev] IoCheckEaBufferValidity

 Hello,
 please provide your real name (this is a must for every commit), and
 also how to test it under Windows (maybe you wrote some test app for
 this - it would be useful too).


 WBR,
 Aleksey Bragin.

 On Aug 21, 2007, at 3:39 AM, netzimme at aim.com wrote:

 > Hallo
 >
 > Have a patch that implemented the function IoCheckEaBufferValidity
 > in ntoskrnl\io\iomgr\util.c.
 > Tested with Windows 2000 and Vista Ultimate 64 Bit.
 > Perhaps some one can comit it for me.
 >
 > Thanks
 > dz
 >

 _______________________________________________
 Ros-dev mailing list
 Ros-dev at reactos.org
 http://www.reactos.org/mailman/listinfo/ros-dev


________________________________________________________________________
Check Out the new free AIM(R) Mail -- 2 GB of storage and 
industry-leading spam and email virus protection.
-------------- next part --------------
===================================================================
--- file.c	(revision 28447)
+++ file.c	(working copy)
@@ -1632,6 +1632,7 @@
              IN ULONG Options)
 {
     KPROCESSOR_MODE AccessMode;
+    ULONG EaErrorOffset;
     HANDLE LocalHandle = 0;
     LARGE_INTEGER SafeAllocationSize;
     PVOID SystemEaBuffer = NULL;
@@ -1732,10 +1733,10 @@
             /* Validate the buffer */
             Status = IoCheckEaBufferValidity(SystemEaBuffer,
                                              EaLength,
-                                             NULL);
+                                             &EaErrorOffset);
             if (!NT_SUCCESS(Status))
             {
-                /* FIXME: Fail once function is implemented */
+               DPRINT1("FIXME: IoCheckEaBufferValidity failed with Status: %lx\n",Status);
             }
         }
     }
Index: util.c
===================================================================
--- util.c	(revision 28447)
+++ util.c	(working copy)
@@ -129,19 +129,80 @@
     return STATUS_SUCCESS;
 }
 
+
 /*
- * @unimplemented
+ * @implemented
  */
 NTSTATUS
 NTAPI
-IoCheckEaBufferValidity(IN PFILE_FULL_EA_INFORMATION EaBuffer,
-                        IN ULONG EaLength,
-                        OUT PULONG ErrorOffset)
+IoCheckEaBufferValidityROS(IN PFILE_FULL_EA_INFORMATION EaBuffer,
+                           IN ULONG EaLength,
+                           OUT PULONG ErrorOffset)
 {
-    UNIMPLEMENTED;
-    return STATUS_NOT_IMPLEMENTED;
+   PFILE_FULL_EA_INFORMATION EaBufferEnd;
+   ULONG NextEaBufferOffset;
+   UINT IntEaLength;
+
+   /* Lenght of the rest. Inital equal to EaLength */ 
+   IntEaLength = EaLength;
+   /* Inital EaBuffer equal to EaBuffer */ 
+   EaBufferEnd = EaBuffer;
+
+   /* The rest length of the buffer */
+   /* 8 = sizeof(ULONG) + sizeof(UCHAR) + sizeof(UCHAR) + sizeof(USHORT) */
+   while (IntEaLength >= 8)
+   {
+      /* rest of buffer must greater then the sizeof(FILE_FULL_EA_INFORMATION) + buffer */ 
+      NextEaBufferOffset = EaBufferEnd->EaNameLength+EaBufferEnd->EaValueLength + 9;
+      if (IntEaLength >= NextEaBufferOffset)
+      {
+         /* is the EaBufferName terminated with zero? */
+         if (EaBufferEnd->EaName[EaBufferEnd->EaNameLength]==0)
+         {
+            /* more EaBuffers ahead */
+            if (EaBufferEnd->NextEntryOffset == 0)
+            {
+               /* test the rest buffersize */
+               IntEaLength = IntEaLength - NextEaBufferOffset;
+               if (IntEaLength>=0)
+               {
+                  return STATUS_SUCCESS;
+               }
+            }
+            else
+            { 
+               /* 
+                  From the MSDN (http://msdn2.microsoft.com/en-us/library/ms795740.aspx). 
+                  For all entries except the last, the value of NextEntryOffset must be greater 
+                  than zero and must fall on a ULONG boundary. 
+               */
+               NextEaBufferOffset = ((NextEaBufferOffset + 3) & 0xFFFFFFFC);
+               if ((EaBufferEnd->NextEntryOffset == NextEaBufferOffset) && (EaBufferEnd->NextEntryOffset>0))
+               {
+                  /* rest of buffer must be greater then the next offset */
+                  IntEaLength = IntEaLength - EaBufferEnd->NextEntryOffset;
+                  if (IntEaLength>=0)
+                  {
+                     EaBufferEnd = (PFILE_FULL_EA_INFORMATION)((ULONG_PTR)EaBufferEnd + EaBufferEnd->NextEntryOffset);
+                     continue;
+                  }
+               }
+            }
+         }
+      }
+      break;
+   }
+
+   if (ErrorOffset != NULL)
+   {
+      /* calculate the error offset. Or in */
+      *ErrorOffset = (ULONG)((ULONG_PTR)EaBufferEnd - (ULONG_PTR)EaBuffer);
+   }
+   
+   return STATUS_EA_LIST_INCONSISTENT;
 }
 
+
 /*
  * @unimplemented
  */


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: IoEaTest.cpp
Url: http://www.reactos.org/pipermail/ros-dev/attachments/20070821/3f44ef10/attachment.pl 


More information about the Ros-dev mailing list