[ros-diffs] [reactos] 02/02: [KMTESTS:CC] Add more tests for SetFileSizes

2018-12-22 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f7c0236fc10e833b62e4f67c29c9093718f2facc

commit f7c0236fc10e833b62e4f67c29c9093718f2facc
Author: Pierre Schweitzer 
AuthorDate: Sat Dec 22 12:42:05 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Dec 22 12:42:05 2018 +0100

[KMTESTS:CC] Add more tests for SetFileSizes

These are covered by Thomas' patch.

CORE-11819
---
 modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c  | 11 +--
 modules/rostests/kmtests/ntos_cc/CcSetFileSizes_user.c |  8 +---
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c 
b/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c
index cc8840dc85..3934b9d6a8 100644
--- a/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c
+++ b/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c
@@ -171,13 +171,18 @@ PerformTest(
 Fcb->Header.FileSize.QuadPart = VACB_MAPPING_GRANULARITY - 
PAGE_SIZE;
 Fcb->Header.ValidDataLength.QuadPart = VACB_MAPPING_GRANULARITY - 
PAGE_SIZE;
 
+if (TestId > 1 && TestId < 4)
+{
+Fcb->Header.AllocationSize.QuadPart = VACB_MAPPING_GRANULARITY 
- PAGE_SIZE;
+}
+
 KmtStartSeh();
 CcInitializeCacheMap(TestFileObject, 
(PCC_FILE_SIZES)&Fcb->Header.AllocationSize, TRUE, &Callbacks, NULL);
 KmtEndSeh(STATUS_SUCCESS);
 
 if (!skip(CcIsFileCached(TestFileObject) == TRUE, 
"CcInitializeCacheMap failed\n"))
 {
-if (TestId == 0)
+if (TestId == 0 || TestId == 2)
 {
 Offset.QuadPart = 0;
 KmtStartSeh();
@@ -194,6 +199,7 @@ PerformTest(
 CcSetFileSizes(TestFileObject, &NewFileSizes);
 KmtEndSeh(STATUS_SUCCESS);
 
+Fcb->Header.AllocationSize.QuadPart = 
VACB_MAPPING_GRANULARITY;
 Fcb->Header.FileSize.QuadPart = VACB_MAPPING_GRANULARITY;
 
 Offset.QuadPart = 0;
@@ -208,7 +214,7 @@ PerformTest(
 CcUnpinData(Bcb);
 }
 }
-else if (TestId == 1)
+else if (TestId == 1 || TestId == 3)
 {
 Buffer = ExAllocatePool(NonPagedPool, PAGE_SIZE);
 if (!skip(Buffer != NULL, "ExAllocatePool failed\n"))
@@ -226,6 +232,7 @@ PerformTest(
 CcSetFileSizes(TestFileObject, &NewFileSizes);
 KmtEndSeh(STATUS_SUCCESS);
 
+Fcb->Header.AllocationSize.QuadPart = 
VACB_MAPPING_GRANULARITY;
 Fcb->Header.FileSize.QuadPart = 
VACB_MAPPING_GRANULARITY;
 RtlZeroMemory(Buffer, PAGE_SIZE);
 
diff --git a/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_user.c 
b/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_user.c
index 6e8a11dfff..121598444c 100644
--- a/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_user.c
+++ b/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_user.c
@@ -18,10 +18,12 @@ START_TEST(CcSetFileSizes)
 KmtLoadDriver(L"CcSetFileSizes", FALSE);
 KmtOpenDriver();
 
-/* 0: mapped data
- * 1: copy read
+/* 0: mapped data - only FS
+ * 1: copy read - only FS
+ * 2: mapped data - FS & AS
+ * 3: copy read - FS & AS
  */
-for (TestId = 0; TestId < 2; ++TestId)
+for (TestId = 0; TestId < 4; ++TestId)
 {
 Ret = KmtSendUlongToDriver(IOCTL_START_TEST, TestId);
 ok(Ret == ERROR_SUCCESS, "KmtSendUlongToDriver failed: %lx\n", Ret);



[ros-diffs] [reactos] 01/02: [KMTESTS:CC] Add tests for CcSetFileSizes

2018-12-22 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ba5d6e977bf36a6248e51bf5ed1588a530cb9baa

commit ba5d6e977bf36a6248e51bf5ed1588a530cb9baa
Author: Pierre Schweitzer 
AuthorDate: Sat Dec 22 12:29:18 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Dec 22 12:32:02 2018 +0100

[KMTESTS:CC] Add tests for CcSetFileSizes

These are passing in W2K3 but failing in ReactOS.

CORE-11819
---
 modules/rostests/kmtests/CMakeLists.txt|   1 +
 modules/rostests/kmtests/kmtest/testlist.c |   2 +
 modules/rostests/kmtests/ntos_cc/CMakeLists.txt|  15 +
 .../rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c  | 408 +
 .../rostests/kmtests/ntos_cc/CcSetFileSizes_user.c |  34 ++
 5 files changed, 460 insertions(+)

diff --git a/modules/rostests/kmtests/CMakeLists.txt 
b/modules/rostests/kmtests/CMakeLists.txt
index 623188e913..feb522be36 100644
--- a/modules/rostests/kmtests/CMakeLists.txt
+++ b/modules/rostests/kmtests/CMakeLists.txt
@@ -139,6 +139,7 @@ list(APPEND KMTEST_SOURCE
 ntos_cc/CcMapData_user.c
 ntos_cc/CcPinMappedData_user.c
 ntos_cc/CcPinRead_user.c
+ntos_cc/CcSetFileSizes_user.c
 ntos_io/IoCreateFile_user.c
 ntos_io/IoDeviceObject_user.c
 ntos_io/IoReadWrite_user.c
diff --git a/modules/rostests/kmtests/kmtest/testlist.c 
b/modules/rostests/kmtests/kmtest/testlist.c
index 5b5b65364b..0c5e2010d6 100644
--- a/modules/rostests/kmtests/kmtest/testlist.c
+++ b/modules/rostests/kmtests/kmtest/testlist.c
@@ -10,6 +10,7 @@ KMT_TESTFUNC Test_CcCopyRead;
 KMT_TESTFUNC Test_CcMapData;
 KMT_TESTFUNC Test_CcPinMappedData;
 KMT_TESTFUNC Test_CcPinRead;
+KMT_TESTFUNC Test_CcSetFileSizes;
 KMT_TESTFUNC Test_Example;
 KMT_TESTFUNC Test_FileAttributes;
 KMT_TESTFUNC Test_FindFile;
@@ -41,6 +42,7 @@ const KMT_TEST TestList[] =
 { "CcMapData",Test_CcMapData },
 { "CcPinMappedData",  Test_CcPinMappedData },
 { "CcPinRead",Test_CcPinRead },
+{ "CcSetFileSizes",   Test_CcSetFileSizes },
 { "-Example", Test_Example },
 { "FileAttributes",   Test_FileAttributes },
 { "FindFile", Test_FindFile },
diff --git a/modules/rostests/kmtests/ntos_cc/CMakeLists.txt 
b/modules/rostests/kmtests/ntos_cc/CMakeLists.txt
index 3357f19e68..8815f5c897 100644
--- a/modules/rostests/kmtests/ntos_cc/CMakeLists.txt
+++ b/modules/rostests/kmtests/ntos_cc/CMakeLists.txt
@@ -60,3 +60,18 @@ add_importlibs(ccpinread_drv ntoskrnl hal)
 add_target_compile_definitions(ccpinread_drv KMT_STANDALONE_DRIVER)
 #add_pch(ccmapdata_drv ../include/kmt_test.h)
 add_rostests_file(TARGET ccpinread_drv)
+
+#
+# CcSetFileSizes
+#
+list(APPEND CCSETFILESIZES_DRV_SOURCE
+../kmtest_drv/kmtest_standalone.c
+CcSetFileSizes_drv.c)
+
+add_library(ccsetfilesizes_drv SHARED ${CCSETFILESIZES_DRV_SOURCE})
+set_module_type(ccsetfilesizes_drv kernelmodedriver)
+target_link_libraries(ccsetfilesizes_drv kmtest_printf ${PSEH_LIB})
+add_importlibs(ccsetfilesizes_drv ntoskrnl hal)
+add_target_compile_definitions(ccsetfilesizes_drv KMT_STANDALONE_DRIVER)
+#add_pch(ccsetfilesizes_drv ../include/kmt_test.h)
+add_rostests_file(TARGET ccsetfilesizes_drv)
diff --git a/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c 
b/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c
new file mode 100644
index 00..cc8840dc85
--- /dev/null
+++ b/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c
@@ -0,0 +1,408 @@
+/*
+ * PROJECT: ReactOS kernel-mode tests
+ * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
+ * PURPOSE:     Test driver for CcSetFileSizes function
+ * PROGRAMMER:  Pierre Schweitzer 
+ */
+
+#include 
+
+#define NDEBUG
+#include 
+
+#define IOCTL_START_TEST  1
+#define IOCTL_FINISH_TEST 2
+
+typedef struct _TEST_FCB
+{
+FSRTL_ADVANCED_FCB_HEADER Header;
+SECTION_OBJECT_POINTERS SectionObjectPointers;
+FAST_MUTEX HeaderMutex;
+} TEST_FCB, *PTEST_FCB;
+
+static ULONG TestTestId = -1;
+static PFILE_OBJECT TestFileObject;
+static PDEVICE_OBJECT TestDeviceObject;
+static KMT_IRP_HANDLER TestIrpHandler;
+static KMT_MESSAGE_HANDLER TestMessageHandler;
+
+NTSTATUS
+TestEntry(
+_In_ PDRIVER_OBJECT DriverObject,
+_In_ PCUNICODE_STRING RegistryPath,
+_Out_ PCWSTR *DeviceName,
+_Inout_ INT *Flags)
+{
+NTSTATUS Status = STATUS_SUCCESS;
+
+PAGED_CODE();
+
+UNREFERENCED_PARAMETER(RegistryPath);
+
+*DeviceName = L"CcSetFileSizes";
+*Flags = TESTENTRY_NO_EXCLUSIVE_DEVICE |
+ TESTENTRY_BUFFERED_IO_DEVICE |
+ TESTENTRY_NO_READONLY_DEVICE;
+
+KmtRegisterIrpHandler(IRP_MJ_READ, NULL, TestIrpHandler);
+KmtRegisterMessageHandler(0, NULL, TestMessageHandler);
+
+return Status;
+}
+
+VOID
+TestUnload(
+_In_ PDRIVER_OBJECT DriverObject)
+{
+PAGED_CODE(

[ros-diffs] [reactos] 01/01: [KMTESTS:CC] Add a trace to identify failing tests

2018-12-22 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0b5c1503c45aced0db201d8a6327054a93cb6c1e

commit 0b5c1503c45aced0db201d8a6327054a93cb6c1e
Author: Pierre Schweitzer 
AuthorDate: Sat Dec 22 14:36:08 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Dec 22 14:36:45 2018 +0100

[KMTESTS:CC] Add a trace to identify failing tests
---
 modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c 
b/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c
index 3934b9d6a8..7895786dd5 100644
--- a/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c
+++ b/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c
@@ -182,6 +182,8 @@ PerformTest(
 
 if (!skip(CcIsFileCached(TestFileObject) == TRUE, 
"CcInitializeCacheMap failed\n"))
 {
+trace("Starting test: %d\n", TestId);
+
 if (TestId == 0 || TestId == 2)
 {
 Offset.QuadPart = 0;



[ros-diffs] [reactos] 01/01: [FONTSUB] Fix build

2018-12-22 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6b4d6d40d6d34dad305a24720c3c80f5f341daa5

commit 6b4d6d40d6d34dad305a24720c3c80f5f341daa5
Author: Pierre Schweitzer 
AuthorDate: Sat Dec 22 14:52:02 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Dec 22 14:52:02 2018 +0100

[FONTSUB] Fix build
---
 modules/rosapps/applications/sysutils/fontsub/lang/zh-TW.rc | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/modules/rosapps/applications/sysutils/fontsub/lang/zh-TW.rc 
b/modules/rosapps/applications/sysutils/fontsub/lang/zh-TW.rc
index 1de9687c47..d521a85c20 100644
--- a/modules/rosapps/applications/sysutils/fontsub/lang/zh-TW.rc
+++ b/modules/rosapps/applications/sysutils/fontsub/lang/zh-TW.rc
@@ -17,7 +17,7 @@ LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL
 
 1 MENU
 BEGIN
-POPUP “檔案(&F)”
+POPUP "檔案(&F)"
 BEGIN
 MENUITEM "匯入(&I)...\tCtrl+O", ID_IMPORT
 MENUITEM "匯出(&E)...\tCtrl+S", ID_EXPORT
@@ -37,7 +37,7 @@ BEGIN
 MENUITEM SEPARATOR
 MENUITEM "刪除項目(&D)\tDel", ID_DELETE
 END
-POPUP “說明(&H)”
+POPUP "說明(&H)"
 BEGIN
 MENUITEM "關於(&A)...", ID_ABOUT
 END
@@ -57,7 +57,7 @@ END
 
 STRINGTABLE
 BEGIN
-IDS_TITLE,  “字型名稱替代”
+IDS_TITLE,  "字型名稱替代"
 IDS_FONTNAME,   "字型名稱"
 IDS_SUBSTITUTE, "替代"
 IDS_ENTERNAME,  "(請輸入字型名稱...)"
@@ -79,7 +79,7 @@ END
 IDD_ADD DIALOGEX 0, 0, 315, 65
 STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU
 CAPTION "添加替代項目"
-FONT 10, “新細明體”
+FONT 10, "新細明體"
 BEGIN
 CONTROL "字型名稱(&N):", -1, "STATIC", SS_RIGHT | SS_CENTERIMAGE | WS_CHILD | 
WS_VISIBLE | WS_GROUP, 5, 5, 55, 15
 CONTROL "", cmb1, "ComboBoxEx32", CBS_DROPDOWN | CBS_AUTOHSCROLL | 
WS_VSCROLL | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 70, 6, 120, 120
@@ -94,7 +94,7 @@ END
 IDD_EDIT DIALOGEX 0, 0, 315, 65
 STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU
 CAPTION "編輯替代項目"
-FONT 10, “新細明體”
+FONT 10, "新細明體"
 BEGIN
 CONTROL "字型名稱(&N):", -1, "STATIC", SS_RIGHT | SS_CENTERIMAGE | WS_CHILD | 
WS_VISIBLE | WS_GROUP, 5, 5, 55, 15
 CONTROL "", edt1, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE 
| WS_DISABLED | WS_BORDER | WS_TABSTOP, 70, 6, 120, 14



[ros-diffs] [reactos] 01/01: [FONTSUB] Fix build²

2018-12-22 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9cbd1cad0e9b282b8951146c9a3a210deeff8e1e

commit 9cbd1cad0e9b282b8951146c9a3a210deeff8e1e
Author: Pierre Schweitzer 
AuthorDate: Sat Dec 22 15:02:16 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Dec 22 15:02:16 2018 +0100

[FONTSUB] Fix build²
---
 modules/rosapps/applications/sysutils/fontsub/lang/zh-TW.rc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/rosapps/applications/sysutils/fontsub/lang/zh-TW.rc 
b/modules/rosapps/applications/sysutils/fontsub/lang/zh-TW.rc
index d521a85c20..9a45c8af65 100644
--- a/modules/rosapps/applications/sysutils/fontsub/lang/zh-TW.rc
+++ b/modules/rosapps/applications/sysutils/fontsub/lang/zh-TW.rc
@@ -25,7 +25,7 @@ BEGIN
 MENUITEM "重新加載登錄(&L)\tCtrl+L", ID_RELOAD
 MENUITEM "更新登錄(&R)\tCtrl+U", ID_UPDATE_REGISTRY
 MENUITEM SEPARATOR
-MENUITEM "在登錄中開啟(&E)”, ID_OPEN_REGKEY
+MENUITEM "在登錄中開啟(&E)", ID_OPEN_REGKEY
 MENUITEM SEPARATOR
 MENUITEM "退出(&X)\tAlt+F4", ID_EXIT
 END



[ros-diffs] [reactos] 01/01: [NTOSKRNL] When growing a file, invalid the last VACB so that it can be refreshed

2018-12-23 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0917c64812c6ed182c8f771309dfc628127eee2d

commit 0917c64812c6ed182c8f771309dfc628127eee2d
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 23 11:08:01 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Dec 23 11:19:14 2018 +0100

[NTOSKRNL] When growing a file, invalid the last VACB so that it can be 
refreshed

This will avoid corruption when a file size is little grown and read 
afterwards.
Up to now, FSD where reading 0es instead of expected data, causing 
corruption.

This fixes MS FastFAT not being able to mount a FAT volume in ReactOS, 
corrupting
the FAT.
This also fixes the CcSetFileSizes kmtest tests.

This is based on a patch by Thomas Faber.

CORE-11819
---
 ntoskrnl/cc/fs.c | 37 +
 1 file changed, 37 insertions(+)

diff --git a/ntoskrnl/cc/fs.c b/ntoskrnl/cc/fs.c
index e31a17b87b..5798f56a91 100644
--- a/ntoskrnl/cc/fs.c
+++ b/ntoskrnl/cc/fs.c
@@ -301,6 +301,43 @@ CcSetFileSizes (
 0,
 FALSE);
 }
+else
+{
+PROS_VACB LastVacb;
+
+/*
+ * If file (allocation) size has increased, then we need to check 
whether
+ * it just grows in a single VACB (the last one).
+ * If so, we must mark the VACB as invalid to trigger a read to the
+ * FSD at the next VACB usage, and thus avoid returning garbage
+ */
+
+/* Check for allocation size and the last VACB */
+if (SharedCacheMap->SectionSize.QuadPart < 
FileSizes->AllocationSize.QuadPart &&
+SharedCacheMap->SectionSize.QuadPart % VACB_MAPPING_GRANULARITY)
+{
+LastVacb = CcRosLookupVacb(SharedCacheMap,
+   SharedCacheMap->SectionSize.QuadPart);
+if (LastVacb != NULL)
+{
+/* Mark it as invalid */
+CcRosReleaseVacb(SharedCacheMap, LastVacb, LastVacb->Dirty ? 
LastVacb->Valid : FALSE, FALSE, FALSE);
+}
+}
+
+/* Check for file size and the last VACB */
+if (SharedCacheMap->FileSize.QuadPart < FileSizes->FileSize.QuadPart &&
+SharedCacheMap->FileSize.QuadPart % VACB_MAPPING_GRANULARITY)
+{
+LastVacb = CcRosLookupVacb(SharedCacheMap,
+   SharedCacheMap->FileSize.QuadPart);
+if (LastVacb != NULL)
+{
+/* Mark it as invalid */
+CcRosReleaseVacb(SharedCacheMap, LastVacb, LastVacb->Dirty ? 
LastVacb->Valid : FALSE, FALSE, FALSE);
+}
+}
+}
 
 KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &oldirql);
 SharedCacheMap->SectionSize = FileSizes->AllocationSize;



[ros-diffs] [reactos] 01/02: [KMTESTS:CC] Add tests showing a dirty VACB isn't flushed on file growing

2018-12-23 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=34b6a287645ea80814ccd2aee161cf59d7acc5a0

commit 34b6a287645ea80814ccd2aee161cf59d7acc5a0
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 23 12:04:39 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Dec 23 12:04:39 2018 +0100

[KMTESTS:CC] Add tests showing a dirty VACB isn't flushed on file growing

CORE-11819
---
 .../rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c  | 123 -
 .../rostests/kmtests/ntos_cc/CcSetFileSizes_user.c |   4 +-
 2 files changed, 122 insertions(+), 5 deletions(-)

diff --git a/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c 
b/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c
index 7895786dd5..af644a0a18 100644
--- a/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c
+++ b/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c
@@ -25,6 +25,11 @@ static PFILE_OBJECT TestFileObject;
 static PDEVICE_OBJECT TestDeviceObject;
 static KMT_IRP_HANDLER TestIrpHandler;
 static KMT_MESSAGE_HANDLER TestMessageHandler;
+static BOOLEAN TestUnpin = FALSE;
+static BOOLEAN TestSizing = FALSE;
+static BOOLEAN TestDirtying = FALSE;
+static BOOLEAN TestUncaching = FALSE;
+static BOOLEAN TestWritten = FALSE;
 
 NTSTATUS
 TestEntry(
@@ -45,6 +50,7 @@ TestEntry(
  TESTENTRY_NO_READONLY_DEVICE;
 
 KmtRegisterIrpHandler(IRP_MJ_READ, NULL, TestIrpHandler);
+KmtRegisterIrpHandler(IRP_MJ_WRITE, NULL, TestIrpHandler);
 KmtRegisterMessageHandler(0, NULL, TestMessageHandler);
 
 return Status;
@@ -153,6 +159,7 @@ PerformTest(
 ok_eq_pointer(TestDeviceObject, NULL);
 ok_eq_ulong(TestTestId, -1);
 
+TestWritten = FALSE;
 TestDeviceObject = DeviceObject;
 TestTestId = TestId;
 TestFileObject = IoCreateStreamFileObject(NULL, DeviceObject);
@@ -171,7 +178,7 @@ PerformTest(
 Fcb->Header.FileSize.QuadPart = VACB_MAPPING_GRANULARITY - 
PAGE_SIZE;
 Fcb->Header.ValidDataLength.QuadPart = VACB_MAPPING_GRANULARITY - 
PAGE_SIZE;
 
-if (TestId > 1 && TestId < 4)
+if ((TestId > 1 && TestId < 4) || TestId == 5)
 {
 Fcb->Header.AllocationSize.QuadPart = VACB_MAPPING_GRANULARITY 
- PAGE_SIZE;
 }
@@ -249,6 +256,65 @@ PerformTest(
 ExFreePool(Buffer);
 }
 }
+else if (TestId == 4 || TestId == 5)
+{
+/* Kill lazy writer */
+CcSetAdditionalCacheAttributes(TestFileObject, FALSE, 
TRUE);
+
+Offset.QuadPart = 0;
+KmtStartSeh();
+Ret = CcPinRead(TestFileObject, &Offset, 
VACB_MAPPING_GRANULARITY - PAGE_SIZE, MAP_WAIT, &Bcb, (PVOID *)&Buffer);
+KmtEndSeh(STATUS_SUCCESS);
+
+if (!skip(Ret == TRUE, "CcPinRead failed\n"))
+{
+LARGE_INTEGER Flushed;
+
+ok_eq_ulong(Buffer[(VACB_MAPPING_GRANULARITY - 
PAGE_SIZE - sizeof(ULONG)) / sizeof(ULONG)], 0xBABABABA);
+Buffer[(VACB_MAPPING_GRANULARITY - PAGE_SIZE - 
sizeof(ULONG)) / sizeof(ULONG)] = 0xDADADADA;
+
+TestDirtying = TRUE;
+CcSetDirtyPinnedData(Bcb, NULL);
+TestDirtying = FALSE;
+
+ok_bool_false(TestWritten, "Dirty VACB has been 
unexpectedly written!\n");
+
+TestSizing = TRUE;
+KmtStartSeh();
+CcSetFileSizes(TestFileObject, &NewFileSizes);
+KmtEndSeh(STATUS_SUCCESS);
+TestSizing = FALSE;
+
+ok_bool_false(TestWritten, "Dirty VACB has been 
unexpectedly written!\n");
+
+Fcb->Header.AllocationSize.QuadPart = 
VACB_MAPPING_GRANULARITY;
+Fcb->Header.FileSize.QuadPart = 
VACB_MAPPING_GRANULARITY;
+
+Flushed = 
CcGetFlushedValidData(TestFileObject->SectionObjectPointer, FALSE);
+ok(Flushed.QuadPart == 0, "Flushed: %I64d\n", 
Flushed.QuadPart);
+
+TestUnpin = TRUE;
+CcUnpinData(Bcb);
+TestUnpin = FALSE;
+
+ok_bool_false(TestWritten, "Dirty VACB has been 
unexpectedly written!\n");
+
+Offset.QuadPart = 0;
+KmtStartSeh();
+Ret = CcMapData(TestFileObject, &Offset, 
VACB_MAPPING_GRANULARITY, MAP_WAIT, &Bcb, (PVOID *)&Buffer);
+KmtEndSeh(STATUS_SUCCESS);
+
+if (!skip(Ret == TRUE, "CcMapData failed\n"))
+{
+ok_eq_u

[ros-diffs] [reactos] 02/02: [NTOSKRNL] Honor files that shouldn't be lazy written

2018-12-23 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1a267045f8cd36de9eb7542bef9a2fd7d34e0b09

commit 1a267045f8cd36de9eb7542bef9a2fd7d34e0b09
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 23 12:10:58 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Dec 23 12:10:58 2018 +0100

[NTOSKRNL] Honor files that shouldn't be lazy written
---
 ntoskrnl/cc/view.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c
index d64496595f..890c75e99c 100644
--- a/ntoskrnl/cc/view.c
+++ b/ntoskrnl/cc/view.c
@@ -222,6 +222,14 @@ CcRosFlushDirtyPages (
 continue;
 }
 
+/* Don't attempt to lazy write the files that asked not to */
+if (CalledFromLazy &&
+BooleanFlagOn(current->SharedCacheMap->Flags, 
WRITEBEHIND_DISABLED))
+{
+CcRosVacbDecRefCount(current);
+continue;
+}
+
 ASSERT(current->Dirty);
 
 KeReleaseQueuedSpinLock(LockQueueMasterLock, OldIrql);



[ros-diffs] [reactos] 01/01: [KMTESTS:CC] Fix a typo, definitely showing this code path is not used during the test

2018-12-23 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cdc419eb1808659362ff71575e84541c6d460319

commit cdc419eb1808659362ff71575e84541c6d460319
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 23 12:31:14 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Dec 23 12:31:14 2018 +0100

[KMTESTS:CC] Fix a typo, definitely showing this code path is not used 
during the test
---
 modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c 
b/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c
index af644a0a18..3d23ab54be 100644
--- a/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c
+++ b/modules/rostests/kmtests/ntos_cc/CcSetFileSizes_drv.c
@@ -456,7 +456,7 @@ TestIrpHandler(
 RtlFillMemory(Buffer, Length, 0xBD);
 }
 
-if (TestTestId == 4 && TestWritten &&
+if ((TestTestId == 4 || TestTestId == 5) && TestWritten &&
 Offset.QuadPart <= VACB_MAPPING_GRANULARITY - PAGE_SIZE - 
sizeof(ULONG) &&
 Offset.QuadPart + Length >= VACB_MAPPING_GRANULARITY - PAGE_SIZE)
 {



[ros-diffs] [reactos] 01/01: [NTOSKRNL] Implement write behind in Cc

2018-12-23 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7e97071c8b715b16303ac7fa00be652b17f552ec

commit 7e97071c8b715b16303ac7fa00be652b17f552ec
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 23 14:43:17 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Dec 23 14:45:38 2018 +0100

[NTOSKRNL] Implement write behind in Cc

For now, this is just a split between scan and flush that
were both done during lazy scan previously.
Lazy scan shouldn't perform any write operation, but only
queue a write behind operation.

Our implementation is far from the original, as it seems
our lazy scan should queue a write behind operation per
shared cache map. Right now, we only perform global
operation.
---
 ntoskrnl/cc/lazywrite.c| 61 ++
 ntoskrnl/include/internal/cc.h |  2 +-
 2 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/ntoskrnl/cc/lazywrite.c b/ntoskrnl/cc/lazywrite.c
index 8cb5adb2e7..275507e904 100644
--- a/ntoskrnl/cc/lazywrite.c
+++ b/ntoskrnl/cc/lazywrite.c
@@ -109,15 +109,33 @@ CcScanDpc(
 }
 
 /* And post it, it will be for lazy write */
-WorkItem->Function = LazyWrite;
+WorkItem->Function = LazyScan;
 CcPostWorkQueue(WorkItem, &CcRegularWorkQueue);
 }
 
+VOID
+CcWriteBehind(VOID)
+{
+ULONG Target, Count;
+
+Target = CcTotalDirtyPages / 8;
+if (Target != 0)
+{
+/* Flush! */
+DPRINT("Lazy writer starting (%d)\n", Target);
+CcRosFlushDirtyPages(Target, &Count, FALSE, TRUE);
+
+/* And update stats */
+CcLazyWritePages += Count;
+++CcLazyWriteIos;
+DPRINT("Lazy writer done (%d)\n", Count);
+}
+}
+
 VOID
 CcLazyWriteScan(VOID)
 {
 ULONG Target;
-ULONG Count;
 KIRQL OldIrql;
 PLIST_ENTRY ListEntry;
 LIST_ENTRY ToPost;
@@ -142,14 +160,15 @@ CcLazyWriteScan(VOID)
 Target = CcTotalDirtyPages / 8;
 if (Target != 0)
 {
-/* Flush! */
-DPRINT("Lazy writer starting (%d)\n", Target);
-CcRosFlushDirtyPages(Target, &Count, FALSE, TRUE);
+/* There is stuff to flush, schedule a write-behind operation */
 
-/* And update stats */
-CcLazyWritePages += Count;
-++CcLazyWriteIos;
-DPRINT("Lazy writer done (%d)\n", Count);
+/* Allocate a work item */
+WorkItem = ExAllocateFromNPagedLookasideList(&CcTwilightLookasideList);
+if (WorkItem != NULL)
+{
+WorkItem->Function = WriteBehind;
+CcPostWorkQueue(WorkItem, &CcRegularWorkQueue);
+}
 }
 
 /* Post items that were due for end of run */
@@ -208,7 +227,7 @@ CcWorkerThread(
 IN PVOID Parameter)
 {
 KIRQL OldIrql;
-BOOLEAN DropThrottle;
+BOOLEAN DropThrottle, WritePerformed;
 PWORK_QUEUE_ITEM Item;
 #if DBG
 PIRP TopLevel;
@@ -218,6 +237,8 @@ CcWorkerThread(
 Item = Parameter;
 /* And by default, don't touch throttle */
 DropThrottle = FALSE;
+/* No write performed */
+WritePerformed =  FALSE;
 
 #if DBG
 /* Top level IRP should be clean when started
@@ -285,7 +306,12 @@ CcWorkerThread(
 CcPerformReadAhead(WorkItem->Parameters.Read.FileObject);
 break;
 
-case LazyWrite:
+case WriteBehind:
+CcWriteBehind();
+WritePerformed = TRUE;
+break;
+
+case LazyScan:
 CcLazyWriteScan();
 break;
 
@@ -309,6 +335,19 @@ CcWorkerThread(
 --CcNumberActiveWorkerThreads;
 KeReleaseQueuedSpinLock(LockQueueWorkQueueLock, OldIrql);
 
+/* If there are pending write openations and we have at least 20 dirty 
pages */
+if (!IsListEmpty(&CcDeferredWrites) && CcTotalDirtyPages >= 20)
+{
+/* And if we performed a write operation previously, then
+ * stress the system a bit and reschedule a scan to find
+ * stuff to write
+ */
+if (WritePerformed)
+{
+CcLazyWriteScan();
+}
+}
+
 #if DBG
 /* Top level shouldn't have changed */
 if (TopLevel != IoGetTopLevelIrp())
diff --git a/ntoskrnl/include/internal/cc.h b/ntoskrnl/include/internal/cc.h
index 8a5fb73838..10bdb43a86 100644
--- a/ntoskrnl/include/internal/cc.h
+++ b/ntoskrnl/include/internal/cc.h
@@ -278,7 +278,7 @@ typedef enum _WORK_QUEUE_FUNCTIONS
 {
 ReadAhead = 1,
 WriteBehind = 2,
-LazyWrite = 3,
+LazyScan = 3,
 SetDone = 4,
 } WORK_QUEUE_FUNCTIONS, *PWORK_QUEUE_FUNCTIONS;
 



[ros-diffs] [reactos] 01/01: [NTOSKRNL] Set the MemoryMaker flag when executing write behind

2018-12-23 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e16241255d518e318aafa7d02b8e2eb6049c60b9

commit e16241255d518e318aafa7d02b8e2eb6049c60b9
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 23 14:59:42 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Dec 23 14:59:42 2018 +0100

[NTOSKRNL] Set the MemoryMaker flag when executing write behind
---
 ntoskrnl/cc/lazywrite.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ntoskrnl/cc/lazywrite.c b/ntoskrnl/cc/lazywrite.c
index 275507e904..56f8d922df 100644
--- a/ntoskrnl/cc/lazywrite.c
+++ b/ntoskrnl/cc/lazywrite.c
@@ -307,7 +307,9 @@ CcWorkerThread(
 break;
 
 case WriteBehind:
+PsGetCurrentThread()->MemoryMaker = 1;
 CcWriteBehind();
+PsGetCurrentThread()->MemoryMaker = 0;
 WritePerformed = TRUE;
 break;
 



[ros-diffs] [reactos] 01/01: [SDK] Set proper lang IDs, aka fix build

2018-12-23 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d0b263f26f6928b26bd267f680865eeaae895968

commit d0b263f26f6928b26bd267f680865eeaae895968
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 23 18:22:57 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Dec 23 18:22:57 2018 +0100

[SDK] Set proper lang IDs, aka fix build
---
 sdk/include/reactos/mc/net_msg.mc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sdk/include/reactos/mc/net_msg.mc 
b/sdk/include/reactos/mc/net_msg.mc
index a65776ce6a..b44a928dc1 100644
--- a/sdk/include/reactos/mc/net_msg.mc
+++ b/sdk/include/reactos/mc/net_msg.mc
@@ -11,9 +11,9 @@ FacilityNames=(System=0x0:FACILITY_SYSTEM
 
 LanguageNames=(English=0x409:MSG00409
Polish=0x415:MSG00415
-   Romanian=0x018:MSG00018
+   Romanian=0x418:MSG00418
Russian=0x419:MSG00419
-   Spanish=0x00A:MSGA
+   Spanish=0x40A:MSG0040A
Turkish=0x41F:MSG0041F
Chinese=0x804:MSG00804
Taiwanese=0x404:MSG00404



[ros-diffs] [reactos] 02/03: [NTOSKRNL_VISTA] Implement FsRtlGetEcpListFromIrp and FsRtlGetNextExtraCreateParameter

2018-12-25 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f75ea083e356c4c9eba0e59262f5fbeeca241136

commit f75ea083e356c4c9eba0e59262f5fbeeca241136
Author: Pierre Schweitzer 
AuthorDate: Tue Dec 25 13:45:41 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Tue Dec 25 13:50:41 2018 +0100

[NTOSKRNL_VISTA] Implement FsRtlGetEcpListFromIrp and 
FsRtlGetNextExtraCreateParameter

CORE-15452
---
 sdk/lib/drivers/ntoskrnl_vista/fsrtl.c | 119 +
 1 file changed, 119 insertions(+)

diff --git a/sdk/lib/drivers/ntoskrnl_vista/fsrtl.c 
b/sdk/lib/drivers/ntoskrnl_vista/fsrtl.c
index 4d7831aa4c..8b714af57a 100644
--- a/sdk/lib/drivers/ntoskrnl_vista/fsrtl.c
+++ b/sdk/lib/drivers/ntoskrnl_vista/fsrtl.c
@@ -9,6 +9,33 @@
 #include 
 #include 
 
+typedef struct _ECP_LIST
+{
+ULONG Signature;
+ULONG Flags;
+LIST_ENTRY EcpList;
+} ECP_LIST, *PECP_LIST;
+
+typedef ULONG ECP_HEADER_FLAGS;
+
+typedef struct _ECP_HEADER
+{
+ULONG Signature;
+ULONG Spare;
+LIST_ENTRY ListEntry;
+GUID EcpType;
+PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK CleanupCallback;
+ECP_HEADER_FLAGS Flags;
+ULONG Size;
+PVOID ListAllocatedFrom;
+PVOID Filter;
+} ECP_HEADER, *PECP_HEADER;
+
+#define ECP_HEADER_SIZE (sizeof(ECP_HEADER))
+
+#define ECP_HEADER_TO_CONTEXT(H) ((PVOID)((ULONG_PTR)H + ECP_HEADER_SIZE))
+#define ECP_CONTEXT_TO_HEADER(C) ((PECP_HEADER)((ULONG_PTR)C - 
ECP_HEADER_SIZE))
+
 NTKERNELAPI
 NTSTATUS
 NTAPI
@@ -240,3 +267,95 @@ FsRtlValidateReparsePointBuffer(IN ULONG BufferLength,
 return STATUS_IO_REPARSE_TAG_INVALID;
 }
 
+NTKERNELAPI
+NTSTATUS
+NTAPI
+FsRtlGetEcpListFromIrp(IN PIRP Irp,
+   OUT PECP_LIST *EcpList)
+{
+/* Call Io */
+return IoGetIrpExtraCreateParameter(Irp, EcpList);
+}
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+FsRtlGetNextExtraCreateParameter(IN PECP_LIST EcpList,
+ IN PVOID CurrentEcpContext,
+ OUT LPGUID NextEcpType OPTIONAL,
+ OUT PVOID *NextEcpContext,
+ OUT PULONG NextEcpContextSize OPTIONAL)
+{
+PECP_HEADER CurrentEntry;
+
+/* If we have no context ... */
+if (CurrentEcpContext == NULL)
+{
+if (IsListEmpty(&EcpList->EcpList))
+{
+goto FailEmpty;
+}
+
+/* Simply consider first entry */
+CurrentEntry = CONTAINING_RECORD(EcpList->EcpList.Flink, ECP_HEADER, 
ListEntry);
+}
+else
+{
+/* Otherwise, consider the entry matching the given context */
+CurrentEntry = ECP_CONTEXT_TO_HEADER(CurrentEcpContext);
+
+/* Make sure we didn't reach the end */
+if (&CurrentEntry->ListEntry == &EcpList->EcpList)
+{
+goto FailEmpty;
+}
+}
+
+/* We must have an entry */
+if (CurrentEntry == NULL)
+{
+goto FailEmpty;
+}
+
+/* If caller wants a context, give it */
+if (NextEcpContext != NULL)
+{
+*NextEcpContext = ECP_HEADER_TO_CONTEXT(CurrentEntry);
+}
+
+/* Same for its size (which the size minus the header overhead) */
+if (NextEcpContextSize != NULL)
+{
+ *NextEcpContextSize = CurrentEntry->Size - sizeof(ECP_HEADER);
+}
+
+/* And copy the type if asked to */
+if (NextEcpType != NULL)
+{
+RtlCopyMemory(NextEcpType, &CurrentEntry->EcpType, sizeof(GUID));
+}
+
+/* Job done */
+return STATUS_SUCCESS;
+
+/* Failure case: just zero everything */
+FailEmpty:
+if (NextEcpContext != NULL)
+{
+*NextEcpContext = NULL;
+}
+
+if (NextEcpContextSize != NULL)
+{
+*NextEcpContextSize = 0;
+}
+
+if (NextEcpType != NULL)
+{
+RtlZeroMemory(NextEcpType, sizeof(GUID));
+}
+
+/* And return failure */
+return STATUS_NOT_FOUND;
+}
+



[ros-diffs] [reactos] 03/03: [BTRFS] Reduce diff with upstream

2018-12-25 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e6cd48809abe178cc9b5c20670ce1a8770ae9d2d

commit e6cd48809abe178cc9b5c20670ce1a8770ae9d2d
Author: Pierre Schweitzer 
AuthorDate: Tue Dec 25 13:50:07 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Tue Dec 25 13:50:41 2018 +0100

[BTRFS] Reduce diff with upstream

CORE-15452
---
 drivers/filesystems/btrfs/btrfs_drv.h | 12 
 drivers/filesystems/btrfs/create.c|  6 --
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/filesystems/btrfs/btrfs_drv.h 
b/drivers/filesystems/btrfs/btrfs_drv.h
index e6ea5891f3..3ccb10ac06 100644
--- a/drivers/filesystems/btrfs/btrfs_drv.h
+++ b/drivers/filesystems/btrfs/btrfs_drv.h
@@ -1856,6 +1856,11 @@ NTSTATUS NTAPI ZwQueryInformationProcess(
 #endif
 #endif
 
+#if defined(__REACTOS__) && (NTDDI_VERSION < NTDDI_VISTA)
+typedef struct _ECP_LIST ECP_LIST;
+typedef struct _ECP_LIST *PECP_LIST;
+#endif
+
 #if defined(__REACTOS__) && (NTDDI_VERSION < NTDDI_WIN7)
 NTSTATUS WINAPI RtlUnicodeToUTF8N(CHAR *utf8_dest, ULONG utf8_bytes_max,
   ULONG *utf8_bytes_written,
@@ -1870,6 +1875,13 @@ NTSTATUS NTAPI FsRtlRemoveDotsFromPath(PWSTR 
OriginalString,
 NTSTATUS NTAPI FsRtlValidateReparsePointBuffer(ULONG BufferLength,
PREPARSE_DATA_BUFFER 
ReparseBuffer);
 ULONG NTAPI KeQueryActiveProcessorCount(PKAFFINITY ActiveProcessors);
+NTSTATUS NTAPI FsRtlGetEcpListFromIrp(IN PIRP Irp,
+  OUT PECP_LIST *EcpList);
+NTSTATUS NTAPI FsRtlGetNextExtraCreateParameter(IN PECP_LIST EcpList,
+IN PVOID CurrentEcpContext,
+OUT LPGUID NextEcpType 
OPTIONAL,
+OUT PVOID *NextEcpContext,
+OUT PULONG NextEcpContextSize 
OPTIONAL);
 #endif /* defined(__REACTOS__) && (NTDDI_VERSION < NTDDI_VISTA) */
 
 #endif
diff --git a/drivers/filesystems/btrfs/create.c 
b/drivers/filesystems/btrfs/create.c
index 1b4417e802..2cde2371e8 100644
--- a/drivers/filesystems/btrfs/create.c
+++ b/drivers/filesystems/btrfs/create.c
@@ -2510,10 +2510,8 @@ static NTSTATUS file_create(PIRP Irp, 
_Requires_lock_held_(_Curr_->tree_lock) _R
 UNICODE_STRING dsus, fpus, stream;
 PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
 POOL_TYPE pool_type = IrpSp->Flags & SL_OPEN_PAGING_FILE ? NonPagedPool : 
PagedPool;
-#ifndef __REACTOS__
 ECP_LIST* ecp_list;
 ATOMIC_CREATE_ECP_CONTEXT* acec = NULL;
-#endif
 #ifdef DEBUG_FCB_REFCOUNTS
 LONG oc;
 #endif
@@ -2526,7 +2524,6 @@ static NTSTATUS file_create(PIRP Irp, 
_Requires_lock_held_(_Curr_->tree_lock) _R
 if (options & FILE_DELETE_ON_CLOSE && 
IrpSp->Parameters.Create.FileAttributes & FILE_ATTRIBUTE_READONLY)
 return STATUS_CANNOT_DELETE;
 
-#ifndef __REACTOS__
 if (NT_SUCCESS(FsRtlGetEcpListFromIrp(Irp, &ecp_list)) && ecp_list) {
 void* ctx = NULL;
 GUID type;
@@ -2543,7 +2540,6 @@ static NTSTATUS file_create(PIRP Irp, 
_Requires_lock_held_(_Curr_->tree_lock) _R
 }
 } while (NT_SUCCESS(Status));
 }
-#endif
 
 dsus.Buffer = (WCHAR*)datasuf;
 dsus.Length = dsus.MaximumLength = sizeof(datasuf) - sizeof(WCHAR);
@@ -2720,7 +2716,6 @@ static NTSTATUS file_create(PIRP Irp, 
_Requires_lock_held_(_Curr_->tree_lock) _R
 
 FileObject->SectionObjectPointer = &fileref->fcb->nonpaged->segment_object;
 
-#ifndef __REACTOS__
 // FIXME - ATOMIC_CREATE_ECP_IN_FLAG_BEST_EFFORT
 if (acec && acec->InFlags & 
ATOMIC_CREATE_ECP_IN_FLAG_REPARSE_POINT_SPECIFIED) {
 if (acec->ReparseBufferLength > sizeof(UINT32) && 
*(UINT32*)acec->ReparseBuffer == IO_REPARSE_TAG_SYMLINK) {
@@ -2751,7 +2746,6 @@ static NTSTATUS file_create(PIRP Irp, 
_Requires_lock_held_(_Curr_->tree_lock) _R
 
 acec->OutFlags |= ATOMIC_CREATE_ECP_OUT_FLAG_REPARSE_POINT_SET;
 }
-#endif
 
 fileref->dc->type = fileref->fcb->type;
 



[ros-diffs] [reactos] 01/03: [NTOSKRNL_VISTA] Implement IoGetIrpExtraCreateParameter

2018-12-25 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a76b8843a88fedd4d1815704412d110006b2000e

commit a76b8843a88fedd4d1815704412d110006b2000e
Author: Pierre Schweitzer 
AuthorDate: Tue Dec 25 13:44:44 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Tue Dec 25 13:50:40 2018 +0100

[NTOSKRNL_VISTA] Implement IoGetIrpExtraCreateParameter

CORE-15452
---
 sdk/lib/drivers/ntoskrnl_vista/CMakeLists.txt |  1 +
 sdk/lib/drivers/ntoskrnl_vista/io.c   | 27 +++
 2 files changed, 28 insertions(+)

diff --git a/sdk/lib/drivers/ntoskrnl_vista/CMakeLists.txt 
b/sdk/lib/drivers/ntoskrnl_vista/CMakeLists.txt
index 0fdafabeb9..0fd8fd8c7e 100644
--- a/sdk/lib/drivers/ntoskrnl_vista/CMakeLists.txt
+++ b/sdk/lib/drivers/ntoskrnl_vista/CMakeLists.txt
@@ -5,6 +5,7 @@ add_definitions(-DUNICODE -D_UNICODE -D__NTOSKRNL__ 
-D_NTOSKRNL_ -D_NTSYSTEM_)
 
 list(APPEND SOURCE
 fsrtl.c
+io.c
 ke.c
 rtl.c)
 
diff --git a/sdk/lib/drivers/ntoskrnl_vista/io.c 
b/sdk/lib/drivers/ntoskrnl_vista/io.c
new file mode 100644
index 00..1d88cbb68f
--- /dev/null
+++ b/sdk/lib/drivers/ntoskrnl_vista/io.c
@@ -0,0 +1,27 @@
+/*
+ * PROJECT: ReactOS Kernel - Vista+ APIs
+ * LICENSE: GPL v2 - See COPYING in the top level directory
+ * FILE:lib/drivers/ntoskrnl_vista/io.c
+ * PURPOSE: Io functions of Vista+
+ * PROGRAMMERS: Pierre Schweitzer 
+ */
+
+#include 
+#include 
+
+NTKERNELAPI
+NTSTATUS
+NTAPI
+IoGetIrpExtraCreateParameter(IN PIRP Irp,
+ OUT PECP_LIST *ExtraCreateParameter)
+{
+/* Check we have a create operation */
+if (!BooleanFlagOn(Irp->Flags, IRP_CREATE_OPERATION))
+{
+return STATUS_INVALID_PARAMETER;
+}
+
+/* If so, return user buffer */
+*ExtraCreateParameter = Irp->UserBuffer;
+return STATUS_SUCCESS;
+}



[ros-diffs] [reactos] 01/01: [SETUP] Add support for selecting FS type in unattended setups

2018-12-28 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4ed6b1ffca67c30568e271ce13454a08d7d85cb9

commit 4ed6b1ffca67c30568e271ce13454a08d7d85cb9
Author: Pierre Schweitzer 
AuthorDate: Fri Dec 28 20:34:48 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Fri Dec 28 20:36:47 2018 +0100

[SETUP] Add support for selecting FS type in unattended setups

By default, we still fallback to FAT if nothing asked, or if there
is an invalid input.
0 is FAT, 1 is BtrFS. This can be grown as soon as we add more IFS.
---
 base/setup/lib/setuplib.c| 10 ++
 base/setup/lib/setuplib.h|  1 +
 base/setup/usetup/usetup.c   | 34 +++-
 boot/bootdata/bootcdregtest/unattend.inf |  5 +
 4 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/base/setup/lib/setuplib.c b/base/setup/lib/setuplib.c
index 1bbdaa8f3e..2b52c463f3 100644
--- a/base/setup/lib/setuplib.c
+++ b/base/setup/lib/setuplib.c
@@ -196,6 +196,16 @@ CheckUnattendedSetup(
}
 }
 
+/* Search for FsType in the 'Unattend' section */
+pSetupData->FsType = 0;
+if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"FsType", &Context))
+{
+if (SpInfGetIntField(&Context, 1, &IntValue))
+{
+pSetupData->FsType = IntValue;
+}
+}
+
 Quit:
 SpInfCloseInfFile(UnattendInf);
 }
diff --git a/base/setup/lib/setuplib.h b/base/setup/lib/setuplib.h
index 4bd5981ff2..658054fac2 100644
--- a/base/setup/lib/setuplib.h
+++ b/base/setup/lib/setuplib.h
@@ -110,6 +110,7 @@ typedef struct _USETUP_DATA
 LONG MBRInstallType;
 LONG FormatPartition;
 LONG AutoPartition;
+LONG FsType;
 
 /* Settings lists */
 PGENERIC_LIST ComputerList;
diff --git a/base/setup/usetup/usetup.c b/base/setup/usetup/usetup.c
index deb918efb6..6fd68b7542 100644
--- a/base/setup/usetup/usetup.c
+++ b/base/setup/usetup/usetup.c
@@ -2859,8 +2859,31 @@ SelectFileSystemPage(PINPUT_RECORD Ir)
 
 if (FileSystemList == NULL)
 {
-/* Create the file system list, and by default select the "FAT" file 
system */
-FileSystemList = CreateFileSystemList(6, 26, PartEntry->New, L"FAT");
+PWSTR DefaultFs;
+
+if (IsUnattendedSetup)
+{
+switch (USetupData.FsType)
+{
+/* 1 is for BtrFS */
+case 1:
+DefaultFs = L"BTRFS";
+break;
+
+/* If we don't understand input, default to FAT */
+default:
+DefaultFs = L"FAT";
+break;
+}
+}
+else
+{
+/* By default select the "FAT" file system */
+DefaultFs = L"FAT";
+}
+
+/* Create the file system list */
+FileSystemList = CreateFileSystemList(6, 26, PartEntry->New, 
DefaultFs);
 if (FileSystemList == NULL)
 {
 /* FIXME: show an error dialog */
@@ -2878,13 +2901,6 @@ SelectFileSystemPage(PINPUT_RECORD Ir)
 {
 if (USetupData.FormatPartition)
 {
-/*
- * We use whatever currently selected file system we have
- * (by default, this is "FAT", as per the initialization
- * performed above). Note that it may be interesting to specify
- * which file system to use in unattended installations, in the
- * txtsetup.sif file.
- */
 return FORMAT_PARTITION_PAGE;
 }
 
diff --git a/boot/bootdata/bootcdregtest/unattend.inf 
b/boot/bootdata/bootcdregtest/unattend.inf
index 08ce20d3fd..e325e570bd 100644
--- a/boot/bootdata/bootcdregtest/unattend.inf
+++ b/boot/bootdata/bootcdregtest/unattend.inf
@@ -38,6 +38,11 @@ FormatPartition=1
 ; 0 - disabled
 AutoPartition = 1
 
+; choose default file system type
+; 0 - FAT
+; 1 - BtrFS
+FsType = 0
+
 ; set this option to automatically
 ; specify language in 2nd mode setup
 ; see hivesys.inf for available languages



[ros-diffs] [reactos] 01/01: [ADVAPI32_APITEST] Unknown field isn't that unknown and should contain "1"

2018-12-29 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=830f2998abf17123f3b0126733cb4f49282ca1fe

commit 830f2998abf17123f3b0126733cb4f49282ca1fe
Author: Pierre Schweitzer 
AuthorDate: Sat Dec 29 22:09:52 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Dec 29 22:09:52 2018 +0100

[ADVAPI32_APITEST] Unknown field isn't that unknown and should contain "1"

See processhacker source code (as reference)
---
 modules/rostests/apitests/advapi32/ServiceEnv.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/modules/rostests/apitests/advapi32/ServiceEnv.c 
b/modules/rostests/apitests/advapi32/ServiceEnv.c
index f71d25541d..cfb7318b4f 100644
--- a/modules/rostests/apitests/advapi32/ServiceEnv.c
+++ b/modules/rostests/apitests/advapi32/ServiceEnv.c
@@ -113,19 +113,20 @@ service_main(DWORD dwArgc, LPWSTR* lpszArgv)
 {
 /* IN/OUT parameter structure for I_QueryTagInformation() function
  * See: 
https://wj32.org/wp/2010/03/30/howto-use-i_querytaginformation/
+ * See: 
https://github.com/processhacker/processhacker/blob/master/phnt/include/subprocesstag.h
  */
 struct
 {
 ULONG ProcessId;
 PVOID ServiceTag;
-ULONG Unknown;
+ULONG TagType;
 PWSTR Buffer;
 } ServiceQuery;
 
 /* Set our input parameters */
 ServiceQuery.ProcessId = GetCurrentProcessId();
 ServiceQuery.ServiceTag = Teb->SubProcessTag;
-ServiceQuery.Unknown = 0;
+ServiceQuery.TagType = 0;
 ServiceQuery.Buffer = NULL;
 /* Call ADVAPI32 to query the correctness of our tag */
 _I_QueryTagInformation(NULL, 1, &ServiceQuery);
@@ -135,6 +136,7 @@ service_main(DWORD dwArgc, LPWSTR* lpszArgv)
 {
 /* It should match our service name */
 service_ok(wcscmp(lpszArgv[0], ServiceQuery.Buffer) == 0, 
"Mismatching info: %S - %S\n", lpszArgv[0], ServiceQuery.Buffer);
+service_ok(ServiceQuery.TagType == 1, "Invalid tag type: 
%x\n", ServiceQuery.TagType);
 LocalFree(ServiceQuery.Buffer);
 }
 }



[ros-diffs] [reactos] 02/06: [ADVAPI32] Implement I_QueryTagInformation

2018-12-30 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=19304da5c3b725f979e081cd18e5290bf92e2080

commit 19304da5c3b725f979e081cd18e5290bf92e2080
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 30 11:52:37 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Dec 30 14:27:02 2018 +0100

[ADVAPI32] Implement I_QueryTagInformation
---
 dll/win32/advapi32/advapi32.spec |  2 +-
 dll/win32/advapi32/service/scm.c | 44 
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/dll/win32/advapi32/advapi32.spec b/dll/win32/advapi32/advapi32.spec
index 3414463328..5a571db55a 100644
--- a/dll/win32/advapi32/advapi32.spec
+++ b/dll/win32/advapi32/advapi32.spec
@@ -294,7 +294,7 @@
 294 stdcall GetUserNameA(ptr ptr)
 295 stdcall GetUserNameW(ptr ptr)
 296 stdcall GetWindowsAccountDomainSid(ptr ptr ptr)
-297 stub I_QueryTagInformation
+297 stdcall I_QueryTagInformation(ptr long ptr)
 298 stdcall I_ScIsSecurityProcess()
 299 stdcall I_ScPnPGetServiceName(ptr wstr long)
 300 stub I_ScSendTSMessage
diff --git a/dll/win32/advapi32/service/scm.c b/dll/win32/advapi32/service/scm.c
index 1fe96213a1..08baad1cb9 100644
--- a/dll/win32/advapi32/service/scm.c
+++ b/dll/win32/advapi32/service/scm.c
@@ -3022,4 +3022,48 @@ NotifyBootConfigStatus(BOOL BootAcceptable)
 return TRUE;
 }
 
+DWORD
+I_ScQueryServiceTagInfo(PVOID Unused,
+TAG_INFO_LEVEL dwInfoLevel,
+PTAG_INFO_NAME_FROM_TAG InOutParams)
+{
+return ERROR_CALL_NOT_IMPLEMENTED;
+}
+
+/**
+ *  I_QueryTagInformation
+ *
+ * @implemented
+ */
+DWORD WINAPI
+I_QueryTagInformation(PVOID Unused,
+  TAG_INFO_LEVEL dwInfoLevel,
+  PTAG_INFO_NAME_FROM_TAG InOutParams)
+{
+/*
+ * We only support one information class and it
+ * needs parameters
+ */
+if (dwInfoLevel != TagInfoLevelNameFromTag ||
+InOutParams == NULL)
+{
+return ERROR_INVALID_PARAMETER;
+}
+
+/* Validate input structure */
+if (InOutParams->InParams.dwPid == 0 || InOutParams->InParams.dwTag == 0)
+{
+return ERROR_INVALID_PARAMETER;
+}
+
+/* Validate output structure */
+if (InOutParams->OutParams.pszName != NULL)
+{
+return ERROR_INVALID_PARAMETER;
+}
+
+/* Call internal function for the RPC call */
+return I_ScQueryServiceTagInfo(Unused, TagInfoLevelNameFromTag, 
InOutParams);
+}
+
 /* EOF */



[ros-diffs] [reactos] 01/06: [SERVICES] Define the RI_ScQueryServiceTagInfo RPC call

2018-12-30 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=dfaee51f98f9c2571a29af80906130f1f3c7da43

commit dfaee51f98f9c2571a29af80906130f1f3c7da43
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 30 11:45:08 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Dec 30 14:26:57 2018 +0100

[SERVICES] Define the RI_ScQueryServiceTagInfo RPC call

All the definitions are taken from ProcessHacker:

https://github.com/processhacker/processhacker/blob/master/phnt/include/subprocesstag.h
---
 base/system/services/rpcserver.c   |  7 +--
 sdk/include/reactos/idl/svcctl.idl | 31 +--
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/base/system/services/rpcserver.c b/base/system/services/rpcserver.c
index 7f251c8760..5b243f7f89 100644
--- a/base/system/services/rpcserver.c
+++ b/base/system/services/rpcserver.c
@@ -6580,8 +6580,11 @@ RCreateServiceWOW64W(
 /* Function 46 */
 DWORD
 WINAPI
-RQueryServiceTagInfo(
-handle_t BindingHandle)  /* FIXME */
+RI_ScQueryServiceTagInfo(
+SC_RPC_HANDLE hSCManager,
+TAG_INFO_LEVEL dwInfoLevel,
+PTAG_INFO_NAME_FROM_TAG_IN_PARAMS * lpInParams,
+PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS * lpOutParams)
 {
 UNIMPLEMENTED;
 return ERROR_CALL_NOT_IMPLEMENTED;
diff --git a/sdk/include/reactos/idl/svcctl.idl 
b/sdk/include/reactos/idl/svcctl.idl
index 36234e74e1..c16efb623d 100644
--- a/sdk/include/reactos/idl/svcctl.idl
+++ b/sdk/include/reactos/idl/svcctl.idl
@@ -296,6 +296,30 @@ typedef struct _STRING_PTRSW {
 [string] LPWSTR StringPtr;
 } STRING_PTRSW, *PSTRING_PTRSW, *LPSTRING_PTRSW;
 
+typedef [v1_enum] enum _TAG_INFO_LEVEL {
+TagInfoLevelNameFromTag = 1,
+} TAG_INFO_LEVEL;
+
+typedef [v1_enum] enum _TAG_TYPE {
+TagTypeService = 1,
+} TAG_TYPE;
+
+typedef struct _TAG_INFO_NAME_FROM_TAG_IN_PARAMS {
+DWORD dwPid;
+DWORD dwTag;
+} TAG_INFO_NAME_FROM_TAG_IN_PARAMS, *PTAG_INFO_NAME_FROM_TAG_IN_PARAMS;
+
+typedef struct _TAG_INFO_NAME_FROM_TAG_OUT_PARAMS {
+TAG_TYPE TagType;
+LPWSTR pszName;
+} TAG_INFO_NAME_FROM_TAG_OUT_PARAMS, *PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS;
+
+typedef struct _TAG_INFO_NAME_FROM_TAG
+{
+TAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams;
+TAG_INFO_NAME_FROM_TAG_OUT_PARAMS OutParams;
+} TAG_INFO_NAME_FROM_TAG, *PTAG_INFO_NAME_FROM_TAG;
+
 [
   uuid(367abb81-9844-35f1-ad32-98f038001003),
   version(2.0),
@@ -798,8 +822,11 @@ interface svcctl
 /* Function 46 */
 DWORD
 __stdcall
-RQueryServiceTagInfo(
-[in] handle_t BindingHandle); /* FIXME */
+RI_ScQueryServiceTagInfo(
+[in] SC_RPC_HANDLE hSCManager,
+[in] TAG_INFO_LEVEL dwInfoLevel,
+[in] PTAG_INFO_NAME_FROM_TAG_IN_PARAMS * lpInParams,
+[out] PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS * lpOutParams);
 
 /* Function 47 */
 DWORD



[ros-diffs] [reactos] 05/06: [SERVICES] Implement ScmGetServiceNameFromTag

2018-12-30 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=519a2c9f6f763713b57a29c0fa311eca0c2fa250

commit 519a2c9f6f763713b57a29c0fa311eca0c2fa250
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 30 13:31:08 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Dec 30 14:27:04 2018 +0100

[SERVICES] Implement ScmGetServiceNameFromTag
---
 base/system/services/database.c | 78 +++--
 1 file changed, 76 insertions(+), 2 deletions(-)

diff --git a/base/system/services/database.c b/base/system/services/database.c
index fc4dd2f561..be6290bef6 100644
--- a/base/system/services/database.c
+++ b/base/system/services/database.c
@@ -148,8 +148,82 @@ ScmGetServiceImageByImagePath(LPWSTR lpImagePath)
 DWORD
 ScmGetServiceNameFromTag(PTAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams, 
PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS *OutParams)
 {
-UNIMPLEMENTED;
-return ERROR_CALL_NOT_IMPLEMENTED;
+PLIST_ENTRY ServiceEntry;
+PSERVICE CurrentService;
+PSERVICE_IMAGE CurrentImage;
+PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS OutBuffer = NULL;
+DWORD dwError;
+
+/* Lock the database */
+ScmLockDatabaseExclusive();
+
+/* Find the matching service */
+ServiceEntry = ServiceListHead.Flink;
+while (ServiceEntry != &ServiceListHead)
+{
+CurrentService = CONTAINING_RECORD(ServiceEntry,
+   SERVICE,
+   ServiceListEntry);
+
+/* We must match the tag */
+if (CurrentService->dwTag == InParams->dwTag &&
+CurrentService->lpImage != NULL)
+{
+CurrentImage = CurrentService->lpImage;
+/* And matching the PID */
+if (CurrentImage->hProcess == (HANDLE)InParams->dwPid)
+{
+break;
+}
+}
+
+ServiceEntry = ServiceEntry->Flink;
+}
+
+/* No match! */
+if (ServiceEntry == &ServiceListHead)
+{
+dwError = ERROR_RETRY;
+goto Cleanup;
+}
+
+/* Allocate the output buffer */
+OutBuffer = MIDL_user_allocate(sizeof(TAG_INFO_NAME_FROM_TAG_OUT_PARAMS));
+if (OutBuffer == NULL)
+{
+dwError = ERROR_NOT_ENOUGH_MEMORY;
+goto Cleanup;
+}
+
+/* And the buffer for the name */
+OutBuffer->pszName = 
MIDL_user_allocate(wcslen(CurrentService->lpServiceName) * sizeof(WCHAR) + 
sizeof(UNICODE_NULL));
+if (OutBuffer->pszName == NULL)
+{
+dwError = ERROR_NOT_ENOUGH_MEMORY;
+goto Cleanup;
+}
+
+/* Fill in output data */
+wcscpy(OutBuffer->pszName, CurrentService->lpServiceName);
+OutBuffer->TagType = TagTypeService;
+
+/* And return */
+*OutParams = OutBuffer;
+dwError = ERROR_SUCCESS;
+
+Cleanup:
+
+/* Unlock database */
+ScmUnlockDatabase();
+
+/* If failure, free allocated memory */
+if (dwError != ERROR_SUCCESS)
+{
+MIDL_user_free(OutBuffer);
+}
+
+/* Return error/success */
+return dwError;
 }
 
 



[ros-diffs] [reactos] 03/06: [ADVAPI32] Implement I_ScQueryServiceTagInfo

2018-12-30 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e29a99245b8bdd299202a165fa11e753274af285

commit e29a99245b8bdd299202a165fa11e753274af285
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 30 12:12:40 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Dec 30 14:27:03 2018 +0100

[ADVAPI32] Implement I_ScQueryServiceTagInfo
---
 dll/win32/advapi32/service/scm.c | 90 +++-
 1 file changed, 89 insertions(+), 1 deletion(-)

diff --git a/dll/win32/advapi32/service/scm.c b/dll/win32/advapi32/service/scm.c
index 08baad1cb9..0588caef19 100644
--- a/dll/win32/advapi32/service/scm.c
+++ b/dll/win32/advapi32/service/scm.c
@@ -5,6 +5,7 @@
  * PURPOSE: Service control manager functions
  * PROGRAMMER:  Emanuele Aliberti
  *  Eric Kohl
+ *  Pierre Schweitzer
  */
 
 /* INCLUDES **/
@@ -3027,7 +3028,94 @@ I_ScQueryServiceTagInfo(PVOID Unused,
 TAG_INFO_LEVEL dwInfoLevel,
 PTAG_INFO_NAME_FROM_TAG InOutParams)
 {
-return ERROR_CALL_NOT_IMPLEMENTED;
+SC_HANDLE hScm;
+DWORD dwError;
+PTAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams;
+PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS OutParams;
+LPWSTR lpszName;
+
+/* We only support one class */
+if (dwInfoLevel != TagInfoLevelNameFromTag)
+{
+return ERROR_RETRY;
+}
+
+/* Validate input structure */
+if (InOutParams->InParams.dwPid == 0 || InOutParams->InParams.dwTag == 0)
+{
+return ERROR_INVALID_PARAMETER;
+}
+
+/* Validate output structure */
+if (InOutParams->OutParams.pszName != NULL)
+{
+return ERROR_INVALID_PARAMETER;
+}
+
+/* Open service manager */
+hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE);
+if (hScm == NULL)
+{
+return GetLastError();
+}
+
+/* Setup call parameters */
+InParams = &InOutParams->InParams;
+OutParams = NULL;
+
+/* Call SCM to query tag information */
+RpcTryExcept
+{
+dwError = RI_ScQueryServiceTagInfo(hScm, TagInfoLevelNameFromTag, 
&InParams, &OutParams);
+}
+RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+{
+dwError = ScmRpcStatusToWinError(RpcExceptionCode());
+}
+RpcEndExcept;
+
+/* Quit if not a success */
+if (dwError != ERROR_SUCCESS)
+{
+goto Cleanup;
+}
+
+/* OutParams must be set now and we must have a name */
+if (OutParams == NULL ||
+OutParams->pszName == NULL)
+{
+dwError = ERROR_INVALID_DATA;
+goto Cleanup;
+}
+
+/* Copy back what SCM returned */
+lpszName = LocalAlloc(LPTR,
+  sizeof(WCHAR) * wcslen(OutParams->pszName) + 
sizeof(UNICODE_NULL));
+if (lpszName == NULL)
+{
+dwError = GetLastError();
+goto Cleanup;
+}
+
+wcscpy(lpszName, OutParams->pszName);
+InOutParams->OutParams.pszName = lpszName;
+InOutParams->OutParams.TagType = OutParams->TagType;
+
+Cleanup:
+CloseServiceHandle(hScm);
+
+/* Free memory allocated by SCM */
+if (OutParams != NULL)
+{
+if (OutParams->pszName != NULL)
+{
+midl_user_free(OutParams->pszName);
+}
+
+midl_user_free(OutParams);
+}
+
+return dwError;
 }
 
 /**



[ros-diffs] [reactos] 04/06: [SERVICES] Implement RI_ScQueryServiceTagInfo

2018-12-30 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=90f5e6b6c322aeb5ad7d47d29f2d6c55a961a36b

commit 90f5e6b6c322aeb5ad7d47d29f2d6c55a961a36b
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 30 12:25:18 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Dec 30 14:27:03 2018 +0100

[SERVICES] Implement RI_ScQueryServiceTagInfo
---
 base/system/services/database.c  |  8 
 base/system/services/rpcserver.c | 34 --
 base/system/services/services.h  |  2 ++
 3 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/base/system/services/database.c b/base/system/services/database.c
index ea91a5cb45..fc4dd2f561 100644
--- a/base/system/services/database.c
+++ b/base/system/services/database.c
@@ -145,6 +145,14 @@ ScmGetServiceImageByImagePath(LPWSTR lpImagePath)
 }
 
 
+DWORD
+ScmGetServiceNameFromTag(PTAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams, 
PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS *OutParams)
+{
+UNIMPLEMENTED;
+return ERROR_CALL_NOT_IMPLEMENTED;
+}
+
+
 static
 BOOL
 ScmIsSameServiceAccount(
diff --git a/base/system/services/rpcserver.c b/base/system/services/rpcserver.c
index 5b243f7f89..b11db5ae0e 100644
--- a/base/system/services/rpcserver.c
+++ b/base/system/services/rpcserver.c
@@ -6586,8 +6586,38 @@ RI_ScQueryServiceTagInfo(
 PTAG_INFO_NAME_FROM_TAG_IN_PARAMS * lpInParams,
 PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS * lpOutParams)
 {
-UNIMPLEMENTED;
-return ERROR_CALL_NOT_IMPLEMENTED;
+PMANAGER_HANDLE hManager;
+
+/* Validate handle */
+hManager = ScmGetServiceManagerFromHandle(hSCManager);
+if (hManager == NULL)
+{
+return ERROR_INVALID_HANDLE;
+}
+
+/* FIXME: should check whether client is local */
+
+/* Check access rights */
+if (!RtlAreAllAccessesGranted(hManager->Handle.DesiredAccess,
+  SC_MANAGER_ENUMERATE_SERVICE))
+{
+return ERROR_ACCESS_DENIED;
+}
+
+/* Check parameters */
+if (lpInParams == NULL || lpOutParams == NULL)
+{
+return ERROR_INVALID_PARAMETER;
+}
+
+/* Check info level */
+if (dwInfoLevel != TagInfoLevelNameFromTag)
+{
+return ERROR_RETRY;
+}
+
+/* Call internal helper */
+return ScmGetServiceNameFromTag(*lpInParams, lpOutParams);
 }
 
 
diff --git a/base/system/services/services.h b/base/system/services/services.h
index 74943372c6..4e6f1f1810 100644
--- a/base/system/services/services.h
+++ b/base/system/services/services.h
@@ -197,6 +197,8 @@ VOID ScmUnlockDatabase(VOID);
 VOID ScmInitNamedPipeCriticalSection(VOID);
 VOID ScmDeleteNamedPipeCriticalSection(VOID);
 
+DWORD ScmGetServiceNameFromTag(PTAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams,
+   PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS *OutParams);
 
 /* driver.c */
 



[ros-diffs] [reactos] 06/06: [SERVICES] Implement ScmGenerateServiceTag and call it on service creation

2018-12-30 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1a9b9800b1766b9301ea68d3dc5b882200c8f931

commit 1a9b9800b1766b9301ea68d3dc5b882200c8f931
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 30 14:09:54 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Dec 30 14:27:04 2018 +0100

[SERVICES] Implement ScmGenerateServiceTag and call it on service creation

This allows assigning an unique ServiceTag to each Win32 service
---
 base/system/services/database.c  | 26 ++
 base/system/services/rpcserver.c |  4 
 base/system/services/services.h  |  2 ++
 3 files changed, 32 insertions(+)

diff --git a/base/system/services/database.c b/base/system/services/database.c
index be6290bef6..26172a7a94 100644
--- a/base/system/services/database.c
+++ b/base/system/services/database.c
@@ -31,6 +31,7 @@ LIST_ENTRY ServiceListHead;
 static RTL_RESOURCE DatabaseLock;
 static DWORD ResumeCount = 1;
 static DWORD NoInteractiveServices = 0;
+static DWORD ServiceTag = 0;
 
 /* The critical section synchronizes service control requests */
 static CRITICAL_SECTION ControlServiceCriticalSection;
@@ -634,6 +635,29 @@ ScmGetServiceEntryByResumeCount(DWORD dwResumeCount)
 }
 
 
+DWORD
+ScmGenerateServiceTag(PSERVICE lpServiceRecord)
+{
+/* Check for an overflow */
+if (ServiceTag == -1)
+{
+return ERROR_INVALID_DATA;
+}
+
+/* This is only valid for Win32 services */
+if (!(lpServiceRecord->Status.dwServiceType & SERVICE_WIN32))
+{
+return ERROR_INVALID_PARAMETER;
+}
+
+/* Increment the tag counter and set it */
+ServiceTag = ServiceTag % 0x + 1;
+lpServiceRecord->dwTag = ServiceTag;
+
+return ERROR_SUCCESS;
+}
+
+
 DWORD
 ScmCreateNewServiceRecord(LPCWSTR lpServiceName,
   PSERVICE *lpServiceRecord,
@@ -847,6 +871,8 @@ CreateServiceListEntry(LPCWSTR lpServiceName,
 
 if (ScmIsDeleteFlagSet(hServiceKey))
 lpService->bDeleted = TRUE;
+else
+ScmGenerateServiceTag(lpService);
 
 if (lpService->Status.dwServiceType & SERVICE_WIN32)
 {
diff --git a/base/system/services/rpcserver.c b/base/system/services/rpcserver.c
index b11db5ae0e..83d83dd9c9 100644
--- a/base/system/services/rpcserver.c
+++ b/base/system/services/rpcserver.c
@@ -2636,6 +2636,10 @@ RCreateServiceW(
 goto done;
 
 lpService->dwRefCount = 1;
+
+/* Get the service tag (if Win32) */
+ScmGenerateServiceTag(lpService);
+
 DPRINT("CreateService - lpService->dwRefCount %u\n", 
lpService->dwRefCount);
 
 done:
diff --git a/base/system/services/services.h b/base/system/services/services.h
index 4e6f1f1810..9297c7ce99 100644
--- a/base/system/services/services.h
+++ b/base/system/services/services.h
@@ -200,6 +200,8 @@ VOID ScmDeleteNamedPipeCriticalSection(VOID);
 DWORD ScmGetServiceNameFromTag(PTAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams,
PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS *OutParams);
 
+DWORD ScmGenerateServiceTag(PSERVICE lpServiceRecord);
+
 /* driver.c */
 
 DWORD ScmStartDriver(PSERVICE lpService);



[ros-diffs] [reactos] 01/05: [SERVICES] On service start control message, send the service tag

2018-12-30 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2ee627ba635bd45f93da1f5967191c35c5e1646c

commit 2ee627ba635bd45f93da1f5967191c35c5e1646c
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 30 18:44:32 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Dec 30 21:44:25 2018 +0100

[SERVICES] On service start control message, send the service tag
---
 base/system/services/database.c | 1 +
 sdk/include/reactos/services/services.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/base/system/services/database.c b/base/system/services/database.c
index 26172a7a94..60e6d4bea1 100644
--- a/base/system/services/database.c
+++ b/base/system/services/database.c
@@ -1431,6 +1431,7 @@ ScmSendStartCommand(PSERVICE Service,
? SERVICE_CONTROL_START_OWN
: SERVICE_CONTROL_START_SHARE;
 ControlPacket->hServiceStatus = (SERVICE_STATUS_HANDLE)Service;
+ControlPacket->dwServiceTag = Service->dwTag;
 
 /* Copy the start command line */
 ControlPacket->dwServiceNameOffset = sizeof(SCM_CONTROL_PACKET);
diff --git a/sdk/include/reactos/services/services.h 
b/sdk/include/reactos/services/services.h
index b6f9d17fcc..fa8ebd2f64 100644
--- a/sdk/include/reactos/services/services.h
+++ b/sdk/include/reactos/services/services.h
@@ -30,6 +30,7 @@ typedef struct _SCM_CONTROL_PACKET
 DWORD dwSize;
 DWORD dwControl;
 DWORD dwArgumentsCount;
+DWORD dwServiceTag;
 SERVICE_STATUS_HANDLE hServiceStatus;
 DWORD dwServiceNameOffset;
 DWORD dwArgumentsOffset;



[ros-diffs] [reactos] 03/05: [ADVAPI32] When starting or sending a control to a service, set the tag in the TEB

2018-12-30 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=29b46995aa7f3c176e17dc6b25c852ed3a858060

commit 29b46995aa7f3c176e17dc6b25c852ed3a858060
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 30 20:45:11 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Dec 30 21:44:39 2018 +0100

[ADVAPI32] When starting or sending a control to a service, set the tag in 
the TEB

This now allows tracking the threads of the services thanks to their tag.

This fixes the failing test in advapi32:ServiceEnv
---
 dll/win32/advapi32/service/sctrl.c | 29 +
 1 file changed, 29 insertions(+)

diff --git a/dll/win32/advapi32/service/sctrl.c 
b/dll/win32/advapi32/service/sctrl.c
index f4a7aa85c4..ec5a4cc4bf 100644
--- a/dll/win32/advapi32/service/sctrl.c
+++ b/dll/win32/advapi32/service/sctrl.c
@@ -22,6 +22,7 @@ typedef struct _SERVICE_THREAD_PARAMSA
 LPSERVICE_MAIN_FUNCTIONA lpServiceMain;
 DWORD dwArgCount;
 LPSTR *lpArgVector;
+DWORD dwServiceTag;
 } SERVICE_THREAD_PARAMSA, *PSERVICE_THREAD_PARAMSA;
 
 
@@ -30,6 +31,7 @@ typedef struct _SERVICE_THREAD_PARAMSW
 LPSERVICE_MAIN_FUNCTIONW lpServiceMain;
 DWORD dwArgCount;
 LPWSTR *lpArgVector;
+DWORD dwServiceTag;
 } SERVICE_THREAD_PARAMSW, *PSERVICE_THREAD_PARAMSW;
 
 
@@ -47,6 +49,7 @@ typedef struct _ACTIVE_SERVICE
 LPVOID HandlerContext;
 BOOL bUnicode;
 BOOL bOwnProcess;
+DWORD dwServiceTag;
 } ACTIVE_SERVICE, *PACTIVE_SERVICE;
 
 
@@ -164,14 +167,22 @@ ScLookupServiceByServiceName(LPCWSTR lpServiceName)
 static DWORD WINAPI
 ScServiceMainStubA(LPVOID Context)
 {
+PTEB Teb;
 PSERVICE_THREAD_PARAMSA ThreadParams = Context;
 
 TRACE("ScServiceMainStubA(%p)\n", Context);
 
+/* Set service tag */
+Teb = NtCurrentTeb();
+Teb->SubProcessTag = (PVOID)ThreadParams->dwServiceTag;
+
 /* Call the main service routine and free the arguments vector */
 (ThreadParams->lpServiceMain)(ThreadParams->dwArgCount,
   ThreadParams->lpArgVector);
 
+/* Reset service tag */
+Teb->SubProcessTag = 0;
+
 if (ThreadParams->lpArgVector != NULL)
 {
 HeapFree(GetProcessHeap(), 0, ThreadParams->lpArgVector);
@@ -185,14 +196,22 @@ ScServiceMainStubA(LPVOID Context)
 static DWORD WINAPI
 ScServiceMainStubW(LPVOID Context)
 {
+PTEB Teb;
 PSERVICE_THREAD_PARAMSW ThreadParams = Context;
 
 TRACE("ScServiceMainStubW(%p)\n", Context);
 
+/* Set service tag */
+Teb = NtCurrentTeb();
+Teb->SubProcessTag = (PVOID)ThreadParams->dwServiceTag;
+
 /* Call the main service routine and free the arguments vector */
 (ThreadParams->lpServiceMain)(ThreadParams->dwArgCount,
   ThreadParams->lpArgVector);
 
+/* Reset service tag */
+Teb->SubProcessTag = 0;
+
 if (ThreadParams->lpArgVector != NULL)
 {
 HeapFree(GetProcessHeap(), 0, ThreadParams->lpArgVector);
@@ -440,6 +459,8 @@ ScStartService(PACTIVE_SERVICE lpService,
 
 /* Set the service status handle */
 lpService->hServiceStatus = ControlPacket->hServiceStatus;
+/* Set the service tag */
+lpService->dwServiceTag = ControlPacket->dwServiceTag;
 
 /* Build the arguments vector */
 if (lpService->bUnicode != FALSE)
@@ -456,6 +477,7 @@ ScStartService(PACTIVE_SERVICE lpService,
 return dwError;
 }
 ThreadParamsW->lpServiceMain = lpService->ServiceMain.W;
+ThreadParamsW->dwServiceTag = ControlPacket->dwServiceTag;
 ThreadHandle = CreateThread(NULL,
 0,
 ScServiceMainStubW,
@@ -489,6 +511,7 @@ ScStartService(PACTIVE_SERVICE lpService,
 return dwError;
 }
 ThreadParamsA->lpServiceMain = lpService->ServiceMain.A;
+ThreadParamsA->dwServiceTag = ControlPacket->dwServiceTag;
 ThreadHandle = CreateThread(NULL,
 0,
 ScServiceMainStubA,
@@ -528,6 +551,9 @@ ScControlService(PACTIVE_SERVICE lpService,
 TRACE("Size: %lu\n", ControlPacket->dwSize);
 TRACE("Service: %S\n", (PWSTR)((ULONG_PTR)ControlPacket + 
ControlPacket->dwServiceNameOffset));
 
+/* Set service tag */
+NtCurrentTeb()->SubProcessTag = (PVOID)lpService->dwServiceTag;
+
 if (lpService->HandlerFunction)
 {
 _SEH2_TRY
@@ -560,6 +586,9 @@ ScControlService(PACTIVE_SERVICE lpService,
 dwError = ERROR_SERVICE_CANNOT_ACCEPT_CTRL;
 }
 
+/* Reset service tag */
+NtCurrentTeb()->SubProcessTag = 0;
+
 TRACE("ScControlService() done (Error %lu)\n", dwError);
 
 return dwError;



[ros-diffs] [reactos] 05/05: [SERVICES] Properly check again PID

2018-12-30 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c10901966e233dbc3bcb25a33a8161a5c34009e9

commit c10901966e233dbc3bcb25a33a8161a5c34009e9
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 30 21:25:48 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Dec 30 21:44:40 2018 +0100

[SERVICES] Properly check again PID

This fixes services not being found.
With that commit and the previous one, I_QueryTagInformation is now fully
functionnal and properly returns service name for a specific tag
---
 base/system/services/database.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/base/system/services/database.c b/base/system/services/database.c
index 60e6d4bea1..11e0d0d676 100644
--- a/base/system/services/database.c
+++ b/base/system/services/database.c
@@ -147,7 +147,8 @@ ScmGetServiceImageByImagePath(LPWSTR lpImagePath)
 
 
 DWORD
-ScmGetServiceNameFromTag(PTAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams, 
PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS *OutParams)
+ScmGetServiceNameFromTag(IN PTAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams,
+ OUT PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS *OutParams)
 {
 PLIST_ENTRY ServiceEntry;
 PSERVICE CurrentService;
@@ -172,7 +173,7 @@ ScmGetServiceNameFromTag(PTAG_INFO_NAME_FROM_TAG_IN_PARAMS 
InParams, PTAG_INFO_N
 {
 CurrentImage = CurrentService->lpImage;
 /* And matching the PID */
-if (CurrentImage->hProcess == (HANDLE)InParams->dwPid)
+if (CurrentImage->dwProcessId == InParams->dwPid)
 {
 break;
 }
@@ -220,7 +221,10 @@ Cleanup:
 /* If failure, free allocated memory */
 if (dwError != ERROR_SUCCESS)
 {
-MIDL_user_free(OutBuffer);
+if (OutBuffer != NULL)
+{
+MIDL_user_free(OutBuffer);
+}
 }
 
 /* Return error/success */



[ros-diffs] [reactos] 04/05: [SERVICES] pszName is a string, mark it so

2018-12-30 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ebf8785661c87c8fe87c498b8497638b61044a60

commit ebf8785661c87c8fe87c498b8497638b61044a60
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 30 21:23:36 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Dec 30 21:44:39 2018 +0100

[SERVICES] pszName is a string, mark it so

This fixes returning string with RI_ScQueryServiceTagInfo
---
 sdk/include/reactos/idl/svcctl.idl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sdk/include/reactos/idl/svcctl.idl 
b/sdk/include/reactos/idl/svcctl.idl
index c16efb623d..fccb371289 100644
--- a/sdk/include/reactos/idl/svcctl.idl
+++ b/sdk/include/reactos/idl/svcctl.idl
@@ -311,7 +311,7 @@ typedef struct _TAG_INFO_NAME_FROM_TAG_IN_PARAMS {
 
 typedef struct _TAG_INFO_NAME_FROM_TAG_OUT_PARAMS {
 TAG_TYPE TagType;
-LPWSTR pszName;
+[string] LPWSTR pszName;
 } TAG_INFO_NAME_FROM_TAG_OUT_PARAMS, *PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS;
 
 typedef struct _TAG_INFO_NAME_FROM_TAG



[ros-diffs] [reactos] 02/05: [ADVAPI32] Stop pretending our advapi32 is NT6+

2018-12-30 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=446e13745c72d9874091b9a808f371cc737dc2bd

commit 446e13745c72d9874091b9a808f371cc737dc2bd
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 30 20:36:20 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Dec 30 21:44:39 2018 +0100

[ADVAPI32] Stop pretending our advapi32 is NT6+

This is wrong and messes up with internal structures (such as TEB).
For the two needed functions which are "NT6+", they were exported
with NT6, but already existed in W2K3 SP2.

This might fix random bugs

CORE-15526
---
 dll/win32/advapi32/CMakeLists.txt  | 3 ---
 dll/win32/advapi32/wine/security.c | 4 
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/dll/win32/advapi32/CMakeLists.txt 
b/dll/win32/advapi32/CMakeLists.txt
index ff7961c492..744dc098a1 100644
--- a/dll/win32/advapi32/CMakeLists.txt
+++ b/dll/win32/advapi32/CMakeLists.txt
@@ -2,9 +2,6 @@
 spec2def(advapi32.dll advapi32.spec ADD_IMPORTLIB)
 add_definitions(-D_ADVAPI32_)
 
-remove_definitions(-D_WIN32_WINNT=0x502)
-add_definitions(-D_WIN32_WINNT=0x600)
-
 include_directories(
 ${REACTOS_SOURCE_DIR}/sdk/include/reactos/idl
 ${REACTOS_SOURCE_DIR}/sdk/include/reactos/drivers/ksecdd
diff --git a/dll/win32/advapi32/wine/security.c 
b/dll/win32/advapi32/wine/security.c
index 54dd595d49..449cbd354b 100644
--- a/dll/win32/advapi32/wine/security.c
+++ b/dll/win32/advapi32/wine/security.c
@@ -17,6 +17,10 @@
 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
 
 static BOOL ParseStringSidToSid(LPCWSTR StringSid, PSID pSid, LPDWORD cBytes);
+#ifdef __REACTOS__
+VOID WINAPI QuerySecurityAccessMask(SECURITY_INFORMATION,LPDWORD);
+VOID WINAPI SetSecurityAccessMask(SECURITY_INFORMATION,LPDWORD);
+#endif
 
 typedef struct _ACEFLAG
 {



[ros-diffs] [reactos] 01/06: [ADVAPI32_APITEST] Add tests showing that first field of OwningModuleInfo is the tag

2018-12-31 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=abb6fd83a482deeb9eefa3b31bd52d45217ef66d

commit abb6fd83a482deeb9eefa3b31bd52d45217ef66d
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 30 22:36:54 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Dec 31 11:19:29 2018 +0100

[ADVAPI32_APITEST] Add tests showing that first field of OwningModuleInfo 
is the tag

Also, show that querying owner information about a connection owned by a 
service
returns the service name, and not the image nor its path.

Obviously, that fails in ReactOS.
---
 modules/rostests/apitests/advapi32/CMakeLists.txt  |   3 +-
 .../rostests/apitests/advapi32/ServiceNetwork.c| 449 +
 modules/rostests/apitests/advapi32/testlist.c  |   2 +
 3 files changed, 453 insertions(+), 1 deletion(-)

diff --git a/modules/rostests/apitests/advapi32/CMakeLists.txt 
b/modules/rostests/apitests/advapi32/CMakeLists.txt
index e34f682676..8d7e56084c 100644
--- a/modules/rostests/apitests/advapi32/CMakeLists.txt
+++ b/modules/rostests/apitests/advapi32/CMakeLists.txt
@@ -16,12 +16,13 @@ list(APPEND SOURCE
 SaferIdentifyLevel.c
 ServiceArgs.c
 ServiceEnv.c
+ServiceNetwork.c
 svchlp.c
 precomp.h)
 
 add_executable(advapi32_apitest ${SOURCE} testlist.c)
 target_link_libraries(advapi32_apitest wine ${PSEH_LIB})
 set_module_type(advapi32_apitest win32cui)
-add_importlibs(advapi32_apitest advapi32 msvcrt kernel32 ntdll)
+add_importlibs(advapi32_apitest advapi32 iphlpapi ws2_32 msvcrt kernel32 ntdll)
 add_pch(advapi32_apitest precomp.h SOURCE)
 add_rostests_file(TARGET advapi32_apitest)
diff --git a/modules/rostests/apitests/advapi32/ServiceNetwork.c 
b/modules/rostests/apitests/advapi32/ServiceNetwork.c
new file mode 100644
index 00..6b5a5676ac
--- /dev/null
+++ b/modules/rostests/apitests/advapi32/ServiceNetwork.c
@@ -0,0 +1,449 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPLv2+ - See COPYING in the top level directory
+ * PURPOSE: Test for service networking
+ * PROGRAMMER:  Pierre Schweitzer
+ */
+
+#include "precomp.h"
+
+#include "svchlp.h"
+
+#define WIN32_NO_STATUS
+#include 
+#include 
+
+/*** Service part of the test ***/
+
+static SERVICE_STATUS_HANDLE status_handle;
+
+static void
+report_service_status(DWORD dwCurrentState,
+  DWORD dwWin32ExitCode,
+  DWORD dwWaitHint)
+{
+BOOL res;
+SERVICE_STATUS status;
+
+status.dwServiceType   = SERVICE_WIN32_OWN_PROCESS;
+status.dwCurrentState  = dwCurrentState;
+status.dwWin32ExitCode = dwWin32ExitCode;
+status.dwWaitHint  = dwWaitHint;
+
+status.dwServiceSpecificExitCode = 0;
+status.dwCheckPoint  = 0;
+
+if ( (dwCurrentState == SERVICE_START_PENDING) ||
+ (dwCurrentState == SERVICE_STOP_PENDING)  ||
+ (dwCurrentState == SERVICE_STOPPED) )
+{
+status.dwControlsAccepted = 0;
+}
+else
+{
+status.dwControlsAccepted = SERVICE_ACCEPT_STOP | 
SERVICE_ACCEPT_SHUTDOWN;
+}
+
+#if 0
+if ( (dwCurrentState == SERVICE_RUNNING) || (dwCurrentState == 
SERVICE_STOPPED) )
+status.dwCheckPoint = 0;
+else
+status.dwCheckPoint = dwCheckPoint++;
+#endif
+
+res = SetServiceStatus(status_handle, &status);
+service_ok(res, "SetServiceStatus(%d) failed: %lu\n", dwCurrentState, 
GetLastError());
+}
+
+static VOID WINAPI service_handler(DWORD ctrl)
+{
+switch(ctrl)
+{
+case SERVICE_CONTROL_STOP:
+case SERVICE_CONTROL_SHUTDOWN:
+report_service_status(SERVICE_STOP_PENDING, NO_ERROR, 0);
+default:
+report_service_status(SERVICE_RUNNING, NO_ERROR, 0);
+}
+}
+
+static DWORD GetExtendedTcpTableWithAlloc(PVOID *TcpTable, BOOL Order, DWORD 
Family, TCP_TABLE_CLASS Class)
+{
+DWORD ret;
+DWORD Size = 0;
+
+*TcpTable = NULL;
+
+ret = GetExtendedTcpTable(*TcpTable, &Size, Order, Family, Class, 0);
+if (ret == ERROR_INSUFFICIENT_BUFFER)
+{
+*TcpTable = HeapAlloc(GetProcessHeap(), 0, Size);
+if (*TcpTable == NULL)
+{
+return ERROR_OUTOFMEMORY;
+}
+
+ret = GetExtendedTcpTable(*TcpTable, &Size, Order, Family, Class, 0);
+if (ret != NO_ERROR)
+{
+HeapFree(GetProcessHeap(), 0, *TcpTable);
+*TcpTable = NULL;
+}
+}
+
+return ret;
+}
+
+static DWORD GetExtendedUdpTableWithAlloc(PVOID *UdpTable, BOOL Order, DWORD 
Family, UDP_TABLE_CLASS Class)
+{
+DWORD ret;
+DWORD Size = 0;
+
+*UdpTable = NULL;
+
+ret = GetExtendedUdpTable(*UdpTable, &Size, Order, Family, Class, 0);
+if (ret == ERROR_INSUFFICIENT_BUFFER)
+{
+*UdpTable = HeapAlloc(GetProcessHeap(), 0, Size);
+if (*UdpTable == NULL)
+{
+return ERROR_OUTOFMEMORY;
+}
+
+ret = GetExtendedUdpTable(*UdpTable, &am

[ros-diffs] [reactos] 03/06: [TCPIP] Save the SubProcessTag when an ADDRESS_FILE is created

2018-12-31 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d98001de17b9988296e56c223b0344d58686912e

commit d98001de17b9988296e56c223b0344d58686912e
Author: Pierre Schweitzer 
AuthorDate: Mon Dec 31 10:21:14 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Dec 31 11:19:35 2018 +0100

[TCPIP] Save the SubProcessTag when an ADDRESS_FILE is created
---
 drivers/network/tcpip/include/titypes.h | 1 +
 drivers/network/tcpip/tcpip/fileobjs.c  | 5 +
 2 files changed, 6 insertions(+)

diff --git a/drivers/network/tcpip/include/titypes.h 
b/drivers/network/tcpip/include/titypes.h
index e63fad2821..3f75976b4e 100644
--- a/drivers/network/tcpip/include/titypes.h
+++ b/drivers/network/tcpip/include/titypes.h
@@ -155,6 +155,7 @@ typedef struct _ADDRESS_FILE {
 IP_ADDRESS AddrCache; /* One entry address cache 
(destination
  address of last packet 
transmitted) */
 HANDLE ProcessId; /* Creator process ID */
+PVOID SubProcessTag;  /* Creator process tag */
 LARGE_INTEGER CreationTime;   /* Time of creation */
 
 /* The following members are used to control event notification */
diff --git a/drivers/network/tcpip/tcpip/fileobjs.c 
b/drivers/network/tcpip/tcpip/fileobjs.c
index 30a3939e2b..400f956034 100644
--- a/drivers/network/tcpip/tcpip/fileobjs.c
+++ b/drivers/network/tcpip/tcpip/fileobjs.c
@@ -10,6 +10,10 @@
 
 #include "precomp.h"
 
+/* FIXME: including pstypes.h without ntifs fails */
+#include 
+#include 
+
 /* Uncomment for logging of connections and address files every 10 seconds */
 //#define LOG_OBJECTS
 
@@ -425,6 +429,7 @@ NTSTATUS FileOpenAddress(
   AddrFile->BCast = 1;
   AddrFile->HeaderIncl = 1;
   AddrFile->ProcessId = PsGetCurrentProcessId();
+  AddrFile->SubProcessTag = ((PTEB)PsGetCurrentThreadTeb())->SubProcessTag;
   KeQuerySystemTime(&AddrFile->CreationTime);
 
   /* Make sure address is a local unicast address or 0 */



[ros-diffs] [reactos] 04/06: [TCPIP] Return the SubProcessTag when enumerating connections with owner class

2018-12-31 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=96985e0746fef1fffe45ad8274a4533eb0aea14c

commit 96985e0746fef1fffe45ad8274a4533eb0aea14c
Author: Pierre Schweitzer 
AuthorDate: Mon Dec 31 10:35:40 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Dec 31 11:19:36 2018 +0100

[TCPIP] Return the SubProcessTag when enumerating connections with owner 
class
---
 drivers/network/tcpip/tcpip/ninfo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/network/tcpip/tcpip/ninfo.c 
b/drivers/network/tcpip/tcpip/ninfo.c
index 8ad01fb413..cb88a2110d 100644
--- a/drivers/network/tcpip/tcpip/ninfo.c
+++ b/drivers/network/tcpip/tcpip/ninfo.c
@@ -251,8 +251,8 @@ TDI_STATUS InfoTdiQueryGetConnectionTcpTable(PADDRESS_FILE 
AddrFile,
 {
 if (Class == TcpUdpClassOwner)
 {
-/* FIXME */
 RtlZeroMemory(&TcpRow.OwningModuleInfo[0], 
sizeof(TcpRow.OwningModuleInfo));
+TcpRow.OwningModuleInfo[0] = (ULONG_PTR)AddrFile->SubProcessTag;
 }
 
 Status = InfoCopyOut( (PCHAR)&TcpRow, Size,
@@ -295,8 +295,8 @@ TDI_STATUS InfoTdiQueryGetConnectionUdpTable(PADDRESS_FILE 
AddrFile,
 UdpRow.dwFlags = 0; /* FIXME */
 if (Class == TcpUdpClassOwner)
 {
-/* FIXME */
 RtlZeroMemory(&UdpRow.OwningModuleInfo[0], 
sizeof(UdpRow.OwningModuleInfo));
+UdpRow.OwningModuleInfo[0] = (ULONG_PTR)AddrFile->SubProcessTag;
 }
 
 Status = InfoCopyOut( (PCHAR)&UdpRow,



[ros-diffs] [reactos] 02/06: [SDK] Add PsGetCurrentThreadTeb() to the DDK

2018-12-31 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1a93d83f925f700c4a436edca476def1937fd843

commit 1a93d83f925f700c4a436edca476def1937fd843
Author: Pierre Schweitzer 
AuthorDate: Sun Dec 30 22:47:36 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Dec 31 11:19:35 2018 +0100

[SDK] Add PsGetCurrentThreadTeb() to the DDK
---
 ntoskrnl/ps/thread.c  | 2 +-
 sdk/include/xdk/psfuncs.h | 8 
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/ntoskrnl/ps/thread.c b/ntoskrnl/ps/thread.c
index 8b0099823b..8045dfba70 100644
--- a/ntoskrnl/ps/thread.c
+++ b/ntoskrnl/ps/thread.c
@@ -780,7 +780,7 @@ PsGetThreadTeb(IN PETHREAD Thread)
 /*
  * @implemented
  */
-PTEB
+PVOID
 NTAPI
 PsGetCurrentThreadTeb(VOID)
 {
diff --git a/sdk/include/xdk/psfuncs.h b/sdk/include/xdk/psfuncs.h
index fabf9e2324..b59dee4c96 100644
--- a/sdk/include/xdk/psfuncs.h
+++ b/sdk/include/xdk/psfuncs.h
@@ -327,6 +327,14 @@ PsGetThreadProcessId(
   IN PETHREAD Thread);
 #endif /* (NTDDI_VERSION >= NTDDI_WS03) */
 
+#if (NTDDI_VERSION >= NTDDI_WS03SP1)
+NTKERNELAPI
+PVOID
+NTAPI
+PsGetCurrentThreadTeb(
+  VOID);
+#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
+
 #if (NTDDI_VERSION >= NTDDI_VISTA)
 
 NTKERNELAPI



[ros-diffs] [reactos] 05/06: [IPHLPAPI] Add support for service tags in GetOwnerModuleFromTcp/UdpEntry

2018-12-31 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=aa55bb1bd38607ce2e2fa1759e502fd42a8fdb55

commit aa55bb1bd38607ce2e2fa1759e502fd42a8fdb55
Author: Pierre Schweitzer 
AuthorDate: Mon Dec 31 11:08:28 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Dec 31 11:19:36 2018 +0100

[IPHLPAPI] Add support for service tags in GetOwnerModuleFromTcp/UdpEntry

If a service tag is set in owner information, then, we'll query advapi32 and
thus services to get the service name instead of the image name
---
 dll/win32/iphlpapi/iphlpapi_main.c | 98 +-
 1 file changed, 96 insertions(+), 2 deletions(-)

diff --git a/dll/win32/iphlpapi/iphlpapi_main.c 
b/dll/win32/iphlpapi/iphlpapi_main.c
index 162731c420..83d53d2b10 100644
--- a/dll/win32/iphlpapi/iphlpapi_main.c
+++ b/dll/win32/iphlpapi/iphlpapi_main.c
@@ -2347,6 +2347,84 @@ static DWORD GetOwnerModuleFromPidEntry(DWORD OwningPid, 
TCPIP_OWNER_MODULE_INFO
 return NO_ERROR;
 }
 
+static DWORD GetOwnerModuleFromTagEntry(DWORD OwningPid, DWORD OwningTag, 
TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
+{
+UINT Size;
+HRESULT Res;
+HANDLE hAdvapi32;
+WCHAR SysDir[MAX_PATH];
+PTCPIP_OWNER_MODULE_BASIC_INFO BasicInfo;
+ULONG (NTAPI *_I_QueryTagInformation)(PVOID, DWORD, PVOID);
+struct
+{
+DWORD ProcessId;
+DWORD ServiceTag;
+DWORD TagType;
+PWSTR Buffer;
+} ServiceQuery;
+
+/* First, secure (avoid injections) load advapi32.dll */
+Size = GetSystemDirectoryW(SysDir, MAX_PATH);
+if (Size == 0)
+{
+return GetLastError();
+}
+
+Res = StringCchCatW(&SysDir[Size], MAX_PATH - Size, L"\\advapi32.dll");
+if (FAILED(Res))
+{
+return Res;
+}
+
+hAdvapi32 = GetModuleHandleW(SysDir);
+if (hAdvapi32 == NULL)
+{
+return GetLastError();
+}
+
+/* Now, we'll query the service associated with the tag */
+_I_QueryTagInformation = (PVOID)GetProcAddress(hAdvapi32, 
"I_QueryTagInformation");
+if (_I_QueryTagInformation == NULL)
+{
+return GetLastError();
+}
+
+/* Set tag and PID for the query */
+ServiceQuery.ProcessId = OwningPid;
+ServiceQuery.ServiceTag = OwningTag;
+ServiceQuery.TagType = 0;
+ServiceQuery.Buffer = NULL;
+
+/* And query */
+Res = _I_QueryTagInformation(NULL, 1, &ServiceQuery);
+if (Res != ERROR_SUCCESS)
+{
+return Res;
+}
+
+/* Compute service name length */
+Size = wcslen(ServiceQuery.Buffer) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
+
+/* We'll copy it twice, so make sure we have enough room */
+if (*pdwSize < sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + 2 * Size)
+{
+*pdwSize = sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + 2 * Size;
+LocalFree(ServiceQuery.Buffer);
+return ERROR_INSUFFICIENT_BUFFER;
+}
+
+/* Copy back data */
+BasicInfo = Buffer;
+BasicInfo->pModuleName = (PVOID)((ULONG_PTR)BasicInfo + 
sizeof(TCPIP_OWNER_MODULE_BASIC_INFO));
+BasicInfo->pModulePath = (PVOID)((ULONG_PTR)BasicInfo->pModuleName + Size);
+wcscpy(BasicInfo->pModuleName, ServiceQuery.Buffer);
+wcscpy(BasicInfo->pModulePath, ServiceQuery.Buffer);
+*pdwSize = sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + 2 * Size;
+LocalFree(ServiceQuery.Buffer);
+
+return NO_ERROR;
+}
+
 /**
  *GetOwnerModuleFromTcpEntry (IPHLPAPI.@)
  *
@@ -2368,7 +2446,15 @@ static DWORD GetOwnerModuleFromPidEntry(DWORD OwningPid, 
TCPIP_OWNER_MODULE_INFO
  */
 DWORD WINAPI GetOwnerModuleFromTcpEntry( PMIB_TCPROW_OWNER_MODULE pTcpEntry, 
TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
 {
-return GetOwnerModuleFromPidEntry(pTcpEntry->dwOwningPid, Class, Buffer, 
pdwSize);
+/* If we have a service tag, that's a service connection */
+if (pTcpEntry->OwningModuleInfo[0] != 0)
+{
+return GetOwnerModuleFromTagEntry(pTcpEntry->dwOwningPid, 
(DWORD)(pTcpEntry->OwningModuleInfo[0]), Class, Buffer, pdwSize);
+}
+else
+{
+return GetOwnerModuleFromPidEntry(pTcpEntry->dwOwningPid, Class, 
Buffer, pdwSize);
+}
 }
 
 /**
@@ -2392,7 +2478,15 @@ DWORD WINAPI GetOwnerModuleFromTcpEntry( 
PMIB_TCPROW_OWNER_MODULE pTcpEntry, TCP
  */
 DWORD WINAPI GetOwnerModuleFromUdpEntry( PMIB_UDPROW_OWNER_MODULE pUdpEntry, 
TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
 {
-return GetOwnerModuleFromPidEntry(pUdpEntry->dwOwningPid, Class, Buffer, 
pdwSize);
+/* If we have a service tag, that's a service connection */
+if (pUdpEntry->OwningModuleInfo[0] != 0)
+{
+return GetOwnerModuleFromTagEntry(pUdpEntry->dwOwningPid, 
(DWORD)(pUdpEntry->OwningModuleInf

[ros-diffs] [reactos] 01/01: [TCPIP] Don't assume the TEB is always defined

2018-12-31 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=89a4cde14a5ac1d3363a8efbca9c26c9f93f037a

commit 89a4cde14a5ac1d3363a8efbca9c26c9f93f037a
Author: Pierre Schweitzer 
AuthorDate: Mon Dec 31 13:59:58 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Dec 31 14:00:34 2018 +0100

[TCPIP] Don't assume the TEB is always defined

Fixes the crash in kmtest:TcpIpConnect test.
---
 drivers/network/tcpip/tcpip/fileobjs.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/network/tcpip/tcpip/fileobjs.c 
b/drivers/network/tcpip/tcpip/fileobjs.c
index 400f956034..f050a09b0c 100644
--- a/drivers/network/tcpip/tcpip/fileobjs.c
+++ b/drivers/network/tcpip/tcpip/fileobjs.c
@@ -396,6 +396,7 @@ NTSTATUS FileOpenAddress(
   PVOID Options)
 {
   PADDRESS_FILE AddrFile;
+  PTEB Teb;
 
   TI_DbgPrint(MID_TRACE, ("Called (Proto %d).\n", Protocol));
 
@@ -429,7 +430,12 @@ NTSTATUS FileOpenAddress(
   AddrFile->BCast = 1;
   AddrFile->HeaderIncl = 1;
   AddrFile->ProcessId = PsGetCurrentProcessId();
-  AddrFile->SubProcessTag = ((PTEB)PsGetCurrentThreadTeb())->SubProcessTag;
+
+  Teb = PsGetCurrentThreadTeb();
+  if (Teb != NULL) {
+AddrFile->SubProcessTag = Teb->SubProcessTag;
+  }
+
   KeQuerySystemTime(&AddrFile->CreationTime);
 
   /* Make sure address is a local unicast address or 0 */



[ros-diffs] [reactos] 01/01: [WIN32K] Deny deviceless calls to EngDeviceIoControl

2018-12-31 Thread Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=01b580d8760be6870964ecd7b18ae2fab5fa250f

commit 01b580d8760be6870964ecd7b18ae2fab5fa250f
Author: Pierre Schweitzer 
AuthorDate: Mon Dec 31 20:33:59 2018 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Dec 31 20:35:17 2018 +0100

[WIN32K] Deny deviceless calls to EngDeviceIoControl

This fixes BSOD happening in ntoskrnl coming from win32k under certain
conditions with 3rd party display drivers (such as VBox or VMware)
---
 win32ss/gdi/eng/device.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/win32ss/gdi/eng/device.c b/win32ss/gdi/eng/device.c
index 0123a2713c..6d20e30de5 100644
--- a/win32ss/gdi/eng/device.c
+++ b/win32ss/gdi/eng/device.c
@@ -485,6 +485,11 @@ EngDeviceIoControl(
 
 TRACE("EngDeviceIoControl() called\n");
 
+if (!hDevice)
+{
+return ERROR_INVALID_HANDLE;
+}
+
 KeInitializeEvent(&Event, SynchronizationEvent, FALSE);
 
 DeviceObject = (PDEVICE_OBJECT) hDevice;



[ros-diffs] [reactos] 01/01: [SETUP] Silence some noisy DPRINT1

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

commit 0150bb964a411474d6cbd60ee45421bb6281deae
Author: Pierre Schweitzer 
AuthorDate: Tue Jan 1 09:57:26 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Tue Jan 1 10:08:02 2019 +0100

[SETUP] Silence some noisy DPRINT1
---
 base/setup/lib/registry.c   | 5 -
 base/setup/lib/settings.c   | 4 ++--
 base/setup/lib/utils/inicache.c | 4 ++--
 base/setup/lib/utils/partlist.c | 6 +++---
 4 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/base/setup/lib/registry.c b/base/setup/lib/registry.c
index bc97489da0..6c02869a28 100644
--- a/base/setup/lib/registry.c
+++ b/base/setup/lib/registry.c
@@ -1048,7 +1048,10 @@ RegCleanupRegistry(
 Status = DisconnectRegistry(NULL,
 RegistryHives[i].HiveRegistryPath,
 1 /* REG_FORCE_UNLOAD */);
-DPRINT1("Unmounting '%S' %s\n", RegistryHives[i].HiveRegistryPath, 
NT_SUCCESS(Status) ? "succeeded" : "failed");
+if (!NT_SUCCESS(Status))
+{
+DPRINT1("Unmounting '%S' failed\n", 
RegistryHives[i].HiveRegistryPath);
+}
 
 /* Switch the hive state to 'Update' */
 RegistryHives[i].State = Update;
diff --git a/base/setup/lib/settings.c b/base/setup/lib/settings.c
index 20a6bd4b8d..2d1c4e1c34 100644
--- a/base/setup/lib/settings.c
+++ b/base/setup/lib/settings.c
@@ -809,7 +809,7 @@ ProcessDisplayRegistry(
 }
 
 ASSERT(wcslen(ServiceName) < 10);
-DPRINT1("Service name: '%S'\n", ServiceName);
+DPRINT("Service name: '%S'\n", ServiceName);
 
 RtlStringCchPrintfW(RegPath, ARRAYSIZE(RegPath),
 L"System\\CurrentControlSet\\Services\\%s",
@@ -853,7 +853,7 @@ ProcessDisplayRegistry(
 RtlStringCchPrintfW(RegPath, ARRAYSIZE(RegPath),
 L"System\\CurrentControlSet\\Hardware 
Profiles\\Current\\System\\CurrentControlSet\\Services\\%s\\Device0",
 ServiceName);
-DPRINT1("RegPath: '%S'\n", RegPath);
+DPRINT("RegPath: '%S'\n", RegPath);
 RtlInitUnicodeString(&KeyName, RegPath);
 InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
diff --git a/base/setup/lib/utils/inicache.c b/base/setup/lib/utils/inicache.c
index e6b2895ab0..c38b618dcf 100644
--- a/base/setup/lib/utils/inicache.c
+++ b/base/setup/lib/utils/inicache.c
@@ -497,7 +497,7 @@ IniCacheLoadFromMemory(
  &SectionName,
  &SectionNameSize);
 
-DPRINT1("[%.*s]\n", SectionNameSize, SectionName);
+DPRINT("[%.*s]\n", SectionNameSize, SectionName);
 
 Section = IniCacheAddSection(*Cache,
  SectionName,
@@ -526,7 +526,7 @@ IniCacheLoadFromMemory(
   &KeyValueSize,
   String);
 
-DPRINT1("'%.*s' = '%.*s'\n", KeyNameSize, KeyName, KeyValueSize, 
KeyValue);
+DPRINT("'%.*s' = '%.*s'\n", KeyNameSize, KeyName, KeyValueSize, 
KeyValue);
 
 Key = IniCacheAddKey(Section,
  KeyName,
diff --git a/base/setup/lib/utils/partlist.c b/base/setup/lib/utils/partlist.c
index 83ad8e0317..aee3c3c161 100644
--- a/base/setup/lib/utils/partlist.c
+++ b/base/setup/lib/utils/partlist.c
@@ -3032,7 +3032,7 @@ CheckActiveSystemPartition(
 return;
 }
 
-DPRINT1("We are here (1)!\n");
+DPRINT("We are here (1)!\n");
 
 List->SystemPartition = NULL;
 List->OriginalSystemPartition = NULL;
@@ -3070,7 +3070,7 @@ CheckActiveSystemPartition(
 DPRINT1("NewDisk TRUE but first partition is used?\n");
 }
 
-DPRINT1("We are here (2)!\n");
+DPRINT("We are here (2)!\n");
 
 /*
  * The disk is not new, check if any partition is initialized;
@@ -3111,7 +3111,7 @@ CheckActiveSystemPartition(
 List->SystemPartition = NULL;
 List->OriginalSystemPartition = NULL;
 
-DPRINT1("We are here (3)!\n");
+DPRINT("We are here (3)!\n");
 
 /* The disk is not new, scan all partitions to find the (active) system 
partition */
 for (ListEntry = DiskEntry->PrimaryPartListHead.Flink;



[ros-diffs] [reactos] 01/01: [TCPIP] Check buffer before dereferencing it

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

commit f76a097a252b52154bdc0818a897200e99e2bc29
Author: Pierre Schweitzer 
AuthorDate: Tue Jan 1 10:45:48 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Tue Jan 1 10:45:48 2019 +0100

[TCPIP] Check buffer before dereferencing it

CID 716664
---
 drivers/network/tcpip/tcpip/ninfo.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/network/tcpip/tcpip/ninfo.c 
b/drivers/network/tcpip/tcpip/ninfo.c
index cb88a2110d..5c0952b033 100644
--- a/drivers/network/tcpip/tcpip/ninfo.c
+++ b/drivers/network/tcpip/tcpip/ninfo.c
@@ -312,13 +312,13 @@ TDI_STATUS InfoTdiSetRoute(PIP_INTERFACE IF, PVOID 
Buffer, UINT BufferSize)
 IP_ADDRESS Address, Netmask, Router;
 PIPROUTE_ENTRY Route = Buffer;
 
+if (!Buffer || BufferSize < sizeof(IPROUTE_ENTRY))
+return TDI_INVALID_PARAMETER;
+
 AddrInitIPv4( &Address, Route->Dest );
 AddrInitIPv4( &Netmask, Route->Mask );
 AddrInitIPv4( &Router,  Route->Gw );
 
-if (!Buffer || BufferSize < sizeof(IPROUTE_ENTRY))
-return TDI_INVALID_PARAMETER;
-
 if (IF == Loopback)
 {
 DbgPrint("Failing attempt to add route to loopback adapter\n");



[ros-diffs] [reactos] 01/01: [NTOSKRNL] Add a raw implementation of !irpfind in kdbg

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

commit d6dc1fd2310ed67891edc27a49aacc2eb11220f3
Author: Pierre Schweitzer 
AuthorDate: Tue Jan 1 21:58:18 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Tue Jan 1 22:00:56 2019 +0100

[NTOSKRNL] Add a raw implementation of !irpfind in kdbg

This is far from perfect, and totally doesn't match the
WinDBG way of doing it. Instead of browsing pool to find
matching 'IRP' tags, we just browse all the processes
to find the queued IRP. This requires the IRPs to be queued,
obviously, and will make us miss the leaked IRPs, for instance.

Proper way to do it would be to implement !poolfind and then
rely on its implementation to find our IRPs.

Perhaps later ;-)
---
 ntoskrnl/kdbg/kdb_cli.c |   3 ++
 ntoskrnl/ps/process.c   | 115 
 2 files changed, 118 insertions(+)

diff --git a/ntoskrnl/kdbg/kdb_cli.c b/ntoskrnl/kdbg/kdb_cli.c
index 3fce1977d9..37ad987b79 100644
--- a/ntoskrnl/kdbg/kdb_cli.c
+++ b/ntoskrnl/kdbg/kdb_cli.c
@@ -96,6 +96,8 @@ BOOLEAN ExpKdbgExtPoolUsed(ULONG Argc, PCHAR Argv[]);
 BOOLEAN ExpKdbgExtFileCache(ULONG Argc, PCHAR Argv[]);
 BOOLEAN ExpKdbgExtDefWrites(ULONG Argc, PCHAR Argv[]);
 
+BOOLEAN PspKdbgIrpFind(ULONG Argc, PCHAR Argv[]);
+
 #ifdef __ROS_DWARF__
 static BOOLEAN KdbpCmdPrintStruct(ULONG Argc, PCHAR Argv[]);
 #endif
@@ -190,6 +192,7 @@ static const struct
 { "!poolused", "!poolused [Flags [Tag]]", "Display pool usage.", 
ExpKdbgExtPoolUsed },
 { "!filecache", "!filecache", "Display cache usage.", ExpKdbgExtFileCache 
},
 { "!defwrites", "!defwrites", "Display cache write values.", 
ExpKdbgExtDefWrites },
+{ "!irpfind", "!irpfind [criteria data]", "Lists IRPs potentially matching 
criteria", PspKdbgIrpFind },
 };
 
 /* FUNCTIONS */
diff --git a/ntoskrnl/ps/process.c b/ntoskrnl/ps/process.c
index c6962762e3..3554d601c1 100644
--- a/ntoskrnl/ps/process.c
+++ b/ntoskrnl/ps/process.c
@@ -1614,4 +1614,119 @@ NtOpenProcess(OUT PHANDLE ProcessHandle,
 /* Return status */
 return Status;
 }
+
+#if DBG && defined(KDBG)
+BOOLEAN
+PspKdbgIrpFind(
+ULONG Argc,
+PCHAR Argv[])
+{
+PLIST_ENTRY PsEntry, TdEntry, IrpEntry;
+PEPROCESS Process = NULL;
+PETHREAD Thread = NULL;
+PIRP Irp = NULL;
+PIO_STACK_LOCATION IoStack = NULL;
+PUNICODE_STRING DriverName;
+ULONG_PTR SData = 0;
+ULONG Criteria = 0;
+
+/*
+ * FIXME: To improve, badly
+ * This should just be a wrapper over !poolfind
+ * As a hack, here we just browse all the queued IRPs
+ * and return them
+ * If that's not *that* wrong, it makes sure that leaked
+ * IRPs are invisible!
+ * We also don't care about pool type, nor address start
+ */
+
+/* Gets the criteria and its data */
+if (Argc > 2)
+{
+if (!KdbpGetHexNumber(Argv[2], &SData))
+{
+SData = 0;
+}
+else
+{
+if (strcmp(Argv[1], "device") == 0)
+{
+Criteria = 0x1;
+}
+else if (strcmp(Argv[1], "fileobject") == 0)
+{
+Criteria = 0x2;
+}
+else if (strcmp(Argv[1], "mdlprocess") == 0)
+{
+Criteria = 0x4;
+}
+else if (strcmp(Argv[1], "thread") == 0)
+{
+Criteria = 0x8;
+}
+else if (strcmp(Argv[1], "userevent") == 0)
+{
+Criteria = 0x10;
+}
+else if (strcmp(Argv[1], "arg") == 0)
+{
+Criteria = 0x1f;
+}
+}
+}
+
+PsEntry = PsActiveProcessHead.Flink;
+/* Loop the process list */
+while (PsEntry != &PsActiveProcessHead)
+{
+/* Get the process */
+Process = CONTAINING_RECORD(PsEntry, EPROCESS, ActiveProcessLinks);
+
+/* Loop the thread list */
+TdEntry = Process->ThreadListHead.Flink;
+while (TdEntry != &Process->ThreadListHead)
+{
+/* Get the thread */
+Thread = CONTAINING_RECORD(TdEntry, ETHREAD, ThreadListEntry);
+
+/* Loop the IRP list */
+IrpEntry = Thread->IrpList.Flink;
+while (IrpEntry != &Thread->IrpList)
+{
+/* Get the IRP and its current stack */
+Irp = CONTAINING_RECORD(IrpEntry, IRP, ThreadListEntry);
+IoStack = IoGetCurrentIrpStackLocation(Irp);
+
+/* Get associated driver */
+if (IoStack->

[ros-diffs] [reactos] 01/01: [RDBSS][RXCE] Implement IRP cancellation

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

commit a9124b412d39ac57e09bcb915064db0ec1265d1b
Author: Pierre Schweitzer 
AuthorDate: Wed Jan 2 15:01:38 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Wed Jan 2 15:02:15 2019 +0100

[RDBSS][RXCE] Implement IRP cancellation

CORE-15441
---
 sdk/include/ddk/rxcontx.h|  17 +
 sdk/lib/drivers/rdbsslib/rdbss.c | 150 ++-
 sdk/lib/drivers/rxce/rxce.c  |  87 +++
 3 files changed, 252 insertions(+), 2 deletions(-)

diff --git a/sdk/include/ddk/rxcontx.h b/sdk/include/ddk/rxcontx.h
index bfab6952fc..d00e96383a 100644
--- a/sdk/include/ddk/rxcontx.h
+++ b/sdk/include/ddk/rxcontx.h
@@ -517,6 +517,8 @@ RxReinitializeContext(
 }
 #endif
 
+extern FAST_MUTEX RxContextPerFileSerializationMutex;
+
 VOID
 NTAPI
 RxResumeBlockedOperations_Serially(
@@ -527,4 +529,19 @@ VOID
 RxResumeBlockedOperations_ALL(
 _Inout_ PRX_CONTEXT RxContext);
 
+#if (_WIN32_WINNT >= 0x0600)
+VOID
+RxCancelBlockingOperation(
+_Inout_ PRX_CONTEXT RxContext,
+_In_ PIRP Irp);
+#else
+VOID
+RxCancelBlockingOperation(
+_Inout_ PRX_CONTEXT RxContext);
+#endif
+
+VOID
+RxRemoveOperationFromBlockingQueue(
+_Inout_ PRX_CONTEXT RxContext);
+
 #endif
diff --git a/sdk/lib/drivers/rdbsslib/rdbss.c b/sdk/lib/drivers/rdbsslib/rdbss.c
index 8822d03155..a65a695037 100644
--- a/sdk/lib/drivers/rdbsslib/rdbss.c
+++ b/sdk/lib/drivers/rdbsslib/rdbss.c
@@ -361,6 +361,11 @@ NTSTATUS
 RxNotifyChangeDirectory(
 PRX_CONTEXT RxContext);
 
+VOID
+NTAPI
+RxpCancelRoutine(
+PVOID Context);
+
 NTSTATUS
 RxpQueryInfoMiniRdr(
 PRX_CONTEXT RxContext,
@@ -529,7 +534,6 @@ BOOLEAN DisableFlushOnCleanup = FALSE;
 ULONG ReadAheadGranularity = 1 << PAGE_SHIFT;
 LIST_ENTRY RxActiveContexts;
 NPAGED_LOOKASIDE_LIST RxContextLookasideList;
-FAST_MUTEX RxContextPerFileSerializationMutex;
 RDBSS_DATA RxData;
 FCB RxDeviceFCB;
 BOOLEAN RxLoudLowIoOpsEnabled = FALSE;
@@ -1128,13 +1132,126 @@ RxCancelNotifyChangeDirectoryRequestsForVNetRoot(
 return Status;
 }
 
+/*
+ * @implemented
+ */
+BOOLEAN
+RxCancelOperationInOverflowQueue(
+PRX_CONTEXT RxContext)
+{
+KIRQL OldIrql;
+BOOLEAN OperationToCancel;
+
+/* By default, nothing cancelled */
+OperationToCancel = FALSE;
+
+/* Acquire the overflow spinlock */
+KeAcquireSpinLock(&RxFileSystemDeviceObject->OverflowQueueSpinLock, 
&OldIrql);
+
+/* Is our context in any queue? */
+if (BooleanFlagOn(RxContext->Flags, 
(RX_CONTEXT_FLAG_FSP_DELAYED_OVERFLOW_QUEUE | 
RX_CONTEXT_FLAG_FSP_CRITICAL_OVERFLOW_QUEUE)))
+{
+/* Make sure flag is consistent with facts... */
+if (RxContext->OverflowListEntry.Flink != NULL)
+{
+/* Remove it from the list */
+RemoveEntryList(&RxContext->OverflowListEntry);
+RxContext->OverflowListEntry.Flink == NULL;
+
+/* Decrement appropriate count */
+if (BooleanFlagOn(RxContext->Flags, 
RX_CONTEXT_FLAG_FSP_CRITICAL_OVERFLOW_QUEUE))
+{
+
--RxFileSystemDeviceObject->OverflowQueueCount[CriticalWorkQueue];
+}
+else
+{
+
--RxFileSystemDeviceObject->OverflowQueueCount[DelayedWorkQueue];
+}
+
+/* Clear the flag */
+ClearFlag(RxContext->Flags, 
~(RX_CONTEXT_FLAG_FSP_DELAYED_OVERFLOW_QUEUE | 
RX_CONTEXT_FLAG_FSP_CRITICAL_OVERFLOW_QUEUE));
+
+/* Time to cancel! */
+OperationToCancel = TRUE;
+}
+}
+
+KeReleaseSpinLock(&RxFileSystemDeviceObject->OverflowQueueSpinLock, 
OldIrql);
+
+/* We have something to cancel & complete */
+if (OperationToCancel)
+{
+RxRemoveOperationFromBlockingQueue(RxContext);
+RxCompleteRequest(RxContext, STATUS_CANCELLED);
+}
+
+return OperationToCancel;
+}
+
+/*
+ * @implemented
+ */
 VOID
 NTAPI
 RxCancelRoutine(
 PDEVICE_OBJECT DeviceObject,
 PIRP Irp)
 {
-UNIMPLEMENTED;
+KIRQL OldIrql;
+PLIST_ENTRY Entry;
+PRX_CONTEXT RxContext;
+
+/* Lock our contexts list */
+KeAcquireSpinLock(&RxStrucSupSpinLock, &OldIrql);
+
+/* Now, find a context that matches the cancelled IRP */
+Entry = RxActiveContexts.Flink;
+while (Entry != &RxActiveContexts)
+{
+RxContext = CONTAINING_RECORD(Entry, RX_CONTEXT, ContextListEntry);
+Entry = Entry->Flink;
+
+/* Found! */
+if (RxContext->CurrentIrp == Irp)
+{
+break;
+}
+}
+
+/* If we reached the end of the list, we didn't find any context, so zero 
the buffer
+ * If the context is already under cancellation, forget about it too
+ */
+if (Entry == &RxActiveContexts || BooleanFlagOn(RxContext->Flags, 
RX_CONTEXT_FLAG_CANCELLED))
+{
+

[ros-diffs] [reactos] 01/01: [TCPIP] Don't trust the TEB

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

commit 9d0eb9b7b85a5fb7b26065a46600fe5edc4dbdab
Author: Pierre Schweitzer 
AuthorDate: Wed Jan 2 23:01:24 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Wed Jan 2 23:02:44 2019 +0100

[TCPIP] Don't trust the TEB

And trust the Russian hackers to exploit that.
---
 drivers/network/tcpip/include/precomp.h |  1 +
 drivers/network/tcpip/tcpip/fileobjs.c  | 14 +-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/network/tcpip/include/precomp.h 
b/drivers/network/tcpip/include/precomp.h
index b2cb75063d..a96c4a51c3 100644
--- a/drivers/network/tcpip/include/precomp.h
+++ b/drivers/network/tcpip/include/precomp.h
@@ -16,5 +16,6 @@
 #include 
 #include 
 #include 
+#include 
 
 #endif /* _TCPIP_PCH_ */
diff --git a/drivers/network/tcpip/tcpip/fileobjs.c 
b/drivers/network/tcpip/tcpip/fileobjs.c
index f050a09b0c..614f1e1147 100644
--- a/drivers/network/tcpip/tcpip/fileobjs.c
+++ b/drivers/network/tcpip/tcpip/fileobjs.c
@@ -396,7 +396,6 @@ NTSTATUS FileOpenAddress(
   PVOID Options)
 {
   PADDRESS_FILE AddrFile;
-  PTEB Teb;
 
   TI_DbgPrint(MID_TRACE, ("Called (Proto %d).\n", Protocol));
 
@@ -431,10 +430,15 @@ NTSTATUS FileOpenAddress(
   AddrFile->HeaderIncl = 1;
   AddrFile->ProcessId = PsGetCurrentProcessId();
 
-  Teb = PsGetCurrentThreadTeb();
-  if (Teb != NULL) {
-AddrFile->SubProcessTag = Teb->SubProcessTag;
-  }
+  _SEH2_TRY {
+  PTEB Teb;
+
+  Teb = PsGetCurrentThreadTeb();
+  if (Teb != NULL)
+ AddrFile->SubProcessTag = Teb->SubProcessTag;
+  } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
+  AddrFile->SubProcessTag = 0;
+  } _SEH2_END;
 
   KeQuerySystemTime(&AddrFile->CreationTime);
 



[ros-diffs] [reactos] 01/01: [RXCE] Fix leftover

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

commit 44fdf3fc3003df3bd2f955d40aae03ac348337af
Author: Pierre Schweitzer 
AuthorDate: Thu Jan 3 16:59:45 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Thu Jan 3 16:59:45 2019 +0100

[RXCE] Fix leftover
---
 sdk/lib/drivers/rxce/rxce.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/sdk/lib/drivers/rxce/rxce.c b/sdk/lib/drivers/rxce/rxce.c
index 0f65b3f6ab..5799a10f99 100644
--- a/sdk/lib/drivers/rxce/rxce.c
+++ b/sdk/lib/drivers/rxce/rxce.c
@@ -726,12 +726,6 @@ RxCancelBlockingOperation(
 PFOBX Fobx;
 BOOLEAN PostRequest;
 
-#ifdef _WIN64
-C_ASSERT(FIELD_OFFSET(RX_CONTEXT, IoStatusBlock.Status) == 0x0B0);
-#else
-C_ASSERT(FIELD_OFFSET(RX_CONTEXT, IoStatusBlock.Status) == 0x064);
-#endif
-
 PAGED_CODE();
 
 Fobx = (PFOBX)RxContext->pFobx;



[ros-diffs] [reactos] 01/01: [MOUNTMGR] Fix buffer length checking

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

commit d84ab9ec7c513eb0917bc9f24f6dc97b70e8485b
Author: Pierre Schweitzer 
AuthorDate: Thu Jan 3 23:10:31 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Thu Jan 3 23:12:16 2019 +0100

[MOUNTMGR] Fix buffer length checking

Found by Vadim Galiant.

CORE-15549
---
 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 08b386daed..17d720e346 100644
--- a/drivers/filters/mountmgr/device.c
+++ b/drivers/filters/mountmgr/device.c
@@ -265,7 +265,7 @@ MountMgrCreatePoint(IN PDEVICE_EXTENSION DeviceExtension,
 
 MaxLength = MAX((Point->DeviceNameOffset + Point->DeviceNameLength),
 (Point->SymbolicLinkNameLength + 
Point->SymbolicLinkNameOffset));
-if (MaxLength >= Stack->Parameters.DeviceIoControl.InputBufferLength)
+if (MaxLength > Stack->Parameters.DeviceIoControl.InputBufferLength)
 {
 return STATUS_INVALID_PARAMETER;
 }



[ros-diffs] [reactos] 01/01: [NTOSKRNL] Implement !poolfind command in KDBG

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

commit 12e579567c0df0008bd1eb02dcdb92bcb31eb8e3
Author: Pierre Schweitzer 
AuthorDate: Sun Jan 6 11:54:05 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Jan 6 11:56:38 2019 +0100

[NTOSKRNL] Implement !poolfind command in KDBG

For now, it allows searching for pool allocations in
both paged and non paged pool.

It is based on Andreas Schuster work to identify POOL_HEADER
structures.
---
 ntoskrnl/kdbg/kdb_cli.c   |   2 +
 ntoskrnl/mm/ARM3/expool.c | 222 ++
 2 files changed, 224 insertions(+)

diff --git a/ntoskrnl/kdbg/kdb_cli.c b/ntoskrnl/kdbg/kdb_cli.c
index 37ad987b79..ef97693414 100644
--- a/ntoskrnl/kdbg/kdb_cli.c
+++ b/ntoskrnl/kdbg/kdb_cli.c
@@ -93,6 +93,7 @@ static BOOLEAN KdbpCmdDmesg(ULONG Argc, PCHAR Argv[]);
 
 BOOLEAN ExpKdbgExtPool(ULONG Argc, PCHAR Argv[]);
 BOOLEAN ExpKdbgExtPoolUsed(ULONG Argc, PCHAR Argv[]);
+BOOLEAN ExpKdbgExtPoolFind(ULONG Argc, PCHAR Argv[]);
 BOOLEAN ExpKdbgExtFileCache(ULONG Argc, PCHAR Argv[]);
 BOOLEAN ExpKdbgExtDefWrites(ULONG Argc, PCHAR Argv[]);
 
@@ -190,6 +191,7 @@ static const struct
 { "help", "help", "Display help screen.", KdbpCmdHelp },
 { "!pool", "!pool [Address [Flags]]", "Display information about pool 
allocations.", ExpKdbgExtPool },
 { "!poolused", "!poolused [Flags [Tag]]", "Display pool usage.", 
ExpKdbgExtPoolUsed },
+{ "!poolfind", "!poolfind Tag [Pool]", "Search for pool tag allocations.", 
ExpKdbgExtPoolFind },
 { "!filecache", "!filecache", "Display cache usage.", ExpKdbgExtFileCache 
},
 { "!defwrites", "!defwrites", "Display cache write values.", 
ExpKdbgExtDefWrites },
 { "!irpfind", "!irpfind [criteria data]", "Lists IRPs potentially matching 
criteria", PspKdbgIrpFind },
diff --git a/ntoskrnl/mm/ARM3/expool.c b/ntoskrnl/mm/ARM3/expool.c
index af83d88f05..b321b52044 100644
--- a/ntoskrnl/mm/ARM3/expool.c
+++ b/ntoskrnl/mm/ARM3/expool.c
@@ -3106,6 +3106,228 @@ ExpKdbgExtPoolUsed(
 return TRUE;
 }
 
+static
+BOOLEAN
+ExpKdbgExtValidatePoolHeader(
+PVOID BaseVa,
+PPOOL_HEADER Entry,
+POOL_TYPE BasePoolTye)
+{
+/* Block size cannot be NULL or negative and it must cover the page */
+if (Entry->BlockSize <= 0)
+{
+return FALSE;
+}
+if (Entry->BlockSize * 8 + (ULONG_PTR)Entry - (ULONG_PTR)BaseVa > 
PAGE_SIZE)
+{
+return FALSE;
+}
+
+/*
+ * PreviousSize cannot be 0 unless on page begin
+ * And it cannot be bigger that our current
+ * position in page
+ */
+if (Entry->PreviousSize == 0 && BaseVa != Entry)
+{
+return FALSE;
+}
+if (Entry->PreviousSize * 8 > (ULONG_PTR)Entry - (ULONG_PTR)BaseVa)
+{
+return FALSE;
+}
+
+/* Must be paged pool */
+if (((Entry->PoolType - 1) & BASE_POOL_TYPE_MASK) != BasePoolTye)
+{
+return FALSE;
+}
+
+/* Match tag mask */
+if ((Entry->PoolTag & 0x00808080) != 0)
+{
+return FALSE;
+}
+
+return TRUE;
+}
+
+static
+VOID
+ExpKdbgExtPoolFindPagedPool(
+ULONG Tag,
+ULONG Mask)
+{
+ULONG i = 0;
+PPOOL_HEADER Entry;
+PVOID BaseVa;
+PMMPTE PointerPte;
+PMMPDE PointerPde;
+
+KdbpPrint("Searching Paged pool (%p : %p) for Tag: %.4s\n", 
MmPagedPoolStart, MmPagedPoolEnd, (PCHAR)&Tag);
+
+/*
+ * To speed up paged pool search, we will use the allocation bipmap.
+ * This is possible because we live directly in the kernel :-)
+ */
+i = RtlFindSetBits(MmPagedPoolInfo.PagedPoolAllocationMap, 1, 0);
+while (i != 0x)
+{
+BaseVa = (PVOID)((ULONG_PTR)MmPagedPoolStart + (i << PAGE_SHIFT));
+Entry = BaseVa;
+
+/* Validate our address */
+if ((ULONG_PTR)BaseVa > (ULONG_PTR)MmPagedPoolEnd || (ULONG_PTR)BaseVa 
+ PAGE_SIZE > (ULONG_PTR)MmPagedPoolEnd)
+{
+break;
+}
+
+/* Check whether we are beyond expansion */
+PointerPde = MiAddressToPde(BaseVa);
+if (PointerPde >= MmPagedPoolInfo.NextPdeForPagedPoolExpansion)
+{
+break;
+}
+
+/* Check if allocation is valid */
+PointerPte = MiAddressToPte(BaseVa);
+if ((ULONG_PTR)PointerPte > PTE_TOP)
+{
+break;
+}
+
+if (PointerPte->u.Hard.Valid)
+{
+for (Entry = BaseVa;
+ (ULONG_PTR)Entry + sizeof(POOL_HEADER) < (ULONG_PTR)BaseVa + 
PAGE_SIZE;
+ Entry = (PVOID)((ULONG_PTR)Entry + 8))
+{
+/* Try to find whether w

[ros-diffs] [reactos] 02/02: [NTOSKRNL] Properly check for address validity in !poolfind

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

commit 28193399ee039b62a03f8ad8c6b23d6bb04facfe
Author: Pierre Schweitzer 
AuthorDate: Sun Jan 6 12:58:14 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Jan 6 12:58:14 2019 +0100

[NTOSKRNL] Properly check for address validity in !poolfind
---
 ntoskrnl/mm/ARM3/expool.c | 54 ++-
 1 file changed, 21 insertions(+), 33 deletions(-)

diff --git a/ntoskrnl/mm/ARM3/expool.c b/ntoskrnl/mm/ARM3/expool.c
index e03645387a..e69be03cbf 100644
--- a/ntoskrnl/mm/ARM3/expool.c
+++ b/ntoskrnl/mm/ARM3/expool.c
@@ -3163,7 +3163,6 @@ ExpKdbgExtPoolFindPagedPool(
 ULONG i = 0;
 PPOOL_HEADER Entry;
 PVOID BaseVa;
-PMMPTE PointerPte;
 PMMPDE PointerPde;
 
 KdbpPrint("Searching Paged pool (%p : %p) for Tag: %.4s\n", 
MmPagedPoolStart, MmPagedPoolEnd, (PCHAR)&Tag);
@@ -3192,13 +3191,7 @@ ExpKdbgExtPoolFindPagedPool(
 }
 
 /* Check if allocation is valid */
-PointerPte = MiAddressToPte(BaseVa);
-if ((ULONG_PTR)PointerPte > PTE_TOP)
-{
-break;
-}
-
-if (PointerPte->u.Hard.Valid)
+if (MmIsAddressValid(BaseVa))
 {
 for (Entry = BaseVa;
  (ULONG_PTR)Entry + sizeof(POOL_HEADER) < (ULONG_PTR)BaseVa + 
PAGE_SIZE;
@@ -3243,7 +3236,6 @@ ExpKdbgExtPoolFindNonPagedPool(
 {
 PPOOL_HEADER Entry;
 PVOID BaseVa;
-PMMPTE PointerPte;
 
 KdbpPrint("Searching NonPaged pool (%p : %p) for Tag: %.4s\n", 
MmNonPagedPoolStart, MmNonPagedPoolEnd0, (PCHAR)&Tag);
 
@@ -3261,38 +3253,34 @@ ExpKdbgExtPoolFindNonPagedPool(
 }
 
 /* Check if allocation is valid */
-PointerPte = MiAddressToPte(BaseVa);
-if ((ULONG_PTR)PointerPte > PTE_TOP)
+if (!MmIsAddressValid(BaseVa))
 {
-break;
+continue;
 }
 
-if (PointerPte->u.Hard.Valid)
+for (Entry = BaseVa;
+ (ULONG_PTR)Entry + sizeof(POOL_HEADER) < (ULONG_PTR)BaseVa + 
PAGE_SIZE;
+ Entry = (PVOID)((ULONG_PTR)Entry + 8))
 {
-for (Entry = BaseVa;
- (ULONG_PTR)Entry + sizeof(POOL_HEADER) < (ULONG_PTR)BaseVa + 
PAGE_SIZE;
- Entry = (PVOID)((ULONG_PTR)Entry + 8))
+/* Try to find whether we have a pool entry */
+if (!ExpKdbgExtValidatePoolHeader(BaseVa, Entry, NonPagedPool))
 {
-/* Try to find whether we have a pool entry */
-if (!ExpKdbgExtValidatePoolHeader(BaseVa, Entry, NonPagedPool))
+continue;
+}
+
+if ((Entry->PoolTag & Mask) == (Tag & Mask))
+{
+if (FoundCallback != NULL)
 {
-continue;
+FoundCallback(Entry, CallbackContext);
 }
-
-if ((Entry->PoolTag & Mask) == (Tag & Mask))
+else
 {
-if (FoundCallback != NULL)
-{
-FoundCallback(Entry, CallbackContext);
-}
-else
-{
-/* Print the line */
-KdbpPrint("%p size: %4d previous size: %4d  %s  
%.4s\n",
-  Entry, Entry->BlockSize, Entry->PreviousSize,
-  Entry->PoolType ? "(Allocated)" : "(Free)
 ",
-  (PCHAR)&Entry->PoolTag);
-}
+/* Print the line */
+KdbpPrint("%p size: %4d previous size: %4d  %s  %.4s\n",
+  Entry, Entry->BlockSize, Entry->PreviousSize,
+  Entry->PoolType ? "(Allocated)" : "(Free) ",
+  (PCHAR)&Entry->PoolTag);
 }
 }
 }



[ros-diffs] [reactos] 01/02: [NTOSKRNL] Reimplement !irpfind using !poolfind helpers

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

commit 47b48520b511842e9e9b74f9e59277ae4710c92f
Author: Pierre Schweitzer 
AuthorDate: Sun Jan 6 12:49:57 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Jan 6 12:49:57 2019 +0100

[NTOSKRNL] Reimplement !irpfind using !poolfind helpers

This allows avoiding one of the previous implementation limits:
leaked IRP not queued to a thread are now totally visible since
we look directly in the memory pool.
---
 ntoskrnl/kdbg/kdb_cli.c   |   5 +-
 ntoskrnl/mm/ARM3/expool.c | 184 ++
 ntoskrnl/ps/process.c | 114 
 3 files changed, 172 insertions(+), 131 deletions(-)

diff --git a/ntoskrnl/kdbg/kdb_cli.c b/ntoskrnl/kdbg/kdb_cli.c
index ef97693414..6b7ee2752b 100644
--- a/ntoskrnl/kdbg/kdb_cli.c
+++ b/ntoskrnl/kdbg/kdb_cli.c
@@ -96,8 +96,7 @@ BOOLEAN ExpKdbgExtPoolUsed(ULONG Argc, PCHAR Argv[]);
 BOOLEAN ExpKdbgExtPoolFind(ULONG Argc, PCHAR Argv[]);
 BOOLEAN ExpKdbgExtFileCache(ULONG Argc, PCHAR Argv[]);
 BOOLEAN ExpKdbgExtDefWrites(ULONG Argc, PCHAR Argv[]);
-
-BOOLEAN PspKdbgIrpFind(ULONG Argc, PCHAR Argv[]);
+BOOLEAN ExpKdbgExtIrpFind(ULONG Argc, PCHAR Argv[]);
 
 #ifdef __ROS_DWARF__
 static BOOLEAN KdbpCmdPrintStruct(ULONG Argc, PCHAR Argv[]);
@@ -194,7 +193,7 @@ static const struct
 { "!poolfind", "!poolfind Tag [Pool]", "Search for pool tag allocations.", 
ExpKdbgExtPoolFind },
 { "!filecache", "!filecache", "Display cache usage.", ExpKdbgExtFileCache 
},
 { "!defwrites", "!defwrites", "Display cache write values.", 
ExpKdbgExtDefWrites },
-{ "!irpfind", "!irpfind [criteria data]", "Lists IRPs potentially matching 
criteria", PspKdbgIrpFind },
+{ "!irpfind", "!irpfind [Pool [Restart Address [criteria data]]]", "Lists 
IRPs potentially matching criteria", ExpKdbgExtIrpFind },
 };
 
 /* FUNCTIONS */
diff --git a/ntoskrnl/mm/ARM3/expool.c b/ntoskrnl/mm/ARM3/expool.c
index b321b52044..e03645387a 100644
--- a/ntoskrnl/mm/ARM3/expool.c
+++ b/ntoskrnl/mm/ARM3/expool.c
@@ -3156,7 +3156,9 @@ static
 VOID
 ExpKdbgExtPoolFindPagedPool(
 ULONG Tag,
-ULONG Mask)
+ULONG Mask,
+VOID (NTAPI* FoundCallback)(PPOOL_HEADER, PVOID),
+PVOID CallbackContext)
 {
 ULONG i = 0;
 PPOOL_HEADER Entry;
@@ -3210,11 +3212,18 @@ ExpKdbgExtPoolFindPagedPool(
 
 if ((Entry->PoolTag & Mask) == (Tag & Mask))
 {
-/* Print the line */
-KdbpPrint("%p size: %4d previous size: %4d  %s  %.4s\n",
-  Entry, Entry->BlockSize, Entry->PreviousSize,
-  Entry->PoolType ? "(Allocated)" : "(Free) ",
-  (PCHAR)&Entry->PoolTag);
+if (FoundCallback != NULL)
+{
+FoundCallback(Entry, CallbackContext);
+}
+else
+{
+/* Print the line */
+KdbpPrint("%p size: %4d previous size: %4d  %s  
%.4s\n",
+  Entry, Entry->BlockSize, Entry->PreviousSize,
+  Entry->PoolType ? "(Allocated)" : "(Free)
 ",
+  (PCHAR)&Entry->PoolTag);
+}
 }
 }
 }
@@ -3228,7 +3237,9 @@ static
 VOID
 ExpKdbgExtPoolFindNonPagedPool(
 ULONG Tag,
-ULONG Mask)
+ULONG Mask,
+VOID (NTAPI* FoundCallback)(PPOOL_HEADER, PVOID),
+PVOID CallbackContext)
 {
 PPOOL_HEADER Entry;
 PVOID BaseVa;
@@ -3270,11 +3281,18 @@ ExpKdbgExtPoolFindNonPagedPool(
 
 if ((Entry->PoolTag & Mask) == (Tag & Mask))
 {
-/* Print the line */
-KdbpPrint("%p size: %4d previous size: %4d  %s  %.4s\n",
-  Entry, Entry->BlockSize, Entry->PreviousSize,
-  Entry->PoolType ? "(Allocated)" : "(Free) ",
-  (PCHAR)&Entry->PoolTag);
+if (FoundCallback != NULL)
+{
+FoundCallback(Entry, CallbackContext);
+}
+else
+{
+/* Print the line */
+KdbpPrint("%p size: %4d previous size: %4d  %s  
%.4s\n",
+  Entry, Entry->Bl

[ros-diffs] [reactos] 01/01: [NTOSKRNL] Fix !irpfind usage message

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

commit 25e14ae2a877e6667c153d9fd71eff576601cb9a
Author: Pierre Schweitzer 
AuthorDate: Sun Jan 6 13:00:43 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Jan 6 13:00:43 2019 +0100

[NTOSKRNL] Fix !irpfind usage message
---
 ntoskrnl/kdbg/kdb_cli.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ntoskrnl/kdbg/kdb_cli.c b/ntoskrnl/kdbg/kdb_cli.c
index 6b7ee2752b..ed40fe3661 100644
--- a/ntoskrnl/kdbg/kdb_cli.c
+++ b/ntoskrnl/kdbg/kdb_cli.c
@@ -193,7 +193,7 @@ static const struct
 { "!poolfind", "!poolfind Tag [Pool]", "Search for pool tag allocations.", 
ExpKdbgExtPoolFind },
 { "!filecache", "!filecache", "Display cache usage.", ExpKdbgExtFileCache 
},
 { "!defwrites", "!defwrites", "Display cache write values.", 
ExpKdbgExtDefWrites },
-{ "!irpfind", "!irpfind [Pool [Restart Address [criteria data]]]", "Lists 
IRPs potentially matching criteria", ExpKdbgExtIrpFind },
+{ "!irpfind", "!irpfind [Pool [startaddress [criteria data]]]", "Lists 
IRPs potentially matching criteria", ExpKdbgExtIrpFind },
 };
 
 /* FUNCTIONS */



[ros-diffs] [reactos] 01/01: [NTOSKRNL] Move KDBG MM functions implementation to their own file

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

commit 36f90e7e4647d284fc2ea8c8f0810f2e71bbcefd
Author: Pierre Schweitzer 
AuthorDate: Sun Jan 6 22:49:23 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Jan 6 22:50:57 2019 +0100

[NTOSKRNL] Move KDBG MM functions implementation to their own file
---
 ntoskrnl/mm/ARM3/expool.c | 540 ---
 ntoskrnl/mm/ARM3/kdbg.c   | 573 ++
 ntoskrnl/ntos.cmake   |   1 +
 3 files changed, 574 insertions(+), 540 deletions(-)

diff --git a/ntoskrnl/mm/ARM3/expool.c b/ntoskrnl/mm/ARM3/expool.c
index e69be03cbf..6a791e583f 100644
--- a/ntoskrnl/mm/ARM3/expool.c
+++ b/ntoskrnl/mm/ARM3/expool.c
@@ -2934,544 +2934,4 @@ ExAllocatePoolWithQuotaTag(IN POOL_TYPE PoolType,
 return Buffer;
 }
 
-#if DBG && defined(KDBG)
-
-BOOLEAN
-ExpKdbgExtPool(
-ULONG Argc,
-PCHAR Argv[])
-{
-ULONG_PTR Address = 0, Flags = 0;
-PVOID PoolPage;
-PPOOL_HEADER Entry;
-BOOLEAN ThisOne;
-PULONG Data;
-
-if (Argc > 1)
-{
-/* Get address */
-if (!KdbpGetHexNumber(Argv[1], &Address))
-{
-KdbpPrint("Invalid parameter: %s\n", Argv[0]);
-return TRUE;
-}
-}
-
-if (Argc > 2)
-{
-/* Get address */
-if (!KdbpGetHexNumber(Argv[1], &Flags))
-{
-KdbpPrint("Invalid parameter: %s\n", Argv[0]);
-return TRUE;
-}
-}
-
-/* Check if we got an address */
-if (Address != 0)
-{
-/* Get the base page */
-PoolPage = PAGE_ALIGN(Address);
-}
-else
-{
-KdbpPrint("Heap is unimplemented\n");
-return TRUE;
-}
-
-/* No paging support! */
-if (!MmIsAddressValid(PoolPage))
-{
-KdbpPrint("Address not accessible!\n");
-return TRUE;
-}
-
-/* Get pool type */
-if ((Address >= (ULONG_PTR)MmPagedPoolStart) && (Address <= 
(ULONG_PTR)MmPagedPoolEnd))
-KdbpPrint("Allocation is from PagedPool region\n");
-else if ((Address >= (ULONG_PTR)MmNonPagedPoolStart) && (Address <= 
(ULONG_PTR)MmNonPagedPoolEnd))
-KdbpPrint("Allocation is from NonPagedPool region\n");
-else
-{
-KdbpPrint("Address 0x%p is not within any pool!\n", (PVOID)Address);
-return TRUE;
-}
-
-/* Loop all entries of that page */
-Entry = PoolPage;
-do
-{
-/* Check if the address is within that entry */
-ThisOne = ((Address >= (ULONG_PTR)Entry) &&
-   (Address < (ULONG_PTR)(Entry + Entry->BlockSize)));
-
-if (!(Flags & 1) || ThisOne)
-{
-/* Print the line */
-KdbpPrint("%c%p size: %4d previous size: %4d  %s  %.4s\n",
- ThisOne ? '*' : ' ', Entry, Entry->BlockSize, 
Entry->PreviousSize,
- (Flags & 0x8000) ? "" : (Entry->PoolType ? 
"(Allocated)" : "(Free) "),
- (Flags & 0x8000) ? "" : (PCHAR)&Entry->PoolTag);
-}
-
-if (Flags & 1)
-{
-Data = (PULONG)(Entry + 1);
-KdbpPrint("%p  %08lx %08lx %08lx %08lx\n"
- "%p  %08lx %08lx %08lx %08lx\n",
- &Data[0], Data[0], Data[1], Data[2], Data[3],
- &Data[4], Data[4], Data[5], Data[6], Data[7]);
-}
-
-/* Go to next entry */
-Entry = POOL_BLOCK(Entry, Entry->BlockSize);
-}
-while ((Entry->BlockSize != 0) && ((ULONG_PTR)Entry < (ULONG_PTR)PoolPage 
+ PAGE_SIZE));
-
-return TRUE;
-}
-
-static
-VOID
-ExpKdbgExtPoolUsedGetTag(PCHAR Arg, PULONG Tag, PULONG Mask)
-{
-CHAR Tmp[4];
-ULONG Len;
-USHORT i;
-
-/* Get the tag */
-Len = strlen(Arg);
-if (Len > 4)
-{
-Len = 4;
-}
-
-/* Generate the mask to have wildcards support */
-for (i = 0; i < Len; ++i)
-{
-Tmp[i] = Arg[i];
-if (Tmp[i] != '?')
-{
-*Mask |= (0xFF << i * 8);
-}
-}
-
-/* Get the tag in the ulong form */
-*Tag = *((PULONG)Tmp);
-}
-
-BOOLEAN
-ExpKdbgExtPoolUsed(
-ULONG Argc,
-PCHAR Argv[])
-{
-ULONG Tag = 0;
-ULONG Mask = 0;
-ULONG Flags = 0;
-
-if (Argc > 1)
-{
-/* If we have 2+ args, easy: flags then tag */
-if (Argc > 2)
-{
-ExpKdbgExtPoolUsedGetTag(Argv[2], &Tag, &Mask);
-if (!KdbpGetHexNumber(Argv[1], &Flags))
-{
-KdbpPrint("Invalid parameter: %s\n", Argv[0]);
-}
-   

[ros-diffs] [reactos] 01/01: [NTOSKRNL] Misc fixes to !irpfind

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

commit e6a1851684dadc9107b1b1ec7530f42674d4a5b2
Author: Pierre Schweitzer 
AuthorDate: Sun Jan 6 23:21:20 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Jan 6 23:21:20 2019 +0100

[NTOSKRNL] Misc fixes to !irpfind
---
 ntoskrnl/mm/ARM3/kdbg.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/ntoskrnl/mm/ARM3/kdbg.c b/ntoskrnl/mm/ARM3/kdbg.c
index 6079e50529..c0fdf6dc9e 100644
--- a/ntoskrnl/mm/ARM3/kdbg.c
+++ b/ntoskrnl/mm/ARM3/kdbg.c
@@ -444,9 +444,10 @@ ExpKdbgExtIrpFindPrint(
 PVOID Context)
 {
 PIRP Irp;
+BOOLEAN IsComplete = FALSE;
 PIRP_FIND_CTXT FindCtxt = Context;
 PIO_STACK_LOCATION IoStack = NULL;
-PUNICODE_STRING DriverName;
+PUNICODE_STRING DriverName = NULL;
 ULONG_PTR SData = FindCtxt->SData;
 ULONG Criteria = FindCtxt->Criteria;
 
@@ -473,8 +474,10 @@ ExpKdbgExtIrpFindPrint(
 /* Get associated driver */
 if (IoStack->DeviceObject && IoStack->DeviceObject->DriverObject)
 DriverName = &IoStack->DeviceObject->DriverObject->DriverName;
-else
-DriverName = NULL;
+}
+else
+{
+IsComplete = TRUE;
 }
 
 /* Display if: no data, no criteria or if criteria matches data */
@@ -485,7 +488,14 @@ ExpKdbgExtIrpFindPrint(
 (Criteria & 0x8 && SData == (ULONG_PTR)Irp->Tail.Overlay.Thread) ||
 (Criteria & 0x10 && SData == (ULONG_PTR)Irp->UserEvent))
 {
-KdbpPrint("%p Thread %p current stack belongs to %wZ\n", Irp, 
Irp->Tail.Overlay.Thread, DriverName);
+if (!IsComplete)
+{
+KdbpPrint("%p Thread %p current stack belongs to %wZ\n", Irp, 
Irp->Tail.Overlay.Thread, DriverName);
+}
+else
+{
+KdbpPrint("%p Thread %p is complete (CurrentLocation %d > 
StackCount %d)\n", Irp, Irp->Tail.Overlay.Thread, Irp->CurrentLocation, 
Irp->StackCount + 1);
+}
 }
 }
 



[ros-diffs] [reactos] 01/02: [NTOSKRNL] In !irpfind, add info about current stack major/minor

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

commit e1342127f0c987a1b9247472b64479834caa0aa4
Author: Pierre Schweitzer 
AuthorDate: Mon Jan 7 08:41:36 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Tue Jan 8 08:43:23 2019 +0100

[NTOSKRNL] In !irpfind, add info about current stack major/minor
---
 ntoskrnl/mm/ARM3/kdbg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ntoskrnl/mm/ARM3/kdbg.c b/ntoskrnl/mm/ARM3/kdbg.c
index c0fdf6dc9e..ebaf494df6 100644
--- a/ntoskrnl/mm/ARM3/kdbg.c
+++ b/ntoskrnl/mm/ARM3/kdbg.c
@@ -490,7 +490,7 @@ ExpKdbgExtIrpFindPrint(
 {
 if (!IsComplete)
 {
-KdbpPrint("%p Thread %p current stack belongs to %wZ\n", Irp, 
Irp->Tail.Overlay.Thread, DriverName);
+KdbpPrint("%p Thread %p current stack (%x, %x) belongs to %wZ\n", 
Irp, Irp->Tail.Overlay.Thread, IoStack->MajorFunction, IoStack->MinorFunction, 
DriverName);
 }
 else
 {



[ros-diffs] [reactos] 02/02: [NTOSKRNL] Add support for large allocations in !poolfind

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

commit a3f8813fff8c89737aadadd22dacfd8338e9eeb0
Author: Pierre Schweitzer 
AuthorDate: Tue Jan 8 08:42:51 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Tue Jan 8 08:43:23 2019 +0100

[NTOSKRNL] Add support for large allocations in !poolfind
---
 ntoskrnl/mm/ARM3/kdbg.c | 35 ++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/ntoskrnl/mm/ARM3/kdbg.c b/ntoskrnl/mm/ARM3/kdbg.c
index ebaf494df6..e3a9ef3adf 100644
--- a/ntoskrnl/mm/ARM3/kdbg.c
+++ b/ntoskrnl/mm/ARM3/kdbg.c
@@ -26,6 +26,10 @@ typedef struct _IRP_FIND_CTXT
 } IRP_FIND_CTXT, *PIRP_FIND_CTXT;
 
 extern PVOID MmNonPagedPoolEnd0;
+extern SIZE_T PoolBigPageTableSize;
+extern PPOOL_TRACKER_BIG_PAGES PoolBigPageTable;
+
+#define POOL_BIG_TABLE_ENTRY_FREE 0x1
 
 /* Pool block/header/list access macros */
 #define POOL_ENTRY(x)   (PPOOL_HEADER)((ULONG_PTR)(x) - 
sizeof(POOL_HEADER))
@@ -210,6 +214,34 @@ ExpKdbgExtPoolUsed(
 return TRUE;
 }
 
+static
+VOID
+ExpKdbgExtPoolFindLargePool(
+ULONG Tag,
+ULONG Mask)
+{
+ULONG i;
+
+KdbpPrint("Scanning large pool allocation table for Tag: %.4s (%p : 
%p)\n", (PCHAR)&Tag, &PoolBigPageTable[0], 
&PoolBigPageTable[PoolBigPageTableSize - 1]);
+
+for (i = 0; i < PoolBigPageTableSize; i++)
+{
+/* Free entry? */
+if ((ULONG_PTR)PoolBigPageTable[i].Va & POOL_BIG_TABLE_ENTRY_FREE)
+{
+continue;
+}
+
+if ((PoolBigPageTable[i].Key & Mask) == (Tag & Mask))
+{
+/* Print the line */
+KdbpPrint("%p: tag %.4s, size: %I64x\n",
+  PoolBigPageTable[i].Va, (PCHAR)&PoolBigPageTable[i].Key,
+  PoolBigPageTable[i].NumberOfPages << PAGE_SHIFT);
+}
+}
+}
+
 static
 BOOLEAN
 ExpKdbgExtValidatePoolHeader(
@@ -423,7 +455,8 @@ ExpKdbgExtPoolFind(
 }
 }
 
-/* FIXME: What about large pool? */
+/* First search for large allocations */
+ExpKdbgExtPoolFindLargePool(Tag, Mask);
 
 if (PoolType == NonPagedPool)
 {



[ros-diffs] [reactos] 01/01: [NTOSKRNL] Add support for callback when enumerating large pool allocations

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

commit d9a3fd16d41e3aa05b431222c500be87321d82dd
Author: Pierre Schweitzer 
AuthorDate: Tue Jan 15 22:07:35 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Tue Jan 15 22:07:35 2019 +0100

[NTOSKRNL] Add support for callback when enumerating large pool allocations
---
 ntoskrnl/mm/ARM3/kdbg.c | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/ntoskrnl/mm/ARM3/kdbg.c b/ntoskrnl/mm/ARM3/kdbg.c
index e3a9ef3adf..1682fa8940 100644
--- a/ntoskrnl/mm/ARM3/kdbg.c
+++ b/ntoskrnl/mm/ARM3/kdbg.c
@@ -218,7 +218,9 @@ static
 VOID
 ExpKdbgExtPoolFindLargePool(
 ULONG Tag,
-ULONG Mask)
+ULONG Mask,
+VOID (NTAPI* FoundCallback)(PVOID, PVOID),
+PVOID CallbackContext)
 {
 ULONG i;
 
@@ -234,10 +236,17 @@ ExpKdbgExtPoolFindLargePool(
 
 if ((PoolBigPageTable[i].Key & Mask) == (Tag & Mask))
 {
-/* Print the line */
-KdbpPrint("%p: tag %.4s, size: %I64x\n",
-  PoolBigPageTable[i].Va, (PCHAR)&PoolBigPageTable[i].Key,
-  PoolBigPageTable[i].NumberOfPages << PAGE_SHIFT);
+if (FoundCallback != NULL)
+{
+FoundCallback(PoolBigPageTable[i].Va, CallbackContext);
+}
+else
+{
+/* Print the line */
+KdbpPrint("%p: tag %.4s, size: %I64x\n",
+  PoolBigPageTable[i].Va, 
(PCHAR)&PoolBigPageTable[i].Key,
+  PoolBigPageTable[i].NumberOfPages << PAGE_SHIFT);
+}
 }
 }
 }
@@ -456,7 +465,7 @@ ExpKdbgExtPoolFind(
 }
 
 /* First search for large allocations */
-ExpKdbgExtPoolFindLargePool(Tag, Mask);
+ExpKdbgExtPoolFindLargePool(Tag, Mask, NULL, NULL);
 
 if (PoolType == NonPagedPool)
 {



[ros-diffs] [reactos] 01/01: [BUTTERFLIES] Fix GCC build

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

commit 32faa247331dc744d307aa9fd60146aa59cde8ba
Author: Pierre Schweitzer 
AuthorDate: Sun Jan 20 11:06:42 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Jan 20 11:06:42 2019 +0100

[BUTTERFLIES] Fix GCC build
---
 modules/rosapps/applications/screensavers/butterflies/butterflies.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/modules/rosapps/applications/screensavers/butterflies/butterflies.c 
b/modules/rosapps/applications/screensavers/butterflies/butterflies.c
index 1c181fea91..60f7ed4d17 100644
--- a/modules/rosapps/applications/screensavers/butterflies/butterflies.c
+++ b/modules/rosapps/applications/screensavers/butterflies/butterflies.c
@@ -230,7 +230,7 @@ void Display()
 
 }
 
-INT_PTR AboutProc(HWND hdlg, UINT msg, WPARAM wpm, LPARAM lpm){
+INT_PTR CALLBACK AboutProc(HWND hdlg, UINT msg, WPARAM wpm, LPARAM lpm){
 
switch(msg){
case WM_CTLCOLORSTATIC:



[ros-diffs] [reactos] 01/01: [MDI] Fix GCC build

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

commit 1b92120fc9263352d402eb50bda93266fa542053
Author: Pierre Schweitzer 
AuthorDate: Sun Jan 20 11:09:54 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Jan 20 11:09:54 2019 +0100

[MDI] Fix GCC build
---
 modules/rosapps/templates/mdi/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/rosapps/templates/mdi/main.c 
b/modules/rosapps/templates/mdi/main.c
index 977a082350..6fa1d144e7 100644
--- a/modules/rosapps/templates/mdi/main.c
+++ b/modules/rosapps/templates/mdi/main.c
@@ -127,7 +127,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
 hFont = CreateFont(-MulDiv(8,GetDeviceCaps(hdc,LOGPIXELSY),72), 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, _T("MS Sans Serif"));
 ReleaseDC(0, hdc);
 
-hFrameWnd = CreateWindowEx(0, (LPCTSTR)hFrameWndClass, szTitle,
+hFrameWnd = CreateWindowEx(0, (LPCTSTR)(ULONG_PTR)hFrameWndClass, szTitle,
 //  hFrameWnd = CreateWindow(szFrameClass, szTitle,
 WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,



[ros-diffs] [reactos] 01/01: [MOUNTMGR] Misc. fixes to QueryDeviceInformation: - Simplify failure path for DeviceName query failure - Don't make stable query failure fail the whole function call

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

commit 20ddde0a97bb927a3ccfe331a9b3bd30d0c5922d
Author: Pierre Schweitzer 
AuthorDate: Sun Jan 20 17:32:48 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Jan 20 17:38:29 2019 +0100

[MOUNTMGR] Misc. fixes to QueryDeviceInformation:
- Simplify failure path for DeviceName query failure
- Don't make stable query failure fail the whole function call

Based on a patch by Vadim Galiant

CORE-15550
---
 drivers/filters/mountmgr/mountmgr.c | 57 +++--
 1 file changed, 29 insertions(+), 28 deletions(-)

diff --git a/drivers/filters/mountmgr/mountmgr.c 
b/drivers/filters/mountmgr/mountmgr.c
index 1852dfc17f..0e273b3957 100644
--- a/drivers/filters/mountmgr/mountmgr.c
+++ b/drivers/filters/mountmgr/mountmgr.c
@@ -213,12 +213,12 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
 PIRP Irp;
 USHORT Size;
 KEVENT Event;
-NTSTATUS Status;
 BOOLEAN IsRemovable;
 PMOUNTDEV_NAME Name;
 PMOUNTDEV_UNIQUE_ID Id;
 PFILE_OBJECT FileObject;
 PIO_STACK_LOCATION Stack;
+NTSTATUS Status, IntStatus;
 PDEVICE_OBJECT DeviceObject;
 IO_STATUS_BLOCK IoStatusBlock;
 PARTITION_INFORMATION_EX PartitionInfo;
@@ -282,7 +282,7 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
 if (Status == STATUS_PENDING)
 {
 KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, 
NULL);
-Status =  IoStatusBlock.Status;
+Status = IoStatusBlock.Status;
 }
 
 /* In case of failure, don't fail, that's no vital */
@@ -329,7 +329,7 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
 if (Status == STATUS_PENDING)
 {
 KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, 
NULL);
-Status =  IoStatusBlock.Status;
+Status = IoStatusBlock.Status;
 }
 
 /* Once again here, failure isn't major */
@@ -368,7 +368,7 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
 if (Status == STATUS_PENDING)
 {
 KeWaitForSingleObject(&Event, Executive, KernelMode, 
FALSE, NULL);
-Status =  IoStatusBlock.Status;
+Status = IoStatusBlock.Status;
 }
 
 if (!NT_SUCCESS(Status))
@@ -470,32 +470,33 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
 }
 }
 
-/* Here we can't fail and assume default value */
-if (!NT_SUCCESS(Status))
-{
-FreePool(Name);
-ObDereferenceObject(DeviceObject);
-ObDereferenceObject(FileObject);
-return Status;
-}
-
-/* Copy back found name to the caller */
-DeviceName->Length = Name->NameLength;
-DeviceName->MaximumLength = Name->NameLength + sizeof(WCHAR);
-DeviceName->Buffer = AllocatePool(DeviceName->MaximumLength);
-if (!DeviceName->Buffer)
+if (NT_SUCCESS(Status))
 {
-FreePool(Name);
-ObDereferenceObject(DeviceObject);
-ObDereferenceObject(FileObject);
-return STATUS_INSUFFICIENT_RESOURCES;
+/* Copy back found name to the caller */
+DeviceName->Length = Name->NameLength;
+DeviceName->MaximumLength = Name->NameLength + sizeof(WCHAR);
+DeviceName->Buffer = AllocatePool(DeviceName->MaximumLength);
+if (!DeviceName->Buffer)
+{
+Status = STATUS_INSUFFICIENT_RESOURCES;
+}
+else
+{
+RtlCopyMemory(DeviceName->Buffer, Name->Name, 
Name->NameLength);
+DeviceName->Buffer[Name->NameLength / sizeof(WCHAR)] = 
UNICODE_NULL;
+}
 }
 
-RtlCopyMemory(DeviceName->Buffer, Name->Name, Name->NameLength);
-DeviceName->Buffer[Name->NameLength / sizeof(WCHAR)] = UNICODE_NULL;
 FreePool(Name);
 }
 
+if (!NT_SUCCESS(Status))
+{
+ObDereferenceObject(DeviceObject);
+ObDereferenceObject(FileObject);
+return Status;
+}
+
 /* If caller wants device unique ID */
 if (UniqueId)
 {
@@ -628,14 +629,14 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
 Stack = IoGetNextIrpStackLocation(Irp);
 Stack->FileObject = FileObject;
 
-Status = IoCallDriver(DeviceObject, Irp);
-if (Status == STATUS_PENDING)
+IntStatus = IoCallDriver(DeviceObject, Irp);
+if (IntStatus == STATUS_PENDING)
 {
 KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
-Status = IoS

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

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

commit 2d8f0aee5ced083f06fa3bdafe49b0f3fa96184e
Author: Pierre Schweitzer 
AuthorDate: Mon Jan 21 21:16:11 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Jan 21 21:16:48 2019 +0100

[SYSDM] Update French translation
---
 dll/cpl/sysdm/lang/fr-FR.rc | 38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/dll/cpl/sysdm/lang/fr-FR.rc b/dll/cpl/sysdm/lang/fr-FR.rc
index 4037a2e853..67b49df685 100644
--- a/dll/cpl/sysdm/lang/fr-FR.rc
+++ b/dll/cpl/sysdm/lang/fr-FR.rc
@@ -10,9 +10,9 @@ BEGIN
 LTEXT REACTOS_STR_PRODUCT_NAME, IDC_STATIC, 10, 128, 116, 9
 LTEXT "Version", IDC_ROSVERSION, 10, 137, 116, 9
 LTEXT REACTOS_STR_PRODUCT_BUILD, IDC_STATIC, 10, 146, 110, 9
-LTEXT "System Uptime:", IDC_STATIC, 4, 158, 86, 9
+LTEXT "Temps d'activité :", IDC_STATIC, 4, 158, 86, 9
 LTEXT "", IDC_UPTIME, 10, 170, 116, 9
-LTEXT "Machine:", IDC_STATIC, 124, 116, 34, 9
+LTEXT "Machine :", IDC_STATIC, 124, 116, 34, 9
 LTEXT "", IDC_MACHINELINE1, 130, 128, 118, 9
 LTEXT "", IDC_MACHINELINE2, 130, 137, 118, 9
 LTEXT "", IDC_MACHINELINE3, 130, 146, 118, 9
@@ -57,19 +57,19 @@ BEGIN
 GROUPBOX "Démarrage et Récupération", IDC_STATIC, 6, 131, 244, 52
 LTEXT "Les options Démarrage et Récupération indiquent à l'ordinateur 
comment démarrer et quoi faire si une erreur empêche l'ordinateur de 
s'arrêter.", IDC_STATIC, 16, 144, 210, 30
 PUSHBUTTON "Réglages", IDC_STAREC, 194, 162, 50, 15
-PUSHBUTTON "System Settings", IDC_SYSSETTINGS, 6, 192, 80, 15
+PUSHBUTTON "Paramètres système", IDC_SYSSETTINGS, 6, 192, 80, 15
 PUSHBUTTON "Variables d'en&vironnement", IDC_ENVVAR, 88, 192, 80, 15
 PUSHBUTTON "Rapport d'e&rreurs", IDC_ERRORREPORT, 170, 192, 80, 15
 END
 
 IDD_SYSSETTINGS DIALOGEX 0, 0, 221, 106
 STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION
-CAPTION "System Settings"
+CAPTION "Paramètres système"
 FONT 8, "MS Shell Dlg", 0, 0, 0x1
 BEGIN
-GROUPBOX "Version Info", IDC_STATIC, 6, 3, 210, 73
-LTEXT "ReactOS is built as a server OS and reports as such. Check this box 
to change this for applications only.", IDC_STATIC, 15, 15, 183, 41
-CONTROL "Report as Workstation", IDC_REPORTASWORKSTATION, "Button", 
BS_AUTOCHECKBOX | WS_TABSTOP, 16, 57, 190, 10
+GROUPBOX "Information de version", IDC_STATIC, 6, 3, 210, 73
+LTEXT "ReactOS est construit comme un OS serveur et se présente comme tel. 
Cochez cette case pour changer ce comportement pour les applications.", 
IDC_STATIC, 15, 15, 183, 41
+CONTROL "Se présenter comme une station de travail", 
IDC_REPORTASWORKSTATION, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 16, 57, 190, 10
 PUSHBUTTON "OK", IDOK, 166, 83, 50, 14
 END
 
@@ -283,7 +283,7 @@ BEGIN
 IDS_PETABYTE "Po de RAM"
 IDS_MEGAHERTZ "MHz"
 IDS_GIGAHERTZ "GHz"
-IDS_UPTIME_FORMAT "%u Days, %02u:%02u:%02u"
+IDS_UPTIME_FORMAT "%u jours, %02u:%02u:%02u"
 IDS_VARIABLE "Variable"
 IDS_VALUE "Valeur"
 IDS_NO_DUMP "(Aucun)"
@@ -296,17 +296,17 @@ BEGIN
 IDS_USERPROFILE_STATUS "Statut"
 IDS_USERPROFILE_MODIFIED "Modifié"
 IDS_MESSAGEBOXTITLE "System control panel applet"
-IDS_WARNINITIALSIZE "Enter a numeric value for the initial size of the 
paging file."
-IDS_WARNMAXIMUMSIZE "Enter a numeric value for the maximum size of the 
paging file."
-IDS_WARNINITIALRANGE "The initial size of the paging file must not be 
smaller than 16 MB and must not exceed the available space on the selected 
drive."
-IDS_WARNMAXIMUMRANGE "The maximum size of the paging file must not be 
smaller than its initial size, must not be larger than 4095 MB and must not 
exceed the available space on the selected drive."
+IDS_WARNINITIALSIZE "Entrez une valeur numérique pour la taille initiale 
du fichier d'échange."
+IDS_WARNMAXIMUMSIZE "Entrez une valeur numérique pour la taille maximale 
du fichier d'échange."
+IDS_WARNINITIALRANGE "La taille initiale du fichier d'échange ne peut pas 
être inférieure à 16 Mo and ne doit pas dépasser l'espace libre total du disque.
+IDS_WARNMAXIMUMRANGE "La taille maximale du fichier d'échange ne peut pas 
être inférieure à sa taille initiale, et ne peut pas être supérieur à 4095 Mo 
et ne peut pas dépasser l'espace libre total du disque."
 IDS_PAGEFILE_NONE "Aucun&qu

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

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

commit 342414c7d6f1c2b1f89a08b9d3b114d3022695e9
Author: Pierre Schweitzer 
AuthorDate: Mon Jan 21 21:27:50 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Jan 21 21:27:50 2019 +0100

[SYSDM] Meh
---
 dll/cpl/sysdm/lang/fr-FR.rc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dll/cpl/sysdm/lang/fr-FR.rc b/dll/cpl/sysdm/lang/fr-FR.rc
index 67b49df685..d802ef2a3a 100644
--- a/dll/cpl/sysdm/lang/fr-FR.rc
+++ b/dll/cpl/sysdm/lang/fr-FR.rc
@@ -298,8 +298,8 @@ BEGIN
 IDS_MESSAGEBOXTITLE "System control panel applet"
 IDS_WARNINITIALSIZE "Entrez une valeur numérique pour la taille initiale 
du fichier d'échange."
 IDS_WARNMAXIMUMSIZE "Entrez une valeur numérique pour la taille maximale 
du fichier d'échange."
-IDS_WARNINITIALRANGE "La taille initiale du fichier d'échange ne peut pas 
être inférieure à 16 Mo and ne doit pas dépasser l'espace libre total du disque.
-IDS_WARNMAXIMUMRANGE "La taille maximale du fichier d'échange ne peut pas 
être inférieure à sa taille initiale, et ne peut pas être supérieur à 4095 Mo 
et ne peut pas dépasser l'espace libre total du disque."
+IDS_WARNINITIALRANGE "La taille initiale du fichier d'échange ne peut pas 
être inférieure à 16 Mo and ne doit pas dépasser l'espace libre total du 
disque."
+IDS_WARNMAXIMUMRANGE "La taille maximale du fichier d'échange ne peut pas 
être inférieure à sa taille initiale, et ne peut pas être supérieure à 4095 Mo 
et ne peut pas dépasser l'espace libre total du disque."
 IDS_PAGEFILE_NONE "Aucun"
 IDS_PAGEFILE_SYSTEM "Géré par le système"
 IDS_INFOREBOOT "Vous devez redémarrer le système pour appliquer les 
changements."



[ros-diffs] [reactos] 01/01: [NTOS:MM] On big pool enumeration, return entry instead of base VA

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

commit a6dc1d69bc025b5afb30076b35e9bd7c27e6a543
Author: Pierre Schweitzer 
AuthorDate: Sat Feb 2 10:45:15 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Feb 2 10:45:15 2019 +0100

[NTOS:MM] On big pool enumeration, return entry instead of base VA
---
 ntoskrnl/mm/ARM3/kdbg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ntoskrnl/mm/ARM3/kdbg.c b/ntoskrnl/mm/ARM3/kdbg.c
index 1682fa8940..5b2554a425 100644
--- a/ntoskrnl/mm/ARM3/kdbg.c
+++ b/ntoskrnl/mm/ARM3/kdbg.c
@@ -219,7 +219,7 @@ VOID
 ExpKdbgExtPoolFindLargePool(
 ULONG Tag,
 ULONG Mask,
-VOID (NTAPI* FoundCallback)(PVOID, PVOID),
+VOID (NTAPI* FoundCallback)(PPOOL_TRACKER_BIG_PAGES, PVOID),
 PVOID CallbackContext)
 {
 ULONG i;
@@ -238,7 +238,7 @@ ExpKdbgExtPoolFindLargePool(
 {
 if (FoundCallback != NULL)
 {
-FoundCallback(PoolBigPageTable[i].Va, CallbackContext);
+FoundCallback(&PoolBigPageTable[i], CallbackContext);
 }
 else
 {



[ros-diffs] [reactos] 01/01: [NTOSKRNL] Add a first implementation of !handle command in KDBG

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

commit 2991f6e76e8b7587cca1993a332879ee37cf415c
Author: Pierre Schweitzer 
AuthorDate: Sat Feb 9 13:45:19 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Feb 9 13:46:35 2019 +0100

[NTOSKRNL] Add a first implementation of !handle command in KDBG

It allows dumping all the handles (filtered by PID/Process)
and it displays basic information about file and key handles
---
 ntoskrnl/ex/handle.c| 227 
 ntoskrnl/kdbg/kdb_cli.c |   2 +
 2 files changed, 229 insertions(+)

diff --git a/ntoskrnl/ex/handle.c b/ntoskrnl/ex/handle.c
index a0ea5fb448c..a5901d856d6 100644
--- a/ntoskrnl/ex/handle.c
+++ b/ntoskrnl/ex/handle.c
@@ -1282,3 +1282,230 @@ ExEnumHandleTable(IN PHANDLE_TABLE HandleTable,
 KeLeaveCriticalRegion();
 return Result;
 }
+
+#if DBG && defined(KDBG)
+BOOLEAN ExpKdbgExtHandle(ULONG Argc, PCHAR Argv[])
+{
+USHORT i;
+char *endptr;
+HANDLE ProcessId;
+EXHANDLE ExHandle;
+PLIST_ENTRY Entry;
+PEPROCESS Process;
+WCHAR KeyPath[MAX_PATH];
+PFILE_OBJECT FileObject;
+PHANDLE_TABLE HandleTable;
+POBJECT_HEADER ObjectHeader;
+PHANDLE_TABLE_ENTRY TableEntry;
+ULONG NeededLength, NameLength;
+PCM_KEY_CONTROL_BLOCK Kcb, CurrentKcb;
+POBJECT_HEADER_NAME_INFO ObjectNameInfo;
+
+if (Argc > 1)
+{
+/* Get EPROCESS address or PID */
+i = 0;
+while (Argv[1][i])
+{
+if (!isdigit(Argv[1][i]))
+{
+i = 0;
+break;
+}
+}
+
+if (i == 0)
+{
+if (!KdbpGetHexNumber(Argv[1], (PVOID)&Process))
+{
+KdbpPrint("Invalid parameter: %s\n", Argv[1]);
+return TRUE;
+}
+
+/* In the end, we always want a PID */
+ProcessId = PsGetProcessId(Process);
+}
+else
+{
+ProcessId = (HANDLE)strtoul(Argv[1], &endptr, 10);
+if (*endptr != '\0')
+{
+KdbpPrint("Invalid parameter: %s\n", Argv[1]);
+return TRUE;
+}
+}
+}
+else
+{
+ProcessId = PsGetCurrentProcessId();
+}
+
+for (Entry = HandleTableListHead.Flink;
+ Entry != &HandleTableListHead;
+ Entry = Entry->Flink)
+{
+/* Only return matching PID
+ * 0 matches everything
+ */
+HandleTable = CONTAINING_RECORD(Entry, HANDLE_TABLE, HandleTableList);
+if (ProcessId != 0 && HandleTable->UniqueProcessId != ProcessId)
+{
+continue;
+}
+
+KdbpPrint("\n");
+
+KdbpPrint("Handle table at %p with %d entries in use\n", HandleTable, 
HandleTable->HandleCount);
+
+ExHandle.Value = 0;
+while ((TableEntry = ExpLookupHandleTableEntry(HandleTable, ExHandle)))
+{
+if ((TableEntry->Object) &&
+(TableEntry->NextFreeTableEntry != -2))
+{
+ObjectHeader = ObpGetHandleObject(TableEntry);
+
+KdbpPrint("%p: Object: %p GrantedAccess: %x Entry: %p\n", 
ExHandle.Value, &ObjectHeader->Body, TableEntry->GrantedAccess, TableEntry);
+KdbpPrint("Object: %p Type: (%x) ", &ObjectHeader->Body, 
ObjectHeader->Type);
+if (ObjectHeader->Type == IoFileObjectType)
+{
+KdbpPrint("File");
+}
+else if (ObjectHeader->Type == ExEventObjectType)
+{
+KdbpPrint("Event");
+}
+else if (ObjectHeader->Type == ExEventPairObjectType)
+{
+KdbpPrint("EventPair");
+}
+else if (ObjectHeader->Type == ExMutantObjectType)
+{
+KdbpPrint("Mutant");
+}
+else if (ObjectHeader->Type == ExSemaphoreObjectType)
+{
+KdbpPrint("Semaphore");
+}
+else if (ObjectHeader->Type == ExTimerType)
+{
+KdbpPrint("Timer");
+}
+else if (ObjectHeader->Type == ExWindowStationObjectType)
+{
+KdbpPrint("WindowStation");
+}
+else if (ObjectHeader->Type == ExDesktopObjectType)
+{
+KdbpPrint("Desktop");
+}
+else if (ObjectHeader->Type == ObpDirectoryObjectType)
+{

[ros-diffs] [reactos] 01/01: [NTOSKRNL] Fix parsing loop

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

commit f4320047c3f1e7d4e0d9f17d1cfa596d9801bb48
Author: Pierre Schweitzer 
AuthorDate: Sat Feb 9 13:59:11 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Feb 9 13:59:11 2019 +0100

[NTOSKRNL] Fix parsing loop
---
 ntoskrnl/ex/handle.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ntoskrnl/ex/handle.c b/ntoskrnl/ex/handle.c
index a5901d856d6..fdd9f2d7e41 100644
--- a/ntoskrnl/ex/handle.c
+++ b/ntoskrnl/ex/handle.c
@@ -1312,6 +1312,8 @@ BOOLEAN ExpKdbgExtHandle(ULONG Argc, PCHAR Argv[])
 i = 0;
 break;
 }
+
+++i;
 }
 
 if (i == 0)



[ros-diffs] [reactos] 01/01: [NTOSKRNL] Also display sections name

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

commit df829f79487a7ec1946751585057b7c7ad0bd544
Author: Pierre Schweitzer 
AuthorDate: Sun Feb 10 11:23:57 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Feb 10 11:23:57 2019 +0100

[NTOSKRNL] Also display sections name
---
 ntoskrnl/ex/handle.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ntoskrnl/ex/handle.c b/ntoskrnl/ex/handle.c
index fdd9f2d7e4..f75f0363f7 100644
--- a/ntoskrnl/ex/handle.c
+++ b/ntoskrnl/ex/handle.c
@@ -1438,7 +1438,8 @@ BOOLEAN ExpKdbgExtHandle(ULONG Argc, PCHAR Argv[])
 /* For directory, and win32k objects, display object name */
 else if (ObjectHeader->Type == ObpDirectoryObjectType ||
  ObjectHeader->Type == ExWindowStationObjectType ||
- ObjectHeader->Type == ExDesktopObjectType)
+ ObjectHeader->Type == ExDesktopObjectType ||
+ ObjectHeader->Type == MmSectionObjectType)
 {
 ObjectNameInfo = OBJECT_HEADER_TO_NAME_INFO(ObjectHeader);
 if (ObjectNameInfo != NULL && ObjectNameInfo->Name.Buffer 
!= NULL)



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

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

commit d2c71d761e8c1bef18aafdebc58377c19018bd06
Author: Pierre Schweitzer 
AuthorDate: Sun Feb 10 20:42:32 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Feb 10 20:43:14 2019 +0100

[CRYPTEX] Add French translation
---
 base/services/nfsd/nfs41_daemon.c| 17 -
 base/services/nfsd/service.c | 19 +++
 dll/shellext/cryptext/cryptext.rc|  3 +++
 dll/shellext/cryptext/lang/fr-FR.rc  | 14 ++
 dll/win32/ole32/rpc.c|  2 ++
 drivers/filesystems/ntfs/fsctl.c |  4 ++--
 modules/rosapps/applications/devutils/CMakeLists.txt |  1 +
 7 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/base/services/nfsd/nfs41_daemon.c 
b/base/services/nfsd/nfs41_daemon.c
index 1a8f2dfbbe..c2f5df2b1b 100644
--- a/base/services/nfsd/nfs41_daemon.c
+++ b/base/services/nfsd/nfs41_daemon.c
@@ -38,7 +38,8 @@
 #include "upcall.h"
 #include "util.h"
 
-#define MAX_NUM_THREADS 128
+//#define MAX_NUM_THREADS 128
+#define MAX_NUM_THREADS 1
 DWORD NFS41D_VERSION = 0;
 
 #ifndef __REACTOS__
@@ -123,6 +124,7 @@ static unsigned int WINAPI thread_main(void *args)
 }
 
 if (upcall.opcode == NFS41_SHUTDOWN) {
+DbgPrint("Shutdown\n");
 printf("Shutting down..\n");
 exit(0);
 }
@@ -155,6 +157,7 @@ write_downcall:
 #ifndef STANDALONE_NFSD
 VOID ServiceStop()
 {
+   DbgPrint("Setting stop event\n");
if (stop_event)
   SetEvent(stop_event);
 }
@@ -333,8 +336,17 @@ static int getdomainname()
 (socklen_t)ptr->ai_addrlen, hostname, NI_MAXHOST, 
 servInfo, NI_MAXSERV, NI_NAMEREQD);
 if (status)
+#if 0
 dprintf(1, "getnameinfo failed %d\n", WSAGetLastError());
 else {
+#else
+{
+dprintf(1, "getnameinfo failed %d, forcing name\n", 
WSAGetLastError());
+memcpy(hostname, "reactos.home", sizeof("reactos.home"));
+status = 0;
+}
+{
+#endif
 size_t i, len = strlen(hostname);
 char *p = hostname;
 dprintf(1, "getdomainname: hostname %s %d\n", hostname, 
len);
@@ -486,6 +498,8 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
 }
 
 #ifndef STANDALONE_NFSD
+DbgPrint("WaitEvent\n");
+
 stop_event = CreateEvent(NULL, TRUE, FALSE, NULL);
 if (stop_event == NULL)
   goto out_pipe;
@@ -504,6 +518,7 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
 // report the status to the service control manager.
 if (!ReportStatusToSCMgr(SERVICE_RUNNING, NO_ERROR, 0))
 goto out_pipe;
+DbgPrint("Starting wait\n");
 WaitForSingleObject(stop_event, INFINITE);
 #else
 //This can be changed to waiting on an array of handles and using 
waitformultipleobjects
diff --git a/base/services/nfsd/service.c b/base/services/nfsd/service.c
index c31fd143d6..05e83117a8 100644
--- a/base/services/nfsd/service.c
+++ b/base/services/nfsd/service.c
@@ -139,6 +139,8 @@ void WINAPI service_main(DWORD dwArgc, LPTSTR *lpszArgv)
if (!sshStatusHandle)
   goto cleanup;
 
+DbgPrint("Starting service\n");
+
// SERVICE_STATUS members that don't change in example
//
ssStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
@@ -153,9 +155,14 @@ void WINAPI service_main(DWORD dwArgc, LPTSTR *lpszArgv)
3000)) // wait hint
   goto cleanup;
 
+DbgPrint("Starting service 2\n");
+
+   SetConsoleCtrlHandler( ControlHandler, TRUE );
 
ServiceStart( dwArgc, lpszArgv );
 
+DbgPrint("Done\n");
+
cleanup:
 
// try to report the stopped status to the service control manager.
@@ -189,6 +196,9 @@ VOID WINAPI service_ctrl(DWORD dwCtrlCode)
 {
// Handle the requested control code.
//
+
+DbgPrint("service_ctrl called\n");
+
switch (dwCtrlCode)
{
// Stop the service.
@@ -198,9 +208,14 @@ VOID WINAPI service_ctrl(DWORD dwCtrlCode)
// ServiceStop().  This avoids a race condition
// which may result in a 1053 - The Service did not respond...
// error.
+#ifdef __REACTOS__
+   case SERVICE_CONTROL_SHUTDOWN:
+#endif
case SERVICE_CONTROL_STOP:
+  DbgPrint("for stop\n");
   ReportStatusToSCMgr(SERVICE_STOP_PENDING, NO_ERROR, 0);
   ServiceStop();
+DbgPrint("Done\n");
   return;
 
   // Update the service status.
@@ -250,7 +265,11 @@ BOOL ReportStatusToSCMgr(DWORD dwCurrentState,
   if (dwCurrentState == SERVICE_START_PE

[ros-diffs] [reactos] 01/01: [OOPS] That was not meant to be pushed/commited

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

commit 6295cc506eec92b92cfd2947d6bcc29293545b00
Author: Pierre Schweitzer 
AuthorDate: Sun Feb 10 20:52:55 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Feb 10 20:52:55 2019 +0100

[OOPS] That was not meant to be pushed/commited
---
 base/services/nfsd/nfs41_daemon.c| 17 +
 base/services/nfsd/service.c | 19 ---
 dll/win32/ole32/rpc.c|  2 --
 drivers/filesystems/ntfs/fsctl.c |  4 ++--
 modules/rosapps/applications/devutils/CMakeLists.txt |  1 -
 5 files changed, 3 insertions(+), 40 deletions(-)

diff --git a/base/services/nfsd/nfs41_daemon.c 
b/base/services/nfsd/nfs41_daemon.c
index c2f5df2b1b..1a8f2dfbbe 100644
--- a/base/services/nfsd/nfs41_daemon.c
+++ b/base/services/nfsd/nfs41_daemon.c
@@ -38,8 +38,7 @@
 #include "upcall.h"
 #include "util.h"
 
-//#define MAX_NUM_THREADS 128
-#define MAX_NUM_THREADS 1
+#define MAX_NUM_THREADS 128
 DWORD NFS41D_VERSION = 0;
 
 #ifndef __REACTOS__
@@ -124,7 +123,6 @@ static unsigned int WINAPI thread_main(void *args)
 }
 
 if (upcall.opcode == NFS41_SHUTDOWN) {
-DbgPrint("Shutdown\n");
 printf("Shutting down..\n");
 exit(0);
 }
@@ -157,7 +155,6 @@ write_downcall:
 #ifndef STANDALONE_NFSD
 VOID ServiceStop()
 {
-   DbgPrint("Setting stop event\n");
if (stop_event)
   SetEvent(stop_event);
 }
@@ -336,17 +333,8 @@ static int getdomainname()
 (socklen_t)ptr->ai_addrlen, hostname, NI_MAXHOST, 
 servInfo, NI_MAXSERV, NI_NAMEREQD);
 if (status)
-#if 0
 dprintf(1, "getnameinfo failed %d\n", WSAGetLastError());
 else {
-#else
-{
-dprintf(1, "getnameinfo failed %d, forcing name\n", 
WSAGetLastError());
-memcpy(hostname, "reactos.home", sizeof("reactos.home"));
-status = 0;
-}
-{
-#endif
 size_t i, len = strlen(hostname);
 char *p = hostname;
 dprintf(1, "getdomainname: hostname %s %d\n", hostname, 
len);
@@ -498,8 +486,6 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
 }
 
 #ifndef STANDALONE_NFSD
-DbgPrint("WaitEvent\n");
-
 stop_event = CreateEvent(NULL, TRUE, FALSE, NULL);
 if (stop_event == NULL)
   goto out_pipe;
@@ -518,7 +504,6 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
 // report the status to the service control manager.
 if (!ReportStatusToSCMgr(SERVICE_RUNNING, NO_ERROR, 0))
 goto out_pipe;
-DbgPrint("Starting wait\n");
 WaitForSingleObject(stop_event, INFINITE);
 #else
 //This can be changed to waiting on an array of handles and using 
waitformultipleobjects
diff --git a/base/services/nfsd/service.c b/base/services/nfsd/service.c
index 05e83117a8..51da1a00c7 100644
--- a/base/services/nfsd/service.c
+++ b/base/services/nfsd/service.c
@@ -139,8 +139,6 @@ void WINAPI service_main(DWORD dwArgc, LPTSTR *lpszArgv)
if (!sshStatusHandle)
   goto cleanup;
 
-DbgPrint("Starting service\n");
-
// SERVICE_STATUS members that don't change in example
//
ssStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
@@ -155,14 +153,8 @@ void WINAPI service_main(DWORD dwArgc, LPTSTR *lpszArgv)
3000)) // wait hint
   goto cleanup;
 
-DbgPrint("Starting service 2\n");
-
-   SetConsoleCtrlHandler( ControlHandler, TRUE );
-
ServiceStart( dwArgc, lpszArgv );
 
-DbgPrint("Done\n");
-
cleanup:
 
// try to report the stopped status to the service control manager.
@@ -197,8 +189,6 @@ VOID WINAPI service_ctrl(DWORD dwCtrlCode)
// Handle the requested control code.
//
 
-DbgPrint("service_ctrl called\n");
-
switch (dwCtrlCode)
{
// Stop the service.
@@ -208,14 +198,9 @@ VOID WINAPI service_ctrl(DWORD dwCtrlCode)
// ServiceStop().  This avoids a race condition
// which may result in a 1053 - The Service did not respond...
// error.
-#ifdef __REACTOS__
-   case SERVICE_CONTROL_SHUTDOWN:
-#endif
case SERVICE_CONTROL_STOP:
-  DbgPrint("for stop\n");
   ReportStatusToSCMgr(SERVICE_STOP_PENDING, NO_ERROR, 0);
   ServiceStop();
-DbgPrint("Done\n");
   return;
 
   // Update the service status.
@@ -265,11 +250,7 @@ BOOL ReportStatusToSCMgr(DWORD dwCurrentState,
   if (dwCurrentState == SERVICE_START_PENDING)
  ssStatus.dwControlsAccepted = 0;
   else
-#ifndef __REACTOS__
  ssStatus.dwCont

[ros-diffs] [reactos] 01/01: [NTOSKRNL] Simplify object type name printing

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

commit 63b13ad939df6b869d4c92b340dfb950459ae3f1
Author: Pierre Schweitzer 
AuthorDate: Mon Feb 11 09:03:15 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Feb 11 09:03:58 2019 +0100

[NTOSKRNL] Simplify object type name printing
---
 ntoskrnl/ex/handle.c | 55 +---
 1 file changed, 1 insertion(+), 54 deletions(-)

diff --git a/ntoskrnl/ex/handle.c b/ntoskrnl/ex/handle.c
index f75f0363f7..76dcbfcff9 100644
--- a/ntoskrnl/ex/handle.c
+++ b/ntoskrnl/ex/handle.c
@@ -1368,60 +1368,7 @@ BOOLEAN ExpKdbgExtHandle(ULONG Argc, PCHAR Argv[])
 ObjectHeader = ObpGetHandleObject(TableEntry);
 
 KdbpPrint("%p: Object: %p GrantedAccess: %x Entry: %p\n", 
ExHandle.Value, &ObjectHeader->Body, TableEntry->GrantedAccess, TableEntry);
-KdbpPrint("Object: %p Type: (%x) ", &ObjectHeader->Body, 
ObjectHeader->Type);
-if (ObjectHeader->Type == IoFileObjectType)
-{
-KdbpPrint("File");
-}
-else if (ObjectHeader->Type == ExEventObjectType)
-{
-KdbpPrint("Event");
-}
-else if (ObjectHeader->Type == ExEventPairObjectType)
-{
-KdbpPrint("EventPair");
-}
-else if (ObjectHeader->Type == ExMutantObjectType)
-{
-KdbpPrint("Mutant");
-}
-else if (ObjectHeader->Type == ExSemaphoreObjectType)
-{
-KdbpPrint("Semaphore");
-}
-else if (ObjectHeader->Type == ExTimerType)
-{
-KdbpPrint("Timer");
-}
-else if (ObjectHeader->Type == ExWindowStationObjectType)
-{
-KdbpPrint("WindowStation");
-}
-else if (ObjectHeader->Type == ExDesktopObjectType)
-{
-KdbpPrint("Desktop");
-}
-else if (ObjectHeader->Type == ObpDirectoryObjectType)
-{
-KdbpPrint("Directory");
-}
-else if (ObjectHeader->Type == CmpKeyObjectType)
-{
-KdbpPrint("Key");
-}
-else if (ObjectHeader->Type == MmSectionObjectType)
-{
-KdbpPrint("Section");
-}
-else if (ObjectHeader->Type == PsThreadType)
-{
-KdbpPrint("Thread");
-}
-else if (ObjectHeader->Type == LpcPortObjectType)
-{
-KdbpPrint("ALPC Port");
-}
-KdbpPrint("\n");
+KdbpPrint("Object: %p Type: (%x) %wZ\n", &ObjectHeader->Body, 
ObjectHeader->Type, &ObjectHeader->Type->Name);
 KdbpPrint("\tObjectHeader: %p\n", ObjectHeader);
 KdbpPrint("\t\tHandleCount: %u PointerCount: %u\n", 
ObjectHeader->HandleCount, ObjectHeader->PointerCount);
 



[ros-diffs] [reactos] 01/01: [VFATLIB] Don't forcibly delete LFN when not in RW mode

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

commit c9c3622ef12acbd4f2d5e8a633f128a0ecdac22f
Author: Pierre Schweitzer 
AuthorDate: Thu Feb 14 10:12:31 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Thu Feb 14 10:13:32 2019 +0100

[VFATLIB] Don't forcibly delete LFN when not in RW mode
---
 sdk/lib/fslib/vfatlib/check/lfn.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/sdk/lib/fslib/vfatlib/check/lfn.c 
b/sdk/lib/fslib/vfatlib/check/lfn.c
index 17832f80c7..a9af62bde6 100644
--- a/sdk/lib/fslib/vfatlib/check/lfn.c
+++ b/sdk/lib/fslib/vfatlib/check/lfn.c
@@ -526,9 +526,17 @@ void lfn_check_orphaned(void)
 free(long_name);
 if (interactive)
printf("1: Delete.\n2: Leave it.\n");
+#ifdef __REACTOS__
+else if (rw)
+#else
 else
+#endif
printf("  Auto-deleting.\n");
+#ifdef __REACTOS__
+if ((!interactive && rw) || (interactive && get_key("12", "?") == '1')) {
+#else
 if (!interactive || get_key("12", "?") == '1') {
+#endif
clear_lfn_slots(0, lfn_parts - 1);
 }
 lfn_reset();



[ros-diffs] [reactos] 01/01: [FASTFAT] On volume open, update share access if volume was already open

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

commit f36cbf75e3aaf432a46edd145e5d54bc120f7bca
Author: Pierre Schweitzer 
AuthorDate: Thu Feb 14 10:48:32 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Thu Feb 14 10:48:32 2019 +0100

[FASTFAT] On volume open, update share access if volume was already open

It was never updated afterwards, leading to a totally loss of share
access information amongst callers.
---
 drivers/filesystems/fastfat/create.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/filesystems/fastfat/create.c 
b/drivers/filesystems/fastfat/create.c
index 22ce0a54ff..aadc990e37 100644
--- a/drivers/filesystems/fastfat/create.c
+++ b/drivers/filesystems/fastfat/create.c
@@ -523,7 +523,7 @@ VfatCreateFile(
 Stack->Parameters.Create.ShareAccess,
 FileObject,
 &pFcb->FCBShareAccess,
-FALSE);
+TRUE);
 if (!NT_SUCCESS(Status))
 {
 vfatAddToStat(DeviceExt, Fat.FailedCreates, 1);



[ros-diffs] [reactos] 01/03: [IPHLPAPI] Remove dead code

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

commit 22f60faf439c8d6b195085acfd94912de6d214af
Author: Pierre Schweitzer 
AuthorDate: Sat Feb 16 08:48:08 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Feb 16 08:48:08 2019 +0100

[IPHLPAPI] Remove dead code

CID 513306, 1442673, 1442697
---
 dll/win32/iphlpapi/ipstats_reactos.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/dll/win32/iphlpapi/ipstats_reactos.c 
b/dll/win32/iphlpapi/ipstats_reactos.c
index 5906388fc4..6bf3df63e9 100644
--- a/dll/win32/iphlpapi/ipstats_reactos.c
+++ b/dll/win32/iphlpapi/ipstats_reactos.c
@@ -524,7 +524,6 @@ DWORD getNumArpEntries(void)
 }
 
 closeTcpFile( tcpFile );
-if( IpArpTable ) tdiFreeThingSet( IpArpTable );
 if( entitySet ) tdiFreeThingSet( entitySet );
 return totalNumber;
 }
@@ -649,7 +648,6 @@ DWORD getNumUdpEntries(void)
 }
 
 closeTcpFile( tcpFile );
-if( IpUdpTable ) tdiFreeThingSet( IpUdpTable );
 if( entitySet ) tdiFreeThingSet( entitySet );
 return totalNumber;
 }
@@ -761,7 +759,6 @@ DWORD getNumTcpEntries(void)
 }
 
 closeTcpFile( tcpFile );
-if( IpTcpTable ) tdiFreeThingSet( IpTcpTable );
 if( entitySet ) tdiFreeThingSet( entitySet );
 return totalNumber;
 }



[ros-diffs] [reactos] 02/03: [IPHLPAPI] Check pointers when returning module info from specific connection

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

commit 93b0957641f1b8c831152aa6fdfc43e2d528f9b4
Author: Pierre Schweitzer 
AuthorDate: Sat Feb 16 09:00:06 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Feb 16 09:00:06 2019 +0100

[IPHLPAPI] Check pointers when returning module info from specific 
connection
---
 dll/win32/iphlpapi/iphlpapi_main.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/dll/win32/iphlpapi/iphlpapi_main.c 
b/dll/win32/iphlpapi/iphlpapi_main.c
index 83d53d2b10..5993c74f98 100644
--- a/dll/win32/iphlpapi/iphlpapi_main.c
+++ b/dll/win32/iphlpapi/iphlpapi_main.c
@@ -2293,6 +2293,12 @@ static DWORD GetOwnerModuleFromPidEntry(DWORD OwningPid, 
TCPIP_OWNER_MODULE_INFO
 WCHAR File[MAX_PATH], Path[MAX_PATH];
 PTCPIP_OWNER_MODULE_BASIC_INFO BasicInfo;
 
+if (IsBadWritePtr(pdwSize, sizeof(DWORD)) ||
+IsBadWritePtr(Buffer, *pdwSize))
+{
+return ERROR_INVALID_PARAMETER;
+}
+
 if (OwningPid == 0)
 {
 return ERROR_NOT_FOUND;
@@ -2363,6 +2369,12 @@ static DWORD GetOwnerModuleFromTagEntry(DWORD OwningPid, 
DWORD OwningTag, TCPIP_
 PWSTR Buffer;
 } ServiceQuery;
 
+if (IsBadWritePtr(pdwSize, sizeof(DWORD)) ||
+IsBadWritePtr(Buffer, *pdwSize))
+{
+return ERROR_INVALID_PARAMETER;
+}
+
 /* First, secure (avoid injections) load advapi32.dll */
 Size = GetSystemDirectoryW(SysDir, MAX_PATH);
 if (Size == 0)



[ros-diffs] [reactos] 03/03: [IPHLPAPI] Properly handle GetModuleBaseName failure

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

commit 22cb300805a6dd39c73bb8ee39bbc390dd8eb5cc
Author: Pierre Schweitzer 
AuthorDate: Sat Feb 16 09:05:15 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Feb 16 09:05:15 2019 +0100

[IPHLPAPI] Properly handle GetModuleBaseName failure

CID 1442662, 1442663
---
 dll/win32/iphlpapi/iphlpapi_main.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/dll/win32/iphlpapi/iphlpapi_main.c 
b/dll/win32/iphlpapi/iphlpapi_main.c
index 5993c74f98..327b31717a 100644
--- a/dll/win32/iphlpapi/iphlpapi_main.c
+++ b/dll/win32/iphlpapi/iphlpapi_main.c
@@ -2289,7 +2289,7 @@ DWORD WINAPI GetNumberOfInterfaces(PDWORD pdwNumIf)
 static DWORD GetOwnerModuleFromPidEntry(DWORD OwningPid, 
TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
 {
 HANDLE Process;
-DWORD FileLen, PathLen;
+DWORD FileLen, PathLen, Error;
 WCHAR File[MAX_PATH], Path[MAX_PATH];
 PTCPIP_OWNER_MODULE_BASIC_INFO BasicInfo;
 
@@ -2326,13 +2326,23 @@ static DWORD GetOwnerModuleFromPidEntry(DWORD 
OwningPid, TCPIP_OWNER_MODULE_INFO
 PathLen *= sizeof(WCHAR);
 FileLen *= sizeof(WCHAR);
 }
-else if (GetLastError() == ERROR_PARTIAL_COPY)
+else
 {
-wcscpy(File, L"System");
-wcscpy(Path, L"System");
+Error = GetLastError();
+
+if (Error == ERROR_PARTIAL_COPY)
+{
+wcscpy(File, L"System");
+wcscpy(Path, L"System");
 
-PathLen = sizeof(L"System");
-FileLen = sizeof(L"System");
+PathLen = sizeof(L"System");
+FileLen = sizeof(L"System");
+}
+else
+{
+CloseHandle(Process);
+return Error;
+}
 }
 
 CloseHandle(Process);



[ros-diffs] [reactos] 02/02: [E1000] Remove useless null check

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

commit 24b2d59ab6a379512215930ed1f27c25175a6483
Author: Pierre Schweitzer 
AuthorDate: Sat Feb 16 10:01:50 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Feb 16 10:02:29 2019 +0100

[E1000] Remove useless null check

CID 512827
---
 drivers/network/dd/e1000/ndis.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/network/dd/e1000/ndis.c b/drivers/network/dd/e1000/ndis.c
index 2e713dfcb6..d6074cb5a2 100644
--- a/drivers/network/dd/e1000/ndis.c
+++ b/drivers/network/dd/e1000/ndis.c
@@ -286,10 +286,8 @@ Cleanup:
 {
 NdisFreeMemory(ResourceList, ResourceListSize, 0);
 }
-if (Adapter != NULL)
-{
-MiniportHalt(Adapter);
-}
+
+MiniportHalt(Adapter);
 
 return Status;
 }



[ros-diffs] [reactos] 01/02: [E1000] Don't attempt to free uninitialized pointer

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

commit e1f4d2864a100c175e5fd708733001a13313150c
Author: Pierre Schweitzer 
AuthorDate: Sat Feb 16 09:58:44 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Feb 16 10:02:28 2019 +0100

[E1000] Don't attempt to free uninitialized pointer

CID 1442660
---
 drivers/network/dd/e1000/ndis.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/network/dd/e1000/ndis.c b/drivers/network/dd/e1000/ndis.c
index f73bf5e89d..2e713dfcb6 100644
--- a/drivers/network/dd/e1000/ndis.c
+++ b/drivers/network/dd/e1000/ndis.c
@@ -116,6 +116,9 @@ MiniportInitialize(
 return NDIS_STATUS_UNSUPPORTED_MEDIA;
 }
 
+ResourceList = NULL;
+ResourceListSize = 0;
+
 /* Allocate our adapter context */
 Status = NdisAllocateMemoryWithTag((PVOID*)&Adapter,
sizeof(*Adapter),
@@ -155,10 +158,7 @@ MiniportInitialize(
 goto Cleanup;
 }
 
-
 /* Get our resources for IRQ and IO base information */
-ResourceList = NULL;
-ResourceListSize = 0;
 NdisMQueryAdapterResources(&Status,
WrapperConfigurationContext,
ResourceList,



[ros-diffs] [reactos] 01/01: [MSAFD] Add an initial implementation of SIO_GET_EXTENSION_FUNCTION_POINTER IOCTL

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

commit 2b1f6c8b0d73b80c9aeaf8808c66c0c52eb1f320
Author: Pierre Schweitzer 
AuthorDate: Sat Feb 16 13:46:40 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Feb 16 13:51:32 2019 +0100

[MSAFD] Add an initial implementation of SIO_GET_EXTENSION_FUNCTION_POINTER 
IOCTL

Also stub the related functions the IOCTL will return, namely: 
WSAID_ACCEPTEX,
WSAID_CONNECTEX, WSAID_DISCONNECTEX, WSAID_GETACCEPTEXSOCKADDRS

This will allow Steam client not to fail in an ASSERT
related to the Steam client PlatformSocketsInit function.

Even though, this doesn't fix Steam running on ReactOS since its UI requires
a Windows 7 API from Kernel32: SetThreadErrorMode().

Nota: its crash got fixed thanks to the Wine sync done recently.

CORE-14966
---
 dll/win32/msafd/misc/dllmain.c | 57 ++-
 dll/win32/msafd/misc/stubs.c   | 61 ++
 dll/win32/msafd/msafd.h| 42 +
 3 files changed, 159 insertions(+), 1 deletion(-)

diff --git a/dll/win32/msafd/misc/dllmain.c b/dll/win32/msafd/misc/dllmain.c
index 5ec1bc151a..e604d2f15a 100644
--- a/dll/win32/msafd/misc/dllmain.c
+++ b/dll/win32/msafd/misc/dllmain.c
@@ -5,6 +5,7 @@
  * PURPOSE: DLL entry point
  * PROGRAMMERS: Casper S. Hornstrup (cho...@users.sourceforge.net)
  *  Alex Ionescu (a...@relsoft.net)
+ *  Pierre Schweitzer (pie...@reactos.org)
  * REVISIONS:
  *  CSH 01/09-2000 Created
  *  Alex 16/07/2004 - Complete Rewrite
@@ -2466,7 +2467,61 @@ WSPIoctl(IN  SOCKET Handle,
 Ret = NO_ERROR;
 break;
 case SIO_GET_EXTENSION_FUNCTION_POINTER:
-Errno = WSAEINVAL;
+if (cbOutBuffer == 0)
+{
+cbRet = sizeof(PVOID);
+Errno = WSAEFAULT;
+break;
+}
+
+if (cbInBuffer < sizeof(GUID) ||
+cbOutBuffer < sizeof(PVOID))
+{
+Errno = WSAEINVAL;
+break;
+}
+
+{
+GUID AcceptExGUID = WSAID_ACCEPTEX;
+GUID ConnectExGUID = WSAID_CONNECTEX;
+GUID DisconnectExGUID = WSAID_DISCONNECTEX;
+GUID GetAcceptExSockaddrsGUID = WSAID_GETACCEPTEXSOCKADDRS;
+
+if (IsEqualGUID(&AcceptExGUID, lpvInBuffer))
+{
+*((PVOID *)lpvOutBuffer) = WSPAcceptEx;
+cbRet = sizeof(PVOID);
+Errno = NO_ERROR;
+Ret = NO_ERROR;
+}
+else if (IsEqualGUID(&ConnectExGUID, lpvInBuffer))
+{
+*((PVOID *)lpvOutBuffer) = WSPConnectEx;
+cbRet = sizeof(PVOID);
+Errno = NO_ERROR;
+Ret = NO_ERROR;
+}
+else if (IsEqualGUID(&DisconnectExGUID, lpvInBuffer))
+{
+*((PVOID *)lpvOutBuffer) = WSPDisconnectEx;
+cbRet = sizeof(PVOID);
+Errno = NO_ERROR;
+Ret = NO_ERROR;
+}
+else if (IsEqualGUID(&GetAcceptExSockaddrsGUID, lpvInBuffer))
+{
+*((PVOID *)lpvOutBuffer) = WSPGetAcceptExSockaddrs;
+cbRet = sizeof(PVOID);
+Errno = NO_ERROR;
+Ret = NO_ERROR;
+}
+else
+{
+ERR("Querying unknown extension function: %x\n", 
((GUID*)lpvInBuffer)->Data1);
+Errno = WSAEOPNOTSUPP;
+}
+}
+
 break;
 case SIO_ADDRESS_LIST_QUERY:
 if (IS_INTRESOURCE(lpvOutBuffer) || cbOutBuffer == 0)
diff --git a/dll/win32/msafd/misc/stubs.c b/dll/win32/msafd/misc/stubs.c
index 2ee41289cd..74d13c188b 100644
--- a/dll/win32/msafd/misc/stubs.c
+++ b/dll/win32/msafd/misc/stubs.c
@@ -53,4 +53,65 @@ WSPJoinLeaf(
 return (SOCKET)0;
 }
 
+BOOL
+WSPAPI
+WSPAcceptEx(
+IN SOCKET sListenSocket,
+IN SOCKET sAcceptSocket,
+OUT PVOID lpOutputBuffer,
+IN DWORD dwReceiveDataLength,
+IN DWORD dwLocalAddressLength,
+IN DWORD dwRemoteAddressLength,
+OUT LPDWORD lpdwBytesReceived,
+IN OUT LPOVERLAPPED lpOverlapped)
+{
+UNIMPLEMENTED;
+
+return FALSE;
+}
+
+BOOL
+WSPAPI
+WSPConnectEx(
+IN SOCKET s,
+IN const struct sockaddr *name,
+IN int namelen,
+IN PVOID lpSendBuffer,
+IN DWORD dwSendDataLength,
+OUT LPDWORD lpdwBytesSent,
+IN OUT LPOVERLAPPED lpOverlapped)
+{
+UNIMPLEMENTED;
+
+return FALSE;
+}
+
+BOOL
+WSPAPI
+WSPDisconnectEx(
+  IN SOCKET hSocket,
+  IN LPOVER

[ros-diffs] [reactos] 01/01: [KERNEL32] Stub SetThreadErrorMode()

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

commit db3f3921b6f7bab5f603a7573836d09113966541
Author: Pierre Schweitzer 
AuthorDate: Sat Feb 16 14:12:01 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Feb 16 14:12:55 2019 +0100

[KERNEL32] Stub SetThreadErrorMode()

Now, Steam crashes because of the stub of GetSystemTimePreciseAsFileTime

CORE-14966
---
 dll/win32/kernel32/kernel32.spec | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/dll/win32/kernel32/kernel32.spec b/dll/win32/kernel32/kernel32.spec
index f3ee418b65..c9176d89a3 100644
--- a/dll/win32/kernel32/kernel32.spec
+++ b/dll/win32/kernel32/kernel32.spec
@@ -617,6 +617,7 @@
 @ stdcall GetTempPathA(long ptr)
 @ stdcall GetTempPathW(long ptr)
 @ stdcall GetThreadContext(long ptr)
+@ stub -version=0x600+ GetThreadErrorMode
 @ stdcall GetThreadIOPendingFlag(long ptr)
 @ stdcall GetThreadId(ptr)
 @ stdcall GetThreadLocale()
@@ -1068,6 +1069,7 @@
 @ stdcall SetTermsrvAppInstallMode(long)
 @ stdcall SetThreadAffinityMask(long long)
 @ stdcall SetThreadContext(long ptr)
+@ stub -version=0x600+ SetThreadErrorMode
 @ stdcall SetThreadExecutionState(long)
 @ stdcall SetThreadIdealProcessor(long long)
 @ stdcall SetThreadLocale(long)



[ros-diffs] [reactos] 01/01: [VIDEOPRT] Don't return uninitialized memory

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

commit 0996dac6830589d308261570823fe58a0da426c3
Author: Pierre Schweitzer 
AuthorDate: Wed Feb 20 21:01:46 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Wed Feb 20 21:02:11 2019 +0100

[VIDEOPRT] Don't return uninitialized memory
---
 win32ss/drivers/videoprt/event.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/win32ss/drivers/videoprt/event.c b/win32ss/drivers/videoprt/event.c
index 99c6b39dd1..c4cf2d272f 100644
--- a/win32ss/drivers/videoprt/event.c
+++ b/win32ss/drivers/videoprt/event.c
@@ -35,6 +35,9 @@ VideoPortCreateEvent(IN PVOID HwDeviceExtension,
  TAG_VIDEO_PORT);
 if (EngEvent)
 {
+/* Zero flags */
+EngEvent->fFlags = 0;
+
 /* Set KEVENT pointer */
 EngEvent->pKEvent = EngEvent + 1;
 



[ros-diffs] [reactos] 01/01: [WS2_32] Implement WSCGetProviderPath()

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

commit 02e84521cc6dbab2131927a87c81317fcf601116
Author: Pierre Schweitzer 
AuthorDate: Sat Feb 23 10:57:06 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Feb 23 10:57:30 2019 +0100

[WS2_32] Implement WSCGetProviderPath()
---
 dll/win32/ws2_32/inc/ws2_32p.h  |  10 
 dll/win32/ws2_32/src/enumprot.c | 116 ++--
 2 files changed, 122 insertions(+), 4 deletions(-)

diff --git a/dll/win32/ws2_32/inc/ws2_32p.h b/dll/win32/ws2_32/inc/ws2_32p.h
index 5e7f5d6782..968c6ce7b8 100644
--- a/dll/win32/ws2_32/inc/ws2_32p.h
+++ b/dll/win32/ws2_32/inc/ws2_32p.h
@@ -232,6 +232,16 @@ typedef struct _PROTOCOL_ENUM_CONTEXT
 INT ErrorCode;
 } PROTOCOL_ENUM_CONTEXT, *PPROTOCOL_ENUM_CONTEXT;
 
+typedef struct _PROVIDER_ENUM_CONTEXT
+{
+GUID ProviderId;
+LPWSTR ProviderDllPath;
+INT ProviderDllPathLen;
+DWORD FoundPathLen;
+DWORD Found;
+INT ErrorCode;
+} PROVIDER_ENUM_CONTEXT, *PPROVIDER_ENUM_CONTEXT;
+
 typedef struct _WS_BUFFER
 {
 ULONG_PTR Position;
diff --git a/dll/win32/ws2_32/src/enumprot.c b/dll/win32/ws2_32/src/enumprot.c
index 4d04ea30f5..a47b290104 100644
--- a/dll/win32/ws2_32/src/enumprot.c
+++ b/dll/win32/ws2_32/src/enumprot.c
@@ -4,6 +4,7 @@
  * FILE:dll/win32/ws2_32_new/src/enumprot.c
  * PURPOSE: Protocol Enumeration
  * PROGRAMMER:  Alex Ionescu (a...@relsoft.net)
+ *  Pierre Schweitzer
  */
 
 /* INCLUDES **/
@@ -98,6 +99,39 @@ ProtocolEnumerationProc(PVOID EnumContext,
 return TRUE;
 }
 
+BOOL
+WSAAPI
+ProviderEnumerationProc(PVOID EnumContext,
+PNSCATALOG_ENTRY Entry)
+{
+INT PathLen;
+PPROVIDER_ENUM_CONTEXT Context = (PPROVIDER_ENUM_CONTEXT)EnumContext;
+
+/* Check if this provider matches */
+if (IsEqualGUID(&Entry->ProviderId, &Context->ProviderId))
+{
+/* Get the information about the provider */
+PathLen = wcslen(Entry->DllPath) + 1;
+Context->FoundPathLen = PathLen;
+Context->Found = 1;
+
+/* If we have enough room, copy path */
+if (PathLen <= Context->ProviderDllPathLen)
+{
+wcscpy(Context->ProviderDllPath, Entry->DllPath);
+}
+
+/* Stop enumeration */
+return FALSE;
+}
+else
+{
+/* Continue enumeration */
+return TRUE;
+}
+
+}
+
 PTCATALOG
 WSAAPI
 OpenInitializedCatalog(VOID)
@@ -284,7 +318,7 @@ WSAProviderConfigChange(IN OUT LPHANDLE 
lpNotificationHandle,
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 INT
 WSPAPI
@@ -293,8 +327,82 @@ WSCGetProviderPath(IN LPGUID lpProviderId,
IN OUT LPINT lpProviderDllPathLen,
OUT LPINT lpErrno)
 {
+PWSTHREAD Thread;
+PWSPROCESS Process;
+PNSCATALOG Catalog;
+INT ErrorCode, PathLen;
+PROVIDER_ENUM_CONTEXT Context;
+
 DPRINT("WSCGetProviderPath: %p %p %p %p\n", lpProviderId, 
lpszProviderDllPath, lpProviderDllPathLen, lpErrno);
-UNIMPLEMENTED;
-SetLastError(WSAEINVAL);
-return SOCKET_ERROR;
+
+/* Enter prolog */
+if ((ErrorCode = WsApiProlog(&Process, &Thread)) != ERROR_SUCCESS)
+{
+/* FIXME: if WSANOTINITIALISED, we should init
+ * and perform the search!
+ */
+
+/* Leave now */
+*lpErrno = ErrorCode;
+return SOCKET_ERROR;
+}
+
+/* Get the catalog */
+Catalog = WsProcGetNsCatalog(Process);
+
+/* Setup the context */
+Context.ProviderId = *lpProviderId;
+Context.ProviderDllPath = lpszProviderDllPath;
+Context.ProviderDllPathLen = *lpProviderDllPathLen;
+Context.FoundPathLen = 0;
+Context.Found = 0;
+Context.ErrorCode = ERROR_SUCCESS;
+
+ErrorCode = ERROR_SUCCESS;
+
+/* Enumerate the catalog */
+WsNcEnumerateCatalogItems(Catalog, ProviderEnumerationProc, &Context);
+
+/* Check the error code */
+if (Context.ErrorCode == ERROR_SUCCESS)
+{
+/* Check if provider was found */
+if (Context.Found)
+{
+PathLen = Context.FoundPathLen;
+
+/* Check whether buffer is too small
+ * If it isn't, return length without null char
+ * (see ProviderEnumerationProc)
+ */
+if (Context.FoundPathLen <= *lpProviderDllPathLen)
+{
+PathLen = Context.FoundPathLen - 1;
+}
+else
+{
+ErrorCode = WSAEFAULT;
+}
+
+/* Set returned/required length */
+*lpProviderDllPathLen = PathLen;
+}
+else
+{
+ErrorCode = WSAEINVAL;
+}
+}
+else
+{
+ErrorCode = Context.ErrorCode;
+}
+
+/* Do we have to return failure? */
+if 

[ros-diffs] [reactos] 01/01: [WS2_32] Use SEH in WSCGetProviderPath()

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

commit d1598788cdf827ce5616d545d2a96f6aa41e2ed1
Author: Pierre Schweitzer 
AuthorDate: Sat Feb 23 13:34:28 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Feb 23 13:35:07 2019 +0100

[WS2_32] Use SEH in WSCGetProviderPath()
---
 dll/win32/ws2_32/src/enumprot.c | 68 +++--
 1 file changed, 38 insertions(+), 30 deletions(-)

diff --git a/dll/win32/ws2_32/src/enumprot.c b/dll/win32/ws2_32/src/enumprot.c
index a47b290104..be1ff596cc 100644
--- a/dll/win32/ws2_32/src/enumprot.c
+++ b/dll/win32/ws2_32/src/enumprot.c
@@ -350,52 +350,60 @@ WSCGetProviderPath(IN LPGUID lpProviderId,
 /* Get the catalog */
 Catalog = WsProcGetNsCatalog(Process);
 
-/* Setup the context */
-Context.ProviderId = *lpProviderId;
-Context.ProviderDllPath = lpszProviderDllPath;
-Context.ProviderDllPathLen = *lpProviderDllPathLen;
-Context.FoundPathLen = 0;
-Context.Found = 0;
-Context.ErrorCode = ERROR_SUCCESS;
+_SEH2_TRY
+{
+/* Setup the context */
+Context.ProviderId = *lpProviderId;
+Context.ProviderDllPath = lpszProviderDllPath;
+Context.ProviderDllPathLen = *lpProviderDllPathLen;
+Context.FoundPathLen = 0;
+Context.Found = 0;
+Context.ErrorCode = ERROR_SUCCESS;
 
-ErrorCode = ERROR_SUCCESS;
+ErrorCode = ERROR_SUCCESS;
 
-/* Enumerate the catalog */
-WsNcEnumerateCatalogItems(Catalog, ProviderEnumerationProc, &Context);
+/* Enumerate the catalog */
+WsNcEnumerateCatalogItems(Catalog, ProviderEnumerationProc, &Context);
 
-/* Check the error code */
-if (Context.ErrorCode == ERROR_SUCCESS)
-{
-/* Check if provider was found */
-if (Context.Found)
+/* Check the error code */
+if (Context.ErrorCode == ERROR_SUCCESS)
 {
-PathLen = Context.FoundPathLen;
-
-/* Check whether buffer is too small
- * If it isn't, return length without null char
- * (see ProviderEnumerationProc)
- */
-if (Context.FoundPathLen <= *lpProviderDllPathLen)
+/* Check if provider was found */
+if (Context.Found)
 {
-PathLen = Context.FoundPathLen - 1;
+PathLen = Context.FoundPathLen;
+
+/* Check whether buffer is too small
+ * If it isn't, return length without null char
+ * (see ProviderEnumerationProc)
+ */
+if (Context.FoundPathLen <= *lpProviderDllPathLen)
+{
+PathLen = Context.FoundPathLen - 1;
+}
+else
+{
+ErrorCode = WSAEFAULT;
+}
+
+/* Set returned/required length */
+*lpProviderDllPathLen = PathLen;
 }
 else
 {
-ErrorCode = WSAEFAULT;
+ErrorCode = WSAEINVAL;
 }
-
-/* Set returned/required length */
-*lpProviderDllPathLen = PathLen;
 }
 else
 {
-ErrorCode = WSAEINVAL;
+ErrorCode = Context.ErrorCode;
 }
 }
-else
+_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
 {
-ErrorCode = Context.ErrorCode;
+ErrorCode = WSAEFAULT;
 }
+_SEH2_END;
 
 /* Do we have to return failure? */
 if (ErrorCode != ERROR_SUCCESS)



[ros-diffs] [reactos] 01/01: [MSAFD] Make WSPSetSockOpt() SO_RCVBUF stub return success

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

commit f6c50cb93d50cd988b8a620b671f69db97b7adc9
Author: Pierre Schweitzer 
AuthorDate: Sun Feb 24 21:25:39 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Feb 24 21:25:39 2019 +0100

[MSAFD] Make WSPSetSockOpt() SO_RCVBUF stub return success
---
 dll/win32/msafd/misc/dllmain.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/dll/win32/msafd/misc/dllmain.c b/dll/win32/msafd/misc/dllmain.c
index e604d2f15a..c761cff13e 100644
--- a/dll/win32/msafd/misc/dllmain.c
+++ b/dll/win32/msafd/misc/dllmain.c
@@ -2870,6 +2870,17 @@ WSPSetSockOpt(
   ERR("Setting send buf to %x is not implemented yet\n", optval);
   return NO_ERROR;
 
+   case SO_RCVBUF:
+  if (optlen < sizeof(DWORD))
+  {
+  if (lpErrno) *lpErrno = WSAEFAULT;
+  return SOCKET_ERROR;
+  }
+
+  /* TODO: The total per-socket buffer space reserved for receives 
*/
+  ERR("Setting receive buf to %x is not implemented yet\n", 
optval);
+  return NO_ERROR;
+
case SO_ERROR:
   if (optlen < sizeof(INT))
   {



[ros-diffs] [reactos] 03/05: [AFD_APITEST] Add apitest for AFD window size options

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

commit 6bf5a8a43dca1672a84a8e519edc2ba7d4c354e6
Author: Pierre Schweitzer 
AuthorDate: Mon Feb 25 22:28:18 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Feb 25 22:34:28 2019 +0100

[AFD_APITEST] Add apitest for AFD window size options
---
 modules/rostests/apitests/afd/AfdHelpers.c   | 124 +++
 modules/rostests/apitests/afd/AfdHelpers.h   |  17 ++
 modules/rostests/apitests/afd/CMakeLists.txt |   1 +
 modules/rostests/apitests/afd/testlist.c |   2 +
 modules/rostests/apitests/afd/windowsize.c   | 306 +++
 5 files changed, 450 insertions(+)

diff --git a/modules/rostests/apitests/afd/AfdHelpers.c 
b/modules/rostests/apitests/afd/AfdHelpers.c
index ad7793efd7..702a8f0cfb 100644
--- a/modules/rostests/apitests/afd/AfdHelpers.c
+++ b/modules/rostests/apitests/afd/AfdHelpers.c
@@ -3,6 +3,7 @@
  * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
  * PURPOSE: Utility function definitions for calling AFD
  * COPYRIGHT:   Copyright 2015-2018 Thomas Faber (thomas.fa...@reactos.org)
+ *  Copyright 2019 Pierre Schweitzer (pie...@reactos.org)
  */
 
 #include "precomp.h"
@@ -382,3 +383,126 @@ AfdSendTo(
 
 return Status;
 }
+
+NTSTATUS
+AfdSetInformation(
+_In_ HANDLE SocketHandle,
+_In_ ULONG InformationClass,
+_In_opt_ PBOOLEAN Boolean,
+_In_opt_ PULONG Ulong,
+_In_opt_ PLARGE_INTEGER LargeInteger)
+{
+NTSTATUS Status;
+IO_STATUS_BLOCK IoStatus;
+AFD_INFO InfoData;
+HANDLE Event;
+
+Status = NtCreateEvent(&Event,
+   EVENT_ALL_ACCESS,
+   NULL,
+   NotificationEvent,
+   FALSE);
+if (!NT_SUCCESS(Status))
+{
+return Status;
+}
+
+InfoData.InformationClass = InformationClass;
+
+if (Ulong != NULL)
+{
+InfoData.Information.Ulong = *Ulong;
+}
+if (LargeInteger != NULL)
+{
+InfoData.Information.LargeInteger = *LargeInteger;
+}
+if (Boolean != NULL)
+{
+InfoData.Information.Boolean = *Boolean;
+}
+
+Status = NtDeviceIoControlFile(SocketHandle,
+   Event,
+   NULL,
+   NULL,
+   &IoStatus,
+   IOCTL_AFD_SET_INFO,
+   &InfoData,
+   sizeof(InfoData),
+   NULL,
+   0);
+if (Status == STATUS_PENDING)
+{
+NtWaitForSingleObject(Event, FALSE, NULL);
+Status = IoStatus.Status;
+}
+
+NtClose(Event);
+
+return Status;
+}
+
+NTSTATUS
+AfdGetInformation(
+_In_ HANDLE SocketHandle,
+_In_ ULONG InformationClass,
+_In_opt_ PBOOLEAN Boolean,
+_In_opt_ PULONG Ulong,
+_In_opt_ PLARGE_INTEGER LargeInteger)
+{
+NTSTATUS Status;
+IO_STATUS_BLOCK IoStatus;
+AFD_INFO InfoData;
+HANDLE Event;
+
+Status = NtCreateEvent(&Event,
+   EVENT_ALL_ACCESS,
+   NULL,
+   NotificationEvent,
+   FALSE);
+if (!NT_SUCCESS(Status))
+{
+return Status;
+}
+
+InfoData.InformationClass = InformationClass;
+
+Status = NtDeviceIoControlFile(SocketHandle,
+   Event,
+   NULL,
+   NULL,
+   &IoStatus,
+   IOCTL_AFD_GET_INFO,
+   &InfoData,
+   sizeof(InfoData),
+   &InfoData,
+   sizeof(InfoData));
+if (Status == STATUS_PENDING)
+{
+NtWaitForSingleObject(Event, FALSE, NULL);
+Status = IoStatus.Status;
+}
+
+NtClose(Event);
+
+if (Status != STATUS_SUCCESS)
+{
+return Status;
+}
+
+if (Ulong != NULL)
+{
+*Ulong = InfoData.Information.Ulong;
+}
+if (LargeInteger != NULL)
+{
+*LargeInteger = InfoData.Information.LargeInteger;
+}
+if (Boolean != NULL)
+{
+*Boolean = InfoData.Information.Boolean;
+}
+
+return Status;
+}
diff --git a/modules/rostests/apitests/afd/AfdHelpers.h 
b/modules/rostests/apitests/afd/AfdHelpers.h
index fadd03d563..0afcef5231 100644
--- a/modules/rostests/apitests/afd/AfdHelpers.h
+++ b/modules/rostests/apitests/afd/AfdHelpers.h
@@ -3,6 +3,7 @@
  * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
  * PURPOSE: Utility function declarations for calling AFD
  * COPYRIGHT:   Copyright 2015 Thomas Faber (thomas.fa...@reacto

[ros-diffs] [reactos] 04/05: [MSAFD] Implement socket options SO_SNDBUF and SO_RCVBUF

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

commit 6bc61f63f1e0ad20ab09f881d6968558eba9a8e6
Author: Pierre Schweitzer 
AuthorDate: Mon Feb 25 22:30:01 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Feb 25 22:34:29 2019 +0100

[MSAFD] Implement socket options SO_SNDBUF and SO_RCVBUF
---
 dll/win32/msafd/misc/dllmain.c | 34 ++
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/dll/win32/msafd/misc/dllmain.c b/dll/win32/msafd/misc/dllmain.c
index c761cff13e..520cf1a3ce 100644
--- a/dll/win32/msafd/misc/dllmain.c
+++ b/dll/win32/msafd/misc/dllmain.c
@@ -2866,8 +2866,21 @@ WSPSetSockOpt(
   return SOCKET_ERROR;
   }
 
-  /* TODO: The total per-socket buffer space reserved for sends */
-  ERR("Setting send buf to %x is not implemented yet\n", optval);
+  SetSocketInformation(Socket,
+   AFD_INFO_SEND_WINDOW_SIZE,
+   NULL,
+   (PULONG)optval,
+   NULL,
+   NULL,
+   NULL);
+  GetSocketInformation(Socket,
+   AFD_INFO_SEND_WINDOW_SIZE,
+   NULL,
+   &Socket->SharedData->SizeOfSendBuffer,
+   NULL,
+   NULL,
+   NULL);
+
   return NO_ERROR;
 
case SO_RCVBUF:
@@ -2877,8 +2890,21 @@ WSPSetSockOpt(
   return SOCKET_ERROR;
   }
 
-  /* TODO: The total per-socket buffer space reserved for receives 
*/
-  ERR("Setting receive buf to %x is not implemented yet\n", 
optval);
+  SetSocketInformation(Socket,
+   AFD_INFO_RECEIVE_WINDOW_SIZE,
+   NULL,
+   (PULONG)optval,
+   NULL,
+   NULL,
+   NULL);
+  GetSocketInformation(Socket,
+   AFD_INFO_RECEIVE_WINDOW_SIZE,
+   NULL,
+   &Socket->SharedData->SizeOfSendBuffer,
+   NULL,
+   NULL,
+   NULL);
+
   return NO_ERROR;
 
case SO_ERROR:



[ros-diffs] [reactos] 02/05: [AFD] Don't allow caller to set broken values to window sizes

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

commit 86483d6e222e42f3faefeac280f988cf8437736d
Author: Pierre Schweitzer 
AuthorDate: Mon Feb 25 22:27:00 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Feb 25 22:34:28 2019 +0100

[AFD] Don't allow caller to set broken values to window sizes

This will avoid 0-sized allocations, or -1-sized allocations.
So far, it's maxed by hard value stored in TCPIP.sys. I believe
this is not right and would deserve a true fix
---
 drivers/network/afd/afd/info.c | 111 ++---
 1 file changed, 71 insertions(+), 40 deletions(-)

diff --git a/drivers/network/afd/afd/info.c b/drivers/network/afd/afd/info.c
index 1c05842e4e..c780eb86a2 100644
--- a/drivers/network/afd/afd/info.c
+++ b/drivers/network/afd/afd/info.c
@@ -124,61 +124,92 @@ AfdSetInfo( PDEVICE_OBJECT DeviceObject, PIRP Irp,
 FCB->OobInline = InfoReq->Information.Boolean;
 break;
 case AFD_INFO_RECEIVE_WINDOW_SIZE:
-NewBuffer = ExAllocatePoolWithTag(PagedPool,
-  InfoReq->Information.Ulong,
-  TAG_AFD_DATA_BUFFER);
-
-if (NewBuffer)
+if (FCB->State == SOCKET_STATE_CONNECTED ||
+FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS)
 {
-if (FCB->Recv.Content > InfoReq->Information.Ulong)
-FCB->Recv.Content = InfoReq->Information.Ulong;
-
-if (FCB->Recv.Window)
+/* FIXME: likely not right, check tcpip.sys for 
TDI_QUERY_MAX_DATAGRAM_INFO */
+if (InfoReq->Information.Ulong > 0 && 
InfoReq->Information.Ulong < 0x)
 {
-RtlCopyMemory(NewBuffer,
-  FCB->Recv.Window,
-  FCB->Recv.Content);
-
-ExFreePoolWithTag(FCB->Recv.Window, 
TAG_AFD_DATA_BUFFER);
+NewBuffer = ExAllocatePoolWithTag(PagedPool,
+  
InfoReq->Information.Ulong,
+  TAG_AFD_DATA_BUFFER);
+
+if (NewBuffer)
+{
+if (FCB->Recv.Content > InfoReq->Information.Ulong)
+FCB->Recv.Content = InfoReq->Information.Ulong;
+
+if (FCB->Recv.Window)
+{
+RtlCopyMemory(NewBuffer,
+  FCB->Recv.Window,
+  FCB->Recv.Content);
+
+ExFreePoolWithTag(FCB->Recv.Window, 
TAG_AFD_DATA_BUFFER);
+}
+
+FCB->Recv.Size = InfoReq->Information.Ulong;
+FCB->Recv.Window = NewBuffer;
+
+Status = STATUS_SUCCESS;
+}
+else
+{
+Status = STATUS_NO_MEMORY;
+}
+}
+else
+{
+Status = STATUS_SUCCESS;
 }
-
-FCB->Recv.Size = InfoReq->Information.Ulong;
-FCB->Recv.Window = NewBuffer;
-
-Status = STATUS_SUCCESS;
 }
 else
 {
-Status = STATUS_NO_MEMORY;
+Status = STATUS_INVALID_PARAMETER;
 }
 break;
 case AFD_INFO_SEND_WINDOW_SIZE:
-NewBuffer = ExAllocatePoolWithTag(PagedPool,
-  InfoReq->Information.Ulong,
-  TAG_AFD_DATA_BUFFER);
-
-if (NewBuffer)
+if (FCB->State == SOCKET_STATE_CONNECTED ||
+FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS)
 {
-if (FCB->Send.BytesUsed > InfoReq->Information.Ulong)
-FCB->Send.BytesUsed = InfoReq->Information.Ulong;
-
-if (FCB->Send.Window)
+if (InfoReq->Information.Ulong > 0 && 
InfoReq->Information.Ulong < 0x)
 {
-RtlCopyMemory(NewBuffer,
-  FCB->Send.Window,
-

[ros-diffs] [reactos] 01/05: [AFD] Add default window sizes on socket creation

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

commit bb9eec753791dabefdadee7969741687eb405ff8
Author: Pierre Schweitzer 
AuthorDate: Mon Feb 25 22:25:03 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Feb 25 22:34:28 2019 +0100

[AFD] Add default window sizes on socket creation
---
 drivers/network/afd/afd/main.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/network/afd/afd/main.c b/drivers/network/afd/afd/main.c
index 04e28652c6..db01703534 100644
--- a/drivers/network/afd/afd/main.c
+++ b/drivers/network/afd/afd/main.c
@@ -22,6 +22,10 @@ DWORD DebugTraceLevel = MIN_TRACE;
 
 #endif /* DBG */
 
+/* FIXME: should depend on SystemSize */
+ULONG AfdReceiveWindowSize = 0x2000;
+ULONG AfdSendWindowSize = 0x2000;
+
 void OskitDumpBuffer( PCHAR Data, UINT Len ) {
 unsigned int i;
 
@@ -352,6 +356,8 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp,
 FCB->DeviceExt = DeviceExt;
 FCB->AddressFile.Handle = INVALID_HANDLE_VALUE;
 FCB->Connection.Handle = INVALID_HANDLE_VALUE;
+FCB->Recv.Size = AfdReceiveWindowSize;
+FCB->Send.Size = AfdSendWindowSize;
 
 KeInitializeMutex( &FCB->Mutex, 0 );
 



[ros-diffs] [reactos] 05/05: [MSAFD] Don't leak event while querying/setting socket options

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

commit 6ee2f9882c9cf1ff32f60fb3786b154e1eef94f0
Author: Pierre Schweitzer 
AuthorDate: Mon Feb 25 22:33:31 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Mon Feb 25 22:34:29 2019 +0100

[MSAFD] Don't leak event while querying/setting socket options
---
 dll/win32/msafd/misc/dllmain.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/dll/win32/msafd/misc/dllmain.c b/dll/win32/msafd/misc/dllmain.c
index 520cf1a3ce..abb184f8e3 100644
--- a/dll/win32/msafd/misc/dllmain.c
+++ b/dll/win32/msafd/misc/dllmain.c
@@ -3298,6 +3298,7 @@ GetSocketInformation(PSOCKET_INFORMATION Socket,
 if ((Socket->SharedData->CreateFlags & SO_SYNCHRONOUS_NONALERT) != 0)
 {
 TRACE("Opened without flag WSA_FLAG_OVERLAPPED. Do nothing.\n");
+NtClose( SockEvent );
 return 0;
 }
 if (CompletionRoutine == NULL)
@@ -3315,6 +3316,7 @@ GetSocketInformation(PSOCKET_INFORMATION Socket,
 if (!APCContext)
 {
 ERR("Not enough memory for APC Context\n");
+NtClose( SockEvent );
 return WSAEFAULT;
 }
 APCContext->lpCompletionRoutine = CompletionRoutine;
@@ -3346,6 +3348,8 @@ GetSocketInformation(PSOCKET_INFORMATION Socket,
 Status = IOSB->Status;
 }
 
+NtClose( SockEvent );
+
 TRACE("Status %x Information %d\n", Status, IOSB->Information);
 
 if (Status == STATUS_PENDING)
@@ -3371,8 +3375,6 @@ GetSocketInformation(PSOCKET_INFORMATION Socket,
 *Boolean = InfoData.Information.Boolean;
 }
 
-NtClose( SockEvent );
-
 return NO_ERROR;
 
 }
@@ -3437,6 +3439,7 @@ SetSocketInformation(PSOCKET_INFORMATION Socket,
 if ((Socket->SharedData->CreateFlags & SO_SYNCHRONOUS_NONALERT) != 0)
 {
 TRACE("Opened without flag WSA_FLAG_OVERLAPPED. Do nothing.\n");
+NtClose( SockEvent );
 return 0;
 }
 if (CompletionRoutine == NULL)
@@ -3454,6 +3457,7 @@ SetSocketInformation(PSOCKET_INFORMATION Socket,
 if (!APCContext)
 {
 ERR("Not enough memory for APC Context\n");
+NtClose( SockEvent );
 return WSAEFAULT;
 }
 APCContext->lpCompletionRoutine = CompletionRoutine;



[ros-diffs] [reactos] 01/03: [NTOSKRNL] UuidMutex -> ExpUuidLock

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

commit 81c88c1029b3569a560b1d32736a03bf0cb05ff5
Author: Pierre Schweitzer 
AuthorDate: Wed Feb 27 08:54:48 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Fri Mar 1 08:22:47 2019 +0100

[NTOSKRNL] UuidMutex -> ExpUuidLock
---
 ntoskrnl/ex/uuid.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/ntoskrnl/ex/uuid.c b/ntoskrnl/ex/uuid.c
index cae12d7bd1..60103f04b4 100644
--- a/ntoskrnl/ex/uuid.c
+++ b/ntoskrnl/ex/uuid.c
@@ -32,7 +32,7 @@
 
 /* GLOBALS /
 
-static FAST_MUTEX UuidMutex;
+static FAST_MUTEX ExpUuidLock;
 static ULARGE_INTEGER UuidLastTime;
 static ULONG UuidSequence;
 static BOOLEAN UuidSequenceInitialized = FALSE;
@@ -49,7 +49,7 @@ INIT_FUNCTION
 NTAPI
 ExpInitUuids(VOID)
 {
-ExInitializeFastMutex(&UuidMutex);
+ExInitializeFastMutex(&ExpUuidLock);
 
 KeQuerySystemTime((PLARGE_INTEGER)&UuidLastTime);
 UuidLastTime.QuadPart += TICKS_15_OCT_1582_TO_1601;
@@ -351,7 +351,7 @@ NtAllocateUuids(OUT PULARGE_INTEGER Time,
 _SEH2_END;
 }
 
-ExAcquireFastMutex(&UuidMutex);
+ExAcquireFastMutex(&ExpUuidLock);
 
 if (!UuidSequenceInitialized)
 {
@@ -374,7 +374,7 @@ NtAllocateUuids(OUT PULARGE_INTEGER Time,
 &UuidSequence);
 if (!NT_SUCCESS(Status))
 {
-ExReleaseFastMutex(&UuidMutex);
+ExReleaseFastMutex(&ExpUuidLock);
 return Status;
 }
 
@@ -385,7 +385,7 @@ NtAllocateUuids(OUT PULARGE_INTEGER Time,
 UuidSequenceChanged = FALSE;
 }
 
-ExReleaseFastMutex(&UuidMutex);
+ExReleaseFastMutex(&ExpUuidLock);
 
 /* Write back UUIDs to caller */
 _SEH2_TRY



[ros-diffs] [reactos] 03/03: [NTOSKRNL] Rewrite/fix our UUID generation implementation So that it matches Windows behavior Also implement ExUuidCreate that will generate UUID version 1

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

commit eb8b481cd4f32472788c6e43c6a3a62a7d396d3b
Author: Pierre Schweitzer 
AuthorDate: Wed Feb 27 21:12:32 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Fri Mar 1 08:22:48 2019 +0100

[NTOSKRNL] Rewrite/fix our UUID generation implementation
So that it matches Windows behavior
Also implement ExUuidCreate that will generate UUID version 1

The implementation is based on the RFC 4122
---
 ntoskrnl/ex/init.c |   6 +-
 ntoskrnl/ex/uuid.c | 458 +++--
 ntoskrnl/include/internal/ex.h |   9 +-
 ntoskrnl/include/internal/se.h |   5 -
 ntoskrnl/se/semgr.c|   2 +-
 5 files changed, 321 insertions(+), 159 deletions(-)

diff --git a/ntoskrnl/ex/init.c b/ntoskrnl/ex/init.c
index 10be805374..1e31003af6 100644
--- a/ntoskrnl/ex/init.c
+++ b/ntoskrnl/ex/init.c
@@ -711,7 +711,11 @@ ExpInitSystemPhase1(VOID)
 }
 
 /* Initialize UUIDs */
-ExpInitUuids();
+if (ExpUuidInitialization() == FALSE)
+{
+DPRINT1("Executive: Uuid initialization failed\n");
+return FALSE;
+}
 
 /* Initialize keyed events */
 if (ExpInitializeKeyedEventImplementation() == FALSE)
diff --git a/ntoskrnl/ex/uuid.c b/ntoskrnl/ex/uuid.c
index 459b957270..1f41bdb122 100644
--- a/ntoskrnl/ex/uuid.c
+++ b/ntoskrnl/ex/uuid.c
@@ -5,6 +5,7 @@
  * PURPOSE: UUID generator
  * PROGRAMMERS: Eric Kohl
  *  Thomas Weidenmueller
+ *      Pierre Schweitzer
  */
 
 /* INCLUDES */
@@ -25,75 +26,81 @@
 #define SECS_15_OCT_1582_TO_1601  ((17 + 30 + 31 + 365 * 18 + 5) * SECSPERDAY)
 #define TICKS_15_OCT_1582_TO_1601 ((ULONGLONG)SECS_15_OCT_1582_TO_1601 * 
TICKSPERSEC)
 
+/* 1 in 100-ns model = 0,1 microsecond */
+#define TIME_FRAME 1
+
 #if defined (ALLOC_PRAGMA)
-#pragma alloc_text(INIT, ExpInitUuids)
+#pragma alloc_text(INIT, ExpUuidInitialization)
+#pragma alloc_text(INIT, ExLuidInitialization)
 #endif
 
 
 /* GLOBALS /
 
-static FAST_MUTEX ExpUuidLock;
-static ULARGE_INTEGER UuidLastTime;
-static ULONG UuidSequence;
-static BOOLEAN UuidSequenceInitialized = FALSE;
-static BOOLEAN UuidSequenceChanged = FALSE;
-static UCHAR UuidSeed[SEED_BUFFER_SIZE];
-static ULONG UuidCount;
-static LARGE_INTEGER LuidIncrement;
-static LARGE_INTEGER LuidValue;
-UUID_CACHED_VALUES_STRUCT ExpUuidCachedValues = { 0ULL, 0x, 0, 0, { 
0x80, 0x6E, 0x6F, 0x6E, 0x69, 0x63 } };
+FAST_MUTEX ExpUuidLock;
+LARGE_INTEGER ExpUuidLastTimeAllocated;
+ULONG ExpUuidSequenceNumber = 0;
+BOOLEAN ExpUuidSequenceNumberValid;
+BOOLEAN ExpUuidSequenceNumberNotSaved = FALSE;
+UUID_CACHED_VALUES_STRUCT ExpUuidCachedValues = {0ULL, 0x, 0, 0, { 
0x80, 0x6E, 0x6F, 0x6E, 0x69, 0x63}};
+BOOLEAN ExpUuidCacheValid = FALSE;
+ULONG ExpLuidIncrement = 1;
+LARGE_INTEGER ExpLuid = {.LowPart = 0x3e9, .HighPart = 0x0};
 
 /* FUNCTIONS /
 
-VOID
+/*
+ * @implemented
+ */
+BOOLEAN
 INIT_FUNCTION
 NTAPI
-ExpInitUuids(VOID)
+ExpUuidInitialization(VOID)
 {
 ExInitializeFastMutex(&ExpUuidLock);
 
-KeQuerySystemTime((PLARGE_INTEGER)&UuidLastTime);
-UuidLastTime.QuadPart += TICKS_15_OCT_1582_TO_1601;
+ExpUuidSequenceNumberValid = FALSE;
+KeQuerySystemTime(&ExpUuidLastTimeAllocated);
 
-UuidCount = TICKS_PER_CLOCK_TICK;
-RtlZeroMemory(UuidSeed, SEED_BUFFER_SIZE);
+return TRUE;
 }
 
 
-#define VALUE_BUFFER_SIZE 256
-
+/*
+ * @implemented
+ */
+#define VALUE_BUFFER_SIZE 20
 static NTSTATUS
-ExpLoadUuidSequence(PULONG Sequence)
+ExpUuidLoadSequenceNumber(PULONG Sequence)
 {
 UCHAR ValueBuffer[VALUE_BUFFER_SIZE];
 PKEY_VALUE_PARTIAL_INFORMATION ValueInfo;
 OBJECT_ATTRIBUTES ObjectAttributes;
-UNICODE_STRING Name;
+UNICODE_STRING KeyName, ValueName;
 HANDLE KeyHandle;
 ULONG ValueLength;
 NTSTATUS Status;
 
-RtlInitUnicodeString(&Name,
-L"\\Registry\\Machine\\Software\\Microsoft\\Rpc");
+PAGED_CODE();
+
+RtlInitUnicodeString(&KeyName, 
L"\\Registry\\Machine\\Software\\Microsoft\\Rpc");
+RtlInitUnicodeString(&ValueName, L"UuidSequenceNumber");
+
 InitializeObjectAttributes(&ObjectAttributes,
-   &Name,
-   OBJ_CASE_INSENSITIVE,
+   &KeyName,
+   OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
NULL,
NULL);
-Status = ZwOpenKey(&KeyHandle,
-   KEY_QUERY_VALUE,
-   &ObjectAttributes);
+Status = ZwOpenKey(&KeyHandle, GENERIC_READ, &ObjectAttributes);

[ros-diffs] [reactos] 02/03: [NTOSKRNL] Introduce the UUID_CACHED_VALUES_STRUCT structure

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

commit 2d9673c68fd6ce9d8749aac0ed3c6bf04c1ba32a
Author: Pierre Schweitzer 
AuthorDate: Wed Feb 27 09:02:30 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Fri Mar 1 08:22:47 2019 +0100

[NTOSKRNL] Introduce the UUID_CACHED_VALUES_STRUCT structure

Source: https://blog.48bits.com/el-codigo-ntoskvinci/
---
 ntoskrnl/ex/uuid.c | 1 +
 ntoskrnl/include/internal/ex.h | 9 +
 2 files changed, 10 insertions(+)

diff --git a/ntoskrnl/ex/uuid.c b/ntoskrnl/ex/uuid.c
index 60103f04b4..459b957270 100644
--- a/ntoskrnl/ex/uuid.c
+++ b/ntoskrnl/ex/uuid.c
@@ -41,6 +41,7 @@ static UCHAR UuidSeed[SEED_BUFFER_SIZE];
 static ULONG UuidCount;
 static LARGE_INTEGER LuidIncrement;
 static LARGE_INTEGER LuidValue;
+UUID_CACHED_VALUES_STRUCT ExpUuidCachedValues = { 0ULL, 0x, 0, 0, { 
0x80, 0x6E, 0x6F, 0x6E, 0x69, 0x63 } };
 
 /* FUNCTIONS /
 
diff --git a/ntoskrnl/include/internal/ex.h b/ntoskrnl/include/internal/ex.h
index 2eaf8d2da0..2072a6a31c 100644
--- a/ntoskrnl/include/internal/ex.h
+++ b/ntoskrnl/include/internal/ex.h
@@ -167,6 +167,15 @@ ExGetPoolTagInfo(
 IN OUT PULONG ReturnLength OPTIONAL
 );
 
+typedef struct _UUID_CACHED_VALUES_STRUCT
+{
+ULONGLONG Time;
+LONG AllocatedCount;
+UCHAR ClockSeqHiAndReserved;
+UCHAR ClockSeqLow;
+UCHAR NodeId [ 6 ] ;
+} UUID_CACHED_VALUES_STRUCT, *PUUID_CACHED_VALUES_STRUCT;
+
 /* INITIALIZATION FUNCTIONS */
 
 INIT_FUNCTION



[ros-diffs] [reactos] 01/01: [NTOSKRNL] Add a test for ExUuidCreate

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

commit bbfb3caa3609bb1716a146efc5437dc4c6e4a910
Author: Pierre Schweitzer 
AuthorDate: Sat Mar 2 10:29:26 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Mar 2 10:30:00 2019 +0100

[NTOSKRNL] Add a test for ExUuidCreate
---
 modules/rostests/kmtests/CMakeLists.txt|  1 +
 modules/rostests/kmtests/kmtest_drv/testlist.c |  2 ++
 modules/rostests/kmtests/ntos_ex/ExUuid.c  | 21 +
 3 files changed, 24 insertions(+)

diff --git a/modules/rostests/kmtests/CMakeLists.txt 
b/modules/rostests/kmtests/CMakeLists.txt
index feb522be36..8d56d61b2d 100644
--- a/modules/rostests/kmtests/CMakeLists.txt
+++ b/modules/rostests/kmtests/CMakeLists.txt
@@ -54,6 +54,7 @@ list(APPEND KMTEST_DRV_SOURCE
 ntos_ex/ExSequencedList.c
 ntos_ex/ExSingleList.c
 ntos_ex/ExTimer.c
+ntos_ex/ExUuid.c
 ntos_fsrtl/FsRtlDissect.c
 ntos_fsrtl/FsRtlExpression.c
 ntos_fsrtl/FsRtlLegal.c
diff --git a/modules/rostests/kmtests/kmtest_drv/testlist.c 
b/modules/rostests/kmtests/kmtest_drv/testlist.c
index fea8708b4f..11d63bbad2 100644
--- a/modules/rostests/kmtests/kmtest_drv/testlist.c
+++ b/modules/rostests/kmtests/kmtest_drv/testlist.c
@@ -19,6 +19,7 @@ KMT_TESTFUNC Test_ExResource;
 KMT_TESTFUNC Test_ExSequencedList;
 KMT_TESTFUNC Test_ExSingleList;
 KMT_TESTFUNC Test_ExTimer;
+KMT_TESTFUNC Test_ExUuid;
 KMT_TESTFUNC Test_FsRtlDissect;
 KMT_TESTFUNC Test_FsRtlExpression;
 KMT_TESTFUNC Test_FsRtlLegal;
@@ -90,6 +91,7 @@ const KMT_TEST TestList[] =
 { "ExSequencedList",Test_ExSequencedList },
 { "ExSingleList",   Test_ExSingleList },
 { "-ExTimer",   Test_ExTimer },
+{ "ExUuid", Test_ExUuid },
 { "Example",Test_Example },
 { "FsRtlDissect",   Test_FsRtlDissect },
 { "FsRtlExpression",Test_FsRtlExpression },
diff --git a/modules/rostests/kmtests/ntos_ex/ExUuid.c 
b/modules/rostests/kmtests/ntos_ex/ExUuid.c
new file mode 100644
index 00..2fb0bba8dc
--- /dev/null
+++ b/modules/rostests/kmtests/ntos_ex/ExUuid.c
@@ -0,0 +1,21 @@
+/*
+ * PROJECT: ReactOS kernel-mode tests
+ * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory
+ * PURPOSE: Kernel-Mode Test Suite UUIDs test
+ * PROGRAMMER:  Pierre Schweitzer 
+ */
+
+#include 
+
+#define NDEBUG
+#include 
+
+START_TEST(ExUuid)
+{
+UUID Uuid;
+NTSTATUS Status;
+
+Status = ExUuidCreate(&Uuid);
+ok(Status == STATUS_SUCCESS, "ExUuidCreate returned unexpected status: 
%lx\n", Status);
+ok((Uuid.Data3 & 0x1000) == 0x1000, "Invalid UUID version: %x\n", 
(Uuid.Data3 & 0xF000));
+}



[ros-diffs] [reactos] 01/01: [NTOSKRNL] Fix ClockDiff aka fix MSVC build

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

commit c2b6c3a69ff133c3370a118a1abaa48dee91122a
Author: Pierre Schweitzer 
AuthorDate: Sat Mar 2 10:45:34 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Mar 2 10:45:34 2019 +0100

[NTOSKRNL] Fix ClockDiff aka fix MSVC build
---
 ntoskrnl/ex/uuid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ntoskrnl/ex/uuid.c b/ntoskrnl/ex/uuid.c
index 1f41bdb122..8c8270a3db 100644
--- a/ntoskrnl/ex/uuid.c
+++ b/ntoskrnl/ex/uuid.c
@@ -261,7 +261,7 @@ ExpAllocateUuids(PULARGE_INTEGER Time,
 else
 {
 *Range = TIME_FRAME;
-ClockDiff.QuadPart -= TIME_FRAME;
+ClockDiff.QuadPart = TimeDiff.QuadPart - TIME_FRAME;
 --ClockDiff.HighPart;
 }
 



[ros-diffs] [reactos] 01/01: [NTOSKRNL] Fix MSVC2010 build

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

commit 1114b89952ab6d92d7c6156f6c8f0fba2f32e334
Author: Pierre Schweitzer 
AuthorDate: Sat Mar 2 11:10:37 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sat Mar 2 11:10:37 2019 +0100

[NTOSKRNL] Fix MSVC2010 build
---
 ntoskrnl/ex/uuid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ntoskrnl/ex/uuid.c b/ntoskrnl/ex/uuid.c
index 8c8270a3db..fdda755214 100644
--- a/ntoskrnl/ex/uuid.c
+++ b/ntoskrnl/ex/uuid.c
@@ -45,7 +45,7 @@ BOOLEAN ExpUuidSequenceNumberNotSaved = FALSE;
 UUID_CACHED_VALUES_STRUCT ExpUuidCachedValues = {0ULL, 0x, 0, 0, { 
0x80, 0x6E, 0x6F, 0x6E, 0x69, 0x63}};
 BOOLEAN ExpUuidCacheValid = FALSE;
 ULONG ExpLuidIncrement = 1;
-LARGE_INTEGER ExpLuid = {.LowPart = 0x3e9, .HighPart = 0x0};
+LARGE_INTEGER ExpLuid = {{0x3e9, 0x0}};
 
 /* FUNCTIONS /
 



[ros-diffs] [reactos] 01/01: [DCOMLAUNCH] Add a DcomLaunch service stub

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

commit 2ab289a34a7af2e020c9b4fe9045d2331ce15b05
Author: Pierre Schweitzer 
AuthorDate: Sun Mar 3 14:21:46 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Mar 3 14:25:19 2019 +0100

[DCOMLAUNCH] Add a DcomLaunch service stub

This stub is responsible for providing the UUID seed to the kernel.
For now, it generates a purely random seed - MAC address support
is to be added.
Because it's purely random seed and local the machine (not tied
to the MAC address) it's made so that ExUuidCreate keeps returning
RPC_NT_UUID_LOCAL_ONLY. It won't fix failing test for now.

Nota: this service shouldn't exist as it. It should be implemented
though rpcss DLL for both rpcss service (network service) and
dcomlaunch service (local system service).
Because rpcss is EXE based and wine-synced for now, I prefered
stubbing a new service. This will have to be changed at some point.
---
 base/services/CMakeLists.txt |   1 +
 base/services/dcomlaunch/CMakeLists.txt  |  11 +++
 base/services/dcomlaunch/dcomlaunch.c| 142 +++
 base/services/dcomlaunch/dcomlaunch.rc   |   5 ++
 base/services/dcomlaunch/dcomlaunch.spec |   1 +
 base/services/dcomlaunch/network.c   | 140 ++
 boot/bootdata/hivesft.inf|   2 +-
 boot/bootdata/hivesys.inf|  23 +
 8 files changed, 324 insertions(+), 1 deletion(-)

diff --git a/base/services/CMakeLists.txt b/base/services/CMakeLists.txt
index 977b5edf68..64cd734690 100644
--- a/base/services/CMakeLists.txt
+++ b/base/services/CMakeLists.txt
@@ -1,5 +1,6 @@
 
 add_subdirectory(audiosrv)
+add_subdirectory(dcomlaunch)
 add_subdirectory(dhcpcsvc)
 add_subdirectory(eventlog)
 add_subdirectory(nfsd)
diff --git a/base/services/dcomlaunch/CMakeLists.txt 
b/base/services/dcomlaunch/CMakeLists.txt
new file mode 100644
index 00..6759d029aa
--- /dev/null
+++ b/base/services/dcomlaunch/CMakeLists.txt
@@ -0,0 +1,11 @@
+spec2def(dcomlaunch.dll dcomlaunch.spec ADD_IMPORTLIB)
+
+add_library(dcomlaunch SHARED
+dcomlaunch.c
+network.c
+dcomlaunch.rc
+${CMAKE_CURRENT_BINARY_DIR}/dcomlaunch.def)
+
+set_module_type(dcomlaunch win32dll UNICODE)
+add_importlibs(dcomlaunch advapi32 msvcrt kernel32 ntdll)
+add_cd_file(TARGET dcomlaunch DESTINATION reactos/system32 FOR all)
diff --git a/base/services/dcomlaunch/dcomlaunch.c 
b/base/services/dcomlaunch/dcomlaunch.c
new file mode 100644
index 00..280dbff3eb
--- /dev/null
+++ b/base/services/dcomlaunch/dcomlaunch.c
@@ -0,0 +1,142 @@
+/*
+ * PROJECT: ReactOS RPC Subsystem Service
+ * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
+ * PURPOSE: DCOMLAUNCH service
+ * COPYRIGHT:   Copyright 2019 Pierre Schweitzer
+ */
+
+/* INCLUDES */
+
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define NDEBUG
+#include 
+
+/* GLOBALS **/
+
+static WCHAR ServiceName[] = L"dcomlaunch";
+
+static SERVICE_STATUS_HANDLE ServiceStatusHandle;
+static SERVICE_STATUS ServiceStatus;
+
+/* FUNCTIONS */
+
+static VOID
+UpdateServiceStatus(DWORD dwState)
+{
+ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
+ServiceStatus.dwCurrentState = dwState;
+ServiceStatus.dwControlsAccepted = 0;
+ServiceStatus.dwWin32ExitCode = 0;
+ServiceStatus.dwServiceSpecificExitCode = 0;
+ServiceStatus.dwCheckPoint = 0;
+
+if (dwState == SERVICE_START_PENDING ||
+dwState == SERVICE_STOP_PENDING ||
+dwState == SERVICE_PAUSE_PENDING ||
+dwState == SERVICE_CONTINUE_PENDING)
+ServiceStatus.dwWaitHint = 1;
+else
+ServiceStatus.dwWaitHint = 0;
+
+SetServiceStatus(ServiceStatusHandle,
+ &ServiceStatus);
+}
+
+static DWORD WINAPI
+ServiceControlHandler(DWORD dwControl,
+  DWORD dwEventType,
+  LPVOID lpEventData,
+  LPVOID lpContext)
+{
+DPRINT1("ServiceControlHandler() called\n");
+
+switch (dwControl)
+{
+case SERVICE_CONTROL_STOP:
+DPRINT1("  SERVICE_CONTROL_STOP received\n");
+UpdateServiceStatus(SERVICE_STOPPED);
+return ERROR_SUCCESS;
+
+case SERVICE_CONTROL_PAUSE:
+DPRINT1("  SERVICE_CONTROL_PAUSE received\n");
+UpdateServiceStatus(SERVICE_PAUSED);
+return ERROR_SUCCESS;
+
+case SERVICE_CONTROL_CONTINUE:
+DPRINT1("  SERVICE_CONTROL_CONTINUE received\n");
+UpdateServiceS

[ros-diffs] [reactos] 01/01: [DCOMLAUNCH][WMISVC] Stop busy waiting shutdown

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

commit e5b0087c8ea87c1952a1edd4daee29839198d33c
Author: Pierre Schweitzer 
AuthorDate: Sun Mar 3 23:14:07 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Mar 3 23:14:37 2019 +0100

[DCOMLAUNCH][WMISVC] Stop busy waiting shutdown
---
 base/services/dcomlaunch/dcomlaunch.c | 15 +--
 base/services/wmisvc/wmisvc.c | 15 +--
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/base/services/dcomlaunch/dcomlaunch.c 
b/base/services/dcomlaunch/dcomlaunch.c
index 280dbff3eb..49c8541c0c 100644
--- a/base/services/dcomlaunch/dcomlaunch.c
+++ b/base/services/dcomlaunch/dcomlaunch.c
@@ -25,6 +25,7 @@ static WCHAR ServiceName[] = L"dcomlaunch";
 
 static SERVICE_STATUS_HANDLE ServiceStatusHandle;
 static SERVICE_STATUS ServiceStatus;
+static HANDLE ShutdownEvent;
 
 /* FUNCTIONS */
 
@@ -62,7 +63,8 @@ ServiceControlHandler(DWORD dwControl,
 {
 case SERVICE_CONTROL_STOP:
 DPRINT1("  SERVICE_CONTROL_STOP received\n");
-UpdateServiceStatus(SERVICE_STOPPED);
+SetEvent(ShutdownEvent);
+UpdateServiceStatus(SERVICE_STOP_PENDING);
 return ERROR_SUCCESS;
 
 case SERVICE_CONTROL_PAUSE:
@@ -83,7 +85,8 @@ ServiceControlHandler(DWORD dwControl,
 
 case SERVICE_CONTROL_SHUTDOWN:
 DPRINT1("  SERVICE_CONTROL_SHUTDOWN received\n");
-UpdateServiceStatus(SERVICE_STOPPED);
+SetEvent(ShutdownEvent);
+UpdateServiceStatus(SERVICE_STOP_PENDING);
 return ERROR_SUCCESS;
 
 default :
@@ -111,14 +114,14 @@ ServiceMain(DWORD argc, LPTSTR *argv)
 return;
 }
 
+ShutdownEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
+
 DealWithDeviceEvent();
 
 UpdateServiceStatus(SERVICE_RUNNING);
 
-do
-{
-Sleep(1);
-} while (1);
+WaitForSingleObject(ShutdownEvent, INFINITE);
+CloseHandle(ShutdownEvent);
 
 UpdateServiceStatus(SERVICE_STOPPED);
 }
diff --git a/base/services/wmisvc/wmisvc.c b/base/services/wmisvc/wmisvc.c
index 8ac9d9b733..042ff84e3d 100644
--- a/base/services/wmisvc/wmisvc.c
+++ b/base/services/wmisvc/wmisvc.c
@@ -44,6 +44,7 @@ static WCHAR ServiceName[] = L"winmgmt";
 
 static SERVICE_STATUS_HANDLE ServiceStatusHandle;
 static SERVICE_STATUS ServiceStatus;
+static HANDLE ShutdownEvent;
 
 /* FUNCTIONS */
 
@@ -81,7 +82,8 @@ ServiceControlHandler(DWORD dwControl,
 {
 case SERVICE_CONTROL_STOP:
 DPRINT1("  SERVICE_CONTROL_STOP received\n");
-UpdateServiceStatus(SERVICE_STOPPED);
+SetEvent(ShutdownEvent);
+UpdateServiceStatus(SERVICE_STOP_PENDING);
 return ERROR_SUCCESS;
 
 case SERVICE_CONTROL_PAUSE:
@@ -102,7 +104,8 @@ ServiceControlHandler(DWORD dwControl,
 
 case SERVICE_CONTROL_SHUTDOWN:
 DPRINT1("  SERVICE_CONTROL_SHUTDOWN received\n");
-UpdateServiceStatus(SERVICE_STOPPED);
+SetEvent(ShutdownEvent);
+UpdateServiceStatus(SERVICE_STOP_PENDING);
 return ERROR_SUCCESS;
 
 default :
@@ -128,12 +131,12 @@ ServiceMain(DWORD argc, LPTSTR *argv)
 return;
 }
 
+ShutdownEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
+
 UpdateServiceStatus(SERVICE_RUNNING);
 
-do
-{
-Sleep(1);
-} while (1);
+WaitForSingleObject(ShutdownEvent, INFINITE);
+CloseHandle(ShutdownEvent);
 
 UpdateServiceStatus(SERVICE_STOPPED);
 }



[ros-diffs] [reactos] 01/01: [AFD] Don't reallocate buffers if windows sizes didn't change

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

commit 4e07b3b9f9448ff17c636bd2de9b72d9f1e403f2
Author: Pierre Schweitzer 
AuthorDate: Sun Mar 10 12:27:30 2019 +0100
Commit: Pierre Schweitzer 
CommitDate: Sun Mar 10 12:27:30 2019 +0100

[AFD] Don't reallocate buffers if windows sizes didn't change
---
 drivers/network/afd/afd/info.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/network/afd/afd/info.c b/drivers/network/afd/afd/info.c
index c780eb86a2..78e0cb0851 100644
--- a/drivers/network/afd/afd/info.c
+++ b/drivers/network/afd/afd/info.c
@@ -128,7 +128,8 @@ AfdSetInfo( PDEVICE_OBJECT DeviceObject, PIRP Irp,
 FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS)
 {
 /* FIXME: likely not right, check tcpip.sys for 
TDI_QUERY_MAX_DATAGRAM_INFO */
-if (InfoReq->Information.Ulong > 0 && 
InfoReq->Information.Ulong < 0x)
+if (InfoReq->Information.Ulong > 0 && 
InfoReq->Information.Ulong < 0x &&
+InfoReq->Information.Ulong != FCB->Recv.Size)
 {
 NewBuffer = ExAllocatePoolWithTag(PagedPool,
   
InfoReq->Information.Ulong,
@@ -172,7 +173,8 @@ AfdSetInfo( PDEVICE_OBJECT DeviceObject, PIRP Irp,
 if (FCB->State == SOCKET_STATE_CONNECTED ||
 FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS)
 {
-if (InfoReq->Information.Ulong > 0 && 
InfoReq->Information.Ulong < 0x)
+if (InfoReq->Information.Ulong > 0 && 
InfoReq->Information.Ulong < 0x &&
+InfoReq->Information.Ulong != FCB->Send.Size)
 {
 NewBuffer = ExAllocatePoolWithTag(PagedPool,
   
InfoReq->Information.Ulong,



<    4   5   6   7   8   9