[ros-diffs] [mjansen] 71261: [NTOSKRNL][NTDLL_APITEST] Fix error returned from NtCreateSection when opening an empty file. CORE-11166

2016-05-05 Thread mjansen
Author: mjansen
Date: Thu May  5 12:06:07 2016
New Revision: 71261

URL: http://svn.reactos.org/svn/reactos?rev=71261&view=rev
Log:
[NTOSKRNL][NTDLL_APITEST] Fix error returned from NtCreateSection when opening 
an empty file. CORE-11166

Modified:
trunk/reactos/ntoskrnl/mm/section.c
trunk/rostests/apitests/ntdll/NtMapViewOfSection.c

Modified: trunk/reactos/ntoskrnl/mm/section.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=71261&r1=71260&r2=71261&view=diff
==
--- trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] Thu May  5 12:06:07 2016
@@ -2993,7 +2993,7 @@
 {
 ObDereferenceObject(Section);
 ObDereferenceObject(FileObject);
-return STATUS_FILE_INVALID;
+return STATUS_MAPPED_FILE_SIZE_ZERO;
 }
 }
 

Modified: trunk/rostests/apitests/ntdll/NtMapViewOfSection.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/NtMapViewOfSection.c?rev=71261&r1=71260&r2=71261&view=diff
==
--- trunk/rostests/apitests/ntdll/NtMapViewOfSection.c  [iso-8859-1] (original)
+++ trunk/rostests/apitests/ntdll/NtMapViewOfSection.c  [iso-8859-1] Thu May  5 
12:06:07 2016
@@ -1351,6 +1351,53 @@
 DeleteFileW(FileName);
 }
 
+static void
+Test_EmptyFile(VOID)
+{
+NTSTATUS Status;
+WCHAR TempPath[MAX_PATH];
+WCHAR FileName[MAX_PATH];
+HANDLE Handle;
+HANDLE SectionHandle;
+ULONG Length;
+
+Length = GetTempPathW(MAX_PATH, TempPath);
+ok(Length != 0, "GetTempPathW failed with %lu\n", GetLastError());
+Length = GetTempFileNameW(TempPath, L"nta", 0, FileName);
+ok(Length != 0, "GetTempFileNameW failed with %lu\n", GetLastError());
+Handle = CreateFileW(FileName,
+ FILE_ALL_ACCESS,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ 0,
+ NULL);
+if (Handle == INVALID_HANDLE_VALUE)
+{
+skip("Failed to create temp file %ls, error %lu\n", FileName, 
GetLastError());
+return;
+}
+
+Status = NtCreateSection(&SectionHandle,
+ STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | 
SECTION_MAP_READ,
+ 0, 0, PAGE_READONLY, SEC_COMMIT, Handle);
+ok_ntstatus(Status, STATUS_MAPPED_FILE_SIZE_ZERO);
+
+if (NT_SUCCESS(Status))
+NtClose(SectionHandle);
+
+Status = NtCreateSection(&SectionHandle,
+ STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | 
SECTION_MAP_READ,
+ 0, 0, PAGE_READONLY, SEC_IMAGE, Handle);
+ok_ntstatus(Status, STATUS_INVALID_FILE_FOR_SECTION);
+
+if (NT_SUCCESS(Status))
+NtClose(SectionHandle);
+
+CloseHandle(Handle);
+DeleteFileW(FileName);
+}
+
 START_TEST(NtMapViewOfSection)
 {
 Test_PageFileSection();
@@ -1358,4 +1405,5 @@
 Test_BasedSection();
 Test_NoLoadSection(FALSE);
 Test_NoLoadSection(TRUE);
+Test_EmptyFile();
 }




[ros-diffs] [mjansen] 71262: fix the build for msvc (2013?) users.

2016-05-05 Thread mjansen
Author: mjansen
Date: Thu May  5 12:43:57 2016
New Revision: 71262

URL: http://svn.reactos.org/svn/reactos?rev=71262&view=rev
Log:
fix the build for msvc (2013?) users.

Modified:
trunk/reactos/drivers/storage/ide/uniata/id_ata.cpp

