Improve comments, consistency and API

This commit is contained in:
Odd Stranne
2021-04-21 13:35:10 +02:00
parent a470a01c67
commit 18b8664f32
3 changed files with 27 additions and 9 deletions

View File

@@ -190,6 +190,15 @@ Reset
break;
}
//
// It's believed that `InnerDeleteEntry` will never fail as long as
// the following conditions are met:
//
// - The tree's CompareRoutine and FreeRoutine are correctly implemented.
// - Nodes in the tree are regarded as internally consistent by tree CompareRoutine.
// - `entry` argument is valid.
//
InnerDeleteEntry(Context, entry);
}
}
@@ -301,19 +310,26 @@ FindEntry
return (PROCESS_REGISTRY_ENTRY*)RtlLookupElementGenericTableAvl(&Context->Tree, &record);
}
void
bool
DeleteEntry
(
CONTEXT *Context,
PROCESS_REGISTRY_ENTRY *Entry
)
{
ForEach(Context, ClearDepartingParentLink, Entry->ProcessId);
const auto processId = Entry->ProcessId;
InnerDeleteEntry(Context, Entry);
const auto status = InnerDeleteEntry(Context, Entry);
if (status)
{
ForEach(Context, ClearDepartingParentLink, processId);
}
return status;
}
void
bool
DeleteEntryById
(
CONTEXT *Context,
@@ -322,10 +338,12 @@ DeleteEntryById
{
auto entry = FindEntry(Context, ProcessId);
if (entry != NULL)
if (entry == NULL)
{
DeleteEntry(Context, entry);
return false;
}
return DeleteEntry(Context, entry);
}
bool

View File

@@ -122,14 +122,14 @@ FindEntry
HANDLE ProcessId
);
void
bool
DeleteEntry
(
CONTEXT *Context,
PROCESS_REGISTRY_ENTRY *Entry
);
void
bool
DeleteEntryById
(
CONTEXT *Context,

View File

@@ -411,7 +411,7 @@ HandleProcessDeparting
WdfSpinLockAcquire(processRegistry->Lock);
procregistry::DeleteEntry(processRegistry->Instance, registryEntry);
NT_ASSERT(procregistry::DeleteEntry(processRegistry->Instance, registryEntry));
WdfSpinLockRelease(processRegistry->Lock);
}