RtlXxxHashTable Example

Continuing the discussion from Why no one use RtlxxxHashTable?:

int HashTest()
{
	int RetVal = -1;
	PRTL_DYNAMIC_HASH_TABLE pHashTtable = NULL;
	RTL_DYNAMIC_HASH_TABLE_ENTRY Entry1, Entry2, Entry3, *ResultHash;
	ULONG_PTR Sig1, Sig2, Sig3;

	if (!RtlCreateHashTable(&pHashTtable, 0, 0))
	{
		goto Exit;
	}

	for (; pHashTtable->TableSize < 8192;)
	{
		RtlExpandHashTable(pHashTtable);
	}

	Sig1 = (ULONG_PTR)1234;
	Sig2 = (ULONG_PTR)5678;
	Sig3 = (ULONG_PTR)9876;

	if (!RtlInsertEntryHashTable(pHashTtable, &Entry1, Sig1, NULL))
	{
		goto Exit;
	}

	if (!RtlInsertEntryHashTable(pHashTtable, &Entry2, Sig2, NULL))
	{
		goto Exit;
	}

	if (!RtlInsertEntryHashTable(pHashTtable, &Entry3, Sig3, NULL))
	{
		goto Exit;
	}

	ResultHash = RtlLookupEntryHashTable(pHashTtable, (ULONG_PTR)Sig3, NULL);
	if (ResultHash != &Entry3)
	{
		goto Exit;
	}

	ResultHash = RtlLookupEntryHashTable(pHashTtable, (ULONG_PTR)Sig2, NULL);
	if (ResultHash != &Entry2)
	{
		goto Exit;
	}

	ResultHash = RtlLookupEntryHashTable(pHashTtable, (ULONG_PTR)Sig1, NULL);
	if (ResultHash != &Entry1)
	{
		goto Exit;
	}


	RetVal = 0;
Exit:
	RtlDeleteHashTable(pHashTtable);
	return RetVal;
}

[Mods added: Edited to make it code... Please, learn to use Markdown.]