Modified: trunk/reactos/drivers/storage/ide/uniata/id_ata.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/ide/uniata/id_ata.cpp?rev=71262&r1=71261&r2=71262&view=diff
==
--- trunk/reactos/drivers/storage/ide/uniata/id_ata.cpp [iso-8859-1] (original)
+++ trunk/reactos/drivers/storage/ide/uniata/id_ata.cpp [iso-8859-1] Thu May  5 
12:43:57 2016
@@ -6139,7 +6139,7 @@
 } else { // srb->Cdb[0] == SCSIOP_REQUEST_SENSE)
 
 PSENSE_DATA senseData = (PSENSE_DATA) srb->DataBuffer;
-
+(void)senseData;
 KdPrint3((PRINT_PREFIX "AtapiInterrupt: ATAPI command status 
%#x\n", status));
 if (status == SRB_STATUS_DATA_OVERRUN) {
 // Check to see if we at least get mininum number of bytes




[ros-diffs] [mjansen] 71263: [NTOSKRNL] Fix NtApphelpCacheControl image lookup failure return codes when validating file times. Also silence some debug outputs in the normal usage flow.

2016-05-05 Thread mjansen
Author: mjansen
Date: Thu May  5 14:13:29 2016
New Revision: 71263

URL: http://svn.reactos.org/svn/reactos?rev=71263&view=rev
Log:
[NTOSKRNL] Fix NtApphelpCacheControl image lookup failure return codes when 
validating file times.
Also silence some debug outputs in the normal usage flow.

Modified:
trunk/reactos/ntoskrnl/ps/apphelp.c

Modified: trunk/reactos/ntoskrnl/ps/apphelp.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/apphelp.c?rev=71263&r1=71262&r2=71263&view=diff
==
--- trunk/reactos/ntoskrnl/ps/apphelp.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ps/apphelp.c [iso-8859-1] Thu May  5 14:13:29 2016
@@ -546,14 +546,14 @@
 Entry = RtlLookupElementGenericTableAvl(&ApphelpShimCache, &Lookup);
 if (Entry == NULL)
 {
-DPRINT1("SHIMS: ApphelpCacheLookupEntry: could not find %wZ\n", 
ImageName);
+DPRINT("SHIMS: ApphelpCacheLookupEntry: could not find %wZ\n", 
ImageName);
 goto Cleanup;
 }
 
-DPRINT1("SHIMS: ApphelpCacheLookupEntry: found %wZ\n", ImageName);
+DPRINT("SHIMS: ApphelpCacheLookupEntry: found %wZ\n", ImageName);
 if (ImageHandle == INVALID_HANDLE_VALUE)
 {
-DPRINT1("SHIMS: ApphelpCacheLookupEntry: ok\n");
+DPRINT("SHIMS: ApphelpCacheLookupEntry: ok\n");
 /* just return if we know it, do not query file info */
 Status = STATUS_SUCCESS;
 }
@@ -564,7 +564,7 @@
 Lookup.Persistent.DateTime.QuadPart == 
Entry->Persistent.DateTime.QuadPart &&
 Lookup.Persistent.FileSize.QuadPart == 
Entry->Persistent.FileSize.QuadPart)
 {
-DPRINT1("SHIMS: ApphelpCacheLookupEntry: found & validated\n");
+DPRINT("SHIMS: ApphelpCacheLookupEntry: found & validated\n");
 Status = STATUS_SUCCESS;
 /* move it to the front to keep it alive */
 RemoveEntryList(&Entry->List);
@@ -572,7 +572,8 @@
 }
 else
 {
-DPRINT1("SHIMS: ApphelpCacheLookupEntry: file info mismatch\n");
+DPRINT1("SHIMS: ApphelpCacheLookupEntry: file info mismatch 
(%lx)\n", Status);
+Status = STATUS_NOT_FOUND;
 /* Could not read file info, or it did not match, drop it from the 
cache */
 ApphelpCacheRemoveEntryNolock(Entry);
 }
@@ -642,7 +643,7 @@
  &NodeOrParent, &SearchResult);
 if (Lookup)
 {
-DPRINT1("SHIMS: ApphelpCacheUpdateEntry: Entry already exists, reusing 
it\n");
+DPRINT("SHIMS: ApphelpCacheUpdateEntry: Entry already exists, reusing 
it\n");
 /* Unlink the found item, so we can put it back at the front,
 and copy the earlier obtained file info*/
 RemoveEntryList(&Lookup->List);
@@ -651,7 +652,7 @@
 }
 else
 {
-DPRINT1("SHIMS: ApphelpCacheUpdateEntry: Inserting new Entry\n");
+DPRINT("SHIMS: ApphelpCacheUpdateEntry: Inserting new Entry\n");
 /* Insert a new entry, with its own copy of the ImageName */
 ApphelpDuplicateUnicodeString(&Entry.Persistent.ImageName, ImageName);
 Lookup = RtlInsertElementGenericTableFullAvl(&ApphelpShimCache,
@@ -705,7 +706,7 @@
 PLIST_ENTRY ListEntry;
 PSHIM_CACHE_ENTRY Entry;
 
-DPRINT1("SHIMS: NtApphelpCacheControl( Dumping entries, newset to oldest 
)\n");
+DPRINT1("SHIMS: NtApphelpCacheControl( Dumping entries, newest to oldest 
)\n");
 ApphelpCacheAcquireLock();
 ListEntry = ApphelpShimCacheAge.Flink;
 while (ListEntry != &ApphelpShimCacheAge)
@@ -741,19 +742,19 @@
 switch (Service)
 {
 case ApphelpCacheServiceLookup:
-DPRINT1("SHIMS: NtApphelpCacheControl( ApphelpCacheServiceLookup 
)\n");
+DPRINT("SHIMS: NtApphelpCacheControl( ApphelpCacheServiceLookup 
)\n");
 Status = ApphelpValidateData(ServiceData, &ImageName, &Handle);
 if (NT_SUCCESS(Status))
 Status = ApphelpCacheLookupEntry(&ImageName, Handle);
 break;
 case ApphelpCacheServiceRemove:
-DPRINT1("SHIMS: NtApphelpCacheControl( ApphelpCacheServiceRemove 
)\n");
+DPRINT("SHIMS: NtApphelpCacheControl( ApphelpCacheServiceRemove 
)\n");
 Status = ApphelpValidateData(ServiceData, &ImageName, &Handle);
 if (NT_SUCCESS(Status))
 Status = ApphelpCacheRemoveEntry(&ImageName);
 break;
 case ApphelpCacheServiceUpdate:
-DPRINT1("SHIMS: NtApphelpCacheControl( ApphelpCacheServiceUpdate 
)\n");
+DPRINT("SHIMS: NtApphelpCacheControl( ApphelpCacheServiceUpdate 
)\n");
 Status = ApphelpCacheAccessCheck();
 if (NT_SUCCESS(Status))
 {




[ros-diffs] [pschweitzer] 71264: [NTOSKRNL_VISTA] Implement FsRtlValidateReparsePointBuffer(). CORE-11172

2016-05-05 Thread pschweitzer
Author: pschweitzer
Date: Thu May  5 16:58:16 2016
New Revision: 71264

URL: http://svn.reactos.org/svn/reactos?rev=71264&view=rev
Log:
[NTOSKRNL_VISTA]
Implement FsRtlValidateReparsePointBuffer().

CORE-11172

Modified:
trunk/reactos/sdk/lib/drivers/ntoskrnl_vista/fsrtl.c

Modified: trunk/reactos/sdk/lib/drivers/ntoskrnl_vista/fsrtl.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/drivers/ntoskrnl_vista/fsrtl.c?rev=71264&r1=71263&r2=71264&view=diff
==
--- trunk/reactos/sdk/lib/drivers/ntoskrnl_vista/fsrtl.c[iso-8859-1] 
(original)
+++ trunk/reactos/sdk/lib/drivers/ntoskrnl_vista/fsrtl.c[iso-8859-1] 
Thu May  5 16:58:16 2016
@@ -119,3 +119,124 @@
 
 return STATUS_SUCCESS;
 }
+
+FORCEINLINE
+BOOLEAN
+IsNullGuid(IN PGUID Guid)
+{
+if (Guid->Data1 == 0 && Guid->Data2 == 0 && Guid->Data3 == 0 &&
+((ULONG *)Guid->Data4)[0] == 0 && ((ULONG *)Guid->Data4)[1] == 0)
+{
+return TRUE;
+}
+
+return FALSE;
+}
+
+FORCEINLINE
+BOOLEAN
+IsEven(IN USHORT Digit)
+{
+return ((Digit & 1) != 1);
+}
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+FsRtlValidateReparsePointBuffer(IN ULONG BufferLength,
+IN PREPARSE_DATA_BUFFER ReparseBuffer)
+{
+USHORT DataLength;
+ULONG ReparseTag;
+PREPARSE_GUID_DATA_BUFFER GuidBuffer;
+
+/* Validate data size range */
+if (BufferLength < REPARSE_DATA_BUFFER_HEADER_SIZE || BufferLength > 
MAXIMUM_REPARSE_DATA_BUFFER_SIZE)
+{
+return STATUS_IO_REPARSE_DATA_INVALID;
+}
+
+GuidBuffer = (PREPARSE_GUID_DATA_BUFFER)ReparseBuffer;
+DataLength = ReparseBuffer->ReparseDataLength;
+ReparseTag = ReparseBuffer->ReparseTag;
+
+/* Validate size consistency */
+if (DataLength + REPARSE_DATA_BUFFER_HEADER_SIZE != BufferLength && 
DataLength + REPARSE_GUID_DATA_BUFFER_HEADER_SIZE != BufferLength)
+{
+return STATUS_IO_REPARSE_DATA_INVALID;
+}
+
+/* REPARSE_DATA_BUFFER is reserved for MS tags */
+if (DataLength + REPARSE_DATA_BUFFER_HEADER_SIZE == BufferLength && 
!IsReparseTagMicrosoft(ReparseTag))
+{
+return STATUS_IO_REPARSE_DATA_INVALID;
+}
+
+/* If that a GUID data buffer, its GUID cannot be null, and it cannot 
contain a MS tag */
+if (DataLength + REPARSE_GUID_DATA_BUFFER_HEADER_SIZE == BufferLength && 
((!IsReparseTagMicrosoft(ReparseTag)
+&& IsNullGuid(&GuidBuffer->ReparseGuid)) || (ReparseTag == 
IO_REPARSE_TAG_MOUNT_POINT || ReparseTag == IO_REPARSE_TAG_SYMLINK)))
+{
+return STATUS_IO_REPARSE_DATA_INVALID;
+}
+
+/* Check the data for MS non reserved tags */
+if (!(ReparseTag & 0xFFF) && ReparseTag != 
IO_REPARSE_TAG_RESERVED_ZERO && ReparseTag != IO_REPARSE_TAG_RESERVED_ONE)
+{
+/* If that's a mount point, validate the MountPointReparseBuffer 
branch */
+if (ReparseTag == IO_REPARSE_TAG_MOUNT_POINT)
+{
+/* We need information */
+if (DataLength >= REPARSE_DATA_BUFFER_HEADER_SIZE)
+{
+/* Substitue must be the first in row */
+if 
(!ReparseBuffer->MountPointReparseBuffer.SubstituteNameOffset)
+{
+/* Substitude must be null-terminated */
+if (ReparseBuffer->MountPointReparseBuffer.PrintNameOffset 
== ReparseBuffer->MountPointReparseBuffer.SubstituteNameLength + 
sizeof(UNICODE_NULL))
+{
+/* There must just be the Offset/Length fields + 
buffer + 2 null chars */
+if (DataLength == 
ReparseBuffer->MountPointReparseBuffer.PrintNameLength + 
ReparseBuffer->MountPointReparseBuffer.SubstituteNameLength + 
(FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer.PathBuffer) - 
FIELD_OFFSET(REPARSE_DATA_BUFFER, 
MountPointReparseBuffer.SubstituteNameOffset)) + 2 * sizeof(UNICODE_NULL))
+{
+return STATUS_SUCCESS;
+}
+}
+}
+}
+}
+else
+{
+#define FIELDS_SIZE (FIELD_OFFSET(REPARSE_DATA_BUFFER, 
SymbolicLinkReparseBuffer.PathBuffer) - FIELD_OFFSET(REPARSE_DATA_BUFFER, 
SymbolicLinkReparseBuffer.SubstituteNameOffset))
+
+/* If that's not a symlink, accept the MS tag as it */
+if (ReparseTag != IO_REPARSE_TAG_SYMLINK)
+{
+return STATUS_SUCCESS;
+}
+
+/* We need information */
+if (DataLength >= FIELDS_SIZE)
+{
+/* Validate lengths */
+if 
(ReparseBuffer->SymbolicLinkReparseBuffer.SubstituteNameLength && 
ReparseBuffer->SymbolicLinkReparseBuffer.PrintNameLength)
+{
+/* Validate unicode strings */
+if 
(IsEven(ReparseBuffer->SymbolicLinkReparseBuffer.SubstituteNameLength

[ros-diffs] [pschweitzer] 71265: [BTRFS] Upgrade the WinBtrfs to release 0.4. CORE-11172 #resolve #Committed in r71265

2016-05-05 Thread pschweitzer
Author: pschweitzer
Date: Thu May  5 17:26:47 2016
New Revision: 71265

URL: http://svn.reactos.org/svn/reactos?rev=71265&view=rev
Log:
[BTRFS]
Upgrade the WinBtrfs to release 0.4.

CORE-11172 #resolve #Committed in r71265

Added:
trunk/reactos/drivers/filesystems/btrfs/extent-tree.c   (with props)
trunk/reactos/drivers/filesystems/btrfs/free-space.c   (with props)
trunk/reactos/drivers/filesystems/btrfs/pnp.c   (with props)
Removed:
trunk/reactos/drivers/filesystems/btrfs/loader.c
Modified:
trunk/reactos/drivers/filesystems/btrfs/CMakeLists.txt
trunk/reactos/drivers/filesystems/btrfs/btrfs.c
trunk/reactos/drivers/filesystems/btrfs/btrfs.h
trunk/reactos/drivers/filesystems/btrfs/btrfs.rc
trunk/reactos/drivers/filesystems/btrfs/btrfs_drv.h
trunk/reactos/drivers/filesystems/btrfs/btrfsioctl.h
trunk/reactos/drivers/filesystems/btrfs/create.c
trunk/reactos/drivers/filesystems/btrfs/dirctrl.c
trunk/reactos/drivers/filesystems/btrfs/fileinfo.c
trunk/reactos/drivers/filesystems/btrfs/flushthread.c
trunk/reactos/drivers/filesystems/btrfs/fsctl.c
trunk/reactos/drivers/filesystems/btrfs/read.c
trunk/reactos/drivers/filesystems/btrfs/reparse.c
trunk/reactos/drivers/filesystems/btrfs/security.c
trunk/reactos/drivers/filesystems/btrfs/treefuncs.c
trunk/reactos/drivers/filesystems/btrfs/write.c

[This mail would be too long, it was shortened to contain the URLs only.]

Modified: trunk/reactos/drivers/filesystems/btrfs/CMakeLists.txt
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/CMakeLists.txt?rev=71265&r1=71264&r2=71265&view=diff

Modified: trunk/reactos/drivers/filesystems/btrfs/btrfs.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/btrfs.c?rev=71265&r1=71264&r2=71265&view=diff

Modified: trunk/reactos/drivers/filesystems/btrfs/btrfs.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/btrfs.h?rev=71265&r1=71264&r2=71265&view=diff

Modified: trunk/reactos/drivers/filesystems/btrfs/btrfs.rc
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/btrfs.rc?rev=71265&r1=71264&r2=71265&view=diff

Modified: trunk/reactos/drivers/filesystems/btrfs/btrfs_drv.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/btrfs_drv.h?rev=71265&r1=71264&r2=71265&view=diff

Modified: trunk/reactos/drivers/filesystems/btrfs/btrfsioctl.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/btrfsioctl.h?rev=71265&r1=71264&r2=71265&view=diff

Modified: trunk/reactos/drivers/filesystems/btrfs/create.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/create.c?rev=71265&r1=71264&r2=71265&view=diff

Modified: trunk/reactos/drivers/filesystems/btrfs/dirctrl.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/dirctrl.c?rev=71265&r1=71264&r2=71265&view=diff

Added: trunk/reactos/drivers/filesystems/btrfs/extent-tree.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/extent-tree.c?rev=71265

Modified: trunk/reactos/drivers/filesystems/btrfs/fileinfo.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/fileinfo.c?rev=71265&r1=71264&r2=71265&view=diff

Modified: trunk/reactos/drivers/filesystems/btrfs/flushthread.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/flushthread.c?rev=71265&r1=71264&r2=71265&view=diff

Added: trunk/reactos/drivers/filesystems/btrfs/free-space.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/free-space.c?rev=71265

Modified: trunk/reactos/drivers/filesystems/btrfs/fsctl.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/fsctl.c?rev=71265&r1=71264&r2=71265&view=diff

Removed: trunk/reactos/drivers/filesystems/btrfs/loader.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/loader.c?rev=71264

Added: trunk/reactos/drivers/filesystems/btrfs/pnp.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/pnp.c?rev=71265

Modified: trunk/reactos/drivers/filesystems/btrfs/read.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/read.c?rev=71265&r1=71264&r2=71265&view=diff

Modified: trunk/reactos/drivers/filesystems/btrfs/reparse.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/reparse.c?rev=71265&r1=71264&r2=71265&view=diff

Modified: trunk/reactos/drivers/filesystems/btrfs/security.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/security.c?rev=71265&r1=71264&r2=71265&view=diff

Modified: trunk/reactos/drivers/filesystems/btrfs/treefuncs.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/btrfs/treefuncs.c?rev=71265&r1=71264&r2=71265&view=diff

Modified: trunk/reactos/drivers/fil