Sorry the patch was wrong. I have forgot to change the function name.
Thanks Daniel Zimmermann
________________________________________________________________________ Check Out the new free AIM(R) Mail -- 2 GB of storage and industry-leading spam and email virus protection.
=================================================================== --- file.c (revision 28448) +++ 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 28448) +++ 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) + 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 */