Index: dll/ntdll/CMakeLists.txt
===================================================================
--- dll/ntdll/CMakeLists.txt	(revision 60527)
+++ dll/ntdll/CMakeLists.txt	(working copy)
@@ -52,6 +52,7 @@
                       rtl
                       ntdllsys
                       libcntpr
+                      uuid
                       ${PSEH_LIB})
 
 add_pch(ntdll include/ntdll.h)
Index: dll/ntdll/def/ntdll.spec
===================================================================
--- dll/ntdll/def/ntdll.spec	(revision 60527)
+++ dll/ntdll/def/ntdll.spec	(working copy)
@@ -405,7 +405,7 @@
 @ stdcall -arch=x86_64 RtlAddFunctionTable(ptr long long)
 ;@ stdcall RtlAddMandatoryAce(ptr long long long long ptr)
 @ stdcall RtlAddRefActivationContext(ptr)
-;@ stdcall RtlAddRefMemoryStream
+@ stdcall RtlAddRefMemoryStream(ptr)
 @ stdcall RtlAddVectoredContinueHandler(long ptr)
 @ stdcall RtlAddVectoredExceptionHandler(long ptr)
 ;@ stdcall RtlAddressInSectionTable
@@ -440,8 +440,8 @@
 @ stdcall RtlCheckRegistryKey(long ptr)
 @ stdcall RtlClearAllBits(ptr)
 @ stdcall RtlClearBits(ptr long long)
-;@ stdcall RtlCloneMemoryStream
-;@ stdcall RtlCommitMemoryStream
+@ stdcall RtlCloneMemoryStream(ptr ptr)
+@ stdcall RtlCommitMemoryStream(ptr long)
 @ stdcall RtlCompactHeap(long long)
 @ stdcall RtlCompareMemory(ptr ptr long)
 @ stdcall RtlCompareMemoryUlong(ptr long long)
@@ -464,8 +464,8 @@
 @ stdcall RtlCopyLuid(ptr ptr)
 @ stdcall RtlCopyLuidAndAttributesArray(long ptr ptr)
 ;@ stdcall RtlCopyMappedMemory
-;@ stdcall RtlCopyMemoryStreamTo
-;@ stdcall RtlCopyOutOfProcessMemoryStreamTo
+@ stdcall RtlCopyMemoryStreamTo(ptr ptr int64 ptr ptr)
+@ stdcall RtlCopyOutOfProcessMemoryStreamTo(ptr ptr int64 ptr ptr)
 ;@ stdcall RtlCopyRangeList ; 5.0 and 5.1 only
 @ stdcall RtlCopySecurityDescriptor(ptr ptr)
 @ stdcall RtlCopySid(long ptr ptr)
@@ -571,7 +571,7 @@
 @ stdcall -arch=win32 -ret64 RtlExtendedMagicDivide(double double long)
 @ stdcall RtlFillMemory(ptr long long)
 @ stdcall RtlFillMemoryUlong(ptr long long)
-;@ stdcall RtlFinalReleaseOutOfProcessMemoryStream
+@ stdcall RtlFinalReleaseOutOfProcessMemoryStream(ptr)
 @ stdcall RtlFindActivationContextSectionGuid(long ptr long ptr ptr)
 @ stdcall RtlFindActivationContextSectionString(long ptr long ptr ptr)
 @ stdcall RtlFindCharInUnicodeString(long ptr ptr ptr)
@@ -658,9 +658,9 @@
 @ stdcall RtlInitAnsiString(ptr str)
 @ stdcall RtlInitAnsiStringEx(ptr str)
 @ stdcall RtlInitCodePageTable(ptr ptr)
-;@ stdcall RtlInitMemoryStream
+@ stdcall RtlInitMemoryStream(ptr)
 @ stdcall RtlInitNlsTables(ptr ptr ptr ptr)
-;@ stdcall RtlInitOutOfProcessMemoryStream
+@ stdcall RtlInitOutOfProcessMemoryStream(ptr)
 @ stdcall RtlInitString(ptr str)
 @ stdcall RtlInitUnicodeString(ptr wstr)
 @ stdcall RtlInitUnicodeStringEx(ptr wstr)
