Skip to content

Fixed crash on invalid hash table #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions 3rdparty/phnt/include/ntrtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ FORCEINLINE BOOLEAN RemoveEntryList(
_In_ PLIST_ENTRY Entry
)
{
PLIST_ENTRY Blink;
PLIST_ENTRY Flink;
if (!Entry) return FALSE;

PLIST_ENTRY Blink = Entry->Blink;
PLIST_ENTRY Flink = Entry->Flink;

if (!Blink || !Flink) return FALSE;

Flink = Entry->Flink;
Blink = Entry->Blink;
Blink->Flink = Flink;
Flink->Blink = Blink;

Entry->Flink = NULL;
Entry->Blink = NULL;
return Flink == Blink;
}

Expand Down
5 changes: 4 additions & 1 deletion MemoryModule/LdrEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,12 @@ NTSTATUS NTAPI RtlGetReferenceCount(
VOID NTAPI RtlInsertMemoryTableEntry(_In_ PLDR_DATA_TABLE_ENTRY LdrEntry) {
PPEB_LDR_DATA PebData = NtCurrentPeb()->Ldr;
PLIST_ENTRY LdrpHashTable = MmpGlobalDataPtr->MmpLdrEntry->LdrpHashTable;
ULONG i;

/* Validate hash table */
if (!MmpGlobalDataPtr->MmpLdrEntry->LdrpHashTable) return;

/* Insert into hash table */
ULONG i;
i = LdrHashEntry(LdrEntry->BaseDllName);
InsertTailList(&LdrpHashTable[i], &LdrEntry->HashLinks);

Expand Down