[ros-diffs] [reactos] 01/01: [CDROM] Forcibly declare our CD devices to the MountMgr

2019-11-19 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0917815efaece8672bfcf0aa52cec6cecf692233

commit 0917815efaece8672bfcf0aa52cec6cecf692233
Author: Pierre Schweitzer 
AuthorDate: Tue Nov 19 19:04:55 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Tue Nov 19 19:05:23 2019 +0100

[CDROM] Forcibly declare our CD devices to the MountMgr
---
 drivers/storage/class/cdrom/cdrom.c   | 126 ++
 drivers/storage/class/cdrom/precomp.h |   2 +
 2 files changed, 128 insertions(+)

diff --git a/drivers/storage/class/cdrom/cdrom.c 
b/drivers/storage/class/cdrom/cdrom.c
index a1c477ef9e5..220eb1fcf4f 100644
--- a/drivers/storage/class/cdrom/cdrom.c
+++ b/drivers/storage/class/cdrom/cdrom.c
@@ -731,6 +731,130 @@ Return Value:
 RtlFreeUnicodeString(&unicodeString);
 }
 
+
+VOID
+NTAPI
+ReportToMountMgr(
+IN PDEVICE_OBJECT CdDeviceObject
+)
+
+/*++
+
+Routine Description:
+
+This routine reports the creation of a cdrom device object to the
+MountMgr to fake PnP.
+
+Arguments:
+
+CdDeviceObject - Pointer to the created cdrom device.
+
+Return Value:
+
+VOID
+
+--*/
+{
+NTSTATUS  status;
+UNICODE_STRINGmountMgrDevice;
+PDEVICE_OBJECTdeviceObject;
+PFILE_OBJECT  fileObject;
+PMOUNTMGR_TARGET_NAME mountTarget;
+ULONG cdLen;
+PDEVICE_EXTENSION deviceExtension;
+PIRP  irp;
+KEVENTevent;
+IO_STATUS_BLOCK   ioStatus;
+
+//
+// First, get MountMgr DeviceObject.
+//
+
+RtlInitUnicodeString(&mountMgrDevice, MOUNTMGR_DEVICE_NAME);
+status = IoGetDeviceObjectPointer(&mountMgrDevice, FILE_READ_ATTRIBUTES,
+  &fileObject, &deviceObject);
+
+if (!NT_SUCCESS(status)) {
+
+DebugPrint((1,
+   "ReportToMountMgr: Can't get MountMgr pointers %lx\n",
+   status));
+
+return;
+}
+
+deviceExtension = CdDeviceObject->DeviceExtension;
+cdLen = deviceExtension->DeviceName.Length;
+
+//
+// Allocate input buffer to report our partition device.
+//
+
+mountTarget = ExAllocatePool(NonPagedPool,
+ sizeof(MOUNTMGR_TARGET_NAME) + cdLen);
+
+if (!mountTarget) {
+
+DebugPrint((1,
+   "ReportToMountMgr: Allocation of mountTarget failed\n"));
+
+ObDereferenceObject(fileObject);
+return;
+}
+
+mountTarget->DeviceNameLength = cdLen;
+RtlCopyMemory(mountTarget->DeviceName, deviceExtension->DeviceName.Buffer, 
cdLen);
+
+KeInitializeEvent(&event, NotificationEvent, FALSE);
+
+//
+// Build the IRP used to communicate with the MountMgr.
+//
+
+irp = 
IoBuildDeviceIoControlRequest(IOCTL_MOUNTMGR_VOLUME_ARRIVAL_NOTIFICATION,
+deviceObject,
+mountTarget,
+sizeof(MOUNTMGR_TARGET_NAME) + cdLen,
+NULL,
+0,
+FALSE,
+&event,
+&ioStatus);
+
+if (!irp) {
+
+DebugPrint((1,
+"ReportToMountMgr: Allocation of irp failed\n"));
+
+ExFreePool(mountTarget);
+ObDereferenceObject(fileObject);
+return;
+}
+
+//
+// Call the MountMgr.
+//
+
+status = IoCallDriver(deviceObject, irp);
+
+if (status == STATUS_PENDING) {
+KeWaitForSingleObject(&event, Suspended, KernelMode, FALSE, NULL);
+status = ioStatus.Status;
+}
+
+//
+// We're done.
+//
+
+DPRINT1("Reported to the MountMgr: %lx\n", status);
+
+ExFreePool(mountTarget);
+ObDereferenceObject(fileObject);
+
+return;
+}
+
+
 NTSTATUS
 NTAPI
 CreateCdRomDeviceObject(
@@ -1323,6 +1447,8 @@ Return Value:
 
 ExFreePool(buffer);
 
+ReportToMountMgr(deviceObject);
+
 //
 // Start the timer now regardless of if Autorun is enabled.
 // The timer must run forever since IoStopTimer faults.
diff --git a/drivers/storage/class/cdrom/precomp.h 
b/drivers/storage/class/cdrom/precomp.h
index 25e00ea68ef..586ddfa59fc 100644
--- a/drivers/storage/class/cdrom/precomp.h
+++ b/drivers/storage/class/cdrom/precomp.h
@@ -3,5 +3,7 @@
 
 #include 
 #include 
+#include 
+#include 
 
 #endif /* _CDROM_PCH_ */



[ros-diffs] [reactos] 01/02: [SDK] Implement std::vector.data()

2019-11-18 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=114556b1c97859f81cf73881c5f2a5ad0de1c2df

commit 114556b1c97859f81cf73881c5f2a5ad0de1c2df
Author: Pierre Schweitzer 
AuthorDate: Wed Nov 13 22:56:16 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Nov 18 23:50:33 2019 +0100

[SDK] Implement std::vector.data()
---
 sdk/include/c++/stlport/stl/_vector.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sdk/include/c++/stlport/stl/_vector.h 
b/sdk/include/c++/stlport/stl/_vector.h
index ed243ef3749..4eb9d755278 100644
--- a/sdk/include/c++/stlport/stl/_vector.h
+++ b/sdk/include/c++/stlport/stl/_vector.h
@@ -210,6 +210,9 @@ public:
   reference at(size_type __n) { _M_range_check(__n); return (*this)[__n]; }
   const_reference at(size_type __n) const { _M_range_check(__n); return 
(*this)[__n]; }
 
+  _Tp* data()   { return this->_M_start; }
+  const _Tp* data() const   { return this->_M_start; }
+
 #if !defined (_STLP_DONT_SUP_DFLT_PARAM)
   explicit vector(const allocator_type& __a = allocator_type())
 #else



[ros-diffs] [reactos] 02/02: [SHELLBTRFS] Use again .data() method of vector class

2019-11-18 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=30986920687b2e35a0bc280a71da85f8743d216c

commit 30986920687b2e35a0bc280a71da85f8743d216c
Author: Pierre Schweitzer 
AuthorDate: Thu Nov 14 15:01:55 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Nov 18 23:50:33 2019 +0100

[SHELLBTRFS] Use again .data() method of vector class

This reverts commit 45a643a136eedf8b39d22f5add94fd372320fdee.
This reverts commit a3c13c624f4a115f99560990f065dd94e4526304.
This reverts commit 1725ddfd8f06bbff1b853c93be35f2b0ab672a01.
---
 dll/shellext/shellbtrfs/contextmenu.cpp| 20 --
 dll/shellext/shellbtrfs/mountmgr_local.cpp | 44 --
 2 files changed, 64 deletions(-)

diff --git a/dll/shellext/shellbtrfs/contextmenu.cpp 
b/dll/shellext/shellbtrfs/contextmenu.cpp
index bf4b5e92c09..3fbca1cb7c2 100755
--- a/dll/shellext/shellbtrfs/contextmenu.cpp
+++ b/dll/shellext/shellbtrfs/contextmenu.cpp
@@ -833,25 +833,15 @@ void BtrfsContextMenu::reflink_copy(HWND hwnd, const 
WCHAR* fn, const WCHAR* dir
 streambufsize += 0x1000;
 streambuf.resize(streambufsize);
 
-#ifndef __REACTOS__
 memset(streambuf.data(), 0, streambufsize);
 
 Status = NtQueryInformationFile(source, &iosb, 
streambuf.data(), streambufsize, FileStreamInformation);
-#else
-memset(&streambuf[0], 0, streambufsize);
-
-Status = NtQueryInformationFile(source, &iosb, &streambuf[0], 
streambufsize, FileStreamInformation);
-#endif
 } while (Status == STATUS_BUFFER_OVERFLOW);
 
 if (!NT_SUCCESS(Status))
 throw ntstatus_error(Status);
 
-#ifndef __REACTOS__
 auto fsi = 
reinterpret_cast(streambuf.data());
-#else
-auto fsi = 
reinterpret_cast(&streambuf[0]);
-#endif
 
 while (true) {
 if (fsi->StreamNameLength > 0) {
@@ -1535,25 +1525,15 @@ static void reflink_copy2(const wstring& srcfn, const 
wstring& destdir, const ws
 streambufsize += 0x1000;
 streambuf.resize(streambufsize);
 
-#ifndef __REACTOS__
 memset(streambuf.data(), 0, streambufsize);
 
 Status = NtQueryInformationFile(source, &iosb, 
streambuf.data(), streambufsize, FileStreamInformation);
-#else
-memset(&streambuf[0], 0, streambufsize);
-
-Status = NtQueryInformationFile(source, &iosb, &streambuf[0], 
streambufsize, FileStreamInformation);
-#endif
 } while (Status == STATUS_BUFFER_OVERFLOW);
 
 if (!NT_SUCCESS(Status))
 throw ntstatus_error(Status);
 
-#ifndef __REACTOS__
 auto fsi = 
reinterpret_cast(streambuf.data());
-#else
-auto fsi = 
reinterpret_cast(&streambuf[0]);
-#endif
 
 while (true) {
 if (fsi->StreamNameLength > 0) {
diff --git a/dll/shellext/shellbtrfs/mountmgr_local.cpp 
b/dll/shellext/shellbtrfs/mountmgr_local.cpp
index 45a47e68e15..164cf4d4804 100644
--- a/dll/shellext/shellbtrfs/mountmgr_local.cpp
+++ b/dll/shellext/shellbtrfs/mountmgr_local.cpp
@@ -33,11 +33,7 @@ void mountmgr::create_point(const wstring_view& symlink, 
const wstring_view& dev
 IO_STATUS_BLOCK iosb;
 
 vector buf(sizeof(MOUNTMGR_CREATE_POINT_INPUT) + 
((symlink.length() + device.length()) * sizeof(WCHAR)));
-#ifndef __REACTOS__
 auto mcpi = reinterpret_cast(buf.data());
-#else
-auto mcpi = reinterpret_cast(&buf[0]);
-#endif
 
 mcpi->SymbolicLinkNameOffset = sizeof(MOUNTMGR_CREATE_POINT_INPUT);
 mcpi->SymbolicLinkNameLength = (USHORT)(symlink.length() * sizeof(WCHAR));
@@ -48,11 +44,7 @@ void mountmgr::create_point(const wstring_view& symlink, 
const wstring_view& dev
 memcpy((uint8_t*)mcpi + mcpi->DeviceNameOffset, device.data(), 
device.length() * sizeof(WCHAR));
 
 Status = NtDeviceIoControlFile(h, nullptr, nullptr, nullptr, &iosb, 
IOCTL_MOUNTMGR_CREATE_POINT,
-#ifndef __REACTOS__
buf.data(), (ULONG)buf.size(), nullptr, 0);
-#else
-   &buf[0], (ULONG)buf.size(), nullptr, 0);
-#endif
 
 if (!NT_SUCCESS(Status))
 throw ntstatus_error(Status);
@@ -63,11 +55,7 @@ void mountmgr::delete_points(const wstring_view& symlink, 
const wstring_view& un
 IO_STATUS_BLOCK iosb;
 
 vector buf(sizeof(MOUNTMGR_MOUNT_POINT) + ((symlink.length() + 
unique_id.length() + device_name.length()) * sizeof(WCHAR)));
-#ifndef __REACTOS__
 auto mmp = reinterpret_cast(buf.data());
-#else
-auto mmp = reinterpret_cast(&buf[0]);
-#endif
 
 memset(mmp, 0, sizeof(MOUNTMGR_MOUNT_POINT));
 
@@ -100,28 +88,16 @@ void mountmgr::delete_points(const wstring_view& symlink, 
const wstring_view& un
 }
 
 vector buf2(sizeof(MOUNTMGR_MOUNT_POINTS));
-#ifndef __

[ros-diffs] [reactos] 01/01: [SHELLBTRFS] Properly fix AppVeyor build This reverts bb6fece

2019-11-12 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=986f6a4b24745211b49ea74c4317b9661473676b

commit 986f6a4b24745211b49ea74c4317b9661473676b
Author: Pierre Schweitzer 
AuthorDate: Wed Nov 13 08:22:13 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Wed Nov 13 08:22:13 2019 +0100

[SHELLBTRFS] Properly fix AppVeyor build
This reverts bb6fece
---
 dll/shellext/shellbtrfs/devices.cpp | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/dll/shellext/shellbtrfs/devices.cpp 
b/dll/shellext/shellbtrfs/devices.cpp
index f044151721e..dfa10647256 100755
--- a/dll/shellext/shellbtrfs/devices.cpp
+++ b/dll/shellext/shellbtrfs/devices.cpp
@@ -237,16 +237,22 @@ static void find_devices(HWND hwnd, const GUID* guid, 
const mountmgr& mm, vector
 free(dli);
 } else {
 try {
-std::vector v;
-v = mm.query_points(L"", L"", 
wstring_view(path.Buffer, path.Length / sizeof(WCHAR)));
+auto v = mm.query_points(L"", L"", 
wstring_view(path.Buffer, path.Length / sizeof(WCHAR)));
 
-for (size_t i = 0; i < v.size(); ++i)
-{
-const mountmgr_point& p = v[i];
+#ifndef __REACTOS__
+for (const auto& p : v) {
 if (p.symlink.length() == 14 && 
p.symlink.substr(0, dosdevices.length()) == dosdevices && p.symlink[13] == ':') 
{
+#else
+for(auto p = v.begin(); p != v.end(); ++p) {
+if ((*p).symlink.length() == 14 && 
(*p).symlink.substr(0, dosdevices.length()) == dosdevices && (*p).symlink[13] 
== ':') {
+#endif
 WCHAR dr[3];
 
+#ifndef __REACTOS__
 dr[0] = p.symlink[12];
+#else
+dr[0] = (*p).symlink[12];
+#endif
 dr[1] = ':';
 dr[2] = 0;
 



[ros-diffs] [reactos] 01/01: [BTRFS] Fix MSVC build

2019-11-12 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cc5c307b8ed889289febb8d190b003005259b4f5

commit cc5c307b8ed889289febb8d190b003005259b4f5
Author: Pierre Schweitzer 
AuthorDate: Wed Nov 13 00:03:22 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Wed Nov 13 00:03:22 2019 +0100

[BTRFS] Fix MSVC build
---
 drivers/filesystems/btrfs/btrfs_drv.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/filesystems/btrfs/btrfs_drv.h 
b/drivers/filesystems/btrfs/btrfs_drv.h
index e24e4980244..24307d93810 100644
--- a/drivers/filesystems/btrfs/btrfs_drv.h
+++ b/drivers/filesystems/btrfs/btrfs_drv.h
@@ -1588,6 +1588,7 @@ void __stdcall check_system_root(PDRIVER_OBJECT 
DriverObject, PVOID Context, ULO
 // based on function in sys/sysmacros.h
 #define makedev(major, minor) (((minor) & 0xFF) | (((major) & 0xFFF) << 8) | 
(((uint64_t)((minor) & ~0xFF)) << 12) | (((uint64_t)((major) & ~0xFFF)) << 32))
 
+#ifndef __REACTOS__
 // not in mingw yet
 #ifndef _MSC_VER
 typedef struct {
@@ -1608,6 +1609,22 @@ typedef struct {
 #else
 #define FSRTL_ADVANCED_FCB_HEADER_NEW FSRTL_ADVANCED_FCB_HEADER
 #endif
+#else
+typedef struct {
+FSRTL_COMMON_FCB_HEADER DUMMYSTRUCTNAME;
+PFAST_MUTEX FastMutex;
+LIST_ENTRY FilterContexts;
+EX_PUSH_LOCK PushLock;
+PVOID* FileContextSupportPointer;
+union {
+OPLOCK Oplock;
+PVOID ReservedForRemote;
+};
+PVOID ReservedContext;
+} FSRTL_ADVANCED_FCB_HEADER_NEW;
+
+#define FSRTL_FCB_HEADER_V2 2
+#endif
 
 static __inline POPLOCK fcb_oplock(fcb* fcb) {
 if (fcb->Header.Version >= FSRTL_FCB_HEADER_V2)



[ros-diffs] [reactos] 01/01: [SHELLBTRFS] Addendum to 1725ddf

2019-11-12 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=45a643a136eedf8b39d22f5add94fd372320fdee

commit 45a643a136eedf8b39d22f5add94fd372320fdee
Author: Pierre Schweitzer 
AuthorDate: Tue Nov 12 23:46:53 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Tue Nov 12 23:46:53 2019 +0100

[SHELLBTRFS] Addendum to 1725ddf
---
 dll/shellext/shellbtrfs/contextmenu.cpp | 20 
 1 file changed, 20 insertions(+)

diff --git a/dll/shellext/shellbtrfs/contextmenu.cpp 
b/dll/shellext/shellbtrfs/contextmenu.cpp
index 3fbca1cb7c2..bf4b5e92c09 100755
--- a/dll/shellext/shellbtrfs/contextmenu.cpp
+++ b/dll/shellext/shellbtrfs/contextmenu.cpp
@@ -833,15 +833,25 @@ void BtrfsContextMenu::reflink_copy(HWND hwnd, const 
WCHAR* fn, const WCHAR* dir
 streambufsize += 0x1000;
 streambuf.resize(streambufsize);
 
+#ifndef __REACTOS__
 memset(streambuf.data(), 0, streambufsize);
 
 Status = NtQueryInformationFile(source, &iosb, 
streambuf.data(), streambufsize, FileStreamInformation);
+#else
+memset(&streambuf[0], 0, streambufsize);
+
+Status = NtQueryInformationFile(source, &iosb, &streambuf[0], 
streambufsize, FileStreamInformation);
+#endif
 } while (Status == STATUS_BUFFER_OVERFLOW);
 
 if (!NT_SUCCESS(Status))
 throw ntstatus_error(Status);
 
+#ifndef __REACTOS__
 auto fsi = 
reinterpret_cast(streambuf.data());
+#else
+auto fsi = 
reinterpret_cast(&streambuf[0]);
+#endif
 
 while (true) {
 if (fsi->StreamNameLength > 0) {
@@ -1525,15 +1535,25 @@ static void reflink_copy2(const wstring& srcfn, const 
wstring& destdir, const ws
 streambufsize += 0x1000;
 streambuf.resize(streambufsize);
 
+#ifndef __REACTOS__
 memset(streambuf.data(), 0, streambufsize);
 
 Status = NtQueryInformationFile(source, &iosb, 
streambuf.data(), streambufsize, FileStreamInformation);
+#else
+memset(&streambuf[0], 0, streambufsize);
+
+Status = NtQueryInformationFile(source, &iosb, &streambuf[0], 
streambufsize, FileStreamInformation);
+#endif
 } while (Status == STATUS_BUFFER_OVERFLOW);
 
 if (!NT_SUCCESS(Status))
 throw ntstatus_error(Status);
 
+#ifndef __REACTOS__
 auto fsi = 
reinterpret_cast(streambuf.data());
+#else
+auto fsi = 
reinterpret_cast(&streambuf[0]);
+#endif
 
 while (true) {
 if (fsi->StreamNameLength > 0) {



[ros-diffs] [reactos] 01/01: [SHELLBTRFS] Replace emplace_back by something less efficient if not avaible

2019-11-12 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5f779048d30bb7fc44e855289c3680706687ad66

commit 5f779048d30bb7fc44e855289c3680706687ad66
Author: Pierre Schweitzer 
AuthorDate: Tue Nov 12 23:29:08 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Tue Nov 12 23:29:08 2019 +0100

[SHELLBTRFS] Replace emplace_back by something less efficient if not avaible
---
 dll/shellext/shellbtrfs/mountmgr_local.cpp | 4 
 1 file changed, 4 insertions(+)

diff --git a/dll/shellext/shellbtrfs/mountmgr_local.cpp 
b/dll/shellext/shellbtrfs/mountmgr_local.cpp
index 061962369ff..45a47e68e15 100644
--- a/dll/shellext/shellbtrfs/mountmgr_local.cpp
+++ b/dll/shellext/shellbtrfs/mountmgr_local.cpp
@@ -217,7 +217,11 @@ vector mountmgr::query_points(const 
wstring_view& symlink, const
 if (mmps->MountPoints[i].DeviceNameLength)
 mpdn = wstring_view((WCHAR*)((uint8_t*)mmps + 
mmps->MountPoints[i].DeviceNameOffset), mmps->MountPoints[i].DeviceNameLength / 
sizeof(WCHAR));
 
+#ifndef __REACTOS__
 v.emplace_back(mpsl, mpuid, mpdn);
+#else
+v.push_back(mountmgr_point(mpsl, mpuid, mpdn));
+#endif
 }
 
 return v;



[ros-diffs] [reactos] 01/01: [SHELLBTRFS] Addendum to 1725ddf

2019-11-12 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a3c13c624f4a115f99560990f065dd94e4526304

commit a3c13c624f4a115f99560990f065dd94e4526304
Author: Pierre Schweitzer 
AuthorDate: Tue Nov 12 23:12:48 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Tue Nov 12 23:12:48 2019 +0100

[SHELLBTRFS] Addendum to 1725ddf
---
 dll/shellext/shellbtrfs/mountmgr_local.cpp | 20 
 1 file changed, 20 insertions(+)

diff --git a/dll/shellext/shellbtrfs/mountmgr_local.cpp 
b/dll/shellext/shellbtrfs/mountmgr_local.cpp
index ee7901e1f2a..061962369ff 100644
--- a/dll/shellext/shellbtrfs/mountmgr_local.cpp
+++ b/dll/shellext/shellbtrfs/mountmgr_local.cpp
@@ -48,7 +48,11 @@ void mountmgr::create_point(const wstring_view& symlink, 
const wstring_view& dev
 memcpy((uint8_t*)mcpi + mcpi->DeviceNameOffset, device.data(), 
device.length() * sizeof(WCHAR));
 
 Status = NtDeviceIoControlFile(h, nullptr, nullptr, nullptr, &iosb, 
IOCTL_MOUNTMGR_CREATE_POINT,
+#ifndef __REACTOS__
buf.data(), (ULONG)buf.size(), nullptr, 0);
+#else
+   &buf[0], (ULONG)buf.size(), nullptr, 0);
+#endif
 
 if (!NT_SUCCESS(Status))
 throw ntstatus_error(Status);
@@ -103,13 +107,21 @@ void mountmgr::delete_points(const wstring_view& symlink, 
const wstring_view& un
 #endif
 
 Status = NtDeviceIoControlFile(h, nullptr, nullptr, nullptr, &iosb, 
IOCTL_MOUNTMGR_DELETE_POINTS,
+#ifndef __REACTOS__
buf.data(), (ULONG)buf.size(), buf2.data(), 
(ULONG)buf2.size());
+#else
+   &buf[0], (ULONG)buf.size(), &buf2[0], 
(ULONG)buf2.size());
+#endif
 
 if (Status == STATUS_BUFFER_OVERFLOW) {
 buf2.resize(mmps->Size);
 
 Status = NtDeviceIoControlFile(h, nullptr, nullptr, nullptr, &iosb, 
IOCTL_MOUNTMGR_DELETE_POINTS,
+#ifndef __REACTOS__
buf.data(), (ULONG)buf.size(), 
buf2.data(), (ULONG)buf2.size());
+#else
+   &buf[0], (ULONG)buf.size(), &buf2[0], 
(ULONG)buf2.size());
+#endif
 }
 
 if (!NT_SUCCESS(Status))
@@ -166,7 +178,11 @@ vector mountmgr::query_points(const 
wstring_view& symlink, const
 #endif
 
 Status = NtDeviceIoControlFile(h, nullptr, nullptr, nullptr, &iosb, 
IOCTL_MOUNTMGR_QUERY_POINTS,
+#ifndef __REACTOS__
buf.data(), (ULONG)buf.size(), buf2.data(), 
(ULONG)buf2.size());
+#else
+   &buf[0], (ULONG)buf.size(), &buf2[0], 
(ULONG)buf2.size());
+#endif
 
 if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW)
 throw ntstatus_error(Status);
@@ -179,7 +195,11 @@ vector mountmgr::query_points(const 
wstring_view& symlink, const
 #endif
 
 Status = NtDeviceIoControlFile(h, nullptr, nullptr, nullptr, &iosb, 
IOCTL_MOUNTMGR_QUERY_POINTS,
+#ifndef __REACTOS__
buf.data(), (ULONG)buf.size(), buf2.data(), 
(ULONG)buf2.size());
+#else
+   &buf[0], (ULONG)buf.size(), &buf2[0], 
(ULONG)buf2.size());
+#endif
 
 if (!NT_SUCCESS(Status))
 throw ntstatus_error(Status);



[ros-diffs] [reactos] 01/01: [SHELLBTRFS] Fix build? (Not sure why it works locally...)

2019-11-12 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a837184300041ea328a187f44488f45252aa49f6

commit a837184300041ea328a187f44488f45252aa49f6
Author: Pierre Schweitzer 
AuthorDate: Tue Nov 12 21:52:16 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Tue Nov 12 21:52:16 2019 +0100

[SHELLBTRFS] Fix build?
(Not sure why it works locally...)
---
 dll/shellext/shellbtrfs/shellext.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/dll/shellext/shellbtrfs/shellext.h 
b/dll/shellext/shellbtrfs/shellext.h
index af7776cb5a3..cfa09779213 100755
--- a/dll/shellext/shellbtrfs/shellext.h
+++ b/dll/shellext/shellbtrfs/shellext.h
@@ -42,6 +42,7 @@
 #include 
 #include 
 #include 
+#include 
 #endif
 #include 
 #ifdef __REACTOS__



[ros-diffs] [reactos] 01/01: [DOC] Addendum to aed50d7

2019-11-12 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4eefc85c9020f923daead4610ac33a03e76f9c48

commit 4eefc85c9020f923daead4610ac33a03e76f9c48
Author: Pierre Schweitzer 
AuthorDate: Tue Nov 12 21:46:36 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Tue Nov 12 21:46:36 2019 +0100

[DOC] Addendum to aed50d7
---
 media/doc/README.FSD | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/media/doc/README.FSD b/media/doc/README.FSD
index ed4c991c0c3..859b183edcc 100644
--- a/media/doc/README.FSD
+++ b/media/doc/README.FSD
@@ -4,7 +4,7 @@
 The following FSD are shared with: https://github.com/maharmstone/btrfs.
 
 reactos/drivers/filesystems/btrfs   # Synced to 1.5
-reactos/dll/shellext/shellbtrfs # Synced to 1.1
+reactos/dll/shellext/shellbtrfs # Synced to 1.5
 reactos/sdk/lib/fslib/btrfslib  # Synced to 1.5
 
 The following FSD are shared with: http://www.ext2fsd.com/



[ros-diffs] [reactos] 02/02: [UBTRFS] Upgrade to 1.5

2019-11-12 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=86ee9b0cc20186afe9e2f1c27e24c0e8da206c66

commit 86ee9b0cc20186afe9e2f1c27e24c0e8da206c66
Author: Pierre Schweitzer 
AuthorDate: Tue Nov 12 19:34:14 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Tue Nov 12 19:35:43 2019 +0100

[UBTRFS] Upgrade to 1.5

CORE-16494
---
 dll/win32/ubtrfs/ubtrfs.rc|   8 +--
 media/doc/README.FSD  |   2 +-
 sdk/lib/fslib/btrfslib/btrfslib.c | 108 ++
 3 files changed, 91 insertions(+), 27 deletions(-)

diff --git a/dll/win32/ubtrfs/ubtrfs.rc b/dll/win32/ubtrfs/ubtrfs.rc
index 1292452a5cd..1720597df5b 100644
--- a/dll/win32/ubtrfs/ubtrfs.rc
+++ b/dll/win32/ubtrfs/ubtrfs.rc
@@ -51,8 +51,8 @@ END
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,4,0,0
- PRODUCTVERSION 1,4,0,0
+ FILEVERSION 1,5,0,0
+ PRODUCTVERSION 1,5,0,0
  FILEFLAGSMASK 0x17L
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -68,12 +68,12 @@ BEGIN
 BLOCK "080904b0"
 BEGIN
 VALUE "FileDescription", "Btrfs utility DLL"
-VALUE "FileVersion", "1.4"
+VALUE "FileVersion", "1.5"
 VALUE "InternalName", "ubtrfs"
 VALUE "LegalCopyright", "Copyright (c) Mark Harmstone 2016-19"
 VALUE "OriginalFilename", "ubtrfs.dll"
 VALUE "ProductName", "WinBtrfs"
-VALUE "ProductVersion", "1.4"
+VALUE "ProductVersion", "1.5"
 END
 END
 BLOCK "VarFileInfo"
diff --git a/media/doc/README.FSD b/media/doc/README.FSD
index 9ce6e3a7d29..ed4c991c0c3 100644
--- a/media/doc/README.FSD
+++ b/media/doc/README.FSD
@@ -5,7 +5,7 @@ The following FSD are shared with: 
https://github.com/maharmstone/btrfs.
 
 reactos/drivers/filesystems/btrfs   # Synced to 1.5
 reactos/dll/shellext/shellbtrfs # Synced to 1.1
-reactos/sdk/lib/fslib/btrfslib  # Synced to 1.4
+reactos/sdk/lib/fslib/btrfslib  # Synced to 1.5
 
 The following FSD are shared with: http://www.ext2fsd.com/
 
diff --git a/sdk/lib/fslib/btrfslib/btrfslib.c 
b/sdk/lib/fslib/btrfslib/btrfslib.c
index ec9fe387037..254873089df 100644
--- a/sdk/lib/fslib/btrfslib/btrfslib.c
+++ b/sdk/lib/fslib/btrfslib/btrfslib.c
@@ -803,7 +803,7 @@ static NTSTATUS write_superblocks(HANDLE h, btrfs_dev* dev, 
btrfs_root* chunk_ro
 sb->chunk_tree_addr = chunk_root->header.address;
 sb->total_bytes = dev->dev_item.num_bytes;
 sb->bytes_used = bytes_used;
-sb->root_dir_objectid = 6;
+sb->root_dir_objectid = BTRFS_ROOT_TREEDIR;
 sb->num_devices = 1;
 sb->sector_size = sector_size;
 sb->node_size = node_size;
@@ -836,14 +836,14 @@ static NTSTATUS write_superblocks(HANDLE h, btrfs_dev* 
dev, btrfs_root* chunk_ro
 }
 
 #ifndef __REACTOS__
-utf8len = WideCharToMultiByte(CP_UTF8, 0, label->Buffer, 
label->Length, NULL, 0, NULL, NULL);
+utf8len = WideCharToMultiByte(CP_UTF8, 0, label->Buffer, label->Length 
/ sizeof(WCHAR), NULL, 0, NULL, NULL);
 
 if (utf8len == 0 || utf8len > MAX_LABEL_SIZE) {
 free(sb);
 return STATUS_INVALID_VOLUME_LABEL;
 }
 
-if (WideCharToMultiByte(CP_UTF8, 0, label->Buffer, label->Length, 
sb->label, utf8len, NULL, NULL) == 0) {
+if (WideCharToMultiByte(CP_UTF8, 0, label->Buffer, label->Length / 
sizeof(WCHAR), sb->label, utf8len, NULL, NULL) == 0) {
 free(sb);
 return STATUS_INVALID_VOLUME_LABEL;
 }
@@ -929,9 +929,29 @@ GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
 }
 #endif
 
+static void add_inode_ref(btrfs_root* r, uint64_t inode, uint64_t parent, 
uint64_t index, const char* name) {
+uint16_t name_len = (uint16_t)strlen(name);
+#ifndef __REACTOS__
+INODE_REF* ir = malloc(offsetof(INODE_REF, name[0]) + name_len);
+#else
+INODE_REF* ir = RtlAllocateHeap(RtlGetProcessHeap(), 0, 
offsetof(INODE_REF, name[0]) + name_len);
+#endif
+
+ir->index = 0;
+ir->n = name_len;
+memcpy(ir->name, name, name_len);
+
+add_item(r, inode, TYPE_INODE_REF, parent, ir, 
(uint16_t)offsetof(INODE_REF, name[0]) + ir->n);
+
+#ifndef __REACTOS__
+free(ir);
+#else
+RtlFreeHeap(RtlGetProcessHeap(), 0, ir);
+#endif
+}
+
 static void init_fs_tree(btrfs_root* r, uint32_t node_size) {
 INODE_ITEM ii;
-INODE_REF* ir;
 FILETIME filetime;
 LARGE_INTEGER time;
 
@@ -951,24 +971,7 @@ static void init_fs_tree(btrfs_root* r, uint32_t 
node_size) {
 
 add_item(r, SUBVOL_ROOT_INODE, TYPE_INODE_ITEM, 0, &ii, 
sizeof(INODE_ITEM));
 
-#ifndef __REACTOS__
-ir = malloc(sizeof(INODE_REF) - 1 + 2);
-#else
-ir = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(INODE_R

[ros-diffs] [reactos] 02/02: [NTOSKRNL] Properly check for Ft volumes

2019-11-11 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=324285f0b9a7726cf2c00aa49cd262f1f4f70ec0

commit 324285f0b9a7726cf2c00aa49cd262f1f4f70ec0
Author: Pierre Schweitzer 
AuthorDate: Mon Nov 11 21:20:58 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Nov 11 21:20:58 2019 +0100

[NTOSKRNL] Properly check for Ft volumes

This fixes a regression introduced in 5ab1cfc which
was causing Unix (BtrFS, ExtX, and so on) volumes not
to be assigned a drive letter assigned anymore. And
thus, they were no longer mounted and presented to the
users.

CORE-16499
---
 ntoskrnl/fstub/disksup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ntoskrnl/fstub/disksup.c b/ntoskrnl/fstub/disksup.c
index 0b81bc561dd..3198481fb5d 100644
--- a/ntoskrnl/fstub/disksup.c
+++ b/ntoskrnl/fstub/disksup.c
@@ -277,7 +277,7 @@ HalpQueryPartitionType(IN PUNICODE_STRING DeviceName,
 }
 
 /* Check if that's a FT volume */
-if (PartitionInfo.Mbr.PartitionType & PARTITION_NTFT)
+if (IsFTPartition(PartitionInfo.Mbr.PartitionType))
 {
 *PartitionType = FtPartition;
 return STATUS_SUCCESS;



[ros-diffs] [reactos] 01/02: [SDK] Properly define IsFTPartition so that it doesn't match Unix partition type

2019-11-11 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0a0e6a9f07c1127888d7c5c533b61e79caad3dd1

commit 0a0e6a9f07c1127888d7c5c533b61e79caad3dd1
Author: Pierre Schweitzer 
AuthorDate: Mon Nov 11 21:18:13 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Nov 11 21:18:13 2019 +0100

[SDK] Properly define IsFTPartition so that it doesn't match Unix partition 
type

CORE-16499
---
 sdk/include/psdk/ntdddisk.h | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/sdk/include/psdk/ntdddisk.h b/sdk/include/psdk/ntdddisk.h
index 13b8e0e9995..7c7cc1dd600 100644
--- a/sdk/include/psdk/ntdddisk.h
+++ b/sdk/include/psdk/ntdddisk.h
@@ -239,8 +239,13 @@ extern "C" {
 #endif
 
 #define IsFTPartition( PartitionType ) \
-  (((PartitionType) & PARTITION_NTFT) && \
-  IsRecognizedPartition(PartitionType))
+  (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == 
PARTITION_FAT_12)) || \
+  (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == 
PARTITION_HUGE)) || \
+  (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == 
PARTITION_IFS)) || \
+  (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == 
PARTITION_FAT32)) || \
+  (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == 
PARTITION_FAT32_XINT13)) || \
+  (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == 
PARTITION_XINT13))
+
 
 #define IsContainerPartition(PartitionType) \
   (((PartitionType) == PARTITION_EXTENDED) || \



[ros-diffs] [reactos] 01/01: [CLASS2] Drop the drive letter hack

2019-11-11 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=887200703ccd580b694929e961357b0f55f1f24d

commit 887200703ccd580b694929e961357b0f55f1f24d
Author: Pierre Schweitzer 
AuthorDate: Mon Nov 11 18:18:12 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Nov 11 18:18:32 2019 +0100

[CLASS2] Drop the drive letter hack
---
 drivers/storage/class/class2/class2.c | 329 +-
 1 file changed, 7 insertions(+), 322 deletions(-)

diff --git a/drivers/storage/class/class2/class2.c 
b/drivers/storage/class/class2/class2.c
index bf67de960fd..5639f072949 100644
--- a/drivers/storage/class/class2/class2.c
+++ b/drivers/storage/class/class2/class2.c
@@ -13,10 +13,6 @@
 #include 
 #include 
 
-/* Part of the drive letter hack */
-#include 
-#include 
-
 //#define NDEBUG
 #include 
 
@@ -135,315 +131,28 @@ DriverEntry(
 return STATUS_SUCCESS;
 }
 
-/* The following hack to assign drive letters with a non-PnP storage stack */
-
-typedef struct _CLASS_DEVICE_INFO {
-  ULONG Signature;
-  ULONG DeviceType;
-  ULONG Partitions;
-  ULONG DeviceNumber;
-  ULONG DriveNumber;
-  PDEVICE_OBJECT LowerDevice;
-} CLASS_DEVICE_INFO, *PCLASS_DEVICE_INFO;
-
-typedef struct _CLASS_DRIVER_EXTENSION {
-  ULONG PortNumber;
-  UNICODE_STRING RegistryPath;
-  CLASS_INIT_DATA InitializationData;
-} CLASS_DRIVER_EXTENSION, *PCLASS_DRIVER_EXTENSION;
-
-VOID
-NTAPI
-ScsiClassRemoveDriveLetter(PCLASS_DEVICE_INFO DeviceInfo)
-{
-WCHAR Buffer1[100];
-UNICODE_STRING DriveLetterU;
-ULONG Index;
-
-DriveLetterU.Buffer = Buffer1;
-DriveLetterU.MaximumLength = sizeof(Buffer1);
-
-/* Delete the symbolic link to PhysicalDriveX */
-DriveLetterU.Length = swprintf(DriveLetterU.Buffer, 
L"\\??\\PhysicalDrive%d", DeviceInfo->DriveNumber) * sizeof(WCHAR);
-IoDeleteSymbolicLink(&DriveLetterU);
-
-DbgPrint("HACK: Deleted symbolic link %wZ\n", &DriveLetterU);
-
-for (Index = 0; Index < sizeof(ULONG) * 8; Index++)
-{
-if (DeviceInfo->Partitions & (1 << Index))
-{
-DriveLetterU.Length = swprintf(DriveLetterU.Buffer, L"\\??\\%C:", 
('C' + Index)) * sizeof(WCHAR);
-IoDeleteSymbolicLink(&DriveLetterU);
-DbgPrint("HACK: Deleted symbolic link %wZ\n", &DriveLetterU);
-}
-}
-}
-
-NTSTATUS
-NTAPI
-ScsiClassAssignDriveLetter(PCLASS_DEVICE_INFO DeviceInfo)
-{
-WCHAR Buffer1[100];
-WCHAR Buffer2[100];
-UNICODE_STRING DriveLetterU, PartitionU;
-NTSTATUS Status;
-ULONG Index, PartitionNumber, DeviceNumber, DriveNumber;
-OBJECT_ATTRIBUTES ObjectAttributes;
-IO_STATUS_BLOCK Iosb;
-HANDLE PartitionHandle;
-
-/* We assume this device does not current have a drive letter */
-
-Index = 0;
-DeviceNumber = 0;
-DriveNumber = 0;
-PartitionNumber = 1;
-DriveLetterU.Buffer = Buffer1;
-DriveLetterU.MaximumLength = sizeof(Buffer1);
-PartitionU.Buffer = Buffer2;
-PartitionU.MaximumLength = sizeof(Buffer2);
-
-/* Determine the correct disk number */
-do
-{
-/* Check that the disk exists */
-if (DeviceInfo->DeviceType == FILE_DEVICE_DISK)
-{
-PartitionU.Length = swprintf(PartitionU.Buffer, 
L"\\Device\\HardDisk%d\\Partition0", DeviceNumber) * sizeof(WCHAR);
-}
-else if (DeviceInfo->DeviceType == FILE_DEVICE_CD_ROM)
-{
-PartitionU.Length = swprintf(PartitionU.Buffer, 
L"\\Device\\CdRom%d", DeviceNumber) * sizeof(WCHAR);
-}
-
-InitializeObjectAttributes(&ObjectAttributes,
-   &PartitionU,
-   OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
-   NULL,
-   NULL);
-Status = ZwOpenFile(&PartitionHandle,
-FILE_READ_ATTRIBUTES,
-&ObjectAttributes,
-&Iosb,
-0,
-0);
-if (!NT_SUCCESS(Status))
-{
-/* Return the last one that worked */
-DeviceNumber--;
-}
-else
-{
-ZwClose(PartitionHandle);
-DeviceNumber++;
-}
-} while (Status == STATUS_SUCCESS);
-
-/* Determine the correct drive number */
-do
-{
-/* Check that the drive exists */
-if (DeviceInfo->DeviceType == FILE_DEVICE_DISK)
-{
-PartitionU.Length = swprintf(PartitionU.Buffer, 
L"\\??\\PhysicalDrive%d", DriveNumber) * sizeof(WCHAR);
-}
-else if (DeviceInfo->DeviceType == FILE_DEVICE_CD_ROM)
-{
-PartitionU.Length = swprintf(PartitionU.Buffer, L"\\??\\%C:", ('C' 
+ DriveNumber)) * sizeof(WCHAR);
-}
-Init

[ros-diffs] [reactos] 01/01: [SHELL32] Update French translation

2019-11-09 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=15a703503eb7d5076b42d2137f36171cde64452f

commit 15a703503eb7d5076b42d2137f36171cde64452f
Author: Pierre Schweitzer 
AuthorDate: Sat Nov 9 10:19:10 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Nov 9 10:19:10 2019 +0100

[SHELL32] Update French translation

CORE-12562
---
 dll/win32/shell32/lang/fr-FR.rc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/dll/win32/shell32/lang/fr-FR.rc b/dll/win32/shell32/lang/fr-FR.rc
index f93ce816bb6..b28d8770a58 100644
--- a/dll/win32/shell32/lang/fr-FR.rc
+++ b/dll/win32/shell32/lang/fr-FR.rc
@@ -814,8 +814,8 @@ BEGIN
 IDS_PERSONAL "Mes documents"
 IDS_FAVORITES "Favoris"
 IDS_STARTUP "Menu Démarrer\\Programmes\\Démarrage"
-IDS_RECENT "Recent"
-IDS_SENDTO "Se&nd To"
+IDS_RECENT "Récent"
+IDS_SENDTO "Envoyer vers"
 IDS_STARTMENU "Menu Démarrer"
 IDS_MYMUSIC "Ma musique"
 IDS_MYVIDEO "Mes vidéos"
@@ -872,7 +872,7 @@ BEGIN
 IDS_CANTEJECTMEDIA "Impossible d'éjecter le média (code d'erreur : %lu)."
 IDS_CANTSHOWPROPERTIES "Impossible de montrer les propriétés (code 
d'erreur : %lu)."
 IDS_CANTDISCONNECT "Impossible de déconnecter (code d'erreur : %lu)."
-IDS_NONE "(None)"
+IDS_NONE "(aucun)"
 
 /* Friendly File Type Names */
 IDS_DIRECTORY "Dossier"



[ros-diffs] [reactos] 01/01: [FLOPPY] Make floppy drives letters being handled by the MountMgr

2019-10-27 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6889cff5b578296d956e5a4a0e9c8c0e46d328cc

commit 6889cff5b578296d956e5a4a0e9c8c0e46d328cc
Author: Pierre Schweitzer 
AuthorDate: Sun Oct 27 11:35:23 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Oct 27 11:35:23 2019 +0100

[FLOPPY] Make floppy drives letters being handled by the MountMgr

This involves many changes/fixes in the floppy driver:
- Stop creating ourselves our DOS device, it's up to the MountMgr or to the 
kernel;
- Report each new floppy drive to the MountMgr (this is a hack for now);
- As a consequence, stop storing the symlink name into the DRIVE_INFO 
structure;
- Store the device name instead;
- On IOCTL_MOUNTDEV_QUERY_DEVICE_NAME, don't return DOS device, but device 
name;
- On IOCTL_MOUNTDEV_QUERY_DEVICE_NAME, properly return if buffer is way too 
small;
- Hackplement IOCTL_MOUNTDEV_QUERY_UNIQUE_ID so that it returns device name.
---
 drivers/storage/floppy/floppy.c | 134 
 drivers/storage/floppy/floppy.h |   2 +-
 drivers/storage/floppy/ioctl.c  |  40 ++--
 3 files changed, 142 insertions(+), 34 deletions(-)

diff --git a/drivers/storage/floppy/floppy.c b/drivers/storage/floppy/floppy.c
index 4234b0f8bb8..b67c6096872 100644
--- a/drivers/storage/floppy/floppy.c
+++ b/drivers/storage/floppy/floppy.c
@@ -406,9 +406,6 @@ Unload(PDRIVER_OBJECT DriverObject)
 {
 UNICODE_STRING Link;
 
-RtlInitUnicodeString(&Link, 
gControllerInfo[i].DriveInfo[j].SymLinkBuffer);
-IoDeleteSymbolicLink(&Link);
-
 RtlInitUnicodeString(&Link, 
gControllerInfo[i].DriveInfo[j].ArcPathBuffer);
 IoDeassignArcName(&Link);
 
@@ -811,6 +808,98 @@ InitController(PCONTROLLER_INFO ControllerInfo)
 }
 
 
+static VOID NTAPI
+ReportToMountMgr(UCHAR ControlerId, UCHAR DriveId)
+/*
+ * FUNCTION: Called to report a new controler to the MountMgr
+ * ARGUMENTS:
+ * ControlerId: ID of the controler
+ * DriveId: ID of the device for the controler
+ * RETURNS:
+ * Nothing
+ * NOTES:
+ * - This is a hack to allow MountMgr handling our devices
+ */
+{
+NTSTATUS  Status;
+UNICODE_STRINGMountMgrDevice;
+PDEVICE_OBJECTDeviceObject;
+PFILE_OBJECT  FileObject;
+PMOUNTMGR_TARGET_NAME MountTarget;
+ULONG DeviceLen;
+PIRP  Irp;
+KEVENTEvent;
+IO_STATUS_BLOCK   IoStatus;
+
+/* First, get MountMgr DeviceObject */
+RtlInitUnicodeString(&MountMgrDevice, MOUNTMGR_DEVICE_NAME);
+Status = IoGetDeviceObjectPointer(&MountMgrDevice, FILE_READ_ATTRIBUTES,
+  &FileObject, &DeviceObject);
+
+if(!NT_SUCCESS(Status))
+{
+WARN_(FLOPPY, "ReportToMountMgr: Can't get MountMgr pointers %lx\n", 
Status);
+return;
+}
+
+DeviceLen = 
wcslen(&gControllerInfo[ControlerId].DriveInfo[DriveId].DeviceNameBuffer[0]) * 
sizeof(WCHAR);
+
+/* Allocate input buffer to report our floppy device */
+MountTarget = ExAllocatePool(NonPagedPool,
+ sizeof(MOUNTMGR_TARGET_NAME) + DeviceLen);
+
+if(!MountTarget)
+{
+WARN_(FLOPPY, "ReportToMountMgr: Allocation of mountTarget failed\n");
+ObDereferenceObject(FileObject);
+return;
+}
+
+MountTarget->DeviceNameLength = DeviceLen;
+RtlCopyMemory(MountTarget->DeviceName,
+  
gControllerInfo[ControlerId].DriveInfo[DriveId].DeviceNameBuffer,
+  DeviceLen);
+
+KeInitializeEvent(&Event, NotificationEvent, FALSE);
+
+/* Build the IRP used to communicate with the MountMgr */
+Irp = 
IoBuildDeviceIoControlRequest(IOCTL_MOUNTMGR_VOLUME_ARRIVAL_NOTIFICATION,
+DeviceObject,
+MountTarget,
+sizeof(MOUNTMGR_TARGET_NAME) + 
DeviceLen,
+NULL,
+0,
+FALSE,
+&Event,
+&IoStatus);
+
+if(!Irp)
+{
+WARN_(FLOPPY, "ReportToMountMgr: Allocation of irp failed\n");
+ExFreePool(MountTarget);
+ObDereferenceObject(FileObject);
+return;
+}
+
+/* Call the MountMgr */
+Status = IoCallDriver(DeviceObject, Irp);
+
+if (Status == STATUS_PENDING) {
+KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
+Status = IoStatus.Status;
+}
+
+/* We're done */
+
+INFO_(FLOPPY, "Reported to the MountMgr: %lx\n", Status);
+
+ExFreePool(MountTarget);
+ObDereferenceObje

[ros-diffs] [reactos] 01/01: [BROWSEUI] Update French translation

2019-10-26 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=96ca9e39f8bc5e059afd9e5fa56b340c23027ac4

commit 96ca9e39f8bc5e059afd9e5fa56b340c23027ac4
Author: Pierre Schweitzer 
AuthorDate: Sat Oct 26 22:09:31 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Oct 26 22:11:18 2019 +0200

[BROWSEUI] Update French translation

Addresses changes done in 103c87d

CORE-16427
---
 dll/win32/browseui/lang/fr-FR.rc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dll/win32/browseui/lang/fr-FR.rc b/dll/win32/browseui/lang/fr-FR.rc
index 2bb5d7f0ff4..2b0ceb3a74e 100644
--- a/dll/win32/browseui/lang/fr-FR.rc
+++ b/dll/win32/browseui/lang/fr-FR.rc
@@ -168,7 +168,7 @@ BEGIN
 DEFPUSHBUTTON "Che&rcher", IDC_SEARCH_BUTTON, 80, 110, 40, 15, WS_GROUP | 
WS_TABSTOP | WS_VISIBLE
 PUSHBUTTON "&Arrêter", IDC_SEARCH_STOP_BUTTON, 80, 110, 40, 15, WS_GROUP | 
WS_TABSTOP
 
-AUTOCHECKBOX "Search Hidden Files and Folders",
+AUTOCHECKBOX "Inclure les dossiers et les fichiers cachés",
  IDC_SEARCH_HIDDEN, 4, 130, 130, 8, WS_VISIBLE | WS_GROUP | 
WS_TABSTOP
 
 CONTROL "", IDC_PROGRESS_BAR, PROGRESS_CLASSA, WS_BORDER | PBS_MARQUEE, 
10, 155, 200, 8



[ros-diffs] [reactos] 01/01: [MOUNTMGR] Fix invalid WorkerReferences check in QueueWorkItem()

2019-10-22 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=457612702b615b45436f02bb8c7eda9be4d0c47c

commit 457612702b615b45436f02bb8c7eda9be4d0c47c
Author: Pierre Schweitzer 
AuthorDate: Tue Oct 22 21:51:04 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Tue Oct 22 21:53:48 2019 +0200

[MOUNTMGR] Fix invalid WorkerReferences check in QueueWorkItem()

This fixes shutting down ReactOS under certain circumstances, where
the references were incremented, but no worker thread started.
Also, took the opportunity to clarify the WorkerReferences comparisons
where relevant.

CORE-16446
---
 drivers/filters/mountmgr/database.c | 4 ++--
 drivers/filters/mountmgr/mountmgr.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/filters/mountmgr/database.c 
b/drivers/filters/mountmgr/database.c
index a025f7db3ec..1cde41a995f 100644
--- a/drivers/filters/mountmgr/database.c
+++ b/drivers/filters/mountmgr/database.c
@@ -1268,8 +1268,8 @@ QueueWorkItem(IN PDEVICE_EXTENSION DeviceExtension,
 
 /* When called, lock is already acquired */
 
-/* If noone, start to work */
-if (InterlockedIncrement(&(DeviceExtension->WorkerReferences)))
+/* If noone (-1 as references), start to work */
+if (InterlockedIncrement(&(DeviceExtension->WorkerReferences)) == 0)
 {
 IoQueueWorkItem(WorkItem->WorkItem, WorkerThread, DelayedWorkQueue, 
DeviceExtension);
 }
diff --git a/drivers/filters/mountmgr/mountmgr.c 
b/drivers/filters/mountmgr/mountmgr.c
index 37c85874c97..aa152621b51 100644
--- a/drivers/filters/mountmgr/mountmgr.c
+++ b/drivers/filters/mountmgr/mountmgr.c
@@ -822,7 +822,7 @@ MountMgrUnload(IN struct _DRIVER_OBJECT *DriverObject)
 KeInitializeEvent(&UnloadEvent, NotificationEvent, FALSE);
 
 /* Wait for workers to finish */
-if (InterlockedIncrement(&DeviceExtension->WorkerReferences))
+if (InterlockedIncrement(&DeviceExtension->WorkerReferences) > 0)
 {
 KeReleaseSemaphore(&(DeviceExtension->WorkerSemaphore),
IO_NO_INCREMENT, 1, FALSE);
@@ -1770,7 +1770,7 @@ MountMgrShutdown(IN PDEVICE_OBJECT DeviceObject,
 KeInitializeEvent(&UnloadEvent, NotificationEvent, FALSE);
 
 /* Wait for workers */
-if (InterlockedIncrement(&(DeviceExtension->WorkerReferences)))
+if (InterlockedIncrement(&(DeviceExtension->WorkerReferences)) > 0)
 {
 KeReleaseSemaphore(&(DeviceExtension->WorkerSemaphore),
IO_NO_INCREMENT,



[ros-diffs] [reactos] 05/05: [NTOSKRNL] Rewrite IoAssignDriveLetters to make NT5 compliant

2019-10-21 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5ab1cfc553f11731d9a352f1157084cc1dfd9042

commit 5ab1cfc553f11731d9a352f1157084cc1dfd9042
Author: Pierre Schweitzer 
AuthorDate: Mon Oct 21 18:28:40 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Oct 21 18:28:40 2019 +0200

[NTOSKRNL] Rewrite IoAssignDriveLetters to make NT5 compliant

The major change with this rewrite is the support for the mount
manager. Fstub will now assume that most of the devices are PnP
and that they are already registered to the mount manager.
It will thus ask the mount manager to assign the drive letter.
Fstub will keep assigning drive letters non mission critical devices
such as CDs, floppies and other removable devices.

See MountMgr:QueryPoints API test that will now return mount points :-).
---
 ntoskrnl/fstub/disksup.c| 1963 ++-
 ntoskrnl/guid.c |1 +
 ntoskrnl/include/ntoskrnl.h |1 +
 3 files changed, 1203 insertions(+), 762 deletions(-)

diff --git a/ntoskrnl/fstub/disksup.c b/ntoskrnl/fstub/disksup.c
index dfdbf0c494c..0b81bc561dd 100644
--- a/ntoskrnl/fstub/disksup.c
+++ b/ntoskrnl/fstub/disksup.c
@@ -6,6 +6,7 @@
 * PROGRAMMERS: Alex Ionescu (alex.ione...@reactos.org)
 *  Eric Kohl
 *  Casper S. Hornstrup (cho...@users.sourceforge.net)
+*  Pierre Schweitzer
 */
 
 /* INCLUDES **/
@@ -15,9 +16,6 @@
 #include 
 #include 
 
-/* DEPRECATED FUNCTIONS **/
-
-#if 1
 const WCHAR DiskMountString[] = L"\\DosDevices\\%C:";
 
 #define AUTO_DRIVE MAXULONG
@@ -43,905 +41,1346 @@ typedef enum _DISK_MANAGER
 EZ_Drive
 } DISK_MANAGER;
 
-static BOOLEAN
-HalpAssignDrive(IN PUNICODE_STRING PartitionName,
-IN ULONG DriveNumber,
-IN UCHAR DriveType,
-IN ULONG Signature,
-IN LARGE_INTEGER StartingOffset,
-IN HANDLE hKey,
-IN PUNICODE_STRING BootDevice,
-OUT PUCHAR NtSystemPath)
+typedef enum _PARTITION_TYPE
+{
+BootablePartition,
+PrimaryPartition,
+LogicalPartition,
+FtPartition,
+UnknownPartition,
+DataPartition
+} PARTITION_TYPE, *PPARTITION_TYPE;
+
+NTSTATUS
+FASTCALL
+HalpQueryDriveLayout(IN PUNICODE_STRING DeviceName,
+ OUT PDRIVE_LAYOUT_INFORMATION *LayoutInfo)
 {
-WCHAR DriveNameBuffer[16];
-UNICODE_STRING DriveName;
-ULONG i;
+IO_STATUS_BLOCK StatusBlock;
+PDEVICE_OBJECT DeviceObject = NULL;
+PFILE_OBJECT FileObject;
+KEVENT Event;
+PIRP Irp;
 NTSTATUS Status;
-REG_DISK_MOUNT_INFO DiskMountInfo;
+ULONG BufferSize;
+PDRIVE_LAYOUT_INFORMATION Buffer;
+PAGED_CODE();
+
+/* Get device pointers */
+Status = IoGetDeviceObjectPointer(DeviceName,
+  FILE_READ_ATTRIBUTES,
+  &FileObject,
+  &DeviceObject);
+if (!NT_SUCCESS(Status))
+{
+return Status;
+}
 
-DPRINT("HalpAssignDrive()\n");
+/* Get attached device object */
+DeviceObject = IoGetAttachedDeviceReference(FileObject->DeviceObject);
+ObDereferenceObject(FileObject);
 
-if ((DriveNumber != AUTO_DRIVE) && (DriveNumber < 26))
+/* Do not handle removable media */
+if (BooleanFlagOn(DeviceObject->Characteristics, FILE_REMOVABLE_MEDIA))
 {
-/* Force assignment */
-KeAcquireGuardedMutex(&ObpDeviceMapLock);
-if ((ObSystemDeviceMap->DriveMap & (1 << DriveNumber)) != 0)
-{
-DbgPrint("Drive letter already used!\n");
-KeReleaseGuardedMutex(&ObpDeviceMapLock);
-return FALSE;
-}
-KeReleaseGuardedMutex(&ObpDeviceMapLock);
+ObDereferenceObject(DeviceObject);
+return STATUS_NO_MEDIA;
 }
-else
+
+/* We'll loop until our buffer is big enough */
+Buffer = NULL;
+BufferSize = 0x1000;
+KeInitializeEvent(&Event, NotificationEvent, FALSE);
+do
 {
-/* Automatic assignment */
-DriveNumber = AUTO_DRIVE;
-KeAcquireGuardedMutex(&ObpDeviceMapLock);
-for (i = 2; i < 26; i++)
+/* If we already had a buffer, it means it's not big
+ * enough, so free and multiply size by two
+ */
+if (Buffer != NULL)
 {
-if ((ObSystemDeviceMap->DriveMap & (1 << i)) == 0)
-{
-DriveNumber = i;
-break;
-}
+ExFreePoolWithTag(Buffer, TAG_FSTUB);
+BufferSize *= 2;
 }
-KeReleaseGuardedMutex(&ObpDeviceMapLock);
 
-if (DriveNumber == AUTO_DR

[ros-diffs] [reactos] 04/05: [DISK] Forcibly declare our partitions to the MountMgr

2019-10-21 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b68104dd87b61c361c327cf44cc8845436c924ec

commit b68104dd87b61c361c327cf44cc8845436c924ec
Author: Pierre Schweitzer 
AuthorDate: Mon Oct 21 16:50:36 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Oct 21 16:50:36 2019 +0200

[DISK] Forcibly declare our partitions to the MountMgr

Because our disk.sys doesn't do anything related to PnP
(compared to disk_new.sys), forcibly declare our partitions
to the MountMgr so that it can references them and assign
them a DOS drive letter on demand later on.
---
 drivers/storage/class/disk/disk.c | 131 ++
 1 file changed, 131 insertions(+)

diff --git a/drivers/storage/class/disk/disk.c 
b/drivers/storage/class/disk/disk.c
index 580c89998d9..535de1fcd5d 100644
--- a/drivers/storage/class/disk/disk.c
+++ b/drivers/storage/class/disk/disk.c
@@ -1068,6 +1068,129 @@ CreateDiskDeviceObjectsExit:
 } // end CreateDiskDeviceObjects()
 
 
+VOID
+NTAPI
+ReportToMountMgr(
+IN PDEVICE_OBJECT DiskDeviceObject
+)
+
+/*++
+
+Routine Description:
+
+This routine reports the creation of a disk device object to the
+MountMgr to fake PnP.
+
+Arguments:
+
+DiskDeviceObject - Pointer to the created disk device.
+
+Return Value:
+
+VOID
+
+--*/
+{
+NTSTATUS  status;
+UNICODE_STRINGmountMgrDevice;
+PDEVICE_OBJECTdeviceObject;
+PFILE_OBJECT  fileObject;
+PMOUNTMGR_TARGET_NAME mountTarget;
+ULONG diskLen;
+PDEVICE_EXTENSION deviceExtension;
+PIRP  irp;
+KEVENTevent;
+IO_STATUS_BLOCK   ioStatus;
+
+//
+// First, get MountMgr DeviceObject.
+//
+
+RtlInitUnicodeString(&mountMgrDevice, MOUNTMGR_DEVICE_NAME);
+status = IoGetDeviceObjectPointer(&mountMgrDevice, FILE_READ_ATTRIBUTES,
+  &fileObject, &deviceObject);
+
+if (!NT_SUCCESS(status)) {
+
+DebugPrint((1,
+   "ReportToMountMgr: Can't get MountMgr pointers %lx\n",
+   status));
+
+return;
+}
+
+deviceExtension = DiskDeviceObject->DeviceExtension;
+diskLen = deviceExtension->DeviceName.Length;
+
+//
+// Allocate input buffer to report our partition device.
+//
+
+mountTarget = ExAllocatePool(NonPagedPool,
+ sizeof(MOUNTMGR_TARGET_NAME) + diskLen);
+
+if (!mountTarget) {
+
+DebugPrint((1,
+   "ReportToMountMgr: Allocation of mountTarget failed\n"));
+
+ObDereferenceObject(fileObject);
+return;
+}
+
+mountTarget->DeviceNameLength = diskLen;
+RtlCopyMemory(mountTarget->DeviceName, deviceExtension->DeviceName.Buffer, 
diskLen);
+
+KeInitializeEvent(&event, NotificationEvent, FALSE);
+
+//
+// Build the IRP used to communicate with the MountMgr.
+//
+
+irp = 
IoBuildDeviceIoControlRequest(IOCTL_MOUNTMGR_VOLUME_ARRIVAL_NOTIFICATION,
+deviceObject,
+mountTarget,
+sizeof(MOUNTMGR_TARGET_NAME) + diskLen,
+NULL,
+0,
+FALSE,
+&event,
+&ioStatus);
+
+if (!irp) {
+
+DebugPrint((1,
+"ReportToMountMgr: Allocation of irp failed\n"));
+
+ExFreePool(mountTarget);
+ObDereferenceObject(fileObject);
+return;
+}
+
+//
+// Call the MountMgr.
+//
+
+status = IoCallDriver(deviceObject, irp);
+
+if (status == STATUS_PENDING) {
+KeWaitForSingleObject(&event, Suspended, KernelMode, FALSE, NULL);
+status = ioStatus.Status;
+}
+
+//
+// We're done.
+//
+
+DPRINT1("Reported to the MountMgr: %lx\n", status);
+
+ExFreePool(mountTarget);
+ObDereferenceObject(fileObject);
+
+return;
+}
+
+
 NTSTATUS
 NTAPI
 CreatePartitionDeviceObjects(
@@ -1460,6 +1583,14 @@ CreatePartitionDeviceObjects(
 deviceExtension->DeviceObject = deviceObject;
 deviceExtension->DeviceFlags |= 
physicalDeviceExtension->DeviceFlags;
 
+//
+// Now we're done, report to the MountMgr.
+// This is a HACK required to have the driver
+// handle the associated DosDevices.
+//
+
+ReportToMountMgr(deviceObject);
+
 } // end for (partitionNumber) ...
 
 //



[ros-diffs] [reactos] 03/05: [CLASS2] Hackplement support for IOCTL_MOUNTDEV_QUERY_UNIQUE_ID

2019-10-21 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=410c6069996abfeb51e134bfec940a9a38598682

commit 410c6069996abfeb51e134bfec940a9a38598682
Author: Pierre Schweitzer 
AuthorDate: Mon Oct 21 16:45:28 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Oct 21 16:45:28 2019 +0200

[CLASS2] Hackplement support for IOCTL_MOUNTDEV_QUERY_UNIQUE_ID

This is required so that MountMgr can handle devices that are still
using class2 instead of classpnp.
Given we have no unique ID to return, we'll return device path, which
is far from perfect but which is enough for now to have everything
working.
---
 drivers/storage/class/class2/class2.c | 67 +--
 1 file changed, 65 insertions(+), 2 deletions(-)

diff --git a/drivers/storage/class/class2/class2.c 
b/drivers/storage/class/class2/class2.c
index 2d29f645759..5107c45f7ad 100644
--- a/drivers/storage/class/class2/class2.c
+++ b/drivers/storage/class/class2/class2.c
@@ -4041,8 +4041,7 @@ Return Value:
 goto SetStatusAndReturn;
 }
 
-if (irpStack->Parameters.DeviceIoControl.IoControlCode == 
IOCTL_MOUNTDEV_QUERY_UNIQUE_ID ||
-irpStack->Parameters.DeviceIoControl.IoControlCode == 
IOCTL_MOUNTDEV_QUERY_SUGGESTED_LINK_NAME) {
+if (irpStack->Parameters.DeviceIoControl.IoControlCode == 
IOCTL_MOUNTDEV_QUERY_SUGGESTED_LINK_NAME) {
 
 UNIMPLEMENTED;
 Irp->IoStatus.Information = 0;
@@ -4052,6 +4051,70 @@ Return Value:
 goto SetStatusAndReturn;
 }
 
+if (irpStack->Parameters.DeviceIoControl.IoControlCode == 
IOCTL_MOUNTDEV_QUERY_UNIQUE_ID) {
+
+//
+// FIXME
+// This is a HACK. We don't have unique ID.
+// We'll just return device name as unique ID.
+// It's unique but may not survive to a reboot,
+// which is not matching the requirements for
+// a MountMgr unique ID.
+//
+
+PMOUNTDEV_UNIQUE_ID uniqueId = Irp->AssociatedIrp.SystemBuffer;
+
+//
+// Check output buffer is big enough.
+//
+
+if (irpStack->Parameters.DeviceIoControl.OutputBufferLength < 
sizeof(MOUNTDEV_UNIQUE_ID)) {
+
+Irp->IoStatus.Information = 0;
+Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
+IoCompleteRequest(Irp, IO_NO_INCREMENT);
+status = STATUS_INVALID_PARAMETER;
+goto SetStatusAndReturn;
+}
+
+//
+// Set size we'll return so that caller can allocate big enough buffer.
+//
+
+RtlZeroMemory(uniqueId, sizeof(MOUNTDEV_UNIQUE_ID));
+uniqueId->UniqueIdLength = deviceExtension->DeviceName.Length;
+
+//
+// Check buffer is big enough to contain device name.
+//
+
+if (irpStack->Parameters.DeviceIoControl.OutputBufferLength < 
FIELD_OFFSET(MOUNTDEV_UNIQUE_ID, UniqueId) + uniqueId->UniqueIdLength) {
+
+Irp->IoStatus.Information = sizeof(MOUNTDEV_UNIQUE_ID);
+Irp->IoStatus.Status = STATUS_BUFFER_OVERFLOW;
+IoCompleteRequest(Irp, IO_NO_INCREMENT);
+status = STATUS_BUFFER_OVERFLOW;
+goto SetStatusAndReturn;
+}
+
+//
+// Copy device name.
+//
+
+RtlCopyMemory(uniqueId->UniqueId, deviceExtension->DeviceName.Buffer,
+  uniqueId->UniqueIdLength);
+status = STATUS_SUCCESS;
+
+//
+// And return to the caller.
+//
+
+Irp->IoStatus.Status = STATUS_SUCCESS;
+Irp->IoStatus.Information = FIELD_OFFSET(MOUNTDEV_UNIQUE_ID, UniqueId) 
+ uniqueId->UniqueIdLength;
+IoCompleteRequest(Irp, IO_NO_INCREMENT);
+goto SetStatusAndReturn;
+}
+
 if (irpStack->Parameters.DeviceIoControl.IoControlCode == 
IOCTL_MOUNTDEV_QUERY_DEVICE_NAME) {
 
 PMOUNTDEV_NAME name = Irp->AssociatedIrp.SystemBuffer;



[ros-diffs] [reactos] 01/05: [NTOSKRNL] Declare IoRemoteBootClient in internal headers

2019-10-21 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=80cc287cf6f824642bf0ebe19d832fb73aacf236

commit 80cc287cf6f824642bf0ebe19d832fb73aacf236
Author: Pierre Schweitzer 
AuthorDate: Mon Oct 21 14:16:58 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Oct 21 14:16:58 2019 +0200

[NTOSKRNL] Declare IoRemoteBootClient in internal headers
---
 ntoskrnl/include/internal/io.h | 1 +
 ntoskrnl/io/iomgr/arcname.c| 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/ntoskrnl/include/internal/io.h b/ntoskrnl/include/internal/io.h
index 14a427973b7..471f6e067f4 100644
--- a/ntoskrnl/include/internal/io.h
+++ b/ntoskrnl/include/internal/io.h
@@ -1418,6 +1418,7 @@ extern PDRIVER_OBJECT IopRootDriverObject;
 extern KSPIN_LOCK IopDeviceActionLock;
 extern LIST_ENTRY IopDeviceActionRequestList;
 extern RESERVE_IRP_ALLOCATOR IopReserveIrpAllocator;
+extern BOOLEAN IoRemoteBootClient;
 
 //
 // Inlined Functions
diff --git a/ntoskrnl/io/iomgr/arcname.c b/ntoskrnl/io/iomgr/arcname.c
index 9d011043571..852f7e02632 100644
--- a/ntoskrnl/io/iomgr/arcname.c
+++ b/ntoskrnl/io/iomgr/arcname.c
@@ -18,7 +18,6 @@
 
 UNICODE_STRING IoArcHalDeviceName, IoArcBootDeviceName;
 PCHAR IoLoaderArcBootDeviceName;
-extern BOOLEAN IoRemoteBootClient;
 
 /* FUNCTIONS */
 



[ros-diffs] [reactos] 02/05: [NTOSKRNL] Define TAG_FSTUB in the dedicated internal header

2019-10-21 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=11db7c9e5ddf399cba54e6bfbbc1d259d266185c

commit 11db7c9e5ddf399cba54e6bfbbc1d259d266185c
Author: Pierre Schweitzer 
AuthorDate: Mon Oct 21 14:26:00 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Oct 21 14:26:00 2019 +0200

[NTOSKRNL] Define TAG_FSTUB in the dedicated internal header
---
 ntoskrnl/fstub/fstubex.c| 2 --
 ntoskrnl/include/internal/tag.h | 3 +++
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/ntoskrnl/fstub/fstubex.c b/ntoskrnl/fstub/fstubex.c
index b9be7fa4e16..922aee7d8de 100644
--- a/ntoskrnl/fstub/fstubex.c
+++ b/ntoskrnl/fstub/fstubex.c
@@ -76,8 +76,6 @@ typedef struct _MASTER_BOOT_RECORD
 USHORT MasterBootRecordMagic; // 510
 } MASTER_BOOT_RECORD, *PMASTER_BOOT_RECORD;
 
-/* Tag for Fstub allocations */
-#define TAG_FSTUB 'BtsF'
 /* Partition entry size (bytes) - FIXME: It's hardcoded as Microsoft does, but 
according to specs, it shouldn't be */
 #define PARTITION_ENTRY_SIZE 128
 /* Defines "EFI PART" */
diff --git a/ntoskrnl/include/internal/tag.h b/ntoskrnl/include/internal/tag.h
index dc47c9cd4f4..4b36524ea5d 100644
--- a/ntoskrnl/include/internal/tag.h
+++ b/ntoskrnl/include/internal/tag.h
@@ -190,3 +190,6 @@
 
 #define TAG_WAIT'tiaW'
 #define TAG_SEC_QUERY   'qSbO'
+
+/* FSTUB */
+#define TAG_FSTUB 'BtsF'



[ros-diffs] [reactos] 01/01: [MOUNTMGR] Fix setting up reparse index file name

2019-10-21 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=16fcf694efc4115d5d354919cf861a81848139f2

commit 16fcf694efc4115d5d354919cf861a81848139f2
Author: Pierre Schweitzer 
AuthorDate: Mon Oct 21 12:58:30 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Oct 21 12:58:30 2019 +0200

[MOUNTMGR] Fix setting up reparse index file name

This fixes memory smashing while attempting to volume
reparse index (we were previously trying to copy the
name on itself, in the middle of itself...).
This code won't go farther on FAT, it requires NTFS.

Now, with this, ReactOS can properly boot with MountMgr
handling DOS devices without any crash or code disabled.
Cf: what was written in 7608ac9.

Modifications in class2, disk, and ntoskrnl are still to
be committed to enable all this.
---
 drivers/filters/mountmgr/database.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/filters/mountmgr/database.c 
b/drivers/filters/mountmgr/database.c
index 5e94f5c9a50..a025f7db3ec 100644
--- a/drivers/filters/mountmgr/database.c
+++ b/drivers/filters/mountmgr/database.c
@@ -678,11 +678,10 @@ ReconcileThisDatabaseWithMasterWorker(IN PVOID Parameter)
 goto ReleaseRDS;
 }
 
-
 RtlCopyMemory(ReparseFile.Buffer, DeviceInformation->DeviceName.Buffer,
   DeviceInformation->DeviceName.Length);
 RtlCopyMemory((PVOID)((ULONG_PTR)ReparseFile.Buffer + 
DeviceInformation->DeviceName.Length),
-  ReparseFile.Buffer, ReparseFile.Length);
+  ReparseIndex.Buffer, ReparseIndex.Length);
 ReparseFile.Buffer[ReparseFile.Length / sizeof(WCHAR)] = UNICODE_NULL;
 
 InitializeObjectAttributes(&ObjectAttributes,



[ros-diffs] [reactos] 01/01: [MOUNTMGR] That was not meant to be committed

2019-10-21 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bced3eaa25451d2aa093a4d338a63fdf0ca43b74

commit bced3eaa25451d2aa093a4d338a63fdf0ca43b74
Author: Pierre Schweitzer 
AuthorDate: Mon Oct 21 11:03:43 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Oct 21 11:03:43 2019 +0200

[MOUNTMGR] That was not meant to be committed

Even though it shows there might be a bug in the
code handling remote databases in the MountMgr ;-)

Addendum to 7608ac9
---
 drivers/filters/mountmgr/database.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/filters/mountmgr/database.c 
b/drivers/filters/mountmgr/database.c
index 694c98a25fa..5e94f5c9a50 100644
--- a/drivers/filters/mountmgr/database.c
+++ b/drivers/filters/mountmgr/database.c
@@ -1622,9 +1622,6 @@ ReconcileThisDatabaseWithMaster(IN PDEVICE_EXTENSION 
DeviceExtension,
 return;
 }
 
-UNIMPLEMENTED;
-return;
-
 /* Allocate a work item */
 WorkItem = AllocatePool(sizeof(RECONCILE_WORK_ITEM));
 if (!WorkItem)



[ros-diffs] [reactos] 01/01: [MOUNTMGR] Misc. fixes for WorkerThread()

2019-10-21 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7608ac9f71956c2ef60a18b1e52f4b4f12749d05

commit 7608ac9f71956c2ef60a18b1e52f4b4f12749d05
Author: Pierre Schweitzer 
AuthorDate: Mon Oct 21 10:54:51 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Oct 21 10:58:14 2019 +0200

[MOUNTMGR] Misc. fixes for WorkerThread()

- Properly quit the active loop when we're out of work items;
- Fix timeout duration (setting it to 1s);
- Fix handling the "Unloading" variable in case of a shutdown
  so that waiting loop is properly stopped;
- Documented why we're waiting on VolumesSafeForWriteAccess.

This fixes shutting down ReactOS with work items queued.
This is needed here because no one ever sets that event (properly)
created by SMSS though. A. Ionescu was explaining in 2018 that it's
autochk responsibility, but it doesn't seem to be the case in W2K3.
To be investigated.

This fix with all the previous ones and more uncommitted stuff (yet ;-))
allows reaching the first steps towards a NT5 storage stack:
https://twitter.com/HeisSpiter/status/1186199631740506112
---
 drivers/filters/mountmgr/database.c | 40 -
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/drivers/filters/mountmgr/database.c 
b/drivers/filters/mountmgr/database.c
index aa0c6a42ef5..694c98a25fa 100644
--- a/drivers/filters/mountmgr/database.c
+++ b/drivers/filters/mountmgr/database.c
@@ -1168,21 +1168,40 @@ WorkerThread(IN PDEVICE_OBJECT DeviceObject,
NULL,
NULL);
 KeInitializeEvent(&Event, NotificationEvent, FALSE);
-Timeout.LowPart = 0x;
-Timeout.HighPart = 0xFF676980;
+Timeout.QuadPart = -1000LL; /* Wait for 1 second */
 
-/* Try to wait as long as possible */
-for (i = (Unloading ? 999 : 0); i < 1000; i++)
+/* Wait as long as possible for clearance from autochk
+ * We will write remote databases only if it is safe
+ * to access volumes.
+ * First, given we start before SMSS, wait for the
+ * event creation.
+ */
+i = 0;
+do
 {
-Status = ZwOpenEvent(&SafeEvent, EVENT_ALL_ACCESS, &ObjectAttributes);
-if (NT_SUCCESS(Status))
+/* If we started to shutdown, stop waiting forever and jump to last 
attempt */
+if (Unloading)
 {
-break;
+i = 999;
+}
+else
+{
+/* Attempt to open the event */
+Status = ZwOpenEvent(&SafeEvent, EVENT_ALL_ACCESS, 
&ObjectAttributes);
+if (NT_SUCCESS(Status))
+{
+break;
+}
+
+/* Wait a bit to give SMSS a chance to create the event */
+KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, 
&Timeout);
 }
 
-KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, &Timeout);
+++i;
 }
+while (i < 1000);
 
+/* We managed to open the event, wait until autochk signals it */
 if (i < 1000)
 {
 do
@@ -1220,7 +1239,7 @@ WorkerThread(IN PDEVICE_OBJECT DeviceObject,
 IoFreeWorkItem(WorkItem->WorkItem);
 FreePool(WorkItem);
 
-if (InterlockedDecrement(&(DeviceExtension->WorkerReferences)) == 0)
+if (InterlockedDecrement(&(DeviceExtension->WorkerReferences)) < 0)
 {
 return;
 }
@@ -1603,6 +1622,9 @@ ReconcileThisDatabaseWithMaster(IN PDEVICE_EXTENSION 
DeviceExtension,
 return;
 }
 
+UNIMPLEMENTED;
+return;
+
 /* Allocate a work item */
 WorkItem = AllocatePool(sizeof(RECONCILE_WORK_ITEM));
 if (!WorkItem)



[ros-diffs] [reactos] 02/02: [MOUNTMGR] Don't kill Mm when a device has several symlinks

2019-10-19 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a058e680b662ad4aca76e1fe4803fe033c124aa2

commit a058e680b662ad4aca76e1fe4803fe033c124aa2
Author: Pierre Schweitzer 
AuthorDate: Sat Oct 19 18:04:30 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Oct 19 18:04:30 2019 +0200

[MOUNTMGR] Don't kill Mm when a device has several symlinks

On preflight to compute output size, device name & unique ID were
counted only once per device.
Then, on copy, these two were copied on every MOUNTMGR_MOUNT_POINT
structure. This is counter efficient (data duplication) but also,
it was overruning the output buffer, since the preflight was not
expecting these extra copies.
---
 drivers/filters/mountmgr/point.c | 55 ++--
 1 file changed, 41 insertions(+), 14 deletions(-)

diff --git a/drivers/filters/mountmgr/point.c b/drivers/filters/mountmgr/point.c
index a2469b0de82..38260a57c2a 100644
--- a/drivers/filters/mountmgr/point.c
+++ b/drivers/filters/mountmgr/point.c
@@ -241,11 +241,12 @@ QueryPointsFromMemory(IN PDEVICE_EXTENSION 
DeviceExtension,
 NTSTATUS Status;
 PIO_STACK_LOCATION Stack;
 UNICODE_STRING DeviceName;
-ULONG TotalSize, TotalSymLinks;
 PMOUNTMGR_MOUNT_POINTS MountPoints;
 PDEVICE_INFORMATION DeviceInformation;
 PLIST_ENTRY DeviceEntry, SymlinksEntry;
 PSYMLINK_INFORMATION SymlinkInformation;
+USHORT UniqueIdLength, DeviceNameLength;
+ULONG TotalSize, TotalSymLinks, UniqueIdOffset, DeviceNameOffset;
 
 /* If we got a symbolic link, query device */
 if (SymbolicName)
@@ -384,6 +385,26 @@ QueryPointsFromMemory(IN PDEVICE_EXTENSION DeviceExtension,
 }
 }
 
+/* Save our information about shared data */
+UniqueIdOffset = TotalSize;
+UniqueIdLength = DeviceInformation->UniqueId->UniqueIdLength;
+DeviceNameOffset = TotalSize + UniqueIdLength;
+DeviceNameLength = DeviceInformation->DeviceName.Length;
+
+/* Initialize first symlink */
+MountPoints->MountPoints[TotalSymLinks].UniqueIdOffset = 
UniqueIdOffset;
+MountPoints->MountPoints[TotalSymLinks].UniqueIdLength = 
UniqueIdLength;
+MountPoints->MountPoints[TotalSymLinks].DeviceNameOffset = 
DeviceNameOffset;
+MountPoints->MountPoints[TotalSymLinks].DeviceNameLength = 
DeviceNameLength;
+
+/* And copy data */
+RtlCopyMemory((PWSTR)((ULONG_PTR)MountPoints + UniqueIdOffset),
+  DeviceInformation->UniqueId->UniqueId, UniqueIdLength);
+RtlCopyMemory((PWSTR)((ULONG_PTR)MountPoints + DeviceNameOffset),
+  DeviceInformation->DeviceName.Buffer, DeviceNameLength);
+
+TotalSize += DeviceInformation->UniqueId->UniqueIdLength + 
DeviceInformation->DeviceName.Length;
+
 /* Now we've got it, but all the data */
 for (SymlinksEntry = DeviceInformation->SymbolicLinksListHead.Flink;
  SymlinksEntry != &(DeviceInformation->SymbolicLinksListHead);
@@ -391,27 +412,33 @@ QueryPointsFromMemory(IN PDEVICE_EXTENSION 
DeviceExtension,
 {
 SymlinkInformation = CONTAINING_RECORD(SymlinksEntry, 
SYMLINK_INFORMATION, SymbolicLinksListEntry);
 
+/* First, set shared data */
+
+/* Only put UniqueID if online */
+if (SymlinkInformation->Online)
+{
+MountPoints->MountPoints[TotalSymLinks].UniqueIdOffset = 
UniqueIdOffset;
+MountPoints->MountPoints[TotalSymLinks].UniqueIdLength = 
UniqueIdLength;
+}
+else
+{
+MountPoints->MountPoints[TotalSymLinks].UniqueIdOffset = 0;
+MountPoints->MountPoints[TotalSymLinks].UniqueIdLength = 0;
+}
+
+MountPoints->MountPoints[TotalSymLinks].DeviceNameOffset = 
DeviceNameOffset;
+MountPoints->MountPoints[TotalSymLinks].DeviceNameLength = 
DeviceNameLength;
+
+/* And now, copy specific symlink info */
 MountPoints->MountPoints[TotalSymLinks].SymbolicLinkNameOffset = 
TotalSize;
 MountPoints->MountPoints[TotalSymLinks].SymbolicLinkNameLength = 
SymlinkInformation->Name.Length;
-MountPoints->MountPoints[TotalSymLinks].UniqueIdOffset = 
SymlinkInformation->Name.Length +
- TotalSize;
-MountPoints->MountPoints[TotalSymLinks].UniqueIdLength = 
DeviceInformation->UniqueId->UniqueIdLength;
-MountPoints->MountPoints[TotalSymLinks].DeviceNameOffset = 
SymlinkInformation->Name.Length +
-   
DeviceInformation->UniqueId->UniqueIdLength +
-   

[ros-diffs] [reactos] 01/02: [MOUNTMGR_APITEST] Dump offsets

2019-10-19 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=67d3fbdd97ef967573b7405e4310ae4bdfd8d7f0

commit 67d3fbdd97ef967573b7405e4310ae4bdfd8d7f0
Author: Pierre Schweitzer 
AuthorDate: Sat Oct 19 18:00:36 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Oct 19 18:00:36 2019 +0200

[MOUNTMGR_APITEST] Dump offsets

That shows that some offset are shared (everything but the symlinks)
---
 modules/rostests/apitests/mountmgr/QueryPoints.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/modules/rostests/apitests/mountmgr/QueryPoints.c 
b/modules/rostests/apitests/mountmgr/QueryPoints.c
index e0341aec7d1..a56b1496606 100644
--- a/modules/rostests/apitests/mountmgr/QueryPoints.c
+++ b/modules/rostests/apitests/mountmgr/QueryPoints.c
@@ -12,7 +12,9 @@ TraceMountPoint(PMOUNTMGR_MOUNT_POINTS MountPoints,
 PMOUNTMGR_MOUNT_POINT MountPoint)
 {
 trace("MountPoint: %p\n", MountPoint);
+trace("\tSymbolicOffset: %ld\n", MountPoint->SymbolicLinkNameOffset);
 trace("\tSymbolicLinkName: %.*S\n", MountPoint->SymbolicLinkNameLength / 
sizeof(WCHAR), (PWSTR)((ULONG_PTR)MountPoints + 
MountPoint->SymbolicLinkNameOffset));
+trace("\tDeviceOffset: %ld\n", MountPoint->DeviceNameOffset);
 trace("\tDeviceName: %.*S\n", MountPoint->DeviceNameLength / 
sizeof(WCHAR), (PWSTR)((ULONG_PTR)MountPoints + MountPoint->DeviceNameOffset));
 }
 



[ros-diffs] [reactos] 05/05: [MOUNTMGR] Fix enumerating drive letter for creating new mountpoint

2019-10-19 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a53992180dc4e378d7e9b219bc6d854b75edfd6a

commit a53992180dc4e378d7e9b219bc6d854b75edfd6a
Author: Pierre Schweitzer 
AuthorDate: Sat Oct 19 16:56:21 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Oct 19 16:59:58 2019 +0200

[MOUNTMGR] Fix enumerating drive letter for creating new mountpoint

This is purely a copypasta error fix, which was causing 
MountMgrNextDriveLetterWorker
to fail as no drive letters were enumerated previously.

With that set of patches, MountMgr now properly assigns drive letters to
new devices!
---
 drivers/filters/mountmgr/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/filters/mountmgr/device.c 
b/drivers/filters/mountmgr/device.c
index ec9a04d063d..9b762890ea6 100644
--- a/drivers/filters/mountmgr/device.c
+++ b/drivers/filters/mountmgr/device.c
@@ -610,7 +610,7 @@ MountMgrNextDriveLetterWorker(IN PDEVICE_EXTENSION 
DeviceExtension,
  DriveLetterInfo->CurrentDriveLetter <= L'Z';
  DriveLetterInfo->CurrentDriveLetter++)
 {
-NameBuffer[LETTER_POSITION] = DeviceInformation->SuggestedDriveLetter;
+NameBuffer[LETTER_POSITION] = DriveLetterInfo->CurrentDriveLetter;
 
 Status = MountMgrCreatePointWorker(DeviceExtension, &SymbolicName, 
&TargetDeviceName);
 if (NT_SUCCESS(Status))



[ros-diffs] [reactos] 04/05: [MOUNTMGR] Fix interpretation of QueryDeviceInformation GptDriveLetter

2019-10-19 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e359a3c8881b1ebb1a96080ba456c94d7f17f95c

commit e359a3c8881b1ebb1a96080ba456c94d7f17f95c
Author: Pierre Schweitzer 
AuthorDate: Sat Oct 19 16:53:45 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Oct 19 16:59:58 2019 +0200

[MOUNTMGR] Fix interpretation of QueryDeviceInformation GptDriveLetter

Being TRUE doesn't mean the device is GPT and has a drive letter. It just
means that it's not a GPT device with 
GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER
attribute. In short, if TRUE, it means that the device can receive a drive
letter mount point.

This fixes MountMgrNextDriveLetterWorker bailing out for any attempt to
assign a drive letter to a device.
---
 drivers/filters/mountmgr/device.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/filters/mountmgr/device.c 
b/drivers/filters/mountmgr/device.c
index 4f3f9d2974e..ec9a04d063d 100644
--- a/drivers/filters/mountmgr/device.c
+++ b/drivers/filters/mountmgr/device.c
@@ -524,11 +524,12 @@ MountMgrNextDriveLetterWorker(IN PDEVICE_EXTENSION 
DeviceExtension,
 }
 
 /* If we didn't find a drive letter online
- * ensure there's no GPT drive letter nor no drive entry
+ * ensure this is not a no drive entry
+* by querying GPT attributes & database
  */
 if (NextEntry == &(DeviceInformation->SymbolicLinksListHead))
 {
-if (GptDriveLetter || 
HasNoDriveLetterEntry(DeviceInformation->UniqueId))
+if (!GptDriveLetter || 
HasNoDriveLetterEntry(DeviceInformation->UniqueId))
 {
 DriveLetterInfo->DriveLetterWasAssigned = FALSE;
 DriveLetterInfo->CurrentDriveLetter = 0;



[ros-diffs] [reactos] 03/05: [MOUNTMGR] Fix IsFtVolume so that it returns TRUE only for FT volumes

2019-10-19 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=961693f0609a6998a8b8810d0e30001d36f7e0fd

commit 961693f0609a6998a8b8810d0e30001d36f7e0fd
Author: Pierre Schweitzer 
AuthorDate: Sat Oct 19 16:52:29 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Oct 19 16:59:58 2019 +0200

[MOUNTMGR] Fix IsFtVolume so that it returns TRUE only for FT volumes
---
 drivers/filters/mountmgr/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/filters/mountmgr/device.c 
b/drivers/filters/mountmgr/device.c
index 8ed81e327d0..4f3f9d2974e 100644
--- a/drivers/filters/mountmgr/device.c
+++ b/drivers/filters/mountmgr/device.c
@@ -393,7 +393,7 @@ IsFtVolume(IN PUNICODE_STRING SymbolicName)
 }
 
 /* Check if this is a FT volume */
-return IsRecognizedPartition(PartitionInfo.PartitionType);
+return IsFTPartition(PartitionInfo.PartitionType);
 }
 
 /*



[ros-diffs] [reactos] 02/05: [MOUNTMGR] Query proper device when creating mount point

2019-10-19 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=225a1e92bdc58314c831b5d1c9f5a7d3358da8c9

commit 225a1e92bdc58314c831b5d1c9f5a7d3358da8c9
Author: Pierre Schweitzer 
AuthorDate: Sat Oct 19 16:34:38 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Oct 19 16:59:57 2019 +0200

[MOUNTMGR] Query proper device when creating mount point

We must query the target device, and not the symbolic link
we attempt to create. The later will always fail as it doesn't
exist yet.

This fixes MountMgrCreatePointWorker not working.
---
 drivers/filters/mountmgr/point.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/filters/mountmgr/point.c b/drivers/filters/mountmgr/point.c
index 35fe8bb2435..a2469b0de82 100644
--- a/drivers/filters/mountmgr/point.c
+++ b/drivers/filters/mountmgr/point.c
@@ -44,7 +44,7 @@ MountMgrCreatePointWorker(IN PDEVICE_EXTENSION 
DeviceExtension,
 PDEVICE_INFORMATION DeviceInformation = NULL, DeviceInfo;
 
 /* Get device name */
-Status = QueryDeviceInformation(SymbolicLinkName,
+Status = QueryDeviceInformation(DeviceName,
 &TargetDeviceName,
 NULL, NULL, NULL,
 NULL, NULL, NULL);



[ros-diffs] [reactos] 01/05: [MOUNTMGR] Remove cancel routine before completing pending IRP

2019-10-19 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7b650d2c3ef90cb7ea3fa0029ab2b75835f5fa5c

commit 7b650d2c3ef90cb7ea3fa0029ab2b75835f5fa5c
Author: Pierre Schweitzer 
AuthorDate: Sat Oct 19 16:29:37 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Oct 19 16:59:57 2019 +0200

[MOUNTMGR] Remove cancel routine before completing pending IRP
---
 drivers/filters/mountmgr/notify.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/filters/mountmgr/notify.c 
b/drivers/filters/mountmgr/notify.c
index 97bc9470376..9a1e7885ac8 100644
--- a/drivers/filters/mountmgr/notify.c
+++ b/drivers/filters/mountmgr/notify.c
@@ -328,6 +328,7 @@ MountMgrNotify(IN PDEVICE_EXTENSION DeviceExtension)
 {
 NextEntry = RemoveHeadList(&(DeviceExtension->IrpListHead));
 Irp = CONTAINING_RECORD(NextEntry, IRP, Tail.Overlay.ListEntry);
+IoSetCancelRoutine(Irp, NULL);
 InsertTailList(&CopyList, &(Irp->Tail.Overlay.ListEntry));
 }
 IoReleaseCancelSpinLock(OldIrql);



[ros-diffs] [reactos] 01/01: [WSHTCPIP] Print IOCTL as hexa value

2019-10-19 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c290ae21c77317c741ec4c37fe03f0b75ab35623

commit c290ae21c77317c741ec4c37fe03f0b75ab35623
Author: Pierre Schweitzer 
AuthorDate: Sat Oct 19 11:46:24 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Oct 19 12:04:40 2019 +0200

[WSHTCPIP] Print IOCTL as hexa value
---
 dll/win32/wshtcpip/wshtcpip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dll/win32/wshtcpip/wshtcpip.c b/dll/win32/wshtcpip/wshtcpip.c
index 22e27efe24d..a66166c2e8f 100644
--- a/dll/win32/wshtcpip/wshtcpip.c
+++ b/dll/win32/wshtcpip/wshtcpip.c
@@ -365,7 +365,7 @@ WSHIoctl(
 
 UNIMPLEMENTED;
 
-DPRINT1("Ioctl: Unknown IOCTL code: %d\n", IoControlCode);
+DPRINT1("Ioctl: Unknown IOCTL code: %x\n", IoControlCode);
 
 return WSAEINVAL;
 }



[ros-diffs] [reactos] 01/01: [MOUNTMGR] QueryPointsFromMemory: take into account the multiple MOUNTMGR_MOUNT_POINT

2019-10-17 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2da92ac67bc7f664840a21f1d55e87192828ae06

commit 2da92ac67bc7f664840a21f1d55e87192828ae06
Author: Pierre Schweitzer 
AuthorDate: Thu Oct 17 22:40:23 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Thu Oct 17 22:42:47 2019 +0200

[MOUNTMGR] QueryPointsFromMemory: take into account the multiple 
MOUNTMGR_MOUNT_POINT

This fixes returning too small structure on an IOCTL_MOUNTMGR_QUERY_POINTS 
call.
The multiple MOUNTMGR_MOUNT_POINT structures were ignored and thus the data 
of the
first one were erased by the multiple structures.
MountMgr now returns consistent output on this IOCTL call.
---
 drivers/filters/mountmgr/point.c | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/filters/mountmgr/point.c b/drivers/filters/mountmgr/point.c
index 26c263eec08..35fe8bb2435 100644
--- a/drivers/filters/mountmgr/point.c
+++ b/drivers/filters/mountmgr/point.c
@@ -336,9 +336,9 @@ QueryPointsFromMemory(IN PDEVICE_EXTENSION DeviceExtension,
 MountPoints = (PMOUNTMGR_MOUNT_POINTS)Irp->AssociatedIrp.SystemBuffer;
 
 /* Ensure we set output to let user reallocate! */
-MountPoints->Size = sizeof(MOUNTMGR_MOUNT_POINTS) + TotalSize;
+MountPoints->Size = sizeof(MOUNTMGR_MOUNT_POINTS) + TotalSymLinks * 
sizeof(MOUNTMGR_MOUNT_POINT) + TotalSize;
 MountPoints->NumberOfMountPoints = TotalSymLinks;
-Irp->IoStatus.Information = sizeof(MOUNTMGR_MOUNT_POINTS) + TotalSize;
+Irp->IoStatus.Information = MountPoints->Size;
 
 if (MountPoints->Size > 
Stack->Parameters.DeviceIoControl.OutputBufferLength)
 {
@@ -353,8 +353,8 @@ QueryPointsFromMemory(IN PDEVICE_EXTENSION DeviceExtension,
 }
 
 /* Now, start putting mount points */
+TotalSize = sizeof(MOUNTMGR_MOUNT_POINTS) + TotalSymLinks * 
sizeof(MOUNTMGR_MOUNT_POINT);
 TotalSymLinks = 0;
-TotalSize = 0;
 for (DeviceEntry = DeviceExtension->DeviceListHead.Flink;
  DeviceEntry != &(DeviceExtension->DeviceListHead);
  DeviceEntry = DeviceEntry->Flink)
@@ -391,16 +391,12 @@ QueryPointsFromMemory(IN PDEVICE_EXTENSION 
DeviceExtension,
 {
 SymlinkInformation = CONTAINING_RECORD(SymlinksEntry, 
SYMLINK_INFORMATION, SymbolicLinksListEntry);
 
-
-MountPoints->MountPoints[TotalSymLinks].SymbolicLinkNameOffset = 
sizeof(MOUNTMGR_MOUNT_POINTS) +
- 
TotalSize;
+MountPoints->MountPoints[TotalSymLinks].SymbolicLinkNameOffset = 
TotalSize;
 MountPoints->MountPoints[TotalSymLinks].SymbolicLinkNameLength = 
SymlinkInformation->Name.Length;
-MountPoints->MountPoints[TotalSymLinks].UniqueIdOffset = 
sizeof(MOUNTMGR_MOUNT_POINTS) +
- 
SymlinkInformation->Name.Length +
+MountPoints->MountPoints[TotalSymLinks].UniqueIdOffset = 
SymlinkInformation->Name.Length +
  TotalSize;
 MountPoints->MountPoints[TotalSymLinks].UniqueIdLength = 
DeviceInformation->UniqueId->UniqueIdLength;
-MountPoints->MountPoints[TotalSymLinks].DeviceNameOffset = 
sizeof(MOUNTMGR_MOUNT_POINTS) +
-   
SymlinkInformation->Name.Length +
+MountPoints->MountPoints[TotalSymLinks].DeviceNameOffset = 
SymlinkInformation->Name.Length +

DeviceInformation->UniqueId->UniqueIdLength +

TotalSize;
 MountPoints->MountPoints[TotalSymLinks].DeviceNameLength = 
DeviceInformation->DeviceName.Length;



[ros-diffs] [reactos] 01/01: [MOUNTMGR_APITEST] Dump returned mount points

2019-10-16 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6116262c747714787bf481736be9c4eb9201ecea

commit 6116262c747714787bf481736be9c4eb9201ecea
Author: Pierre Schweitzer 
AuthorDate: Wed Oct 16 22:22:30 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Wed Oct 16 22:22:30 2019 +0200

[MOUNTMGR_APITEST] Dump returned mount points
---
 modules/rostests/apitests/mountmgr/QueryPoints.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/modules/rostests/apitests/mountmgr/QueryPoints.c 
b/modules/rostests/apitests/mountmgr/QueryPoints.c
index 169728a8d81..e0341aec7d1 100644
--- a/modules/rostests/apitests/mountmgr/QueryPoints.c
+++ b/modules/rostests/apitests/mountmgr/QueryPoints.c
@@ -7,6 +7,15 @@
 
 #include "precomp.h"
 
+VOID
+TraceMountPoint(PMOUNTMGR_MOUNT_POINTS MountPoints,
+PMOUNTMGR_MOUNT_POINT MountPoint)
+{
+trace("MountPoint: %p\n", MountPoint);
+trace("\tSymbolicLinkName: %.*S\n", MountPoint->SymbolicLinkNameLength / 
sizeof(WCHAR), (PWSTR)((ULONG_PTR)MountPoints + 
MountPoint->SymbolicLinkNameOffset));
+trace("\tDeviceName: %.*S\n", MountPoint->DeviceNameLength / 
sizeof(WCHAR), (PWSTR)((ULONG_PTR)MountPoints + MountPoint->DeviceNameOffset));
+}
+
 START_TEST(QueryPoints)
 {
 BOOL Ret;
@@ -45,12 +54,19 @@ START_TEST(QueryPoints)
 }
 else
 {
+AllocatedPoints->NumberOfMountPoints = 0;
+
 Ret = DeviceIoControl(MountMgrHandle, IOCTL_MOUNTMGR_QUERY_POINTS,
   &SinglePoint, sizeof(MOUNTMGR_MOUNT_POINT),
   AllocatedPoints, MountPoints.Size,
   &BytesReturned, NULL);
 ok(Ret == TRUE, "IOCTL unexpectedly failed %lx\n", GetLastError());
 
+for (i = 0; i < AllocatedPoints->NumberOfMountPoints; ++i)
+{
+TraceMountPoint(AllocatedPoints, &AllocatedPoints->MountPoints[i]);
+}
+
 RtlFreeHeap(RtlGetProcessHeap(), 0, AllocatedPoints);
 }
 



[ros-diffs] [reactos] 01/01: [MOUNTMGR] Properly look for symlink and break when found

2019-10-05 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a7f97cc70f62f6805e71b28eba51f52b942d22b4

commit a7f97cc70f62f6805e71b28eba51f52b942d22b4
Author: Pierre Schweitzer 
AuthorDate: Sat Oct 5 21:29:38 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Oct 5 21:30:55 2019 +0200

[MOUNTMGR] Properly look for symlink and break when found

This fixes a bug where MountMgr was returning first found entry
on query even when not matching the requested device.
---
 drivers/filters/mountmgr/point.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/filters/mountmgr/point.c b/drivers/filters/mountmgr/point.c
index 4c1d843db50..198e0a5324c 100644
--- a/drivers/filters/mountmgr/point.c
+++ b/drivers/filters/mountmgr/point.c
@@ -472,7 +472,7 @@ QueryPointsFromSymbolicLinkName(IN PDEVICE_EXTENSION 
DeviceExtension,
 {
 SymlinkInformation = CONTAINING_RECORD(SymlinksEntry, 
SYMLINK_INFORMATION, SymbolicLinksListEntry);
 
-if (RtlEqualUnicodeString(SymbolicName, &SymlinkInformation->Name, 
TRUE) == 0)
+if (RtlEqualUnicodeString(SymbolicName, &SymlinkInformation->Name, 
TRUE))
 {
 break;
 }
@@ -500,7 +500,7 @@ QueryPointsFromSymbolicLinkName(IN PDEVICE_EXTENSION 
DeviceExtension,
 {
 SymlinkInformation = CONTAINING_RECORD(SymlinksEntry, 
SYMLINK_INFORMATION, SymbolicLinksListEntry);
 
-if (RtlEqualUnicodeString(SymbolicName, 
&SymlinkInformation->Name, TRUE) == 0)
+if (RtlEqualUnicodeString(SymbolicName, 
&SymlinkInformation->Name, TRUE))
 {
 break;
 }



[ros-diffs] [reactos] 01/01: [FREELDR] Stop asking people to report bugs on ros-...@reactos.org

2019-10-02 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=17db4217a83e9ea6ce45b5957f9dfef19c13a149

commit 17db4217a83e9ea6ce45b5957f9dfef19c13a149
Author: Pierre Schweitzer 
AuthorDate: Thu Oct 3 02:54:27 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Thu Oct 3 02:55:45 2019 +0200

[FREELDR] Stop asking people to report bugs on ros-...@reactos.org

That should be merged to 0.4.13
---
 boot/freeldr/freeldr/arch/i386/i386bug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/boot/freeldr/freeldr/arch/i386/i386bug.c 
b/boot/freeldr/freeldr/arch/i386/i386bug.c
index 6d42279d1ab..fd89ddf7873 100644
--- a/boot/freeldr/freeldr/arch/i386/i386bug.c
+++ b/boot/freeldr/freeldr/arch/i386/i386bug.c
@@ -112,7 +112,7 @@ i386PrintExceptionText(ULONG TrapIndex, PKTRAP_FRAME 
TrapFrame, PKSPECIAL_REGIST
 i386_ScreenPosY = 0;
 
 PrintText("An error occured in " VERSION "\n"
-  "Report this error to the ReactOS Development mailing list 
\n\n"
+  "Report this error on the ReactOS Bug Tracker: 
https://jira.reactos.org\n\n";
   "0x%02lx: %s\n", TrapIndex, 
i386ExceptionDescriptionText[TrapIndex]);
 #ifdef _M_IX86
 PrintText("EAX: %.8lxESP: %.8lxCR0: %.8lxDR0: 
%.8lx\n",



[ros-diffs] [reactos] 02/02: [KERNEL32] Fix FIXME by calling appropriate function in GetNativeSystemInfo()

2019-10-02 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0ce3941b419e27d2894b227a7a101182f5850cd6

commit 0ce3941b419e27d2894b227a7a101182f5850cd6
Author: Pierre Schweitzer 
AuthorDate: Wed Oct 2 10:52:00 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Wed Oct 2 10:52:00 2019 +0200

[KERNEL32] Fix FIXME by calling appropriate function in 
GetNativeSystemInfo()
---
 dll/win32/kernel32/client/sysinfo.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/dll/win32/kernel32/client/sysinfo.c 
b/dll/win32/kernel32/client/sysinfo.c
index 0e588b3e449..ac0ad750efc 100644
--- a/dll/win32/kernel32/client/sysinfo.c
+++ b/dll/win32/kernel32/client/sysinfo.c
@@ -209,18 +209,16 @@ GetNativeSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
 SYSTEM_PROCESSOR_INFORMATION ProcInfo;
 NTSTATUS Status;
 
-/* FIXME: Should be SystemNativeBasicInformation */
-Status = NtQuerySystemInformation(SystemBasicInformation,
-  &BasicInfo,
-  sizeof(BasicInfo),
-  0);
+Status = RtlGetNativeSystemInformation(SystemBasicInformation,
+   &BasicInfo,
+   sizeof(BasicInfo),
+   0);
 if (!NT_SUCCESS(Status)) return;
   
-/* FIXME: Should be SystemNativeProcessorInformation */
-Status = NtQuerySystemInformation(SystemProcessorInformation,
-  &ProcInfo,
-  sizeof(ProcInfo),
-  0);
+Status = RtlGetNativeSystemInformation(SystemProcessorInformation,
+   &ProcInfo,
+   sizeof(ProcInfo),
+   0);
 if (!NT_SUCCESS(Status)) return;
 
 GetSystemInfoInternal(&BasicInfo, &ProcInfo, lpSystemInfo);



[ros-diffs] [reactos] 01/02: [SDK] Define RtlGetNativeSystemInformation()

2019-10-02 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8c7b84bb5c623ff8284a5e1840dbc0ab69b6b7fb

commit 8c7b84bb5c623ff8284a5e1840dbc0ab69b6b7fb
Author: Pierre Schweitzer 
AuthorDate: Wed Oct 2 10:50:59 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Wed Oct 2 10:50:59 2019 +0200

[SDK] Define RtlGetNativeSystemInformation()
---
 sdk/include/ndk/rtlfuncs.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/sdk/include/ndk/rtlfuncs.h b/sdk/include/ndk/rtlfuncs.h
index 48e3f7d0432..005d761ae73 100644
--- a/sdk/include/ndk/rtlfuncs.h
+++ b/sdk/include/ndk/rtlfuncs.h
@@ -4739,6 +4739,16 @@ RtlCloneMemoryStream(
 _Outptr_ struct IStream **ResultStream
 );
 
+NTSYSAPI
+NTSTATUS
+NTAPI
+RtlGetNativeSystemInformation(
+_In_ SYSTEM_INFORMATION_CLASS SystemInformationClass,
+_Out_writes_bytes_to_opt_(SystemInformationLength, *ReturnLength) PVOID 
SystemInformation,
+_In_ ULONG SystemInformationLength,
+_Out_opt_ PULONG ReturnLength
+);
+
 #endif // NTOS_MODE_USER
 
 NTSYSAPI



[ros-diffs] [reactos] 01/01: [NTDLL_WINETESTS] Fix the test so that it works on W2K3

2019-10-01 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d055c9f16f85dda5af33f8180e15194c9b386c81

commit d055c9f16f85dda5af33f8180e15194c9b386c81
Author: Pierre Schweitzer 
AuthorDate: Tue Oct 1 10:10:52 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Tue Oct 1 10:11:39 2019 +0200

[NTDLL_WINETESTS] Fix the test so that it works on W2K3

It's an addendum to ad547c9
---
 modules/rostests/winetests/ntdll/info.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/modules/rostests/winetests/ntdll/info.c 
b/modules/rostests/winetests/ntdll/info.c
index 3d2c6318840..e641a8d0ff2 100644
--- a/modules/rostests/winetests/ntdll/info.c
+++ b/modules/rostests/winetests/ntdll/info.c
@@ -1883,9 +1883,7 @@ static void test_queryvirtualmemory(void)
 {
 NTSTATUS status;
 SIZE_T readcount;
-#ifndef __REACTOS__
 static const WCHAR windowsW[] = {'w','i','n','d','o','w','s'};
-#endif
 static const char teststring[] = "test string";
 static char datatestbuf[42] = "abc";
 static char rwtestbuf[42];
@@ -1893,10 +1891,13 @@ static void test_queryvirtualmemory(void)
 char stackbuf[42];
 HMODULE module;
 char buffer_name[sizeof(MEMORY_SECTION_NAME) + MAX_PATH * sizeof(WCHAR)];
-MEMORY_SECTION_NAME *msn = (MEMORY_SECTION_NAME *)buffer_name;
 #ifndef __REACTOS__
+MEMORY_SECTION_NAME *msn = (MEMORY_SECTION_NAME *)buffer_name;
+#endif
 BOOL found;
 int i;
+#ifdef __REACTOS__
+MEMORY_SECTION_NAME *msn = HeapAlloc(GetProcessHeap(), 0, 
sizeof(buffer_name));
 #endif
 
 module = GetModuleHandleA( "ntdll.dll" );
@@ -1998,7 +1999,6 @@ static void test_queryvirtualmemory(void)
 memset(buffer_name, 0x77, sizeof(buffer_name));
 readcount = 0;
 status = pNtQueryVirtualMemory(NtCurrentProcess(), module, 
MemorySectionName, msn, sizeof(buffer_name), &readcount);
-#ifndef __REACTOS__
 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", 
status);
 ok( readcount > 0, "Expected readcount to be > 0\n");
 trace ("Section Name: %s\n", wine_dbgstr_w(msn->SectionFileName.Buffer));
@@ -2006,18 +2006,17 @@ static void test_queryvirtualmemory(void)
 for (found = FALSE, i = (msn->SectionFileName.Length - sizeof(windowsW)) / 
sizeof(WCHAR); i >= 0; i--)
 found |= !memcmp( &msn->SectionFileName.Buffer[i], windowsW, 
sizeof(windowsW) );
 ok( found, "Section name does not contain \"Windows\"\n");
-#else
-/* W2K3 will return this, because the buffer is not ULONG-aligned */
-ok( status == STATUS_DATATYPE_MISALIGNMENT, "Expected 
STATUS_DATATYPE_MISALIGNMENT, got %08x\n", status);
-ok( readcount == 0, "Expected readcount to be 0: %ld\n", readcount);
-#endif
 
 trace("Check section name of non mapped memory\n");
-memset(msn, 0, sizeof(*msn));
+memset(msn, 0, sizeof(buffer_name));
 readcount = 0;
 status = pNtQueryVirtualMemory(NtCurrentProcess(), &buffer_name, 
MemorySectionName, msn, sizeof(buffer_name), &readcount);
 ok( status == STATUS_INVALID_ADDRESS, "Expected STATUS_INVALID_ADDRESS, 
got %08x\n", status);
 ok( readcount == 0 || broken(readcount != 0) /* wow64 */, "Expected 
readcount to be 0\n");
+
+#ifdef __REACTOS__
+HeapFree(GetProcessHeap(), 0, msn);
+#endif
 }
 
 static void test_affinity(void)



[ros-diffs] [reactos] 01/03: [NTDLL_WINETESTS] Section name query test is broken on W2K3 and will lead to a crash Comment out the test for now and add a more "appropriate" test code for now

2019-09-29 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ad547c960fce62b49c64172f12e1230566be14db

commit ad547c960fce62b49c64172f12e1230566be14db
Author: Pierre Schweitzer 
AuthorDate: Sun Sep 29 14:13:55 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sun Sep 29 14:13:55 2019 +0200

[NTDLL_WINETESTS] Section name query test is broken on W2K3 and will lead 
to a crash
Comment out the test for now and add a more "appropriate" test code for now
---
 modules/rostests/winetests/ntdll/info.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/modules/rostests/winetests/ntdll/info.c 
b/modules/rostests/winetests/ntdll/info.c
index 14ddf20d1eb..3d2c6318840 100644
--- a/modules/rostests/winetests/ntdll/info.c
+++ b/modules/rostests/winetests/ntdll/info.c
@@ -1883,7 +1883,9 @@ static void test_queryvirtualmemory(void)
 {
 NTSTATUS status;
 SIZE_T readcount;
+#ifndef __REACTOS__
 static const WCHAR windowsW[] = {'w','i','n','d','o','w','s'};
+#endif
 static const char teststring[] = "test string";
 static char datatestbuf[42] = "abc";
 static char rwtestbuf[42];
@@ -1892,8 +1894,10 @@ static void test_queryvirtualmemory(void)
 HMODULE module;
 char buffer_name[sizeof(MEMORY_SECTION_NAME) + MAX_PATH * sizeof(WCHAR)];
 MEMORY_SECTION_NAME *msn = (MEMORY_SECTION_NAME *)buffer_name;
+#ifndef __REACTOS__
 BOOL found;
 int i;
+#endif
 
 module = GetModuleHandleA( "ntdll.dll" );
 trace("Check flags of the PE header of NTDLL.DLL at %p\n", module);
@@ -1994,6 +1998,7 @@ static void test_queryvirtualmemory(void)
 memset(buffer_name, 0x77, sizeof(buffer_name));
 readcount = 0;
 status = pNtQueryVirtualMemory(NtCurrentProcess(), module, 
MemorySectionName, msn, sizeof(buffer_name), &readcount);
+#ifndef __REACTOS__
 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", 
status);
 ok( readcount > 0, "Expected readcount to be > 0\n");
 trace ("Section Name: %s\n", wine_dbgstr_w(msn->SectionFileName.Buffer));
@@ -2001,6 +2006,11 @@ static void test_queryvirtualmemory(void)
 for (found = FALSE, i = (msn->SectionFileName.Length - sizeof(windowsW)) / 
sizeof(WCHAR); i >= 0; i--)
 found |= !memcmp( &msn->SectionFileName.Buffer[i], windowsW, 
sizeof(windowsW) );
 ok( found, "Section name does not contain \"Windows\"\n");
+#else
+/* W2K3 will return this, because the buffer is not ULONG-aligned */
+ok( status == STATUS_DATATYPE_MISALIGNMENT, "Expected 
STATUS_DATATYPE_MISALIGNMENT, got %08x\n", status);
+ok( readcount == 0, "Expected readcount to be 0: %ld\n", readcount);
+#endif
 
 trace("Check section name of non mapped memory\n");
 memset(msn, 0, sizeof(*msn));



[ros-diffs] [reactos] 03/03: [SDK] Make our MEMORY_SECTION_NAME definitions consistent. I choose the definition which is also used by Wine & Chromium.

2019-09-29 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3f63f236baa5edaa26aed223635202a6dd0741db

commit 3f63f236baa5edaa26aed223635202a6dd0741db
Author: Pierre Schweitzer 
AuthorDate: Sun Sep 29 14:18:11 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sun Sep 29 14:18:11 2019 +0200

[SDK] Make our MEMORY_SECTION_NAME definitions consistent.
I choose the definition which is also used by Wine & Chromium.

CORE-12043
---
 sdk/include/ndk/mmtypes.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sdk/include/ndk/mmtypes.h b/sdk/include/ndk/mmtypes.h
index 2e96dcad3e7..5c271938320 100644
--- a/sdk/include/ndk/mmtypes.h
+++ b/sdk/include/ndk/mmtypes.h
@@ -315,7 +315,6 @@ typedef struct _MEMORY_WORKING_SET_LIST
 typedef struct
 {
 UNICODE_STRING SectionFileName;
-WCHAR NameBuffer[ANYSIZE_ARRAY];
 } MEMORY_SECTION_NAME, *PMEMORY_SECTION_NAME;
 
 //



[ros-diffs] [reactos] 02/03: [NTOSKRNL] Simplify buffer definition in MiQueryMemorySectionName(). Also take into account the UNICODE_STRING structure while computing whole size This is based on Thomas

2019-09-29 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3b78ca210ef49c020e34321ba9206c83340f26c0

commit 3b78ca210ef49c020e34321ba9206c83340f26c0
Author: Pierre Schweitzer 
AuthorDate: Sun Sep 29 14:16:44 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sun Sep 29 14:16:44 2019 +0200

[NTOSKRNL] Simplify buffer definition in MiQueryMemorySectionName().
Also take into account the UNICODE_STRING structure while computing whole 
size
This is based on Thomas' patch.

CORE-12043
---
 ntoskrnl/mm/ARM3/section.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c
index e50aa518e5d..6bc1a6ef8db 100644
--- a/ntoskrnl/mm/ARM3/section.c
+++ b/ntoskrnl/mm/ARM3/section.c
@@ -1923,11 +1923,12 @@ MiQueryMemorySectionName(IN HANDLE ProcessHandle,
 {
 _SEH2_TRY
 {
-RtlInitUnicodeString(&SectionName->SectionFileName, 
SectionName->NameBuffer);
-SectionName->SectionFileName.MaximumLength = 
(USHORT)MemoryInformationLength;
+RtlInitEmptyUnicodeString(&SectionName->SectionFileName,
+  (PWSTR)(SectionName + 1),
+  MemoryInformationLength - 
sizeof(MEMORY_SECTION_NAME));
 RtlCopyUnicodeString(&SectionName->SectionFileName, 
&ModuleFileName);
 
-if (ReturnLength) *ReturnLength = ModuleFileName.Length;
+if (ReturnLength) *ReturnLength = ModuleFileName.Length + 
sizeof(MEMORY_SECTION_NAME);
 
 }
 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
@@ -1938,11 +1939,12 @@ MiQueryMemorySectionName(IN HANDLE ProcessHandle,
 }
 else
 {
-RtlInitUnicodeString(&SectionName->SectionFileName, 
SectionName->NameBuffer);
-SectionName->SectionFileName.MaximumLength = 
(USHORT)MemoryInformationLength;
+RtlInitEmptyUnicodeString(&SectionName->SectionFileName,
+  (PWSTR)(SectionName + 1),
+  MemoryInformationLength - 
sizeof(MEMORY_SECTION_NAME));
 RtlCopyUnicodeString(&SectionName->SectionFileName, 
&ModuleFileName);
 
-if (ReturnLength) *ReturnLength = ModuleFileName.Length;
+if (ReturnLength) *ReturnLength = ModuleFileName.Length + 
sizeof(MEMORY_SECTION_NAME);
 
 }
 



[ros-diffs] [reactos] 01/01: [NTOSKRNL] Implement NtQuerySystemInformation(SystemLogicalProcessorInformation)

2019-09-27 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=96ee4509e552a006f8e51b5261359d4cb139b1c3

commit 96ee4509e552a006f8e51b5261359d4cb139b1c3
Author: Pierre Schweitzer 
AuthorDate: Fri Sep 27 20:36:34 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Fri Sep 27 20:36:59 2019 +0200

[NTOSKRNL] Implement 
NtQuerySystemInformation(SystemLogicalProcessorInformation)
---
 ntoskrnl/ex/sysinfo.c | 86 ++-
 1 file changed, 85 insertions(+), 1 deletion(-)

diff --git a/ntoskrnl/ex/sysinfo.c b/ntoskrnl/ex/sysinfo.c
index e3c6ece86d6..aa999b2a023 100644
--- a/ntoskrnl/ex/sysinfo.c
+++ b/ntoskrnl/ex/sysinfo.c
@@ -2631,6 +2631,90 @@ QSI_DEF(SystemObjectSecurityMode)
 return STATUS_SUCCESS;
 }
 
+/* Class 73 - Logical processor information  */
+QSI_DEF(SystemLogicalProcessorInformation)
+{
+LONG i;
+PKPRCB Prcb;
+KAFFINITY CurrentProc;
+NTSTATUS Status = STATUS_SUCCESS;
+ULONG DataSize = 0, ProcessorFlags;
+PSYSTEM_LOGICAL_PROCESSOR_INFORMATION CurrentInfo;
+
+/* First, browse active processors, thanks to the map */
+i = 0;
+CurrentInfo = Buffer;
+CurrentProc = KeActiveProcessors;
+do
+{
+/* If current processor is active and is main in case of HT/MC, return 
it */
+Prcb = KiProcessorBlock[i];
+if ((CurrentProc & 1) &&
+Prcb == Prcb->MultiThreadSetMaster)
+{
+/* Assume processor can do HT or multicore */
+ProcessorFlags = 1;
+
+/* If set is the same for PRCB and multithread, then
+ * actually, the processor is single core
+ */
+if (Prcb->SetMember == Prcb->MultiThreadProcessorSet)
+{
+ProcessorFlags = 0;
+}
+
+/* Check we have enough room to return */
+DataSize += sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION);
+if (DataSize > Size)
+{
+Status = STATUS_INFO_LENGTH_MISMATCH;
+}
+else
+{
+/* Zero output and return */
+RtlZeroMemory(CurrentInfo, 
sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION));
+CurrentInfo->ProcessorMask = Prcb->MultiThreadProcessorSet;
+
+/* Processor core needs 1 if HT/MC is supported */
+CurrentInfo->Relationship = RelationProcessorCore;
+CurrentInfo->ProcessorCore.Flags = ProcessorFlags;
+++CurrentInfo;
+}
+}
+
+/* Move to the next proc */
+CurrentProc >>= 1;
+++i;
+/* Loop while there's someone in the bitmask */
+} while (CurrentProc != 0);
+
+/* Now, return the NUMA nodes */
+for (i = 0; i < KeNumberNodes; ++i)
+{
+/* Check we have enough room to return */
+DataSize += sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION);
+if (DataSize > Size)
+{
+Status = STATUS_INFO_LENGTH_MISMATCH;
+}
+else
+{
+/* Zero output and return */
+RtlZeroMemory(CurrentInfo, 
sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION));
+CurrentInfo->ProcessorMask = KeActiveProcessors;
+
+/* NUMA node needs its ID */
+CurrentInfo->Relationship = RelationNumaNode;
+CurrentInfo->NumaNode.NodeNumber = i;
+++CurrentInfo;
+}
+}
+
+*ReqSize = DataSize;
+
+return Status;
+}
+
 /* Class 76 - System firmware table information  */
 QSI_DEF(SystemFirmwareTableInformation)
 {
@@ -2826,7 +2910,7 @@ CallQS [] =
 SI_QX(SystemObjectSecurityMode),
 SI_XX(SystemWatchdogTimerHandler), /* FIXME: not implemented */
 SI_XX(SystemWatchdogTimerInformation), /* FIXME: not implemented */
-SI_XX(SystemLogicalProcessorInformation), /* FIXME: not implemented */
+SI_QX(SystemLogicalProcessorInformation),
 SI_XX(SystemWow64SharedInformation), /* FIXME: not implemented */
 SI_XX(SystemRegisterFirmwareTableInformationHandler), /* FIXME: not 
implemented */
 SI_QX(SystemFirmwareTableInformation),



[ros-diffs] [reactos] 01/01: [BTRFS] Reenable the MountMgr thread

2019-09-07 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7ff3658f109357ea033c759e993ccc3b2027cac1

commit 7ff3658f109357ea033c759e993ccc3b2027cac1
Author: Pierre Schweitzer 
AuthorDate: Sat Sep 7 23:28:58 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Sep 7 23:28:58 2019 +0200

[BTRFS] Reenable the MountMgr thread

Now that IOCTL_MOUNTMGR_QUERY_POINTS and IOCTL_MOUNTMGR_CHANGE_NOTIFY have
been fixed, the thread no longer eats 100% CPU nor prevent ReactOS shutdown
---
 drivers/filesystems/btrfs/btrfs.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/filesystems/btrfs/btrfs.c 
b/drivers/filesystems/btrfs/btrfs.c
index 2f0c97d5675..2977667de9a 100644
--- a/drivers/filesystems/btrfs/btrfs.c
+++ b/drivers/filesystems/btrfs/btrfs.c
@@ -6013,11 +6013,9 @@ NTSTATUS __stdcall DriverEntry(_In_ PDRIVER_OBJECT 
DriverObject, _In_ PUNICODE_S
 
 KeInitializeEvent(&mountmgr_thread_event, NotificationEvent, false);
 
-#ifndef __REACTOS__
 Status = PsCreateSystemThread(&mountmgr_thread_handle, 0, NULL, NULL, 
NULL, mountmgr_thread, NULL);
 if (!NT_SUCCESS(Status))
 WARN("PsCreateSystemThread returned %08x\n", Status);
-#endif
 
 IoRegisterFileSystem(DeviceObject);
 



[ros-diffs] [reactos] 01/01: [MOUNTMGR] Properly return EpicNumber in MountMgrChangeNotify

2019-09-07 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d904ee19c5cda7d7a6548b888ae9d6742658e5d0

commit d904ee19c5cda7d7a6548b888ae9d6742658e5d0
Author: Pierre Schweitzer 
AuthorDate: Sat Sep 7 23:07:54 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Sep 7 23:07:54 2019 +0200

[MOUNTMGR] Properly return EpicNumber in MountMgrChangeNotify
---
 drivers/filters/mountmgr/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/filters/mountmgr/device.c 
b/drivers/filters/mountmgr/device.c
index 7172a3b5da8..ce8f58ce855 100644
--- a/drivers/filters/mountmgr/device.c
+++ b/drivers/filters/mountmgr/device.c
@@ -57,7 +57,7 @@ MountMgrChangeNotify(IN PDEVICE_EXTENSION DeviceExtension,
 if (DeviceExtension->EpicNumber != ChangeNotify->EpicNumber)
 {
 ChangeNotify->EpicNumber = DeviceExtension->EpicNumber;
-Irp->IoStatus.Information = 0;
+Irp->IoStatus.Information = sizeof(MOUNTMGR_CHANGE_NOTIFY_INFO);
 return STATUS_SUCCESS;
 }
 



[ros-diffs] [reactos] 02/02: [SDK] Workaround MSVC2010 not having _Bool type

2019-09-05 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ddc853a4be9c8ae821149a7ed4f5bbc7c44abbfc

commit ddc853a4be9c8ae821149a7ed4f5bbc7c44abbfc
Author: Pierre Schweitzer 
AuthorDate: Fri Sep 6 08:56:58 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Fri Sep 6 08:56:58 2019 +0200

[SDK] Workaround MSVC2010 not having _Bool type

CORE-16366
---
 sdk/include/crt/stdbool.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/sdk/include/crt/stdbool.h b/sdk/include/crt/stdbool.h
index 5cb66b55d02..497bb493cb6 100644
--- a/sdk/include/crt/stdbool.h
+++ b/sdk/include/crt/stdbool.h
@@ -28,7 +28,11 @@
 
 /* Don't define bool, true, and false in C++, except as a GNU extension. */
 #ifndef __cplusplus
+#if _MSC_VER <= 1600
+#define bool unsigned char
+#else
 #define bool _Bool
+#endif
 #define true 1
 #define false 0
 #elif defined(__GNUC__) && !defined(__STRICT_ANSI__)



[ros-diffs] [reactos] 01/02: [BTRFS] bool must be 1-sized

2019-09-05 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6e3c0d360b58a005f84e8ccf236f2b577a3adb2e

commit 6e3c0d360b58a005f84e8ccf236f2b577a3adb2e
Author: Pierre Schweitzer 
AuthorDate: Fri Sep 6 08:56:26 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Fri Sep 6 08:56:26 2019 +0200

[BTRFS] bool must be 1-sized

CORE-16366
---
 drivers/filesystems/btrfs/btrfs_drv.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/filesystems/btrfs/btrfs_drv.h 
b/drivers/filesystems/btrfs/btrfs_drv.h
index 3af0170e6c9..67cb24902c7 100644
--- a/drivers/filesystems/btrfs/btrfs_drv.h
+++ b/drivers/filesystems/btrfs/btrfs_drv.h
@@ -70,6 +70,10 @@
 #include "btrfs.h"
 #include "btrfsioctl.h"
 
+#ifdef __REACTOS__
+C_ASSERT(sizeof(bool) == 1);
+#endif
+
 #ifdef _DEBUG
 // #define DEBUG_FCB_REFCOUNTS
 // #define DEBUG_LONG_MESSAGES



[ros-diffs] [reactos] 01/02: [MOUNTMGR] Fix QueryPointsFromSymbolicLinkName and make it working

2019-09-05 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=26a31b160ab3db16bf92cc786e9d5ecf080057fe

commit 26a31b160ab3db16bf92cc786e9d5ecf080057fe
Author: Pierre Schweitzer 
AuthorDate: Fri Sep 6 08:28:36 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Fri Sep 6 08:28:36 2019 +0200

[MOUNTMGR] Fix QueryPointsFromSymbolicLinkName and make it working

Select the current stack location for output buffer
And set output size so that buffer gets properly copied to caller
---
 drivers/filters/mountmgr/point.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/filters/mountmgr/point.c b/drivers/filters/mountmgr/point.c
index d63ec3a4592..77fc6fba95f 100644
--- a/drivers/filters/mountmgr/point.c
+++ b/drivers/filters/mountmgr/point.c
@@ -518,7 +518,7 @@ QueryPointsFromSymbolicLinkName(IN PDEVICE_EXTENSION 
DeviceExtension,
 }
 
 /* Get output buffer */
-Stack = IoGetNextIrpStackLocation(Irp);
+Stack = IoGetCurrentIrpStackLocation(Irp);
 MountPoints = (PMOUNTMGR_MOUNT_POINTS)Irp->AssociatedIrp.SystemBuffer;
 
 /* Compute output length */
@@ -528,9 +528,12 @@ QueryPointsFromSymbolicLinkName(IN PDEVICE_EXTENSION 
DeviceExtension,
 /* Give length to allow reallocation */
 MountPoints->Size = sizeof(MOUNTMGR_MOUNT_POINTS) + TotalLength;
 MountPoints->NumberOfMountPoints = 1;
+Irp->IoStatus.Information = sizeof(MOUNTMGR_MOUNT_POINTS) + TotalLength;
 
 if (MountPoints->Size > 
Stack->Parameters.DeviceIoControl.OutputBufferLength)
 {
+Irp->IoStatus.Information = sizeof(MOUNTMGR_MOUNT_POINTS);
+
 return STATUS_BUFFER_OVERFLOW;
 }
 



[ros-diffs] [reactos] 02/02: [MOUNTMGR] Don't overrun output buffer in QueryPointsFromMemory

2019-09-05 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ff19ce934bf35768e3478bf484ed4935bb826eb3

commit ff19ce934bf35768e3478bf484ed4935bb826eb3
Author: Pierre Schweitzer 
AuthorDate: Fri Sep 6 08:30:18 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Fri Sep 6 08:30:18 2019 +0200

[MOUNTMGR] Don't overrun output buffer in QueryPointsFromMemory
---
 drivers/filters/mountmgr/point.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/filters/mountmgr/point.c b/drivers/filters/mountmgr/point.c
index 77fc6fba95f..4c1d843db50 100644
--- a/drivers/filters/mountmgr/point.c
+++ b/drivers/filters/mountmgr/point.c
@@ -342,6 +342,8 @@ QueryPointsFromMemory(IN PDEVICE_EXTENSION DeviceExtension,
 
 if (MountPoints->Size > 
Stack->Parameters.DeviceIoControl.OutputBufferLength)
 {
+Irp->IoStatus.Information = sizeof(MOUNTMGR_MOUNT_POINTS);
+
 return STATUS_BUFFER_OVERFLOW;
 }
 



[ros-diffs] [reactos] 04/04: [MOUNTMGR_APITEST] Add a test suite for the mount manager

2019-09-04 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=16ec2e2aa53b403a9e59ffd7c9db09ce356335e3

commit 16ec2e2aa53b403a9e59ffd7c9db09ce356335e3
Author: Pierre Schweitzer 
AuthorDate: Thu Sep 5 08:35:23 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Thu Sep 5 08:36:20 2019 +0200

[MOUNTMGR_APITEST] Add a test suite for the mount manager

It only tests IOCTL_MOUNTMGR_QUERY_POINTS for now
---
 modules/rostests/apitests/CMakeLists.txt  |  1 +
 modules/rostests/apitests/mountmgr/CMakeLists.txt | 11 +
 modules/rostests/apitests/mountmgr/QueryPoints.c  | 55 +++
 modules/rostests/apitests/mountmgr/precomp.h  | 12 +
 modules/rostests/apitests/mountmgr/testlist.c | 11 +
 5 files changed, 90 insertions(+)

diff --git a/modules/rostests/apitests/CMakeLists.txt 
b/modules/rostests/apitests/CMakeLists.txt
index 5bff8ce7604..1d623104fc7 100644
--- a/modules/rostests/apitests/CMakeLists.txt
+++ b/modules/rostests/apitests/CMakeLists.txt
@@ -19,6 +19,7 @@ if(NOT ARCH STREQUAL "amd64")
 add_subdirectory(kernel32)
 endif()
 add_subdirectory(localspl)
+add_subdirectory(mountmgr)
 add_subdirectory(msgina)
 add_subdirectory(mspatcha)
 add_subdirectory(msvcrt)
diff --git a/modules/rostests/apitests/mountmgr/CMakeLists.txt 
b/modules/rostests/apitests/mountmgr/CMakeLists.txt
new file mode 100644
index 000..73317c628b6
--- /dev/null
+++ b/modules/rostests/apitests/mountmgr/CMakeLists.txt
@@ -0,0 +1,11 @@
+
+list(APPEND SOURCE
+QueryPoints.c
+precomp.h)
+
+add_executable(mountmgr_apitest ${SOURCE} testlist.c)
+target_link_libraries(mountmgr_apitest wine ${PSEH_LIB})
+set_module_type(mountmgr_apitest win32cui)
+add_importlibs(mountmgr_apitest msvcrt kernel32 ntdll)
+add_pch(mountmgr_apitest precomp.h SOURCE)
+add_rostests_file(TARGET mountmgr_apitest)
diff --git a/modules/rostests/apitests/mountmgr/QueryPoints.c 
b/modules/rostests/apitests/mountmgr/QueryPoints.c
new file mode 100644
index 000..b7e6bee3250
--- /dev/null
+++ b/modules/rostests/apitests/mountmgr/QueryPoints.c
@@ -0,0 +1,55 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPLv2+ - See COPYING in the top level directory
+ * PURPOSE: Test for QueryPoints IOCTL
+ * PROGRAMMER:      Pierre Schweitzer
+ */
+
+#include "precomp.h"
+
+START_TEST(QueryPoints)
+{
+BOOL Ret;
+DWORD BytesReturned;
+HANDLE MountMgrHandle;
+MOUNTMGR_MOUNT_POINT SinglePoint;
+MOUNTMGR_MOUNT_POINTS MountPoints;
+PMOUNTMGR_MOUNT_POINTS AllocatedPoints;
+
+MountMgrHandle = CreateFileW(MOUNTMGR_DOS_DEVICE_NAME, 0,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
+ INVALID_HANDLE_VALUE);
+if (MountMgrHandle == INVALID_HANDLE_VALUE)
+{
+win_skip("MountMgr unavailable: %lx\n", GetLastError());
+return;
+}
+
+ZeroMemory(&SinglePoint, sizeof(MOUNTMGR_MOUNT_POINT));
+
+Ret = DeviceIoControl(MountMgrHandle, IOCTL_MOUNTMGR_QUERY_POINTS,
+  &SinglePoint, sizeof(MOUNTMGR_MOUNT_POINT),
+  &MountPoints, sizeof(MOUNTMGR_MOUNT_POINTS),
+  &BytesReturned, NULL);
+ok(Ret == FALSE, "IOCTL unexpectedly succeed\n");
+ok(GetLastError() == ERROR_MORE_DATA, "Unexcepted failure: %lx\n", 
GetLastError());
+
+AllocatedPoints = RtlAllocateHeap(RtlGetProcessHeap(), 0, 
MountPoints.Size);
+if (AllocatedPoints == NULL)
+{
+win_skip("Insufficiant memory\n");
+goto Done;
+}
+
+Ret = DeviceIoControl(MountMgrHandle, IOCTL_MOUNTMGR_QUERY_POINTS,
+  &SinglePoint, sizeof(MOUNTMGR_MOUNT_POINT),
+  AllocatedPoints, MountPoints.Size,
+  &BytesReturned, NULL);
+ok(Ret == TRUE, "IOCTL unexpectedly failed %lx\n", GetLastError());
+
+RtlFreeHeap(RtlGetProcessHeap(), 0, AllocatedPoints);
+
+Done:
+CloseHandle(MountMgrHandle);
+}
diff --git a/modules/rostests/apitests/mountmgr/precomp.h 
b/modules/rostests/apitests/mountmgr/precomp.h
new file mode 100644
index 000..33509fb8083
--- /dev/null
+++ b/modules/rostests/apitests/mountmgr/precomp.h
@@ -0,0 +1,12 @@
+#ifndef _MOUNTMGR_APITEST_PRECOMP_H_
+#define _MOUNTMGR_APITEST_PRECOMP_H_
+
+#define WIN32_NO_STATUS
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#endif /* _MOUNTMGR_APITEST_PRECOMP_H_ */
diff --git a/modules/rostests/apitests/mountmgr/testlist.c 
b/modules/rostests/apitests/mountmgr/testlist.c
new file mode 100644
index 000..ab7c0921a26
--- /dev/null
+++ b/modules/rostests/apitests/mountmgr/testlist.c
@@ -0,0 +1,11 @@
+#define STANDALONE
+#include 
+
+extern void func_QueryPoints(void);
+
+const struct test winetest_testlist[] =
+{
+{ "QueryPoints", func_QueryPoints },
+{ 0, 0 }
+};
+



[ros-diffs] [reactos] 03/04: [MOUNTMGR] Fix QueryPointsFromMemory and make it working

2019-09-04 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d592e00dfa07277b2f27c4f50543c8caacdd1bce

commit d592e00dfa07277b2f27c4f50543c8caacdd1bce
Author: Pierre Schweitzer 
AuthorDate: Thu Sep 5 08:28:56 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Thu Sep 5 08:36:19 2019 +0200

[MOUNTMGR] Fix QueryPointsFromMemory and make it working

Select the current stack location for output buffer
And set output size so that buffer gets properly copied to caller
---
 drivers/filters/mountmgr/point.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/filters/mountmgr/point.c b/drivers/filters/mountmgr/point.c
index d9a468f32c2..d63ec3a4592 100644
--- a/drivers/filters/mountmgr/point.c
+++ b/drivers/filters/mountmgr/point.c
@@ -332,12 +332,13 @@ QueryPointsFromMemory(IN PDEVICE_EXTENSION 
DeviceExtension,
 }
 
 /* Now, ensure output buffer can hold everything */
-Stack = IoGetNextIrpStackLocation(Irp);
+Stack = IoGetCurrentIrpStackLocation(Irp);
 MountPoints = (PMOUNTMGR_MOUNT_POINTS)Irp->AssociatedIrp.SystemBuffer;
 
 /* Ensure we set output to let user reallocate! */
 MountPoints->Size = sizeof(MOUNTMGR_MOUNT_POINTS) + TotalSize;
 MountPoints->NumberOfMountPoints = TotalSymLinks;
+Irp->IoStatus.Information = sizeof(MOUNTMGR_MOUNT_POINTS) + TotalSize;
 
 if (MountPoints->Size > 
Stack->Parameters.DeviceIoControl.OutputBufferLength)
 {



[ros-diffs] [reactos] 02/04: [MOUNTMGR] Properly validate input buffer size

2019-09-04 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=70d29ec4238e830a84a4b6d41a0ee3eafe9fcbd5

commit 70d29ec4238e830a84a4b6d41a0ee3eafe9fcbd5
Author: Pierre Schweitzer 
AuthorDate: Thu Sep 5 08:22:59 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Thu Sep 5 08:36:19 2019 +0200

[MOUNTMGR] Properly validate input buffer size

This avoids IOCTL_MOUNTMGR_QUERY_POINTS always failing
---
 drivers/filters/mountmgr/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/filters/mountmgr/device.c 
b/drivers/filters/mountmgr/device.c
index 17d720e346c..7172a3b5da8 100644
--- a/drivers/filters/mountmgr/device.c
+++ b/drivers/filters/mountmgr/device.c
@@ -1745,7 +1745,7 @@ MountMgrQueryPoints(IN PDEVICE_EXTENSION DeviceExtension,
 
 /* We can't go beyond */
 if (((ULONG)MountPoint->SymbolicLinkNameLength + 
MountPoint->UniqueIdLength +
-MountPoint->DeviceNameLength) < 
Stack->Parameters.DeviceIoControl.InputBufferLength)
+MountPoint->DeviceNameLength) > 
Stack->Parameters.DeviceIoControl.InputBufferLength)
 {
 return STATUS_INVALID_PARAMETER;
 }



[ros-diffs] [reactos] 01/04: [MOUNTMGR] Fix global symbolic link creations

2019-09-04 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=77657c22c950dc1d5404df1cac7ce06e0cf8fa24

commit 77657c22c950dc1d5404df1cac7ce06e0cf8fa24
Author: Pierre Schweitzer 
AuthorDate: Wed Sep 4 23:47:26 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Thu Sep 5 08:36:19 2019 +0200

[MOUNTMGR] Fix global symbolic link creations

They were wrongly pointing to the original target once rewritten
instead of pointing to the proper target: the device.

This notably fixes opening the MountMgr device from user
mode (to perform IOCTL calls, for instance), and might
also fix various bugs dealing with global namespaces.
This might have some various effects in ReactOS~.
---
 drivers/filters/mountmgr/symlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/filters/mountmgr/symlink.c 
b/drivers/filters/mountmgr/symlink.c
index 061e6717e77..254eb2fb452 100644
--- a/drivers/filters/mountmgr/symlink.c
+++ b/drivers/filters/mountmgr/symlink.c
@@ -124,7 +124,7 @@ GlobalCreateSymbolicLink(IN PUNICODE_STRING DosName,
 }
 
 /* Then, create the symlink */
-Status = IoCreateSymbolicLink(&GlobalName, DosName);
+Status = IoCreateSymbolicLink(&GlobalName, DeviceName);
 
 FreePool(GlobalName.Buffer);
 



[ros-diffs] [reactos] 01/01: [BTRFS] Fix fileinfo.c build

2019-09-02 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=dcd463ba986038d374114ad246c6d276e0c0798b

commit dcd463ba986038d374114ad246c6d276e0c0798b
Author: Pierre Schweitzer 
AuthorDate: Mon Sep 2 22:17:17 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Sep 2 22:17:17 2019 +0200

[BTRFS] Fix fileinfo.c build
---
 drivers/filesystems/btrfs/fileinfo.c | 44 
 1 file changed, 44 insertions(+)

diff --git a/drivers/filesystems/btrfs/fileinfo.c 
b/drivers/filesystems/btrfs/fileinfo.c
index 6defcb1e512..445f4948e59 100644
--- a/drivers/filesystems/btrfs/fileinfo.c
+++ b/drivers/filesystems/btrfs/fileinfo.c
@@ -17,6 +17,7 @@
 
 #include "btrfs_drv.h"
 
+#if (NTDDI_VERSION >= NTDDI_WIN10)
 // not currently in mingw - introduced with Windows 10
 #ifndef _MSC_VER
 #define FileIdInformation (enum _FILE_INFORMATION_CLASS)59
@@ -145,6 +146,45 @@ typedef struct _FILE_LINKS_FULL_ID_INFORMATION {
 #define FILE_RENAME_INFORMATION_EX FILE_RENAME_INFORMATION
 #define FILE_LINK_INFORMATION_EX FILE_LINK_INFORMATION
 
+#endif
+#endif
+
+#ifdef __REACTOS__
+typedef struct _FILE_RENAME_INFORMATION_EX {
+union {
+BOOLEAN ReplaceIfExists;
+ULONG Flags;
+};
+HANDLE RootDirectory;
+ULONG FileNameLength;
+WCHAR FileName[1];
+} FILE_RENAME_INFORMATION_EX, *PFILE_RENAME_INFORMATION_EX;
+
+typedef struct _FILE_DISPOSITION_INFORMATION_EX {
+ULONG Flags;
+} FILE_DISPOSITION_INFORMATION_EX, *PFILE_DISPOSITION_INFORMATION_EX;
+
+typedef struct _FILE_LINK_INFORMATION_EX {
+union {
+BOOLEAN ReplaceIfExists;
+ULONG Flags;
+};
+HANDLE RootDirectory;
+ULONG FileNameLength;
+WCHAR FileName[1];
+} FILE_LINK_INFORMATION_EX, *PFILE_LINK_INFORMATION_EX;
+
+#define FILE_RENAME_REPLACE_IF_EXISTS   0x001
+#define FILE_RENAME_POSIX_SEMANTICS 0x002
+#define FILE_RENAME_IGNORE_READONLY_ATTRIBUTE   0x040
+
+#define FILE_DISPOSITION_DELETE 0x1
+#define FILE_DISPOSITION_POSIX_SEMANTICS0x2
+#define FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK  0x4
+
+#define FILE_LINK_REPLACE_IF_EXISTS   0x001
+#define FILE_LINK_POSIX_SEMANTICS 0x002
+#define FILE_LINK_IGNORE_READONLY_ATTRIBUTE   0x040
 #endif
 
 static NTSTATUS set_basic_information(device_extension* Vcb, PIRP Irp, 
PFILE_OBJECT FileObject) {
@@ -2826,7 +2866,11 @@ NTSTATUS __stdcall drv_set_information(IN PDEVICE_OBJECT 
DeviceObject, IN PIRP I
 }
 
 if (fcb != Vcb->dummy_fcb && is_subvol_readonly(fcb->subvol, Irp) && 
IrpSp->Parameters.SetFile.FileInformationClass != FilePositionInformation &&
+#ifndef __REACTOS__
 (fcb->inode != SUBVOL_ROOT_INODE || 
(IrpSp->Parameters.SetFile.FileInformationClass != FileBasicInformation && 
IrpSp->Parameters.SetFile.FileInformationClass != FileRenameInformation && 
IrpSp->Parameters.SetFile.FileInformationClass != FileRenameInformationEx))) {
+#else
+(fcb->inode != SUBVOL_ROOT_INODE || 
(IrpSp->Parameters.SetFile.FileInformationClass != FileBasicInformation && 
IrpSp->Parameters.SetFile.FileInformationClass != FileRenameInformation))) {
+#endif
 Status = STATUS_ACCESS_DENIED;
 goto end;
 }



[ros-diffs] [reactos] 01/01: [BTRFS] Fix create.c build

2019-09-02 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=021e25f2495a511e81da724e4c3d789d2bb8aa21

commit 021e25f2495a511e81da724e4c3d789d2bb8aa21
Author: Pierre Schweitzer 
AuthorDate: Mon Sep 2 22:02:45 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Sep 2 22:02:45 2019 +0200

[BTRFS] Fix create.c build
---
 drivers/filesystems/btrfs/btrfs_drv.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/filesystems/btrfs/btrfs_drv.h 
b/drivers/filesystems/btrfs/btrfs_drv.h
index d8397367515..3af0170e6c9 100644
--- a/drivers/filesystems/btrfs/btrfs_drv.h
+++ b/drivers/filesystems/btrfs/btrfs_drv.h
@@ -144,11 +144,9 @@
 #define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL 0x0002
 #endif
 
-#ifndef _MSC_VER
 typedef struct _FILE_ID_128 {
 UCHAR Identifier[16];
 } FILE_ID_128, *PFILE_ID_128;
-#endif
 
 typedef struct _DUPLICATE_EXTENTS_DATA {
 HANDLE FileHandle;
@@ -1820,6 +1818,7 @@ typedef struct _PEB {
 PVOID Reserved7[1];
 ULONG SessionId;
 } PEB,*PPEB;
+#endif
 
 #ifdef _MSC_VER
 __kernel_entry
@@ -1831,4 +1830,3 @@ NTSTATUS NTAPI ZwQueryInformationProcess(
 OUT PULONG ReturnLength OPTIONAL
 );
 #endif
-#endif



[ros-diffs] [reactos] 01/01: [BTRFS] Fix dirctl.c build

2019-09-02 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fe0a6c9be481780d1d25451f47e023f1bcf4b4fa

commit fe0a6c9be481780d1d25451f47e023f1bcf4b4fa
Author: Pierre Schweitzer 
AuthorDate: Mon Sep 2 21:48:54 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Sep 2 21:48:54 2019 +0200

[BTRFS] Fix dirctl.c build
---
 drivers/filesystems/btrfs/dirctrl.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/filesystems/btrfs/dirctrl.c 
b/drivers/filesystems/btrfs/dirctrl.c
index 2e324e4f6d2..41a68268add 100644
--- a/drivers/filesystems/btrfs/dirctrl.c
+++ b/drivers/filesystems/btrfs/dirctrl.c
@@ -17,6 +17,7 @@
 
 #include "btrfs_drv.h"
 
+#ifndef __REACTOS__
 // not currently in mingw
 #ifndef _MSC_VER
 #define FileIdExtdDirectoryInformation (enum _FILE_INFORMATION_CLASS)60
@@ -58,6 +59,10 @@ typedef struct _FILE_ID_EXTD_BOTH_DIR_INFORMATION {
 WCHAR FileName[1];
 } FILE_ID_EXTD_BOTH_DIR_INFORMATION, *PFILE_ID_EXTD_BOTH_DIR_INFORMATION;
 
+#endif
+#else
+#define FileIdExtdDirectoryInformation (enum _FILE_INFORMATION_CLASS)60
+#define FileIdExtdBothDirectoryInformation (enum _FILE_INFORMATION_CLASS)63
 #endif
 
 enum DirEntryType {
@@ -516,6 +521,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* 
buf, LONG* len, PIRP Ir
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wswitch"
 #endif
+#if (NTDDI_VERSION >= NTDDI_VISTA)
 case FileIdExtdDirectoryInformation:
 {
 FILE_ID_EXTD_DIR_INFORMATION* fiedi = buf;
@@ -603,6 +609,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* 
buf, LONG* len, PIRP Ir
 
 return STATUS_SUCCESS;
 }
+#endif
 
 #ifndef _MSC_VER
 #pragma GCC diagnostic pop



[ros-diffs] [reactos] 03/03: [UBTRFS] Upgrade to 1.4

2019-09-02 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=255ef2c332fc6226df4311e14f3344e8d79a1788

commit 255ef2c332fc6226df4311e14f3344e8d79a1788
Author: Pierre Schweitzer 
AuthorDate: Mon Sep 2 08:18:48 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Sep 2 08:19:49 2019 +0200

[UBTRFS] Upgrade to 1.4

CORE-16354
---
 dll/win32/ubtrfs/ubtrfs.rc|   8 +-
 media/doc/README.FSD  |   2 +-
 sdk/lib/fslib/btrfslib/btrfslib.c | 297 --
 3 files changed, 95 insertions(+), 212 deletions(-)

diff --git a/dll/win32/ubtrfs/ubtrfs.rc b/dll/win32/ubtrfs/ubtrfs.rc
index 2fbce14c1f1..1292452a5cd 100644
--- a/dll/win32/ubtrfs/ubtrfs.rc
+++ b/dll/win32/ubtrfs/ubtrfs.rc
@@ -51,8 +51,8 @@ END
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,3,0,0
- PRODUCTVERSION 1,3,0,0
+ FILEVERSION 1,4,0,0
+ PRODUCTVERSION 1,4,0,0
  FILEFLAGSMASK 0x17L
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -68,12 +68,12 @@ BEGIN
 BLOCK "080904b0"
 BEGIN
 VALUE "FileDescription", "Btrfs utility DLL"
-VALUE "FileVersion", "1.3"
+VALUE "FileVersion", "1.4"
 VALUE "InternalName", "ubtrfs"
 VALUE "LegalCopyright", "Copyright (c) Mark Harmstone 2016-19"
 VALUE "OriginalFilename", "ubtrfs.dll"
 VALUE "ProductName", "WinBtrfs"
-VALUE "ProductVersion", "1.3"
+VALUE "ProductVersion", "1.4"
 END
 END
 BLOCK "VarFileInfo"
diff --git a/media/doc/README.FSD b/media/doc/README.FSD
index c9e05141216..534e264b010 100644
--- a/media/doc/README.FSD
+++ b/media/doc/README.FSD
@@ -5,7 +5,7 @@ The following FSD are shared with: 
https://github.com/maharmstone/btrfs.
 
 reactos/drivers/filesystems/btrfs   # Synced to 1.4
 reactos/dll/shellext/shellbtrfs # Synced to 1.1
-reactos/sdk/lib/fslib/btrfslib  # Synced to 1.3
+reactos/sdk/lib/fslib/btrfslib  # Synced to 1.4
 
 The following FSD are shared with: http://www.ext2fsd.com/
 
diff --git a/sdk/lib/fslib/btrfslib/btrfslib.c 
b/sdk/lib/fslib/btrfslib/btrfslib.c
index 902e80893ca..ec9fe387037 100644
--- a/sdk/lib/fslib/btrfslib/btrfslib.c
+++ b/sdk/lib/fslib/btrfslib/btrfslib.c
@@ -36,9 +36,11 @@
 #include 
 #include 
 #ifdef __REACTOS__
+#include 
 #include "btrfs.h"
 #include "btrfsioctl.h"
 #else
+#include 
 #include "../btrfs.h"
 #include "../btrfsioctl.h"
 #endif
@@ -62,9 +64,6 @@ NTSTATUS NTAPI NtWriteFile(HANDLE FileHandle, HANDLE Event, 
PIO_APC_ROUTINE ApcR
 
 NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE 
ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer,
   ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key);
-
-NTSYSAPI NTSTATUS NTAPI RtlUnicodeToUTF8N(PCHAR UTF8StringDestination, ULONG 
UTF8StringMaxByteCount, PULONG UTF8StringActualByteCount,
-  PCWCH UnicodeStringSource, ULONG  
UnicodeStringByteCount);
 #ifdef __cplusplus
 }
 #endif
@@ -89,9 +88,9 @@ typedef struct {
 #define FORMAT_FLAG_INTEGRITY_DISABLE   0x0100
 
 typedef struct {
-UINT16 unk1;
-UINT16 unk2;
-UINT32 flags;
+uint16_t unk1;
+uint16_t unk2;
+uint32_t flags;
 DSTRING* label;
 } options;
 
@@ -111,33 +110,27 @@ FORCEINLINE VOID InsertTailList(PLIST_ENTRY ListHead, 
PLIST_ENTRY Entry) {
 }
 #endif
 
-#if defined(__REACTOS__) && (NTDDI_VERSION < NTDDI_WIN7)
-NTSTATUS NTAPI RtlUnicodeToUTF8N(CHAR *utf8_dest, ULONG utf8_bytes_max,
- ULONG *utf8_bytes_written,
- const WCHAR *uni_src, ULONG uni_bytes);
-#endif /* defined(__REACTOS__) && (NTDDI_VERSION < NTDDI_WIN7) */
-
 #ifdef __REACTOS__
 ULONG NTAPI NtGetTickCount(VOID);
 #endif
 
 typedef struct {
 KEY key;
-UINT16 size;
+uint16_t size;
 void* data;
 LIST_ENTRY list_entry;
 } btrfs_item;
 
 typedef struct {
-UINT64 offset;
+uint64_t offset;
 CHUNK_ITEM* chunk_item;
-UINT64 lastoff;
-UINT64 used;
+uint64_t lastoff;
+uint64_t used;
 LIST_ENTRY list_entry;
 } btrfs_chunk;
 
 typedef struct {
-UINT64 id;
+uint64_t id;
 tree_header header;
 btrfs_chunk* c;
 LIST_ENTRY items;
@@ -146,7 +139,7 @@ typedef struct {
 
 typedef struct {
 DEV_ITEM dev_item;
-UINT64 last_alloc;
+uint64_t last_alloc;
 } btrfs_dev;
 
 #define keycmp(key1, key2)\
@@ -160,7 +153,7 @@ typedef struct {
 
 HMODULE module;
 ULONG def_sector_size = 0, def_node_size = 0;
-UINT64 def_incompat_flags = BTRFS_INCOMPAT_FLAGS_EXTENDED_IREF | 
BTRFS_INCOMPAT_FLAGS_SKINNY_METADATA;
+uint64_t def_incompat_flags = BTRFS_INCOMPAT_FLAGS_EXTEN

[ros-diffs] [reactos] 01/03: [CRT] Import stdbool.h from CLANG

2019-09-02 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a0592b71e9883a8995b46dedbcab25c5c07e2c90

commit a0592b71e9883a8995b46dedbcab25c5c07e2c90
Author: Pierre Schweitzer 
AuthorDate: Sun Sep 1 14:52:04 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Sep 2 08:19:48 2019 +0200

[CRT] Import stdbool.h from CLANG

CORE-16354
---
 sdk/include/crt/stdbool.h | 47 +++
 1 file changed, 47 insertions(+)

diff --git a/sdk/include/crt/stdbool.h b/sdk/include/crt/stdbool.h
new file mode 100644
index 000..5cb66b55d02
--- /dev/null
+++ b/sdk/include/crt/stdbool.h
@@ -0,0 +1,47 @@
+/*=== stdbool.h - Standard header for booleans -===
+ *
+ * Copyright (c) 2008 Eli Friedman
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+
+#ifndef __STDBOOL_H
+#define __STDBOOL_H
+
+/* Don't define bool, true, and false in C++, except as a GNU extension. */
+#ifndef __cplusplus
+#define bool _Bool
+#define true 1
+#define false 0
+#elif defined(__GNUC__) && !defined(__STRICT_ANSI__)
+/* Define _Bool as a GNU extension. */
+#define _Bool bool
+#if __cplusplus < 201103L
+/* For C++98, define bool, false, true as a GNU extension. */
+#define bool  bool
+#define false false
+#define true  true
+#endif
+#endif
+
+#define __bool_true_false_are_defined 1
+
+#endif /* __STDBOOL_H */



[ros-diffs] [reactos] 01/01: [UTILMAN] Meh

2019-08-19 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=db4b34a046ee0dd23e497fd0a47ec5ce771e870b

commit db4b34a046ee0dd23e497fd0a47ec5ce771e870b
Author: Pierre Schweitzer 
AuthorDate: Mon Aug 19 19:46:08 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Aug 19 19:46:08 2019 +0200

[UTILMAN] Meh
---
 base/applications/utilman/lang/fr-FR.rc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/base/applications/utilman/lang/fr-FR.rc 
b/base/applications/utilman/lang/fr-FR.rc
index 6f17a5c83ee..f5c79a3f98d 100644
--- a/base/applications/utilman/lang/fr-FR.rc
+++ b/base/applications/utilman/lang/fr-FR.rc
@@ -18,7 +18,7 @@ BEGIN
 CONTROL "Démarrer", IDC_START, "Button", BS_PUSHBUTTON | WS_CHILD | 
WS_VISIBLE | WS_TABSTOP, 14, 76, 45, 16
 CONTROL "Arrêter", IDC_STOP, "Button", BS_PUSHBUTTON | WS_CHILD | 
WS_VISIBLE | WS_TABSTOP, 69, 76, 45, 16
 CONTROL "Démarrer automatiquement quand je me connecte", IDC_START_LOG_IN, 
"Button", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_TABSTOP, 12, 
101, 206, 14 
-CONTROL "Démarrer automatiquement quand je suis sur le bureau", 
IDC_START_DESKTOP, "Button", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_DISABLED 
| WS_TABSTOP, 12, 118, 212, 14 
+CONTROL "Démarrer automatiquement quand je verrouille mon bureau", 
IDC_START_DESKTOP, "Button", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_DISABLED 
| WS_TABSTOP, 12, 118, 212, 14
 CONTROL "Démarrer automatiquement quand le gestionnaire démarre", 
IDC_START_UTILMAN, "Button", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_DISABLED 
| WS_TABSTOP, 12, 134, 212, 13 
 CONTROL "&OK", IDC_OK, "Button", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE 
| WS_TABSTOP, 160, 161, 50, 14 
 CONTROL "&Annuler", IDC_CANCEL, "Button", BS_PUSHBUTTON | WS_CHILD | 
WS_VISIBLE | WS_TABSTOP, 221, 161, 50, 14 



[ros-diffs] [reactos] 01/01: [UTILMAN] Add French translation

2019-08-19 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a8351727b599eb1668297e9bf457069f43bdb3f6

commit a8351727b599eb1668297e9bf457069f43bdb3f6
Author: Pierre Schweitzer 
AuthorDate: Mon Aug 19 13:42:52 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Aug 19 13:42:52 2019 +0200

[UTILMAN] Add French translation
---
 base/applications/utilman/lang/fr-FR.rc | 54 +
 base/applications/utilman/utilman.rc|  3 ++
 media/inf/shortcuts.inf |  2 ++
 3 files changed, 59 insertions(+)

diff --git a/base/applications/utilman/lang/fr-FR.rc 
b/base/applications/utilman/lang/fr-FR.rc
new file mode 100644
index 000..78c95eb9315
--- /dev/null
+++ b/base/applications/utilman/lang/fr-FR.rc
@@ -0,0 +1,54 @@
+/*
+ * PROJECT: ReactOS Utility Manager (Accessibility)
+ * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
+ * PURPOSE: French (France) translation resource
+ * COPYRIGHT:   Copyright 2019 Pierre Schweitzer (pie...@reactos.org)
+ */
+
+IDD_MAIN_DIALOG DIALOGEX 0, 0, 284, 183
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_CONTEXTHELP
+CAPTION "Gestionnaire d'utilitaires d'accessibilité"
+LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
+FONT 8, "MS Shell Dlg"
+BEGIN
+LISTBOX IDC_LISTBOX, 4, 4, 273, 56, LBS_STANDARD | WS_CHILD | WS_VISIBLE | 
WS_TABSTOP | WS_BORDER
+CONTROL "", IDC_GROUPBOX, "Button", BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 
3, 62, 275, 92
+CONTROL "Démarrer", IDC_START, "Button", BS_PUSHBUTTON | WS_CHILD | 
WS_VISIBLE | WS_TABSTOP, 14, 76, 45, 16
+CONTROL "Arrêter", IDC_STOP, "Button", BS_PUSHBUTTON | WS_CHILD | 
WS_VISIBLE | WS_TABSTOP, 69, 76, 45, 16
+CONTROL "Démarrer automatiquement quand je me connecte", IDC_START_LOG_IN, 
"Button", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_TABSTOP, 12, 
101, 206, 14 
+CONTROL "Démarrer automatiquement quand je suis sur le bureau", 
IDC_START_DESKTOP, "Button", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_DISABLED 
| WS_TABSTOP, 12, 118, 212, 14 
+CONTROL "Démarrer automatiquement quand le gestionnaire démarre", 
IDC_START_UTILMAN, "Button", BS_CHECKBOX | WS_CHILD | WS_VISIBLE | WS_DISABLED 
| WS_TABSTOP, 12, 134, 212, 13 
+CONTROL "&OK", IDC_OK, "Button", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE 
| WS_TABSTOP, 160, 161, 50, 14 
+CONTROL "&Annuler", IDC_CANCEL, "Button", BS_PUSHBUTTON | WS_CHILD | 
WS_VISIBLE | WS_TABSTOP, 221, 161, 50, 14 
+CONTROL "&Aide", IDC_HELP_TOPICS, "Button", BS_PUSHBUTTON | WS_CHILD | 
WS_VISIBLE | WS_DISABLED | WS_TABSTOP, 98, 161, 50, 14 
+END
+
+IDD_ABOUT_DIALOG DIALOGEX 22, 16, 210, 65
+CAPTION "A propos du gestionnaire d'utilitaires d'accessibilité"
+FONT 8, "MS Shell Dlg", 0, 0
+STYLE DS_SHELLFONT | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | DS_MODALFRAME
+BEGIN
+ICON IDI_ICON_UTILMAN, IDC_STATIC, 10, 10, 7, 30
+LTEXT "Accessibility Utility Manager\nCopyright (C) 2019 George Bișoc 
(fraizeraust99 at gmail dot com)", IDC_STATIC, 48, 7, 150, 36
+LTEXT "Copyright (C) 2019 Hermes Belusca-Maito", IDC_STATIC, 48, 33, 150, 
36
+PUSHBUTTON "Close", IDOK, 75, 47, 44, 15
+END
+
+STRINGTABLE
+BEGIN
+IDS_OSK "Clavier visuel"
+IDS_MAGNIFIER "Loupe"
+END
+
+STRINGTABLE
+BEGIN
+IDS_NOTRUNNING "%s n'est pas en cours d'exécution"
+IDS_RUNNING "%s est en cours d'exécution"
+IDS_GROUPBOX_OPTIONS_TITLE "Options pour %s"
+END
+
+STRINGTABLE
+BEGIN
+IDM_ABOUT "A propos du gestionnaire d'utilitaires d'accessibilité..."
+END
diff --git a/base/applications/utilman/utilman.rc 
b/base/applications/utilman/utilman.rc
index 50bfa4d710c..02fa4614aa7 100644
--- a/base/applications/utilman/utilman.rc
+++ b/base/applications/utilman/utilman.rc
@@ -28,5 +28,8 @@ IDI_ICON_UTILMAN ICON "res/utilman.ico"
 #ifdef LANGUAGE_EN_US
 #include "lang/en-US.rc"
 #endif
+#ifdef LANGUAGE_FR_FR
+#include "lang/fr-FR.rc"
+#endif
 
 /* EOF */
diff --git a/media/inf/shortcuts.inf b/media/inf/shortcuts.inf
index cc59005e55d..d3c0eb8aa3f 100644
--- a/media/inf/shortcuts.inf
+++ b/media/inf/shortcuts.inf
@@ -579,6 +579,8 @@ WINMINE_TITLE=WineMine
 WINMINE_DESC=WineMine
 SPIDER_TITLE=Spider Solitaire
 SPIDER_DESC=Spider Solitaire
+UTILMAN_TITLE=Gestionnaire d'utilitaires d'accessibilité
+UTILMAN_DESC=Lance le gestionnaire d'utilitaires d'accessibilité
 
 ; Hebrew
 [Strings.040D]



[ros-diffs] [reactos] 01/01: [NTOSKRNL] Handle symlink parsing when it's bound to a specific object

2019-08-19 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e12abf63c53670009f6843fa705ab7d392b66cf9

commit e12abf63c53670009f6843fa705ab7d392b66cf9
Author: Pierre Schweitzer 
AuthorDate: Mon Aug 19 10:44:56 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Aug 19 10:45:50 2019 +0200

[NTOSKRNL] Handle symlink parsing when it's bound to a specific object
---
 ntoskrnl/ob/oblink.c | 94 +++-
 1 file changed, 93 insertions(+), 1 deletion(-)

diff --git a/ntoskrnl/ob/oblink.c b/ntoskrnl/ob/oblink.c
index 712143e1ed7..67cb36385dd 100644
--- a/ntoskrnl/ob/oblink.c
+++ b/ntoskrnl/ob/oblink.c
@@ -5,6 +5,7 @@
 * PURPOSE: Implements symbolic links
 * PROGRAMMERS: Alex Ionescu (a...@relsoft.net)
 *  David Welch (we...@mcmail.com)
+*  Pierre Schweitzer
 */
 
 /* INCLUDES */
@@ -481,7 +482,98 @@ ObpParseSymbolicLink(IN PVOID ParsedObject,
 /* Check if this symlink is bound to a specific object */
 if (SymlinkObject->LinkTargetObject)
 {
-UNIMPLEMENTED;
+/* No name to reparse, directly reparse the object */
+if (!SymlinkObject->LinkTargetRemaining.Length)
+{
+*NextObject = SymlinkObject->LinkTargetObject;
+return STATUS_REPARSE_OBJECT;
+}
+
+TempLength = SymlinkObject->LinkTargetRemaining.Length;
+/* The target and remaining names aren't empty, so check for slashes */
+if (SymlinkObject->LinkTargetRemaining.Buffer[TempLength / 
sizeof(WCHAR) - 1] == OBJ_NAME_PATH_SEPARATOR &&
+RemainingName->Buffer[0] == OBJ_NAME_PATH_SEPARATOR)
+{
+/* Reduce the length by one to cut off the extra '\' */
+TempLength -= sizeof(OBJ_NAME_PATH_SEPARATOR);
+}
+
+/* Calculate the new length */
+LengthUsed = TempLength + RemainingName->Length;
+LengthUsed += (sizeof(WCHAR) * (RemainingName->Buffer - 
FullPath->Buffer));
+
+/* Check if it's not too much */
+if (LengthUsed > 0xFFF0)
+return STATUS_NAME_TOO_LONG;
+
+/* If FullPath is enough, use it */
+if (FullPath->MaximumLength > LengthUsed)
+{
+/* Update remaining length if appropriate */
+if (RemainingName->Length)
+{
+RtlMoveMemory((PVOID)((ULONG_PTR)RemainingName->Buffer + 
TempLength),
+  RemainingName->Buffer,
+  RemainingName->Length);
+}
+
+/* And move the target object name */
+RtlCopyMemory(RemainingName->Buffer,
+  SymlinkObject->LinkTargetRemaining.Buffer,
+  TempLength);
+
+/* Finally update the full path with what we parsed */
+FullPath->Length += SymlinkObject->LinkTargetRemaining.Length;
+RemainingName->Length += SymlinkObject->LinkTargetRemaining.Length;
+RemainingName->MaximumLength += RemainingName->Length + 
sizeof(WCHAR);
+FullPath->Buffer[FullPath->Length / sizeof(WCHAR)] = UNICODE_NULL;
+
+/* And reparse */
+*NextObject = SymlinkObject->LinkTargetObject;
+return STATUS_REPARSE_OBJECT;
+}
+
+/* FullPath is not enough, we'll have to reallocate */
+MaximumLength = LengthUsed + sizeof(WCHAR);
+NewTargetPath = ExAllocatePoolWithTag(NonPagedPool,
+  MaximumLength,
+  OB_NAME_TAG);
+if (!NewTargetPath) return STATUS_INSUFFICIENT_RESOURCES;
+
+/* Copy path begin */
+RtlCopyMemory(NewTargetPath,
+  FullPath->Buffer,
+  sizeof(WCHAR) * (RemainingName->Buffer - 
FullPath->Buffer));
+
+/* Copy path end (if any) */
+if (RemainingName->Length)
+{
+
RtlCopyMemory((PVOID)((ULONG_PTR)&NewTargetPath[RemainingName->Buffer - 
FullPath->Buffer] + TempLength),
+  RemainingName->Buffer,
+  RemainingName->Length);
+}
+
+/* And finish path with bound object */
+RtlCopyMemory(&NewTargetPath[RemainingName->Buffer - FullPath->Buffer],
+  SymlinkObject->LinkTargetRemaining.Buffer,
+  TempLength);
+
+/* Free old buffer */
+ExFreePool(FullPath->Buffer);
+
+/* Set new buffer in FullPath */
+FullPath->Buffer = NewTargetPath;
+FullPath->MaximumLength = MaximumLength;
+FullPath->Length = LengthUsed;
+
+/* Update remaining with what we handled */
+RemainingName->Length = Leng

[ros-diffs] [reactos] 01/01: [SDK] As sole author of the file, relicense it as LPGL

2019-08-16 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2faee11672366e9b028a382e24cc55fa267b7356

commit 2faee11672366e9b028a382e24cc55fa267b7356
Author: Pierre Schweitzer 
AuthorDate: Fri Aug 16 19:54:44 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Fri Aug 16 19:54:44 2019 +0200

[SDK] As sole author of the file, relicense it as LPGL

It allows third party developers (such as Mark Harmstone :-)) to use it
---
 sdk/lib/drivers/ntoskrnl_vista/fsrtl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sdk/lib/drivers/ntoskrnl_vista/fsrtl.c 
b/sdk/lib/drivers/ntoskrnl_vista/fsrtl.c
index 8b714af57aa..8072ee00135 100644
--- a/sdk/lib/drivers/ntoskrnl_vista/fsrtl.c
+++ b/sdk/lib/drivers/ntoskrnl_vista/fsrtl.c
@@ -1,6 +1,6 @@
 /*
  * PROJECT: ReactOS Kernel - Vista+ APIs
- * LICENSE: GPL v2 - See COPYING in the top level directory
+ * LICENSE: LGPL-2.1-or-later 
(https://spdx.org/licenses/LGPL-2.1-or-later)
  * FILE:lib/drivers/ntoskrnl_vista/fsrtl.c
  * PURPOSE: FsRtl functions of Vista+
  * PROGRAMMERS: Pierre Schweitzer 



[ros-diffs] [reactos] 01/01: [SMSS] Use the appropriate security descriptor when creating the LPC port

2019-08-03 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d49a53ca99397d7154898ac1d2c8c804f6ef598e

commit d49a53ca99397d7154898ac1d2c8c804f6ef598e
Author: Pierre Schweitzer 
AuthorDate: Sat Aug 3 21:55:28 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Aug 3 21:56:15 2019 +0200

[SMSS] Use the appropriate security descriptor when creating the LPC port
---
 base/system/smss/sminit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/base/system/smss/sminit.c b/base/system/smss/sminit.c
index 49141ff2d0d..056176aa426 100644
--- a/base/system/smss/sminit.c
+++ b/base/system/smss/sminit.c
@@ -2441,7 +2441,7 @@ SmpInit(IN PUNICODE_STRING InitialCommand,
 
 /* Create the SM API Port */
 RtlInitUnicodeString(&PortName, L"\\SmApiPort");
-InitializeObjectAttributes(&ObjectAttributes, &PortName, 0, NULL, NULL);
+InitializeObjectAttributes(&ObjectAttributes, &PortName, 0, NULL, 
SmpApiPortSecurityDescriptor);
 Status = NtCreatePort(&PortHandle,
   &ObjectAttributes,
   sizeof(SB_CONNECTION_INFO),



[ros-diffs] [reactos] 01/01: [KMTESTS:CC] Make buffer mapping tests more accurate

2019-07-03 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=56c4e83fb3c05d92b80d0459d847b5c76a4d0d39

commit 56c4e83fb3c05d92b80d0459d847b5c76a4d0d39
Author: Pierre Schweitzer 
AuthorDate: Wed Jul 3 21:38:37 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Wed Jul 3 21:39:35 2019 +0200

[KMTESTS:CC] Make buffer mapping tests more accurate
---
 modules/rostests/kmtests/ntos_cc/CcMapData_drv.c | 57 ---
 modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c | 58 +---
 2 files changed, 101 insertions(+), 14 deletions(-)

diff --git a/modules/rostests/kmtests/ntos_cc/CcMapData_drv.c 
b/modules/rostests/kmtests/ntos_cc/CcMapData_drv.c
index 5f7dc934694..12e8286b936 100644
--- a/modules/rostests/kmtests/ntos_cc/CcMapData_drv.c
+++ b/modules/rostests/kmtests/ntos_cc/CcMapData_drv.c
@@ -32,6 +32,8 @@ static PFILE_OBJECT TestFileObject;
 static PDEVICE_OBJECT TestDeviceObject;
 static KMT_IRP_HANDLER TestIrpHandler;
 static KMT_MESSAGE_HANDLER TestMessageHandler;
+static ULONGLONG Memory = 0;
+static BOOLEAN TS = FALSE;
 
 NTSTATUS
 TestEntry(
@@ -40,7 +42,10 @@ TestEntry(
 _Out_ PCWSTR *DeviceName,
 _Inout_ INT *Flags)
 {
+ULONG Length;
+SYSTEM_BASIC_INFORMATION SBI;
 NTSTATUS Status = STATUS_SUCCESS;
+RTL_OSVERSIONINFOEXW VersionInfo;
 
 PAGED_CODE();
 
@@ -54,6 +59,32 @@ TestEntry(
 KmtRegisterIrpHandler(IRP_MJ_READ, NULL, TestIrpHandler);
 KmtRegisterMessageHandler(0, NULL, TestMessageHandler);
 
+Status = ZwQuerySystemInformation(SystemBasicInformation,
+  &SBI,
+  sizeof(SBI),
+  &Length);
+if (NT_SUCCESS(Status))
+{
+Memory = (SBI.NumberOfPhysicalPages * SBI.PageSize) / 1024 / 1024;
+}
+else
+{
+Status = STATUS_SUCCESS;
+}
+
+VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo);
+Status = RtlGetVersion((PRTL_OSVERSIONINFOW)&VersionInfo);
+if (NT_SUCCESS(Status))
+{
+TS = BooleanFlagOn(VersionInfo.wSuiteMask, VER_SUITE_TERMINAL) &&
+ !BooleanFlagOn(VersionInfo.wSuiteMask, VER_SUITE_SINGLEUSERTS);
+}
+else
+{
+Status = STATUS_SUCCESS;
+}
+
+trace("System with %I64dMb RAM and terminal services %S\n",  Memory, (TS ? 
L"enabled" : L"disabled"));
 
 return Status;
 }
@@ -299,17 +330,29 @@ PerformTest(
 {
 PKTHREAD ThreadHandle;
 
+/* That's a bit rough but should do the job */
 #ifdef _X86_
-/* FIXME: Should be fixed, will fail under 
certains conditions */
-ok(TestContext->Buffer > (PVOID)0xC100 && 
TestContext->Buffer < (PVOID)0xDCFF,
-   "Buffer %p not mapped in system space\n", 
TestContext->Buffer);
-#else
-#ifdef _M_AMD64
-ok(TestContext->Buffer > (PVOID)0xF980 
&& TestContext->Buffer < (PVOID)0xFA80,
+if (Memory >= 2 * 1024)
+{
+ok((TestContext->Buffer >= (PVOID)0xC100 
&& TestContext->Buffer < (PVOID)0xE0FF) ||
+   (TestContext->Buffer >= (PVOID)0xA400 
&& TestContext->Buffer < (PVOID)0xBFFF),
+   "Buffer %p not mapped in system space\n", 
TestContext->Buffer);
+}
+else if (TS)
+{
+ok(TestContext->Buffer >= (PVOID)0xC100 && 
TestContext->Buffer < (PVOID)0xDCFF,
+   "Buffer %p not mapped in system space\n", 
TestContext->Buffer);
+}
+else
+{
+ok(TestContext->Buffer >= (PVOID)0xC100 && 
TestContext->Buffer < (PVOID)0xDBFF,
+   "Buffer %p not mapped in system space\n", 
TestContext->Buffer);
+}
+#elif defined(_M_AMD64)
+ok(TestContext->Buffer >= 
(PVOID)0xF980 && TestContext->Buffer < (PVOID)0xFA80,
"Buffer %p not mapped in system space\n", 
TestContext->Buffer);
 #else
 skip(FALSE, "System space mapping not defined\n");
-#endif
 #endif
 
 TestContext->Length = FileSizes.FileSize.QuadPart 
- Offset.QuadPart;
diff --git a/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c 
b/modules/rostests/

[ros-diffs] [reactos] 06/07: [NTOSKRNL] When looping again in ObpLookupEntryDirectory, properly init root entry

2019-06-30 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4fd223729b84740e558a9bbc9c0727749959f8a2

commit 4fd223729b84740e558a9bbc9c0727749959f8a2
Author: Pierre Schweitzer 
AuthorDate: Tue Jun 25 22:09:54 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sun Jun 30 23:07:54 2019 +0200

[NTOSKRNL] When looping again in ObpLookupEntryDirectory, properly init 
root entry

This fixes looking in global directory for DOS drives that are globally 
mounted
(such as C: drive)

CORE-16114
---
 ntoskrnl/ob/obdir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ntoskrnl/ob/obdir.c b/ntoskrnl/ob/obdir.c
index 83d05d4beb9..1c7b457c726 100644
--- a/ntoskrnl/ob/obdir.c
+++ b/ntoskrnl/ob/obdir.c
@@ -214,11 +214,11 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory,
 Context->HashValue = HashValue;
 Context->HashIndex = (USHORT)HashIndex;
 
+DoItAgain:
 /* Get the root entry and set it as our lookup bucket */
 AllocatedEntry = &Directory->HashBuckets[HashIndex];
 LookupBucket = AllocatedEntry;
 
-DoItAgain:
 /* Check if the directory is already locked */
 if (!Context->DirectoryLocked)
 {



[ros-diffs] [reactos] 07/07: [REACTOS] Finally enable the LUID mapped devices

2019-06-30 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c2aa749bbd03c20dbc18b13897c33fca67fd115f

commit c2aa749bbd03c20dbc18b13897c33fca67fd115f
Author: Pierre Schweitzer 
AuthorDate: Tue Jun 25 22:14:23 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sun Jun 30 23:07:54 2019 +0200

[REACTOS] Finally enable the LUID mapped devices

This allows users to have their own locally mapped DOS devices.
For instance, when a network drive is mapped, it is now mapped in the
user device maps and no longer in the global device map.
This avoids sharing mount points system wide whereas they shouldn't.

LUID mapped devices is the default W2K3 behavior.
Globally mapped devices can be restored by adding back this registry key.

https://twitter.com/HeisSpiter/status/1143615176450686976

CORE-16114
---
 boot/bootdata/hivesys.inf | 1 -
 1 file changed, 1 deletion(-)

diff --git a/boot/bootdata/hivesys.inf b/boot/bootdata/hivesys.inf
index d1e1f7d4d59..0f2fc9369eb 100644
--- a/boot/bootdata/hivesys.inf
+++ b/boot/bootdata/hivesys.inf
@@ -1445,7 +1445,6 @@ HKLM,"SYSTEM\CurrentControlSet\Control\Session 
Manager","ObjectDirectories",0x00
  "\Windows", \
  "\RPC Control"
 HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager","ProtectionMode", 
0x00010003, 0x0001
-HKLM,"SYSTEM\CurrentControlSet\Control\Session 
Manager","LUIDDeviceMapsDisabled", 0x00010003, 0x0001
 
 ; DOS devices
 HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\DOS 
Devices","AUX",0x0002,"\DosDevices\COM1"



[ros-diffs] [reactos] 04/07: [SDK] Add RtlInitString to the NDK

2019-06-30 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=522821bb8b8b17cdfc03766b64b99465ac6ceeb8

commit 522821bb8b8b17cdfc03766b64b99465ac6ceeb8
Author: Pierre Schweitzer 
AuthorDate: Thu Jun 20 08:56:05 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sun Jun 30 23:07:54 2019 +0200

[SDK] Add RtlInitString to the NDK
---
 sdk/include/ndk/rtlfuncs.h | 16 
 1 file changed, 16 insertions(+)

diff --git a/sdk/include/ndk/rtlfuncs.h b/sdk/include/ndk/rtlfuncs.h
index 8f5cdf07e5a..60cac48dc59 100644
--- a/sdk/include/ndk/rtlfuncs.h
+++ b/sdk/include/ndk/rtlfuncs.h
@@ -2201,6 +2201,22 @@ RtlHashUnicodeString(
 _Out_ PULONG HashValue
 );
 
+_IRQL_requires_max_(DISPATCH_LEVEL)
+_At_(DestinationString->Buffer, _Post_equal_to_(SourceString))
+_When_(SourceString != NULL,
+_At_(DestinationString->Length, _Post_equal_to_(_String_length_(SourceString)))
+_At_(DestinationString->MaximumLength, 
_Post_equal_to_(DestinationString->Length + sizeof(CHAR
+_When_(SourceString == NULL,
+_At_(DestinationString->Length, _Post_equal_to_(0))
+_At_(DestinationString->MaximumLength, _Post_equal_to_(0)))
+NTSYSAPI
+VOID
+NTAPI
+RtlInitString(
+_Out_ PSTRING DestinationString,
+_In_opt_z_ __drv_aliasesMem PCSTR SourceString
+);
+
 _IRQL_requires_max_(DISPATCH_LEVEL)
 _At_(DestinationString->Buffer, _Post_equal_to_(SourceString))
 _When_(SourceString != NULL,



[ros-diffs] [reactos] 05/07: [BASESRV] Implement LUID mapped drive arrival/removal notification

2019-06-30 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=222ace7c6c014741217b8e4ff73ad4bbdf7a3139

commit 222ace7c6c014741217b8e4ff73ad4bbdf7a3139
Author: Pierre Schweitzer 
AuthorDate: Thu Jun 20 09:00:07 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sun Jun 30 23:07:54 2019 +0200

[BASESRV] Implement LUID mapped drive arrival/removal notification

CORE-16114
---
 subsystems/win/basesrv/basesrv.h |   2 +
 subsystems/win/basesrv/dosdev.c  | 362 ++-
 subsystems/win/basesrv/init.c|  10 +-
 3 files changed, 367 insertions(+), 7 deletions(-)

diff --git a/subsystems/win/basesrv/basesrv.h b/subsystems/win/basesrv/basesrv.h
index 67b73a6da69..c758ab435c5 100644
--- a/subsystems/win/basesrv/basesrv.h
+++ b/subsystems/win/basesrv/basesrv.h
@@ -16,6 +16,7 @@
 #define COM_NO_WINDOWS_H
 #include 
 #include 
+#include 
 #define NTOS_MODE_USER
 #include 
 #include 
@@ -67,6 +68,7 @@ extern HANDLE BaseSrvSharedHeap;
 extern PBASE_STATIC_SERVER_DATA BaseStaticServerData;
 extern ULONG SessionId;
 extern ULONG ProtectionMode;
+extern RTL_CRITICAL_SECTION BaseSrvDDDBSMCritSec;
 
 #define SM_REG_KEY \
 L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Session Manager"
diff --git a/subsystems/win/basesrv/dosdev.c b/subsystems/win/basesrv/dosdev.c
index d13edb4ac19..83a01242e73 100644
--- a/subsystems/win/basesrv/dosdev.c
+++ b/subsystems/win/basesrv/dosdev.c
@@ -13,9 +13,21 @@
 #define NDEBUG
 #include 
 
+typedef struct _BSM_REQUEST
+{
+struct _BSM_REQUEST * Next;
+LUID BroadcastLuid;
+LONG DriveLetter;
+LONG RemoveDefinition;
+} BSM_REQUEST, *PBSM_REQUEST;
+
 /* GLOBALS 
/
 
 static RTL_CRITICAL_SECTION BaseDefineDosDeviceCritSec;
+RTL_CRITICAL_SECTION BaseSrvDDDBSMCritSec;
+PBSM_REQUEST BSM_Request_Queue = NULL, BSM_Request_Queue_End = NULL;
+ULONG BaseSrvpBSMThreadCount = 0;
+LONG (WINAPI *PBROADCASTSYSTEMMESSAGEEXW)(DWORD, LPDWORD, UINT, WPARAM, 
LPARAM, PBSMINFO) = NULL;
 
 /* PRIVATE FUNCTIONS 
**/
 
@@ -146,6 +158,317 @@ IsGlobalSymbolicLink(HANDLE LinkHandle,
 return Status;
 }
 
+BOOLEAN
+CheckForGlobalDriveLetter(SHORT DriveLetter)
+{
+WCHAR Path[8];
+NTSTATUS Status;
+BOOLEAN IsGlobal;
+UNICODE_STRING PathU;
+HANDLE SymbolicLinkHandle;
+OBJECT_ATTRIBUTES ObjectAttributes;
+
+/* Setup our drive path */
+wcsncpy(Path, L"\\??\\X:", (sizeof(L"\\??\\X:") / sizeof(WCHAR)));
+Path[4] = DriveLetter + L'A';
+Path[6] = UNICODE_NULL;
+
+/* Prepare everything to open the link */
+RtlInitUnicodeString(&PathU, Path);
+InitializeObjectAttributes(&ObjectAttributes,
+   &PathU,
+   OBJ_CASE_INSENSITIVE,
+   NULL,
+   NULL);
+
+/* Impersonate the caller */
+if (!CsrImpersonateClient(NULL))
+{
+return FALSE;
+}
+
+/* Open our drive letter */
+Status = NtOpenSymbolicLinkObject(&SymbolicLinkHandle,
+  SYMBOLIC_LINK_QUERY,
+  &ObjectAttributes);
+
+CsrRevertToSelf();
+
+if (!NT_SUCCESS(Status))
+{
+return FALSE;
+}
+
+/* Check whether it's global */
+Status = IsGlobalSymbolicLink(SymbolicLinkHandle, &IsGlobal);
+NtClose(SymbolicLinkHandle);
+
+if (!NT_SUCCESS(Status))
+{
+return FALSE;
+}
+
+return IsGlobal;
+}
+
+NTSTATUS
+SendWinStationBSM(DWORD Flags,
+  LPDWORD Recipients,
+  UINT Message,
+  WPARAM wParam,
+  LPARAM lParam)
+{
+UNIMPLEMENTED;
+return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+BroadcastDriveLetterChange(LONG DriveLetter,
+   BOOLEAN RemoveDefinition,
+   PLUID BroadcastLuid)
+{
+HANDLE hUser32;
+NTSTATUS Status;
+UNICODE_STRING User32U;
+ANSI_STRING ProcedureName;
+DWORD Recipients, Flags, wParam;
+LUID SystemLuid = SYSTEM_LUID;
+BSMINFO Info;
+DEV_BROADCAST_VOLUME Volume;
+
+/* We need a broadcast LUID */
+if (BroadcastLuid == NULL)
+{
+return STATUS_INVALID_PARAMETER;
+}
+
+/* Get the Csr procedure, and keep it forever */
+if (PBROADCASTSYSTEMMESSAGEEXW == NULL)
+{
+hUser32 = NULL;
+RtlInitUnicodeString(&User32U, L"user32");
+Status = LdrGetDllHandle(NULL, NULL, &User32U, &hUser32);
+if (hUser32 != NULL && NT_SUCCESS(Status))
+{
+RtlInitString(&ProcedureName, "CsrBroadcastSystemMessageExW");
+Status = LdrGetProcedureAddress(hUser32,
+&ProcedureName,
+

[ros-diffs] [reactos] 03/07: [NTOSKRNL] Implement support for device maps in ObpLookupObjectName

2019-06-30 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f13b6e025f89096cee0d224b3d258f75ba356d3d

commit f13b6e025f89096cee0d224b3d258f75ba356d3d
Author: Pierre Schweitzer 
AuthorDate: Thu Jun 20 08:55:31 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sun Jun 30 23:07:54 2019 +0200

[NTOSKRNL] Implement support for device maps in ObpLookupObjectName

This allows getting rid of the ?? hack in the kernel but this doesn't
allow enabling LUID device maps as ReactOS can no longer open a
session with them enabled. So, we must remain with device maps at
root

CORE-16114
---
 ntoskrnl/include/internal/ob.h |  6 
 ntoskrnl/ob/obname.c   | 67 ++
 2 files changed, 48 insertions(+), 25 deletions(-)

diff --git a/ntoskrnl/include/internal/ob.h b/ntoskrnl/include/internal/ob.h
index 266c4dd668c..41e1af894a9 100644
--- a/ntoskrnl/include/internal/ob.h
+++ b/ntoskrnl/include/internal/ob.h
@@ -443,6 +443,12 @@ ObIsLUIDDeviceMapsEnabled(
 VOID
 );
 
+PDEVICE_MAP
+NTAPI
+ObpReferenceDeviceMap(
+VOID
+);
+
 //
 // Security descriptor cache functions
 //
diff --git a/ntoskrnl/ob/obname.c b/ntoskrnl/ob/obname.c
index 460338f0d48..9ba15a6d013 100644
--- a/ntoskrnl/ob/obname.c
+++ b/ntoskrnl/ob/obname.c
@@ -214,26 +214,6 @@ ObpCreateDosDevicesDirectory(VOID)
 if (!NT_SUCCESS(Status))
 goto done;
 
-/*\
-|*** HACK until we support device mappings ***|
-|*** Add a symlink \??\ <--> \GLOBAL??\***|
-\*/
-RtlInitUnicodeString(&LinkName, L"\\??");
-InitializeObjectAttributes(&ObjectAttributes,
-   &LinkName,
-   OBJ_PERMANENT,
-   NULL,
-   &DosDevicesSD);
-Status = NtCreateSymbolicLinkObject(&SymHandle,
-SYMBOLIC_LINK_ALL_ACCESS,
-&ObjectAttributes,
-&RootName);
-if (NT_SUCCESS(Status)) NtClose(SymHandle);
-/*\
-\*/
-
-// FIXME: Create a device mapping for the global \?? directory
-
 /*
  * Initialize the \??\GLOBALROOT symbolic link
  * pointing to the root directory \ .
@@ -490,6 +470,8 @@ ObpLookupObjectName(IN HANDLE RootHandle OPTIONAL,
 PWCHAR NewName;
 POBJECT_HEADER_NAME_INFO ObjectNameInfo;
 ULONG MaxReparse = 30;
+PDEVICE_MAP DeviceMap = NULL;
+UNICODE_STRING LocalName;
 PAGED_CODE();
 OBTRACE(OB_NAMESPACE_DEBUG,
 "%s - Finding Object: %wZ. Expecting: %p\n",
@@ -642,6 +624,8 @@ ObpLookupObjectName(IN HANDLE RootHandle OPTIONAL,
 *FoundObject = Object;
 return Status;
 }
+
+LocalName = *ObjectName;
 }
 else
 {
@@ -695,7 +679,14 @@ ObpLookupObjectName(IN HANDLE RootHandle OPTIONAL,
 else
 {
 ParseFromRoot:
-/* FIXME: Check if we have a device map */
+LocalName = *ObjectName;
+
+/* Deference the device map if we already have one */
+if (DeviceMap != NULL)
+{
+ObfDereferenceDeviceMap(DeviceMap);
+DeviceMap = NULL;
+}
 
 /* Check if this is a possible DOS name */
 if (!((ULONG_PTR)(ObjectName->Buffer) & 7))
@@ -713,7 +704,17 @@ ParseFromRoot:
 (*(PULONGLONG)(ObjectName->Buffer) ==
  ObpDosDevicesShortNamePrefix.Alignment.QuadPart))
 {
-/* FIXME! */
+DeviceMap = ObpReferenceDeviceMap();
+/* We have a local mapping, drop the ?? prefix */
+if (DeviceMap != NULL && DeviceMap->DosDevicesDirectory != 
NULL)
+{
+LocalName.Length -= ObpDosDevicesShortName.Length;
+LocalName.MaximumLength -= 
ObpDosDevicesShortName.Length;
+LocalName.Buffer += (ObpDosDevicesShortName.Length / 
sizeof(WCHAR));
+
+/* We'll browse that local directory */
+Directory = DeviceMap->DosDevicesDirectory;
+}
 }
 else if ((ObjectName->Length == ObpDosDevicesShortName.Length -
 sizeof(WCHAR)) &&
@@ -722,7 +723,23 @@ ParseFromRoot:
  (*((PWCHAR)(ObjectName->Buffer) + 2) ==
   
(WCHAR)(ObpDosDevicesShortNameRoot.Alignment.HighPart)))
 {
-/* FIXME! */
+DeviceMap = ObpReferenceDeviceMap();
+
+ 

[ros-diffs] [reactos] 02/07: [KMTESTS:OB] Add support for LUID mappings being disabled in ObSecurity tests

2019-06-30 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f529033555bdfe7fb090e8f21f1191187b21706b

commit f529033555bdfe7fb090e8f21f1191187b21706b
Author: Pierre Schweitzer 
AuthorDate: Thu Jun 20 08:53:27 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sun Jun 30 23:07:54 2019 +0200

[KMTESTS:OB] Add support for LUID mappings being disabled in ObSecurity 
tests

CORE-16114
---
 modules/rostests/kmtests/include/kmt_platform.h |  1 +
 modules/rostests/kmtests/ntos_ob/ObSecurity.c   | 52 -
 2 files changed, 44 insertions(+), 9 deletions(-)

diff --git a/modules/rostests/kmtests/include/kmt_platform.h 
b/modules/rostests/kmtests/include/kmt_platform.h
index 4895bf25a31..2cdc9b655c8 100644
--- a/modules/rostests/kmtests/include/kmt_platform.h
+++ b/modules/rostests/kmtests/include/kmt_platform.h
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #if defined KMT_FILTER_DRIVER
diff --git a/modules/rostests/kmtests/ntos_ob/ObSecurity.c 
b/modules/rostests/kmtests/ntos_ob/ObSecurity.c
index 4ac9478074a..55f5a0fe4cb 100644
--- a/modules/rostests/kmtests/ntos_ob/ObSecurity.c
+++ b/modules/rostests/kmtests/ntos_ob/ObSecurity.c
@@ -124,18 +124,52 @@ CheckDirectorySecurity__(
 
 START_TEST(ObSecurity)
 {
+NTSTATUS Status;
+/* Assume yes, that's the default on W2K3 */
+ULONG LUIDMappingsEnabled = 1, ReturnLength;
+
 #define DIRECTORY_GENERIC_READ  STANDARD_RIGHTS_READ | DIRECTORY_TRAVERSE 
| DIRECTORY_QUERY
 #define DIRECTORY_GENERIC_WRITE STANDARD_RIGHTS_WRITE | 
DIRECTORY_CREATE_SUBDIRECTORY | DIRECTORY_CREATE_OBJECT
 
-CheckDirectorySecurityWithOwnerAndGroup(L"\\??", 
SeExports->SeAliasAdminsSid, NULL, // Group is "Domain Users"
-   4, ACCESS_ALLOWED_ACE_TYPE, CONTAINER_INHERIT_ACE |
-   OBJECT_INHERIT_ACE, 
 SeExports->SeLocalSystemSid, DIRECTORY_ALL_ACCESS,
-  ACCESS_ALLOWED_ACE_TYPE, CONTAINER_INHERIT_ACE |
-   OBJECT_INHERIT_ACE, 
 SeExports->SeAliasAdminsSid, DIRECTORY_ALL_ACCESS,
-  ACCESS_ALLOWED_ACE_TYPE, 0,  
 SeExports->SeAliasAdminsSid, DIRECTORY_ALL_ACCESS,
-  ACCESS_ALLOWED_ACE_TYPE, INHERIT_ONLY_ACE |
-   CONTAINER_INHERIT_ACE |
-   OBJECT_INHERIT_ACE, 
 SeExports->SeCreatorOwnerSid,GENERIC_ALL);
+/* Check if LUID device maps are enabled */
+Status = ZwQueryInformationProcess(NtCurrentProcess(),
+   ProcessLUIDDeviceMapsEnabled,
+   &LUIDMappingsEnabled,
+   sizeof(LUIDMappingsEnabled),
+   &ReturnLength);
+ok(NT_SUCCESS(Status), "NtQueryInformationProcess failed: 0x%x\n", Status);
+
+trace("LUID mappings are enabled: %d\n", LUIDMappingsEnabled);
+if (LUIDMappingsEnabled != 0)
+{
+CheckDirectorySecurityWithOwnerAndGroup(L"\\??", 
SeExports->SeAliasAdminsSid, NULL, // Group is "Domain Users"
+   4, ACCESS_ALLOWED_ACE_TYPE, 
CONTAINER_INHERIT_ACE |
+   OBJECT_INHERIT_ACE, 
 SeExports->SeLocalSystemSid, DIRECTORY_ALL_ACCESS,
+  ACCESS_ALLOWED_ACE_TYPE, 
CONTAINER_INHERIT_ACE |
+   OBJECT_INHERIT_ACE, 
 SeExports->SeAliasAdminsSid, DIRECTORY_ALL_ACCESS,
+  ACCESS_ALLOWED_ACE_TYPE, 0,  
 SeExports->SeAliasAdminsSid, DIRECTORY_ALL_ACCESS,
+  ACCESS_ALLOWED_ACE_TYPE, INHERIT_ONLY_ACE |
+   
CONTAINER_INHERIT_ACE |
+   OBJECT_INHERIT_ACE, 
 SeExports->SeCreatorOwnerSid,GENERIC_ALL);
+}
+else
+{
+CheckDirectorySecurityWithOwnerAndGroup(L"\\??", 
SeExports->SeAliasAdminsSid, NULL, // Group is "Domain Users"
+   6, ACCESS_ALLOWED_ACE_TYPE, 0, 
SeExports->SeWorldSid, READ_CONTROL | DIRECTORY_TRAVERSE | DIRECTORY_QUERY,
+  ACCESS_ALLOWED_ACE_TYPE, 0, 
SeExports->SeLocalSystemSid, DIRECTORY_ALL_ACCESS,
+  ACCESS_ALLOWED_ACE_TYPE, INHERIT_ONLY_ACE |
+   
CONTAINER_INHERIT_ACE |
+   OBJECT_INHERIT_ACE, 
 SeExports->SeWorldSid, GENERIC_EXECUTE,
+ 

[ros-diffs] [reactos] 01/01: [SDK] Add missing definitions

2019-06-28 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e75bdce6cd19ce5725be8eb5280ad82f9fa97c80

commit e75bdce6cd19ce5725be8eb5280ad82f9fa97c80
Author: Pierre Schweitzer 
AuthorDate: Fri Jun 28 22:11:54 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Fri Jun 28 22:11:54 2019 +0200

[SDK] Add missing definitions

This fixes storport build
---
 sdk/include/ddk/storport.h | 37 +
 1 file changed, 37 insertions(+)

diff --git a/sdk/include/ddk/storport.h b/sdk/include/ddk/storport.h
index 44d5d96d274..7b7416ff24d 100644
--- a/sdk/include/ddk/storport.h
+++ b/sdk/include/ddk/storport.h
@@ -404,6 +404,23 @@ extern "C" {
 #define VPD_MODE_PAGE_POLICY0x87
 #define VPD_SCSI_PORTS  0x88
 
+#define SCSI_SENSE_NO_SENSE 0x00
+#define SCSI_SENSE_RECOVERED_ERROR  0x01
+#define SCSI_SENSE_NOT_READY0x02
+#define SCSI_SENSE_MEDIUM_ERROR 0x03
+#define SCSI_SENSE_HARDWARE_ERROR   0x04
+#define SCSI_SENSE_ILLEGAL_REQUEST  0x05
+#define SCSI_SENSE_UNIT_ATTENTION   0x06
+#define SCSI_SENSE_DATA_PROTECT 0x07
+#define SCSI_SENSE_BLANK_CHECK  0x08
+#define SCSI_SENSE_UNIQUE   0x09
+#define SCSI_SENSE_COPY_ABORTED 0x0A
+#define SCSI_SENSE_ABORTED_COMMAND  0x0B
+#define SCSI_SENSE_EQUAL0x0C
+#define SCSI_SENSE_VOL_OVERFLOW 0x0D
+#define SCSI_SENSE_MISCOMPARE   0x0E
+#define SCSI_SENSE_RESERVED 0x0F
+
 typedef enum _STOR_SYNCHRONIZATION_MODEL
 {
 StorSynchronizeHalfDuplex,
@@ -1931,6 +1948,26 @@ typedef struct _LUN_LIST
 UCHAR Lun[0][8];
 #endif
 } LUN_LIST, *PLUN_LIST;
+
+typedef struct _SENSE_DATA
+{
+UCHAR ErrorCode:7;
+UCHAR Valid:1;
+UCHAR SegmentNumber;
+UCHAR SenseKey:4;
+UCHAR Reserved:1;
+UCHAR IncorrectLength:1;
+UCHAR EndOfMedia:1;
+UCHAR FileMark:1;
+UCHAR Information[4];
+UCHAR AdditionalSenseLength;
+UCHAR CommandSpecificInformation[4];
+UCHAR AdditionalSenseCode;
+UCHAR AdditionalSenseCodeQualifier;
+UCHAR FieldReplaceableUnitCode;
+UCHAR SenseKeySpecific[3];
+} SENSE_DATA, *PSENSE_DATA;
+
 #include 
 
 typedef PHYSICAL_ADDRESS STOR_PHYSICAL_ADDRESS;



[ros-diffs] [reactos] 01/01: [NTOSKRNL] Rework ObpDeleteSymbolicLinkName and ObpCreateSymbolicLinkName So that they handle LUID mappings and process device maps.

2019-06-11 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f6eb13a969e5108f0e58bc71473f04ab4dce399f

commit f6eb13a969e5108f0e58bc71473f04ab4dce399f
Author: Pierre Schweitzer 
AuthorDate: Tue Jun 11 21:18:22 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Tue Jun 11 21:21:52 2019 +0200

[NTOSKRNL] Rework ObpDeleteSymbolicLinkName and ObpCreateSymbolicLinkName
So that they handle LUID mappings and process device maps.

Get rid of the ObpParseSymbolicLinkToIoDeviceObject helper and introduce a
new helper ObpProcessDosDeviceSymbolicLink that will do the same things
but also handle name creation/deletion as well as device map handling.
All this is based on previous code (hence the same comments :-)).

What's left to do now is to add support for device maps in 
ObpLookupObjectName
---
 ntoskrnl/ob/oblink.c | 499 +--
 1 file changed, 283 insertions(+), 216 deletions(-)

diff --git a/ntoskrnl/ob/oblink.c b/ntoskrnl/ob/oblink.c
index f8fbe5ad500..712143e1ed7 100644
--- a/ntoskrnl/ob/oblink.c
+++ b/ntoskrnl/ob/oblink.c
@@ -20,288 +20,355 @@ POBJECT_TYPE ObpSymbolicLinkObjectType = NULL;
 /* PRIVATE FUNCTIONS */
 
 VOID
-NTAPI
-ObpDeleteSymbolicLinkName(IN POBJECT_SYMBOLIC_LINK SymbolicLink)
+ObpProcessDosDeviceSymbolicLink(IN POBJECT_SYMBOLIC_LINK SymbolicLink,
+IN BOOLEAN DeleteLink)
 {
+PDEVICE_MAP DeviceMap;
+UNICODE_STRING TargetPath, LocalTarget;
+POBJECT_DIRECTORY NameDirectory, DirectoryObject;
+ULONG MaxReparse;
+OBP_LOOKUP_CONTEXT LookupContext;
+ULONG DriveType;
 POBJECT_HEADER ObjectHeader;
 POBJECT_HEADER_NAME_INFO ObjectNameInfo;
+BOOLEAN DirectoryLocked;
+PVOID Object;
 
-/* FIXME: Need to support Device maps */
+/*
+ * To prevent endless reparsing, setting an upper limit on the 
+ * number of reparses.
+ */
+MaxReparse = 32;
+NameDirectory = NULL;
 
 /* Get header data */
 ObjectHeader = OBJECT_TO_OBJECT_HEADER(SymbolicLink);
-ObjectNameInfo = ObpReferenceNameInfo(ObjectHeader);
-
-/* Check if we are not actually in a directory with a device map */
-if (!(ObjectNameInfo) ||
-!(ObjectNameInfo->Directory) /*||
-!(ObjectNameInfo->Directory->DeviceMap)*/)
-{
-ObpDereferenceNameInfo(ObjectNameInfo);
-return;
-}
+ObjectNameInfo = OBJECT_HEADER_TO_NAME_INFO(ObjectHeader);
 
-/* Check if it's a DOS drive letter, and remove the entry from drive map 
if needed */
-if (SymbolicLink->DosDeviceDriveIndex != 0 &&
-ObjectNameInfo->Name.Length == 2 * sizeof(WCHAR) &&
-ObjectNameInfo->Name.Buffer[1] == L':' &&
-( (ObjectNameInfo->Name.Buffer[0] >= L'A' &&
-ObjectNameInfo->Name.Buffer[0] <= L'Z') ||
-  (ObjectNameInfo->Name.Buffer[0] >= L'a' &&
-ObjectNameInfo->Name.Buffer[0] <= L'z') ))
+/* Check if we have a directory in our symlink to use */
+if (ObjectNameInfo != NULL)
 {
-/* Remove the drive entry */
-KeAcquireGuardedMutex(&ObpDeviceMapLock);
-ObSystemDeviceMap->DriveType[SymbolicLink->DosDeviceDriveIndex-1] =
-DOSDEVICE_DRIVE_UNKNOWN;
-ObSystemDeviceMap->DriveMap &=
-~(1 << (SymbolicLink->DosDeviceDriveIndex-1));
-KeReleaseGuardedMutex(&ObpDeviceMapLock);
-
-/* Reset the drive index, valid drive index starts from 1 */
-SymbolicLink->DosDeviceDriveIndex = 0;
+NameDirectory = ObjectNameInfo->Directory;
 }
 
-ObpDereferenceNameInfo(ObjectNameInfo);
-}
-
-NTSTATUS
-NTAPI
-ObpParseSymbolicLinkToIoDeviceObject(IN POBJECT_DIRECTORY 
SymbolicLinkDirectory,
- IN OUT POBJECT_DIRECTORY *Directory,
- IN OUT PUNICODE_STRING TargetPath,
- IN OUT POBP_LOOKUP_CONTEXT Context,
- OUT PVOID *Object)
-{
-UNICODE_STRING Name;
-BOOLEAN ManualUnlock;
+/* Initialize lookup context */
+ObpInitializeLookupContext(&LookupContext);
 
-if (! TargetPath || ! Object || ! Context || ! Directory ||
-! SymbolicLinkDirectory)
+/*
+ * If we have to create the link, locate the IoDeviceObject if any
+ * this symbolic link points to.
+ */
+if (SymbolicLink->LinkTargetObject != NULL || !DeleteLink)
 {
-return STATUS_INVALID_PARAMETER;
-}
+/* Start the search from the root */
+DirectoryObject = ObpRootDirectoryObject;
 
-/* FIXME: Need to support Device maps */
+/* Keep track of our progress while parsing the name */
+LocalTarget = SymbolicLink->Lin

[ros-diffs] [reactos] 01/01: [BTRFS] Fix MSVC build

2019-06-11 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=95848cb53831e46b79c4f543477d36388c3e7644

commit 95848cb53831e46b79c4f543477d36388c3e7644
Author: Pierre Schweitzer 
AuthorDate: Tue Jun 11 12:50:49 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Tue Jun 11 12:50:49 2019 +0200

[BTRFS] Fix MSVC build

CORE-16111
---
 drivers/filesystems/btrfs/dirctrl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/filesystems/btrfs/dirctrl.c 
b/drivers/filesystems/btrfs/dirctrl.c
index 48e7fc2aca6..d088de35f72 100644
--- a/drivers/filesystems/btrfs/dirctrl.c
+++ b/drivers/filesystems/btrfs/dirctrl.c
@@ -18,7 +18,7 @@
 #include "btrfs_drv.h"
 
 // not currently in mingw
-#ifndef _MSC_VER
+//#ifndef _MSC_VER
 #define FileIdExtdDirectoryInformation (enum _FILE_INFORMATION_CLASS)60
 #define FileIdExtdBothDirectoryInformation (enum _FILE_INFORMATION_CLASS)63
 
@@ -58,7 +58,7 @@ typedef struct _FILE_ID_EXTD_BOTH_DIR_INFORMATION {
 WCHAR FileName[1];
 } FILE_ID_EXTD_BOTH_DIR_INFORMATION, *PFILE_ID_EXTD_BOTH_DIR_INFORMATION;
 
-#endif
+//#endif
 
 enum DirEntryType {
 DirEntryType_File,



[ros-diffs] [reactos] 01/01: [BTRFS] Fix MSVC build

2019-06-11 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=92543df9e15f88b6e6367fe3766f4325c1bf3994

commit 92543df9e15f88b6e6367fe3766f4325c1bf3994
Author: Pierre Schweitzer 
AuthorDate: Tue Jun 11 12:43:43 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Tue Jun 11 12:43:43 2019 +0200

[BTRFS] Fix MSVC build

CORE-16111
---
 drivers/filesystems/btrfs/btrfs_drv.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/filesystems/btrfs/btrfs_drv.h 
b/drivers/filesystems/btrfs/btrfs_drv.h
index b5d1cd2e4f0..9439bd49e93 100644
--- a/drivers/filesystems/btrfs/btrfs_drv.h
+++ b/drivers/filesystems/btrfs/btrfs_drv.h
@@ -143,11 +143,9 @@
 #define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL 0x0002
 #endif
 
-#ifndef _MSC_VER
 typedef struct _FILE_ID_128 {
 UCHAR Identifier[16];
 } FILE_ID_128, *PFILE_ID_128;
-#endif
 
 typedef struct _DUPLICATE_EXTENTS_DATA {
 HANDLE FileHandle;



[ros-diffs] [reactos] 01/01: [BTRFS] Upgrade to 1.3

2019-06-11 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f381137c89da4ff272e939bedb91c34262369846

commit f381137c89da4ff272e939bedb91c34262369846
Author: Pierre Schweitzer 
AuthorDate: Tue Jun 11 12:35:19 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Tue Jun 11 12:35:19 2019 +0200

[BTRFS] Upgrade to 1.3

CORE-16111
---
 dll/win32/ubtrfs/ubtrfs.rc  |  24 +-
 drivers/filesystems/btrfs/btrfs.c   | 166 ++---
 drivers/filesystems/btrfs/btrfs.h   |   3 +
 drivers/filesystems/btrfs/btrfs.rc  |   8 +-
 drivers/filesystems/btrfs/btrfs_drv.h   |  23 +-
 drivers/filesystems/btrfs/create.c  | 269 --
 drivers/filesystems/btrfs/dirctrl.c | 158 +++-
 drivers/filesystems/btrfs/fileinfo.c| 630 +---
 drivers/filesystems/btrfs/flushthread.c | 196 +-
 drivers/filesystems/btrfs/free-space.c  |   4 +-
 drivers/filesystems/btrfs/fsctl.c   |  10 +-
 drivers/filesystems/btrfs/write.c   |   2 +-
 media/doc/README.FSD|   4 +-
 13 files changed, 1344 insertions(+), 153 deletions(-)

diff --git a/dll/win32/ubtrfs/ubtrfs.rc b/dll/win32/ubtrfs/ubtrfs.rc
index c4c486f92af..2fbce14c1f1 100644
--- a/dll/win32/ubtrfs/ubtrfs.rc
+++ b/dll/win32/ubtrfs/ubtrfs.rc
@@ -25,18 +25,18 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
 // TEXTINCLUDE
 //
 
-1 TEXTINCLUDE
+1 TEXTINCLUDE 
 BEGIN
 "resource.h\0"
 END
 
-2 TEXTINCLUDE
+2 TEXTINCLUDE 
 BEGIN
 "#include ""winres.h""\r\n"
 "\0"
 END
 
-3 TEXTINCLUDE
+3 TEXTINCLUDE 
 BEGIN
 "\r\n"
 "\0"
@@ -51,8 +51,8 @@ END
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,1,0,0
- PRODUCTVERSION 1,1,0,0
+ FILEVERSION 1,3,0,0
+ PRODUCTVERSION 1,3,0,0
  FILEFLAGSMASK 0x17L
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -60,20 +60,20 @@ VS_VERSION_INFO VERSIONINFO
  FILEFLAGS 0x0L
 #endif
  FILEOS 0x4L
- FILETYPE 0x0L
+ FILETYPE 0x2L
  FILESUBTYPE 0x0L
 BEGIN
 BLOCK "StringFileInfo"
 BEGIN
 BLOCK "080904b0"
 BEGIN
-VALUE "FileDescription", "Btrfs formatting utility"
-VALUE "FileVersion", "1.1"
-VALUE "InternalName", "mkbtrfs"
-VALUE "LegalCopyright", "Copyright (c) Mark Harmstone 2016-18"
-VALUE "OriginalFilename", "mkbtrfs.exe"
+VALUE "FileDescription", "Btrfs utility DLL"
+VALUE "FileVersion", "1.3"
+VALUE "InternalName", "ubtrfs"
+VALUE "LegalCopyright", "Copyright (c) Mark Harmstone 2016-19"
+VALUE "OriginalFilename", "ubtrfs.dll"
 VALUE "ProductName", "WinBtrfs"
-VALUE "ProductVersion", "1.1"
+VALUE "ProductVersion", "1.3"
 END
 END
 BLOCK "VarFileInfo"
diff --git a/drivers/filesystems/btrfs/btrfs.c 
b/drivers/filesystems/btrfs/btrfs.c
index 4cd6bb10a10..c480d9f0502 100644
--- a/drivers/filesystems/btrfs/btrfs.c
+++ b/drivers/filesystems/btrfs/btrfs.c
@@ -795,7 +795,8 @@ static NTSTATUS drv_query_volume_information(_In_ 
PDEVICE_OBJECT DeviceObject, _
 data->FileSystemAttributes = FILE_CASE_PRESERVED_NAMES | 
FILE_CASE_SENSITIVE_SEARCH |
  FILE_UNICODE_ON_DISK | 
FILE_NAMED_STREAMS | FILE_SUPPORTS_HARD_LINKS | FILE_PERSISTENT_ACLS |
  FILE_SUPPORTS_REPARSE_POINTS | 
FILE_SUPPORTS_SPARSE_FILES | FILE_SUPPORTS_OBJECT_IDS |
- FILE_SUPPORTS_OPEN_BY_FILE_ID | 
FILE_SUPPORTS_EXTENDED_ATTRIBUTES | FILE_SUPPORTS_BLOCK_REFCOUNTING;
+ FILE_SUPPORTS_OPEN_BY_FILE_ID | 
FILE_SUPPORTS_EXTENDED_ATTRIBUTES | FILE_SUPPORTS_BLOCK_REFCOUNTING |
+ FILE_SUPPORTS_POSIX_UNLINK_RENAME;
 if (Vcb->readonly)
 data->FileSystemAttributes |= FILE_READ_ONLY_VOLUME;
 
@@ -1068,6 +1069,7 @@ NTSTATUS create_root(_In_ 
_Requires_exclusive_lock_held_(_Curr_->tree_lock) devi
 RtlZeroMemory(&r->root_item, sizeof(ROOT_ITEM));
 r->root_item.num_references = 1;
 r->fcbs_version = 0;
+r->checked_for_orphans = TRUE;
 InitializeListHead(&r->fcbs);
 RtlZeroMemory(r->fcbs_ptrs, sizeof(LIST_ENTRY*) * 256);
 
@@ -1966,7 +1968,63 @@ void uninit(_In_ device_extension* Vcb) {
 ZwClose(Vcb->flush_thread_handle);
 }
 
-NTSTATUS delete_fileref(_In_ file_ref* fileref, _In_opt_ PFILE_OBJECT 
FileObject, _In_opt_ PIRP Irp, _In_ LIST_ENTRY* rollback) {
+static NTSTATUS delete_fileref_fcb(_In_ file_ref* fileref, _In_opt_ 
PFILE_OBJECT FileObject, _In_opt_ PIRP Irp, _In

[ros-diffs] [reactos] 01/01: [NTOSKRNL] Fix ObpLUIDDeviceMapsEnabled initialization

2019-06-10 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=33604e014768009d2c66c106d54d6d22945063fa

commit 33604e014768009d2c66c106d54d6d22945063fa
Author: Pierre Schweitzer 
AuthorDate: Mon Jun 10 21:16:41 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Jun 10 21:17:21 2019 +0200

[NTOSKRNL] Fix ObpLUIDDeviceMapsEnabled initialization
---
 ntoskrnl/ob/obname.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ntoskrnl/ob/obname.c b/ntoskrnl/ob/obname.c
index 5700d43d5ca..460338f0d48 100644
--- a/ntoskrnl/ob/obname.c
+++ b/ntoskrnl/ob/obname.c
@@ -188,6 +188,8 @@ ObpCreateDosDevicesDirectory(VOID)
  */
 if (ObpProtectionMode == 0 || ObpLUIDDeviceMapsDisabled != 0)
 ObpLUIDDeviceMapsEnabled = 0;
+else
+ObpLUIDDeviceMapsEnabled = 1;
 
 /* Create a custom security descriptor for the global DosDevices directory 
*/
 Status = ObpGetDosDevicesProtection(&DosDevicesSD);



[ros-diffs] [reactos] 01/01: [NETPLWIZ] Add French translation

2019-06-10 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=72d229b38c206254098aedf115c4a8ab3e870e16

commit 72d229b38c206254098aedf115c4a8ab3e870e16
Author: Pierre Schweitzer 
AuthorDate: Mon Jun 10 19:01:04 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Jun 10 19:01:30 2019 +0200

[NETPLWIZ] Add French translation
---
 dll/shellext/netplwiz/lang/fr-FR.rc | 21 +
 dll/shellext/netplwiz/netplwiz.rc   |  3 +++
 2 files changed, 24 insertions(+)

diff --git a/dll/shellext/netplwiz/lang/fr-FR.rc 
b/dll/shellext/netplwiz/lang/fr-FR.rc
new file mode 100644
index 000..657ed65ed47
--- /dev/null
+++ b/dll/shellext/netplwiz/lang/fr-FR.rc
@@ -0,0 +1,21 @@
+LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
+
+IDD_DISCONNECTDRIVES DIALOGEX 0, 0, 300, 200
+STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Déconnecter un lecteur réseau"
+FONT 8, "MS Shell Dlg"
+BEGIN
+LTEXT "Sélectionnez le(s) lecteur(s) réseau que vous voulez déconnecter, 
puis cliquez sur OK.", -1, 7, 7, 286, 8
+LTEXT "&Lecteurs réseau :", -1, 7, 23, 286, 8
+CONTROL "", IDC_CONNECTEDDRIVELIST, "SysListView32", LVS_REPORT | 
LVS_SHOWSELALWAYS | LVS_SORTASCENDING | LVS_SINGLESEL | WS_CHILD | WS_VISIBLE | 
WS_BORDER | WS_TABSTOP, 7, 31, 286, 140
+PUSHBUTTON "OK", ID_OK, 189, 179, 50, 14
+PUSHBUTTON "Annuler", IDCANCEL, 243, 179, 50, 14
+END
+
+STRINGTABLE
+BEGIN
+IDS_DIALOG_CAPTION "Déconnecter un lecteur réseau"
+IDS_DRIVE_LETTER "Lecteur"
+IDS_NETWORK_PATH "Chemin réseau"
+IDS_NO_DRIVES "Vous n'avez pas de lecteurs réseau à déconnecter."
+END
diff --git a/dll/shellext/netplwiz/netplwiz.rc 
b/dll/shellext/netplwiz/netplwiz.rc
index aac48703fbf..27bd8c14e65 100644
--- a/dll/shellext/netplwiz/netplwiz.rc
+++ b/dll/shellext/netplwiz/netplwiz.rc
@@ -24,3 +24,6 @@ IDI_DISCONNECT_NET_DRIVES ICON "res/4400.ico"
 #ifdef LANGUAGE_EN_US
 #include "lang/en-US.rc"
 #endif
+#ifdef LANGUAGE_FR_FR
+#include "lang/fr-FR.rc"
+#endif



[ros-diffs] [reactos] 01/01: [MSGINA] Update French translation

2019-06-10 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a7b6a1a97db061b4e77ac7e12b370098ec304239

commit a7b6a1a97db061b4e77ac7e12b370098ec304239
Author: Pierre Schweitzer 
AuthorDate: Mon Jun 10 15:36:14 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Jun 10 15:37:32 2019 +0200

[MSGINA] Update French translation
---
 dll/win32/msgina/lang/fr-FR.rc | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/dll/win32/msgina/lang/fr-FR.rc b/dll/win32/msgina/lang/fr-FR.rc
index 7e89bf8edf6..b7251e08e34 100644
--- a/dll/win32/msgina/lang/fr-FR.rc
+++ b/dll/win32/msgina/lang/fr-FR.rc
@@ -112,7 +112,7 @@ CAPTION "Déconnexion de ReactOS"
 FONT 8, "MS Shell Dlg", 400, 0, 1
 BEGIN
 ICON IDI_LOGOFF, IDC_STATIC, 7, 7, 20, 20
-LTEXT "Êtes-vous sûr de vouloir vous déconnecter?", IDC_STATIC, 35, 16, 
146, 8
+LTEXT "Êtes-vous sûr de vouloir vous déconnecter ?", IDC_STATIC, 35, 16, 
146, 8
 PUSHBUTTON "Oui", IDYES, 41, 39, 50, 14, BS_DEFPUSHBUTTON
 PUSHBUTTON "Non", IDNO, 95, 39, 50, 14
 END
@@ -153,7 +153,7 @@ BEGIN
 AUTOCHECKBOX "&Planifié", IDC_REASON_PLANNED, 182, 154, 47, 10
 COMBOBOX IDC_REASON_LIST, 39, 165, 190, 210, CBS_DROPDOWNLIST | WS_VSCROLL 
| WS_TABSTOP
 LTEXT "", IDC_REASON_DESCRIPTION, 39, 184, 190, 27
-LTEXT "&Commentaire:", IDC_STATIC, 39, 214, 80, 8
+LTEXT "&Commentaire :", IDC_STATIC, 39, 214, 80, 8
 EDITTEXT IDC_REASON_COMMENT, 39, 224, 190, 35, ES_MULTILINE | WS_VISIBLE | 
WS_TABSTOP
 DEFPUSHBUTTON "OK", IDOK, 150, 276, 55, 14, WS_GROUP
 PUSHBUTTON "Annuler", IDCANCEL, 211, 276, 55, 14
@@ -202,11 +202,11 @@ BEGIN
 IDS_LOGONUSERDISABLED "Votre compte est désactivé. Voyez votre 
administrateur système."
 IDS_PASSWORDMUSTCHANGE "Vous devez changer votre mot de passe à la 
première connexion."
 IDS_PASSWORDEXPIRED "Votre mot de passe a expiré et doit être changé."
-IDS_ACCOUNTEXPIRED "Your account has expired. Please see your system 
administrator."
-IDS_ACCOUNTLOCKED "Unable to log you on beacuse your account has been 
locked out. Please see your system administrator."
-IDS_INVALIDLOGONHOURS "Your account has time restrictions that prevent you 
from logging on at this time. Please try again later."
-IDS_INVALIDWORKSTATION "Your account is configured to prevent you from 
using this computer. Please try another computer."
-IDS_ACCOUNTRESTRICTION "Unable to log you on because of an account 
restriction."
+IDS_ACCOUNTEXPIRED "Votre compte a expiré. Veuillez contacter votre 
administrateur système."
+IDS_ACCOUNTLOCKED "Impossible de vous connecter car votre compte est 
verrouillé. Veuillez contacter votre administrateur système."
+IDS_INVALIDLOGONHOURS "Votre compte a des restrictions temporelles qui 
vous empêchent de vous connecter à cette heure-ci. Veuillez réessayer 
ultérieurement."
+IDS_INVALIDWORKSTATION "Votre compte a été configuré pour que vous 
n'utilisiez pas cet ordinateur. Veuillez réessayer depuis un autre ordinateur."
+IDS_ACCOUNTRESTRICTION "Impossible de vous connecter en raison d'une 
restriction sur votre compte."
 END
 
 /* Shutdown Dialog Strings */



[ros-diffs] [reactos] 03/03: [NTOSKRNL] Taggify some allocs

2019-06-10 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=651ba03c6d5e252b837c57bf3c9fd63d8a7f9e60

commit 651ba03c6d5e252b837c57bf3c9fd63d8a7f9e60
Author: Pierre Schweitzer 
AuthorDate: Mon Jun 10 14:54:55 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Jun 10 14:54:55 2019 +0200

[NTOSKRNL] Taggify some allocs
---
 ntoskrnl/include/internal/tag.h |  2 ++
 ntoskrnl/se/srm.c   | 16 ++--
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/ntoskrnl/include/internal/tag.h b/ntoskrnl/include/internal/tag.h
index cca581f15cf..dc47c9cd4f4 100644
--- a/ntoskrnl/include/internal/tag.h
+++ b/ntoskrnl/include/internal/tag.h
@@ -178,6 +178,8 @@
 #define TAG_LUID  'uLeS'
 #define TAG_PRIVILEGE_SET 'rPeS'
 #define TAG_TOKEN_DYNAMIC 'dTeS'
+#define TAG_SE_HANDLES_TAB'aHeS'
+#define TAG_SE_DIR_BUFFER 'bDeS'
 
 /* LPC Tags */
 #define TAG_LPC_MESSAGE   'McpL'
diff --git a/ntoskrnl/se/srm.c b/ntoskrnl/se/srm.c
index fc91cd1f1dc..d67305036a9 100644
--- a/ntoskrnl/se/srm.c
+++ b/ntoskrnl/se/srm.c
@@ -489,7 +489,9 @@ SepCleanupLUIDDeviceMapDirectory(
  * All handles have been already closed
  */
 AllocateLinksAgain:
-LinksBuffer = ExAllocatePoolWithTag(PagedPool, LinksSize, 'aHeS');
+LinksBuffer = ExAllocatePoolWithTag(PagedPool,
+LinksSize,
+TAG_SE_HANDLES_TAB);
 if (LinksBuffer == NULL)
 {
 /*
@@ -504,7 +506,7 @@ AllocateLinksAgain:
  */
 if (DirectoryInfo != NULL)
 {
-ExFreePoolWithTag(DirectoryInfo, 0);
+ExFreePoolWithTag(DirectoryInfo, TAG_SE_DIR_BUFFER);
 }
 
 if (!UseCurrentProc)
@@ -551,7 +553,9 @@ AllocateLinksAgain:
 }
 
 /* And reallocate a bigger one */
-DirectoryInfo = ExAllocatePoolWithTag(PagedPool, DirInfoLength, 
'bDeS');
+DirectoryInfo = ExAllocatePoolWithTag(PagedPool,
+  DirInfoLength,
+  TAG_SE_DIR_BUFFER);
 /* Fail if we cannot allocate */
 if (DirectoryInfo == NULL)
 {
@@ -584,7 +588,7 @@ AllocateLinksAgain:
 /* Allow 20 more HANDLEs */
 LinksCount += 20;
 CurrentLinks = 0;
-ExFreePoolWithTag(LinksBuffer, 'aHeS');
+ExFreePoolWithTag(LinksBuffer, TAG_SE_HANDLES_TAB);
 LinksSize = LinksCount * sizeof(HANDLE);
 
 /* And reloop again */
@@ -627,12 +631,12 @@ AllocateLinksAgain:
 ZwClose(LinksBuffer[i]);
 }
 /* And free our links buffer */
-ExFreePoolWithTag(LinksBuffer, 'aHeS');
+ExFreePoolWithTag(LinksBuffer, TAG_SE_HANDLES_TAB);
 
 /* Free our directory info buffer - it might be NULL if we failed realloc 
*/
 if (DirectoryInfo != NULL)
 {
-ExFreePoolWithTag(DirectoryInfo, 'bDeS');
+ExFreePoolWithTag(DirectoryInfo, TAG_SE_DIR_BUFFER);
 }
 
 /* Close our session directory */



[ros-diffs] [reactos] 01/03: [NTOSKRNL] On session last reference removal, dereference LUID device map

2019-06-10 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5ecc05003d2a7cfda9f6aff299188b39c92ef273

commit 5ecc05003d2a7cfda9f6aff299188b39c92ef273
Author: Pierre Schweitzer 
AuthorDate: Mon Jun 10 12:30:49 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Jun 10 12:30:49 2019 +0200

[NTOSKRNL] On session last reference removal, dereference LUID device map
---
 ntoskrnl/se/srm.c | 28 ++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/ntoskrnl/se/srm.c b/ntoskrnl/se/srm.c
index f0cc7341093..9134ebadb5d 100644
--- a/ntoskrnl/se/srm.c
+++ b/ntoskrnl/se/srm.c
@@ -392,7 +392,7 @@ SepRmReferenceLogonSession(
 if (RtlEqualLuid(&CurrentSession->LogonId, LogonLuid))
 {
 /* Reference the session */
-CurrentSession->ReferenceCount += 1;
+++CurrentSession->ReferenceCount;
 DPRINT("ReferenceCount: %lu\n", CurrentSession->ReferenceCount);
 
 /* Release the database lock */
@@ -409,10 +409,21 @@ SepRmReferenceLogonSession(
 }
 
 
+NTSTATUS
+SepCleanupLUIDDeviceMapDirectory(
+PLUID LogonLuid)
+{
+UNIMPLEMENTED;
+return STATUS_NOT_IMPLEMENTED;
+}
+
+
 NTSTATUS
 SepRmDereferenceLogonSession(
 PLUID LogonLuid)
 {
+ULONG RefCount;
+PDEVICE_MAP DeviceMap;
 PSEP_LOGON_SESSION_REFERENCES CurrentSession;
 
 DPRINT("SepRmDereferenceLogonSession(%08lx:%08lx)\n",
@@ -430,12 +441,25 @@ SepRmDereferenceLogonSession(
 if (RtlEqualLuid(&CurrentSession->LogonId, LogonLuid))
 {
 /* Dereference the session */
-CurrentSession->ReferenceCount -= 1;
+RefCount = --CurrentSession->ReferenceCount;
 DPRINT("ReferenceCount: %lu\n", CurrentSession->ReferenceCount);
 
 /* Release the database lock */
 KeReleaseGuardedMutex(&SepRmDbLock);
 
+/* We're done with the session */
+if (RefCount == 0)
+{
+/* Get rid of the LUID device map */
+DeviceMap = CurrentSession->pDeviceMap;
+if (DeviceMap != NULL)
+{
+CurrentSession->pDeviceMap = NULL;
+SepCleanupLUIDDeviceMapDirectory(LogonLuid);
+ObfDereferenceDeviceMap(DeviceMap);
+}
+}
+
 return STATUS_SUCCESS;
 }
 }



[ros-diffs] [reactos] 02/03: [NTOSKRNL] Implement SepCleanupLUIDDeviceMapDirectory This will clean up all the links (drive letters) created by an user on session deletion once LUID device maps are in

2019-06-10 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a5daa8894d05dae1c9e8ba075a49205384c0deb9

commit a5daa8894d05dae1c9e8ba075a49205384c0deb9
Author: Pierre Schweitzer 
AuthorDate: Mon Jun 10 14:49:50 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Jun 10 14:49:50 2019 +0200

[NTOSKRNL] Implement SepCleanupLUIDDeviceMapDirectory
This will clean up all the links (drive letters) created
by an user on session deletion once LUID device maps are
in use
---
 ntoskrnl/se/srm.c | 234 +-
 1 file changed, 232 insertions(+), 2 deletions(-)

diff --git a/ntoskrnl/se/srm.c b/ntoskrnl/se/srm.c
index 9134ebadb5d..fc91cd1f1dc 100644
--- a/ntoskrnl/se/srm.c
+++ b/ntoskrnl/se/srm.c
@@ -413,8 +413,238 @@ NTSTATUS
 SepCleanupLUIDDeviceMapDirectory(
 PLUID LogonLuid)
 {
-UNIMPLEMENTED;
-return STATUS_NOT_IMPLEMENTED;
+BOOLEAN UseCurrentProc;
+KAPC_STATE ApcState;
+WCHAR Buffer[63];
+UNICODE_STRING DirectoryName;
+OBJECT_ATTRIBUTES ObjectAttributes;
+NTSTATUS Status;
+HANDLE DirectoryHandle, LinkHandle;
+PHANDLE LinksBuffer;
+POBJECT_DIRECTORY_INFORMATION DirectoryInfo;
+ULONG LinksCount, LinksSize, DirInfoLength, ReturnLength, Context, 
CurrentLinks, i;
+BOOLEAN RestartScan;
+
+PAGED_CODE();
+
+/* We need a logon LUID */
+if (LogonLuid == NULL)
+{
+return STATUS_INVALID_PARAMETER;
+}
+
+/* Use current process */
+UseCurrentProc = ObReferenceObjectSafe(PsGetCurrentProcess());
+if (UseCurrentProc)
+{
+ObDereferenceObject(PsGetCurrentProcess());
+}
+/* Unless it's gone, then use system process */
+else
+{
+KeStackAttachProcess(&PsInitialSystemProcess->Pcb, &ApcState);
+}
+
+/* Initialize our directory name */
+_snwprintf(Buffer,
+   sizeof(Buffer) / sizeof(WCHAR),
+   L"\\Sessions\\0\\DosDevices\\%08x-%08x",
+   LogonLuid->HighPart,
+   LogonLuid->LowPart);
+RtlInitUnicodeString(&DirectoryName, Buffer);
+
+/* And open it */
+InitializeObjectAttributes(&ObjectAttributes,
+   &DirectoryName,
+   OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE,
+   NULL,
+   NULL);
+Status = ZwOpenDirectoryObject(&DirectoryHandle,
+   DIRECTORY_QUERY,
+   &ObjectAttributes);
+if (!NT_SUCCESS(Status))
+{
+if (!UseCurrentProc)
+{
+KeUnstackDetachProcess(&ApcState);
+}
+
+return Status;
+}
+
+/* Some initialization needed for browsing all our links... */
+Context = 0;
+DirectoryInfo = NULL;
+DirInfoLength = 0;
+/* In our buffer, we'll store at max 100 HANDLE */
+LinksCount = 100;
+CurrentLinks = 0;
+/* Which gives a certain size */
+LinksSize = LinksCount * sizeof(HANDLE);
+
+/*
+ * This label is hit if we need to store more than a hundred
+ * of links. In that case, we jump here after having cleaned
+ * and deleted previous buffer.
+ * All handles have been already closed
+ */
+AllocateLinksAgain:
+LinksBuffer = ExAllocatePoolWithTag(PagedPool, LinksSize, 'aHeS');
+if (LinksBuffer == NULL)
+{
+/*
+ * Failure path: no need to clear handles:
+ * already closed and the buffer is already gone
+ */
+ZwClose(DirectoryHandle);
+
+/*
+ * On the first round, DirectoryInfo is NULL,
+ * if we grow LinksBuffer, it has been allocated
+ */
+if (DirectoryInfo != NULL)
+{
+ExFreePoolWithTag(DirectoryInfo, 0);
+}
+
+if (!UseCurrentProc)
+{
+KeUnstackDetachProcess(&ApcState);
+}
+
+return STATUS_NO_MEMORY;
+}
+
+/*
+ * We always restart scan, but on the first loop
+ * if we couldn't fit everything in our buffer,
+ * then, we continue scan.
+ * But we restart if link buffer was too small
+ */
+for (RestartScan = TRUE; ; RestartScan = FALSE)
+{
+/*
+ * Loop until our buffer is big enough to store
+ * one entry
+ */
+while (TRUE)
+{
+Status = ZwQueryDirectoryObject(DirectoryHandle,
+DirectoryInfo,
+DirInfoLength,
+TRUE,
+RestartScan,
+&Context,
+&ReturnLength);
+/* Only handle buffer growth in that loop */
+if (Status != STATUS_BUFFER_TOO_SMALL)
+{

[ros-diffs] [reactos] 01/01: [NTOSKRNL] Implement NtSetInformationProcess:ProcessDeviceMap

2019-06-10 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ad80715b1adb444a514b43a7c6c868b0cac4be34

commit ad80715b1adb444a514b43a7c6c868b0cac4be34
Author: Pierre Schweitzer 
AuthorDate: Mon Jun 3 08:12:16 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Mon Jun 10 10:35:24 2019 +0200

[NTOSKRNL] Implement NtSetInformationProcess:ProcessDeviceMap
---
 ntoskrnl/ps/query.c | 34 +-
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/ntoskrnl/ps/query.c b/ntoskrnl/ps/query.c
index 5391ae18d64..31275a5247f 100644
--- a/ntoskrnl/ps/query.c
+++ b/ntoskrnl/ps/query.c
@@ -1120,6 +1120,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
 NTSTATUS Status;
 HANDLE PortHandle = NULL;
 HANDLE TokenHandle = NULL;
+HANDLE DirectoryHandle = NULL;
 PROCESS_SESSION_INFORMATION SessionInfo = {0};
 PROCESS_PRIORITY_CLASS PriorityClass = {0};
 PROCESS_FOREGROUND_BACKGROUND Foreground = {0};
@@ -1939,6 +1940,34 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
 Status = MmSetExecuteOptions(NoExecute);
 break;
 
+case ProcessDeviceMap:
+
+/* Check buffer length */
+if (ProcessInformationLength != sizeof(HANDLE))
+{
+Status = STATUS_INFO_LENGTH_MISMATCH;
+break;
+}
+
+/* Use SEH for capture */
+_SEH2_TRY
+{
+/* Capture the handle */
+DirectoryHandle = *(PHANDLE)ProcessInformation;
+}
+_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+{
+/* Get the exception code */
+Status = _SEH2_GetExceptionCode();
+_SEH2_YIELD(break);
+}
+_SEH2_END;
+
+/* Call Ob to set the device map */
+Status = ObSetDeviceMap(Process, DirectoryHandle);
+break;
+
+
 /* We currently don't implement any of these */
 case ProcessLdtInformation:
 case ProcessLdtSize:
@@ -1961,11 +1990,6 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
 Status = STATUS_NOT_IMPLEMENTED;
 break;
 
-case ProcessDeviceMap:
-DPRINT1("Device map not implemented\n");
-Status = STATUS_NOT_IMPLEMENTED;
-break;
-
 case ProcessHandleTracing:
 DPRINT1("Handle tracing not implemented\n");
 Status = STATUS_NOT_IMPLEMENTED;



[ros-diffs] [reactos] 01/01: [NTOSKRNL] Add support for global DOS directory in ObpLookupEntryDirectory If any exists, we'll loop over in that directory, trying to find the object

2019-06-02 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fd4752450f9453aa9c635d87bed6b7a340fd1713

commit fd4752450f9453aa9c635d87bed6b7a340fd1713
Author: Pierre Schweitzer 
AuthorDate: Sun Jun 2 21:44:45 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sun Jun 2 21:46:35 2019 +0200

[NTOSKRNL] Add support for global DOS directory in ObpLookupEntryDirectory
If any exists, we'll loop over in that directory, trying to find the object
---
 ntoskrnl/ob/obdir.c | 47 +--
 1 file changed, 45 insertions(+), 2 deletions(-)

diff --git a/ntoskrnl/ob/obdir.c b/ntoskrnl/ob/obdir.c
index f8e3a36a06a..83d05d4beb9 100644
--- a/ntoskrnl/ob/obdir.c
+++ b/ntoskrnl/ob/obdir.c
@@ -92,6 +92,42 @@ ObpInsertEntryDirectory(IN POBJECT_DIRECTORY Parent,
 return TRUE;
 }
 
+/*++
+* @name ObpGetShadowDirectory
+*
+* The ObpGetShadowDirectory routine .
+*
+* @param Directory
+*.
+*
+* @return Pointer to the global DOS directory if any, or NULL otherwise.
+*
+* @remarks None.
+*
+*--*/
+POBJECT_DIRECTORY
+NTAPI
+ObpGetShadowDirectory(IN POBJECT_DIRECTORY Directory)
+{
+PDEVICE_MAP DeviceMap;
+POBJECT_DIRECTORY GlobalDosDirectory = NULL;
+
+/* Acquire the device map lock */
+KeAcquireGuardedMutex(&ObpDeviceMapLock);
+
+/* Get the global DOS directory if any */
+DeviceMap = Directory->DeviceMap;
+if (DeviceMap != NULL)
+{
+GlobalDosDirectory = DeviceMap->GlobalDosDevicesDirectory;
+}
+
+/* Release the devicemap lock */
+KeReleaseGuardedMutex(&ObpDeviceMapLock);
+
+return GlobalDosDirectory;
+}
+
 /*++
 * @name ObpLookupEntryDirectory
 *
@@ -137,6 +173,7 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory,
 POBJECT_DIRECTORY_ENTRY CurrentEntry;
 PVOID FoundObject = NULL;
 PWSTR Buffer;
+POBJECT_DIRECTORY ShadowDirectory;
 PAGED_CODE();
 
 /* Check if we should search the shadow directory */
@@ -181,6 +218,7 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory,
 AllocatedEntry = &Directory->HashBuckets[HashIndex];
 LookupBucket = AllocatedEntry;
 
+DoItAgain:
 /* Check if the directory is already locked */
 if (!Context->DirectoryLocked)
 {
@@ -250,8 +288,13 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory,
 /* Check if we should scan the shadow directory */
 if ((SearchShadow) && (Directory->DeviceMap))
 {
-/* FIXME: We don't support this yet */
-ASSERT(FALSE);
+ShadowDirectory = ObpGetShadowDirectory(Directory);
+/* A global DOS directory was found, loop it again */
+if (ShadowDirectory != NULL)
+{
+Directory = ShadowDirectory;
+goto DoItAgain;
+}
 }
 }
 



[ros-diffs] [reactos] 01/01: [NTOSKRNL] In case IopMountVolume call is a success, return its VPB This fixes an extra (erroneous) reference being set on the VPB.

2019-06-02 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9c3c0d123bf2306b808262fba1d3a224be9fac96

commit 9c3c0d123bf2306b808262fba1d3a224be9fac96
Author: Pierre Schweitzer 
AuthorDate: Sun Jun 2 10:48:35 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sun Jun 2 10:48:35 2019 +0200

[NTOSKRNL] In case IopMountVolume call is a success, return its VPB
This fixes an extra (erroneous) reference being set on the VPB.

Based on a patch by Vadim Galyant

CORE-16080
---
 ntoskrnl/io/iomgr/volume.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/ntoskrnl/io/iomgr/volume.c b/ntoskrnl/io/iomgr/volume.c
index 6c2e3191e9a..1d1e31e5c0d 100644
--- a/ntoskrnl/io/iomgr/volume.c
+++ b/ntoskrnl/io/iomgr/volume.c
@@ -123,6 +123,14 @@ IopCheckVpbMounted(IN POPEN_PACKET OpenPacket,
 *Status = STATUS_WRONG_VOLUME;
 return NULL;
 }
+/*
+ * In case IopMountVolume returns a valid VPB
+ * Then, the volume is mounted, return it
+ */
+else if (Vpb != NULL)
+{
+return Vpb;
+}
 
 /* Re-acquire the lock */
 IoAcquireVpbSpinLock(&OldIrql);



[ros-diffs] [reactos] 01/01: [NTOSKRNL] On process primary token change, dereference device map

2019-06-02 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f8a4d31da489660d48975a685da49fb1f4748685

commit f8a4d31da489660d48975a685da49fb1f4748685
Author: Pierre Schweitzer 
AuthorDate: Sun Jun 2 09:50:05 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sun Jun 2 10:00:17 2019 +0200

[NTOSKRNL] On process primary token change, dereference device map
---
 ntoskrnl/ps/security.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/ntoskrnl/ps/security.c b/ntoskrnl/ps/security.c
index e245dde563f..619ff56d247 100644
--- a/ntoskrnl/ps/security.c
+++ b/ntoskrnl/ps/security.c
@@ -325,6 +325,14 @@ PspSetPrimaryToken(IN PEPROCESS Process,
STANDARD_RIGHTS_ALL |
PROCESS_SET_QUOTA);
 }
+
+/*
+ * In case LUID device maps are enable, we may not be using
+ * system device map for this process, but a logon LUID based
+ * device map. Because we change primary token, this usage is
+ * no longer valid, so dereference the process device map
+ */
+if (ObIsLUIDDeviceMapsEnabled()) ObDereferenceDeviceMap(Process);
 }
 
 /* Dereference the token */



[ros-diffs] [reactos] 02/02: [NTOSKRNL] Implement ObSetDirectoryDeviceMap

2019-06-01 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=de17b3603726bd3fdf668b344f47dbf15425ca0f

commit de17b3603726bd3fdf668b344f47dbf15425ca0f
Author: Pierre Schweitzer 
AuthorDate: Sat Jun 1 21:22:30 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Jun 1 21:22:30 2019 +0200

[NTOSKRNL] Implement ObSetDirectoryDeviceMap
---
 ntoskrnl/ob/devicemap.c | 93 +++--
 1 file changed, 91 insertions(+), 2 deletions(-)

diff --git a/ntoskrnl/ob/devicemap.c b/ntoskrnl/ob/devicemap.c
index 5dfe1994dd8..5d583e9388b 100644
--- a/ntoskrnl/ob/devicemap.c
+++ b/ntoskrnl/ob/devicemap.c
@@ -149,8 +149,97 @@ NTAPI
 ObSetDirectoryDeviceMap(OUT PDEVICE_MAP * DeviceMap,
 IN HANDLE DirectoryHandle)
 {
-UNIMPLEMENTED;
-return STATUS_NOT_IMPLEMENTED;
+POBJECT_DIRECTORY DirectoryObject = NULL;
+PDEVICE_MAP LocalMap = NULL, NewDeviceMap = NULL;
+NTSTATUS Status;
+POBJECT_HEADER ObjectHeader;
+POBJECT_HEADER_NAME_INFO HeaderNameInfo;
+
+Status = ObReferenceObjectByHandle(DirectoryHandle,
+   DIRECTORY_TRAVERSE,
+   ObpDirectoryObjectType,
+   KernelMode,
+   (PVOID*)&DirectoryObject,
+   NULL);
+if (!NT_SUCCESS(Status))
+{
+DPRINT("ObReferenceObjectByHandle() failed (Status 0x%08lx)\n", 
Status);
+return Status;
+}
+
+/* Allocate and initialize a new device map */
+LocalMap = ExAllocatePoolWithTag(PagedPool,
+ sizeof(*LocalMap),
+ 'mDbO');
+if (LocalMap == NULL)
+{
+ObDereferenceObject(DirectoryObject);
+return STATUS_INSUFFICIENT_RESOURCES;
+}
+
+/* Initialize the device map */
+RtlZeroMemory(LocalMap, sizeof(*LocalMap));
+LocalMap->ReferenceCount = 1;
+LocalMap->DosDevicesDirectory = DirectoryObject;
+
+/* Acquire the device map lock */
+KeAcquireGuardedMutex(&ObpDeviceMapLock);
+
+/* Attach the device map to the directory object */
+if (DirectoryObject->DeviceMap == NULL)
+{
+DirectoryObject->DeviceMap = LocalMap;
+}
+else
+{
+NewDeviceMap = LocalMap;
+
+/* There's already a device map,
+   so reuse it */
+LocalMap = DirectoryObject->DeviceMap;
+++LocalMap->ReferenceCount;
+}
+
+/* If current object isn't system one, save system one in current
+ * device map */
+if (DirectoryObject != ObSystemDeviceMap->DosDevicesDirectory)
+{
+/* We also need to make the object permanant */
+LocalMap->GlobalDosDevicesDirectory = 
ObSystemDeviceMap->DosDevicesDirectory;
+}
+
+/* Release the device map lock */
+KeReleaseGuardedMutex(&ObpDeviceMapLock);
+
+if (DeviceMap != NULL)
+{
+*DeviceMap = LocalMap;
+}
+
+/* Caller expects us to make the object permanant, so do it! */
+ObjectHeader = OBJECT_TO_OBJECT_HEADER(DirectoryObject);
+HeaderNameInfo = ObpReferenceNameInfo(ObjectHeader);
+
+ObpEnterObjectTypeMutex(ObjectHeader->Type);
+if (HeaderNameInfo != NULL && HeaderNameInfo->Directory != NULL)
+{
+ObjectHeader->Flags |= OB_FLAG_PERMANENT;
+}
+ObpLeaveObjectTypeMutex(ObjectHeader->Type);
+
+if (HeaderNameInfo != NULL)
+{
+ObpDereferenceNameInfo(HeaderNameInfo);
+}
+
+/* Release useless device map if required */
+if (NewDeviceMap != NULL)
+{
+ObfDereferenceObject(DirectoryObject);
+ExFreePoolWithTag(NewDeviceMap, 'mDbO');
+}
+
+return Status;
 }
 
 



[ros-diffs] [reactos] 01/02: [NTOSKRNL] Implement SeGetLogonIdDeviceMap

2019-06-01 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7c618faa326bde0337ca74f50b02215576e8a397

commit 7c618faa326bde0337ca74f50b02215576e8a397
Author: Pierre Schweitzer 
AuthorDate: Sat Jun 1 21:05:14 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Jun 1 21:09:20 2019 +0200

[NTOSKRNL] Implement SeGetLogonIdDeviceMap
---
 ntoskrnl/include/internal/ob.h |   9 ++-
 ntoskrnl/ob/devicemap.c|  10 +++
 ntoskrnl/se/srm.c  | 145 -
 3 files changed, 161 insertions(+), 3 deletions(-)

diff --git a/ntoskrnl/include/internal/ob.h b/ntoskrnl/include/internal/ob.h
index 23f54cefefd..266c4dd668c 100644
--- a/ntoskrnl/include/internal/ob.h
+++ b/ntoskrnl/include/internal/ob.h
@@ -402,7 +402,14 @@ NTSTATUS
 NTAPI
 ObSetDeviceMap(
 IN PEPROCESS Process,
-IN HANDLE DirectoryHandle);
+IN HANDLE DirectoryHandle
+);
+
+NTSTATUS
+NTAPI
+ObSetDirectoryDeviceMap(OUT PDEVICE_MAP * DeviceMap,
+IN HANDLE DirectoryHandle
+);
 
 VOID
 NTAPI
diff --git a/ntoskrnl/ob/devicemap.c b/ntoskrnl/ob/devicemap.c
index 8a471446919..5dfe1994dd8 100644
--- a/ntoskrnl/ob/devicemap.c
+++ b/ntoskrnl/ob/devicemap.c
@@ -144,6 +144,16 @@ ObSetDeviceMap(IN PEPROCESS Process,
 }
 
 
+NTSTATUS
+NTAPI
+ObSetDirectoryDeviceMap(OUT PDEVICE_MAP * DeviceMap,
+IN HANDLE DirectoryHandle)
+{
+UNIMPLEMENTED;
+return STATUS_NOT_IMPLEMENTED;
+}
+
+
 NTSTATUS
 NTAPI
 ObpSetCurrentProcessDeviceMap(VOID)
diff --git a/ntoskrnl/se/srm.c b/ntoskrnl/se/srm.c
index 7d1526623c6..f0cc7341093 100644
--- a/ntoskrnl/se/srm.c
+++ b/ntoskrnl/se/srm.c
@@ -5,6 +5,7 @@
  * PURPOSE: Security Reference Monitor Server
  *
  * PROGRAMMERS: Timo Kreuzer (timo.kreu...@reactos.org)
+ *  Pierre Schweitzer (pie...@reactos.org)
  */
 
 /* INCLUDES 
***/
@@ -701,8 +702,148 @@ SeGetLogonIdDeviceMap(
 OUT PDEVICE_MAP * DeviceMap
 )
 {
-UNIMPLEMENTED;
-return STATUS_NOT_IMPLEMENTED;
+NTSTATUS Status;
+WCHAR Buffer[63];
+PDEVICE_MAP LocalMap;
+HANDLE DirectoryHandle, LinkHandle;
+OBJECT_ATTRIBUTES ObjectAttributes;
+PSEP_LOGON_SESSION_REFERENCES CurrentSession;
+UNICODE_STRING DirectoryName, LinkName, TargetName;
+
+PAGED_CODE();
+
+if  (LogonId == NULL ||
+ DeviceMap == NULL)
+{
+return STATUS_INVALID_PARAMETER;
+}
+
+/* Acquire the database lock */
+KeAcquireGuardedMutex(&SepRmDbLock);
+
+/* Loop all existing sessions */
+for (CurrentSession = SepLogonSessions;
+ CurrentSession != NULL;
+ CurrentSession = CurrentSession->Next)
+{
+/* Check if the LUID matches the provided one */
+if (RtlEqualLuid(&CurrentSession->LogonId, LogonId))
+{
+break;
+}
+}
+
+/* No session found, fail */
+if (CurrentSession == NULL)
+{
+/* Release the database lock */
+KeReleaseGuardedMutex(&SepRmDbLock);
+
+return STATUS_NO_SUCH_LOGON_SESSION;
+}
+
+/* The found session has a device map, return it! */
+if (CurrentSession->pDeviceMap != NULL)
+{
+*DeviceMap = CurrentSession->pDeviceMap;
+
+/* Release the database lock */
+KeReleaseGuardedMutex(&SepRmDbLock);
+
+return STATUS_SUCCESS;
+}
+
+/* At that point, we'll setup a new device map for the session */
+LocalMap = NULL;
+
+/* Reference the session so that it doesn't go away */
+CurrentSession->ReferenceCount += 1;
+
+/* Release the database lock */
+KeReleaseGuardedMutex(&SepRmDbLock);
+
+/* Create our object directory given the LUID */
+_snwprintf(Buffer,
+   sizeof(Buffer) / sizeof(WCHAR),
+   L"\\Sessions\\0\\DosDevices\\%08x-%08x",
+   LogonId->HighPart,
+   LogonId->LowPart);
+RtlInitUnicodeString(&DirectoryName, Buffer);
+
+InitializeObjectAttributes(&ObjectAttributes,
+   &DirectoryName,
+   OBJ_KERNEL_HANDLE | OBJ_OPENIF | 
OBJ_CASE_INSENSITIVE,
+   NULL,
+   NULL);
+Status = ZwCreateDirectoryObject(&DirectoryHandle,
+ DIRECTORY_ALL_ACCESS,
+ &ObjectAttributes);
+if (NT_SUCCESS(Status))
+{
+/* Create the associated device map */
+Status = ObSetDirectoryDeviceMap(&LocalMap, DirectoryHandle);
+if (NT_SUCCESS(Status))
+{
+/* Make Global point to \Global?? in the directory */
+RtlInitUnicodeString(&LinkName, L"Global");
+RtlInitUnicodeString(&TargetName, L"\\Global??");
+
+InitializeObjectAttributes(&ObjectAtt

[ros-diffs] [reactos] 07/07: [NTOSKRNL] Implement ObpSetCurrentProcessDeviceMap

2019-06-01 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4bf7d54910acb38fdc33de8177c33d7967ece69e

commit 4bf7d54910acb38fdc33de8177c33d7967ece69e
Author: Pierre Schweitzer 
AuthorDate: Sat Jun 1 18:58:36 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Jun 1 18:58:36 2019 +0200

[NTOSKRNL] Implement ObpSetCurrentProcessDeviceMap
---
 ntoskrnl/ob/devicemap.c | 72 -
 1 file changed, 71 insertions(+), 1 deletion(-)

diff --git a/ntoskrnl/ob/devicemap.c b/ntoskrnl/ob/devicemap.c
index 12abcb90595..8a471446919 100644
--- a/ntoskrnl/ob/devicemap.c
+++ b/ntoskrnl/ob/devicemap.c
@@ -5,6 +5,7 @@
  * PURPOSE: Device map implementation
  * PROGRAMMERS: Eric Kohl (eric.k...@reactos.org)
  *  Alex Ionescu (alex.ione...@reactos.org)
+ *  Pierre Schweitzer (pie...@reactos.org)
  */
 
 /* INCLUDES ***/
@@ -147,7 +148,76 @@ NTSTATUS
 NTAPI
 ObpSetCurrentProcessDeviceMap(VOID)
 {
-return STATUS_NOT_IMPLEMENTED;
+PTOKEN Token;
+LUID LogonId;
+NTSTATUS Status;
+PEPROCESS CurrentProcess;
+LUID SystemLuid = SYSTEM_LUID;
+PDEVICE_MAP DeviceMap, OldDeviceMap;
+
+/* Get our impersonation token */
+CurrentProcess = PsGetCurrentProcess();
+Token = PsReferencePrimaryToken(CurrentProcess);
+if (Token == NULL)
+{
+return STATUS_NO_TOKEN;
+}
+
+/* Query the Logon ID */
+Status = SeQueryAuthenticationIdToken(Token, &LogonId);
+if (!NT_SUCCESS(Status))
+{
+goto done;
+}
+
+/* If that's system, then use system device map */
+if (RtlEqualLuid(&LogonId, &SystemLuid))
+{
+DeviceMap = ObSystemDeviceMap;
+}
+/* Otherwise ask Se for the device map */
+else
+{
+Status = SeGetLogonIdDeviceMap(&LogonId, &DeviceMap);
+if (!NT_SUCCESS(Status))
+{
+/* Normalize failure status */
+Status = STATUS_OBJECT_PATH_INVALID;
+goto done;
+}
+}
+
+/* Fail if no device map */
+if (DeviceMap == NULL)
+{
+Status = STATUS_OBJECT_PATH_INVALID;
+goto done;
+}
+
+/* Acquire the device map lock */
+KeAcquireGuardedMutex(&ObpDeviceMapLock);
+
+/* Save old device map attached to the process */
+OldDeviceMap = CurrentProcess->DeviceMap;
+
+/* Set new device map & reference it */
+++DeviceMap->ReferenceCount;
+CurrentProcess->DeviceMap = DeviceMap;
+
+/* Release the device map lock */
+KeReleaseGuardedMutex(&ObpDeviceMapLock);
+
+/* If we had a device map, dereference it */
+if (OldDeviceMap != NULL)
+{
+ObfDereferenceDeviceMap(OldDeviceMap);
+}
+
+done:
+/* We're done with the token! */
+ObDereferenceObject(Token);
+
+return Status;
 }
 
 



[ros-diffs] [reactos] 06/07: [NTOSKRNL] Implement ObpReferenceDeviceMap()

2019-06-01 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=57c608680672fcab9461a0a88ac5ea283a6d312f

commit 57c608680672fcab9461a0a88ac5ea283a6d312f
Author: Pierre Schweitzer 
AuthorDate: Sat Jun 1 18:43:38 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Jun 1 18:43:38 2019 +0200

[NTOSKRNL] Implement ObpReferenceDeviceMap()
---
 ntoskrnl/ob/devicemap.c | 134 +++-
 1 file changed, 132 insertions(+), 2 deletions(-)

diff --git a/ntoskrnl/ob/devicemap.c b/ntoskrnl/ob/devicemap.c
index 4dcaff1c832..12abcb90595 100644
--- a/ntoskrnl/ob/devicemap.c
+++ b/ntoskrnl/ob/devicemap.c
@@ -143,12 +143,142 @@ ObSetDeviceMap(IN PEPROCESS Process,
 }
 
 
+NTSTATUS
+NTAPI
+ObpSetCurrentProcessDeviceMap(VOID)
+{
+return STATUS_NOT_IMPLEMENTED;
+}
+
+
 PDEVICE_MAP
 NTAPI
 ObpReferenceDeviceMap(VOID)
 {
-UNIMPLEMENTED;
-return NULL;
+LUID LogonId;
+NTSTATUS Status;
+PTOKEN Token = NULL;
+PDEVICE_MAP DeviceMap;
+PETHREAD CurrentThread;
+BOOLEAN LookingForSystem;
+LUID SystemLuid = SYSTEM_LUID;
+BOOLEAN CopyOnOpen, EffectiveOnly;
+SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
+
+LookingForSystem = FALSE;
+
+/* If LUID mapping is enable, try to get appropriate device map */
+if (ObpLUIDDeviceMapsEnabled != 0)
+{
+/* In case of impersonation, we've got a bit of work to do */
+CurrentThread = PsGetCurrentThread();
+if (CurrentThread->ActiveImpersonationInfo)
+{
+/* Get impersonation token */
+Token = PsReferenceImpersonationToken(CurrentThread,
+  &CopyOnOpen,
+  &EffectiveOnly,
+  &ImpersonationLevel);
+/* Get logon LUID */
+if (Token != NULL)
+{
+Status = SeQueryAuthenticationIdToken(Token, &LogonId);
+}
+else
+{
+/* Force failure */
+Status = STATUS_NO_TOKEN;
+}
+
+/* If we got logon LUID */
+if (NT_SUCCESS(Status))
+{
+/*
+ * Check it's not system, system is easy to handle,
+ * we just need to return ObSystemDeviceMap
+ */
+if (!RtlEqualLuid(&LogonId, &SystemLuid))
+{
+/* Ask Se for the device  map */
+Status = SeGetLogonIdDeviceMap(&LogonId, &DeviceMap);
+if (NT_SUCCESS(Status))
+{
+/* Acquire the device map lock */
+KeAcquireGuardedMutex(&ObpDeviceMapLock);
+
+/* Reference the device map if any */
+if (DeviceMap != NULL)
+{
+++DeviceMap->ReferenceCount;
+}
+
+/* Release the device map lock */
+KeReleaseGuardedMutex(&ObpDeviceMapLock);
+
+/* If we got the device map, we're done! */
+if (DeviceMap != NULL)
+{
+ObDereferenceObject(Token);
+
+return DeviceMap;
+}
+}
+}
+else
+{
+LookingForSystem = TRUE;
+}
+}
+}
+
+/*
+ * Fall back case of the LUID mapping, make sure there's a
+ * a device map attached to the current process
+ */
+if (PsGetCurrentProcess()->DeviceMap == NULL &&
+!NT_SUCCESS(ObpSetCurrentProcessDeviceMap()))
+{
+/* We may have failed after we got impersonation token */
+if (Token != NULL)
+{
+ObDereferenceObject(Token);
+}
+
+return NULL;
+}
+}
+
+/* Acquire the device map lock */
+KeAcquireGuardedMutex(&ObpDeviceMapLock);
+
+/* If we're looking for system map, use it */
+if (LookingForSystem)
+{
+DeviceMap = ObSystemDeviceMap;
+}
+/* Otherwise, use current process device map */
+else
+{
+DeviceMap = PsGetCurrentProcess()->DeviceMap;
+}
+
+/* If we got one, reference it */
+if (DeviceMap != NULL)
+{
+++DeviceMap->ReferenceCount;
+}
+
+/* Release the device map lock */
+KeReleaseGuardedMutex(&ObpDeviceMapLock);
+
+/* We may have impersonation token (if we failed in impersonation branch) 
*/
+if (Token != NULL)
+{
+ObDereferenceObject(Token);
+}
+
+/* Return the potentially found device map */
+return DeviceMap;
 }
 
 



[ros-diffs] [reactos] 04/07: [NTOSKRNL] Simplify NtQueryInformationProcess:ProcessDeviceMap implementation

2019-06-01 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=445e895932438ef6e1790beda439221645aeccad

commit 445e895932438ef6e1790beda439221645aeccad
Author: Pierre Schweitzer 
AuthorDate: Sat Jun 1 17:39:29 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Jun 1 17:40:23 2019 +0200

[NTOSKRNL] Simplify NtQueryInformationProcess:ProcessDeviceMap 
implementation
---
 ntoskrnl/ps/query.c | 24 +++-
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/ntoskrnl/ps/query.c b/ntoskrnl/ps/query.c
index 29c8171a474..5391ae18d64 100644
--- a/ntoskrnl/ps/query.c
+++ b/ntoskrnl/ps/query.c
@@ -78,11 +78,11 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
 PVM_COUNTERS VmCounters = (PVM_COUNTERS)ProcessInformation;
 PIO_COUNTERS IoCounters = (PIO_COUNTERS)ProcessInformation;
 PQUOTA_LIMITS QuotaLimits = (PQUOTA_LIMITS)ProcessInformation;
-PROCESS_DEVICEMAP_INFORMATION_EX DeviceMap;
 PUNICODE_STRING ImageName;
 ULONG Cookie, ExecuteOptions = 0;
 ULONG_PTR Wow64 = 0;
 PROCESS_VALUES ProcessValues;
+ULONG Flags;
 PAGED_CODE();
 
 /* Check for user-mode caller */
@@ -577,7 +577,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
 {
 PPROCESS_DEVICEMAP_INFORMATION_EX DeviceMapEx = 
ProcessInformation;
 
-DeviceMap.Flags = DeviceMapEx->Flags;
+Flags = DeviceMapEx->Flags;
 }
 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
 {
@@ -592,7 +592,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
 }
 
 /* Only one flag is supported and it needs LUID mappings */
-if ((DeviceMap.Flags & ~PROCESS_LUID_DOSDEVICES_ONLY) != 0 ||
+if ((Flags & ~PROCESS_LUID_DOSDEVICES_ONLY) != 0 ||
 !ObIsLUIDDeviceMapsEnabled())
 {
 Status = STATUS_INVALID_PARAMETER;
@@ -608,7 +608,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
 }
 
 /* No flags for standard call */
-DeviceMap.Flags = 0;
+Flags = 0;
 }
 
 /* Set the return length */
@@ -624,19 +624,9 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
 if (!NT_SUCCESS(Status)) break;
 
 /* Query the device map information */
-ObQueryDeviceMapInformation(Process, 
(PPROCESS_DEVICEMAP_INFORMATION)&DeviceMap, DeviceMap.Flags);
-
-/* Enter SEH for writing back data */
-_SEH2_TRY
-{
-RtlCopyMemory(ProcessInformation, &DeviceMap, 
sizeof(PROCESS_DEVICEMAP_INFORMATION));
-}
-_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
-{
-/* Get the exception code */
-Status = _SEH2_GetExceptionCode();
-}
-_SEH2_END;
+Status = ObQueryDeviceMapInformation(Process,
+ ProcessInformation,
+ Flags);
 
 /* Dereference the process */
 ObDereferenceObject(Process);



[ros-diffs] [reactos] 01/07: [NTOSKRNL] Implement ObIsLUIDDeviceMapsEnabled and call it in NtQueryInformationProcess

2019-06-01 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b16a07fa6913184abe2d2bee321f8f7aef919808

commit b16a07fa6913184abe2d2bee321f8f7aef919808
Author: Pierre Schweitzer 
AuthorDate: Sat Jun 1 14:56:28 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Jun 1 14:56:28 2019 +0200

[NTOSKRNL] Implement ObIsLUIDDeviceMapsEnabled and call it in 
NtQueryInformationProcess
---
 ntoskrnl/include/internal/ob.h |  7 +++
 ntoskrnl/ob/devicemap.c| 11 +++
 ntoskrnl/ob/obdir.c|  3 +--
 ntoskrnl/ob/obname.c   |  3 ---
 ntoskrnl/ps/query.c|  4 ++--
 5 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/ntoskrnl/include/internal/ob.h b/ntoskrnl/include/internal/ob.h
index ddbfeb42d92..132b47f5a6b 100644
--- a/ntoskrnl/include/internal/ob.h
+++ b/ntoskrnl/include/internal/ob.h
@@ -429,6 +429,12 @@ ObpCreateDosDevicesDirectory(
 VOID
 );
 
+ULONG
+NTAPI
+ObIsLUIDDeviceMapsEnabled(
+VOID
+);
+
 //
 // Security descriptor cache functions
 //
@@ -621,6 +627,7 @@ extern ULONG ObpUnsecureGlobalNamesLength;
 extern ULONG ObpObjectSecurityMode;
 extern ULONG ObpProtectionMode;
 extern ULONG ObpLUIDDeviceMapsDisabled;
+extern ULONG ObpLUIDDeviceMapsEnabled;
 
 //
 // Inlined Functions
diff --git a/ntoskrnl/ob/devicemap.c b/ntoskrnl/ob/devicemap.c
index dd501f134f8..a4cd5afbfae 100644
--- a/ntoskrnl/ob/devicemap.c
+++ b/ntoskrnl/ob/devicemap.c
@@ -13,6 +13,9 @@
 #define NDEBUG
 #include 
 
+ULONG ObpLUIDDeviceMapsDisabled;
+ULONG ObpLUIDDeviceMapsEnabled;
+
 /* PRIVATE FUNCTIONS **/
 
 NTSTATUS
@@ -249,6 +252,14 @@ ObQueryDeviceMapInformation(IN PEPROCESS Process,
 }
 
 
+ULONG
+NTAPI
+ObIsLUIDDeviceMapsEnabled(VOID)
+{
+return ObpLUIDDeviceMapsEnabled;
+}
+
+
 #if 0
 NTSTATUS
 NTAPI
diff --git a/ntoskrnl/ob/obdir.c b/ntoskrnl/ob/obdir.c
index 3c62411fed5..f8e3a36a06a 100644
--- a/ntoskrnl/ob/obdir.c
+++ b/ntoskrnl/ob/obdir.c
@@ -17,7 +17,6 @@
 #define NDEBUG
 #include 
 
-BOOLEAN ObpLUIDDeviceMapsEnabled;
 POBJECT_TYPE ObpDirectoryObjectType = NULL;
 
 /* PRIVATE FUNCTIONS **/
@@ -141,7 +140,7 @@ ObpLookupEntryDirectory(IN POBJECT_DIRECTORY Directory,
 PAGED_CODE();
 
 /* Check if we should search the shadow directory */
-if (!ObpLUIDDeviceMapsEnabled) SearchShadow = FALSE;
+if (ObpLUIDDeviceMapsEnabled == 0) SearchShadow = FALSE;
 
 /* Fail if we don't have a directory or name */
 if (!(Directory) || !(Name)) goto Quickie;
diff --git a/ntoskrnl/ob/obname.c b/ntoskrnl/ob/obname.c
index f05a06805d0..5700d43d5ca 100644
--- a/ntoskrnl/ob/obname.c
+++ b/ntoskrnl/ob/obname.c
@@ -32,9 +32,6 @@ UNICODE_STRING ObpDosDevicesShortName =
 WCHAR ObpUnsecureGlobalNamesBuffer[128] = {0};
 ULONG ObpUnsecureGlobalNamesLength = sizeof(ObpUnsecureGlobalNamesBuffer);
 
-ULONG ObpLUIDDeviceMapsDisabled;
-ULONG ObpLUIDDeviceMapsEnabled;
-
 /* PRIVATE FUNCTIONS */
 
 INIT_FUNCTION
diff --git a/ntoskrnl/ps/query.c b/ntoskrnl/ps/query.c
index 1f605be3349..12036fb01a1 100644
--- a/ntoskrnl/ps/query.c
+++ b/ntoskrnl/ps/query.c
@@ -911,8 +911,8 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
 /* Protect write in SEH */
 _SEH2_TRY
 {
-/* Return FALSE -- we don't support this */
-*(PULONG)ProcessInformation = FALSE;
+/* Query Ob */
+*(PULONG)ProcessInformation = ObIsLUIDDeviceMapsEnabled();
 }
 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
 {



[ros-diffs] [reactos] 02/07: [NTOSKRNL] Implement support for PROCESS_DEVICEMAP_INFORMATION_EX in NtQueryInformationProcess

2019-06-01 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1074a9aaff0b8d03782132cbe08f035afa85de9b

commit 1074a9aaff0b8d03782132cbe08f035afa85de9b
Author: Pierre Schweitzer 
AuthorDate: Sat Jun 1 15:18:52 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Jun 1 15:18:52 2019 +0200

[NTOSKRNL] Implement support for PROCESS_DEVICEMAP_INFORMATION_EX in 
NtQueryInformationProcess
---
 ntoskrnl/include/internal/ob.h |  3 ++-
 ntoskrnl/ob/devicemap.c|  3 ++-
 ntoskrnl/ps/query.c| 53 ++
 3 files changed, 47 insertions(+), 12 deletions(-)

diff --git a/ntoskrnl/include/internal/ob.h b/ntoskrnl/include/internal/ob.h
index 132b47f5a6b..910858ac5de 100644
--- a/ntoskrnl/include/internal/ob.h
+++ b/ntoskrnl/include/internal/ob.h
@@ -296,7 +296,8 @@ VOID
 NTAPI
 ObQueryDeviceMapInformation(
 IN PEPROCESS Process,
-OUT PPROCESS_DEVICEMAP_INFORMATION DeviceMapInfo
+OUT PPROCESS_DEVICEMAP_INFORMATION DeviceMapInfo,
+IN ULONG Flags
 );
 
 //
diff --git a/ntoskrnl/ob/devicemap.c b/ntoskrnl/ob/devicemap.c
index a4cd5afbfae..d1b7368bb8c 100644
--- a/ntoskrnl/ob/devicemap.c
+++ b/ntoskrnl/ob/devicemap.c
@@ -229,7 +229,8 @@ ObInheritDeviceMap(IN PEPROCESS Parent,
 VOID
 NTAPI
 ObQueryDeviceMapInformation(IN PEPROCESS Process,
-IN PPROCESS_DEVICEMAP_INFORMATION DeviceMapInfo)
+IN PPROCESS_DEVICEMAP_INFORMATION DeviceMapInfo,
+IN ULONG Flags)
 {
 PDEVICE_MAP DeviceMap;
 
diff --git a/ntoskrnl/ps/query.c b/ntoskrnl/ps/query.c
index 12036fb01a1..29c8171a474 100644
--- a/ntoskrnl/ps/query.c
+++ b/ntoskrnl/ps/query.c
@@ -78,7 +78,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
 PVM_COUNTERS VmCounters = (PVM_COUNTERS)ProcessInformation;
 PIO_COUNTERS IoCounters = (PIO_COUNTERS)ProcessInformation;
 PQUOTA_LIMITS QuotaLimits = (PQUOTA_LIMITS)ProcessInformation;
-PROCESS_DEVICEMAP_INFORMATION DeviceMap;
+PROCESS_DEVICEMAP_INFORMATION_EX DeviceMap;
 PUNICODE_STRING ImageName;
 ULONG Cookie, ExecuteOptions = 0;
 ULONG_PTR Wow64 = 0;
@@ -564,22 +564,55 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
 /* DOS Device Map */
 case ProcessDeviceMap:
 
-if (ProcessInformationLength != 
RTL_FIELD_SIZE(PROCESS_DEVICEMAP_INFORMATION, Query))
+if (ProcessInformationLength < 
sizeof(PROCESS_DEVICEMAP_INFORMATION))
 {
-if (ProcessInformationLength == 
sizeof(PROCESS_DEVICEMAP_INFORMATION_EX))
+Status = STATUS_INFO_LENGTH_MISMATCH;
+break;
+}
+
+if (ProcessInformationLength == 
sizeof(PROCESS_DEVICEMAP_INFORMATION_EX))
+{
+/* Protect read in SEH */
+_SEH2_TRY
 {
-DPRINT1("PROCESS_DEVICEMAP_INFORMATION_EX not 
supported!\n");
-Status = STATUS_NOT_IMPLEMENTED;
+PPROCESS_DEVICEMAP_INFORMATION_EX DeviceMapEx = 
ProcessInformation;
+
+DeviceMap.Flags = DeviceMapEx->Flags;
 }
-else
+_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+{
+/* Get the exception code */
+Status = _SEH2_GetExceptionCode();
+}
+_SEH2_END;
+
+if (!NT_SUCCESS(Status))
+{
+break;
+}
+
+/* Only one flag is supported and it needs LUID mappings */
+if ((DeviceMap.Flags & ~PROCESS_LUID_DOSDEVICES_ONLY) != 0 ||
+!ObIsLUIDDeviceMapsEnabled())
+{
+Status = STATUS_INVALID_PARAMETER;
+break;
+}
+}
+else
+{
+if (ProcessInformationLength != 
sizeof(PROCESS_DEVICEMAP_INFORMATION))
 {
 Status = STATUS_INFO_LENGTH_MISMATCH;
+break;
 }
-break;
+
+/* No flags for standard call */
+DeviceMap.Flags = 0;
 }
 
 /* Set the return length */
-Length = sizeof(PROCESS_DEVICEMAP_INFORMATION);
+Length = ProcessInformationLength;
 
 /* Reference the process */
 Status = ObReferenceObjectByHandle(ProcessHandle,
@@ -591,12 +624,12 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
 if (!NT_SUCCESS(Status)) break;
 
 /* Query the device map information */
-ObQueryDeviceMapInformation(Process, &DeviceMap);
+ObQueryDeviceMapInformation(Process, 
(PPROCESS_DEVICEMAP_INFORMATION)&DeviceMap, DeviceMap.Flags);
 
 /* Enter SEH for writing back da

[ros-diffs] [reactos] 05/07: [NTOSKRNL] Stub SeGetLogonIdDeviceMap

2019-06-01 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=59806f7eb0a589d4eb0c73ab9e0cb3b3a9b9729e

commit 59806f7eb0a589d4eb0c73ab9e0cb3b3a9b9729e
Author: Pierre Schweitzer 
AuthorDate: Sat Jun 1 18:37:47 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Jun 1 18:37:47 2019 +0200

[NTOSKRNL] Stub SeGetLogonIdDeviceMap
---
 ntoskrnl/include/internal/se.h |  6 ++
 ntoskrnl/se/srm.c  | 14 ++
 2 files changed, 20 insertions(+)

diff --git a/ntoskrnl/include/internal/se.h b/ntoskrnl/include/internal/se.h
index aec259cdb7c..722d2d9a2aa 100644
--- a/ntoskrnl/include/internal/se.h
+++ b/ntoskrnl/include/internal/se.h
@@ -604,6 +604,12 @@ NTSTATUS
 SepRmDereferenceLogonSession(
 PLUID LogonLuid);
 
+NTSTATUS
+NTAPI
+SeGetLogonIdDeviceMap(
+IN PLUID LogonId,
+OUT PDEVICE_MAP * DeviceMap);
+
 #endif
 
 /* EOF */
diff --git a/ntoskrnl/se/srm.c b/ntoskrnl/se/srm.c
index 66761d874bf..7d1526623c6 100644
--- a/ntoskrnl/se/srm.c
+++ b/ntoskrnl/se/srm.c
@@ -691,6 +691,20 @@ SepRmCommandServerThread(
 
 /* PUBLIC FUNCTIONS 
***/
 
+/*
+ * @unimplemented
+ */
+NTSTATUS
+NTAPI
+SeGetLogonIdDeviceMap(
+IN PLUID LogonId,
+OUT PDEVICE_MAP * DeviceMap
+)
+{
+UNIMPLEMENTED;
+return STATUS_NOT_IMPLEMENTED;
+}
+
 /*
  * @unimplemented
  */



[ros-diffs] [reactos] 03/07: [NTOSKRNL] Add support for LUID mappings in ObQueryDeviceMapInformation

2019-06-01 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=46b90ccb9695279e90afeea89eb0cf8b79f3f4d8

commit 46b90ccb9695279e90afeea89eb0cf8b79f3f4d8
Author: Pierre Schweitzer 
AuthorDate: Sat Jun 1 17:28:11 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Jun 1 17:40:18 2019 +0200

[NTOSKRNL] Add support for LUID mappings in ObQueryDeviceMapInformation
---
 ntoskrnl/include/internal/ob.h |   2 +-
 ntoskrnl/ob/devicemap.c| 122 ++---
 2 files changed, 114 insertions(+), 10 deletions(-)

diff --git a/ntoskrnl/include/internal/ob.h b/ntoskrnl/include/internal/ob.h
index 910858ac5de..23f54cefefd 100644
--- a/ntoskrnl/include/internal/ob.h
+++ b/ntoskrnl/include/internal/ob.h
@@ -292,7 +292,7 @@ ObpSetHandleAttributes(
 IN ULONG_PTR Context
 );
 
-VOID
+NTSTATUS
 NTAPI
 ObQueryDeviceMapInformation(
 IN PEPROCESS Process,
diff --git a/ntoskrnl/ob/devicemap.c b/ntoskrnl/ob/devicemap.c
index d1b7368bb8c..4dcaff1c832 100644
--- a/ntoskrnl/ob/devicemap.c
+++ b/ntoskrnl/ob/devicemap.c
@@ -143,6 +143,15 @@ ObSetDeviceMap(IN PEPROCESS Process,
 }
 
 
+PDEVICE_MAP
+NTAPI
+ObpReferenceDeviceMap(VOID)
+{
+UNIMPLEMENTED;
+return NULL;
+}
+
+
 VOID
 NTAPI
 ObDereferenceDeviceMap(IN PEPROCESS Process)
@@ -226,30 +235,125 @@ ObInheritDeviceMap(IN PEPROCESS Parent,
 }
 
 
-VOID
+NTSTATUS
 NTAPI
 ObQueryDeviceMapInformation(IN PEPROCESS Process,
 IN PPROCESS_DEVICEMAP_INFORMATION DeviceMapInfo,
 IN ULONG Flags)
 {
-PDEVICE_MAP DeviceMap;
+PDEVICE_MAP DeviceMap = NULL, GlobalDeviceMap;
+BOOLEAN Dereference;
+PROCESS_DEVICEMAP_INFORMATION MapInfo;
+ULONG BitMask, i;
+BOOLEAN ReturnAny;
+NTSTATUS Status;
+
+/* Validate flags */
+if (Flags & ~PROCESS_LUID_DOSDEVICES_ONLY)
+{
+return STATUS_INVALID_PARAMETER;
+}
+
+Dereference = FALSE;
+/* Do we want to return anything? */
+ReturnAny = ~Flags & PROCESS_LUID_DOSDEVICES_ONLY;
+
+/* If LUID mappings are enabled... */
+if (ObpLUIDDeviceMapsEnabled != 0)
+{
+/* Check for process parameter validness */
+if (Process != NULL && Process != PsGetCurrentProcess())
+{
+return STATUS_INVALID_PARAMETER;
+}
+
+/* And get the device map */
+DeviceMap = ObpReferenceDeviceMap();
+}
 
 /* Acquire the device map lock */
 KeAcquireGuardedMutex(&ObpDeviceMapLock);
 
-/* Get the process device map or the system device map */
-DeviceMap = (Process != NULL) ? Process->DeviceMap : ObSystemDeviceMap;
+/*
+ * If we had a device map, if because of LUID mappings,
+ * we'll have to dereference it afterwards
+ */
 if (DeviceMap != NULL)
 {
-/* Make a copy */
-DeviceMapInfo->Query.DriveMap = DeviceMap->DriveMap;
-RtlCopyMemory(DeviceMapInfo->Query.DriveType,
-  DeviceMap->DriveType,
-  sizeof(DeviceMap->DriveType));
+Dereference = TRUE;
+}
+else
+{
+/* Get the process device map or the system device map */
+DeviceMap = (Process != NULL) ? Process->DeviceMap : ObSystemDeviceMap;
+}
+
+/* Fail if no device map */
+if (DeviceMap == NULL)
+{
+KeReleaseGuardedMutex(&ObpDeviceMapLock);
+return STATUS_END_OF_FILE;
+}
+
+/* At that point, assume success */
+Status = STATUS_SUCCESS;
+
+/* Try to get the global device map if any */
+GlobalDeviceMap = DeviceMap;
+if (DeviceMap->GlobalDosDevicesDirectory != NULL)
+{
+if (DeviceMap->GlobalDosDevicesDirectory->DeviceMap != NULL)
+{
+GlobalDeviceMap = DeviceMap->GlobalDosDevicesDirectory->DeviceMap;
+}
+}
+
+/* Now, setup our device map info, especially drive types */
+MapInfo.Query.DriveMap = DeviceMap->DriveMap;
+/* Browse every device */
+for (i = 0, BitMask = 1; i < 32; ++i, BitMask *= 2)
+{
+/* Set the type given current device map */
+MapInfo.Query.DriveType[i] = DeviceMap->DriveType[i];
+
+/*
+ * If device is not existing and we're asked to return
+ * more than just LUID mapped, get the entry
+ * from global device map if not remote
+ */
+if (!(MapInfo.Query.DriveMap & BitMask) && ReturnAny)
+{
+if (ObpLUIDDeviceMapsEnabled != 0 ||
+(GlobalDeviceMap->DriveType[i] != DOSDEVICE_DRIVE_REMOTE &&
+ GlobalDeviceMap->DriveType[i] != DOSDEVICE_DRIVE_CALCULATE))
+{
+MapInfo.Query.DriveType[i] = GlobalDeviceMap->DriveType[i];
+MapInfo.Query.DriveMap |= BitMask & GlobalDeviceMap->DriveMap;
+}
+}
 }
 
 /* Release the device map lock */
 KeReleaseGuardedMutex(&Ob

[ros-diffs] [reactos] 01/01: [NTOSKRNL] Disable LUID mapping until it's properly implemented

2019-06-01 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7898b2eaa365b72cfb00186b165cff13d2990b40

commit 7898b2eaa365b72cfb00186b165cff13d2990b40
Author: Pierre Schweitzer 
AuthorDate: Sat Jun 1 14:40:24 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Jun 1 14:40:54 2019 +0200

[NTOSKRNL] Disable LUID mapping until it's properly implemented
---
 boot/bootdata/hivesys.inf  |  1 +
 ntoskrnl/config/cmdata.c   |  2 +-
 ntoskrnl/include/internal/ob.h |  1 +
 ntoskrnl/ob/obname.c   | 10 ++
 4 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/boot/bootdata/hivesys.inf b/boot/bootdata/hivesys.inf
index 0f2fc9369eb..d1e1f7d4d59 100644
--- a/boot/bootdata/hivesys.inf
+++ b/boot/bootdata/hivesys.inf
@@ -1445,6 +1445,7 @@ HKLM,"SYSTEM\CurrentControlSet\Control\Session 
Manager","ObjectDirectories",0x00
  "\Windows", \
  "\RPC Control"
 HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager","ProtectionMode", 
0x00010003, 0x0001
+HKLM,"SYSTEM\CurrentControlSet\Control\Session 
Manager","LUIDDeviceMapsDisabled", 0x00010003, 0x0001
 
 ; DOS devices
 HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\DOS 
Devices","AUX",0x0002,"\DosDevices\COM1"
diff --git a/ntoskrnl/config/cmdata.c b/ntoskrnl/config/cmdata.c
index 816dfd28c91..7a2c6af6c55 100644
--- a/ntoskrnl/config/cmdata.c
+++ b/ntoskrnl/config/cmdata.c
@@ -157,7 +157,7 @@ INIT_SECTION CM_SYSTEM_CONTROL_VECTOR CmControlVector[] =
 {
 L"Session Manager",
 L"LUIDDeviceMapsDisabled",
-&DummyData,
+&ObpLUIDDeviceMapsDisabled,
 NULL,
 NULL
 },
diff --git a/ntoskrnl/include/internal/ob.h b/ntoskrnl/include/internal/ob.h
index b2d7037d9dc..ddbfeb42d92 100644
--- a/ntoskrnl/include/internal/ob.h
+++ b/ntoskrnl/include/internal/ob.h
@@ -620,6 +620,7 @@ extern WCHAR ObpUnsecureGlobalNamesBuffer[128];
 extern ULONG ObpUnsecureGlobalNamesLength;
 extern ULONG ObpObjectSecurityMode;
 extern ULONG ObpProtectionMode;
+extern ULONG ObpLUIDDeviceMapsDisabled;
 
 //
 // Inlined Functions
diff --git a/ntoskrnl/ob/obname.c b/ntoskrnl/ob/obname.c
index d76ed10a919..f05a06805d0 100644
--- a/ntoskrnl/ob/obname.c
+++ b/ntoskrnl/ob/obname.c
@@ -32,6 +32,9 @@ UNICODE_STRING ObpDosDevicesShortName =
 WCHAR ObpUnsecureGlobalNamesBuffer[128] = {0};
 ULONG ObpUnsecureGlobalNamesLength = sizeof(ObpUnsecureGlobalNamesBuffer);
 
+ULONG ObpLUIDDeviceMapsDisabled;
+ULONG ObpLUIDDeviceMapsEnabled;
+
 /* PRIVATE FUNCTIONS */
 
 INIT_FUNCTION
@@ -182,6 +185,13 @@ ObpCreateDosDevicesDirectory(VOID)
 SECURITY_DESCRIPTOR DosDevicesSD;
 NTSTATUS Status;
 
+/*
+ * Enable LUID mappings only if not explicitely disabled
+ * and if protection mode is set
+ */
+if (ObpProtectionMode == 0 || ObpLUIDDeviceMapsDisabled != 0)
+ObpLUIDDeviceMapsEnabled = 0;
+
 /* Create a custom security descriptor for the global DosDevices directory 
*/
 Status = ObpGetDosDevicesProtection(&DosDevicesSD);
 if (!NT_SUCCESS(Status))



[ros-diffs] [reactos] 05/05: [NTOSKRNL] On device map freeing, make directory object temporary again

2019-06-01 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=848f7bb687b77de1302b013765e486d864ea31c6

commit 848f7bb687b77de1302b013765e486d864ea31c6
Author: Pierre Schweitzer 
AuthorDate: Sat Jun 1 13:59:13 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Jun 1 13:59:13 2019 +0200

[NTOSKRNL] On device map freeing, make directory object temporary again
---
 ntoskrnl/ob/devicemap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ntoskrnl/ob/devicemap.c b/ntoskrnl/ob/devicemap.c
index 8cda474a38d..dd501f134f8 100644
--- a/ntoskrnl/ob/devicemap.c
+++ b/ntoskrnl/ob/devicemap.c
@@ -189,7 +189,8 @@ ObfDereferenceDeviceMap(IN PDEVICE_MAP DeviceMap)
 KeReleaseGuardedMutex(&ObpDeviceMapLock);
 
 /* Dereference the DOS Devices Directory and free the Device Map */
-ObDereferenceObject(DeviceMap->DosDevicesDirectory );
+ObMakeTemporaryObject(DeviceMap->DosDevicesDirectory);
+ObDereferenceObject(DeviceMap->DosDevicesDirectory);
 ExFreePoolWithTag(DeviceMap, 'mDbO');
 }
 



[ros-diffs] [reactos] 02/05: [NTOSKRNL] Implement ObpFreeDosDevicesProtection to free DACL

2019-06-01 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8f655f9466eca0f0c5d4719c1cccd032e4a14ae2

commit 8f655f9466eca0f0c5d4719c1cccd032e4a14ae2
Author: Pierre Schweitzer 
AuthorDate: Sat Jun 1 13:44:55 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Jun 1 13:44:55 2019 +0200

[NTOSKRNL] Implement ObpFreeDosDevicesProtection to free DACL
---
 ntoskrnl/ob/obname.c | 21 +
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/ntoskrnl/ob/obname.c b/ntoskrnl/ob/obname.c
index 6c996132d87..866ac748d84 100644
--- a/ntoskrnl/ob/obname.c
+++ b/ntoskrnl/ob/obname.c
@@ -141,6 +141,22 @@ ObpGetDosDevicesProtection(OUT PSECURITY_DESCRIPTOR 
SecurityDescriptor)
 return STATUS_SUCCESS;
 }
 
+INIT_FUNCTION
+VOID
+NTAPI
+ObpFreeDosDevicesProtection(OUT PSECURITY_DESCRIPTOR SecurityDescriptor)
+{
+PACL Dacl;
+NTSTATUS Status;
+BOOLEAN DaclPresent, DaclDefaulted;
+
+Status = RtlGetDaclSecurityDescriptor(SecurityDescriptor, &DaclPresent, 
&Dacl, &DaclDefaulted);
+ASSERT(NT_SUCCESS(Status));
+ASSERT(DaclPresent);
+ASSERT(Dacl != NULL);
+ExFreePoolWithTag(Dacl, 'lcaD');
+}
+
 INIT_FUNCTION
 NTSTATUS
 NTAPI
@@ -151,8 +167,6 @@ ObpCreateDosDevicesDirectory(VOID)
 HANDLE Handle, SymHandle;
 SECURITY_DESCRIPTOR DosDevicesSD;
 NTSTATUS Status;
-PACL Dacl;
-BOOLEAN DaclPresent, DaclDefaulted;
 
 /* Create a custom security descriptor for the global DosDevices directory 
*/
 Status = ObpGetDosDevicesProtection(&DosDevicesSD);
@@ -256,8 +270,7 @@ ObpCreateDosDevicesDirectory(VOID)
 if (NT_SUCCESS(Status)) NtClose(SymHandle);
 
 done:
-RtlGetDaclSecurityDescriptor(&DosDevicesSD, &DaclPresent, &Dacl, 
&DaclDefaulted);
-ExFreePoolWithTag(Dacl, 'lcaD');
+ObpFreeDosDevicesProtection(&DosDevicesSD);
 
 /* Return status */
 return Status;



[ros-diffs] [reactos] 04/05: [NTOSKRNL] De-duplicate code between Ob(f)DereferenceDeviceMap functions

2019-06-01 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=221ed8814121e5fb5af5e56a9197d34e9c091824

commit 221ed8814121e5fb5af5e56a9197d34e9c091824
Author: Pierre Schweitzer 
AuthorDate: Sat Jun 1 13:54:15 2019 +0200
Commit: Pierre Schweitzer 
CommitDate: Sat Jun 1 13:54:34 2019 +0200

[NTOSKRNL] De-duplicate code between Ob(f)DereferenceDeviceMap functions
---
 ntoskrnl/ob/devicemap.c | 29 ++---
 1 file changed, 2 insertions(+), 27 deletions(-)

diff --git a/ntoskrnl/ob/devicemap.c b/ntoskrnl/ob/devicemap.c
index c79838bbabd..8cda474a38d 100644
--- a/ntoskrnl/ob/devicemap.c
+++ b/ntoskrnl/ob/devicemap.c
@@ -156,33 +156,8 @@ ObDereferenceDeviceMap(IN PEPROCESS Process)
 KeReleaseGuardedMutex(&ObpDeviceMapLock);
 
 /* Continue only if there is a device map */
-if (DeviceMap == NULL)
-return;
-
-/* Acquire the device map lock again */
-KeAcquireGuardedMutex(&ObpDeviceMapLock);
-
-/* Decrement the reference counter */
-DeviceMap->ReferenceCount--;
-DPRINT("ReferenceCount: %lu\n", DeviceMap->ReferenceCount);
-
-/* Leave, if there are still references to this device map */
-if (DeviceMap->ReferenceCount != 0)
-{
-/* Release the device map lock and leave */
-KeReleaseGuardedMutex(&ObpDeviceMapLock);
-return;
-}
-
-/* Nobody is referencing it anymore, unlink the DOS directory */
-DeviceMap->DosDevicesDirectory->DeviceMap = NULL;
-
-/* Release the device map lock */
-KeReleaseGuardedMutex(&ObpDeviceMapLock);
-
-/* Dereference the DOS Devices Directory and free the DeviceMap */
-ObDereferenceObject(DeviceMap->DosDevicesDirectory);
-ExFreePoolWithTag(DeviceMap, 'mDbO');
+if (DeviceMap != NULL)
+ObfDereferenceDeviceMap(DeviceMap);
 }
 
 



  1   2   3   4   5   6   7   8   9   >