@@ -735,7 +735,7 @@
 @ stdcall RtlLocalTimeToSystemTime(ptr ptr)
 @ stdcall RtlLockBootStatusData(ptr)
 @ stdcall RtlLockHeap(long)
-;@ stdcall RtlLockMemoryStreamRegion
+@ stdcall RtlLockMemoryStreamRegion(ptr int64 int64 long)
 ;@ stdcall RtlLogStackBackTrace
 @ stdcall RtlLookupAtomInAtomTable(ptr wstr ptr)
 @ stdcall RtlLookupElementGenericTable(ptr ptr)
@@ -781,7 +781,7 @@
 @ stdcall RtlQueryInformationAcl(ptr ptr long long)
 @ stdcall RtlQueryInformationActivationContext(long long ptr long ptr long ptr)
 @ stdcall RtlQueryInformationActiveActivationContext(long ptr long ptr)
-;@ stdcall RtlQueryInterfaceMemoryStream
+@ stdcall RtlQueryInterfaceMemoryStream(ptr ptr ptr)
 ;@ stdcall RtlQueryProcessBackTraceInformation
 @ stdcall RtlQueryProcessDebugInformation(long long ptr)
 ;@ stdcall RtlQueryProcessHeapInformation
@@ -800,14 +800,14 @@
 @ stdcall RtlRandom(ptr)
 @ stdcall RtlRandomEx(ptr)
 @ stdcall RtlReAllocateHeap(long long ptr long)
-;@ stdcall RtlReadMemoryStream
-;@ stdcall RtlReadOutOfProcessMemoryStream
+@ stdcall RtlReadMemoryStream(ptr ptr long ptr)
+@ stdcall RtlReadOutOfProcessMemoryStream(ptr ptr long ptr)
 @ stdcall RtlRealPredecessor(ptr)
 @ stdcall RtlRealSuccessor(ptr)
 @ stdcall RtlRegisterSecureMemoryCacheCallback(ptr)
 @ stdcall RtlRegisterWait(ptr ptr ptr ptr long long)
 @ stdcall RtlReleaseActivationContext(ptr)
-;@ stdcall RtlReleaseMemoryStream
+@ stdcall RtlReleaseMemoryStream(ptr)
 @ stdcall RtlReleasePebLock()
 @ stdcall RtlReleasePrivilege(ptr)
 @ stdcall RtlReleaseRelativeName(ptr)
@@ -820,12 +820,12 @@
 @ stdcall RtlResetRtlTranslations(ptr)
 @ stdcall -arch=x86_64 RtlRestoreContext(ptr ptr)
 @ stdcall RtlRestoreLastWin32Error(long) RtlSetLastWin32Error
-;@ stdcall RtlRevertMemoryStream
+@ stdcall RtlRevertMemoryStream(ptr)
 @ stdcall RtlRunDecodeUnicodeString(long ptr)
 @ stdcall RtlRunEncodeUnicodeString(long ptr)
 @ stdcall RtlSecondsSince1970ToTime(long ptr)
 @ stdcall RtlSecondsSince1980ToTime(long ptr)
-;@ stdcall RtlSeekMemoryStream
+@ stdcall RtlSeekMemoryStream(ptr int64 long ptr)
 @ stdcall RtlSelfRelativeToAbsoluteSD2(ptr ptr)
 @ stdcall RtlSelfRelativeToAbsoluteSD(ptr ptr ptr ptr ptr ptr ptr ptr ptr ptr ptr)
 @ stdcall RtlSetAllBits(ptr)
@@ -844,7 +844,7 @@
 @ stdcall RtlSetIoCompletionCallback(long ptr long)
 @ stdcall RtlSetLastWin32Error(long)
 @ stdcall RtlSetLastWin32ErrorAndNtStatusFromNtStatus(long)
-;@ stdcall RtlSetMemoryStreamSize
+@ stdcall RtlSetMemoryStreamSize(ptr int64)
 @ stdcall RtlSetOwnerSecurityDescriptor(ptr ptr long)
 @ stdcall RtlSetProcessIsCritical(long ptr long)
 ;@ stdcall RtlSetProperties ; RtlSetProperties
