[ros-diffs] [reactos] 01/01: [NTOS] Addendum to da81345: Fix checks when a hive is opened in shared mode.

2017-11-12 Thread Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0b2bbd1125a935fb50e979812d3a34cfde500882

commit 0b2bbd1125a935fb50e979812d3a34cfde500882
Author: Hermès Bélusca-Maïto 
AuthorDate: Mon Nov 13 00:27:41 2017 +0100

[NTOS] Addendum to da81345: Fix checks when a hive is opened in shared mode.
---
 ntoskrnl/config/cminit.c   | 14 --
 ntoskrnl/config/cmsysini.c |  7 +--
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/ntoskrnl/config/cminit.c b/ntoskrnl/config/cminit.c
index 46ab61e4b3..bf055fd914 100644
--- a/ntoskrnl/config/cminit.c
+++ b/ntoskrnl/config/cminit.c
@@ -38,15 +38,17 @@ CmpInitializeHive(OUT PCMHIVE *CmHive,
 
 /*
  * The following are invalid:
- * An external hive that is also internal.
- * A log hive that's not a primary hive too.
- * A volatile hive that's linked to permanent storage.
- * An in-memory initialization without hive data.
- * A log hive that's not linked to a correct file type.
+ * - An external hive that is also internal.
+ * - A log hive that is not a primary hive too.
+ * - A volatile hive that is linked to permanent storage,
+ *   unless this hive is a shared system hive.
+ * - An in-memory initialization without hive data.
+ * - A log hive that is not linked to a correct file type.
  */
 if (((External) && ((Primary) || (Log))) ||
 ((Log) && !(Primary)) ||
-((HiveFlags & HIVE_VOLATILE) && ((Primary) || (External) || (Log))) ||
+(!(CmpShareSystemHives) && (HiveFlags & HIVE_VOLATILE) &&
+((Primary) || (External) || (Log))) ||
 ((OperationType == HINIT_MEMORY) && (!HiveData)) ||
 ((Log) && (FileType != HFILE_TYPE_LOG)))
 {
diff --git a/ntoskrnl/config/cmsysini.c b/ntoskrnl/config/cmsysini.c
index 112543fac7..a433485eb2 100644
--- a/ntoskrnl/config/cmsysini.c
+++ b/ntoskrnl/config/cmsysini.c
@@ -1297,9 +1297,12 @@ CmpLoadHiveThread(IN PVOID StartContext)
  &CmpMachineHiveList[i].Allocate,
  0);
 if (!(NT_SUCCESS(Status)) ||
-(!(CmHive->FileHandles[HFILE_TYPE_LOG]) && !(CmpMiniNTBoot))) // 
HACK
+(!(CmpShareSystemHives) && !(CmHive->FileHandles[HFILE_TYPE_LOG])))
 {
-/* We failed or couldn't get a log file, raise a hard error */
+/*
+ * We failed, or could not get a log file (unless
+ * the hive is shared), raise a hard error.
+ */
 ErrorParameters = &FileName;
 NtRaiseHardError(STATUS_CANNOT_LOAD_REGISTRY_FILE,
  1,



[ros-diffs] [reactos] 01/01: [SETUPAPI] Improve the range list implementation. - SEH-protect the range list validation and move it into a separate function. - Use a mutex to synchronize access to the

2017-11-12 Thread Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3ad5c7fd84bdcce26db5f46a2afd4c7a972c7700

commit 3ad5c7fd84bdcce26db5f46a2afd4c7a972c7700
Author: Eric Kohl 
AuthorDate: Sun Nov 12 23:27:09 2017 +0100

[SETUPAPI] Improve the range list implementation.
- SEH-protect the range list validation and move it into a separate 
function.
- Use a mutex to synchronize access to the range list.
- Implement CM_First_Range and parts of CM_Add_Range.
---
 dll/win32/setupapi/cfgmgr.c | 162 
 1 file changed, 150 insertions(+), 12 deletions(-)

diff --git a/dll/win32/setupapi/cfgmgr.c b/dll/win32/setupapi/cfgmgr.c
index 898b755ec3..14f05963e2 100644
--- a/dll/win32/setupapi/cfgmgr.c
+++ b/dll/win32/setupapi/cfgmgr.c
@@ -69,17 +69,18 @@ typedef struct _NOTIFY_DATA
 #define NOTIFY_MAGIC 0x44556677
 
 
-typedef struct _INTERNAL_RANGE_ELEMENT
+typedef struct _INTERNAL_RANGE
 {
-struct _INTERNAL_RANGE_ELEMENT *Next;
-ULONG ulDummy;
-} INTERNAL_RANGE_ELEMENT, *PINTERNAL_RANGE_ELEMENT;
+LIST_ENTRY ListEntry;
+DWORDLONG ullStart;
+DWORDLONG ullEnd;
+} INTERNAL_RANGE, *PINTERNAL_RANGE;
 
 typedef struct _INTERNAL_RANGE_LIST
 {
 ULONG ulMagic;
-PINTERNAL_RANGE_ELEMENT Current;
-PINTERNAL_RANGE_ELEMENT First;
+HANDLE hMutex;
+LIST_ENTRY ListHead;
 } INTERNAL_RANGE_LIST, *PINTERNAL_RANGE_LIST;
 
 #define RANGE_LIST_MAGIC 0x33445566
@@ -338,6 +339,30 @@ done:
 }
 
 
+BOOL
+IsValidRangeList(
+_In_ PINTERNAL_RANGE_LIST pRangeList)
+{
+BOOL bValid = TRUE;
+
+if (pRangeList == NULL)
+return FALSE;
+
+_SEH2_TRY
+{
+if (pRangeList->ulMagic != RANGE_LIST_MAGIC)
+bValid = FALSE;
+}
+_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+{
+bValid = FALSE;
+}
+_SEH2_END;
+
+return bValid;
+}
+
+
 /***
  * CMP_GetBlockedDriverInfo [SETUPAPI.@]
  */
@@ -950,9 +975,53 @@ CM_Add_Range(
 _In_ RANGE_LIST rlh,
 _In_ ULONG ulFlags)
 {
+PINTERNAL_RANGE_LIST pRangeList;
+PINTERNAL_RANGE pRange;
+CONFIGRET ret = CR_SUCCESS;
+
 FIXME("CM_Add_Range(%I64u %I64u %p %lx)\n",
   ullStartValue, ullEndValue, rlh, ulFlags);
-return CR_CALL_NOT_IMPLEMENTED;
+
+pRangeList = (PINTERNAL_RANGE_LIST)rlh;
+
+if (!IsValidRangeList(pRangeList))
+return CR_INVALID_RANGE_LIST;
+
+if (ulFlags & ~CM_ADD_RANGE_BITS)
+return CR_INVALID_FLAG;
+
+if (ullEndValue < ullStartValue)
+return CR_INVALID_RANGE;
+
+/* Lock the range list */
+WaitForSingleObject(pRangeList->hMutex, INFINITE);
+
+/* Allocate the new range */
+pRange = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNAL_RANGE));
+if (pRange == NULL)
+{
+ret = CR_OUT_OF_MEMORY;
+goto done;
+}
+
+pRange->ullStart = ullStartValue;
+pRange->ullEnd = ullEndValue;
+
+/* Insert the range */
+if (IsListEmpty(&pRangeList->ListHead))
+{
+InsertTailList(&pRangeList->ListHead, &pRange->ListEntry);
+}
+else
+{
+
+}
+
+done:
+/* Unlock the range list */
+ReleaseMutex(pRangeList->hMutex);
+
+return ret;
 }
 
 
@@ -1266,13 +1335,23 @@ CM_Create_Range_List(
 if (prlh == NULL)
 return CR_INVALID_POINTER;
 
+/* Allocate the range list */
 pRangeList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 
sizeof(INTERNAL_RANGE_LIST));
 if (pRangeList == NULL)
 return CR_OUT_OF_MEMORY;
 
+/* Set the magic value */
 pRangeList->ulMagic = RANGE_LIST_MAGIC;
 
-// TODO: More initialization
+/* Initialize the mutex for synchonized access */
+pRangeList->hMutex = CreateMutex(NULL, FALSE, NULL);
+if (pRangeList->hMutex == NULL)
+{
+HeapFree(GetProcessHeap(), 0, pRangeList);
+return CR_FAILURE;
+}
+
+InitializeListHead(&pRangeList->ListHead);
 
 *prlh = (RANGE_LIST)pRangeList;
 
@@ -1814,9 +1893,49 @@ CM_First_Range(
 _Out_ PRANGE_ELEMENT preElement,
 _In_ ULONG ulFlags)
 {
+PINTERNAL_RANGE_LIST pRangeList;
+PINTERNAL_RANGE pRange;
+PLIST_ENTRY ListEntry;
+CONFIGRET ret = CR_SUCCESS;
+
 FIXME("CM_First_Range(%p %p %p %p %lx)\n",
   rlh, pullStart, pullEnd, preElement, ulFlags);
-return CR_CALL_NOT_IMPLEMENTED;
+
+pRangeList = (PINTERNAL_RANGE_LIST)rlh;
+
+if (!IsValidRangeList(pRangeList))
+return CR_INVALID_RANGE_LIST;
+
+if (pullStart == NULL || pullEnd == NULL || preElement == NULL)
+return CR_INVALID_POINTER;
+
+if (ulFlags != 0)
+return CR_INVALID_FLAG;
+
+/* Lock the range list */
+WaitForSingleObject(pRangeList->hMutex, INFINITE);
+
+/* Fail, if the list is empty */
+if (IsListEmpty(&pRangeList->ListHead))
+{
+ret = CR_FAILURE;
+goto done;
+}
+
+/* Get the first range */
+ListEntry = pRangeList->ListHead.Flink;
+pRange = CONTAINING_RECO

[ros-diffs] [reactos] 05/05: [CDFS_NEW] Now NtWriteFile is fixed, revert 5f25582, ie remove FastIO hack from the driver CORE-14003

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

commit faee3753ea79c7e332c7a1b5eb74ca2c6614e23d
Author: Pierre Schweitzer 
AuthorDate: Sun Nov 12 22:36:47 2017 +0100

[CDFS_NEW] Now NtWriteFile is fixed, revert 5f25582, ie remove FastIO hack 
from the driver
CORE-14003
---
 drivers/filesystems/cdfs_new/cdinit.c | 36 ---
 1 file changed, 36 deletions(-)

diff --git a/drivers/filesystems/cdfs_new/cdinit.c 
b/drivers/filesystems/cdfs_new/cdinit.c
index 1f086fe61d..b6bec14c45 100755
--- a/drivers/filesystems/cdfs_new/cdinit.c
+++ b/drivers/filesystems/cdfs_new/cdinit.c
@@ -58,29 +58,6 @@ CdShutdown (
 #pragma alloc_text(INIT, CdInitializeGlobalData)
 #endif
 
-#ifdef __REACTOS__
-
-//
-// Stub for CcWrite, this is a hack
-//
-BOOLEAN
-NTAPI
-CdFastIoWrite (
-IN PFILE_OBJECT FileObject,
-IN PLARGE_INTEGER FileOffset,
-IN ULONG Length,
-IN BOOLEAN Wait,
-IN ULONG LockKey,
-IN PVOID Buffer,
-OUT PIO_STATUS_BLOCK IoStatus,
-IN PDEVICE_OBJECT DeviceObject)
-{
-ASSERT(FALSE);
-return FALSE;
-}
-
-#endif
-
 
 //
 //  Local support routine
@@ -365,19 +342,6 @@ Return Value:
 CdFastIoDispatch.SizeOfFastIoDispatch =sizeof(FAST_IO_DISPATCH);
 CdFastIoDispatch.FastIoCheckIfPossible =   CdFastIoCheckIfPossible;  //  
CheckForFastIo
 CdFastIoDispatch.FastIoRead =  FsRtlCopyRead;//  
Read
-#ifdef __REACTOS__
-
-//
-// Add a stub for CdFastIoWrite. This is a hack required because
-// our current implementation of NtWriteFile won't validate
-// access granted to files opened. And some applications may attempt
-// to write to a file. In case it is cached, the kernel will 
null-dereference
-// the fastIO routine, trying to call it.
-// FIXME: remove once NtWriteFile got fixed!
-//
-
-CdFastIoDispatch.FastIoWrite = CdFastIoWrite;// 
Write
-#endif
 CdFastIoDispatch.FastIoQueryBasicInfo =CdFastQueryBasicInfo; //  
QueryBasicInfo
 CdFastIoDispatch.FastIoQueryStandardInfo = CdFastQueryStdInfo;   //  
QueryStandardInfo
 CdFastIoDispatch.FastIoLock =  CdFastLock;   //  
Lock



[ros-diffs] [reactos] 04/05: [NTOSKNRL] In NtWriteFile, remove the check that is now redundant with ObReferenceFileObjectForWrite(). CORE-14003

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

commit 1d777ffab5458495c04f250cf7ced379f306a7af
Author: Pierre Schweitzer 
AuthorDate: Sun Nov 12 22:33:58 2017 +0100

[NTOSKNRL] In NtWriteFile, remove the check that is now redundant with 
ObReferenceFileObjectForWrite().
CORE-14003
---
 ntoskrnl/io/iomgr/iofunc.c | 15 ---
 1 file changed, 15 deletions(-)

diff --git a/ntoskrnl/io/iomgr/iofunc.c b/ntoskrnl/io/iomgr/iofunc.c
index 9ab983ac21..46fcce201d 100644
--- a/ntoskrnl/io/iomgr/iofunc.c
+++ b/ntoskrnl/io/iomgr/iofunc.c
@@ -3511,21 +3511,6 @@ NtWriteFile(IN HANDLE FileHandle,
 {
 _SEH2_TRY
 {
-/*
- * Check if the handle has either FILE_WRITE_DATA or
- * FILE_APPEND_DATA granted. However, if this is a named pipe,
- * make sure we don't ask for FILE_APPEND_DATA as it interferes
- * with the FILE_CREATE_PIPE_INSTANCE access right!
- */
-if (!(ObjectHandleInfo.GrantedAccess &
- ((!(FileObject->Flags & FO_NAMED_PIPE) ?
-   FILE_APPEND_DATA : 0) | FILE_WRITE_DATA)))
-{
-/* We failed */
-ObDereferenceObject(FileObject);
-_SEH2_YIELD(return STATUS_ACCESS_DENIED);
-}
-
 /* Probe the status block */
 ProbeForWriteIoStatusBlock(IoStatusBlock);
 



[ros-diffs] [reactos] 03/05: [NTOSKRNL] In NtWriteFile, quit using ObReferenceObjectByHandle in favor of ObReferenceFileObjectForWrite(). This avoids RO FSDs being called for write operations. CORE-14

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

commit c3d5a3f2bdff97f03b802fe95dce9d0c9375e53e
Author: Pierre Schweitzer 
AuthorDate: Sun Nov 12 22:32:16 2017 +0100

[NTOSKRNL] In NtWriteFile, quit using ObReferenceObjectByHandle in favor of 
ObReferenceFileObjectForWrite().
This avoids RO FSDs being called for write operations.
CORE-14003
---
 ntoskrnl/io/iomgr/iofunc.c | 18 +-
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/ntoskrnl/io/iomgr/iofunc.c b/ntoskrnl/io/iomgr/iofunc.c
index 93f1fe4e5f..9ab983ac21 100644
--- a/ntoskrnl/io/iomgr/iofunc.c
+++ b/ntoskrnl/io/iomgr/iofunc.c
@@ -3499,19 +3499,11 @@ NtWriteFile(IN HANDLE FileHandle,
 CapturedByteOffset.QuadPart = 0;
 IOTRACE(IO_API_DEBUG, "FileHandle: %p\n", FileHandle);
 
-/* Get File Object
- * FIXME: We should call ObReferenceFileObjectForWrite() instead to
- * check whether write access was actually granted. If not it will
- * fail and we will return.
- * That would allow avoiding ASSERT on FastIO later on if the FSD
- * is read-only
- */
-Status = ObReferenceObjectByHandle(FileHandle,
-   0,
-   IoFileObjectType,
-   PreviousMode,
-   (PVOID*)&FileObject,
-   &ObjectHandleInfo);
+/* Get File Object for write */
+Status = ObReferenceFileObjectForWrite(FileHandle,
+   PreviousMode,
+   &FileObject,
+   &ObjectHandleInfo);
 if (!NT_SUCCESS(Status)) return Status;
 
 /* Validate User-Mode Buffers */



[ros-diffs] [reactos] 02/05: [NTOSKRNL] Implement (with many FIXMEs) ObReferenceFileObjectForWrite() so that it can already do the job! CORE-14003

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

commit 3b64f7f8fbbc64ada4dfdb6bdd1feff4bac10c1d
Author: Pierre Schweitzer 
AuthorDate: Sun Nov 12 22:28:54 2017 +0100

[NTOSKRNL] Implement (with many FIXMEs) ObReferenceFileObjectForWrite() so 
that it can already do the job!
CORE-14003
---
 ntoskrnl/include/internal/ob.h |   9 
 ntoskrnl/ob/obref.c| 108 +
 2 files changed, 117 insertions(+)

diff --git a/ntoskrnl/include/internal/ob.h b/ntoskrnl/include/internal/ob.h
index a78b5ad457..374f4a2c3e 100644
--- a/ntoskrnl/include/internal/ob.h
+++ b/ntoskrnl/include/internal/ob.h
@@ -384,6 +384,15 @@ ObpDeleteObjectType(
 IN PVOID Object
 );
 
+NTSTATUS
+NTAPI
+ObReferenceFileObjectForWrite(
+IN HANDLE Handle,
+IN KPROCESSOR_MODE AccessMode,
+OUT PFILE_OBJECT *FileObject,
+OUT POBJECT_HANDLE_INFORMATION HandleInformation
+);
+
 //
 // DOS Devices Functions
 //
diff --git a/ntoskrnl/ob/obref.c b/ntoskrnl/ob/obref.c
index 00e2188069..2f4da20149 100644
--- a/ntoskrnl/ob/obref.c
+++ b/ntoskrnl/ob/obref.c
@@ -15,6 +15,8 @@
 #define NDEBUG
 #include 
 
+extern ULONG ObpAccessProtectCloseBit;
+
 /* PRIVATE FUNCTIONS */
 
 BOOLEAN
@@ -195,6 +197,112 @@ ObFastReplaceObject(IN PEX_FAST_REF FastRef,
 return OldObject;
 }
 
+NTSTATUS
+NTAPI
+ObReferenceFileObjectForWrite(IN HANDLE Handle,
+  IN KPROCESSOR_MODE AccessMode,
+  OUT PFILE_OBJECT *FileObject,
+  OUT POBJECT_HANDLE_INFORMATION HandleInformation)
+{
+NTSTATUS Status;
+PHANDLE_TABLE HandleTable;
+POBJECT_HEADER ObjectHeader;
+PHANDLE_TABLE_ENTRY HandleEntry;
+ACCESS_MASK GrantedAccess, DesiredAccess;
+
+/* Assume failure */
+*FileObject = NULL;
+
+/* Check if this is a special handle */
+if (HandleToLong(Handle) < 0)
+{
+/* Make sure we have a valid kernel handle */
+if (AccessMode != KernelMode || Handle == NtCurrentProcess() || Handle 
== NtCurrentThread())
+{
+return STATUS_INVALID_HANDLE;
+}
+
+/* Use the kernel handle table and get the actual handle value */
+Handle = ObKernelHandleToHandle(Handle);
+HandleTable = ObpKernelHandleTable;
+}
+else
+{
+/* Otherwise use this process's handle table */
+HandleTable = PsGetCurrentProcess()->ObjectTable;
+}
+
+ASSERT(HandleTable != NULL);
+KeEnterCriticalRegion();
+
+/* Get the handle entry */
+HandleEntry = ExMapHandleToPointer(HandleTable, Handle);
+if (HandleEntry)
+{
+/* Get the object header and validate the type*/
+ObjectHeader = ObpGetHandleObject(HandleEntry);
+
+/* Get the desired access from the file object */
+if 
(!NT_SUCCESS(IoComputeDesiredAccessFileObject((PFILE_OBJECT)&ObjectHeader->Body,
+&DesiredAccess)))
+{
+Status = STATUS_OBJECT_TYPE_MISMATCH;
+}
+else
+{
+/* Extract the granted access from the handle entry */
+if (BooleanFlagOn(NtGlobalFlag, FLG_KERNEL_STACK_TRACE_DB))
+{
+/* FIXME: Translate granted access */
+GrantedAccess = HandleEntry->GrantedAccess;
+}
+else
+{
+GrantedAccess = HandleEntry->GrantedAccess & 
~ObpAccessProtectCloseBit;
+}
+
+/* FIXME: Get handle information for audit */
+
+HandleInformation->GrantedAccess = GrantedAccess;
+
+/* FIXME: Get handle attributes */
+HandleInformation->HandleAttributes = 0;
+
+/* Do granted and desired access match? */
+if (GrantedAccess & DesiredAccess)
+{
+/* FIXME: Audit access if required */
+
+/* Reference the object directly since we have its header */
+InterlockedIncrement(&ObjectHeader->PointerCount);
+
+/* Unlock the handle */
+ExUnlockHandleTableEntry(HandleTable, HandleEntry);
+KeLeaveCriticalRegion();
+
+*FileObject = (PFILE_OBJECT)&ObjectHeader->Body;
+
+/* Return success */
+ASSERT(*FileObject != NULL);
+return STATUS_SUCCESS;
+}
+
+/* No match, deny write access */
+Status = STATUS_ACCESS_DENIED;
+
+ExUnlockHandleTableEntry(HandleTable, HandleEntry);
+}
+}
+else
+{
+Status = STATUS_INVALID_HANDLE;
+}
+
+/* Return failure status */
+KeLeaveCriticalRegion();
+return Status;
+}
+
 /* PUBLIC FUNCTIONS */
 
 LONG_PTR



[ros-diffs] [reactos] 01/05: [NTOSKRNL] Implement IoComputeDesiredAccessFileObject() based on checks performed in NtFlushBuffersFile() CORE-14003

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

commit 7eefe702949da68e49c4365d466c5373099c3b1f
Author: Pierre Schweitzer 
AuthorDate: Sun Nov 12 22:26:18 2017 +0100

[NTOSKRNL] Implement IoComputeDesiredAccessFileObject() based on checks 
performed in NtFlushBuffersFile()
CORE-14003
---
 ntoskrnl/include/internal/io.h |  7 +++
 ntoskrnl/io/iomgr/util.c   | 27 +++
 2 files changed, 34 insertions(+)

diff --git a/ntoskrnl/include/internal/io.h b/ntoskrnl/include/internal/io.h
index 54a46906db..2a4c62f42d 100644
--- a/ntoskrnl/include/internal/io.h
+++ b/ntoskrnl/include/internal/io.h
@@ -1230,6 +1230,13 @@ IopDoNameTransmogrify(
 IN PREPARSE_DATA_BUFFER DataBuffer
 );
 
+NTSTATUS
+NTAPI
+IoComputeDesiredAccessFileObject(
+IN PFILE_OBJECT FileObject,
+IN PACCESS_MASK DesiredAccess
+);
+
 //
 // I/O Timer Routines
 //
diff --git a/ntoskrnl/io/iomgr/util.c b/ntoskrnl/io/iomgr/util.c
index 14bfafda7c..7329dbf8f1 100644
--- a/ntoskrnl/io/iomgr/util.c
+++ b/ntoskrnl/io/iomgr/util.c
@@ -19,6 +19,33 @@ NTAPI
 RtlpGetStackLimits(PULONG_PTR StackBase,
PULONG_PTR StackLimit);
 
+/* PRIVATE FUNCTIONS */
+
+NTSTATUS
+NTAPI
+IoComputeDesiredAccessFileObject(IN PFILE_OBJECT FileObject,
+ IN PACCESS_MASK DesiredAccess)
+{
+/* Assume failure */
+*DesiredAccess = 0;
+
+/* First check we really have a FileObject */
+if (OBJECT_TO_OBJECT_HEADER(FileObject)->Type != IoFileObjectType)
+{
+return STATUS_OBJECT_TYPE_MISMATCH;
+}
+
+/* Then compute desired access:
+ * Check if the handle has either FILE_WRITE_DATA or FILE_APPEND_DATA was
+ * granted. However, if this is a named pipe, make sure we don't ask for
+ * FILE_APPEND_DATA as it interferes with the FILE_CREATE_PIPE_INSTANCE
+ * access right!
+ */
+*DesiredAccess = ((!(FileObject->Flags & FO_NAMED_PIPE) ? FILE_APPEND_DATA 
: 0) | FILE_WRITE_DATA);
+
+return STATUS_SUCCESS;
+}
+
 /* FUNCTIONS */
 
 /*



[ros-diffs] [reactos] 01/01: [NTOS] Do not perform hive write operations when we are not supposed to.

2017-11-12 Thread Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=da8134527b69a2a1bc0193352dcb73b70762f613

commit da8134527b69a2a1bc0193352dcb73b70762f613
Author: Hermès Bélusca-Maïto 
AuthorDate: Sun Nov 12 22:02:45 2017 +0100

[NTOS] Do not perform hive write operations when we are not supposed to.

- When we are in LiveCD mode (more generally, when hives are shared), load
  the system hives as volatile.
- Ignore hive write operations when everything operates in read-only mode
  and just return success instead.
- Just return success on hive file I/O if no file is associated with a
  given hive. This happens when e.g. a CM hive has a primary but no log.
---
 ntoskrnl/config/cmsysini.c |  8 ++--
 ntoskrnl/config/cmwraprs.c | 24 
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/ntoskrnl/config/cmsysini.c b/ntoskrnl/config/cmsysini.c
index 6b079ce0d4..112543fac7 100644
--- a/ntoskrnl/config/cmsysini.c
+++ b/ntoskrnl/config/cmsysini.c
@@ -900,7 +900,7 @@ CmpInitializeSystemHive(IN PLOADER_PARAMETER_BLOCK 
LoaderBlock)
 /* We imported, no need to create a new hive */
 Allocate = FALSE;
 
-/* Manually set the hive as volatile, if in Live CD mode */
+/* Manually set the hive as volatile, if in LiveCD mode */
 if (CmpShareSystemHives) SystemHive->Hive.HiveFlags = HIVE_VOLATILE;
 }
 else
@@ -1433,9 +1433,13 @@ CmpInitializeHiveList(IN USHORT Flag)
 /* Loop every hive we care about */
 for (i = 0; i < CM_NUMBER_OF_MACHINE_HIVES; i++)
 {
-/* Make sure the list is setup */
+/* Make sure the list is set up */
 ASSERT(CmpMachineHiveList[i].Name != NULL);
 
+/* Load the hive as volatile, if in LiveCD mode */
+if (CmpShareSystemHives)
+CmpMachineHiveList[i].HHiveFlags |= HIVE_VOLATILE;
+
 /* Create a thread to handle this hive */
 Status = PsCreateSystemThread(&Thread,
   THREAD_ALL_ACCESS,
diff --git a/ntoskrnl/config/cmwraprs.c b/ntoskrnl/config/cmwraprs.c
index 031dc77c00..0f5e47da92 100644
--- a/ntoskrnl/config/cmwraprs.c
+++ b/ntoskrnl/config/cmwraprs.c
@@ -82,6 +82,10 @@ CmpFileRead(IN PHHIVE RegistryHive,
 IO_STATUS_BLOCK IoStatusBlock;
 NTSTATUS Status;
 
+/* Just return success if no file is associated with this hive */
+if (HiveHandle == NULL)
+return TRUE;
+
 _FileOffset.QuadPart = *FileOffset;
 Status = ZwReadFile(HiveHandle, NULL, NULL, NULL, &IoStatusBlock,
 Buffer, (ULONG)BufferLength, &_FileOffset, NULL);
@@ -102,6 +106,14 @@ CmpFileWrite(IN PHHIVE RegistryHive,
 IO_STATUS_BLOCK IoStatusBlock;
 NTSTATUS Status;
 
+/* Just return success if no file is associated with this hive */
+if (HiveHandle == NULL)
+return TRUE;
+
+/* Don't do anything if we're not supposed to */
+if (CmpNoWrite)
+return TRUE;
+
 _FileOffset.QuadPart = *FileOffset;
 Status = ZwWriteFile(HiveHandle, NULL, NULL, NULL, &IoStatusBlock,
  Buffer, (ULONG)BufferLength, &_FileOffset, NULL);
@@ -122,6 +134,10 @@ CmpFileSetSize(IN PHHIVE RegistryHive,
 IO_STATUS_BLOCK IoStatusBlock;
 NTSTATUS Status;
 
+/* Just return success if no file is associated with this hive */
+if (HiveHandle == NULL)
+return TRUE;
+
 EndOfFileInfo.EndOfFile.QuadPart = FileSize;
 Status = ZwSetInformationFile(HiveHandle,
   &IoStatusBlock,
@@ -153,6 +169,14 @@ CmpFileFlush(IN PHHIVE RegistryHive,
 IO_STATUS_BLOCK IoStatusBlock;
 NTSTATUS Status;
 
+/* Just return success if no file is associated with this hive */
+if (HiveHandle == NULL)
+return TRUE;
+
+/* Don't do anything if we're not supposed to */
+if (CmpNoWrite)
+return TRUE;
+
 Status = ZwFlushBuffersFile(HiveHandle, &IoStatusBlock);
 return NT_SUCCESS(Status) ? TRUE : FALSE;
 }



[ros-diffs] [reactos] 01/01: [CDFS_NEW] Following 1bef487, add a hack and stub FastIO write routine to avoid bugchecks on write attempts. This allows booting the ReactOS LiveCD as HDD image in Qemu wi

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

commit 5f255827d3282b2dea1bc6d5ba77607550742ced
Author: Pierre Schweitzer 
AuthorDate: Sun Nov 12 21:16:31 2017 +0100

[CDFS_NEW] Following 1bef487, add a hack and stub FastIO write routine to 
avoid bugchecks on write attempts.
This allows booting the ReactOS LiveCD as HDD image in Qemu without issues 
:-)
---
 drivers/filesystems/cdfs_new/cdinit.c | 36 +++
 1 file changed, 36 insertions(+)

diff --git a/drivers/filesystems/cdfs_new/cdinit.c 
b/drivers/filesystems/cdfs_new/cdinit.c
index b6bec14c45..1f086fe61d 100755
--- a/drivers/filesystems/cdfs_new/cdinit.c
+++ b/drivers/filesystems/cdfs_new/cdinit.c
@@ -58,6 +58,29 @@ CdShutdown (
 #pragma alloc_text(INIT, CdInitializeGlobalData)
 #endif
 
+#ifdef __REACTOS__
+
+//
+// Stub for CcWrite, this is a hack
+//
+BOOLEAN
+NTAPI
+CdFastIoWrite (
+IN PFILE_OBJECT FileObject,
+IN PLARGE_INTEGER FileOffset,
+IN ULONG Length,
+IN BOOLEAN Wait,
+IN ULONG LockKey,
+IN PVOID Buffer,
+OUT PIO_STATUS_BLOCK IoStatus,
+IN PDEVICE_OBJECT DeviceObject)
+{
+ASSERT(FALSE);
+return FALSE;
+}
+
+#endif
+
 
 //
 //  Local support routine
@@ -342,6 +365,19 @@ Return Value:
 CdFastIoDispatch.SizeOfFastIoDispatch =sizeof(FAST_IO_DISPATCH);
 CdFastIoDispatch.FastIoCheckIfPossible =   CdFastIoCheckIfPossible;  //  
CheckForFastIo
 CdFastIoDispatch.FastIoRead =  FsRtlCopyRead;//  
Read
+#ifdef __REACTOS__
+
+//
+// Add a stub for CdFastIoWrite. This is a hack required because
+// our current implementation of NtWriteFile won't validate
+// access granted to files opened. And some applications may attempt
+// to write to a file. In case it is cached, the kernel will 
null-dereference
+// the fastIO routine, trying to call it.
+// FIXME: remove once NtWriteFile got fixed!
+//
+
+CdFastIoDispatch.FastIoWrite = CdFastIoWrite;// 
Write
+#endif
 CdFastIoDispatch.FastIoQueryBasicInfo =CdFastQueryBasicInfo; //  
QueryBasicInfo
 CdFastIoDispatch.FastIoQueryStandardInfo = CdFastQueryStdInfo;   //  
QueryStandardInfo
 CdFastIoDispatch.FastIoLock =  CdFastLock;   //  
Lock



[ros-diffs] [reactos] 01/01: [NTOSKRNL] Add a FIXME in NtWriteFile() that explains how broken is our current implementation regarding read-only FSDs

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

commit 1bef48796e4df655c71ddd92a00417dbe9e530ca
Author: Pierre Schweitzer 
AuthorDate: Sun Nov 12 21:11:22 2017 +0100

[NTOSKRNL] Add a FIXME in NtWriteFile() that explains how broken is our 
current implementation regarding read-only FSDs
---
 ntoskrnl/io/iomgr/iofunc.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/ntoskrnl/io/iomgr/iofunc.c b/ntoskrnl/io/iomgr/iofunc.c
index 5aa67ee3e1..93f1fe4e5f 100644
--- a/ntoskrnl/io/iomgr/iofunc.c
+++ b/ntoskrnl/io/iomgr/iofunc.c
@@ -3499,7 +3499,13 @@ NtWriteFile(IN HANDLE FileHandle,
 CapturedByteOffset.QuadPart = 0;
 IOTRACE(IO_API_DEBUG, "FileHandle: %p\n", FileHandle);
 
-/* Get File Object */
+/* Get File Object
+ * FIXME: We should call ObReferenceFileObjectForWrite() instead to
+ * check whether write access was actually granted. If not it will
+ * fail and we will return.
+ * That would allow avoiding ASSERT on FastIO later on if the FSD
+ * is read-only
+ */
 Status = ObReferenceObjectByHandle(FileHandle,
0,
IoFileObjectType,



[ros-diffs] [reactos] 01/01: [CDFS_NEW] Bugfix for f88fe43: don't delete devices twice on shutdown. With that bugfix, I can install ROS from ISO on HDD without troubles :-) CORE-13184

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

commit cbf0430b56b600c29c1f615117574afcce1a9027
Author: Pierre Schweitzer 
AuthorDate: Sun Nov 12 18:57:11 2017 +0100

[CDFS_NEW] Bugfix for f88fe43: don't delete devices twice on shutdown.
With that bugfix, I can install ROS from ISO on HDD without troubles :-)
CORE-13184
---
 drivers/filesystems/cdfs_new/cdinit.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/filesystems/cdfs_new/cdinit.c 
b/drivers/filesystems/cdfs_new/cdinit.c
index aac879a235..b6bec14c45 100755
--- a/drivers/filesystems/cdfs_new/cdinit.c
+++ b/drivers/filesystems/cdfs_new/cdinit.c
@@ -241,10 +241,16 @@ Return Value:
 
 --*/
 {
+#ifdef __REACTOS__
+ASSERT(DeviceObject == CdData.FileSystemDeviceObject ||
+   DeviceObject == CdData.HddFileSystemDeviceObject);
+#endif
+
 IoUnregisterFileSystem (DeviceObject);
+#ifndef __REACTOS__
 IoDeleteDevice (CdData.FileSystemDeviceObject);
-#ifdef __REACTOS__
-IoDeleteDevice (CdData.HddFileSystemDeviceObject);
+#else
+IoDeleteDevice (DeviceObject);
 #endif
 
 CdCompleteRequest( NULL, Irp, STATUS_SUCCESS );



[ros-diffs] [reactos] 01/01: [RAPPS-DB] CORE-14000 mIRC 7.51 update update URL & hash (size stays same)

2017-11-12 Thread Joachim Henze
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cda5d7c8433853b9136dd776aadfcd2e9e312a6f

commit cda5d7c8433853b9136dd776aadfcd2e9e312a6f
Author: Joachim Henze 
AuthorDate: Sun Nov 12 18:57:34 2017 +0100

[RAPPS-DB] CORE-14000 mIRC 7.51 update
update URL & hash (size stays same)
---
 media/rapps/mirc.txt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/media/rapps/mirc.txt b/media/rapps/mirc.txt
index 35cc522dde..46b842d3c1 100644
--- a/media/rapps/mirc.txt
+++ b/media/rapps/mirc.txt
@@ -1,13 +1,13 @@
 [Section]
 Name = mIRC 7
-Version = 7.49
+Version = 7.51
 License = Shareware
 Description = The most popular client for the Internet Relay Chat (IRC).
 Size = 2.6 MiB
 Category = 5
 URLSite = http://www.mirc.com/
-URLDownload = 
https://web.archive.org/web/20170628091903/http://download.mirc.com/19/mirc749.exe
-SHA1 = 741b6c69852c50252ec6b7b3f90ffdefb02b5ffd
+URLDownload = http://download.mirc.com/20/mirc751.exe
+SHA1 = 8ed87210fa4b31b77c0c987e87e53ea765e9a27e
 CDPath = none
 
 [Section.0407]



[ros-diffs] [reactos] 01/01: [NTOSKRNL] It is forbidden to call DbgPrint at DISPATCH_LEVEL with %wZ

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

commit f88fe43abd6a039f25cc08a8dfd65f9a56ef9da7
Author: Pierre Schweitzer 
AuthorDate: Sun Nov 12 18:51:07 2017 +0100

[NTOSKRNL] It is forbidden to call DbgPrint at DISPATCH_LEVEL with %wZ
---
 ntoskrnl/io/iomgr/device.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/ntoskrnl/io/iomgr/device.c b/ntoskrnl/io/iomgr/device.c
index 5d7f31e147..9342d5a22d 100644
--- a/ntoskrnl/io/iomgr/device.c
+++ b/ntoskrnl/io/iomgr/device.c
@@ -357,9 +357,8 @@ IopEditDeviceList(IN PDRIVER_OBJECT DriverObject,
 /* Not this one, keep moving */
 if (!Previous->NextDevice)
 {
-DPRINT1("Failed to remove PDO %p on driver %wZ (not 
found)\n",
-DeviceObject,
-&DeviceObject->DriverObject->DriverName);
+DPRINT1("Failed to remove PDO %p (not found)\n",
+DeviceObject);
 
 ASSERT(FALSE);
 KeReleaseQueuedSpinLock(LockQueueIoDatabaseLock, OldIrql);



[ros-diffs] [reactos] 01/01: [CDFS_NEW] Restore the ability to restore installing from disk image. CORE-13184

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

commit 6c733856258ebfac4b62ffb7733202dddb74a4be
Author: Pierre Schweitzer 
AuthorDate: Sun Nov 12 18:36:20 2017 +0100

[CDFS_NEW]
Restore the ability to restore installing from disk image.
CORE-13184
---
 drivers/filesystems/cdfs_new/cdinit.c   | 58 +
 drivers/filesystems/cdfs_new/cdstruc.h  |  4 +++
 drivers/filesystems/cdfs_new/fsctrl.c   | 44 +
 drivers/filesystems/cdfs_new/strucsup.c | 10 ++
 4 files changed, 116 insertions(+)

diff --git a/drivers/filesystems/cdfs_new/cdinit.c 
b/drivers/filesystems/cdfs_new/cdinit.c
index e66bd75377..aac879a235 100755
--- a/drivers/filesystems/cdfs_new/cdinit.c
+++ b/drivers/filesystems/cdfs_new/cdinit.c
@@ -38,6 +38,10 @@ NTSTATUS
 CdInitializeGlobalData (
 IN PDRIVER_OBJECT DriverObject,
 IN PDEVICE_OBJECT FileSystemDeviceObject
+#ifdef __REACTOS__
+,
+IN PDEVICE_OBJECT HddFileSystemDeviceObject
+#endif
 );
 
 NTSTATUS
@@ -89,6 +93,9 @@ Return Value:
 NTSTATUS Status;
 UNICODE_STRING UnicodeString;
 PDEVICE_OBJECT CdfsFileSystemDeviceObject;
+#ifdef __REACTOS__
+PDEVICE_OBJECT HddFileSystemDeviceObject;
+#endif
 
 //
 // Create the device object.
@@ -107,6 +114,27 @@ Return Value:
 if (!NT_SUCCESS( Status )) {
 return Status;
 }
+
+#ifdef __REACTOS__
+//
+// Create the HDD device object.
+//
+
+RtlInitUnicodeString( &UnicodeString, L"\\CdfsHdd" );
+
+Status = IoCreateDevice( DriverObject,
+ 0,
+ &UnicodeString,
+ FILE_DEVICE_DISK_FILE_SYSTEM,
+ 0,
+ FALSE,
+ &HddFileSystemDeviceObject );
+
+if (!NT_SUCCESS( Status )) {
+IoDeleteDevice (CdfsFileSystemDeviceObject);
+return Status;
+}
+#endif
 DriverObject->DriverUnload = CdUnload;
 //
 //  Note that because of the way data caching is done, we set neither
@@ -141,6 +169,9 @@ Return Value:
 Status = IoRegisterShutdownNotification (CdfsFileSystemDeviceObject);
 if (!NT_SUCCESS (Status)) {
 IoDeleteDevice (CdfsFileSystemDeviceObject);
+#ifdef __REACTOS__
+IoDeleteDevice (HddFileSystemDeviceObject);
+#endif
 return Status;
 }
 
@@ -148,9 +179,16 @@ Return Value:
 //  Initialize the global data structures
 //
 
+#ifndef __REACTOS__
 Status = CdInitializeGlobalData( DriverObject, CdfsFileSystemDeviceObject 
);
+#else
+Status = CdInitializeGlobalData( DriverObject, CdfsFileSystemDeviceObject, 
HddFileSystemDeviceObject );
+#endif
 if (!NT_SUCCESS (Status)) {
 IoDeleteDevice (CdfsFileSystemDeviceObject);
+#ifdef __REACTOS__
+IoDeleteDevice (HddFileSystemDeviceObject);
+#endif
 return Status;
 }
 
@@ -161,9 +199,16 @@ Return Value:
 //
 
 CdfsFileSystemDeviceObject->Flags |= DO_LOW_PRIORITY_FILESYSTEM;
+#ifdef __REACTOS__
+HddFileSystemDeviceObject->Flags |= DO_LOW_PRIORITY_FILESYSTEM;
+#endif
 
 IoRegisterFileSystem( CdfsFileSystemDeviceObject );
 ObReferenceObject (CdfsFileSystemDeviceObject);
+#ifdef __REACTOS__
+IoRegisterFileSystem( HddFileSystemDeviceObject );
+ObReferenceObject (HddFileSystemDeviceObject);
+#endif
 
 //
 //  And return to our caller
@@ -198,6 +243,9 @@ Return Value:
 {
 IoUnregisterFileSystem (DeviceObject);
 IoDeleteDevice (CdData.FileSystemDeviceObject);
+#ifdef __REACTOS__
+IoDeleteDevice (CdData.HddFileSystemDeviceObject);
+#endif
 
 CdCompleteRequest( NULL, Irp, STATUS_SUCCESS );
 return STATUS_SUCCESS;
@@ -241,6 +289,9 @@ Return Value:
 IoFreeWorkItem (CdData.CloseItem);
 ExDeleteResourceLite( &CdData.DataResource );
 ObDereferenceObject (CdData.FileSystemDeviceObject);
+#ifdef __REACTOS__
+ObDereferenceObject (CdData.HddFileSystemDeviceObject);
+#endif
 }
 
 //
@@ -251,6 +302,10 @@ NTSTATUS
 CdInitializeGlobalData (
 IN PDRIVER_OBJECT DriverObject,
 IN PDEVICE_OBJECT FileSystemDeviceObject
+#ifdef __REACTOS__
+,
+IN PDEVICE_OBJECT HddFileSystemDeviceObject
+#endif
 )
 
 /*++
@@ -307,6 +362,9 @@ Return Value:
 
 CdData.DriverObject = DriverObject;
 CdData.FileSystemDeviceObject = FileSystemDeviceObject;
+#ifdef __REACTOS__
+CdData.HddFileSystemDeviceObject = HddFileSystemDeviceObject;
+#endif
 
 InitializeListHead( &CdData.VcbQueue );
 
diff --git a/drivers/filesystems/cdfs_new/cdstruc.h 
b/drivers/filesystems/cdfs_new/cdstruc.h
index e120ee27d0..1259349db2 100755
--- a/drivers/filesystems/cdfs_new/cdstruc.h
+++ b/drivers/filesystems/cdfs_new/cdstruc.h
@@ -349,6 +349,10 @@ typedef struct _CD_DATA {
 
 PDEVICE_OBJECT FileSystemDeviceObject;
 
+#ifdef __REACTOS__
+PDEVICE_OBJECT HddFileSystemDeviceObject;
+#endif
+
 //
 //  Following are used to mana

[ros-diffs] [reactos] 01/01: [RAPPS-DB] CORE-14000 mIRC 7.49 fix URL

2017-11-12 Thread Joachim Henze
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7dc30a5b84287e75c1c5a6e98aac2a028ca81cc2

commit 7dc30a5b84287e75c1c5a6e98aac2a028ca81cc2
Author: Joachim Henze 
AuthorDate: Sun Nov 12 18:01:36 2017 +0100

[RAPPS-DB] CORE-14000 mIRC 7.49 fix URL
---
 media/rapps/mirc.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/media/rapps/mirc.txt b/media/rapps/mirc.txt
index f2d9e9b74f..35cc522dde 100644
--- a/media/rapps/mirc.txt
+++ b/media/rapps/mirc.txt
@@ -6,7 +6,7 @@ Description = The most popular client for the Internet Relay 
Chat (IRC).
 Size = 2.6 MiB
 Category = 5
 URLSite = http://www.mirc.com/
-URLDownload = http://download.mirc.com/19/mirc749.exe
+URLDownload = 
https://web.archive.org/web/20170628091903/http://download.mirc.com/19/mirc749.exe
 SHA1 = 741b6c69852c50252ec6b7b3f90ffdefb02b5ffd
 CDPath = none
 



[ros-diffs] [reactos] 01/01: [EVENTLOG] Use the STDCALL calling convention for all remote procedure calls.

2017-11-12 Thread Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=52fa3479f32ef3240d4aaded1bf246b7801fdf98

commit 52fa3479f32ef3240d4aaded1bf246b7801fdf98
Author: Eric Kohl 
AuthorDate: Sun Nov 12 15:54:22 2017 +0100

[EVENTLOG] Use the STDCALL calling convention for all remote procedure 
calls.
---
 base/services/eventlog/rpc.c|  25 
 sdk/include/reactos/idl/eventlogrpc.idl | 100 
 2 files changed, 100 insertions(+), 25 deletions(-)

diff --git a/base/services/eventlog/rpc.c b/base/services/eventlog/rpc.c
index 01cd920b6b..da1706ac33 100644
--- a/base/services/eventlog/rpc.c
+++ b/base/services/eventlog/rpc.c
@@ -285,6 +285,7 @@ ElfDeleteEventLogHandle(PIELF_HANDLE LogHandle)
 
 /* Function 0 */
 NTSTATUS
+WINAPI
 ElfrClearELFW(
 IELF_HANDLE LogHandle,
 PRPC_UNICODE_STRING BackupFileName)
@@ -308,6 +309,7 @@ ElfrClearELFW(
 
 /* Function 1 */
 NTSTATUS
+WINAPI
 ElfrBackupELFW(
 IELF_HANDLE LogHandle,
 PRPC_UNICODE_STRING BackupFileName)
@@ -327,6 +329,7 @@ ElfrBackupELFW(
 
 /* Function 2 */
 NTSTATUS
+WINAPI
 ElfrCloseEL(
 PIELF_HANDLE LogHandle)
 {
@@ -336,6 +339,7 @@ ElfrCloseEL(
 
 /* Function 3 */
 NTSTATUS
+WINAPI
 ElfrDeregisterEventSource(
 PIELF_HANDLE LogHandle)
 {
@@ -345,6 +349,7 @@ ElfrDeregisterEventSource(
 
 /* Function 4 */
 NTSTATUS
+WINAPI
 ElfrNumberOfRecords(
 IELF_HANDLE LogHandle,
 PULONG NumberOfRecords)
@@ -393,6 +398,7 @@ ElfrNumberOfRecords(
 
 /* Function 5 */
 NTSTATUS
+WINAPI
 ElfrOldestRecord(
 IELF_HANDLE LogHandle,
 PULONG OldestRecordNumber)
@@ -423,6 +429,7 @@ ElfrOldestRecord(
 
 /* Function 6 */
 NTSTATUS
+WINAPI
 ElfrChangeNotify(
 IELF_HANDLE LogHandle,
 RPC_CLIENT_ID ClientId,
@@ -435,6 +442,7 @@ ElfrChangeNotify(
 
 /* Function 7 */
 NTSTATUS
+WINAPI
 ElfrOpenELW(
 EVENTLOG_HANDLE_W UNCServerName,
 PRPC_UNICODE_STRING ModuleName,
@@ -462,6 +470,7 @@ ElfrOpenELW(
 
 /* Function 8 */
 NTSTATUS
+WINAPI
 ElfrRegisterEventSourceW(
 EVENTLOG_HANDLE_W UNCServerName,
 PRPC_UNICODE_STRING ModuleName,
@@ -493,6 +502,7 @@ ElfrRegisterEventSourceW(
 
 /* Function 9 */
 NTSTATUS
+WINAPI
 ElfrOpenBELW(
 EVENTLOG_HANDLE_W UNCServerName,
 PRPC_UNICODE_STRING BackupFileName,
@@ -516,6 +526,7 @@ ElfrOpenBELW(
 
 /* Function 10 */
 NTSTATUS
+WINAPI
 ElfrReadELW(
 IELF_HANDLE LogHandle,
 ULONG ReadFlags,
@@ -709,6 +720,7 @@ ElfrIntReportEventW(
 
 /* Function 11 */
 NTSTATUS
+WINAPI
 ElfrReportEventW(
 IELF_HANDLE LogHandle,
 ULONG Time,
@@ -746,6 +758,7 @@ ElfrReportEventW(
 
 /* Function 12 */
 NTSTATUS
+WINAPI
 ElfrClearELFA(
 IELF_HANDLE LogHandle,
 PRPC_STRING BackupFileName)
@@ -770,6 +783,7 @@ ElfrClearELFA(
 
 /* Function 13 */
 NTSTATUS
+WINAPI
 ElfrBackupELFA(
 IELF_HANDLE LogHandle,
 PRPC_STRING BackupFileName)
@@ -794,6 +808,7 @@ ElfrBackupELFA(
 
 /* Function 14 */
 NTSTATUS
+WINAPI
 ElfrOpenELA(
 EVENTLOG_HANDLE_A UNCServerName,
 PRPC_STRING ModuleName,
@@ -830,6 +845,7 @@ ElfrOpenELA(
 
 /* Function 15 */
 NTSTATUS
+WINAPI
 ElfrRegisterEventSourceA(
 EVENTLOG_HANDLE_A UNCServerName,
 PRPC_STRING ModuleName,
@@ -877,6 +893,7 @@ ElfrRegisterEventSourceA(
 
 /* Function 16 */
 NTSTATUS
+WINAPI
 ElfrOpenBELA(
 EVENTLOG_HANDLE_A UNCServerName,
 PRPC_STRING BackupFileName,
@@ -919,6 +936,7 @@ ElfrOpenBELA(
 
 /* Function 17 */
 NTSTATUS
+WINAPI
 ElfrReadELA(
 IELF_HANDLE LogHandle,
 ULONG ReadFlags,
@@ -970,6 +988,7 @@ ElfrReadELA(
 
 /* Function 18 */
 NTSTATUS
+WINAPI
 ElfrReportEventA(
 IELF_HANDLE LogHandle,
 ULONG Time,
@@ -1088,6 +1107,7 @@ Done:
 
 /* Function 19 */
 NTSTATUS
+WINAPI
 ElfrRegisterClusterSvc(
 handle_t BindingHandle)
 {
@@ -1098,6 +1118,7 @@ ElfrRegisterClusterSvc(
 
 /* Function 20 */
 NTSTATUS
+WINAPI
 ElfrDeregisterClusterSvc(
 handle_t BindingHandle)
 {
@@ -1108,6 +1129,7 @@ ElfrDeregisterClusterSvc(
 
 /* Function 21 */
 NTSTATUS
+WINAPI
 ElfrWriteClusterEvents(
 handle_t BindingHandle)
 {
@@ -1118,6 +1140,7 @@ ElfrWriteClusterEvents(
 
 /* Function 22 */
 NTSTATUS
+WINAPI
 ElfrGetLogInformation(
 IELF_HANDLE LogHandle,
 ULONG InfoLevel,
@@ -1169,6 +1192,7 @@ ElfrGetLogInformation(
 
 /* Function 23 */
 NTSTATUS
+WINAPI
 ElfrFlushEL(
 IELF_HANDLE LogHandle)
 {
@@ -1196,6 +1220,7 @@ ElfrFlushEL(
 
 /* Function 24 */
 NTSTATUS
+WINAPI
 ElfrReportEventAndSourceW(
 IELF_HANDLE LogHandle,
 ULONG Time,
diff --git a/sdk/include/reactos/idl/eventlogrpc.idl 
b/sdk/include/reactos/idl/eventlogrpc.idl
index 4dd5cadd51..f9c0e7fae1 100644
--- a/sdk/include/reactos/idl/eventlogrpc.idl
+++ b/sdk/include/reactos/idl/eventlogrpc.idl
@@ -42,41 +42,57 @@ typedef struct _RPC_CLIENT_ID {
 interface eventlog
 {
 /* Function 0 */
-NTSTATUS ElfrClearELFW(
+NTSTATUS
+__stdcall
+ElfrClearELFW(
 [in] IELF_HANDLE LogHandle,
 [in, unique] PRPC_UNICODE_STRING BackupFileName);
 
 /* Function 1 */
- NTSTATUS ElfrBackupE

[ros-diffs] [reactos] 01/01: [SERVICES] Use the STDCALL calling convention for all remote procedure calls.

2017-11-12 Thread Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7dd8ebcbbd7799661100753502f77ede96636e66

commit 7dd8ebcbbd7799661100753502f77ede96636e66
Author: Eric Kohl 
AuthorDate: Sun Nov 12 14:04:22 2017 +0100

[SERVICES] Use the STDCALL calling convention for all remote procedure 
calls.
---
 base/system/services/rpcserver.c   | 224 +++-
 sdk/include/reactos/idl/svcctl.idl | 228 +++--
 2 files changed, 338 insertions(+), 114 deletions(-)

diff --git a/base/system/services/rpcserver.c b/base/system/services/rpcserver.c
index 3465d4da30..d2f032cfe0 100644
--- a/base/system/services/rpcserver.c
+++ b/base/system/services/rpcserver.c
@@ -928,7 +928,9 @@ Int_EnumDependentServicesW(HKEY hServicesKey,
 
 
 /* Function 0 */
-DWORD RCloseServiceHandle(
+DWORD
+WINAPI
+RCloseServiceHandle(
 LPSC_RPC_HANDLE hSCObject)
 {
 PMANAGER_HANDLE hManager;
@@ -1058,7 +1060,9 @@ DWORD RCloseServiceHandle(
 
 
 /* Function 1 */
-DWORD RControlService(
+DWORD
+WINAPI
+RControlService(
 SC_RPC_HANDLE hService,
 DWORD dwControl,
 LPSERVICE_STATUS lpServiceStatus)
@@ -1271,7 +1275,9 @@ DWORD RControlService(
 
 
 /* Function 2 */
-DWORD RDeleteService(
+DWORD
+WINAPI
+RDeleteService(
 SC_RPC_HANDLE hService)
 {
 PSERVICE_HANDLE hSvc;
@@ -1327,7 +1333,9 @@ Done:
 
 
 /* Function 3 */
-DWORD RLockServiceDatabase(
+DWORD
+WINAPI
+RLockServiceDatabase(
 SC_RPC_HANDLE hSCManager,
 LPSC_RPC_LOCK lpLock)
 {
@@ -1353,7 +1361,9 @@ DWORD RLockServiceDatabase(
 
 
 /* Function 4 */
-DWORD RQueryServiceObjectSecurity(
+DWORD
+WINAPI
+RQueryServiceObjectSecurity(
 SC_RPC_HANDLE hService,
 SECURITY_INFORMATION dwSecurityInformation,
 LPBYTE lpSecurityDescriptor,
@@ -1435,7 +1445,9 @@ DWORD RQueryServiceObjectSecurity(
 
 
 /* Function 5 */
-DWORD RSetServiceObjectSecurity(
+DWORD
+WINAPI
+RSetServiceObjectSecurity(
 SC_RPC_HANDLE hService,
 DWORD dwSecurityInformation,
 LPBYTE lpSecurityDescriptor,
@@ -1561,7 +1573,9 @@ Done:
 
 
 /* Function 6 */
-DWORD RQueryServiceStatus(
+DWORD
+WINAPI
+RQueryServiceStatus(
 SC_RPC_HANDLE hService,
 LPSERVICE_STATUS lpServiceStatus)
 {
@@ -1630,7 +1644,9 @@ ScmIsValidServiceState(DWORD dwCurrentState)
 
 
 /* Function 7 */
-DWORD RSetServiceStatus(
+DWORD
+WINAPI
+RSetServiceStatus(
 RPC_SERVICE_STATUS_HANDLE hServiceStatus,
 LPSERVICE_STATUS lpServiceStatus)
 {
@@ -1764,7 +1780,9 @@ DWORD RSetServiceStatus(
 
 
 /* Function 8 */
-DWORD RUnlockServiceDatabase(
+DWORD
+WINAPI
+RUnlockServiceDatabase(
 LPSC_RPC_LOCK Lock)
 {
 DPRINT("RUnlockServiceDatabase(%p)\n", Lock);
@@ -1773,7 +1791,9 @@ DWORD RUnlockServiceDatabase(
 
 
 /* Function 9 */
-DWORD RNotifyBootConfigStatus(
+DWORD
+WINAPI
+RNotifyBootConfigStatus(
 SVCCTL_HANDLEW lpMachineName,
 DWORD BootAcceptable)
 {
@@ -1786,7 +1806,9 @@ DWORD RNotifyBootConfigStatus(
 
 
 /* Function 10 */
-DWORD RI_ScSetServiceBitsW(
+DWORD
+WINAPI
+RI_ScSetServiceBitsW(
 RPC_SERVICE_STATUS_HANDLE hServiceStatus,
 DWORD dwServiceBits,
 int bSetBitsOn,
@@ -1799,7 +1821,9 @@ DWORD RI_ScSetServiceBitsW(
 
 
 /* Function 11 */
-DWORD RChangeServiceConfigW(
+DWORD
+WINAPI
+RChangeServiceConfigW(
 SC_RPC_HANDLE hService,
 DWORD dwServiceType,
 DWORD dwStartType,
@@ -2092,7 +2116,9 @@ done:
 
 
 /* Function 12 */
-DWORD RCreateServiceW(
+DWORD
+WINAPI
+RCreateServiceW(
 SC_RPC_HANDLE hSCManager,
 LPCWSTR lpServiceName,
 LPCWSTR lpDisplayName,
@@ -2503,7 +2529,9 @@ done:
 
 
 /* Function 13 */
-DWORD REnumDependentServicesW(
+DWORD
+WINAPI
+REnumDependentServicesW(
 SC_RPC_HANDLE hService,
 DWORD dwServiceState,
 LPBYTE lpServices,
@@ -2636,7 +2664,9 @@ Done:
 
 
 /* Function 14 */
-DWORD REnumServicesStatusW(
+DWORD
+WINAPI
+REnumServicesStatusW(
 SC_RPC_HANDLE hSCManager,
 DWORD dwServiceType,
 DWORD dwServiceState,
@@ -2660,7 +2690,9 @@ DWORD REnumServicesStatusW(
 
 
 /* Function 15 */
-DWORD ROpenSCManagerW(
+DWORD
+WINAPI
+ROpenSCManagerW(
 LPWSTR lpMachineName,
 LPWSTR lpDatabaseName,
 DWORD dwDesiredAccess,
@@ -2710,7 +2742,9 @@ DWORD ROpenSCManagerW(
 
 
 /* Function 16 */
-DWORD ROpenServiceW(
+DWORD
+WINAPI
+ROpenServiceW(
 SC_RPC_HANDLE hSCManager,
 LPWSTR lpServiceName,
 DWORD dwDesiredAccess,
@@ -2791,7 +2825,9 @@ Done:
 
 
 /* Function 17 */
-DWORD RQueryServiceConfigW(
+DWORD
+WINAPI
+RQueryServiceConfigW(
 SC_RPC_HANDLE hService,
 LPBYTE lpBuf, //LPQUERY_SERVICE_CONFIGW lpServiceConfig,
 DWORD cbBufSize,
@@ -2998,7 +3034,9 @@ Done:
 
 
 /* Function 18 */
-DWORD RQueryServiceLockStatusW(
+DWORD
+WINAPI
+RQueryServiceLockStatusW(
 SC_RPC_HANDLE hSCManager,
 LPBYTE lpBuf, // LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus,
 DWORD cbBufSize,
@@ -3039,7 +3077,9 @@ DWORD RQueryServiceLockStatusW(
 
 
 /* Function 19 */
-DWORD RStartServiceW(
+DWORD
+WINAPI
+RStartServiceW(
 SC_RPC_HANDLE hService,
 DWORD 

[ros-diffs] [reactos] 01/01: [UMPNPMGR] Add missing status mappings to NtStatusToCrError. CORE-13944

2017-11-12 Thread Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2b5c4bd2c755bacd7a158b529feb4d69022f65ae

commit 2b5c4bd2c755bacd7a158b529feb4d69022f65ae
Author: Eric Kohl 
AuthorDate: Sun Nov 12 12:51:19 2017 +0100

[UMPNPMGR] Add missing status mappings to NtStatusToCrError.
CORE-13944
---
 base/services/umpnpmgr/umpnpmgr.c | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/base/services/umpnpmgr/umpnpmgr.c 
b/base/services/umpnpmgr/umpnpmgr.c
index 9bc4e4b3f1..e86047785a 100644
--- a/base/services/umpnpmgr/umpnpmgr.c
+++ b/base/services/umpnpmgr/umpnpmgr.c
@@ -169,14 +169,25 @@ NtStatusToCrError(NTSTATUS Status)
 {
 switch (Status)
 {
-case STATUS_NO_SUCH_DEVICE:
-return CR_NO_SUCH_DEVINST;
 case STATUS_NOT_IMPLEMENTED:
 return CR_CALL_NOT_IMPLEMENTED;
 
+case STATUS_INVALID_PARAMETER:
+return CR_INVALID_DATA;
+
+case STATUS_NO_SUCH_DEVICE:
+return CR_NO_SUCH_DEVINST;
+
+case STATUS_ACCESS_DENIED:
+return CR_ACCESS_DENIED;
+
+case STATUS_BUFFER_TOO_SMALL:
+return CR_BUFFER_SMALL;
+
+case STATUS_OBJECT_NAME_NOT_FOUND:
+return CR_NO_SUCH_VALUE;
+
 default:
-/* FIXME: add more mappings */
-DPRINT1("Unable to map status 0x%08lx\n", Status);
 return CR_FAILURE;
 }
 }



[ros-diffs] [reactos] 01/01: [EXT2] Upgrade to 0.69 CORE-13980

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

commit a1d7e9936d8e58bc07ff2cc73a937ce845c7d542
Author: Pierre Schweitzer 
AuthorDate: Sun Nov 12 10:47:29 2017 +0100

[EXT2] Upgrade to 0.69
CORE-13980
---
 drivers/filesystems/ext2/CMakeLists.txt  |2 +
 drivers/filesystems/ext2/inc/ext2fs.h|   63 +-
 drivers/filesystems/ext2/inc/linux/errno.h   |2 +
 drivers/filesystems/ext2/inc/linux/ext4_xattr.h  |  205 
 drivers/filesystems/ext2/inc/linux/fs.h  |   19 -
 drivers/filesystems/ext2/inc/linux/module.h  |2 +
 drivers/filesystems/ext2/src/create.c|  190 +++-
 drivers/filesystems/ext2/src/dirctl.c|6 +
 drivers/filesystems/ext2/src/dispatch.c  |6 +
 drivers/filesystems/ext2/src/ea.c|  604 ++
 drivers/filesystems/ext2/src/ext3/generic.c  |  616 +++---
 drivers/filesystems/ext2/src/ext3/recover.c  |7 +-
 drivers/filesystems/ext2/src/ext4/ext4_extents.c |1 +
 drivers/filesystems/ext2/src/ext4/ext4_xattr.c   | 1295 ++
 drivers/filesystems/ext2/src/fastio.c|5 +
 drivers/filesystems/ext2/src/fileinfo.c  |   34 +-
 drivers/filesystems/ext2/src/flush.c |   94 +-
 drivers/filesystems/ext2/src/fsctl.c |5 +
 drivers/filesystems/ext2/src/init.c  |8 +
 drivers/filesystems/ext2/src/linux.c |   33 +-
 drivers/filesystems/ext2/src/memory.c|  107 +-
 drivers/filesystems/ext2/src/volinfo.c   |2 +-
 drivers/filesystems/ext2/src/write.c |   18 +-
 media/doc/README.FSD |2 +-
 24 files changed, 3027 insertions(+), 299 deletions(-)

diff --git a/drivers/filesystems/ext2/CMakeLists.txt 
b/drivers/filesystems/ext2/CMakeLists.txt
index 4291b27a46..abc1c2489d 100644
--- a/drivers/filesystems/ext2/CMakeLists.txt
+++ b/drivers/filesystems/ext2/CMakeLists.txt
@@ -11,6 +11,7 @@ list(APPEND SOURCE
 src/ext4/ext4_bh.c
 src/ext4/ext4_extents.c
 src/ext4/ext4_jbd2.c
+src/ext4/ext4_xattr.c
 src/ext4/extents.c
 src/jbd/recovery.c
 src/jbd/replay.c
@@ -66,6 +67,7 @@ list(APPEND SOURCE
 src/devctl.c
 src/dirctl.c
 src/dispatch.c
+src/ea.c
 src/except.c
 src/fastio.c
 src/fileinfo.c
diff --git a/drivers/filesystems/ext2/inc/ext2fs.h 
b/drivers/filesystems/ext2/inc/ext2fs.h
index 7792ed18ac..525a1d1bc9 100644
--- a/drivers/filesystems/ext2/inc/ext2fs.h
+++ b/drivers/filesystems/ext2/inc/ext2fs.h
@@ -47,7 +47,7 @@
 
 /* STRUCTS & CONSTS**/
 
-#define EXT2FSD_VERSION "0.68"
+#define EXT2FSD_VERSION "0.69"
 
 
 /* WDK DEFINITIONS **/
@@ -720,7 +720,7 @@ typedef struct _EXT2_VCB {
 // Sector size in bits
 ULONG   SectorBits;
 
-// Aligned size (Page or Block)
+// Minimal i/o size: min(PageSize, BlockSize)
 ULONGLONG   IoUnitSize;
 
 // Bits of aligned size
@@ -783,6 +783,7 @@ typedef struct _EXT2_VCB {
 #define VCB_BEING_CLOSED0x0020
 #define VCB_USER_IDS0x0040  /* uid/gid specified by user */
 #define VCB_USER_EIDS   0x0080  /* euid/egid specified by user */
+#define VCB_GD_LOADED   0x0100  /* group desc loaded */
 
 #define VCB_BEING_DROPPED   0x2000
 #define VCB_FORCE_WRITING   0x4000
@@ -929,6 +930,8 @@ struct _EXT2_MCB {
 // List Link to Vcb->McbList
 LIST_ENTRY  Link;
 
+   
+
 struct inodeInode;
 struct dentry  *de;
 };
@@ -1006,6 +1009,9 @@ typedef struct _EXT2_CCB {
 /* Open handle control block */
 struct file filp;
 
+   /* The EA index we are on */
+   ULONG   EaIndex;
+
 } EXT2_CCB, *PEXT2_CCB;
 
 //
@@ -1116,6 +1122,10 @@ typedef struct _EXT2_EXTENT {
 #define FSCTL_GET_RETRIEVAL_POINTER_BASECTL_CODE(FILE_DEVICE_FILE_SYSTEM, 
141, METHOD_BUFFERED, FILE_ANY_ACCESS) // RETRIEVAL_POINTER_BASE
 #endif
 
+#ifndef FILE_SUPPORTS_EXTENDED_ATTRIBUTES
+#define FILE_SUPPORTS_EXTENDED_ATTRIBUTES   0x0080
+#endif
+
 //
 //  The following macro is used to determine if an FSD thread can block
 //  for I/O or wait for a resource.  It returns TRUE if the thread can
@@ -1605,6 +1615,26 @@ Ext2BuildRequest (
 IN PIRP Irp
 );
 
+//
+// ea.c
+//
+
+NTSTATUS
+Ext2QueryEa(
+   IN PEXT2_IRP_CONTEXTIrpContext
+);
+
+BOOLEAN
+Ext2IsEaNameValid(
+   IN OEM_STRING Name
+);
+
+NTSTATUS
+Ext2SetEa(
+   IN PEXT2_IRP_CONTEXTIrpContext
+);
+
+
 //
 // Except.c
 //
@@ -1765,15 +1795,24 @@ Ext2RefreshSuper(
 IN PEXT2_VCBVcb
 );
 
+BOOLEAN
+Ext2LoadGroupBH(IN PEXT2_VCB Vcb);
+
 BOOLEAN
 Ext2LoadGroup(IN PEXT2_VCB Vcb);
 
+VOID
+Ext2DropGroupBH(IN