-
-
Save yardenshafir/5feb09151236f115204cd20c83326d40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NTSTATUS ExRegisterHost(_Out_ PHOST_LIST_ENTRY ExtensionHost, _In_ ULONG Unused, _In_ PHOST_INFORMATION HostInformation) | |
{ | |
NTSTATUS Status = STATUS_SUCCESS; | |
// Allocate memory for a new HOST_LIST_ENTRY | |
PHOST_LIST_ENTRY p = ExAllocatePoolWithTag(HostInformation->PoolType, 0x60, 'HExE'); | |
if (p == nullptr) | |
{ | |
return STATUS_INSUFFICIENT_RESOURCES; | |
} | |
// | |
// Initialize a new HOST_LIST_ENTRY | |
// | |
p->Flags &= 0xFE; | |
p->RefCount = 1; | |
p->FunctionTable = 0; | |
p->ExtensionId = HostInformation->ExtensionId; | |
p->ExtensionVersion = HostInformation->ExtensionVersion; | |
p->hostInterface = HostInformation->hostInterface; | |
p->FunctionAddress = HostInformation->FunctionAddress; | |
p->ArgForFunction = HostInformation->ArgForFunction; | |
p->Lock = 0; | |
p->RundownRef = 0; | |
// Search for an existing listEntry with the same version and id. | |
PHOST_LIST_ENTRY listEntry = ExpFindHost(HostInformation->ExtensionId, HostInformation->ExtensionVersion); | |
if (listEntry) | |
{ | |
Status = STATUS_OBJECT_NAME_COLLISION; | |
ExpDereferenceHost(p); | |
ExpDereferenceHost(listEntry); | |
} | |
else | |
{ | |
// Insert the new HOST_LIST_ENTRY to the end of ExpHostList. | |
if ( *lastHostListEntry != &firstHostListEntry ) | |
{ | |
__fastfail(); | |
} | |
firstHostListEntry->Prev = &p; | |
p->Next = firstHostListEntry; | |
lastHostListEntry = p; | |
ExtensionHost = p; | |
} | |
return Status; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment