Author: ion
Date: Sun Jul 10 13:23:19 2011
New Revision: 52603
URL:
http://svn.reactos.org/svn/reactos?rev=52603&view=rev
Log:
[NTDLL]: More fixes to the PE parsing code.
[NTDLL]: Move and fix LdrUnloadDll to ldrapi.c
[NTDLL]: Remove yet another cruft file.
Modified:
trunk/reactos/dll/ntdll/include/ntdllp.h
trunk/reactos/dll/ntdll/ldr/ldrapi.c
trunk/reactos/dll/ntdll/ldr/ldrpe.c
trunk/reactos/dll/ntdll/ldr/ldrutils.c
trunk/reactos/dll/ntdll/ntdll.rbuild
Modified: trunk/reactos/dll/ntdll/include/ntdllp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/include/ntdllp.h…
==============================================================================
--- trunk/reactos/dll/ntdll/include/ntdllp.h [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/include/ntdllp.h [iso-8859-1] Sun Jul 10 13:23:19 2011
@@ -9,6 +9,7 @@
/* INCLUDES ******************************************************************/
#define LDR_HASH_TABLE_ENTRIES 32
+#define LDR_GET_HASH_ENTRY(x) (RtlUpcaseUnicodeChar((x)) & (LDR_HASH_TABLE_ENTRIES -
1))
/* LdrpUpdateLoadCount2 flags */
#define LDRP_UPDATE_REFCOUNT 0x01
@@ -41,7 +42,7 @@
extern ULONG LdrpActiveUnloadCount;
extern BOOLEAN LdrpShutdownInProgress;
extern UNICODE_STRING LdrpKnownDllPath;
-extern PLDR_DATA_TABLE_ENTRY LdrpGetModuleHandleCache;
+extern PLDR_DATA_TABLE_ENTRY LdrpGetModuleHandleCache, LdrpLoadedDllHandleCache;
/* ldrinit.c */
NTSTATUS NTAPI LdrpRunInitializeRoutines(IN PCONTEXT Context OPTIONAL);
@@ -153,6 +154,10 @@
OUT PLDR_DATA_TABLE_ENTRY *DataTableEntry,
OUT PBOOLEAN Existing);
+VOID
+NTAPI
+LdrpFinalizeAndDeallocateDataTableEntry(IN PLDR_DATA_TABLE_ENTRY Entry);
+
extern HANDLE WindowsApiPort;
/* EOF */
Modified: trunk/reactos/dll/ntdll/ldr/ldrapi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ldr/ldrapi.c?rev…
==============================================================================
--- trunk/reactos/dll/ntdll/ldr/ldrapi.c [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/ldr/ldrapi.c [iso-8859-1] Sun Jul 10 13:23:19 2011
@@ -15,6 +15,7 @@
/* GLOBALS *******************************************************************/
+LIST_ENTRY LdrpUnloadHead;
LONG LdrpLoaderLockAcquisitonCount;
BOOLEAN LdrpShowRecursiveLoads, LdrpBreakOnRecursiveDllLoads;
UNICODE_STRING LdrApiDefaultExtension = RTL_CONSTANT_STRING(L".DLL");
@@ -1044,9 +1045,14 @@
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;
@@ -1244,6 +1250,270 @@
/*
* @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 != -1)
+ {
+ /* 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(ActCtx));
+
+ /* 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("(%d) [%ws] %ws (%lx) deinit %lx\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)
+ {
+ /* If we have an active entry */
+ if (CurrentEntry)
+ {
+ /* Remove it */
+ RemoveEntryList(&CurrentEntry->InLoadOrderLinks);
+ CurrentEntry = NULL;
+
+ /* Reset list pointers */
+ NextEntry = LdrpUnloadHead.Flink;
+ if (NextEntry == &LdrpUnloadHead) break;
+ }
+
+ /* 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 %lx\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(ActCtx));
+
+ /* 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
+ */
BOOLEAN
NTAPI
RtlDllShutdownInProgress(VOID)
Modified: trunk/reactos/dll/ntdll/ldr/ldrpe.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ldr/ldrpe.c?rev=…
==============================================================================
--- trunk/reactos/dll/ntdll/ldr/ldrpe.c [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/ldr/ldrpe.c [iso-8859-1] Sun Jul 10 13:23:19 2011
@@ -27,21 +27,15 @@
IN PIMAGE_IMPORT_DESCRIPTOR IatEntry,
IN BOOLEAN EntriesValid)
{
- PIMAGE_EXPORT_DIRECTORY ExportDirectory;
- ULONG ExportSize;
PVOID Iat;
- SIZE_T ImportSize;
- ULONG IatSize;
- //PPEB Peb = NtCurrentPeb();
NTSTATUS Status;
PIMAGE_THUNK_DATA OriginalThunk, FirstThunk;
- LPSTR ImportName;
- ULONG ForwarderChain;
PIMAGE_NT_HEADERS NtHeader;
PIMAGE_SECTION_HEADER SectionHeader;
- ULONG i, Rva;
- ULONG OldProtect;
-
+ PIMAGE_EXPORT_DIRECTORY ExportDirectory;
+ LPSTR ImportName;
+ ULONG ForwarderChain, i, Rva, OldProtect, IatSize, ExportSize;
+ SIZE_T ImportSize;
DPRINT("LdrpSnapIAT(%wZ %wZ %p %d)\n", &ExportLdrEntry->BaseDllName,
&ImportLdrEntry->BaseDllName, IatEntry, EntriesValid);
/* Get export directory */
@@ -51,7 +45,13 @@
&ExportSize);
/* Make sure it has one */
- if (!ExportDirectory) return STATUS_INVALID_IMAGE_FORMAT;
+ if (!ExportDirectory)
+ {
+ /* Fail */
+ DbgPrint("LDR: %wZ doesn't contain an EXPORT table\n",
+ &ExportLdrEntry->BaseDllName);
+ return STATUS_INVALID_IMAGE_FORMAT;
+ }
/* Get the IAT */
Iat = RtlImageDirectoryEntryToData(ImportLdrEntry->DllBase,
@@ -65,6 +65,7 @@
{
/* Get the NT Header and the first section */
NtHeader = RtlImageNtHeader(ImportLdrEntry->DllBase);
+ if (!NtHeader) return STATUS_INVALID_IMAGE_FORMAT;
SectionHeader = IMAGE_FIRST_SECTION(NtHeader);
/* Get the RVA of the import directory */
@@ -89,8 +90,7 @@
IatSize = SectionHeader->Misc.VirtualSize;
/* Deal with Watcom and other retarded compilers */
- if (!IatSize)
- IatSize = SectionHeader->SizeOfRawData;
+ if (!IatSize) IatSize = SectionHeader->SizeOfRawData;
/* Found it, get out */
break;
@@ -102,7 +102,14 @@
}
/* If we still don't have an IAT, that's bad */
- if (!Iat) return STATUS_INVALID_IMAGE_FORMAT;
+ if (!Iat)
+ {
+ /* Fail */
+ DbgPrint("LDR: Unable to unprotect IAT for %wZ (Image Base %p)\n",
+ &ImportLdrEntry->BaseDllName,
+ ImportLdrEntry->DllBase);
+ return STATUS_INVALID_IMAGE_FORMAT;
+ }
/* Set the right size */
ImportSize = IatSize;
@@ -114,7 +121,14 @@
&ImportSize,
PAGE_READWRITE,
&OldProtect);
- if (!NT_SUCCESS(Status)) return Status;
+ if (!NT_SUCCESS(Status))
+ {
+ /* Fail */
+ DbgPrint("LDR: Unable to unprotect IAT for %wZ (Status %x)\n",
+ &ImportLdrEntry->BaseDllName,
+ Status);
+ return Status;
+ }
/* Check if the Thunks are already valid */
if (EntriesValid)
@@ -400,6 +414,7 @@
if (Stale)
{
/* It was, so find the IAT entry for it */
+ ++LdrpNormalSnap;
ImportEntry = RtlImageDirectoryEntryToData(LdrEntry->DllBase,
TRUE,
IMAGE_DIRECTORY_ENTRY_IMPORT,
Modified: trunk/reactos/dll/ntdll/ldr/ldrutils.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ldr/ldrutils.c?r…
==============================================================================
--- trunk/reactos/dll/ntdll/ldr/ldrutils.c [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/ldr/ldrutils.c [iso-8859-1] Sun Jul 10 13:23:19 2011
@@ -15,10 +15,7 @@
/* GLOBALS *******************************************************************/
-LIST_ENTRY LdrpUnloadHead;
PLDR_DATA_TABLE_ENTRY LdrpLoadedDllHandleCache, LdrpGetModuleHandleCache;
-
-#define LDR_GET_HASH_ENTRY(x) (RtlUpcaseUnicodeChar((x)) & (LDR_HASH_TABLE_ENTRIES -
1))
/* FUNCTIONS *****************************************************************/
@@ -283,35 +280,39 @@
/* Protect against invalid pointers */
_SEH2_TRY
{
- /* Make sure it's valid and we have an array */
- Array = (PIMAGE_TLS_CALLBACK *)TlsDirectory->AddressOfCallBacks;
- if ((TlsDirectory) && (Array))
- {
- /* Display debug */
- if (ShowSnaps)
- {
- DPRINT1("LDR: Tls Callbacks Found. Imagebase %p Tls %p CallBacks
%p\n",
- BaseAddress, TlsDirectory, Array);
- }
-
- /* Loop the array */
- while (*Array)
- {
- /* Get the TLS Entrypoint */
- Callback = *Array++;
-
+ /* Make sure it's valid */
+ if (TlsDirectory)
+ {
+ /* Get the array */
+ Array = (PIMAGE_TLS_CALLBACK *)TlsDirectory->AddressOfCallBacks;
+ if (Array)
+ {
/* Display debug */
if (ShowSnaps)
{
- DPRINT1("LDR: Calling Tls Callback Imagebase %p Function
%p\n",
- BaseAddress, Callback);
+ DPRINT1("LDR: Tls Callbacks Found. Imagebase %p Tls %p CallBacks
%p\n",
+ BaseAddress, TlsDirectory, Array);
}
- /* Call it */
- LdrpCallInitRoutine((PDLL_INIT_ROUTINE)Callback,
- BaseAddress,
- Reason,
- NULL);
+ /* Loop the array */
+ while (*Array)
+ {
+ /* Get the TLS Entrypoint */
+ Callback = *Array++;
+
+ /* Display debug */
+ if (ShowSnaps)
+ {
+ DPRINT1("LDR: Calling Tls Callback Imagebase %p Function
%p\n",
+ BaseAddress, Callback);
+ }
+
+ /* Call it */
+ LdrpCallInitRoutine((PDLL_INIT_ROUTINE)Callback,
+ BaseAddress,
+ Reason,
+ NULL);
+ }
}
}
}
@@ -2050,272 +2051,6 @@
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 = 1;
- 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 */
- if (LdrpActiveUnloadCount == 1)
- {
- /* Initialize the unload list */
- 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("(%d) [%ws] %ws (%lx) deinit %lx\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)
- {
- /* If we have an active entry */
- if (CurrentEntry)
- {
- /* Remove it */
- RemoveEntryList(&CurrentEntry->InLoadOrderLinks);
- CurrentEntry = NULL;
-
- /* Reset list pointers */
- NextEntry = LdrpUnloadHead.Flink;
- if (NextEntry == &LdrpUnloadHead) break;
- }
-
- /* Get the current entry */
- LdrEntry = CONTAINING_RECORD(NextEntry, LDR_DATA_TABLE_ENTRY, HashLinks);
-
- /* 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 %lx\n", EntryPoint);
- }
-
- /* Set up the Act Ctx */
- ActCtx.Size = sizeof(ActCtx);
- ActCtx.Format = 1;
- 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 */
- if ((CorImageData = RtlImageDirectoryEntryToData(LdrEntry->DllBase,
- TRUE,
-
IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR,
- &ComSectionSize)))
- {
- /* 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);
- }
-
- /* Unload the alternate resource module, if any */
- LdrUnloadAlternateResourceModule(CurrentEntry->DllBase);
-
- /* 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, invalide it */
- if (LdrpGetModuleHandleCache == CurrentEntry)
- {
- LdrpGetModuleHandleCache = NULL;
- }
- }
-
-Quickie:
- /* Decrease unload count */
- LdrpActiveUnloadCount--;
- if (!LdrpInLdrInit) RtlLeaveCriticalSection(Peb->LoaderLock);
-
- /* FIXME: Rundown the Hotpatch data, if present */
-
- /* Return to caller */
- return Status;
-}
-
ULONG
NTAPI
LdrpClearLoadInProgress(VOID)
Modified: trunk/reactos/dll/ntdll/ntdll.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ntdll.rbuild?rev…
==============================================================================
--- trunk/reactos/dll/ntdll/ntdll.rbuild [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/ntdll.rbuild [iso-8859-1] Sun Jul 10 13:23:19 2011
@@ -51,7 +51,6 @@
<file>ldrinit.c</file>
<file>ldrpe.c</file>
<file>ldrutils.c</file>
- <file>actctx.c</file>
</directory>
<directory name="rtl">
<file>libsupp.c</file>