mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
[FREELDR] peloader.c: Minor code enhancements.
PeLdrCheckForLoadedDll(): - Use a for-loop to iterate over the linked list. - Adjust few comments. - Use SAL2 annotations. PeLdrpCompareDllName(): - Make its input paramters const. - Use SAL2 annotations.
This commit is contained in:
parent
4d376dfd64
commit
ba342e1d14
2 changed files with 24 additions and 26 deletions
|
@ -63,9 +63,9 @@ PeLdrScanImportDescriptorTable(
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
PeLdrCheckForLoadedDll(
|
PeLdrCheckForLoadedDll(
|
||||||
IN OUT PLIST_ENTRY ModuleListHead,
|
_Inout_ PLIST_ENTRY ModuleListHead,
|
||||||
IN PCH DllName,
|
_In_ PCSTR DllName,
|
||||||
OUT PLDR_DATA_TABLE_ENTRY *LoadedEntry);
|
_Out_ PLDR_DATA_TABLE_ENTRY* LoadedEntry);
|
||||||
|
|
||||||
PVOID
|
PVOID
|
||||||
PeLdrInitSecurityCookie(
|
PeLdrInitSecurityCookie(
|
||||||
|
|
|
@ -74,11 +74,11 @@ PeLdrpFetchAddressOfSecurityCookie(PVOID BaseAddress, ULONG SizeOfImage)
|
||||||
return Cookie;
|
return Cookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DllName - physical, UnicodeString->Buffer - virtual */
|
/* DllName: physical, UnicodeString->Buffer: virtual */
|
||||||
static BOOLEAN
|
static BOOLEAN
|
||||||
PeLdrpCompareDllName(
|
PeLdrpCompareDllName(
|
||||||
IN PCH DllName,
|
_In_ PCSTR DllName,
|
||||||
IN PUNICODE_STRING UnicodeName)
|
_In_ PCUNICODE_STRING UnicodeName)
|
||||||
{
|
{
|
||||||
PWSTR Buffer;
|
PWSTR Buffer;
|
||||||
SIZE_T i, Length;
|
SIZE_T i, Length;
|
||||||
|
@ -92,8 +92,8 @@ PeLdrpCompareDllName(
|
||||||
UnicodeNamePA.Length = UnicodeName->Length;
|
UnicodeNamePA.Length = UnicodeName->Length;
|
||||||
UnicodeNamePA.MaximumLength = UnicodeName->MaximumLength;
|
UnicodeNamePA.MaximumLength = UnicodeName->MaximumLength;
|
||||||
UnicodeNamePA.Buffer = VaToPa(UnicodeName->Buffer);
|
UnicodeNamePA.Buffer = VaToPa(UnicodeName->Buffer);
|
||||||
TRACE("PeLdrpCompareDllName: %s and %wZ, Length = %d "
|
TRACE("PeLdrpCompareDllName: %s and %wZ, Length = %d, UN->Length %d\n",
|
||||||
"UN->Length %d\n", DllName, &UnicodeNamePA, Length, UnicodeName->Length);
|
DllName, &UnicodeNamePA, Length, UnicodeName->Length);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ PeLdrpCompareDllName(
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Strings don't match, return FALSE */
|
/* Strings don't match */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -582,24 +582,25 @@ PeLdrInitSecurityCookie(PLDR_DATA_TABLE_ENTRY LdrEntry)
|
||||||
return Cookie;
|
return Cookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns TRUE if DLL has already been loaded - looks in LoadOrderList in LPB */
|
/* Returns TRUE if the DLL has already been loaded in the module list */
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
PeLdrCheckForLoadedDll(
|
PeLdrCheckForLoadedDll(
|
||||||
IN OUT PLIST_ENTRY ModuleListHead,
|
_Inout_ PLIST_ENTRY ModuleListHead,
|
||||||
IN PCH DllName,
|
_In_ PCSTR DllName,
|
||||||
OUT PLDR_DATA_TABLE_ENTRY *LoadedEntry)
|
_Out_ PLDR_DATA_TABLE_ENTRY* LoadedEntry)
|
||||||
{
|
{
|
||||||
|
PLIST_ENTRY ModuleEntry;
|
||||||
PLDR_DATA_TABLE_ENTRY DataTableEntry;
|
PLDR_DATA_TABLE_ENTRY DataTableEntry;
|
||||||
LIST_ENTRY *ModuleEntry;
|
|
||||||
|
|
||||||
TRACE("PeLdrCheckForLoadedDll: DllName %s\n", DllName);
|
TRACE("PeLdrCheckForLoadedDll: DllName %s\n", DllName);
|
||||||
|
|
||||||
/* Just go through each entry in the LoadOrderList and compare loaded module's
|
/* Go through each entry in the LoadOrderList and
|
||||||
name with a given name */
|
* compare the module's name with the given name */
|
||||||
ModuleEntry = ModuleListHead->Flink;
|
for (ModuleEntry = ModuleListHead->Flink;
|
||||||
while (ModuleEntry != ModuleListHead)
|
ModuleEntry != ModuleListHead;
|
||||||
|
ModuleEntry = ModuleEntry->Flink)
|
||||||
{
|
{
|
||||||
/* Get pointer to the current DTE */
|
/* Get a pointer to the current DTE */
|
||||||
DataTableEntry = CONTAINING_RECORD(ModuleEntry,
|
DataTableEntry = CONTAINING_RECORD(ModuleEntry,
|
||||||
LDR_DATA_TABLE_ENTRY,
|
LDR_DATA_TABLE_ENTRY,
|
||||||
InLoadOrderLinks);
|
InLoadOrderLinks);
|
||||||
|
@ -612,16 +613,13 @@ PeLdrCheckForLoadedDll(
|
||||||
/* Compare names */
|
/* Compare names */
|
||||||
if (PeLdrpCompareDllName(DllName, &DataTableEntry->BaseDllName))
|
if (PeLdrpCompareDllName(DllName, &DataTableEntry->BaseDllName))
|
||||||
{
|
{
|
||||||
/* Yes, found it, report pointer to the loaded module's DTE
|
/* Found it, return a pointer to the loaded module's
|
||||||
to the caller and increase load count for it */
|
* DTE to the caller and increase its load count */
|
||||||
*LoadedEntry = DataTableEntry;
|
*LoadedEntry = DataTableEntry;
|
||||||
DataTableEntry->LoadCount++;
|
DataTableEntry->LoadCount++;
|
||||||
TRACE("PeLdrCheckForLoadedDll: LoadedEntry 0x%p\n", DataTableEntry);
|
TRACE("PeLdrCheckForLoadedDll: LoadedEntry 0x%p\n", DataTableEntry);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Go to the next entry */
|
|
||||||
ModuleEntry = ModuleEntry->Flink;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Nothing found */
|
/* Nothing found */
|
||||||
|
|
Loading…
Reference in a new issue