@@ -869,7 +869,7 @@
 @ stdcall RtlSleepConditionVariableSRW(ptr ptr ptr long)
 @ stdcall RtlSplay(ptr)
 ;@ stdcall RtlStartRXact
-;@ stdcall RtlStatMemoryStream
+@ stdcall RtlStatMemoryStream(ptr ptr long)
 @ stdcall RtlStringFromGUID(ptr ptr)
 @ stdcall RtlSubAuthorityCountSid(ptr)
 @ stdcall RtlSubAuthoritySid(ptr long)
@@ -907,7 +907,7 @@
 @ stdcall RtlUniform(ptr)
 @ stdcall RtlUnlockBootStatusData(ptr)
 @ stdcall RtlUnlockHeap(long)
-;@ stdcall RtlUnlockMemoryStreamRegion
+@ stdcall RtlUnlockMemoryStreamRegion(ptr int64 int64 long)
 @ stdcall -register RtlUnwind(ptr ptr ptr ptr)
 @ stdcall -arch=x86_64 RtlUnwindEx(long long ptr long ptr)
 @ stdcall RtlUpcaseUnicodeChar(long)
@@ -938,7 +938,7 @@
 @ stdcall RtlWow64EnableFsRedirectionEx(long ptr)
 @ stdcall RtlWakeAllConditionVariable(ptr)
 @ stdcall RtlWakeConditionVariable(ptr)
-;@ stdcall RtlWriteMemoryStream
+@ stdcall RtlWriteMemoryStream(ptr ptr long ptr)
 @ stdcall RtlWriteRegistryValue(long ptr ptr long ptr long)
 @ stdcall RtlZeroHeap(ptr long)
 @ stdcall RtlZeroMemory(ptr long)
Index: include/ndk/rtlfuncs.h
===================================================================
--- include/ndk/rtlfuncs.h	(revision 60527)
+++ include/ndk/rtlfuncs.h	(working copy)
@@ -4152,6 +4152,156 @@
 );
 #endif
 
+//
+// MemoryStream functions
+//
+#ifdef NTOS_MODE_USER
+
+NTSYSAPI
+VOID
+NTAPI
+RtlInitMemoryStream(PRTL_MEMORY_STREAM stream);
+
+NTSYSAPI
+VOID
+NTAPI
+RtlInitOutOfProcessMemoryStream(PRTL_MEMORY_STREAM stream);
+
+NTSYSAPI
+VOID
+NTAPI
+RtlFinalReleaseOutOfProcessMemoryStream(PRTL_MEMORY_STREAM stream);
+
+NTSYSAPI
+HRESULT
+NTAPI
+RtlQueryInterfaceMemoryStream( 
+    _In_ struct IStream * This,
+    _In_ REFIID riid,
+    _Outptr_result_maybenull_ PVOID *ppvObject);
+
+NTSYSAPI
+ULONG
+NTAPI
+RtlAddRefMemoryStream( 
+    _In_ struct IStream * This);
+
+NTSYSAPI
+ULONG
+NTAPI
+RtlReleaseMemoryStream( 
+    _In_ struct IStream * This);
+
+NTSYSAPI
+HRESULT
+NTAPI
+RtlReadMemoryStream( 
+    _In_ struct IStream * This,
+    _Out_writes_bytes_(cb) PVOID pv,
+    _In_ ULONG cb,
+    _Out_ PULONG pcbRead);
+
+NTSYSAPI
+HRESULT
+NTAPI
+RtlReadOutOfProcessMemoryStream( 
+    _In_ struct IStream * This,
+    _Out_writes_bytes_(cb) PVOID pv,
+    _In_ ULONG cb,
+    _Out_ PULONG pcbRead);
+
+NTSYSAPI
+HRESULT
+NTAPI
+RtlWriteMemoryStream( 
+    _In_ struct IStream * This,
+    _In_reads_bytes_(cb) const void * pv,
+    _In_ ULONG cb,
+    _Out_opt_ PULONG pcbWritten);
+
+NTSYSAPI
+HRESULT
+NTAPI
+RtlSeekMemoryStream( 
+    _In_ struct IStream * This,
+    _In_ LARGE_INTEGER dlibMove,
+    _In_ DWORD dwOrigin,
+    _Out_opt_ PULARGE_INTEGER plibNewPosition);
+
+NTSYSAPI
+HRESULT
+NTAPI
+RtlSetMemoryStreamSize( 
+    _In_ struct IStream * This,
+    _In_ ULARGE_INTEGER libNewSize);
+
+NTSYSAPI
+HRESULT
+NTAPI
+RtlCopyMemoryStreamTo( 
+    _In_ struct IStream * This,
+    _In_ struct IStream * pstm,
+    _In_ ULARGE_INTEGER cb,
+    _Out_opt_ PULARGE_INTEGER pcbRead,
+    _Out_opt_ PULARGE_INTEGER pcbWritten);
+
+NTSYSAPI
+HRESULT
+NTAPI
+RtlCopyOutOfProcessMemoryStreamTo( 
+    _In_ struct IStream * This,
+    _In_ struct IStream * pstm,
+    _In_ ULARGE_INTEGER cb,
+    _Out_opt_ PULARGE_INTEGER pcbRead,
+    _Out_opt_ PULARGE_INTEGER pcbWritten);
+
+NTSYSAPI
+HRESULT
+NTAPI
+RtlCommitMemoryStream( 
+    _In_ struct IStream * This,
+    _In_ DWORD grfCommitFlags);
+
+NTSYSAPI
+HRESULT
+NTAPI
+RtlRevertMemoryStream( 
+    _In_ struct IStream * This);
+
+NTSYSAPI
+HRESULT
+NTAPI
+RtlLockMemoryStreamRegion( 
+    _In_ struct IStream * This,
+    _In_ ULARGE_INTEGER libOffset,
+    _In_ ULARGE_INTEGER cb,
+    _In_ DWORD dwLockType);
+
+NTSYSAPI
+HRESULT
+NTAPI
+RtlUnlockMemoryStreamRegion( 
+    _In_ struct IStream * This,
+    _In_ ULARGE_INTEGER libOffset,
+    _In_ ULARGE_INTEGER cb,
+    _In_ DWORD dwLockType);
+
+NTSYSAPI
+HRESULT
+NTAPI
+RtlStatMemoryStream( 
+    _In_ struct IStream * This,
+    _Out_ struct tagSTATSTG * pstatstg,
+    _In_ DWORD grfStatFlag);
+
+NTSYSAPI
+HRESULT
+NTAPI
+RtlCloneMemoryStream( 
+    _In_ struct IStream * This,
+    _Outptr_result_maybenull_ struct IStream **ppvStream);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
Index: include/ndk/rtltypes.h
===================================================================
--- include/ndk/rtltypes.h	(revision 60527)
+++ include/ndk/rtltypes.h	(working copy)
@@ -1559,6 +1559,30 @@
 
 #endif /* !NTOS_MODE_USER */
 
+#ifdef NTOS_MODE_USER
+
+// forward declarations
+struct IStreamVtbl;
+struct IStream;
+struct IMemoryStream;
+struct tagSTATSTG;
+
+typedef VOID (NTAPI * PFnFinalReleaseMemoryStream)(struct IMemoryStream * stream);
+
+typedef struct IMemoryStream
+{
+    struct IStreamVtbl *lpVtbl;
+    ULONG RefCount;
+    ULONG Unk1;
+    PUCHAR Current;
+    PUCHAR Start;
+    PUCHAR End;
+    PFnFinalReleaseMemoryStream FinalRelease;
+    HANDLE HProcess;
+} RTL_MEMORY_STREAM, *PRTL_MEMORY_STREAM;
+
+#endif /* NTOS_MODE_USER */
+
 #ifdef __cplusplus
 }
 #endif
Index: lib/rtl/CMakeLists.txt
===================================================================
--- lib/rtl/CMakeLists.txt	(revision 60527)
+++ lib/rtl/CMakeLists.txt	(working copy)
@@ -33,6 +33,7 @@
     heapuser.c
     image.c
     interlck.c
+    memstream.c
     message.c
     largeint.c
     luid.c
Index: lib/rtl/memstream.c
===================================================================
--- lib/rtl/memstream.c	(revision 0)
+++ lib/rtl/memstream.c	(working copy)
@@ -0,0 +1,429 @@
+/* COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS system libraries
+ * FILE:            lib/rtl/mem.c
+ * PURPOSE:         MemoryStream functions
+ * PROGRAMMER:      David Quintana (gigaherz@gmail.com)
+ */
+
+/* INCLUDES *****************************************************************/
+
+#define COBJMACROS
+
+#include <rtl.h>
+
+#define NDEBUG
+#include <debug.h>
+
+/* Virtual Method Tables******************************************************/
+
+static struct IStreamVtbl RtlMemoryStreamVtbl = {
+    RtlQueryInterfaceMemoryStream,
+    RtlAddRefMemoryStream,
+    RtlReleaseMemoryStream,
+    RtlReadMemoryStream,
+    RtlWriteMemoryStream,
+    RtlSeekMemoryStream,
+    RtlSetMemoryStreamSize,
+    RtlCopyMemoryStreamTo,
+    RtlCommitMemoryStream,
+    RtlRevertMemoryStream,
+    RtlLockMemoryStreamRegion,
+    RtlUnlockMemoryStreamRegion,
+    RtlStatMemoryStream,
+    RtlCloneMemoryStream,
+};
+
+struct IStreamVtbl RtlOutOfProcessMemoryStreamVtbl = {
+    RtlQueryInterfaceMemoryStream,
+    RtlAddRefMemoryStream,
+    RtlReleaseMemoryStream,
+    RtlReadOutOfProcessMemoryStream,
+    RtlWriteMemoryStream,
+    RtlSeekMemoryStream,
+    RtlSetMemoryStreamSize,
+    RtlCopyOutOfProcessMemoryStreamTo,
+    RtlCommitMemoryStream,
+    RtlRevertMemoryStream,
+    RtlLockMemoryStreamRegion,
+    RtlUnlockMemoryStreamRegion,
+    RtlStatMemoryStream,
+    RtlCloneMemoryStream,
+};
+
+/* FUNCTIONS *****************************************************************/
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+RtlInitMemoryStream(PRTL_MEMORY_STREAM stream)
+{
+    if(!stream) return;
+    
+    RtlZeroMemory(stream, sizeof(RTL_MEMORY_STREAM));
+    stream->lpVtbl = &RtlMemoryStreamVtbl;
+}
+
+/*
+ * @unimplemented
+ */
+VOID
+NTAPI
+RtlInitOutOfProcessMemoryStream(PRTL_MEMORY_STREAM stream)
+{
+    if(!stream) return;
+    
+    RtlZeroMemory(stream, sizeof(RTL_MEMORY_STREAM));
+    stream->lpVtbl = &RtlOutOfProcessMemoryStreamVtbl;
+    stream->FinalRelease = RtlFinalReleaseOutOfProcessMemoryStream;
+}
+
+/*
+ * @unimplemented
+ */
+VOID
+NTAPI
+RtlFinalReleaseOutOfProcessMemoryStream(PRTL_MEMORY_STREAM stream)
+{
+    UNIMPLEMENTED;
+}
+
+/*
+ * @implemented
+ */
+HRESULT
+NTAPI
+RtlQueryInterfaceMemoryStream( 
+    _In_ IStream * This,
+    _In_ REFIID riid,
+    _Outptr_result_maybenull_ PVOID *ppvObject)
+{
+    if (IsEqualGUID(&IID_IUnknown, riid) 
+     || IsEqualGUID(&IID_ISequentialStream, riid)
+     || IsEqualGUID(&IID_IStream, riid)) {
+        IStream_AddRef(This);
+        *ppvObject = This;
+        return S_OK;
+    }
+
+    *ppvObject = NULL;
+    return E_NOINTERFACE;
+}
+
+/*
+ * @implemented
+ */
+ULONG
+NTAPI
+RtlAddRefMemoryStream( 
+    _In_ IStream * This)
+{
+    PRTL_MEMORY_STREAM pstream = (PRTL_MEMORY_STREAM)This;
+    
+    pstream->RefCount++;
+    
+    return 2;
+}
+
+ULONG
+NTAPI
+RtlReleaseMemoryStream( 
+    _In_ IStream * This)
+{
+    PRTL_MEMORY_STREAM pstream = (PRTL_MEMORY_STREAM)This;
+    
+    pstream->RefCount--;
+    
+    if(pstream->RefCount == 0)
+    {
+        if(pstream->FinalRelease)
+            pstream->FinalRelease(pstream);
+    }
+    
+    return pstream->RefCount;
+}
+
+/*
+ * @implemented
+ */
+HRESULT
+NTAPI
+RtlReadMemoryStream( 
+    _In_ IStream * This,
+    _Out_writes_bytes_(cb) PVOID pv,
+    _In_ ULONG cb,
+    _Out_opt_ PULONG pcbRead)
+{
+    ULONG copyLength;
+    PRTL_MEMORY_STREAM pstream = (PRTL_MEMORY_STREAM)This;
+    SIZE_T available = pstream->End-pstream->Current;
+    
+    if (pcbRead) *pcbRead = 0;
+        
+    if (!cb) return S_OK;
+    
+    copyLength = available < cb ? available : cb;
+        
+    RtlMoveMemory(pv, pstream->Current, copyLength);
+    
+    pstream->Current += copyLength;
+    
+    if (pcbRead) *pcbRead = copyLength;
+    
+    return S_OK;
+}
+
+/*
+ * @implemented
+ */
+HRESULT
+NTAPI
+RtlReadOutOfProcessMemoryStream( 
+    _In_ IStream * This,
+    _Out_writes_bytes_(cb) PVOID pv,
+    _In_ ULONG cb,
+    _Out_opt_ PULONG pcbRead)
+{
+    ULONG copyLength;
+    HRESULT res;
+    PRTL_MEMORY_STREAM pstream = (PRTL_MEMORY_STREAM)This;
+    SIZE_T available = pstream->End-pstream->Current;
+    
+    if(pcbRead) *pcbRead = 0;
+        
+    if (!cb) return S_OK;
+    
+    copyLength = available < cb ? available : cb;
+        
+    res = NtReadVirtualMemory(pstream->HProcess, pstream->Current, pv, copyLength, pcbRead);
+    
+    if(res == STATUS_SUCCESS)
+        pstream->Current += copyLength;
+    
+    return HRESULT_FROM_WIN32(RtlNtStatusToDosError(res));
+}
+
+/*
+ * @implemented
+ */
+HRESULT
+NTAPI
+RtlSeekMemoryStream( 
+    _In_ IStream * This,
+    _In_ LARGE_INTEGER dlibMove,
+    _In_ DWORD dwOrigin,
+    _Out_opt_ PULARGE_INTEGER plibNewPosition)
+{
+    PRTL_MEMORY_STREAM pstream = (PRTL_MEMORY_STREAM)This;
+    
+    switch(dwOrigin)
+    {
+        case STREAM_SEEK_SET:
+            pstream->Current = pstream->Start + (SIZE_T)dlibMove.QuadPart;
+            break;
+            
+        case STREAM_SEEK_CUR:
+            pstream->Current = pstream->Current + (SIZE_T)dlibMove.QuadPart;
+            break;
+        
+        case STREAM_SEEK_END:
+            pstream->Current = pstream->End + (SIZE_T)dlibMove.QuadPart;
+            break;
+            
+        default:
+            return E_INVALIDARG;
+    }
+    
+    if(plibNewPosition)
+    {
+        plibNewPosition->QuadPart = pstream->Current - pstream->Start;
+    }
+    
+    return S_OK;
+}
+
+/*
+ * @implemented
+ */
+HRESULT
+NTAPI
+RtlCopyMemoryStreamTo( 
+    _In_ IStream * This,
+    _In_ IStream * pstm,
+    _In_ ULARGE_INTEGER cb,
+    _Out_opt_ PULARGE_INTEGER pcbRead,
+    _Out_opt_ PULARGE_INTEGER pcbWritten)
+{
+    char copyBuff[1024];
+    ULONGLONG ulSize;
+    HRESULT hRet = S_OK;
+
+    if (pcbRead)
+        pcbRead->QuadPart = 0;
+    if (pcbWritten)
+        pcbWritten->QuadPart = 0;
+
+    if (!pstm)
+        return S_OK;
+
+    if (!cb.QuadPart)
+        return S_OK;
+
+    /* Copy data */
+    ulSize = cb.QuadPart;
+    while (ulSize)
+    {
+        ULONG ulLeft, ulAmt;
+
+        ulLeft = ulSize > sizeof(copyBuff) ? sizeof(copyBuff) : ulSize;
+
+        /* Read */
+        hRet = IStream_Read(This, copyBuff, ulLeft, &ulAmt);
+        if (pcbRead)
+            pcbRead->QuadPart += ulAmt;
+        if (FAILED(hRet) || ulAmt != ulLeft)
+            break;
+
+        /* Write */
+        hRet = IStream_Write(pstm, copyBuff, ulLeft, &ulAmt);
+        if (pcbWritten)
+            pcbWritten->QuadPart += ulAmt;
+        if (FAILED(hRet) || ulAmt != ulLeft)
+            break;
+
+        ulSize -= ulLeft;
+    }
+    return hRet;
+}
+
+/*
+ * @implemented
+ */
+HRESULT
+NTAPI
+RtlCopyOutOfProcessMemoryStreamTo( 
+    _In_ IStream * This,
+    _In_ IStream * pstm,
+    _In_ ULARGE_INTEGER cb,
+    _Out_opt_ PULARGE_INTEGER pcbRead,
+    _Out_opt_ PULARGE_INTEGER pcbWritten)
+{
+    return RtlCopyMemoryStreamTo(This, pstm, cb, pcbRead, pcbWritten);
+}
+
+/*
+ * @implemented
+ */
+HRESULT
+NTAPI
+RtlStatMemoryStream( 
+    _In_ IStream * This,
+    _Out_ STATSTG * pstatstg,
+    _In_ DWORD grfStatFlag)
+{
+    PRTL_MEMORY_STREAM pstream = (PRTL_MEMORY_STREAM)This;
+    
+    if (!pstatstg) return STG_E_INVALIDPOINTER;
+
+    ZeroMemory(pstatstg, sizeof(STATSTG));
+    pstatstg->type = STGTY_STREAM;
+    pstatstg->cbSize.QuadPart = pstream->End - pstream->Start;
+
+    return S_OK;
+}
+
+// Dummy functions
+
+/*
+ * @implemented
+ */
+HRESULT
+NTAPI
+RtlWriteMemoryStream( 
+    _In_ IStream * This,
+    _In_reads_bytes_(cb) const void * pv,
+    _In_ ULONG cb,
+    _Out_opt_ PULONG pcbWritten)
+{
+    // Dummy
+    return E_NOTIMPL;
+}
+
+HRESULT
+NTAPI
+RtlSetMemoryStreamSize( 
+    _In_ IStream * This,
+    _In_ ULARGE_INTEGER libNewSize)
+{
+    // Dummy
+    return E_NOTIMPL;
+}
+
+/*
+ * @implemented
+ */
+HRESULT
+NTAPI
+RtlCommitMemoryStream( 
+    _In_ IStream * This,
+    _In_ DWORD grfCommitFlags)
+{
+    // Dummy
+    return E_NOTIMPL;
+}
+
+/*
+ * @implemented
+ */
+HRESULT
+NTAPI
+RtlRevertMemoryStream( 
+    _In_ IStream * This)
+{
+    // Dummy
+    return E_NOTIMPL;
+}
+
+/*
+ * @implemented
+ */
+HRESULT
+NTAPI
+RtlLockMemoryStreamRegion( 
+    _In_ IStream * This,
+    _In_ ULARGE_INTEGER libOffset,
+    _In_ ULARGE_INTEGER cb,
+    _In_ DWORD dwLockType)
+{
+    // Dummy
+    return E_NOTIMPL;
+}
+
+/*
+ * @implemented
+ */
+HRESULT
+NTAPI
+RtlUnlockMemoryStreamRegion( 
+    _In_ IStream * This,
+    _In_ ULARGE_INTEGER libOffset,
+    _In_ ULARGE_INTEGER cb,
+    _In_ DWORD dwLockType)
+{
+    // Dummy
+    return E_NOTIMPL;
+}
+
+/*
+ * @implemented
+ */
+HRESULT
+NTAPI
+RtlCloneMemoryStream( 
+    _In_ IStream * This,
+    _Outptr_result_maybenull_ IStream **ppvStream)
+{
+    // Dummy
+    return E_NOTIMPL;
+}
