[NTDLL]
[reactos.git] / reactos / dll / ntdll / ldr / ldrapi.c
index b559e85..e44cd79 100644 (file)
 /* INCLUDES *****************************************************************/
 
 #include <ntdll.h>
+
 #define NDEBUG
 #include <debug.h>
 
 /* GLOBALS *******************************************************************/
 
+LIST_ENTRY LdrpUnloadHead;
 LONG LdrpLoaderLockAcquisitonCount;
 BOOLEAN LdrpShowRecursiveLoads, LdrpBreakOnRecursiveDllLoads;
 UNICODE_STRING LdrApiDefaultExtension = RTL_CONSTANT_STRING(L".DLL");
+ULONG AlternateResourceModuleCount;
 
 /* FUNCTIONS *****************************************************************/
 
-ULONG_PTR
+NTSTATUS
+NTAPI
+LdrFindCreateProcessManifest(IN ULONG Flags,
+                             IN PVOID Image,
+                             IN PVOID IdPath,
+                             IN ULONG IdPathLength,
+                             IN PVOID OutDataEntry)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+LdrDestroyOutOfProcessImage(IN PVOID Image)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+LdrCreateOutOfProcessImage(IN ULONG Flags,
+                           IN HANDLE ProcessHandle,
+                           IN HANDLE DllHandle,
+                           IN PVOID Unknown3)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+LdrAccessOutOfProcessResource(IN PVOID Unknown,
+                              IN PVOID Image,
+                              IN PVOID Unknown1,
+                              IN PVOID Unknown2,
+                              IN PVOID Unknown3)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+VOID
+NTAPI
+LdrSetDllManifestProber(IN PVOID ProberFunction)
+{
+    UNIMPLEMENTED;
+}
+
+BOOLEAN
+NTAPI
+LdrAlternateResourcesEnabled(VOID)
+{
+    /* ReactOS does not support this */
+    return FALSE;
+}
+
 FORCEINLINE
+ULONG_PTR
 LdrpMakeCookie(VOID)
 {
     /* Generate a cookie */
     return (((ULONG_PTR)NtCurrentTeb()->RealClientId.UniqueThread & 0xFFF) << 16) |
-                        _InterlockedIncrement(&LdrpLoaderLockAcquisitonCount);
+                        (_InterlockedIncrement(&LdrpLoaderLockAcquisitonCount) & 0xFFFF);
 }
 
 /*
@@ -149,9 +210,6 @@ LdrLockLoaderLock(IN ULONG Flags,
         return STATUS_INVALID_PARAMETER_3;
     }
 
-    /* Do or Do Not. There is no Try */
-    ASSERT((Disposition != NULL) || !(Flags & LDR_LOCK_LOADER_LOCK_FLAG_TRY_ONLY));
-
     /* If the flag is set, make sure we have a valid pointer to use */
     if ((Flags & LDR_LOCK_LOADER_LOCK_FLAG_TRY_ONLY) && !(Disposition))
     {
@@ -246,6 +304,7 @@ LdrLockLoaderLock(IN ULONG Flags,
  */
 NTSTATUS
 NTAPI
+DECLSPEC_HOTPATCH
 LdrLoadDll(IN PWSTR SearchPath OPTIONAL,
            IN PULONG DllCharacteristics OPTIONAL,
            IN PUNICODE_STRING DllName,
@@ -260,10 +319,8 @@ LdrLoadDll(IN PWSTR SearchPath OPTIONAL,
     PTEB Teb = NtCurrentTeb();
 
     /* Initialize the strings */
+    RtlInitEmptyUnicodeString(&DllString1, StringBuffer, sizeof(StringBuffer));
     RtlInitEmptyUnicodeString(&DllString2, NULL, 0);
-    DllString1.Buffer = StringBuffer;
-    DllString1.Length = 0;
-    DllString1.MaximumLength = sizeof(StringBuffer);
 
     /* Check if the SxS Assemblies specify another file */
     Status = RtlDosApplyFileIsolationRedirection_Ustr(TRUE,
@@ -300,14 +357,14 @@ LdrLoadDll(IN PWSTR SearchPath OPTIONAL,
         if ((ShowSnaps) || (LdrpShowRecursiveLoads) || (LdrpBreakOnRecursiveDllLoads))
         {
             /* Print out debug messages */
-            DPRINT1("[%lx, %lx] LDR: Recursive DLL Load\n",
+            DPRINT1("[%p, %p] LDR: Recursive DLL Load\n",
                     Teb->RealClientId.UniqueProcess,
                     Teb->RealClientId.UniqueThread);
-            DPRINT1("[%lx, %lx]      Previous DLL being loaded \"%wZ\"\n",
+            DPRINT1("[%p, %p]      Previous DLL being loaded \"%wZ\"\n",
                     Teb->RealClientId.UniqueProcess,
                     Teb->RealClientId.UniqueThread,
                     OldTldDll);
-            DPRINT1("[%lx, %lx]      DLL being requested \"%wZ\"\n",
+            DPRINT1("[%p, %p]      DLL being requested \"%wZ\"\n",
                     Teb->RealClientId.UniqueProcess,
                     Teb->RealClientId.UniqueThread,
                     DllName);
@@ -315,13 +372,13 @@ LdrLoadDll(IN PWSTR SearchPath OPTIONAL,
             /* Was it initializing too? */
             if (!LdrpCurrentDllInitializer)
             {
-                DPRINT1("[%lx, %lx] LDR: No DLL Initializer was running\n",
+                DPRINT1("[%p, %p] LDR: No DLL Initializer was running\n",
                         Teb->RealClientId.UniqueProcess,
                         Teb->RealClientId.UniqueThread);
             }
             else
             {
-                DPRINT1("[%lx, %lx]      DLL whose initializer was currently running \"%wZ\"\n",
+                DPRINT1("[%p, %p]      DLL whose initializer was currently running \"%wZ\"\n",
                         Teb->ClientId.UniqueProcess,
                         Teb->ClientId.UniqueThread,
                         &LdrpCurrentDllInitializer->BaseDllName);
@@ -348,8 +405,7 @@ LdrLoadDll(IN PWSTR SearchPath OPTIONAL,
              (Status != STATUS_OBJECT_NAME_NOT_FOUND) &&
              (Status != STATUS_DLL_INIT_FAILED))
     {
-        // 85 == DPFLTR_LDR_ID;
-        DbgPrintEx(85,
+        DbgPrintEx(DPFLTR_LDR_ID,
                    DPFLTR_WARNING_LEVEL,
                    "LDR: %s - failing because LdrpLoadDll(%wZ) returned status %x\n",
                    __FUNCTION__,
@@ -441,8 +497,11 @@ LdrFindEntryForAddress(PVOID Address,
     }
 
     /* Nothing found */
-    // 85 == DPFLTR_LDR_ID;
-    DbgPrintEx(85, DPFLTR_WARNING_LEVEL, "LDR: %s() exiting 0x%08lx\n", __FUNCTION__, STATUS_NO_MORE_ENTRIES);
+    DbgPrintEx(DPFLTR_LDR_ID,
+               DPFLTR_WARNING_LEVEL,
+               "LDR: %s() exiting 0x%08lx\n",
+               __FUNCTION__,
+               STATUS_NO_MORE_ENTRIES);
     return STATUS_NO_MORE_ENTRIES;
 }
 
@@ -773,7 +832,7 @@ LdrVerifyImageMatchesChecksum(IN HANDLE FileHandle,
 {
     FILE_STANDARD_INFORMATION FileStandardInfo;
     PIMAGE_IMPORT_DESCRIPTOR ImportData;
-    PIMAGE_SECTION_HEADER LastSection;
+    PIMAGE_SECTION_HEADER LastSection = NULL;
     IO_STATUS_BLOCK IoStatusBlock;
     PIMAGE_NT_HEADERS NtHeader;
     HANDLE SectionHandle;
@@ -910,7 +969,7 @@ NTSTATUS
 NTAPI
 LdrQueryProcessModuleInformationEx(IN ULONG ProcessId,
                                    IN ULONG Reserved,
-                                   IN PRTL_PROCESS_MODULES ModuleInformation,
+                                   OUT PRTL_PROCESS_MODULES ModuleInformation,
                                    IN ULONG Size,
                                    OUT PULONG ReturnedSize OPTIONAL)
 {
@@ -928,21 +987,21 @@ LdrQueryProcessModuleInformationEx(IN ULONG ProcessId,
     /* Acquire loader lock */
     RtlEnterCriticalSection(NtCurrentPeb()->LoaderLock);
 
-    /* Check if we were given enough space */
-    if (Size < UsedSize)
-    {
-        Status = STATUS_INFO_LENGTH_MISMATCH;
-    }
-    else
-    {
-        ModuleInformation->NumberOfModules = 0;
-        ModulePtr = &ModuleInformation->Modules[0];
-        Status = STATUS_SUCCESS;
-    }
-
-    /* Traverse the list of modules */
     _SEH2_TRY
     {
+        /* Check if we were given enough space */
+        if (Size < UsedSize)
+        {
+            Status = STATUS_INFO_LENGTH_MISMATCH;
+        }
+        else
+        {
+            ModuleInformation->NumberOfModules = 0;
+            ModulePtr = &ModuleInformation->Modules[0];
+            Status = STATUS_SUCCESS;
+        }
+
+        /* Traverse the list of modules */
         ModuleListHead = &NtCurrentPeb()->Ldr->InLoadOrderModuleList;
         Entry = ModuleListHead->Flink;
 
@@ -1044,9 +1103,14 @@ LdrQueryProcessModuleInformation(IN PRTL_PROCESS_MODULES ModuleInformation,
     return LdrQueryProcessModuleInformationEx(0, 0, ModuleInformation, Size, ReturnedSize);
 }
 
+/*
+ * @implemented
+ */
 NTSTATUS
 NTAPI
-LdrEnumerateLoadedModules(BOOLEAN ReservedFlag, PLDR_ENUM_CALLBACK EnumProc, PVOID Context)
+LdrEnumerateLoadedModules(IN BOOLEAN ReservedFlag,
+                          IN PLDR_ENUM_CALLBACK EnumProc,
+                          IN PVOID Context)
 {
     PLIST_ENTRY ListHead, ListEntry;
     PLDR_DATA_TABLE_ENTRY LdrEntry;
@@ -1156,6 +1220,343 @@ LdrDisableThreadCalloutsForDll(IN PVOID BaseAddress)
     return Status;
 }
 
+/*
+ * @implemented
+ */
+NTSTATUS
+NTAPI
+LdrAddRefDll(IN ULONG Flags,
+             IN PVOID BaseAddress)
+{
+    PLDR_DATA_TABLE_ENTRY LdrEntry;
+    NTSTATUS Status = STATUS_SUCCESS;
+    ULONG Cookie;
+    BOOLEAN Locked = FALSE;
+
+    /* Check for invalid flags */
+    if (Flags & ~(LDR_ADDREF_DLL_PIN))
+    {
+        /* Fail with invalid parameter status if so */
+        Status = STATUS_INVALID_PARAMETER;
+        goto quickie;
+    }
+
+    /* Acquire the loader lock if not in init phase */
+    if (!LdrpInLdrInit)
+    {
+        /* Acquire the lock */
+        Status = LdrLockLoaderLock(0, NULL, &Cookie);
+        if (!NT_SUCCESS(Status)) goto quickie;
+        Locked = TRUE;
+    }
+
+    /* Get this module's data table entry */
+    if (LdrpCheckForLoadedDllHandle(BaseAddress, &LdrEntry))
+    {
+        if (!LdrEntry)
+        {
+            /* Shouldn't happen */
+            Status = STATUS_INTERNAL_ERROR;
+            goto quickie;
+        }
+
+        /* If this is not a pinned module */
+        if (LdrEntry->LoadCount != 0xFFFF)
+        {
+            /* Update its load count */
+            if (Flags & LDR_ADDREF_DLL_PIN)
+            {
+                /* Pin it by setting load count to -1 */
+                LdrEntry->LoadCount = 0xFFFF;
+                LdrpUpdateLoadCount2(LdrEntry, LDRP_UPDATE_PIN);
+            }
+            else
+            {
+                /* Increase its load count by one */
+                LdrEntry->LoadCount++;
+                LdrpUpdateLoadCount2(LdrEntry, LDRP_UPDATE_REFCOUNT);
+            }
+
+            /* Clear load in progress */
+            LdrpClearLoadInProgress();
+        }
+    }
+    else
+    {
+        /* There was an error getting this module's handle, return invalid param status */
+        Status = STATUS_INVALID_PARAMETER;
+    }
+
+quickie:
+    /* Check for error case */
+    if (!NT_SUCCESS(Status))
+    {
+        /* Print debug information */
+        if ((ShowSnaps) || ((Status != STATUS_NO_SUCH_FILE) &&
+                            (Status != STATUS_DLL_NOT_FOUND) &&
+                            (Status != STATUS_OBJECT_NAME_NOT_FOUND)))
+        {
+            DPRINT1("LDR: LdrAddRefDll(%p) 0x%08lx\n", BaseAddress, Status);
+        }
+    }
+
+    /* Release the lock if needed */
+    if (Locked) LdrUnlockLoaderLock(LDR_LOCK_LOADER_LOCK_FLAG_RAISE_ON_ERRORS, Cookie);
+    return Status;
+}
+
+/*
+ * @implemented
+ */
+NTSTATUS
+NTAPI
+LdrUnloadDll(IN PVOID BaseAddress)
+{
+    NTSTATUS Status = STATUS_SUCCESS;
+    PPEB Peb = NtCurrentPeb();
+    PLDR_DATA_TABLE_ENTRY LdrEntry, CurrentEntry;
+    PVOID EntryPoint;
+    PLIST_ENTRY NextEntry;
+    LIST_ENTRY UnloadList;
+    RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED ActCtx;
+    PVOID CorImageData;
+    ULONG ComSectionSize;
+
+    /* Get the LDR Lock */
+    if (!LdrpInLdrInit) RtlEnterCriticalSection(Peb->LoaderLock);
+
+    /* Increase the unload count */
+    LdrpActiveUnloadCount++;
+
+    /* Skip unload */
+    if (LdrpShutdownInProgress) goto Quickie;
+
+    /* Make sure the DLL is valid and get its entry */
+    if (!LdrpCheckForLoadedDllHandle(BaseAddress, &LdrEntry))
+    {
+        Status = STATUS_DLL_NOT_FOUND;
+        goto Quickie;
+    }
+
+    /* Check the current Load Count */
+    if (LdrEntry->LoadCount != 0xFFFF)
+    {
+        /* Decrease it */
+        LdrEntry->LoadCount--;
+
+        /* If it's a dll */
+        if (LdrEntry->Flags & LDRP_IMAGE_DLL)
+        {
+            /* Set up the Act Ctx */
+            ActCtx.Size = sizeof(ActCtx);
+            ActCtx.Format = RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_FORMAT_WHISTLER;
+            RtlZeroMemory(&ActCtx.Frame, sizeof(RTL_ACTIVATION_CONTEXT_STACK_FRAME));
+
+            /* Activate the ActCtx */
+            RtlActivateActivationContextUnsafeFast(&ActCtx,
+                                                   LdrEntry->EntryPointActivationContext);
+
+            /* Update the load count */
+            LdrpUpdateLoadCount2(LdrEntry, LDRP_UPDATE_DEREFCOUNT);
+
+            /* Release the context */
+            RtlDeactivateActivationContextUnsafeFast(&ActCtx);
+        }
+    }
+    else
+    {
+        /* The DLL is locked */
+        goto Quickie;
+    }
+
+    /* Show debug message */
+    if (ShowSnaps) DPRINT1("LDR: UNINIT LIST\n");
+
+    /* Check if this is our only unload and initialize the list if so */
+    if (LdrpActiveUnloadCount == 1) InitializeListHead(&LdrpUnloadHead);
+
+    /* Loop the modules to build the list */
+    NextEntry = Peb->Ldr->InInitializationOrderModuleList.Blink;
+    while (NextEntry != &Peb->Ldr->InInitializationOrderModuleList)
+    {
+        /* Get the entry */
+        LdrEntry = CONTAINING_RECORD(NextEntry,
+                                     LDR_DATA_TABLE_ENTRY,
+                                     InInitializationOrderModuleList);
+        NextEntry = NextEntry->Blink;
+
+        /* Remove flag */
+        LdrEntry->Flags &= ~LDRP_UNLOAD_IN_PROGRESS;
+
+        /* If the load count is now 0 */
+        if (!LdrEntry->LoadCount)
+        {
+            /* Show message */
+            if (ShowSnaps)
+            {
+                DPRINT1("(%lu) [%ws] %ws (%lx) deinit %p\n",
+                        LdrpActiveUnloadCount,
+                        LdrEntry->BaseDllName.Buffer,
+                        LdrEntry->FullDllName.Buffer,
+                        (ULONG)LdrEntry->LoadCount,
+                        LdrEntry->EntryPoint);
+            }
+
+            /* FIXME: Call Shim Engine and notify */
+
+            /* Unlink it */
+            CurrentEntry = LdrEntry;
+            RemoveEntryList(&CurrentEntry->InInitializationOrderModuleList);
+            RemoveEntryList(&CurrentEntry->InMemoryOrderModuleList);
+            RemoveEntryList(&CurrentEntry->HashLinks);
+
+            /* If there's more then one active unload */
+            if (LdrpActiveUnloadCount > 1)
+            {
+                /* Flush the cached DLL handle and clear the list */
+                LdrpLoadedDllHandleCache = NULL;
+                CurrentEntry->InMemoryOrderModuleList.Flink = NULL;
+            }
+
+            /* Add the entry on the unload list */
+            InsertTailList(&LdrpUnloadHead, &CurrentEntry->HashLinks);
+        }
+    }
+
+    /* Only call the entrypoints once */
+    if (LdrpActiveUnloadCount > 1) goto Quickie;
+
+    /* Now loop the unload list and create our own */
+    InitializeListHead(&UnloadList);
+    CurrentEntry = NULL;
+    NextEntry = LdrpUnloadHead.Flink;
+    while (NextEntry != &LdrpUnloadHead)
+    {
+        /* Get the current entry */
+        LdrEntry = CONTAINING_RECORD(NextEntry, LDR_DATA_TABLE_ENTRY, HashLinks);
+
+        /* FIXME: Log the Unload Event */
+        //LdrpRecordUnloadEvent(LdrEntry);
+
+        /* Set the entry and clear it from the list */
+        CurrentEntry = LdrEntry;
+        LdrpLoadedDllHandleCache = NULL;
+        CurrentEntry->InMemoryOrderModuleList.Flink = NULL;
+
+        /* Move it from the global to the local list */
+        RemoveEntryList(&CurrentEntry->HashLinks);
+        InsertTailList(&UnloadList, &CurrentEntry->HashLinks);
+
+        /* Get the entrypoint */
+        EntryPoint = LdrEntry->EntryPoint;
+
+        /* Check if we should call it */
+        if ((EntryPoint) && (LdrEntry->Flags & LDRP_PROCESS_ATTACH_CALLED))
+        {
+            /* Show message */
+            if (ShowSnaps)
+            {
+                DPRINT1("LDR: Calling deinit %p\n", EntryPoint);
+            }
+
+            /* Set up the Act Ctx */
+            ActCtx.Size = sizeof(ActCtx);
+            ActCtx.Format = RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_FORMAT_WHISTLER;
+            RtlZeroMemory(&ActCtx.Frame, sizeof(RTL_ACTIVATION_CONTEXT_STACK_FRAME));
+
+            /* Activate the ActCtx */
+            RtlActivateActivationContextUnsafeFast(&ActCtx,
+                                                   LdrEntry->EntryPointActivationContext);
+
+            /* Call the entrypoint */
+            LdrpCallInitRoutine(LdrEntry->EntryPoint,
+                                LdrEntry->DllBase,
+                                DLL_PROCESS_DETACH,
+                                NULL);
+
+            /* Release the context */
+            RtlDeactivateActivationContextUnsafeFast(&ActCtx);
+        }
+
+        /* Remove it from the list */
+        RemoveEntryList(&CurrentEntry->InLoadOrderLinks);
+        CurrentEntry = NULL;
+        NextEntry = LdrpUnloadHead.Flink;
+    }
+
+    /* Now loop our local list */
+    NextEntry = UnloadList.Flink;
+    while (NextEntry != &UnloadList)
+    {
+        /* Get the entry */
+        LdrEntry = CONTAINING_RECORD(NextEntry, LDR_DATA_TABLE_ENTRY, HashLinks);
+        NextEntry = NextEntry->Flink;
+        CurrentEntry = LdrEntry;
+
+        /* Notify Application Verifier */
+        if (Peb->NtGlobalFlag & FLG_HEAP_ENABLE_TAIL_CHECK)
+        {
+            DPRINT1("We don't support Application Verifier yet\n");
+        }
+
+        /* Show message */
+        if (ShowSnaps)
+        {
+            DPRINT1("LDR: Unmapping [%ws]\n", LdrEntry->BaseDllName.Buffer);
+        }
+
+        /* Check if this is a .NET executable */
+        CorImageData = RtlImageDirectoryEntryToData(LdrEntry->DllBase,
+                                                    TRUE,
+                                                    IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR,
+                                                    &ComSectionSize);
+        if (CorImageData)
+        {
+            /* FIXME */
+            DPRINT1(".NET Images are not supported yet\n");
+        }
+
+        /* Check if we should unmap*/
+        if (!(CurrentEntry->Flags & LDR_COR_OWNS_UNMAP))
+        {
+            /* Unmap the DLL */
+            Status = NtUnmapViewOfSection(NtCurrentProcess(),
+                                          CurrentEntry->DllBase);
+            ASSERT(NT_SUCCESS(Status));
+        }
+
+        /* Unload the alternate resource module, if any */
+        LdrUnloadAlternateResourceModule(CurrentEntry->DllBase);
+
+        /* FIXME: Send shutdown notification */
+        //LdrpSendDllNotifications(CurrentEntry, 2, LdrpShutdownInProgress);
+
+        /* Check if a Hotpatch is active */
+        if (LdrEntry->PatchInformation)
+        {
+            /* FIXME */
+            DPRINT1("We don't support Hotpatching yet\n");
+        }
+
+        /* Deallocate the Entry */
+        LdrpFinalizeAndDeallocateDataTableEntry(CurrentEntry);
+
+        /* If this is the cached entry, invalidate it */
+        if (LdrpGetModuleHandleCache == CurrentEntry)
+        {
+            LdrpGetModuleHandleCache = NULL;
+        }
+    }
+
+Quickie:
+    /* Decrease unload count */
+    LdrpActiveUnloadCount--;
+    if (!LdrpInLdrInit) RtlLeaveCriticalSection(Peb->LoaderLock);
+
+    /* Return to caller */
+    return Status;
+}
+
 /*
  * @implemented
  */
@@ -1180,15 +1581,57 @@ LdrProcessRelocationBlock(IN ULONG_PTR Address,
     return LdrProcessRelocationBlockLongLong(Address, Count, TypeOffset, Delta);
 }
 
+/* FIXME: Add to ntstatus.mc */
+#define STATUS_MUI_FILE_NOT_FOUND        ((NTSTATUS)0xC00B0001L)
+
 /*
- * @unimplemented
+ * @implemented
+ */
+NTSTATUS
+NTAPI
+LdrLoadAlternateResourceModule(IN PVOID Module,
+                               IN PWSTR Buffer)
+{
+    /* Is MUI Support enabled? */
+    if (!LdrAlternateResourcesEnabled()) return STATUS_SUCCESS;
+
+    UNIMPLEMENTED;
+    return STATUS_MUI_FILE_NOT_FOUND;
+}
+
+/*
+ * @implemented
  */
 BOOLEAN
 NTAPI
 LdrUnloadAlternateResourceModule(IN PVOID BaseAddress)
 {
-    static BOOLEAN WarnedOnce = FALSE;
-    if (WarnedOnce == FALSE) { UNIMPLEMENTED; WarnedOnce = TRUE; }
+    ULONG_PTR Cookie;
+
+    /* Acquire the loader lock */
+    LdrLockLoaderLock(LDR_LOCK_LOADER_LOCK_FLAG_RAISE_ON_ERRORS, NULL, &Cookie);
+
+    /* Check if there's any alternate resources loaded */
+    if (AlternateResourceModuleCount)
+    {
+        UNIMPLEMENTED;
+    }
+
+    /* Release the loader lock */
+    LdrUnlockLoaderLock(1, Cookie);
+
+    /* All done */
+    return TRUE;
+}
+
+/*
+ * @unimplemented
+ */
+BOOLEAN
+NTAPI
+LdrFlushAlternateResourceModules(VOID)
+{
+    UNIMPLEMENTED;
     return FALSE;
 }